Jelajahi Sumber

新增流程结束更新crm状态

wangliang 1 tahun lalu
induk
melakukan
5934c42a4d

+ 2 - 2
sop-api/src/main/java/com/qmth/sop/server/api/TBSopInfoController.java

@@ -51,7 +51,7 @@ public class TBSopInfoController {
     @ApiOperation(value = "sop元数据查询")
     @RequestMapping(value = "/metadata/list", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = TDFormWidgetMetadata.class)})
-    public Result list(@ApiParam(value = "sop流程类型", required = true) @RequestParam TFCustomTypeEnum type,
+    public Result metadataList(@ApiParam(value = "sop流程类型", required = true) @RequestParam TFCustomTypeEnum type,
                        @ApiParam(value = "sop流程版本") @RequestParam(required = false) Integer version) {
         return ResultUtil.ok(tdFormWidgetMetadataService.selectAll(type, Objects.isNull(version) ? 1 : version));
     }
@@ -59,7 +59,7 @@ public class TBSopInfoController {
     @ApiOperation(value = "sop元数据修改")
     @RequestMapping(value = "/metadata/save", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
-    public Result list(@Valid @ApiParam(value = "元数据保存信息", required = true) @RequestBody List<TDFormWidgetMetadata> formWidgetMetadataList, BindingResult bindingResult) {
+    public Result metadataSave(@Valid @ApiParam(value = "元数据保存信息", required = true) @RequestBody List<TDFormWidgetMetadata> formWidgetMetadataList, BindingResult bindingResult) {
         return ResultUtil.ok(tdFormWidgetMetadataService.save(formWidgetMetadataList));
     }
 

+ 10 - 6
sop-business/src/main/java/com/qmth/sop/business/activiti/listener/ProcessEventListener.java

@@ -7,10 +7,7 @@ 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.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.service.*;
 import com.qmth.sop.business.util.SmsSendUtil;
 import com.qmth.sop.common.contant.SpringContextHolder;
 import com.qmth.sop.common.contant.SystemConstant;
@@ -56,6 +53,9 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
             case PROCESS_COMPLETED:
                 // 流程结束
                 log.info("流程结束_PROCESS_COMPLETED:ProcessInstanceId:{},ExecutionId:{},ProcessDefinitionId:{}", event.getProcessInstanceId(), event.getExecutionId(), event.getProcessDefinitionId());
+                //todo 流程结束修改派单状态
+                TBCrmService tbCrmService = SpringContextHolder.getBean(TBCrmService.class);
+                TFFlowApproveService tfFlowApproveService = SpringContextHolder.getBean(TFFlowApproveService.class);
                 HistoryService historyService = SpringContextHolder.getBean(HistoryService.class);
 
                 List<HistoricVariableInstance> historicVariableInstanceList = historyService.createHistoricVariableInstanceQuery().processInstanceId(event.getProcessInstanceId()).list();
@@ -83,6 +83,10 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
                         }
                     }
                     this.sendFlowFinishSms(tfCustomFlow.getType(), tfCustomFlowEntity, tfFlowApprove.getStatus(), tfFlowLog);
+                    int count = tfFlowApproveService.findFlowPassageSopByCrmNo(tfCustomFlowEntity.getCrmNo());
+                    if (count == 0) {
+                        tbCrmService.updateCrmStatus(tfCustomFlowEntity.getCrmNo(), CrmStatusEnum.FINISH);
+                    }
                 }
                 break;
             case TASK_CREATED:
@@ -120,7 +124,7 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
                             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()));
 //                                if (CollectionUtils.isEmpty(map)) {//系统自动提交的不发待办短信
-                                    this.sendSopFlowDoneSms(tfCustomFlow.getType(), tfCustomFlowEntity, task.getName(), Long.parseLong(task.getAssignee()));
+                                this.sendSopFlowDoneSms(tfCustomFlow.getType(), tfCustomFlowEntity, task.getName(), Long.parseLong(task.getAssignee()));
 //                                    jobRemindService.saveJobRemind(tsJobRemindArrayList);
 //                                }
                             } else {
@@ -129,7 +133,7 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
                                     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()));
 //                                        if (CollectionUtils.isEmpty(map)) {//系统自动提交的不发待办短信
-                                            this.sendSopFlowDoneSms(tfCustomFlow.getType(), tfCustomFlowEntity, task.getName(), Long.parseLong(i.getUserId()));
+                                        this.sendSopFlowDoneSms(tfCustomFlow.getType(), tfCustomFlowEntity, task.getName(), Long.parseLong(i.getUserId()));
 //                                            jobRemindService.saveJobRemind(tsJobRemindArrayList);
 //                                        }
                                     }

+ 8 - 0
sop-business/src/main/java/com/qmth/sop/business/mapper/TFFlowApproveMapper.java

@@ -23,4 +23,12 @@ public interface TFFlowApproveMapper extends BaseMapper<TFFlowApprove> {
      * @return
      */
     List<Long> findFlowIdByCrmNo(@Param("crmNo") String crmNo);
+
+    /**
+     * 根据crmNo查找sop在途的流程数
+     *
+     * @param crmNo
+     * @return
+     */
+    int findFlowPassageSopByCrmNo(@Param("crmNo") String crmNo);
 }

+ 8 - 0
sop-business/src/main/java/com/qmth/sop/business/service/TFFlowApproveService.java

@@ -22,4 +22,12 @@ public interface TFFlowApproveService extends IService<TFFlowApprove> {
      * @return
      */
     List<Long> findFlowIdByCrmNo(String crmNo);
+
+    /**
+     * 根据crmNo查找sop在途的流程数
+     *
+     * @param crmNo
+     * @return
+     */
+    int findFlowPassageSopByCrmNo(String crmNo);
 }

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

@@ -29,4 +29,15 @@ public class TFFlowApproveServiceImpl extends ServiceImpl<TFFlowApproveMapper, T
     public List<Long> findFlowIdByCrmNo(String crmNo) {
         return this.baseMapper.findFlowIdByCrmNo(crmNo);
     }
+
+    /**
+     * 根据crmNo查找sop在途的流程数
+     *
+     * @param crmNo
+     * @return
+     */
+    @Override
+    public int findFlowPassageSopByCrmNo(String crmNo) {
+        return this.baseMapper.findFlowPassageSopByCrmNo(crmNo);
+    }
 }

+ 13 - 0
sop-business/src/main/resources/mapper/TFFlowApproveMapper.xml

@@ -12,4 +12,17 @@
                 and tffa.status not in('FINISH','END')
         </where>
     </select>
+
+    <select id="findFlowPassageSopByCrmNo" resultType="java.lang.Integer">
+        select count(1)
+        from
+            t_f_flow_approve tffa
+            join t_f_custom_flow_entity tfcfe on tfcfe.flow_id = tffa.flow_id
+            join t_f_custom_flow tfcf on tfcf.id = tfcfe.t_f_custom_flow_id
+        where
+            1 = 1
+          and (tfcf.`type` = 'OFFICE_SOP_FLOW' or tfcf.`type` = 'CLOUD_MARK_SOP_FLOW')
+          and tfcfe.crm_no = #{crmNo}
+          and tffa.status not in ('FINISH', 'END')
+    </select>
 </mapper>