浏览代码

广药子流程update

wangliang 3 年之前
父节点
当前提交
22fd81b67d
共有 14 个文件被更改,包括 102 次插入63 次删除
  1. 21 1
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/activiti/StartApproveSubListener.java
  2. 0 31
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/activiti/TeacherApproveSubListener.java
  3. 8 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/TFFlowApproveLogMapper.java
  4. 8 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/TFFlowApproveLogService.java
  5. 24 21
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ActivitiServiceImpl.java
  6. 15 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TFFlowApproveLogServiceImpl.java
  7. 1 1
      distributed-print-business/src/main/resources/mapper/ExamTaskMapper.xml
  8. 2 2
      distributed-print-business/src/main/resources/mapper/ExamTaskReviewLogMapper.xml
  9. 3 0
      distributed-print-business/src/main/resources/mapper/TFFlowApproveLogMapper.xml
  10. 1 1
      distributed-print-business/src/main/resources/mapper/TFFlowApproveMapper.xml
  11. 1 1
      distributed-print-business/src/main/resources/mapper/TFFlowMapper.xml
  12. 16 0
      distributed-print/src/main/java/com/qmth/distributed/print/api/TFFlowController.java
  13. 1 5
      distributed-print/src/main/resources/processes/GdykdxPaperApproveSubByPrint.bpmn
  14. 1 0
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/contant/SystemConstant.java

+ 21 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/activiti/StartApproveSubListener.java

@@ -1,12 +1,19 @@
 package com.qmth.distributed.print.business.activiti;
 
 import com.qmth.distributed.print.business.entity.ExamTask;
+import com.qmth.distributed.print.business.entity.TFFlowApprove;
+import com.qmth.distributed.print.business.entity.TFFlowApproveLog;
 import com.qmth.distributed.print.business.service.ExamTaskService;
+import com.qmth.distributed.print.business.service.TFFlowApproveLogService;
+import com.qmth.distributed.print.business.service.TFFlowApproveService;
 import com.qmth.teachcloud.common.contant.SpringContextHolder;
 import org.activiti.engine.delegate.DelegateExecution;
 import org.activiti.engine.delegate.ExecutionListener;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.StringJoiner;
 
 /**
  * @Description: 子流程启动监听
@@ -19,10 +26,23 @@ public class StartApproveSubListener implements ExecutionListener {
     private final static Logger log = LoggerFactory.getLogger(StartApproveSubListener.class);
 
     @Override
+    @Transactional
     public void notify(DelegateExecution delegateExecution) {
         ExamTaskService examTaskService = SpringContextHolder.getBean(ExamTaskService.class);
+        TFFlowApproveService tfFlowApproveService = SpringContextHolder.getBean(TFFlowApproveService.class);
+        TFFlowApproveLogService tfFlowApproveLogService = SpringContextHolder.getBean(TFFlowApproveLogService.class);
+
+        TFFlowApprove flowApprove = tfFlowApproveService.findByFlowId(delegateExecution.getRootProcessInstanceId());
+        TFFlowApproveLog tfFlowApproveLog = tfFlowApproveLogService.findByFlowId(delegateExecution.getRootProcessInstanceId());
         ExamTask examTask = examTaskService.findByFlowId(delegateExecution.getRootProcessInstanceId());
-        examTask.setFlowId(examTask.getFlowId() + "," + delegateExecution.getProcessInstanceId());
+        String flowIds = new StringJoiner("").add(examTask.getFlowId()).add(",").add(delegateExecution.getProcessInstanceId()).toString();
+        examTask.setFlowId(flowIds);
         examTaskService.updateById(examTask);
+
+        flowApprove.setFlowId(flowIds);
+        tfFlowApproveService.updateById(flowApprove);
+
+        tfFlowApproveLog.setFlowId(flowIds);
+        tfFlowApproveLogService.updateById(tfFlowApproveLog);
     }
 }

+ 0 - 31
distributed-print-business/src/main/java/com/qmth/distributed/print/business/activiti/TeacherApproveSubListener.java

@@ -1,31 +0,0 @@
-package com.qmth.distributed.print.business.activiti;
-
-import com.qmth.distributed.print.business.service.ActivitiService;
-import com.qmth.teachcloud.common.contant.SpringContextHolder;
-import com.qmth.teachcloud.common.contant.SystemConstant;
-import org.activiti.engine.delegate.DelegateTask;
-import org.activiti.engine.delegate.TaskListener;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @Description: 子流程启动监听
- * @Param:
- * @return:
- * @Author: wangliang
- * @Date: 2021/11/19
- */
-public class TeacherApproveSubListener implements TaskListener {
-    private final static Logger log = LoggerFactory.getLogger(TeacherApproveSubListener.class);
-
-    @Override
-    public void notify(DelegateTask delegateTask) {
-//        ActivitiService activitiService = SpringContextHolder.getBean(ActivitiService.class);
-//        Map<String, Object> map = new HashMap<>();
-//        map.computeIfAbsent(SystemConstant.FLOW_TASK_ID, v -> delegateTask.getId());
-//        activitiService.taskApprove(map);
-    }
-}

