Browse Source

发布sop新增短信通知

wangliang 1 năm trước cách đây
mục cha
commit
2424a92da9

+ 19 - 3
sop-business/src/main/java/com/qmth/sop/business/activiti/service/ActivitiService.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.qmth.sop.business.bean.params.FlowApproveParam;
 import com.qmth.sop.business.bean.result.FlowViewResult;
 import com.qmth.sop.business.bean.result.WorkTaskResult;
+import com.qmth.sop.business.entity.TFCustomFlowEntity;
 import com.qmth.sop.common.enums.FlowTaskTypeEnum;
 import com.qmth.sop.common.enums.TFCustomTypeEnum;
 import org.activiti.engine.task.Task;
@@ -74,7 +75,8 @@ public interface ActivitiService {
      * @param crmNo
      * @return
      */
-    public Map<String, Object> formPropertiesGet(String flowDeploymentId, Long flowId, Long taskId, Boolean dynamicTable, String crmNo) throws Exception;
+    public Map<String, Object> formPropertiesGet(String flowDeploymentId, Long flowId, Long taskId,
+            Boolean dynamicTable, String crmNo) throws Exception;
 
     /**
      * 获取用户待办
@@ -88,7 +90,8 @@ public interface ActivitiService {
      * @param crmNo
      * @return
      */
-    public IPage<WorkTaskResult> getFlowTaskList(IPage<Map> iPage, Long userId, TFCustomTypeEnum type, Long serviceId, String customName, FlowTaskTypeEnum flowTaskTypeEnum, String crmNo);
+    public IPage<WorkTaskResult> getFlowTaskList(IPage<Map> iPage, Long userId, TFCustomTypeEnum type, Long serviceId,
+            String customName, FlowTaskTypeEnum flowTaskTypeEnum, String crmNo);
 
     /**
      * 获取用户待办计数
@@ -101,7 +104,8 @@ public interface ActivitiService {
      * @param crmNo
      * @return
      */
-    public int getFlowTaskListCount(Long userId, TFCustomTypeEnum type, Long serviceId, String customName, FlowTaskTypeEnum flowTaskTypeEnum, String crmNo);
+    public int getFlowTaskListCount(Long userId, TFCustomTypeEnum type, Long serviceId, String customName,
+            FlowTaskTypeEnum flowTaskTypeEnum, String crmNo);
 
     /**
      * 流程节点转他人审批
@@ -152,4 +156,16 @@ public interface ActivitiService {
      * @return
      */
     public List<String> getTaskApprove(Task task);
+
+    /**
+     * 发送待办短信
+     *
+     * @param type
+     * @param tfCustomFlowEntity
+     * @param taskName
+     * @param userId
+     * @param taskId
+     */
+    public void sendSopFlowDoneSms(TFCustomTypeEnum type, TFCustomFlowEntity tfCustomFlowEntity, String taskName,
+            Long userId, Long taskId);
 }

+ 40 - 14
sop-business/src/main/java/com/qmth/sop/business/activiti/service/impl/ActivitiServiceImpl.java

