Pārlūkot izejas kodu

消息提醒修改

wangliang 9 mēneši atpakaļ
vecāks
revīzija
23fe159478

+ 17 - 5
sop-business/src/main/java/com/qmth/sop/business/activiti/listener/ProcessEventListener.java

@@ -16,6 +16,7 @@ import com.qmth.sop.business.util.SmsSendUtil;
 import com.qmth.sop.common.contant.SpringContextHolder;
 import com.qmth.sop.common.contant.SpringContextHolder;
 import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.*;
 import com.qmth.sop.common.enums.*;
+import com.qmth.sop.common.lock.MemoryLock;
 import com.qmth.sop.common.util.JacksonUtil;
 import com.qmth.sop.common.util.JacksonUtil;
 import org.activiti.engine.HistoryService;
 import org.activiti.engine.HistoryService;
 import org.activiti.engine.TaskService;
 import org.activiti.engine.TaskService;
@@ -93,9 +94,9 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
                 }
                 }
                 this.sendFlowFinishSms(tfCustomFlow.getType(), tfCustomFlowEntity, tfFlowApprove.getStatus(),
                 this.sendFlowFinishSms(tfCustomFlow.getType(), tfCustomFlowEntity, tfFlowApprove.getStatus(),
                         tfFlowLog);
                         tfFlowLog);
-                ActivitiService activitiService = SpringContextHolder.getBean(ActivitiService.class);
-                activitiService.sendSopFlowDoneMsg(tfCustomFlow.getType(), tfCustomFlowEntity, tfFlowApprove, null,
-                        FlowStatusEnum.FINISH.getTitle());
+                //                ActivitiService activitiService = SpringContextHolder.getBean(ActivitiService.class);
+                //                activitiService.sendSopFlowDoneMsg(tfCustomFlow.getType(), tfCustomFlowEntity, tfFlowApprove, null,
+                //                        FlowStatusEnum.FINISH.getTitle());
             }
             }
             break;
             break;
         case TASK_CREATED:
         case TASK_CREATED:
@@ -149,8 +150,19 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
                                 || tfCustomFlow.getType() == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW)
                                 || tfCustomFlow.getType() == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW)
                                 && tfFlowLog.getApproveOperation() != FlowApproveOperationEnum.DRAFT
                                 && tfFlowLog.getApproveOperation() != FlowApproveOperationEnum.DRAFT
                                 && tfFlowLog.getApproveOperation() != FlowApproveOperationEnum.END) {
                                 && tfFlowLog.getApproveOperation() != FlowApproveOperationEnum.END) {
-                            activitiService.sendSopFlowDoneMsg(tfCustomFlow.getType(), tfCustomFlowEntity,
-                                    tfFlowApprove, Long.parseLong(task.getId()), task.getName());
+                            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);
+                                }
+                            }
                         }
                         }
                     }
                     }
                 }
                 }

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

@@ -177,7 +177,8 @@ public interface ActivitiService {
      * @param tfFlowApprove
      * @param tfFlowApprove
      * @param taskId
      * @param taskId
      * @param taskName
      * @param taskName
+     * @param noticeId
      */
      */
     public void sendSopFlowDoneMsg(TFCustomTypeEnum type, TFCustomFlowEntity tfCustomFlowEntity,
     public void sendSopFlowDoneMsg(TFCustomTypeEnum type, TFCustomFlowEntity tfCustomFlowEntity,
-            TFFlowApprove tfFlowApprove, Long taskId, String taskName);
+            TFFlowApprove tfFlowApprove, Long taskId, String taskName, Long noticeId);
 }
 }

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

