wangliang преди 9 месеца
родител
ревизия
afa96f947f

+ 35 - 15
sop-business/src/main/java/com/qmth/sop/business/activiti/listener/ProcessEventListener.java

@@ -141,21 +141,6 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
                                     }
                                 }
                             }
-
-                            //此处统一发送流程节点待办消息
-                            MemoryLock memoryLock = SpringContextHolder.getBean(MemoryLock.class);
-                            String key = tfCustomFlowEntity.getCode() + tfFlowLog.getId();
-                            boolean lock = memoryLock.lock(SystemConstant.LOCK_FLOW_TASK_MSG_PREFIX + key, key,
-                                    SystemConstant.LOCK_FLOW_MSG_TIME_OUT);
-                            if (lock) {
-                                try {
-                                    activitiService.sendSopFlowDoneMsg(tfCustomFlow.getType(), tfCustomFlowEntity,
-                                            tfFlowApprove, Long.parseLong(task.getId()), task.getName(),
-                                            tfFlowLog.getId());
-                                } finally {
-                                    memoryLock.unlock(SystemConstant.LOCK_FLOW_TASK_PREFIX + key);
-                                }
-                            }
                         }
                     }
                 }
@@ -185,6 +170,41 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
                             || tfCustomFlow.getType() == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {
                         //任务完成后统一设置延期预警任务enable为false
                         jobRemindService.updateJobRemind(Long.parseLong(task.getId()));
+
+                        ActivitiService activitiService = SpringContextHolder.getBean(ActivitiService.class);
+                        TFFlowApprove tfFlowApprove = (TFFlowApprove) taskService.getVariable(task.getId(),
+                                SystemConstant.FLOW_APPROVE);
+                        Optional.ofNullable(tfFlowApprove)
+                                .orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_NO_DATA.exception());
+
+                        TFCustomFlowEntity tfCustomFlowEntity = (TFCustomFlowEntity) taskService.getVariable(
+                                task.getId(), SystemConstant.FLOW_ENTITY);
+                        Optional.ofNullable(tfCustomFlowEntity)
+                                .orElseThrow(() -> ExceptionResultEnum.FLOW_ENTITY_NO_DATA.exception());
+                        //此处统一发送流程节点待办消息
+                        MemoryLock memoryLock = SpringContextHolder.getBean(MemoryLock.class);
+                        String key = tfCustomFlowEntity.getCode() + tfFlowLog.getId();
+                        boolean lock = memoryLock.lock(SystemConstant.LOCK_FLOW_TASK_MSG_PREFIX + key, key,
+                                SystemConstant.LOCK_FLOW_MSG_TIME_OUT);
+                        if (lock) {
+                            try {
+                                if (tfCustomFlow.getType() == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW
+                                        && tfFlowLog.getApproveSetup().intValue() == 3) {
+                                    Boolean finish = (Boolean) taskService.getVariable(task.getId(),
+                                            SystemConstant.FINISH);
+                                    if (Objects.nonNull(finish) && finish) {
+                                        activitiService.sendSopFlowDoneMsg(tfCustomFlow.getType(), tfCustomFlowEntity,
+                                                tfFlowLog.getApproveSetup(), Long.parseLong(task.getId()),
+                                                task.getName());
+                                    }
+                                } else {
+                                    activitiService.sendSopFlowDoneMsg(tfCustomFlow.getType(), tfCustomFlowEntity,
+                                            tfFlowLog.getApproveSetup(), Long.parseLong(task.getId()), task.getName());
+                                }
+                            } finally {
+                                memoryLock.unlock(SystemConstant.LOCK_FLOW_TASK_PREFIX + key);
+                            }
+                        }
                     }
                 }
             }

+ 2 - 4
sop-business/src/main/java/com/qmth/sop/business/activiti/service/ActivitiService.java

@@ -5,7 +5,6 @@ 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.business.entity.TFFlowApprove;
 import com.qmth.sop.common.enums.FlowTaskTypeEnum;
 import com.qmth.sop.common.enums.TFCustomTypeEnum;
 import org.activiti.engine.task.Task;
@@ -174,11 +173,10 @@ public interface ActivitiService {
      *
      * @param type
      * @param tfCustomFlowEntity
-     * @param tfFlowApprove
+     * @param setup
      * @param taskId
      * @param taskName
-     * @param noticeId
      */
     public void sendSopFlowDoneMsg(TFCustomTypeEnum type, TFCustomFlowEntity tfCustomFlowEntity,
-            TFFlowApprove tfFlowApprove, Long taskId, String taskName, Long noticeId);
+            Integer setup, Long taskId, String taskName);
 }