+ 8 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/TFFlowApproveLogMapper.java

@@ -2,6 +2,7 @@ package com.qmth.distributed.print.business.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.qmth.distributed.print.business.entity.TFFlowApproveLog;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * <p>
@@ -13,4 +14,11 @@ import com.qmth.distributed.print.business.entity.TFFlowApproveLog;
  */
 public interface TFFlowApproveLogMapper extends BaseMapper<TFFlowApproveLog> {
 
+    /**
+     * 根据流程id查询流程状态
+     *
+     * @param flowId
+     * @return
+     */
+    TFFlowApproveLog findByFlowId(@Param("flowId") String flowId);
 }

+ 8 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/TFFlowApproveLogService.java

@@ -1,6 +1,7 @@
 package com.qmth.distributed.print.business.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.distributed.print.business.entity.TFFlowApprove;
 import com.qmth.distributed.print.business.entity.TFFlowApproveLog;
 
 /**
@@ -13,4 +14,11 @@ import com.qmth.distributed.print.business.entity.TFFlowApproveLog;
  */
 public interface TFFlowApproveLogService extends IService<TFFlowApproveLog> {
 
+    /**
+     * 根据流程id查询流程状态
+     *
+     * @param flowId
+     * @return
+     */
+    TFFlowApproveLog findByFlowId(String flowId);
 }

+ 24 - 21
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ActivitiServiceImpl.java

@@ -31,7 +31,6 @@ import org.activiti.engine.RepositoryService;
 import org.activiti.engine.RuntimeService;
 import org.activiti.engine.TaskService;
 import org.activiti.engine.impl.RepositoryServiceImpl;
-import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
 import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
 import org.activiti.engine.repository.DeploymentBuilder;
 import org.activiti.engine.runtime.ProcessInstance;
