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.domain.MessageDetail;
|
||||
import io.metersphere.notice.domain.MessageSettingDetail;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
@ -27,59 +28,49 @@ public class NoticeService {
|
|||
|
||||
|
||||
public void saveMessageTask(MessageRequest messageRequest) {
|
||||
SessionUser user = SessionUtils.getUser();
|
||||
String orgId = user.getLastOrganizationId();
|
||||
long time = System.currentTimeMillis();
|
||||
messageRequest.getMessageDetail().forEach(list -> {
|
||||
MessageTaskExample example = new MessageTaskExample();
|
||||
example.createCriteria().andIdentificationEqualTo(list.getIdentification());
|
||||
List<MessageTask> messageTaskLists = messageTaskMapper.selectByExample(example);
|
||||
if (messageTaskLists.size() > 0) {
|
||||
delMessage(list.getIdentification());
|
||||
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);
|
||||
});
|
||||
} 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);
|
||||
getSaveMessageTask(list);
|
||||
}
|
||||
if (messageTaskLists.size() <= 0) {
|
||||
getSaveMessageTask(list);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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) {
|
||||
List<MessageTask> messageTaskLists = extMessageMapper.searchMessageByTestId(testId);
|
||||
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) -> {
|
||||
Set userIds = new HashSet();
|
||||
Set<String> userIds = new HashSet<>();
|
||||
MessageDetail messageDetail = new MessageDetail();
|
||||
for (MessageTask m : v) {
|
||||
userIds.add(m.getUserId());
|
||||
|
@ -91,8 +82,8 @@ public class NoticeService {
|
|||
messageDetail.setIsSet(m.getIsSet());
|
||||
messageDetail.setCreateTime(m.getCreateTime());
|
||||
}
|
||||
if (userIds != null || !"".equals(userIds)) {
|
||||
messageDetail.setUserIds(new ArrayList(userIds));
|
||||
if (CollectionUtils.isNotEmpty(userIds)) {
|
||||
messageDetail.setUserIds(new ArrayList<>(userIds));
|
||||
}
|
||||
scheduleMessageTask.add(messageDetail);
|
||||
});
|
||||
|
@ -102,14 +93,15 @@ public class NoticeService {
|
|||
|
||||
public MessageSettingDetail searchMessage() {
|
||||
SessionUser user = SessionUtils.getUser();
|
||||
assert user != null;
|
||||
String orgId = user.getLastOrganizationId();
|
||||
List<MessageTask> messageTaskLists = new ArrayList<>();
|
||||
List<MessageTask> messageTaskLists;
|
||||
MessageSettingDetail messageSettingDetail = new MessageSettingDetail();
|
||||
List<MessageDetail> MessageDetailList = new ArrayList<>();
|
||||
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) -> {
|
||||
Set userIds = new HashSet();
|
||||
Set<String> userIds = new HashSet<>();
|
||||
MessageDetail messageDetail = new MessageDetail();
|
||||
for (MessageTask m : v) {
|
||||
userIds.add(m.getUserId());
|
||||
|
@ -121,17 +113,13 @@ public class NoticeService {
|
|||
messageDetail.setIsSet(m.getIsSet());
|
||||
messageDetail.setCreateTime(m.getCreateTime());
|
||||
}
|
||||
messageDetail.setUserIds(new ArrayList(userIds));
|
||||
messageDetail.setUserIds(new ArrayList<String>(userIds));
|
||||
MessageDetailList.add(messageDetail);
|
||||
});
|
||||
List<MessageDetail> jenkinsTask = MessageDetailList.stream().filter(a -> a.getTaskType().equals(NoticeConstants.JENKINS_TASK)).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)).collect(Collectors.toList());
|
||||
testCasePlanTask.sort(Comparator.comparing(MessageDetail::getCreateTime, Comparator.nullsLast(Long::compareTo)).reversed());
|
||||
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());
|
||||
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());
|
||||
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> reviewTask = MessageDetailList.stream().filter(a -> a.getTaskType().equals(NoticeConstants.REVIEW_TASK)).sorted(Comparator.comparing(MessageDetail::getCreateTime, Comparator.nullsLast(Long::compareTo)).reversed()).collect(Collectors.toList());
|
||||
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());
|
||||
messageSettingDetail.setJenkinsTask(jenkinsTask);
|
||||
messageSettingDetail.setTestCasePlanTask(testCasePlanTask);
|
||||
messageSettingDetail.setReviewTask(reviewTask);
|
||||
|
|
Loading…
Reference in New Issue