@@ -130,6 +130,9 @@ public class ActivitiServiceImpl implements ActivitiService {
     @Resource
     SmsSendUtil smsSendUtil;
 
+    @Resource
+    ActivitiService activitiService;
+
     /**
      * 根据deploymentId查找processDefinitionId
      *
@@ -268,22 +271,12 @@ public class ActivitiServiceImpl implements ActivitiService {
                     FlowStatusEnum.valueOf(flowApproveParam.getApprove().name()), sysUser.getId());
             flowResult = JSONObject.parseObject(tfCustomFlow.getFlowProcessVar(), FlowResult.class);
 
-            FlowTaskSmsResult flowTaskSmsResult = tfCustomFlowEntityService.getFlowTaskRemindSmsInfo(
-                    tfCustomFlowEntity.getId(), Long.parseLong(approveUserIds.get(0)));
-            if (Objects.isNull(flowTaskSmsResult)) {
-                flowTaskSmsResult = tfCustomFlowEntityService.getFlowTaskRemindSmsInfo(tfCustomFlowEntity.getCrmNo(),
-                        Long.parseLong(approveUserIds.get(0)));
-            }
-            Optional.ofNullable(flowTaskSmsResult).orElseThrow(() -> ExceptionResultEnum.USER_NO_EXISTS.exception());
-
             Task task = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId())
                     .singleResult();
-            Map<String, Object> templateParam = new HashMap<>();
-            templateParam.put("userName", flowTaskSmsResult.getRealName());
-            templateParam.put("serviceName", flowTaskSmsResult.getServiceName());
-            templateParam.put("customName", flowTaskSmsResult.getCustomName());
-            templateParam.put("flowName", maxTfCustomFlow.getType().getTitle() + "【" + task.getName() + "】");
-            smsSendUtil.sendSms(flowTaskSmsResult.getMobileNumber(), SystemConstant.SMS_SOP_DONE_CODE, templateParam);
+            Optional.ofNullable(task).orElseThrow(() -> ExceptionResultEnum.TASK_NO_DATA.exception());
+
+            activitiService.sendSopFlowDoneSms(maxTfCustomFlow.getType(), tfCustomFlowEntity, task.getName(),
+                    Long.parseLong(approveUserIds.get(0)), Long.parseLong(task.getId()));
         } else if (Objects.nonNull(flowApproveParam.getTaskId())) {
             taskTemp = taskService.createTaskQuery().taskId(String.valueOf(flowApproveParam.getTaskId()))
                     .singleResult();
@@ -809,6 +802,8 @@ public class ActivitiServiceImpl implements ActivitiService {
                     sysUser.getRealName() + "(" + orgName + ")转" + exchangeUser.getRealName() + "(" + exchangeOrgName
                             + ")审批");
             tfFlowLogService.save(tfFlowLog);
+            activitiService.sendSopFlowDoneSms(tfCustomFlow.getType(), tfCustomFlowEntity, task.getName(), userId,
+                    Long.parseLong(task.getId()));
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);
             if (e instanceof ApiException) {
@@ -1283,4 +1278,35 @@ public class ActivitiServiceImpl implements ActivitiService {
             tfFlowLog.setApproveRemark(DingExceptionApproveEnum.NO_PASS.getTitle());
         }
     }
+
+    /**
+     * 发送待办短信
+     *
+     * @param type
+     * @param tfCustomFlowEntity
+     * @param taskName
+     * @param userId
+     * @param taskId
+     */
+    @Override
+    public void sendSopFlowDoneSms(TFCustomTypeEnum type, TFCustomFlowEntity tfCustomFlowEntity, String taskName,
+            Long userId, Long taskId) {
+        FlowTaskSmsResult flowTaskSmsResult = tfCustomFlowEntityService.getFlowTaskRemindSmsInfo(
+                tfCustomFlowEntity.getId(), userId);
+        if (Objects.isNull(flowTaskSmsResult)) {
+            flowTaskSmsResult = tfCustomFlowEntityService.getFlowTaskRemindSmsInfo(tfCustomFlowEntity.getCrmNo(),
+                    userId);
+        }
+        Optional.ofNullable(flowTaskSmsResult).orElseThrow(() -> ExceptionResultEnum.USER_NO_EXISTS.exception());
+
+        Task task = taskService.createTaskQuery().taskId(String.valueOf(taskId)).singleResult();
+        Optional.ofNullable(task).orElseThrow(() -> ExceptionResultEnum.TASK_NO_DATA.exception());
+
+        Map<String, Object> templateParam = new HashMap<>();
+        templateParam.put("userName", flowTaskSmsResult.getRealName());
+        templateParam.put("serviceName", flowTaskSmsResult.getServiceName());
+        templateParam.put("customName", flowTaskSmsResult.getCustomName());
+        templateParam.put("flowName", type.getTitle() + "【" + task.getName() + "】");
+        smsSendUtil.sendSms(flowTaskSmsResult.getMobileNumber(), SystemConstant.SMS_SOP_DONE_CODE, templateParam);
+    }
 }