@@ -278,7 +278,7 @@ public class ActivitiServiceImpl implements ActivitiService {
             activitiService.sendSopFlowDoneSms(maxTfCustomFlow.getType(), tfCustomFlowEntity, task.getName(),
             activitiService.sendSopFlowDoneSms(maxTfCustomFlow.getType(), tfCustomFlowEntity, task.getName(),
                     Long.parseLong(approveUserIds.get(0)));
                     Long.parseLong(approveUserIds.get(0)));
             activitiService.sendSopFlowDoneMsg(maxTfCustomFlow.getType(), tfCustomFlowEntity, tfFlowApprove,
             activitiService.sendSopFlowDoneMsg(maxTfCustomFlow.getType(), tfCustomFlowEntity, tfFlowApprove,
-                    Long.parseLong(task.getId()), task.getName());
+                    Long.parseLong(task.getId()), task.getName(), tbCrmDetail.getId());
         } else if (Objects.nonNull(flowApproveParam.getTaskId())) {
         } else if (Objects.nonNull(flowApproveParam.getTaskId())) {
             taskTemp = taskService.createTaskQuery().taskId(String.valueOf(flowApproveParam.getTaskId()))
             taskTemp = taskService.createTaskQuery().taskId(String.valueOf(flowApproveParam.getTaskId()))
                     .singleResult();
                     .singleResult();
@@ -1361,10 +1361,11 @@ public class ActivitiServiceImpl implements ActivitiService {
      * @param tfFlowApprove
      * @param tfFlowApprove
      * @param taskId
      * @param taskId
      * @param taskName
      * @param taskName
+     * @param noticeId
      */
      */
     @Override
     @Override
     public void sendSopFlowDoneMsg(TFCustomTypeEnum type, TFCustomFlowEntity tfCustomFlowEntity,
     public void sendSopFlowDoneMsg(TFCustomTypeEnum type, TFCustomFlowEntity tfCustomFlowEntity,
-            TFFlowApprove tfFlowApprove, Long taskId, String taskName) {
+            TFFlowApprove tfFlowApprove, Long taskId, String taskName, Long noticeId) {
         TBCrmDetail tbCrmDetail = null;
         TBCrmDetail tbCrmDetail = null;
         if (Objects.nonNull(taskId)) {
         if (Objects.nonNull(taskId)) {
             tbCrmDetail = (TBCrmDetail) taskService.getVariable(taskId.toString(), SystemConstant.CRM_DETAIL);
             tbCrmDetail = (TBCrmDetail) taskService.getVariable(taskId.toString(), SystemConstant.CRM_DETAIL);
@@ -1393,10 +1394,16 @@ public class ActivitiServiceImpl implements ActivitiService {
             }
             }
             receiveUserId = crmProjectResult.getRegionCoordinatorList().get(0).getUserId();//研究生固定区域协调人
             receiveUserId = crmProjectResult.getRegionCoordinatorList().get(0).getUserId();//研究生固定区域协调人
         }
         }
-
-        SysMessage sysMessage = new SysMessage(tfCustomFlowEntity.getCrmNo(), tfCustomFlowEntity.getCode(),
-                messageTypeEnum, type.name(), crmProjectResult.getServiceUnitId(), receiveUserId,
-                stringJoiner.toString(), -1L, tfFlowApprove.getSetup(), taskName);
-        sysMessageService.saveSysMessage(Arrays.asList(sysMessage));
+        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));
+        }
     }
     }
 }
 }

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

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

@@ -7,6 +7,7 @@ import com.qmth.sop.business.bean.result.SysMessageResult;
 import com.qmth.sop.business.bean.result.SysMessageWorkResult;
 import com.qmth.sop.business.bean.result.SysMessageWorkResult;
 import com.qmth.sop.business.entity.SysMessage;
 import com.qmth.sop.business.entity.SysMessage;
 import com.qmth.sop.business.entity.SysNotice;
 import com.qmth.sop.business.entity.SysNotice;
+import com.qmth.sop.common.enums.MessageEnum;
 import com.qmth.sop.common.enums.MessageTypeEnum;
 import com.qmth.sop.common.enums.MessageTypeEnum;
 
 
 import java.util.List;
 import java.util.List;
@@ -52,4 +53,16 @@ public interface SysMessageService extends IService<SysMessage> {
 
 
     IPage<SysMessageWorkResult> pageByTypes(IPage<Map> iPage, MessageTypeEnum[] types, Boolean status, Long serviceId,
     IPage<SysMessageWorkResult> pageByTypes(IPage<Map> iPage, MessageTypeEnum[] types, Boolean status, Long serviceId,
             String custom, String query, Long startTime, Long endTime);
             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);
 }
 }

+ 11 - 0
sop-business/src/main/java/com/qmth/sop/business/service/TBCrmDetailService.java

