|
|
@@ -1,14 +1,24 @@
|
|
|
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.notifyconfig.vo.NotifyConfigDetailRespVO;
|
|
|
-import cn.iocoder.yudao.module.iscs.controller.admin.notifyconfig.vo.NotifyConfigPageReqVO;
|
|
|
-import cn.iocoder.yudao.module.iscs.controller.admin.notifyconfig.vo.NotifyConfigRespVO;
|
|
|
-import cn.iocoder.yudao.module.iscs.controller.admin.notifyconfig.vo.NotifyConfigSaveReqVO;
|
|
|
+import cn.iocoder.yudao.module.iscs.controller.admin.jobticket.vo.JobTicketUserRespVO;
|
|
|
+import cn.iocoder.yudao.module.iscs.controller.admin.notifyconfig.vo.*;
|
|
|
import cn.iocoder.yudao.module.iscs.dal.dataobject.notifyconfig.NotifyConfigDO;
|
|
|
import cn.iocoder.yudao.module.iscs.dal.dataobject.notifyconfig.NotifyConfigDetailDO;
|
|
|
+import cn.iocoder.yudao.module.iscs.dal.dataobject.notifyconfig.NotifyMessagePlanDO;
|
|
|
import cn.iocoder.yudao.module.iscs.dal.mysql.notifyconfig.NotifyConfigMapper;
|
|
|
+import cn.iocoder.yudao.module.iscs.service.jobticket.JobTicketService;
|
|
|
+import cn.iocoder.yudao.module.iscs.service.jobticket.JobTicketUserService;
|
|
|
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateSendReqVO;
|
|
|
+import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
|
|
|
+import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO;
|
|
|
+import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
|
|
+import cn.iocoder.yudao.module.system.service.notify.NotifySendService;
|
|
|
+import cn.iocoder.yudao.module.system.service.notify.NotifyTemplateService;
|
|
|
+import cn.iocoder.yudao.module.system.service.permission.RoleService;
|
|
|
+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;
|
|
|
@@ -16,7 +26,10 @@ import jakarta.annotation.Resource;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* 通知规则 Service 实现类
|
|
|
@@ -31,6 +44,20 @@ public class NotifyConfigServiceImpl extends ServiceImpl<NotifyConfigMapper, Not
|
|
|
private NotifyConfigMapper notifyConfigMapper;
|
|
|
@Resource
|
|
|
private NotifyConfigDetailService notifyConfigDetailService;
|
|
|
+ @Resource
|
|
|
+ private RoleService roleService;
|
|
|
+ @Resource
|
|
|
+ private JobTicketService jobTicketService;
|
|
|
+ @Resource
|
|
|
+ private NotifySendService notifySendService;
|
|
|
+ @Resource
|
|
|
+ private NotifyTemplateService notifyTemplateService;
|
|
|
+ @Resource
|
|
|
+ private JobTicketUserService jobTicketUserService;
|
|
|
+ @Resource
|
|
|
+ private NotifyMessagePlanService notifyMessagePlanService;
|
|
|
+ @Resource
|
|
|
+ private AdminUserService adminUserService;
|
|
|
|
|
|
@Override
|
|
|
public Long createNotifyConfig(NotifyConfigSaveReqVO createReqVO) {
|
|
|
@@ -38,9 +65,9 @@ public class NotifyConfigServiceImpl extends ServiceImpl<NotifyConfigMapper, Not
|
|
|
NotifyConfigDO notifyConfig = BeanUtils.toBean(createReqVO, NotifyConfigDO.class);
|
|
|
notifyConfigMapper.insert(notifyConfig);
|
|
|
// 开始新增detail
|
|
|
- if (!createReqVO.getNotifyConfigDetailSaveReqVOS().isEmpty()) {
|
|
|
- createReqVO.getNotifyConfigDetailSaveReqVOS().forEach( item -> item.setConfigId(notifyConfig.getId()));
|
|
|
- notifyConfigDetailService.insertOrUpdateList(BeanUtils.toBean(createReqVO.getNotifyConfigDetailSaveReqVOS(), NotifyConfigDetailDO.class));
|
|
|
+ if (createReqVO.getNotifyConfigDetailRespVOList() != null && !createReqVO.getNotifyConfigDetailRespVOList().isEmpty()) {
|
|
|
+ createReqVO.getNotifyConfigDetailRespVOList().forEach( item -> item.setConfigId(notifyConfig.getId()));
|
|
|
+ notifyConfigDetailService.insertOrUpdateList(BeanUtils.toBean(createReqVO.getNotifyConfigDetailRespVOList(), NotifyConfigDetailDO.class));
|
|
|
}
|
|
|
|
|
|
// 返回
|
|
|
@@ -53,9 +80,9 @@ public class NotifyConfigServiceImpl extends ServiceImpl<NotifyConfigMapper, Not
|
|
|
NotifyConfigDO updateObj = BeanUtils.toBean(updateReqVO, NotifyConfigDO.class);
|
|
|
notifyConfigMapper.updateById(updateObj);
|
|
|
// 开始新增detail
|
|
|
- if (!updateReqVO.getNotifyConfigDetailSaveReqVOS().isEmpty()) {
|
|
|
- updateReqVO.getNotifyConfigDetailSaveReqVOS().forEach( item -> item.setConfigId(updateObj.getId()));
|
|
|
- notifyConfigDetailService.insertOrUpdateList(BeanUtils.toBean(updateReqVO.getNotifyConfigDetailSaveReqVOS(), NotifyConfigDetailDO.class));
|
|
|
+ if (updateReqVO.getNotifyConfigDetailRespVOList() != null && !updateReqVO.getNotifyConfigDetailRespVOList().isEmpty()) {
|
|
|
+ updateReqVO.getNotifyConfigDetailRespVOList().forEach( item -> item.setConfigId(updateObj.getId()));
|
|
|
+ notifyConfigDetailService.insertOrUpdateList(BeanUtils.toBean(updateReqVO.getNotifyConfigDetailRespVOList(), NotifyConfigDetailDO.class));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -97,4 +124,246 @@ public class NotifyConfigServiceImpl extends ServiceImpl<NotifyConfigMapper, Not
|
|
|
return respVOPageResult;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Boolean insertMessByRule(MessSaveVO vo) {
|
|
|
+ // 1.先查询当前操作在isc_notify_config中有没有值
|
|
|
+ NotifyConfigDO notifyConfigDO = getOne(Wrappers.<NotifyConfigDO>lambdaQuery()
|
|
|
+ .eq(NotifyConfigDO::getSopId, vo.getSopId())
|
|
|
+ .eq(NotifyConfigDO::getType, vo.getType())
|
|
|
+ .eq(NotifyConfigDO::getRule, vo.getRule())
|
|
|
+ .eq(NotifyConfigDO::getStatus, 1));
|
|
|
+ // 2.如果有规则,则看下规则详情是什么,先看下是不是提前、立即、延迟
|
|
|
+ if (notifyConfigDO != null) {
|
|
|
+ // 3.根据规则生成时间
|
|
|
+ if (notifyConfigDO.getNotifyTimeType().equals(0)) {
|
|
|
+ // 3.1提前
|
|
|
+ beforeSend(notifyConfigDO.getId(), vo.getTicketId(), vo.getShouldSendTime(), notifyConfigDO.getNotifyTime(), vo.getTemplateParams());
|
|
|
+ }
|
|
|
+ if (notifyConfigDO.getNotifyTimeType().equals(0)) {
|
|
|
+ // 3.2立即
|
|
|
+ immediatelySend(notifyConfigDO.getId(), vo.getTicketId(), vo.getTemplateParams());
|
|
|
+ }
|
|
|
+ if (notifyConfigDO.getNotifyTimeType().equals(0)) {
|
|
|
+ // 3.3延后
|
|
|
+ delaySend(notifyConfigDO.getId(), vo.getTicketId(), vo.getShouldSendTime(), notifyConfigDO.getNotifyTime(), vo.getTemplateParams());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 提前发送的消息
|
|
|
+ * @param notifyConfigId 通知规则id
|
|
|
+ * @param ticketId 作业id
|
|
|
+ * @param shouldSendTime 应该发送时间
|
|
|
+ * @param secondsToSubtract 提前的时间
|
|
|
+ * @param templateParams 参数模板
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Boolean beforeSend(Long notifyConfigId, Long ticketId, LocalDateTime shouldSendTime, Integer secondsToSubtract, Map<String, Object> templateParams) {
|
|
|
+ // 查询规则详情-启用的
|
|
|
+ List<NotifyConfigDetailDO> notifyConfigDetailDOS = notifyConfigDetailService.list(Wrappers.<NotifyConfigDetailDO>lambdaQuery()
|
|
|
+ .eq(NotifyConfigDetailDO::getConfigId, notifyConfigId)
|
|
|
+ .eq(NotifyConfigDetailDO::getStatus, 1)
|
|
|
+ .isNotNull(NotifyConfigDetailDO::getNotifyTemplateCode));
|
|
|
+ // 查询这个作业设置的所有人员
|
|
|
+ List<JobTicketUserRespVO> jobTicketUserRespVOS = jobTicketUserService.listByTicketId(ticketId);
|
|
|
+ if (!notifyConfigDetailDOS.isEmpty() && !jobTicketUserRespVOS.isEmpty()) {
|
|
|
+ // 获取规则详情配置的角色id
|
|
|
+ List<Long> roleIds = notifyConfigDetailDOS.stream().map(NotifyConfigDetailDO::getRoleId).toList();
|
|
|
+ List<RoleDO> roleList = roleService.getRoleList(roleIds);
|
|
|
+ // 循环规则详情,判断是否是发动给当事人
|
|
|
+ for (NotifyConfigDetailDO notifyConfigDetailDO : notifyConfigDetailDOS) {
|
|
|
+ String roleCode = null;
|
|
|
+ for (RoleDO roleDO : roleList) {
|
|
|
+ if (notifyConfigDetailDO.getRoleId().equals(roleDO.getId())) {
|
|
|
+ roleCode = roleDO.getCode();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 获取该详情配置的模板信息
|
|
|
+ NotifyTemplateDO notifyTemplateByCodeFromCache = notifyTemplateService.getNotifyTemplateByCodeFromCache(notifyConfigDetailDO.getNotifyTemplateCode());
|
|
|
+ if (notifyConfigDetailDO.getIsClient().equals(1)) {
|
|
|
+ // 仅仅通知当事人
|
|
|
+ String finalRoleCode = roleCode;
|
|
|
+ List<JobTicketUserRespVO> jobTicketUserRespVOList = jobTicketUserRespVOS.stream().filter(o -> o.getUserRole().equals(finalRoleCode)).toList();
|
|
|
+ for (JobTicketUserRespVO jobTicketUserRespVO : jobTicketUserRespVOList) {
|
|
|
+ // 根据模板生成准备发送的mess
|
|
|
+ NotifyMessagePlanDO notifyMessagePlanDO = new NotifyMessagePlanDO();
|
|
|
+ notifyMessagePlanDO.setUserId(jobTicketUserRespVO.getUserId());
|
|
|
+ notifyMessagePlanDO.setUserType(2);
|
|
|
+ notifyMessagePlanDO.setTemplateId(notifyTemplateByCodeFromCache.getId());
|
|
|
+ notifyMessagePlanDO.setTemplateCode(notifyConfigDetailDO.getNotifyTemplateCode());
|
|
|
+ notifyMessagePlanDO.setTemplateNickname(notifyTemplateByCodeFromCache.getNickname());
|
|
|
+ notifyMessagePlanDO.setTemplateContent(notifyTemplateService.formatNotifyTemplateContent(notifyTemplateByCodeFromCache.getContent(), templateParams));
|
|
|
+ notifyMessagePlanDO.setTemplateType(notifyTemplateByCodeFromCache.getType());
|
|
|
+ notifyMessagePlanDO.setTemplateParams(new JSONArray(notifyTemplateByCodeFromCache.getParams()).toString());
|
|
|
+ notifyMessagePlanDO.setPlanSendTime(shouldSendTime.minusSeconds(secondsToSubtract));
|
|
|
+ notifyMessagePlanDO.setSendStatus(0);
|
|
|
+ notifyMessagePlanService.save(notifyMessagePlanDO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (notifyConfigDetailDO.getIsClient().equals(0)) {
|
|
|
+ // 不仅仅通知当事人
|
|
|
+ ArrayList<Long> longs = new ArrayList<>();
|
|
|
+ longs.add(notifyConfigDetailDO.getRoleId());
|
|
|
+ List<AdminUserDO> userListByRoleIds = adminUserService.getUserListByRoleIds(longs);
|
|
|
+ for (AdminUserDO userListByRoleId : userListByRoleIds) {
|
|
|
+ // 根据模板生成准备发送的mess
|
|
|
+ NotifyMessagePlanDO notifyMessagePlanDO = new NotifyMessagePlanDO();
|
|
|
+ notifyMessagePlanDO.setUserId(userListByRoleId.getId());
|
|
|
+ notifyMessagePlanDO.setUserType(2);
|
|
|
+ notifyMessagePlanDO.setTemplateId(notifyTemplateByCodeFromCache.getId());
|
|
|
+ notifyMessagePlanDO.setTemplateCode(notifyConfigDetailDO.getNotifyTemplateCode());
|
|
|
+ notifyMessagePlanDO.setTemplateNickname(notifyTemplateByCodeFromCache.getNickname());
|
|
|
+ notifyMessagePlanDO.setTemplateContent(notifyTemplateService.formatNotifyTemplateContent(notifyTemplateByCodeFromCache.getContent(), templateParams));
|
|
|
+ notifyMessagePlanDO.setTemplateType(notifyTemplateByCodeFromCache.getType());
|
|
|
+ notifyMessagePlanDO.setTemplateParams(new JSONArray(notifyTemplateByCodeFromCache.getParams()).toString());
|
|
|
+ notifyMessagePlanDO.setPlanSendTime(shouldSendTime.minusSeconds(secondsToSubtract));
|
|
|
+ notifyMessagePlanDO.setSendStatus(0);
|
|
|
+ notifyMessagePlanService.save(notifyMessagePlanDO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 立刻发送的消息
|
|
|
+ * @param notifyConfigId 通知规则id
|
|
|
+ * @param ticketId 作业id
|
|
|
+ * @param templateParams 参数模板
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Boolean immediatelySend(Long notifyConfigId, Long ticketId , Map<String, Object> templateParams) {
|
|
|
+ // 查询规则详情-启用的
|
|
|
+ List<NotifyConfigDetailDO> notifyConfigDetailDOS = notifyConfigDetailService.list(Wrappers.<NotifyConfigDetailDO>lambdaQuery()
|
|
|
+ .eq(NotifyConfigDetailDO::getConfigId, notifyConfigId)
|
|
|
+ .eq(NotifyConfigDetailDO::getStatus, 1)
|
|
|
+ .isNotNull(NotifyConfigDetailDO::getNotifyTemplateCode));
|
|
|
+ // 查询这个作业设置的所有人员
|
|
|
+ List<JobTicketUserRespVO> jobTicketUserRespVOS = jobTicketUserService.listByTicketId(ticketId);
|
|
|
+ if (!notifyConfigDetailDOS.isEmpty() && !jobTicketUserRespVOS.isEmpty()) {
|
|
|
+ // 获取规则详情配置的角色id
|
|
|
+ List<Long> roleIds = notifyConfigDetailDOS.stream().map(NotifyConfigDetailDO::getRoleId).toList();
|
|
|
+ List<RoleDO> roleList = roleService.getRoleList(roleIds);
|
|
|
+ // 循环规则详情,判断是否是发动给当事人
|
|
|
+ for (NotifyConfigDetailDO notifyConfigDetailDO : notifyConfigDetailDOS) {
|
|
|
+ String roleCode = null;
|
|
|
+ for (RoleDO roleDO : roleList) {
|
|
|
+ if (notifyConfigDetailDO.getRoleId().equals(roleDO.getId())) {
|
|
|
+ roleCode = roleDO.getCode();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (notifyConfigDetailDO.getIsClient().equals(1)) {
|
|
|
+ // 仅仅通知当事人
|
|
|
+ String finalRoleCode = roleCode;
|
|
|
+ List<JobTicketUserRespVO> jobTicketUserRespVOList = jobTicketUserRespVOS.stream().filter(o -> o.getUserRole().equals(finalRoleCode)).toList();
|
|
|
+ for (JobTicketUserRespVO jobTicketUserRespVO : jobTicketUserRespVOList) {
|
|
|
+ // 根据模板生成准备发送的mess
|
|
|
+ NotifyTemplateSendReqVO notifyTemplateSendReqVO = new NotifyTemplateSendReqVO();
|
|
|
+ notifyTemplateSendReqVO.setUserId(jobTicketUserRespVO.getUserId());
|
|
|
+ notifyTemplateSendReqVO.setUserType(2);
|
|
|
+ notifyTemplateSendReqVO.setTemplateCode(notifyConfigDetailDO.getNotifyTemplateCode());
|
|
|
+ notifyTemplateSendReqVO.setTemplateParams(templateParams);
|
|
|
+ notifySendService.sendSingleNotifyFromPlan(notifyTemplateSendReqVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (notifyConfigDetailDO.getIsClient().equals(0)) {
|
|
|
+ // 不仅仅通知当事人
|
|
|
+ ArrayList<Long> longs = new ArrayList<>();
|
|
|
+ longs.add(notifyConfigDetailDO.getRoleId());
|
|
|
+ List<AdminUserDO> userListByRoleIds = adminUserService.getUserListByRoleIds(longs);
|
|
|
+ for (AdminUserDO userListByRoleId : userListByRoleIds) {
|
|
|
+ // 根据模板生成准备发送的mess
|
|
|
+ NotifyTemplateSendReqVO notifyTemplateSendReqVO = new NotifyTemplateSendReqVO();
|
|
|
+ notifyTemplateSendReqVO.setUserId(userListByRoleId.getId());
|
|
|
+ notifyTemplateSendReqVO.setUserType(2);
|
|
|
+ notifyTemplateSendReqVO.setTemplateCode(notifyConfigDetailDO.getNotifyTemplateCode());
|
|
|
+ notifyTemplateSendReqVO.setTemplateParams(templateParams);
|
|
|
+ notifySendService.sendSingleNotifyFromPlan(notifyTemplateSendReqVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 推迟发送的消息
|
|
|
+ * @param notifyConfigId 通知规则id
|
|
|
+ * @param ticketId 作业id
|
|
|
+ * @param shouldSendTime 应该发送时间
|
|
|
+ * @param secondsToSubtract 推迟的时间
|
|
|
+ * @param templateParams 参数模板
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Boolean delaySend(Long notifyConfigId, Long ticketId, LocalDateTime shouldSendTime, Integer secondsToSubtract, Map<String, Object> templateParams) {
|
|
|
+ // 查询规则详情-启用的
|
|
|
+ List<NotifyConfigDetailDO> notifyConfigDetailDOS = notifyConfigDetailService.list(Wrappers.<NotifyConfigDetailDO>lambdaQuery()
|
|
|
+ .eq(NotifyConfigDetailDO::getConfigId, notifyConfigId)
|
|
|
+ .eq(NotifyConfigDetailDO::getStatus, 1)
|
|
|
+ .isNotNull(NotifyConfigDetailDO::getNotifyTemplateCode));
|
|
|
+ // 查询这个作业设置的所有人员
|
|
|
+ List<JobTicketUserRespVO> jobTicketUserRespVOS = jobTicketUserService.listByTicketId(ticketId);
|
|
|
+ if (!notifyConfigDetailDOS.isEmpty() && !jobTicketUserRespVOS.isEmpty()) {
|
|
|
+ // 获取规则详情配置的角色id
|
|
|
+ List<Long> roleIds = notifyConfigDetailDOS.stream().map(NotifyConfigDetailDO::getRoleId).toList();
|
|
|
+ List<RoleDO> roleList = roleService.getRoleList(roleIds);
|
|
|
+ // 循环规则详情,判断是否是发动给当事人
|
|
|
+ for (NotifyConfigDetailDO notifyConfigDetailDO : notifyConfigDetailDOS) {
|
|
|
+ String roleCode = null;
|
|
|
+ for (RoleDO roleDO : roleList) {
|
|
|
+ if (notifyConfigDetailDO.getRoleId().equals(roleDO.getId())) {
|
|
|
+ roleCode = roleDO.getCode();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 获取该详情配置的模板信息
|
|
|
+ NotifyTemplateDO notifyTemplateByCodeFromCache = notifyTemplateService.getNotifyTemplateByCodeFromCache(notifyConfigDetailDO.getNotifyTemplateCode());
|
|
|
+ if (notifyConfigDetailDO.getIsClient().equals(1)) {
|
|
|
+ // 仅仅通知当事人
|
|
|
+ String finalRoleCode = roleCode;
|
|
|
+ List<JobTicketUserRespVO> jobTicketUserRespVOList = jobTicketUserRespVOS.stream().filter(o -> o.getUserRole().equals(finalRoleCode)).toList();
|
|
|
+ for (JobTicketUserRespVO jobTicketUserRespVO : jobTicketUserRespVOList) {
|
|
|
+ // 根据模板生成准备发送的mess
|
|
|
+ NotifyMessagePlanDO notifyMessagePlanDO = new NotifyMessagePlanDO();
|
|
|
+ notifyMessagePlanDO.setUserId(jobTicketUserRespVO.getUserId());
|
|
|
+ notifyMessagePlanDO.setUserType(2);
|
|
|
+ notifyMessagePlanDO.setTemplateId(notifyTemplateByCodeFromCache.getId());
|
|
|
+ notifyMessagePlanDO.setTemplateCode(notifyConfigDetailDO.getNotifyTemplateCode());
|
|
|
+ notifyMessagePlanDO.setTemplateNickname(notifyTemplateByCodeFromCache.getNickname());
|
|
|
+ notifyMessagePlanDO.setTemplateContent(notifyTemplateService.formatNotifyTemplateContent(notifyTemplateByCodeFromCache.getContent(), templateParams));
|
|
|
+ notifyMessagePlanDO.setTemplateType(notifyTemplateByCodeFromCache.getType());
|
|
|
+ notifyMessagePlanDO.setTemplateParams(new JSONArray(notifyTemplateByCodeFromCache.getParams()).toString());
|
|
|
+ notifyMessagePlanDO.setPlanSendTime(shouldSendTime.plusSeconds(secondsToSubtract));
|
|
|
+ notifyMessagePlanDO.setSendStatus(0);
|
|
|
+ notifyMessagePlanService.save(notifyMessagePlanDO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (notifyConfigDetailDO.getIsClient().equals(0)) {
|
|
|
+ // 不仅仅通知当事人
|
|
|
+ ArrayList<Long> longs = new ArrayList<>();
|
|
|
+ longs.add(notifyConfigDetailDO.getRoleId());
|
|
|
+ List<AdminUserDO> userListByRoleIds = adminUserService.getUserListByRoleIds(longs);
|
|
|
+ for (AdminUserDO userListByRoleId : userListByRoleIds) {
|
|
|
+ // 根据模板生成准备发送的mess
|
|
|
+ NotifyMessagePlanDO notifyMessagePlanDO = new NotifyMessagePlanDO();
|
|
|
+ notifyMessagePlanDO.setUserId(userListByRoleId.getId());
|
|
|
+ notifyMessagePlanDO.setUserType(2);
|
|
|
+ notifyMessagePlanDO.setTemplateId(notifyTemplateByCodeFromCache.getId());
|
|
|
+ notifyMessagePlanDO.setTemplateCode(notifyConfigDetailDO.getNotifyTemplateCode());
|
|
|
+ notifyMessagePlanDO.setTemplateNickname(notifyTemplateByCodeFromCache.getNickname());
|
|
|
+ notifyMessagePlanDO.setTemplateContent(notifyTemplateService.formatNotifyTemplateContent(notifyTemplateByCodeFromCache.getContent(), templateParams));
|
|
|
+ notifyMessagePlanDO.setTemplateType(notifyTemplateByCodeFromCache.getType());
|
|
|
+ notifyMessagePlanDO.setTemplateParams(new JSONArray(notifyTemplateByCodeFromCache.getParams()).toString());
|
|
|
+ notifyMessagePlanDO.setPlanSendTime(shouldSendTime.minusSeconds(secondsToSubtract));
|
|
|
+ notifyMessagePlanDO.setSendStatus(0);
|
|
|
+ notifyMessagePlanService.save(notifyMessagePlanDO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
}
|