fix: 去除警告⚠️
This commit is contained in:
parent
b2469cb1c4
commit
ed211e2e5d
|
@ -10,6 +10,7 @@ import io.metersphere.commons.utils.SessionUtils;
|
||||||
import io.metersphere.notice.controller.request.MessageRequest;
|
import io.metersphere.notice.controller.request.MessageRequest;
|
||||||
import io.metersphere.notice.domain.MessageDetail;
|
import io.metersphere.notice.domain.MessageDetail;
|
||||||
import io.metersphere.notice.domain.MessageSettingDetail;
|
import io.metersphere.notice.domain.MessageSettingDetail;
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@ -27,59 +28,49 @@ public class NoticeService {
|
||||||
|
|
||||||
|
|
||||||
public void saveMessageTask(MessageRequest messageRequest) {
|
public void saveMessageTask(MessageRequest messageRequest) {
|
||||||
SessionUser user = SessionUtils.getUser();
|
|
||||||
String orgId = user.getLastOrganizationId();
|
|
||||||
long time = System.currentTimeMillis();
|
|
||||||
messageRequest.getMessageDetail().forEach(list -> {
|
messageRequest.getMessageDetail().forEach(list -> {
|
||||||
MessageTaskExample example = new MessageTaskExample();
|
MessageTaskExample example = new MessageTaskExample();
|
||||||
example.createCriteria().andIdentificationEqualTo(list.getIdentification());
|
example.createCriteria().andIdentificationEqualTo(list.getIdentification());
|
||||||
List<MessageTask> messageTaskLists = messageTaskMapper.selectByExample(example);
|
List<MessageTask> messageTaskLists = messageTaskMapper.selectByExample(example);
|
||||||
if (messageTaskLists.size() > 0) {
|
if (messageTaskLists.size() > 0) {
|
||||||
delMessage(list.getIdentification());
|
delMessage(list.getIdentification());
|
||||||
String identification = UUID.randomUUID().toString();
|
getSaveMessageTask(list);
|
||||||
list.getUserIds().forEach(m -> {
|
}
|
||||||
MessageTask message = new MessageTask();
|
if (messageTaskLists.size() <= 0) {
|
||||||
message.setId(UUID.randomUUID().toString());
|
getSaveMessageTask(list);
|
||||||
message.setEvent(list.getEvent());
|
}
|
||||||
message.setTaskType(list.getTaskType());
|
|
||||||
message.setUserId(m);
|
|
||||||
message.setType(list.getType());
|
|
||||||
message.setWebhook(list.getWebhook());
|
|
||||||
message.setIdentification(identification);
|
|
||||||
message.setIsSet(list.getIsSet());
|
|
||||||
message.setOrganizationId(orgId);
|
|
||||||
message.setTestId(list.getTestId());
|
|
||||||
message.setCreateTime(time);
|
|
||||||
messageTaskMapper.insert(message);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
String identification = UUID.randomUUID().toString();
|
|
||||||
list.getUserIds().forEach(m -> {
|
|
||||||
MessageTask message = new MessageTask();
|
|
||||||
message.setId(UUID.randomUUID().toString());
|
|
||||||
message.setEvent(list.getEvent());
|
|
||||||
message.setTaskType(list.getTaskType());
|
|
||||||
message.setUserId(m);
|
|
||||||
message.setType(list.getType());
|
|
||||||
message.setWebhook(list.getWebhook());
|
|
||||||
message.setIdentification(identification);
|
|
||||||
message.setIsSet(list.getIsSet());
|
|
||||||
message.setOrganizationId(orgId);
|
|
||||||
message.setTestId(list.getTestId());
|
|
||||||
message.setCreateTime(time);
|
|
||||||
messageTaskMapper.insert(message);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void getSaveMessageTask(MessageDetail list) {
|
||||||
|
SessionUser user = SessionUtils.getUser();
|
||||||
|
assert user != null;
|
||||||
|
String orgId = user.getLastOrganizationId();
|
||||||
|
long time = System.currentTimeMillis();
|
||||||
|
String identification = UUID.randomUUID().toString();
|
||||||
|
list.getUserIds().forEach(m -> {
|
||||||
|
MessageTask message = new MessageTask();
|
||||||
|
message.setId(UUID.randomUUID().toString());
|
||||||
|
message.setEvent(list.getEvent());
|
||||||
|
message.setTaskType(list.getTaskType());
|
||||||
|
message.setUserId(m);
|
||||||
|
message.setType(list.getType());
|
||||||
|
message.setWebhook(list.getWebhook());
|
||||||
|
message.setIdentification(identification);
|
||||||
|
message.setIsSet(list.getIsSet());
|
||||||
|
message.setOrganizationId(orgId);
|
||||||
|
message.setTestId(list.getTestId());
|
||||||
|
message.setCreateTime(time);
|
||||||
|
messageTaskMapper.insert(message);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MessageDetail> searchMessageSchedule(String testId) {
|
public List<MessageDetail> searchMessageSchedule(String testId) {
|
||||||
List<MessageTask> messageTaskLists = extMessageMapper.searchMessageByTestId(testId);
|
List<MessageTask> messageTaskLists = extMessageMapper.searchMessageByTestId(testId);
|
||||||
List<MessageDetail> scheduleMessageTask = new ArrayList<>();
|
List<MessageDetail> scheduleMessageTask = new ArrayList<>();
|
||||||
Map<String, List<MessageTask>> MessageTaskMap = messageTaskLists.stream().collect(Collectors.groupingBy(e -> e.getIdentification()));
|
Map<String, List<MessageTask>> MessageTaskMap = messageTaskLists.stream().collect(Collectors.groupingBy(MessageTask::getIdentification));
|
||||||
MessageTaskMap.forEach((k, v) -> {
|
MessageTaskMap.forEach((k, v) -> {
|
||||||
Set userIds = new HashSet();
|
Set<String> userIds = new HashSet<>();
|
||||||
MessageDetail messageDetail = new MessageDetail();
|
MessageDetail messageDetail = new MessageDetail();
|
||||||
for (MessageTask m : v) {
|
for (MessageTask m : v) {
|
||||||
userIds.add(m.getUserId());
|
userIds.add(m.getUserId());
|
||||||
|
@ -91,8 +82,8 @@ public class NoticeService {
|
||||||
messageDetail.setIsSet(m.getIsSet());
|
messageDetail.setIsSet(m.getIsSet());
|
||||||
messageDetail.setCreateTime(m.getCreateTime());
|
messageDetail.setCreateTime(m.getCreateTime());
|
||||||
}
|
}
|
||||||
if (userIds != null || !"".equals(userIds)) {
|
if (CollectionUtils.isNotEmpty(userIds)) {
|
||||||
messageDetail.setUserIds(new ArrayList(userIds));
|
messageDetail.setUserIds(new ArrayList<>(userIds));
|
||||||
}
|
}
|
||||||
scheduleMessageTask.add(messageDetail);
|
scheduleMessageTask.add(messageDetail);
|
||||||
});
|
});
|
||||||
|
@ -102,14 +93,15 @@ public class NoticeService {
|
||||||
|
|
||||||
public MessageSettingDetail searchMessage() {
|
public MessageSettingDetail searchMessage() {
|
||||||
SessionUser user = SessionUtils.getUser();
|
SessionUser user = SessionUtils.getUser();
|
||||||
|
assert user != null;
|
||||||
String orgId = user.getLastOrganizationId();
|
String orgId = user.getLastOrganizationId();
|
||||||
List<MessageTask> messageTaskLists = new ArrayList<>();
|
List<MessageTask> messageTaskLists;
|
||||||
MessageSettingDetail messageSettingDetail = new MessageSettingDetail();
|
MessageSettingDetail messageSettingDetail = new MessageSettingDetail();
|
||||||
List<MessageDetail> MessageDetailList = new ArrayList<>();
|
List<MessageDetail> MessageDetailList = new ArrayList<>();
|
||||||
messageTaskLists = extMessageMapper.searchMessageByOrganizationId(orgId);
|
messageTaskLists = extMessageMapper.searchMessageByOrganizationId(orgId);
|
||||||
Map<String, List<MessageTask>> MessageTaskMap = messageTaskLists.stream().collect(Collectors.groupingBy(e -> fetchGroupKey(e)));
|
Map<String, List<MessageTask>> MessageTaskMap = messageTaskLists.stream().collect(Collectors.groupingBy(NoticeService::fetchGroupKey));
|
||||||
MessageTaskMap.forEach((k, v) -> {
|
MessageTaskMap.forEach((k, v) -> {
|
||||||
Set userIds = new HashSet();
|
Set<String> userIds = new HashSet<>();
|
||||||
MessageDetail messageDetail = new MessageDetail();
|
MessageDetail messageDetail = new MessageDetail();
|
||||||
for (MessageTask m : v) {
|
for (MessageTask m : v) {
|
||||||
userIds.add(m.getUserId());
|
userIds.add(m.getUserId());
|
||||||
|
@ -121,17 +113,13 @@ public class NoticeService {
|
||||||
messageDetail.setIsSet(m.getIsSet());
|
messageDetail.setIsSet(m.getIsSet());
|
||||||
messageDetail.setCreateTime(m.getCreateTime());
|
messageDetail.setCreateTime(m.getCreateTime());
|
||||||
}
|
}
|
||||||
messageDetail.setUserIds(new ArrayList(userIds));
|
messageDetail.setUserIds(new ArrayList<String>(userIds));
|
||||||
MessageDetailList.add(messageDetail);
|
MessageDetailList.add(messageDetail);
|
||||||
});
|
});
|
||||||
List<MessageDetail> jenkinsTask = MessageDetailList.stream().filter(a -> a.getTaskType().equals(NoticeConstants.JENKINS_TASK)).collect(Collectors.toList());
|
List<MessageDetail> jenkinsTask = MessageDetailList.stream().filter(a -> a.getTaskType().equals(NoticeConstants.JENKINS_TASK)).sorted(Comparator.comparing(MessageDetail::getCreateTime, Comparator.nullsLast(Long::compareTo)).reversed()).collect(Collectors.toList());
|
||||||
jenkinsTask.sort(Comparator.comparing(MessageDetail::getCreateTime, Comparator.nullsLast(Long::compareTo)).reversed());
|
List<MessageDetail> testCasePlanTask = MessageDetailList.stream().filter(a -> a.getTaskType().equals(NoticeConstants.TEST_PLAN_TASK)).sorted(Comparator.comparing(MessageDetail::getCreateTime, Comparator.nullsLast(Long::compareTo)).reversed()).collect(Collectors.toList());
|
||||||
List<MessageDetail> testCasePlanTask = MessageDetailList.stream().filter(a -> a.getTaskType().equals(NoticeConstants.TEST_PLAN_TASK)).collect(Collectors.toList());
|
List<MessageDetail> reviewTask = MessageDetailList.stream().filter(a -> a.getTaskType().equals(NoticeConstants.REVIEW_TASK)).sorted(Comparator.comparing(MessageDetail::getCreateTime, Comparator.nullsLast(Long::compareTo)).reversed()).collect(Collectors.toList());
|
||||||
testCasePlanTask.sort(Comparator.comparing(MessageDetail::getCreateTime, Comparator.nullsLast(Long::compareTo)).reversed());
|
List<MessageDetail> defectTask = MessageDetailList.stream().filter(a -> a.getTaskType().equals(NoticeConstants.DEFECT_TASK)).sorted(Comparator.comparing(MessageDetail::getCreateTime, Comparator.nullsLast(Long::compareTo)).reversed()).collect(Collectors.toList());
|
||||||
List<MessageDetail> reviewTask = MessageDetailList.stream().filter(a -> a.getTaskType().equals(NoticeConstants.REVIEW_TASK)).collect(Collectors.toList());
|
|
||||||
reviewTask.sort(Comparator.comparing(MessageDetail::getCreateTime, Comparator.nullsLast(Long::compareTo)).reversed());
|
|
||||||
List<MessageDetail> defectTask = MessageDetailList.stream().filter(a -> a.getTaskType().equals(NoticeConstants.DEFECT_TASK)).collect(Collectors.toList());
|
|
||||||
defectTask.sort(Comparator.comparing(MessageDetail::getCreateTime, Comparator.nullsLast(Long::compareTo)).reversed());
|
|
||||||
messageSettingDetail.setJenkinsTask(jenkinsTask);
|
messageSettingDetail.setJenkinsTask(jenkinsTask);
|
||||||
messageSettingDetail.setTestCasePlanTask(testCasePlanTask);
|
messageSettingDetail.setTestCasePlanTask(testCasePlanTask);
|
||||||
messageSettingDetail.setReviewTask(reviewTask);
|
messageSettingDetail.setReviewTask(reviewTask);
|
||||||
|
|
Loading…
Reference in New Issue