@@ -7,7 +7,9 @@ import com.qmth.sop.business.bean.params.TBCrmDetailParam;
 import com.qmth.sop.business.bean.result.CrmProjectResult;
 import com.qmth.sop.business.bean.result.CrmProjectResult;
 import com.qmth.sop.business.entity.TBCrmDetail;
 import com.qmth.sop.business.entity.TBCrmDetail;
 import com.qmth.sop.business.entity.TFCustomFlow;
 import com.qmth.sop.business.entity.TFCustomFlow;
+import com.qmth.sop.business.entity.TFFlowApprove;
 import com.qmth.sop.common.enums.FlowStatusEnum;
 import com.qmth.sop.common.enums.FlowStatusEnum;
+import com.qmth.sop.common.enums.TFCustomTypeEnum;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartFile;
 
 
 import java.util.List;
 import java.util.List;
@@ -129,4 +131,13 @@ public interface TBCrmDetailService extends IService<TBCrmDetail> {
      * @return 派单明细
      * @return 派单明细
      */
      */
     List<TBCrmDetail> findByServiceIdAndCustomId(Long serviceId, Long customId);
     List<TBCrmDetail> findByServiceIdAndCustomId(Long serviceId, Long customId);
+
+    /**
+     * 保存实际时间
+     *
+     * @param type
+     * @param tfFlowApprove
+     * @param tbCrmDetail
+     */
+    void saveActualTime(TFCustomTypeEnum type, TFFlowApprove tfFlowApprove, TBCrmDetail tbCrmDetail);
 }
 }

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

@@ -140,4 +140,22 @@ public class SysMessageServiceImpl extends ServiceImpl<SysMessageMapper, SysMess
         return this.baseMapper.pageByTypes(iPage, typeStr.length > 0 ? typeStr : null, status, serviceId, custom, query,
         return this.baseMapper.pageByTypes(iPage, typeStr.length > 0 ? typeStr : null, status, serviceId, custom, query,
                 startTime, endTime, sysUser.getId());
                 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));
+    }
 }
 }

+ 46 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBCrmDetailServiceImpl.java

@@ -588,4 +588,50 @@ public class TBCrmDetailServiceImpl extends ServiceImpl<TBCrmDetailMapper, TBCrm
     public List<TBCrmDetail> findByServiceIdAndCustomId(Long serviceId, Long customId) {
     public List<TBCrmDetail> findByServiceIdAndCustomId(Long serviceId, Long customId) {
         return this.baseMapper.findByServiceIdAndCustomId(serviceId, customId);
         return this.baseMapper.findByServiceIdAndCustomId(serviceId, customId);
     }
     }
+
+    /**
+     * 保存实际时间
+     *
+     * @param type
+     * @param tfFlowApprove
+     * @param tbCrmDetail
+     */
+    @Override
+    @Transactional
+    public void saveActualTime(TFCustomTypeEnum type, TFFlowApprove tfFlowApprove, TBCrmDetail tbCrmDetail) {
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+        Long updateTime = tbCrmDetail.getUpdateTime();
+        if (type == TFCustomTypeEnum.OFFICE_SOP_FLOW) {
+            if (tfFlowApprove.getSetup().intValue() == 3) {//扫描收尾检查
+                tbCrmDetail.setScanActualStartTime(tfFlowApprove.getUpdateTime());
+                tbCrmDetail.updateInfo(sysUser.getId());
+            } else if (tfFlowApprove.getSetup().intValue() == 4) {//阅卷参数检查
+                tbCrmDetail.setScanActualEndTime(tfFlowApprove.getUpdateTime());
+                tbCrmDetail.updateInfo(sysUser.getId());
+            } else if (tfFlowApprove.getSetup().intValue() == 5) {//阅卷收尾检查
+                tbCrmDetail.setMarkPaperActualStartTime(tfFlowApprove.getUpdateTime());
+                tbCrmDetail.updateInfo(sysUser.getId());
+            } else if (tfFlowApprove.getSetup().intValue() == 0) {//结束
+                tbCrmDetail.setMarkPaperActualEndTime(tfFlowApprove.getUpdateTime());
+                tbCrmDetail.updateInfo(sysUser.getId());
+            }
+        } else if (type == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {
+            if (tfFlowApprove.getSetup().intValue() == 5) {//扫描准备
+                tbCrmDetail.setScanActualStartTime(tfFlowApprove.getUpdateTime());
+                tbCrmDetail.updateInfo(sysUser.getId());
+            } else if (tfFlowApprove.getSetup().intValue() == 7) {//校验收尾
+                tbCrmDetail.setScanActualEndTime(tfFlowApprove.getUpdateTime());
+                tbCrmDetail.updateInfo(sysUser.getId());
+            } else if (tfFlowApprove.getSetup().intValue() == 8) {//成绩复核
+                tbCrmDetail.setMarkPaperActualStartTime(tfFlowApprove.getUpdateTime());
+                tbCrmDetail.updateInfo(sysUser.getId());
+            } else if (tfFlowApprove.getSetup().intValue() == 0) {//结束
+                tbCrmDetail.setMarkPaperActualEndTime(tfFlowApprove.getUpdateTime());
+                tbCrmDetail.updateInfo(sysUser.getId());
+            }
+        }
+        if (Objects.isNull(updateTime) || updateTime.longValue() != tbCrmDetail.getUpdateTime().longValue()) {
+            tbCrmDetailService.updateById(tbCrmDetail);
+        }
+    }
 }
 }