+ 11 - 19
sop-business/src/main/java/com/qmth/sop/business/activiti/service/impl/ActivitiServiceImpl.java

@@ -277,10 +277,6 @@ public class ActivitiServiceImpl implements ActivitiService {
                     || tfCustomFlow.getType() == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {
                 activitiService.sendSopFlowDoneSms(maxTfCustomFlow.getType(), tfCustomFlowEntity, task.getName(),
                         Long.parseLong(approveUserIds.get(0)));
-                TBCrmDetail tbCrmDetail = (TBCrmDetail) flowApproveParam.getVar().get(SystemConstant.CRM_DETAIL);
-                taskService.setVariable(task.getId(), SystemConstant.CRM_DETAIL, tbCrmDetail);
-                activitiService.sendSopFlowDoneMsg(maxTfCustomFlow.getType(), tfCustomFlowEntity, tfFlowApprove,
-                        Long.parseLong(task.getId()), task.getName(), tbCrmDetail.getId());
             }
         } else if (Objects.nonNull(flowApproveParam.getTaskId())) {
             taskTemp = taskService.createTaskQuery().taskId(String.valueOf(flowApproveParam.getTaskId()))
@@ -460,6 +456,10 @@ public class ActivitiServiceImpl implements ActivitiService {
                             TBCrmDetail tbCrmDetail = tbCrmDetailService.findBySopNo(tfCustomFlowEntity.getCode());
                             taskService.setVariable(task.getId(), SystemConstant.CRM_DETAIL, tbCrmDetail);
                         }
+                        if (multiInstance && Objects.nonNull(nrOfCompletedInstances) && Objects.nonNull(nrOfInstances)
+                                && nrOfCompletedInstances.intValue() == nrOfInstances.intValue()) {
+                            taskService.setVariable(task.getId(), SystemConstant.FINISH, true);
+                        }
                         taskService.setVariable(task.getId(), SystemConstant.FLOW_CUSTOM, tfCustomFlow);
                         taskService.setVariable(task.getId(), SystemConstant.FLOW_APPROVE, tfFlowApprove);
                         taskService.setVariable(task.getId(), SystemConstant.FLOW_ENTITY, tfCustomFlowEntity);
@@ -1364,14 +1364,13 @@ public class ActivitiServiceImpl implements ActivitiService {
      *
      * @param type
      * @param tfCustomFlowEntity
-     * @param tfFlowApprove
+     * @param setup
      * @param taskId
      * @param taskName
-     * @param noticeId
      */
     @Override
-    public void sendSopFlowDoneMsg(TFCustomTypeEnum type, TFCustomFlowEntity tfCustomFlowEntity,
-            TFFlowApprove tfFlowApprove, Long taskId, String taskName, Long noticeId) {
+    public void sendSopFlowDoneMsg(TFCustomTypeEnum type, TFCustomFlowEntity tfCustomFlowEntity, Integer setup,
+            Long taskId, String taskName) {
         TBCrmDetail tbCrmDetail = null;
         if (Objects.nonNull(taskId)) {
             tbCrmDetail = (TBCrmDetail) taskService.getVariable(taskId.toString(), SystemConstant.CRM_DETAIL);
@@ -1400,16 +1399,9 @@ public class ActivitiServiceImpl implements ActivitiService {
             }
             receiveUserId = crmProjectResult.getRegionCoordinatorList().get(0).getUserId();//研究生固定区域协调人
         }
-        int count = 0;
-        if (type == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW && tfFlowApprove.getSetup().intValue() == 3) {
-            count = sysMessageService.countByInAudit(MessageTypeEnum.CLOUD_MARK_SOP, tfCustomFlowEntity.getCode(),
-                    noticeId, receiveUserId, tfFlowApprove.getSetup().intValue());
-        }
-        if (count == 0) {
-            SysMessage sysMessage = new SysMessage(tfCustomFlowEntity.getCrmNo(), tfCustomFlowEntity.getCode(),
-                    messageTypeEnum, type.name(), crmProjectResult.getServiceUnitId(), receiveUserId,
-                    stringJoiner.toString(), -1L, tfFlowApprove.getSetup(), taskName, noticeId);
-            sysMessageService.saveSysMessage(Arrays.asList(sysMessage));
-        }
+        SysMessage sysMessage = new SysMessage(tfCustomFlowEntity.getCrmNo(), tfCustomFlowEntity.getCode(),
+                messageTypeEnum, type.name(), crmProjectResult.getServiceUnitId(), receiveUserId,
+                stringJoiner.toString(), -1L, setup, taskName);
+        sysMessageService.saveSysMessage(Arrays.asList(sysMessage));
     }
 }

+ 1 - 2
sop-business/src/main/java/com/qmth/sop/business/entity/SysMessage.java

@@ -96,7 +96,7 @@ public class SysMessage implements Serializable {
     }
 
     public SysMessage(String crmNo, String code, MessageTypeEnum type, String objType, Long serviceId,
-            Long receiveUserId, String content, Long formUserId, Integer setup, String setupName, Long noticeId) {
+            Long receiveUserId, String content, Long formUserId, Integer setup, String setupName) {
         this.id = SystemConstant.getDbUuid();
         this.crmNo = crmNo;
         this.code = code;
@@ -110,7 +110,6 @@ public class SysMessage implements Serializable {
         this.formUserId = formUserId;
         this.setup = setup;
         this.setupName = setupName;
-        this.noticeId = noticeId;
     }
 
     public String getSetupName() {

+ 11 - 12
sop-business/src/main/java/com/qmth/sop/business/service/SysMessageService.java

@@ -7,7 +7,6 @@ import com.qmth.sop.business.bean.result.SysMessageResult;
 import com.qmth.sop.business.bean.result.SysMessageWorkResult;
 import com.qmth.sop.business.entity.SysMessage;
 import com.qmth.sop.business.entity.SysNotice;
-import com.qmth.sop.common.enums.MessageEnum;
 import com.qmth.sop.common.enums.MessageTypeEnum;
 
 import java.util.List;
@@ -54,15 +53,15 @@ public interface SysMessageService extends IService<SysMessage> {
     IPage<SysMessageWorkResult> pageByTypes(IPage<Map> iPage, MessageTypeEnum[] types, Boolean status, Long serviceId,
             String custom, String query, Long startTime, Long endTime);
 
-    /**
-     * count内审
-     *
-     * @param type
-     * @param code
-     * @param noticeId
-     * @param receiveUserId
-     * @param setup
-     * @return
-     */
-    int countByInAudit(MessageTypeEnum type, String code, Long noticeId, Long receiveUserId, Integer setup);
+//    /**
+//     * count内审
+//     *
+//     * @param type
+//     * @param code
+//     * @param noticeId
+//     * @param receiveUserId
+//     * @param setup
+//     * @return
+//     */
+//    int countByInAudit(MessageTypeEnum type, String code, Long noticeId, Long receiveUserId, Integer setup);
 }

+ 17 - 17
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysMessageServiceImpl.java

@@ -141,21 +141,21 @@ public class SysMessageServiceImpl extends ServiceImpl<SysMessageMapper, SysMess
                 startTime, endTime, sysUser.getId());
     }
 
-    /**
-     * count内审
-     *
-     * @param type
-     * @param code
-     * @param noticeId
-     * @param receiveUserId
-     * @param setup
-     * @return
-     */
-    @Override
-    public int countByInAudit(MessageTypeEnum type, String code, Long noticeId, Long receiveUserId, Integer setup) {
-        return this.count(
-                new QueryWrapper<SysMessage>().lambda().eq(SysMessage::getCode, code).eq(SysMessage::getType, type)
-                        .eq(SysMessage::getNoticeId, noticeId).eq(SysMessage::getReceiveUserId, receiveUserId)
-                        .eq(SysMessage::getSetup, setup));
-    }
+    //    /**
+    //     * count内审
+    //     *
+    //     * @param type
+    //     * @param code
+    //     * @param noticeId
+    //     * @param receiveUserId
+    //     * @param setup
+    //     * @return
+    //     */
+    //    @Override
+    //    public int countByInAudit(MessageTypeEnum type, String code, Long noticeId, Long receiveUserId, Integer setup) {
+    //        return this.count(
+    //                new QueryWrapper<SysMessage>().lambda().eq(SysMessage::getCode, code).eq(SysMessage::getType, type)
+    //                        .eq(SysMessage::getNoticeId, noticeId).eq(SysMessage::getReceiveUserId, receiveUserId)
+    //                        .eq(SysMessage::getSetup, setup));
+    //    }
 }

+ 2 - 0
sop-common/src/main/java/com/qmth/sop/common/contant/SystemConstant.java

@@ -555,6 +555,8 @@ public class SystemConstant {
 
     public static final String FLOW_CUSTOM = "tfCustomFlow";
 
+    public static final String FINISH = "finish";
+
     public static final String FLOW_APPROVE = "tfFlowApprove";
 
     public static final String FLOW_APPROVE_LOG = "tfFlowApproveLog";