Sfoglia il codice sorgente

新增短信模版

wangliang 1 anno fa
parent
commit
5077c33433

+ 18 - 13
sop-business/src/main/java/com/qmth/sop/business/activiti/listener/ProcessEventListener.java

@@ -7,7 +7,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.qmth.sop.business.bean.dto.FlowRejectSequenceDto;
 import com.qmth.sop.business.bean.result.*;
 import com.qmth.sop.business.entity.*;
-import com.qmth.sop.business.service.*;
+import com.qmth.sop.business.service.SysMessageService;
+import com.qmth.sop.business.service.TFCustomFlowEntityService;
+import com.qmth.sop.business.service.TFCustomFlowService;
+import com.qmth.sop.business.service.TSJobRemindService;
 import com.qmth.sop.business.util.SmsSendUtil;
 import com.qmth.sop.common.contant.SpringContextHolder;
 import com.qmth.sop.common.contant.SystemConstant;
@@ -113,13 +116,13 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
                             List<TSJobRemind> tsJobRemindArrayList = new ArrayList<>();
                             if (Objects.nonNull(task.getAssignee())) {
                                 tsJobRemindArrayList.add(new TSJobRemind(JobQuartzTypeEnum.FLOW, tfCustomFlowEntity.getCode(), Long.parseLong(task.getId()), tfCustomFlow.getType().getTitle() + ";" + task.getName(), JobTypeEnum.AFTER, Long.parseLong(task.getAssignee()), tfFlowLog.getApproveOperation(), sysUser.getId()));
-                                this.sendSopFlowDoneSms(tfCustomFlow.getType(), Long.parseLong(task.getAssignee()));
+                                this.sendSopFlowDoneSms(tfCustomFlow.getType(), tfCustomFlowEntity, task.getName(), Long.parseLong(task.getAssignee()));
                             } else {
                                 List<IdentityLink> identityLinkList = taskService.getIdentityLinksForTask(task.getId());
                                 if (!CollectionUtils.isEmpty(identityLinkList)) {
                                     for (IdentityLink i : identityLinkList) {
                                         tsJobRemindArrayList.add(new TSJobRemind(JobQuartzTypeEnum.FLOW, tfCustomFlowEntity.getCode(), Long.parseLong(i.getTaskId()), tfCustomFlow.getType().getTitle() + ";" + task.getName(), JobTypeEnum.AFTER, Long.parseLong(i.getUserId()), tfFlowLog.getApproveOperation(), sysUser.getId()));
-                                        this.sendSopFlowDoneSms(tfCustomFlow.getType(), Long.parseLong(i.getUserId()));
+                                        this.sendSopFlowDoneSms(tfCustomFlow.getType(), tfCustomFlowEntity, task.getName(), Long.parseLong(i.getUserId()));
                                     }
                                 }
                             }
@@ -319,17 +322,21 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
      * 发送流程待办短信
      *
      * @param type
+     * @param tfCustomFlowEntity
+     * @param taskName
      * @param userId
      */