@@ -181,9 +180,7 @@ public class ActivitiServiceImpl implements ActivitiService {
             SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
             runtimeService.deleteProcessInstance(flowId, FlowApproveSetupEnum.END.getTitle());
             //流程审批
-            QueryWrapper<TFFlowApprove> tfFlowApproveQueryWrapper = new QueryWrapper<>();
-            tfFlowApproveQueryWrapper.lambda().eq(TFFlowApprove::getFlowId, Long.parseLong(flowId));
-            TFFlowApprove tfFlowApprove = tfFlowApproveService.getOne(tfFlowApproveQueryWrapper);
+            TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(flowId);
             if (Objects.isNull(tfFlowApprove)) {
                 ExamTask examTask = examTaskService.findByFlowId(flowId);
                 int count = sysUserService.countByTeachingRoomId(examTask.getTeachingRoomId());
@@ -212,10 +209,7 @@ public class ActivitiServiceImpl implements ActivitiService {
                 if (currFlow instanceof UserTask) {
                     UserTask userTask = (UserTask) currFlow;
                     //流程审批记录
-                    QueryWrapper<TFFlowApproveLog> tfFlowApproveLogQueryWrapper = new QueryWrapper<>();
-                    tfFlowApproveLogQueryWrapper.lambda().eq(TFFlowApproveLog::getFlowId, Long.parseLong(flowId))
-                            .eq(TFFlowApproveLog::getTaskId, examTask.getId());
-                    TFFlowApproveLog tfFlowApproveLog = tfFlowApproveLogService.getOne(tfFlowApproveLogQueryWrapper);
+                    TFFlowApproveLog tfFlowApproveLog = tfFlowApproveLogService.findByFlowId(flowId);
                     if (Objects.isNull(tfFlowApproveLog)) {
                         tfFlowApproveLog = new TFFlowApproveLog(sysUser.getSchoolId(), sysUser.getOrgId(), flowId, examTask.getId(), sysUser.getId(), sysUser.getId());
                     }
@@ -313,16 +307,12 @@ public class ActivitiServiceImpl implements ActivitiService {
             FlowNode currFlow = (FlowNode) bpmnModel.getMainProcess().getFlowElement(currActivityId);
 
             //流程审批
-            QueryWrapper<TFFlowApprove> tfFlowApproveQueryWrapper = new QueryWrapper<>();
-            tfFlowApproveQueryWrapper.lambda().eq(TFFlowApprove::getFlowId, Long.parseLong(processInstanceId));
-            TFFlowApprove tfFlowApprove = tfFlowApproveService.getOne(tfFlowApproveQueryWrapper);
+            TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(processInstanceId);
 
             //流程审批记录
-            QueryWrapper<TFFlowApproveLog> tfFlowApproveLogQueryWrapper = new QueryWrapper<>();
-            tfFlowApproveLogQueryWrapper.lambda().eq(TFFlowApproveLog::getFlowId, Long.parseLong(processInstanceId))
-                    .eq(TFFlowApproveLog::getTaskId, examTask.getId());
-            TFFlowApproveLog tfFlowApproveLog = tfFlowApproveLogService.getOne(tfFlowApproveLogQueryWrapper);
+            TFFlowApproveLog tfFlowApproveLog = tfFlowApproveLogService.findByFlowId(processInstanceId);
 
+            Map<String, Object> objectMap = new HashMap<>();
             TFFlowLog tfFlowLog = null;
             if (currFlow instanceof UserTask) {
                 UserTask userTask = (UserTask) currFlow;
@@ -370,8 +360,15 @@ public class ActivitiServiceImpl implements ActivitiService {
                         } else if (approve == FlowApproveVariableEnum.SECOND_APPROVE) {//提交
                             tfFlowLog.setApproveOperation(FlowApproveOperationEnum.APPROVE);
                             tfFlowApproveLog.setSecondApproveOperation(FlowApproveOperationEnum.APPROVE);
-                            tfFlowApprove.setStatus(FlowStatusEnum.AUDITING);
-                            tfFlowApprove.setSetup(FlowApproveSetupEnum.THREE_APPROVE.getSetup());
+                            List<FlowTaskResult> taskTaskAll = getTaskAll(processInstanceId);
+                            if (Objects.nonNull(taskTaskAll) && taskTaskAll.size() > 3) {
+                                tfFlowApprove.setStatus(FlowStatusEnum.AUDITING);
+                                tfFlowApprove.setSetup(FlowApproveSetupEnum.THREE_APPROVE.getSetup());
+                                objectMap.computeIfAbsent(SystemConstant.APPROVE_PRESIDENT_SYSTEM, v -> true);
+                            } else {
+                                tfFlowApprove.setStatus(FlowStatusEnum.FINISH);
+                                tfFlowApprove.setSetup(FlowApproveSetupEnum.FINISH.getSetup());
+                            }
                         } else {
                             throw ExceptionResultEnum.ERROR.exception("流程变量值错误");
                         }
@@ -380,13 +377,20 @@ public class ActivitiServiceImpl implements ActivitiService {
                         TFFlowApproveLog finalTfFlowApproveLog = tfFlowApproveLog;
                         map.computeIfAbsent(SystemConstant.APPROVE_ID, v -> finalTfFlowApproveLog.getStartId());
                     } else if (setupEnum == FlowApproveSetupEnum.THREE_APPROVE) {//命题提交
-                        flowSubmitVaild(task, sysUser.getId());
+                        boolean presidentApprove = Objects.nonNull(map.get(SystemConstant.APPROVE_PRESIDENT_SYSTEM)) ? (boolean) map.get(SystemConstant.APPROVE_PRESIDENT_SYSTEM) : false;
+                        Long userId = null;
+                        if (presidentApprove) {
+                            userId = tfFlowApproveLog.getStartId();
+                        } else {
+                            userId = sysUser.getId();
+                        }
+                        flowSubmitVaild(task, userId);
                         tfFlowLog.setApproveSetup(FlowApproveSetupEnum.THREE_APPROVE.getSetup());
                         tfFlowLog.setApproveOperation(FlowApproveOperationEnum.APPROVE);
                         tfFlowApprove.setStatus(FlowStatusEnum.AUDITING);
                         tfFlowApprove.setSetup(FlowApproveSetupEnum.THREE_APPROVE.getSetup());
-                        tfFlowApproveLog.setStartApproveId(sysUser.getId());
-                        tfFlowApproveLog.setSecondApproveRemark(remark);
+                        tfFlowApproveLog.setStartApproveId(userId);
+                        tfFlowApproveLog.setThreeApproveRemark(remark);
                         map.computeIfAbsent(SystemConstant.APPROVE_PRINT_USER_IDS, v -> map.get(SystemConstant.APPROVE_USER_IDS));
                     } else if (setupEnum == FlowApproveSetupEnum.FOUR_APPROVE) {//印刷员提交
                         flowApproveVaild(task, sysUser.getId(), map);
@@ -436,7 +440,6 @@ public class ActivitiServiceImpl implements ActivitiService {
             }
             examTask.updateInfo(sysUser.getId());
             examTaskService.updateById(examTask);
-            Map<String, Object> objectMap = new HashMap<>();
             objectMap.putIfAbsent("tfFlowApprove", tfFlowApprove);
             objectMap.putIfAbsent("examTask", examTask);
             objectMap.putIfAbsent("sysUser", sysUser);

+ 15 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TFFlowApproveLogServiceImpl.java

@@ -6,6 +6,8 @@ import com.qmth.distributed.print.business.mapper.TFFlowApproveLogMapper;
 import com.qmth.distributed.print.business.service.TFFlowApproveLogService;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
+
 /**
  * <p>
  * 流程审批记录 服务实现类
@@ -17,4 +19,17 @@ import org.springframework.stereotype.Service;
 @Service
 public class TFFlowApproveLogServiceImpl extends ServiceImpl<TFFlowApproveLogMapper, TFFlowApproveLog> implements TFFlowApproveLogService {
 
+    @Resource
+    TFFlowApproveLogMapper tfFlowApproveLogMapper;
+
+    /**
+     * 根据流程id查询流程状态
+     *
+     * @param flowId
+     * @return
+     */
+    @Override
+    public TFFlowApproveLog findByFlowId(String flowId) {
+        return tfFlowApproveLogMapper.findByFlowId(flowId);
+    }
 }

+ 1 - 1
distributed-print-business/src/main/resources/mapper/ExamTaskMapper.xml

@@ -1143,7 +1143,7 @@
     </select>
 
     <select id="findByFlowId" resultType="com.qmth.distributed.print.business.entity.ExamTask">
-        select * from exam_task et where find_in_set(et.flow_id ,#{flowId})
+        select * from exam_task et where find_in_set(#{flowId} ,et.flow_id)
     </select>
 
     <select id="getProcessDefinitionIdByMaxVersion" resultType="java.lang.String">

+ 2 - 2
distributed-print-business/src/main/resources/mapper/ExamTaskReviewLogMapper.xml

@@ -30,7 +30,7 @@
         from
             t_f_flow_log tffl
         left join sys_user su on tffl.approve_id = su.id
-        where find_in_set(tffl.flow_id ,#{flowId})
+        where find_in_set(#{flowId} ,tffl.flow_id)
         order by tffl.create_time desc
     </select>
 
@@ -49,7 +49,7 @@
         <where>
             AND tffl.approve_operation = 'APPROVE'
             <if test="flowId > 0 and flowId != ''">
-                AND find_in_set(tffl.flow_id ,#{flowId})
+                AND find_in_set(#{flowId} ,tffl.flow_id)
             </if>
             <if test="setup != null and setup != ''">
                 AND tffl.approve_setup = #{setup}

+ 3 - 0
distributed-print-business/src/main/resources/mapper/TFFlowApproveLogMapper.xml

@@ -2,4 +2,7 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.qmth.distributed.print.business.mapper.TFFlowApproveLogMapper">
 
+    <select id="findByFlowId" resultType="com.qmth.distributed.print.business.entity.TFFlowApproveLog">
+        select * from t_f_flow_approve_log tffal where find_in_set(#{flowId} ,tffal.flow_id)
+    </select>
 </mapper>

+ 1 - 1
distributed-print-business/src/main/resources/mapper/TFFlowApproveMapper.xml

@@ -3,6 +3,6 @@
 <mapper namespace="com.qmth.distributed.print.business.mapper.TFFlowApproveMapper">
 
     <select id="findByFlowId" resultType="com.qmth.distributed.print.business.entity.TFFlowApprove">
-        select * from t_f_flow_approve tffa where find_in_set(tffa.flow_id ,#{flowId})
+        select * from t_f_flow_approve tffa where find_in_set(#{flowId} ,tffa.flow_id)
     </select>
 </mapper>

+ 1 - 1
distributed-print-business/src/main/resources/mapper/TFFlowMapper.xml

@@ -59,7 +59,7 @@
 <!--                and tffal.org_id = #{orgId}-->
 <!--            </if>-->
             <if test="flowId != null and flowId != ''">
-                and find_in_set(tffal.flow_id ,#{flowId})
+                and find_in_set(#{flowId} ,tffal.flow_id)
             </if>
             and tffal.enable = 1
         </where>

+ 16 - 0
distributed-print/src/main/java/com/qmth/distributed/print/api/TFFlowController.java

@@ -31,6 +31,8 @@ import com.qmth.teachcloud.common.util.Result;
 import com.qmth.teachcloud.common.util.ResultUtil;
 import com.qmth.teachcloud.common.util.ServletUtil;
 import io.swagger.annotations.*;
+import org.activiti.engine.TaskService;
+import org.activiti.engine.task.Task;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -85,6 +87,9 @@ public class TFFlowController {
     @Autowired
     BasicMessageService basicMessageService;
 
+    @Resource
+    TaskService taskService;
+
     @ApiOperation(value = "注册流程")
     @Transactional
     @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = ResultUtil.class)})
@@ -176,6 +181,7 @@ public class TFFlowController {
         if (Objects.nonNull(objectMap)) {
             TFFlowApprove tfFlowApprove = (TFFlowApprove) objectMap.get("tfFlowApprove");
             ExamTask examTask = (ExamTask) objectMap.get("examTask");
+            boolean presidentApprove = Objects.nonNull(objectMap.get(SystemConstant.APPROVE_PRESIDENT_SYSTEM)) ? (boolean) objectMap.get(SystemConstant.APPROVE_PRESIDENT_SYSTEM) : false;
             //审核通过,生成pdf
             if (Objects.nonNull(tfFlowApprove) && FlowApproveSetupEnum.FINISH.getSetup() == tfFlowApprove.getSetup()) {
                 // 取命题老师ID
@@ -185,6 +191,16 @@ public class TFFlowController {
                 } catch (IOException e) {
                     throw ExceptionResultEnum.ERROR.exception("生成pdf失败");
                 }
+            } else if (Objects.nonNull(tfFlowApprove) && FlowApproveSetupEnum.THREE_APPROVE.getSetup() == tfFlowApprove.getSetup() && presidentApprove) {//命题老师后台提交
+                String flowId = examTask.getFlowId();
+                String[] flowIds = flowId.split(",");
+                Task task = taskService.createTaskQuery().processInstanceId(flowIds[1]).singleResult();
+                if (Objects.nonNull(task)) {
+                    Map<String, Object> mapObject = new HashMap<>();
+                    mapObject.computeIfAbsent(SystemConstant.FLOW_TASK_ID, v -> task.getId());
+                    mapObject.computeIfAbsent(SystemConstant.APPROVE_PRESIDENT_SYSTEM, v -> presidentApprove);
+                    activitiService.taskApprove(mapObject);
+                }
             }
 
             // 驳回短信(驳回给提交老师)

+ 1 - 5
distributed-print/src/main/resources/processes/GdykdxPaperApproveSubByPrint.bpmn

@@ -6,11 +6,7 @@
         <activiti:executionListener event="start" class="com.qmth.distributed.print.business.activiti.StartApproveSubListener"></activiti:executionListener>
       </extensionElements>
     </startEvent>
-    <userTask id="usertask4" name="提交试卷" activiti:assignee="${approveId}">
-      <extensionElements>
-        <activiti:taskListener event="create" class="com.qmth.distributed.print.business.activiti.TeacherApproveSubListener"></activiti:taskListener>
-      </extensionElements>
-    </userTask>
+    <userTask id="usertask4" name="提交试卷" activiti:assignee="${approveId}"></userTask>
     <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="usertask4"></sequenceFlow>
     <userTask id="usertask5" name="审核试卷">
       <extensionElements>

+ 1 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/contant/SystemConstant.java

@@ -212,6 +212,7 @@ public class SystemConstant {
     public static final String APPROVE_OPERATION = "approveOperation";//流程操作
     public static final String FLOW_STATUS = "flowStatus";//流程状态
     public static final String APPROVE_REMARK = "approveRemark";//流程审批意见
+    public static final String APPROVE_PRESIDENT_SYSTEM = "presidentApprove";//流程院长自动审批
     public static final String REDIS_LOCK_FLOW_TASK_PREFIX = "redis:lock:flow:task:";//流程节点锁
     public static final long REDIS_LOCK_FLOW_TASK_TIME_OUT = 60L * 2;
     public static final String REDIS_LOCK_FLOW_PREFIX = "redis:lock:flow:";//流程锁