|
|
@@ -1,6 +1,5 @@
|
|
|
package cn.iocoder.yudao.module.iscs.service.notifyconfig;
|
|
|
|
|
|
-import cn.hutool.json.JSONArray;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
import cn.iocoder.yudao.module.iscs.controller.admin.jobticket.vo.JobTicketUserRespVO;
|
|
|
@@ -22,6 +21,8 @@ import cn.iocoder.yudao.module.system.service.user.AdminUserService;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import jakarta.annotation.Resource;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
@@ -125,7 +126,7 @@ public class NotifyConfigServiceImpl extends ServiceImpl<NotifyConfigMapper, Not
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Boolean insertMessByRule(MessSaveVO vo) {
|
|
|
+ public Boolean insertMessByRule(MessSaveVO vo) throws JsonProcessingException {
|
|
|
// 1.先查询当前操作在isc_notify_config中有没有值
|
|
|
NotifyConfigDO notifyConfigDO = getOne(Wrappers.<NotifyConfigDO>lambdaQuery()
|
|
|
.eq(NotifyConfigDO::getSopId, vo.getSopId())
|
|
|
@@ -139,11 +140,11 @@ public class NotifyConfigServiceImpl extends ServiceImpl<NotifyConfigMapper, Not
|
|
|
// 3.1提前
|
|
|
beforeSend(notifyConfigDO.getId(), vo.getTicketId(), vo.getShouldSendTime(), notifyConfigDO.getNotifyTime(), vo.getTemplateParams());
|
|
|
}
|
|
|
- if (notifyConfigDO.getNotifyTimeType().equals(0)) {
|
|
|
+ if (notifyConfigDO.getNotifyTimeType().equals(1)) {
|
|
|
// 3.2立即
|
|
|
immediatelySend(notifyConfigDO.getId(), vo.getTicketId(), vo.getTemplateParams());
|
|
|
}
|
|
|
- if (notifyConfigDO.getNotifyTimeType().equals(0)) {
|
|
|
+ if (notifyConfigDO.getNotifyTimeType().equals(2)) {
|
|
|
// 3.3延后
|
|
|
delaySend(notifyConfigDO.getId(), vo.getTicketId(), vo.getShouldSendTime(), notifyConfigDO.getNotifyTime(), vo.getTemplateParams());
|
|
|
}
|
|
|
@@ -151,6 +152,8 @@ public class NotifyConfigServiceImpl extends ServiceImpl<NotifyConfigMapper, Not
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+
|
|
|
/**
|
|
|
* 提前发送的消息
|
|
|
*
|
|
|
@@ -161,7 +164,8 @@ public class NotifyConfigServiceImpl extends ServiceImpl<NotifyConfigMapper, Not
|
|
|
* @param templateParams 参数模板
|
|
|
* @return
|
|
|
*/
|
|
|
- private Boolean beforeSend(Long notifyConfigId, Long ticketId, LocalDateTime shouldSendTime, Integer secondsToSubtract, Map<String, Object> templateParams) {
|
|
|
+ private Boolean beforeSend(Long notifyConfigId, Long ticketId, LocalDateTime shouldSendTime, Integer secondsToSubtract, Map<String, Object> templateParams) throws JsonProcessingException {
|
|
|
+
|
|
|
// 查询规则详情-启用的
|
|
|
List<NotifyConfigDetailDO> notifyConfigDetailDOS = notifyConfigDetailService.list(Wrappers.<NotifyConfigDetailDO>lambdaQuery()
|
|
|
.eq(NotifyConfigDetailDO::getConfigId, notifyConfigId)
|
|
|
@@ -197,7 +201,7 @@ public class NotifyConfigServiceImpl extends ServiceImpl<NotifyConfigMapper, Not
|
|
|
notifyMessagePlanDO.setTemplateNickname(notifyTemplateByCodeFromCache.getNickname());
|
|
|
notifyMessagePlanDO.setTemplateContent(notifyTemplateService.formatNotifyTemplateContent(notifyTemplateByCodeFromCache.getContent(), templateParams));
|
|
|
notifyMessagePlanDO.setTemplateType(notifyTemplateByCodeFromCache.getType());
|
|
|
- notifyMessagePlanDO.setTemplateParams(new JSONArray(notifyTemplateByCodeFromCache.getParams()).toString());
|
|
|
+ notifyMessagePlanDO.setTemplateParams(objectMapper.writeValueAsString(templateParams));
|
|
|
notifyMessagePlanDO.setPlanSendTime(shouldSendTime.minusSeconds(secondsToSubtract));
|
|
|
notifyMessagePlanDO.setSendStatus(0);
|
|
|
notifyMessagePlanService.save(notifyMessagePlanDO);
|
|
|
@@ -218,7 +222,7 @@ public class NotifyConfigServiceImpl extends ServiceImpl<NotifyConfigMapper, Not
|
|
|
notifyMessagePlanDO.setTemplateNickname(notifyTemplateByCodeFromCache.getNickname());
|
|
|
notifyMessagePlanDO.setTemplateContent(notifyTemplateService.formatNotifyTemplateContent(notifyTemplateByCodeFromCache.getContent(), templateParams));
|
|
|
notifyMessagePlanDO.setTemplateType(notifyTemplateByCodeFromCache.getType());
|
|
|
- notifyMessagePlanDO.setTemplateParams(new JSONArray(notifyTemplateByCodeFromCache.getParams()).toString());
|
|
|
+ notifyMessagePlanDO.setTemplateParams(objectMapper.writeValueAsString(templateParams));
|
|
|
notifyMessagePlanDO.setPlanSendTime(shouldSendTime.minusSeconds(secondsToSubtract));
|
|
|
notifyMessagePlanDO.setSendStatus(0);
|
|
|
notifyMessagePlanService.save(notifyMessagePlanDO);
|
|
|
@@ -301,7 +305,7 @@ public class NotifyConfigServiceImpl extends ServiceImpl<NotifyConfigMapper, Not
|
|
|
* @param templateParams 参数模板
|
|
|
* @return
|
|
|
*/
|
|
|
- private Boolean delaySend(Long notifyConfigId, Long ticketId, LocalDateTime shouldSendTime, Integer secondsToSubtract, Map<String, Object> templateParams) {
|
|
|
+ private Boolean delaySend(Long notifyConfigId, Long ticketId, LocalDateTime shouldSendTime, Integer secondsToSubtract, Map<String, Object> templateParams) throws JsonProcessingException {
|
|
|
// 查询规则详情-启用的
|
|
|
List<NotifyConfigDetailDO> notifyConfigDetailDOS = notifyConfigDetailService.list(Wrappers.<NotifyConfigDetailDO>lambdaQuery()
|
|
|
.eq(NotifyConfigDetailDO::getConfigId, notifyConfigId)
|
|
|
@@ -337,7 +341,7 @@ public class NotifyConfigServiceImpl extends ServiceImpl<NotifyConfigMapper, Not
|
|
|
notifyMessagePlanDO.setTemplateNickname(notifyTemplateByCodeFromCache.getNickname());
|
|
|
notifyMessagePlanDO.setTemplateContent(notifyTemplateService.formatNotifyTemplateContent(notifyTemplateByCodeFromCache.getContent(), templateParams));
|
|
|
notifyMessagePlanDO.setTemplateType(notifyTemplateByCodeFromCache.getType());
|
|
|
- notifyMessagePlanDO.setTemplateParams(new JSONArray(notifyTemplateByCodeFromCache.getParams()).toString());
|
|
|
+ notifyMessagePlanDO.setTemplateParams(objectMapper.writeValueAsString(templateParams));
|
|
|
notifyMessagePlanDO.setPlanSendTime(shouldSendTime.plusSeconds(secondsToSubtract));
|
|
|
notifyMessagePlanDO.setSendStatus(0);
|
|
|
notifyMessagePlanService.save(notifyMessagePlanDO);
|
|
|
@@ -358,7 +362,7 @@ public class NotifyConfigServiceImpl extends ServiceImpl<NotifyConfigMapper, Not
|
|
|
notifyMessagePlanDO.setTemplateNickname(notifyTemplateByCodeFromCache.getNickname());
|
|
|
notifyMessagePlanDO.setTemplateContent(notifyTemplateService.formatNotifyTemplateContent(notifyTemplateByCodeFromCache.getContent(), templateParams));
|
|
|
notifyMessagePlanDO.setTemplateType(notifyTemplateByCodeFromCache.getType());
|
|
|
- notifyMessagePlanDO.setTemplateParams(new JSONArray(notifyTemplateByCodeFromCache.getParams()).toString());
|
|
|
+ notifyMessagePlanDO.setTemplateParams(objectMapper.writeValueAsString(templateParams));
|
|
|
notifyMessagePlanDO.setPlanSendTime(shouldSendTime.minusSeconds(secondsToSubtract));
|
|
|
notifyMessagePlanDO.setSendStatus(0);
|
|
|
notifyMessagePlanService.save(notifyMessagePlanDO);
|