-    protected void sendSopFlowDoneSms(TFCustomTypeEnum type, Long userId) {
-        SysUserService sysUserService = SpringContextHolder.getBean(SysUserService.class);
+    protected void sendSopFlowDoneSms(TFCustomTypeEnum type, TFCustomFlowEntity tfCustomFlowEntity, String taskName, Long userId) {
         SmsSendUtil smsSendUtil = SpringContextHolder.getBean(SmsSendUtil.class);
+        TFCustomFlowEntityService tfCustomFlowEntityService = SpringContextHolder.getBean(TFCustomFlowEntityService.class);
         if (type == TFCustomTypeEnum.OFFICE_SOP_FLOW || type == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {//发送待审批短信
+            FlowTaskSmsResult flowTaskSmsResult = tfCustomFlowEntityService.getFlowTaskRemindSmsInfo(tfCustomFlowEntity.getId(), userId);
+            Optional.ofNullable(flowTaskSmsResult).orElseThrow(() -> ExceptionResultEnum.USER_NO_EXISTS.exception());
             Map<String, Object> templateParam = new HashMap<>();
-            templateParam.put("code", "test");
-            SysUser sysUser = sysUserService.getById(userId);
-            Optional.ofNullable(sysUser).orElseThrow(() -> ExceptionResultEnum.USER_NO_EXISTS.exception());
-            smsSendUtil.sendSms(sysUser.getMobileNumber(), SystemConstant.SMS_TPL_CODE, templateParam);
+            templateParam.put("userName", flowTaskSmsResult.getRealName());
+            templateParam.put("customName", flowTaskSmsResult.getCustomName());
+            templateParam.put("flowName", type.getTitle() + "【" + taskName + "】");
+            smsSendUtil.sendSms(flowTaskSmsResult.getMobileNumber(), SystemConstant.SMS_SOP_DONE_CODE, templateParam);
         }
     }
 
@@ -362,14 +369,12 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
                 content = content.replaceAll("\\$\\{dingDate\\}", DateUtil.format(new Date(flowTaskMsgResult.getApplyTime()), SystemConstant.DEFAULT_DATE_PATTERN));
                 content = content.replaceAll("\\$\\{approveRemark\\}", tfFlowLog.getApproveRemark());
 
-                configKey = SystemConstant.SMS_TPL_CODE;
+                configKey = SystemConstant.SMS_FLOW_DING_EXCEPTION_FINISH_CODE;
                 templateParam.put("dingDate", DateUtil.format(new Date(flowTaskMsgResult.getApplyTime()), SystemConstant.DEFAULT_DATE_PATTERN));
                 templateParam.put("approveRemark", tfFlowLog.getApproveRemark());
 
                 sysMessage = new SysMessage(tfCustomFlowEntity.getCrmNo(), tfCustomFlowEntity.getCode(),
                         MessageTypeEnum.EXCEPTION_APPROVE, type.name(), flowTaskMsgResult.getServiceId(), tfCustomFlowEntity.getCreateId(), content);
-
-                configKey = SystemConstant.SMS_TPL_CODE;
             } else if (type == TFCustomTypeEnum.PROJECT_EXCHANGE_FLOW) {//项目计划变更
                 content = MessageEnum.NOTICE_OF_PROJECT_EXCHANGE.getTemplate();
                 content = content.replaceAll("\\$\\{userName\\}", flowTaskMsgResult.getRealName());
@@ -377,7 +382,7 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
                 content = content.replaceAll("\\$\\{customName\\}", flowTaskMsgResult.getCustomName());
                 content = content.replaceAll("\\$\\{exchangeType\\}", flowTaskMsgResult.getExchangeType().getTitle());
 
-                configKey = SystemConstant.SMS_TPL_CODE;
+                configKey = SystemConstant.SMS_FLOW_PROJECT_EXCHANGE_FINISH_CODE;
                 templateParam.put("serviceName", flowTaskMsgResult.getServiceName());
                 templateParam.put("customName", flowTaskMsgResult.getCustomName());
                 templateParam.put("exchangeType", flowTaskMsgResult.getExchangeType().getTitle());

+ 10 - 0
sop-business/src/main/java/com/qmth/sop/business/mapper/TFCustomFlowEntityMapper.java

@@ -2,6 +2,7 @@ package com.qmth.sop.business.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.qmth.sop.business.bean.result.FlowTaskMsgResult;
+import com.qmth.sop.business.bean.result.FlowTaskSmsResult;
 import com.qmth.sop.business.entity.TFCustomFlowEntity;
 import org.apache.ibatis.annotations.Param;
 
@@ -23,4 +24,13 @@ public interface TFCustomFlowEntityMapper extends BaseMapper<TFCustomFlowEntity>
      * @return
      */
     FlowTaskMsgResult getFlowTaskRemindMsgInfo(@Param("id") Long id, @Param("userId") Long userId);
+
+    /**
+     * 获取流程实体id发送短信内容
+     *
+     * @param id
+     * @param userId
+     * @return
+     */
+    FlowTaskSmsResult getFlowTaskRemindSmsInfo(@Param("id") Long id, @Param("userId") Long userId);
 }

+ 10 - 0
sop-business/src/main/java/com/qmth/sop/business/service/TFCustomFlowEntityService.java

@@ -2,6 +2,7 @@ package com.qmth.sop.business.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.sop.business.bean.result.FlowTaskMsgResult;
+import com.qmth.sop.business.bean.result.FlowTaskSmsResult;
 import com.qmth.sop.business.entity.TFCustomFlowEntity;
 
 /**
@@ -22,4 +23,13 @@ public interface TFCustomFlowEntityService extends IService<TFCustomFlowEntity>
      * @return
      */
     FlowTaskMsgResult getFlowTaskRemindMsgInfo(Long id, Long userId);
+
+    /**
+     * 获取流程实体id发送短信内容
+     *
+     * @param id
+     * @param userId
+     * @return
+     */
+    FlowTaskSmsResult getFlowTaskRemindSmsInfo(Long id, Long userId);
 }