+ 4 - 1
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBSopInfoServiceImpl.java

@@ -851,10 +851,13 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
             map.put(SystemConstant.SOP_ID, tbSopInfo.getId());
             map.put(SystemConstant.SOP_ID, tbSopInfo.getId());
             tbSopInfoService.saveJobRemind(map);
             tbSopInfoService.saveJobRemind(map);
 
 
-            //新增sop日志
             TFFlowApprove tfFlowApprove = (TFFlowApprove) map.get(SystemConstant.FLOW_APPROVE);
             TFFlowApprove tfFlowApprove = (TFFlowApprove) map.get(SystemConstant.FLOW_APPROVE);
             Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_NO_DATA.exception());
             Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_NO_DATA.exception());
 
 
+            //新增保存实际时间
+            tbCrmDetailService.saveActualTime(tfCustomFlow.getType(), tfFlowApprove, tbCrmDetail);
+
+            //新增sop日志
             TBSopLog tbSopLog = new TBSopLog(tbSopInfo.getId(), SopLogTypeEnum.APPROVE, tfFlowApprove.getStatus(),
             TBSopLog tbSopLog = new TBSopLog(tbSopInfo.getId(), SopLogTypeEnum.APPROVE, tfFlowApprove.getStatus(),
                     tfFlowApprove.getSetup(), oldFlowProcessVar, tfCustomFlowEntity.getFlowProcessVar(),
                     tfFlowApprove.getSetup(), oldFlowProcessVar, tfCustomFlowEntity.getFlowProcessVar(),
                     sysUser.getId());
                     sysUser.getId());

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

@@ -570,6 +570,8 @@ public class SystemConstant {
     /**
     /**
      * 锁
      * 锁
      */
      */
+    public static final String LOCK_FLOW_TASK_MSG_PREFIX = "lock:flow:task:msg";//流程节点消息锁
+
     public static final String LOCK_FLOW_TASK_PREFIX = "lock:flow:task:";//流程节点锁
     public static final String LOCK_FLOW_TASK_PREFIX = "lock:flow:task:";//流程节点锁
 
 
     public static final String LOCK_FLOW_END_PREFIX = "lock:flow:end:";//流程结束锁
     public static final String LOCK_FLOW_END_PREFIX = "lock:flow:end:";//流程结束锁
@@ -594,6 +596,8 @@ public class SystemConstant {
 
 
     public static final Long LOCK_FLOW_TIME_OUT = 60L * 2 * 1000;
     public static final Long LOCK_FLOW_TIME_OUT = 60L * 2 * 1000;
 
 
+    public static final Long LOCK_FLOW_MSG_TIME_OUT = 60L * 2 * 1000;
+
     public static final Long LOCK_SEQUENCE_TIME_OUT = 60L * 1 * 1000;
     public static final Long LOCK_SEQUENCE_TIME_OUT = 60L * 1 * 1000;
 
 
     public static final Long LOCK_JOB_TIME_OUT = 60L * 5 * 1000;
     public static final Long LOCK_JOB_TIME_OUT = 60L * 5 * 1000;