+ 13 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/TFCustomFlowEntityServiceImpl.java

@@ -2,6 +2,7 @@ package com.qmth.sop.business.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.sop.business.bean.result.FlowTaskMsgResult;
+import com.qmth.sop.business.bean.result.FlowTaskSmsResult;
 import com.qmth.sop.business.entity.TFCustomFlowEntity;
 import com.qmth.sop.business.mapper.TFCustomFlowEntityMapper;
 import com.qmth.sop.business.service.TFCustomFlowEntityService;
@@ -29,4 +30,16 @@ public class TFCustomFlowEntityServiceImpl extends ServiceImpl<TFCustomFlowEntit
     public FlowTaskMsgResult getFlowTaskRemindMsgInfo(Long id, Long userId) {
         return this.baseMapper.getFlowTaskRemindMsgInfo(id, userId);
     }
+
+    /**
+     * 获取流程实体id发送短信内容
+     *
+     * @param id
+     * @param userId
+     * @return
+     */
+    @Override
+    public FlowTaskSmsResult getFlowTaskRemindSmsInfo(Long id, Long userId) {
+        return this.baseMapper.getFlowTaskRemindSmsInfo(id, userId);
+    }
 }

+ 24 - 1
sop-business/src/main/resources/db/log/wangliang_update_log.sql

@@ -667,4 +667,27 @@ INSERT INTO sys_config
 VALUES(23, NULL, 'remind.job.poll.time', '任务提醒轮询时间', '0 0/1 * * * ?', NULL, 1, 1, 1, NULL, NULL, NULL);
 INSERT INTO sys_config
 (id, org_id, config_key, config_name, config_value, remark, enable, sort, create_id, create_time, update_id, update_time)
-VALUES(24, NULL, 'remind.job.db.limit', '任务提醒查询条数', 'limit 0,100000', NULL, 1, 2, 1, NULL, NULL, NULL);
+VALUES(24, NULL, 'remind.job.db.limit', '任务提醒查询条数', 'limit 0,100000', NULL, 1, 2, 1, NULL, NULL, NULL);
+
+--2023.8.23update
+INSERT INTO sys_config
+(id, org_id, config_key, config_name, config_value, remark, enable, sort, create_id, create_time, update_id, update_time)
+VALUES(25, NULL, 'sms.notice.code', '系统通知公告', 'SMS_462685325', NULL, 1, 1, 1, NULL, NULL, NULL);
+INSERT INTO sys_config
+(id, org_id, config_key, config_name, config_value, remark, enable, sort, create_id, create_time, update_id, update_time)
+VALUES(26, NULL, 'sms.sop.before.remind.code', '教务处/研究生SOP提前提醒通知', 'SMS_462660413', NULL, 1, 1, 1, NULL, NULL, NULL);
+INSERT INTO sys_config
+(id, org_id, config_key, config_name, config_value, remark, enable, sort, create_id, create_time, update_id, update_time)
+VALUES(27, NULL, 'sms.sop.done.code', '教务处/研究生SOP节点负责人通知', 'SMS_462730333', NULL, 1, 1, 1, NULL, NULL, NULL);
+INSERT INTO sys_config
+(id, org_id, config_key, config_name, config_value, remark, enable, sort, create_id, create_time, update_id, update_time)
+VALUES(28, NULL, 'sms.flow.project.exchange.finish.code', '系统计划变更审核通知', 'SMS_462685324', NULL, 1, 1, 1, NULL, NULL, NULL);
+INSERT INTO sys_config
+(id, org_id, config_key, config_name, config_value, remark, enable, sort, create_id, create_time, update_id, update_time)
+VALUES(29, NULL, 'sms.flow.ding.exception.finish.code', '异常审核通知', 'SMS_462700329', NULL, 1, 1, 1, NULL, NULL, NULL);
+INSERT INTO sys_config
+(id, org_id, config_key, config_name, config_value, remark, enable, sort, create_id, create_time, update_id, update_time)
+VALUES(30, NULL, 'sms.sop.after.remind.code', '延期提醒通知', 'SMS_462700328', NULL, 1, 1, 1, NULL, NULL, NULL);
+INSERT INTO sys_config
+(id, org_id, config_key, config_name, config_value, remark, enable, sort, create_id, create_time, update_id, update_time)
+VALUES(31, NULL, 'sms.violation.remind.code', '违规提醒通知', 'SMS_462720332', NULL, 1, 1, 1, NULL, NULL, NULL);

+ 16 - 0
sop-business/src/main/resources/mapper/TFCustomFlowEntityMapper.xml

@@ -21,4 +21,20 @@
         where
             tfcfe.id = #{id}
     </select>
+
+    <select id="getFlowTaskRemindSmsInfo" resultType="com.qmth.sop.business.bean.result.FlowTaskSmsResult">
+        select
+            tbc.id as serviceId,
+            tbc.name as serviceName,
+            sc.name as customName,
+            su.real_name as realName,
+            su.mobile_number as mobileNumber
+        from
+            t_f_custom_flow_entity tfcfe
+                left join t_b_crm tbc on tbc.crm_no = tfcfe.crm_no
+                left join sys_custom sc on sc.id = tbc.custom_id
+                left join sys_user su on su.id = #{userId}
+        where
+            tfcfe.id = #{id}
+    </select>
 </mapper>

+ 7 - 1
sop-common/src/main/java/com/qmth/sop/common/contant/SystemConstant.java

@@ -124,7 +124,13 @@ public class SystemConstant {
     public static final String FLOW_JOB_AFTER_TIME = "flow.job.after.time";
     public static final String NOTICE_JOB_AFTER_TIME = "notice.job.after.time";
     public static final String REMIND_JOB_POLL_TIME = "remind.job.poll.time";
-    public static final String REMIND_JOB_DB_LIMIT = "remind.job.db.limit";
+    public static final String SMS_NOTICE_CODE = "sms.notice.code";
+    public static final String SMS_SOP_BEFORE_REMIND_CODE = "sms.sop.before.remind.code";
+    public static final String SMS_SOP_DONE_CODE = "sms.sop.done.code";
+    public static final String SMS_FLOW_PROJECT_EXCHANGE_FINISH_CODE = "sms.flow.project.exchange.finish.code";
+    public static final String SMS_FLOW_DING_EXCEPTION_FINISH_CODE = "sms.flow.ding.exception.finish.code";
+    public static final String SMS_SOP_AFTER_REMIND_CODE = "sms.sop.after.remind.code";
+    public static final String SMS_VIOLATION_REMIND_CODE = "sms.violation.remind.code";
 
     /**
      * api前缀

+ 5 - 4
sop-task/src/main/java/com/qmth/sop/task/job/RemindTaskJob.java

@@ -72,7 +72,7 @@ public class RemindTaskJob extends QuartzJobBean {
                                 content = content.replaceAll("\\$\\{customName\\}", flowTaskSmsResult.getCustomName());
                                 content = content.replaceAll("\\$\\{flowName\\}", strs[0] + "【" + strs[1] + "】");
 
-                                configKey = SystemConstant.SMS_TPL_CODE;
+                                configKey = SystemConstant.SMS_SOP_BEFORE_REMIND_CODE;
                                 templateParam.put("serviceName", flowTaskSmsResult.getServiceName());
                                 templateParam.put("customName", flowTaskSmsResult.getCustomName());
                                 templateParam.put("flowName", strs[0] + "【" + strs[1] + "】");
@@ -86,7 +86,7 @@ public class RemindTaskJob extends QuartzJobBean {
                                 content = content.replaceAll("\\$\\{customName\\}", flowTaskSmsResult.getCustomName());
                                 content = content.replaceAll("\\$\\{flowName\\}", strs[0] + "【" + strs[1] + "】");
 
-                                configKey = SystemConstant.SMS_TPL_CODE;
+                                configKey = SystemConstant.SMS_SOP_AFTER_REMIND_CODE;
                                 templateParam.put("serviceName", flowTaskSmsResult.getServiceName());
                                 templateParam.put("customName", flowTaskSmsResult.getCustomName());
                                 templateParam.put("flowName", strs[0] + "【" + strs[1] + "】");
@@ -105,8 +105,9 @@ public class RemindTaskJob extends QuartzJobBean {
                             List<SysUser> sysUserList = sysUserService.list(new QueryWrapper<SysUser>().lambda().isNotNull(SysUser::getMobileNumber).eq(SysUser::getEnable, true));
                             for (SysUser s : sysUserList) {
                                 Map<String, Object> templateParam = new HashMap<>();
-                                templateParam.put("code", "test");
-                                smsSendUtil.sendSms(s.getMobileNumber(), SystemConstant.SMS_TPL_CODE, templateParam);
+                                templateParam.put("userName", s.getRealName());
+                                templateParam.put("title", tsJobRemind.getObjName());
+                                smsSendUtil.sendSms(s.getMobileNumber(), SystemConstant.SMS_NOTICE_CODE, templateParam);
                             }
                         }
                     }