Browse Source

自定义流程表结构调整

wangliang 3 years ago
parent
commit
3412ba9041
26 changed files with 440 additions and 338 deletions
  1. 17 6
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/result/FlowApproveListResult.java
  2. 17 6
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/result/TFFlowLogResult.java
  3. 18 6
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/result/TFFlowViewLogResult.java
  4. 23 11
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TFFlowJoin.java
  5. 25 11
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TFFlowLog.java
  6. 11 4
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/enums/TFCustomTypeEnum.java
  7. 0 42
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/TExamTaskFlowMapper.java
  8. 48 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/TFFlowJoinMapper.java
  9. 3 3
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/TFFlowLogMapper.java
  10. 10 10
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/TFFlowJoinService.java
  11. 3 3
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/TFFlowLogService.java
  12. 27 17
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ActivitiServiceImpl.java
  13. 5 3
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskDetailServiceImpl.java
  14. 19 13
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskServiceImpl.java
  15. 0 139
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TExamTaskFlowServiceImpl.java
  16. 143 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TFFlowJoinServiceImpl.java
  17. 4 4
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TFFlowLogServiceImpl.java
  18. 15 15
      distributed-print-business/src/main/resources/mapper/ExamTaskMapper.xml
  19. 6 6
      distributed-print-business/src/main/resources/mapper/ExamTaskReviewLogMapper.xml
  20. 0 19
      distributed-print-business/src/main/resources/mapper/TExamTaskFlowMapper.xml
  21. 5 4
      distributed-print-business/src/main/resources/mapper/TFFlowApproveMapper.xml
  22. 20 0
      distributed-print-business/src/main/resources/mapper/TFFlowJoinMapper.xml
  23. 8 7
      distributed-print-business/src/main/resources/mapper/TFFlowLogMapper.xml
  24. 4 4
      distributed-print/src/main/java/com/qmth/distributed/print/api/ExamTaskController.java
  25. 6 4
      distributed-print/src/main/java/com/qmth/distributed/print/api/TFCustomFlowController.java
  26. 3 1
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/contant/SystemConstant.java

+ 17 - 6
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/result/FlowApproveListResult.java

@@ -30,9 +30,12 @@ public class FlowApproveListResult implements Serializable {
     @JsonSerialize(using = ToStringSerializer.class)
     private Long flowEntityId;
 
-    @ApiModelProperty(value = "命题任务id")
+    @ApiModelProperty(value = "实体表")
+    private String objectTable;
+
+    @ApiModelProperty(value = "任务id")
     @JsonSerialize(using = ToStringSerializer.class)
-    private Long taskId;
+    private Long objectId;
 
     @ApiModelProperty(value = "提交人id")
     @JsonSerialize(using = ToStringSerializer.class)
@@ -87,12 +90,20 @@ public class FlowApproveListResult implements Serializable {
         this.flowEntityId = flowEntityId;
     }
 
-    public Long getTaskId() {
-        return taskId;
+    public String getObjectTable() {
+        return objectTable;
+    }
+
+    public void setObjectTable(String objectTable) {
+        this.objectTable = objectTable;
+    }
+
+    public Long getObjectId() {
+        return objectId;
     }
 
-    public void setTaskId(Long taskId) {
-        this.taskId = taskId;
+    public void setObjectId(Long objectId) {
+        this.objectId = objectId;
     }
 
     public String getPendApproveId() {

+ 17 - 6
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/result/TFFlowLogResult.java

@@ -21,9 +21,12 @@ public class TFFlowLogResult extends ApproveUserResult implements Serializable {
     @JsonSerialize(using = ToStringSerializer.class)
     private Long flowId;
 
-    @ApiModelProperty(value = "任务id")
+    @ApiModelProperty(value = "实体表")
+    private String objectTable;
+
+    @ApiModelProperty(value = "实体id")
     @JsonSerialize(using = ToStringSerializer.class)
-    private Long taskId;
+    private Long objectId;
 
     @ApiModelProperty(value = "审核人id")
     @JsonSerialize(using = ToStringSerializer.class)
@@ -82,12 +85,20 @@ public class TFFlowLogResult extends ApproveUserResult implements Serializable {
         this.flowId = flowId;
     }
 
-    public Long getTaskId() {
-        return taskId;
+    public String getObjectTable() {
+        return objectTable;
+    }
+
+    public void setObjectTable(String objectTable) {
+        this.objectTable = objectTable;
+    }
+
+    public Long getObjectId() {
+        return objectId;
     }
 
-    public void setTaskId(Long taskId) {
-        this.taskId = taskId;
+    public void setObjectId(Long objectId) {
+        this.objectId = objectId;
     }
 
     public Long getApproveId() {

+ 18 - 6
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/result/TFFlowViewLogResult.java

@@ -20,9 +20,12 @@ public class TFFlowViewLogResult implements Serializable {
     @JsonSerialize(using = ToStringSerializer.class)
     private Long flowId;
 
+    @ApiModelProperty(value = "实体表")
+    private String objectTable;
+
     @ApiModelProperty(value = "任务id")
     @JsonSerialize(using = ToStringSerializer.class)
-    private Long taskId;
+    private Long objectId;
 
     @ApiModelProperty(value = "审核人id")
     @JsonSerialize(using = ToStringSerializer.class)
@@ -61,7 +64,8 @@ public class TFFlowViewLogResult implements Serializable {
 
     public TFFlowViewLogResult(TFFlowLogResult tfFlowLogResult) {
         this.flowId = tfFlowLogResult.getFlowId();
-        this.taskId = tfFlowLogResult.getTaskId();
+        this.objectId = tfFlowLogResult.getObjectId();
+        this.objectTable = tfFlowLogResult.getObjectTable();
         this.approveId = tfFlowLogResult.getApproveId();
         this.approveSetup = tfFlowLogResult.getApproveSetup();
         this.approveRemark = tfFlowLogResult.getApproveRemark();
@@ -122,12 +126,20 @@ public class TFFlowViewLogResult implements Serializable {
         this.flowId = flowId;
     }
 
-    public Long getTaskId() {
-        return taskId;
+    public String getObjectTable() {
+        return objectTable;
+    }
+
+    public void setObjectTable(String objectTable) {
+        this.objectTable = objectTable;
+    }
+
+    public Long getObjectId() {
+        return objectId;
     }
 
-    public void setTaskId(Long taskId) {
-        this.taskId = taskId;
+    public void setObjectId(Long objectId) {
+        this.objectId = objectId;
     }
 
     public Long getApproveId() {

+ 23 - 11
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TExamTaskFlow.java → distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TFFlowJoin.java

@@ -19,8 +19,8 @@ import java.io.Serializable;
  * @author wangliang
  * @since 2021-11-22
  */
-@ApiModel(value = "TExamTaskFlow对象", description = "考试任务和流程关联表")
-public class TExamTaskFlow implements Serializable {
+@ApiModel(value = "TFFlowJoin对象", description = "实体和流程关联表")
+public class TFFlowJoin implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
@@ -32,9 +32,12 @@ public class TExamTaskFlow implements Serializable {
     @JsonSerialize(using = ToStringSerializer.class)
     private Long flowEntityId;
 
-    @ApiModelProperty(value = "考试任务id")
+    @ApiModelProperty(value = "实体表")
+    private String objectTable;
+
+    @ApiModelProperty(value = "实体id")
     @JsonSerialize(using = ToStringSerializer.class)
-    private Long taskId;
+    private Long objectId;
 
     @ApiModelProperty(value = "流程id")
     @JsonSerialize(using = ToStringSerializer.class)
@@ -55,17 +58,18 @@ public class TExamTaskFlow implements Serializable {
     @ApiModelProperty(value = "创建时间")
     private Long createTime;
 
-    public TExamTaskFlow() {
+    public TFFlowJoin() {
 
     }
 
-    public TExamTaskFlow(Long flowEntityId, Long taskId, Long flowId, Integer level, ExamTaskFlowTypeEnum type, Long userId) {
+    public TFFlowJoin(Long flowEntityId, Long objectId, Long flowId, Integer level, ExamTaskFlowTypeEnum type, Long userId, String objectTable) {
         setId(SystemConstant.getDbUuid());
         this.flowEntityId = flowEntityId;
-        this.taskId = taskId;
+        this.objectId = objectId;
         this.flowId = flowId;
         this.level = level;
         this.type = type;
+        this.objectTable = objectTable;
         this.createId = userId;
         this.createTime = System.currentTimeMillis();
     }
@@ -114,12 +118,20 @@ public class TExamTaskFlow implements Serializable {
         this.id = id;
     }
 
-    public Long getTaskId() {
-        return taskId;
+    public String getObjectTable() {
+        return objectTable;
+    }
+
+    public void setObjectTable(String objectTable) {
+        this.objectTable = objectTable;
+    }
+
+    public Long getObjectId() {
+        return objectId;
     }
 
-    public void setTaskId(Long taskId) {
-        this.taskId = taskId;
+    public void setObjectId(Long objectId) {
+        this.objectId = objectId;
     }
 
     public Long getFlowId() {

+ 25 - 11
distributed-print-business/src/main/java/com/qmth/distributed/print/business/entity/TFFlowLog.java

@@ -39,9 +39,12 @@ public class TFFlowLog extends BaseEntity implements Serializable {
     @JsonSerialize(using = ToStringSerializer.class)
     private Long flowId;
 
+    @ApiModelProperty(value = "实体表")
+    private String objectTable;
+
     @ApiModelProperty(value = "任务id")
     @JsonSerialize(using = ToStringSerializer.class)
-    private Long taskId;
+    private Long objectId;
 
     @ApiModelProperty(value = "审核人id")
     @JsonSerialize(using = ToStringSerializer.class)
@@ -78,38 +81,41 @@ public class TFFlowLog extends BaseEntity implements Serializable {
 
     }
 
-    public TFFlowLog(Long schoolId, Long orgId, Long flowId, Long taskId, Long approveId, Long userId, String approveRemark) {
+    public TFFlowLog(Long schoolId, Long orgId, Long flowId, Long objectId, Long approveId, Long userId, String approveRemark, String objectTable) {
         this.schoolId = schoolId;
         this.orgId = orgId;
         this.flowId = flowId;
         this.approveId = approveId;
-        this.taskId = taskId;
+        this.objectId = objectId;
         this.approveRemark = approveRemark;
+        this.objectTable = objectTable;
         insertInfo(userId);
     }
 
-    public TFFlowLog(Long schoolId, Long orgId, Long flowId, Long taskId, Long approveId, Long userId, String approveRemark, String pendApproveId, FlowApproveOperationEnum approveOperation) {
+    public TFFlowLog(Long schoolId, Long orgId, Long flowId, Long objectId, Long approveId, Long userId, String approveRemark, String pendApproveId, FlowApproveOperationEnum approveOperation, String objectTable) {
         this.schoolId = schoolId;
         this.orgId = orgId;
         this.flowId = flowId;
         this.approveId = approveId;
-        this.taskId = taskId;
+        this.objectId = objectId;
         this.approveRemark = approveRemark;
         this.pendApproveId = pendApproveId;
         this.approveOperation = approveOperation;
+        this.objectTable = objectTable;
         insertInfo(userId);
     }
 
-    public TFFlowLog(Long schoolId, Long orgId, Long flowId, Long taskId, Long userId, String approveRemark, FlowApproveOperationEnum approveOperation, Long approveId, String pendApproveId) {
+    public TFFlowLog(Long schoolId, Long orgId, Long flowId, Long objectId, Long userId, String approveRemark, FlowApproveOperationEnum approveOperation, Long approveId, String pendApproveId, String objectTable) {
         setId(SystemConstant.getDbUuid());
         this.schoolId = schoolId;
         this.orgId = orgId;
         this.flowId = flowId;
-        this.taskId = taskId;
+        this.objectId = objectId;
         this.approveRemark = approveRemark;
         this.approveOperation = approveOperation;
         this.approveId = approveId;
         this.pendApproveId = pendApproveId;
+        this.objectTable = objectTable;
         insertInfo(userId);
     }
 
@@ -181,12 +187,20 @@ public class TFFlowLog extends BaseEntity implements Serializable {
         this.flowId = flowId;
     }
 
-    public Long getTaskId() {
-        return taskId;
+    public String getObjectTable() {
+        return objectTable;
+    }
+
+    public void setObjectTable(String objectTable) {
+        this.objectTable = objectTable;
+    }
+
+    public Long getObjectId() {
+        return objectId;
     }
 
-    public void setTaskId(Long taskId) {
-        this.taskId = taskId;
+    public void setObjectId(Long objectId) {
+        this.objectId = objectId;
     }
 
     public Long getApproveId() {

+ 11 - 4
distributed-print-business/src/main/java/com/qmth/distributed/print/business/enums/TFCustomTypeEnum.java

@@ -11,16 +11,23 @@ import java.util.Objects;
  */
 public enum TFCustomTypeEnum {
 
-    ELECTRON_FLOW("电子交卷审核"),
+    ELECTRON_FLOW("电子交卷审核", "exam_task"),
 
-    QUESTION_ELECTRON_FLOW("题库试题提交审核"),
+    QUESTION_ELECTRON_FLOW("题库试题提交审核", null),
 
-    PAPER_ELECTRON_FLOW("题库试卷审核");
+    PAPER_ELECTRON_FLOW("题库试卷审核", null);
 
     private String title;
 
-    private TFCustomTypeEnum(String title) {
+    private String table;
+
+    private TFCustomTypeEnum(String title, String table) {
         this.title = title;
+        this.table = table;
+    }
+
+    public String getTable() {
+        return table;
     }
 
     public String getTitle() {

+ 0 - 42
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/TExamTaskFlowMapper.java

@@ -1,42 +0,0 @@
-package com.qmth.distributed.print.business.mapper;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.qmth.distributed.print.business.entity.TExamTaskFlow;
-import org.apache.ibatis.annotations.Param;
-
-/**
- * <p>
- * 考试任务和流程关联表 Mapper 接口
- * </p>
- *
- * @author wangliang
- * @since 2021-11-22
- */
-public interface TExamTaskFlowMapper extends BaseMapper<TExamTaskFlow> {
-
-    /**
-     * 根据考试任务id查找
-     *
-     * @param taskId
-     * @return
-     */
-    Integer findByFlowLevel(@Param("taskId") Long taskId);
-
-    /**
-     * 根据流程id查找
-     *
-     * @param flowId
-     * @return
-     */
-    Long findByRootLevel(@Param("flowId") Long flowId);
-
-    /**
-     * 根据考试任务id查找
-     *
-     * @param taskId
-     * @return
-     */
-    Integer findByRootLevelByExamTaskId(@Param("taskId") Long taskId);
-
-    Long selectMaxFlowIdByExamTaskId(@Param("taskId") Long taskId);
-}

+ 48 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/TFFlowJoinMapper.java

@@ -0,0 +1,48 @@
+package com.qmth.distributed.print.business.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.qmth.distributed.print.business.entity.TFFlowJoin;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * <p>
+ * 考试任务和流程关联表 Mapper 接口
+ * </p>
+ *
+ * @author wangliang
+ * @since 2021-11-22
+ */
+public interface TFFlowJoinMapper extends BaseMapper<TFFlowJoin> {
+
+    /**
+     * 根据实体id查找
+     *
+     * @param objectId
+     * @return
+     */
+    Integer findByFlowLevel(@Param("objectId") Long objectId);
+
+    /**
+     * 根据流程id查找
+     *
+     * @param flowId
+     * @return
+     */
+    Long findByRootLevel(@Param("flowId") Long flowId);
+
+    /**
+     * 根据实体id查找
+     *
+     * @param objectId
+     * @return
+     */
+    Integer findByRootLevelByObjectId(@Param("objectId") Long objectId);
+
+    /**
+     * 根据实体id查找最大流程号
+     *
+     * @param objectId
+     * @return
+     */
+    Long selectMaxFlowIdByObjectId(@Param("objectId") Long objectId);
+}

+ 3 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/mapper/TFFlowLogMapper.java

@@ -27,12 +27,12 @@ public interface TFFlowLogMapper extends BaseMapper<TFFlowLog> {
     List<TFFlowLog> findByFlowId(@Param("flowId") Long flowId, @Param("schoolId") Long schoolId);
 
     /**
-     * 根据考试任务id查询
+     * 根据实体id查询
      *
-     * @param taskId
+     * @param objectId
      * @return
      */
-    List<TFFlowLogResult> findByExamTaskId(@Param("taskId") Long taskId);
+    List<TFFlowLogResult> findByObjectId(@Param("objectId") Long objectId);
 
     /**
      * 查找最后一条审批记录

+ 10 - 10
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/TExamTaskFlowService.java → distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/TFFlowJoinService.java

@@ -1,7 +1,7 @@
 package com.qmth.distributed.print.business.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
-import com.qmth.distributed.print.business.entity.TExamTaskFlow;
+import com.qmth.distributed.print.business.entity.TFFlowJoin;
 
 import java.util.List;
 import java.util.Map;
@@ -14,7 +14,7 @@ import java.util.Map;
  * @author wangliang
  * @since 2021-11-22
  */
-public interface TExamTaskFlowService extends IService<TExamTaskFlow> {
+public interface TFFlowJoinService extends IService<TFFlowJoin> {
 
     /**
      * 保存或更新TExamTaskFlow
@@ -24,20 +24,20 @@ public interface TExamTaskFlowService extends IService<TExamTaskFlow> {
     public boolean saveOrUpdate(Map<String, Object> map);
 
     /**
-     * 根据考试任务id查找
+     * 根据实体id查找
      *
-     * @param taskId
+     * @param objectId
      * @return
      */
-    public TExamTaskFlow findByFlowLevel(Long taskId);
+    public TFFlowJoin findByFlowLevel(Long objectId);
 
     /**
-     * 根据考试任务id查找
+     * 根据实体id查找
      *
-     * @param taskId
+     * @param objectId
      * @return
      */
-    public List<TExamTaskFlow> findByExamTaskId(Long taskId);
+    public List<TFFlowJoin> findByObjectId(Long objectId);
 
     /**
      * 根据流程id查找
@@ -45,7 +45,7 @@ public interface TExamTaskFlowService extends IService<TExamTaskFlow> {
      * @param flowId
      * @return
      */
-    public TExamTaskFlow findByRootLevel(Long flowId);
+    public TFFlowJoin findByRootLevel(Long flowId);
 
     /**
      * 根据自定义流程实体id查询
@@ -53,5 +53,5 @@ public interface TExamTaskFlowService extends IService<TExamTaskFlow> {
      * @param flowEntityId
      * @return
      */
-    public List<TExamTaskFlow> findByFlowEntityId(Long flowEntityId);
+    public List<TFFlowJoin> findByFlowEntityId(Long flowEntityId);
 }

+ 3 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/TFFlowLogService.java

@@ -27,12 +27,12 @@ public interface TFFlowLogService extends IService<TFFlowLog> {
     List<TFFlowLog> findByFlowId(Long flowId, Long schoolId);
 
     /**
-     * 根据考试任务id查询
+     * 根据实体id查询
      *
-     * @param taskId
+     * @param objectId
      * @return
      */
-    List<TFFlowLogResult> findByExamTaskId(Long taskId);
+    List<TFFlowLogResult> findByObjectId(Long objectId);
 
     /**
      * 查找最后一条审批记录

+ 27 - 17
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ActivitiServiceImpl.java

@@ -104,7 +104,7 @@ public class ActivitiServiceImpl implements ActivitiService {
     ExamDetailService examDetailService;
 
     @Resource
-    TExamTaskFlowService tExamTaskFlowService;
+    TFFlowJoinService tfFlowJoinService;
 
     @Resource
     MultiWorkFlow multiWorkFlow;
@@ -266,6 +266,7 @@ public class ActivitiServiceImpl implements ActivitiService {
             ExamTask examTask = examTaskService.findByFlowId(SystemConstant.convertIdToLong(flowId));
             //流程审批
             TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(SystemConstant.convertIdToLong(flowId), examTask.getSchoolId());
+            TFFlowJoin tfFlowJoin = tfFlowJoinService.findByRootLevel(SystemConstant.convertIdToLong(flowId));
             if (Objects.isNull(tfFlowApprove)) {
                 tfFlowApprove = new TFFlowApprove(sysUser.getSchoolId(), sysUser.getOrgId(), SystemConstant.convertIdToLong(flowId), sysUser.getId(), FlowStatusEnum.END, sysUser.getId());
             } else {
@@ -276,7 +277,7 @@ public class ActivitiServiceImpl implements ActivitiService {
             tfFlowApproveService.saveOrUpdate(tfFlowApprove);
 
             //流程流水日志
-            TFFlowLog tfFlowLog = new TFFlowLog(sysUser.getSchoolId(), sysUser.getOrgId(), examTask.getFlowId(), examTask.getId(), sysUser.getId(), sysUser.getId(), FlowApproveSetupEnum.END.getTitle());
+            TFFlowLog tfFlowLog = new TFFlowLog(sysUser.getSchoolId(), sysUser.getOrgId(), examTask.getFlowId(), examTask.getId(), sysUser.getId(), sysUser.getId(), FlowApproveSetupEnum.END.getTitle(), tfFlowJoin.getObjectTable());
             tfFlowLog.setApproveOperation(FlowApproveOperationEnum.END);
             tfFlowLog.setApproveSetup(FlowApproveSetupEnum.END.getSetup());
             tfFlowLogService.save(tfFlowLog);
@@ -308,6 +309,7 @@ public class ActivitiServiceImpl implements ActivitiService {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         Optional.ofNullable(map.get(SystemConstant.FLOW_ID)).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程id不能为空"));
         String flowId = (String) map.get(SystemConstant.FLOW_ID);
+        TFCustomTypeEnum flowType = (TFCustomTypeEnum) map.get(SystemConstant.FLOW_TYPE);
 
         Optional.ofNullable(map.get(SystemConstant.FLOW_STATUS)).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程状态不能为空"));
         FlowStatusEnum flowStatusEnum = (FlowStatusEnum) map.get(SystemConstant.FLOW_STATUS);
@@ -315,19 +317,22 @@ public class ActivitiServiceImpl implements ActivitiService {
         String approveId = Objects.nonNull(map.get(SystemConstant.APPROVE_ID)) ? String.valueOf((Long) map.get(SystemConstant.APPROVE_ID)) : null;
         tfFlowApproveService.save(new TFFlowApprove(sysUser.getSchoolId(), sysUser.getOrgId(), SystemConstant.convertIdToLong(flowId), sysUser.getId(), flowStatusEnum, sysUser.getId()));
 
+        Long objectId = (Long) map.get(SystemConstant.OBJECT_ID);
         //TODO 测试用
-        Long examTaskId = (Long) map.get(SystemConstant.EXAM_TASK_ID);
-        ExamTask examTask = examTaskService.getById(examTaskId);
-        examTask.setFlowId(SystemConstant.convertIdToLong(flowId));
-        examTaskService.updateById(examTask);
+        if (flowType == TFCustomTypeEnum.ELECTRON_FLOW) {//如果是电子交卷审核,就查询命题任务
+            ExamTask examTask = examTaskService.getById(objectId);
+            examTask.setFlowId(SystemConstant.convertIdToLong(flowId));
+            examTaskService.updateById(examTask);
+        }
 
         String id = (String) map.get(SystemConstant.FLOW_ENTITY_ID);
-        TExamTaskFlow tExamTaskFlow = tExamTaskFlowService.findByFlowLevel(examTaskId);
-        tExamTaskFlow.setFlowEntityId(SystemConstant.convertIdToLong(id));
-        tExamTaskFlow.setFlowId(SystemConstant.convertIdToLong(flowId));
-        tExamTaskFlowService.updateById(tExamTaskFlow);
+        TFFlowJoin tfFlowJoin = tfFlowJoinService.findByFlowLevel(objectId);
+        tfFlowJoin.setFlowEntityId(SystemConstant.convertIdToLong(id));
+        tfFlowJoin.setFlowId(SystemConstant.convertIdToLong(flowId));
+        tfFlowJoin.setObjectTable(flowType.getTable());
+        tfFlowJoinService.updateById(tfFlowJoin);
 
-        tfFlowLogService.save(new TFFlowLog(sysUser.getSchoolId(), sysUser.getOrgId(), SystemConstant.convertIdToLong(flowId), examTaskId, sysUser.getId(), sysUser.getId(), "提交流程", approveId, FlowApproveOperationEnum.SUBMIT));
+        tfFlowLogService.save(new TFFlowLog(sysUser.getSchoolId(), sysUser.getOrgId(), SystemConstant.convertIdToLong(flowId), objectId, sysUser.getId(), sysUser.getId(), "提交流程", approveId, FlowApproveOperationEnum.SUBMIT, flowType.getTable()));
     }
 
     /**
@@ -367,6 +372,8 @@ public class ActivitiServiceImpl implements ActivitiService {
             TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.findByFlowId(flowId);
             Map<String, Object> flowProcessVarMap = this.getFlowProcessVarMap(tfCustomFlowEntity);
 
+            TFFlowJoin tfFlowJoin = tfFlowJoinService.findByRootLevel(flowId);
+
             String remark = null;
             FlowTaskResult currFlowTaskResult = null, nextFlowTaskResult = null;
             Map<String, CustomFlowVarDto> agginessMap = (Map<String, CustomFlowVarDto>) flowProcessVarMap.get(SystemConstant.AGGINESS_MAP);
@@ -387,7 +394,7 @@ public class ActivitiServiceImpl implements ActivitiService {
                 }
                 remark = Objects.nonNull(map.get(SystemConstant.APPROVE_REMARK)) ? map.get(SystemConstant.APPROVE_REMARK).toString() : null;
                 //流程流水日志
-                tfFlowLog = new TFFlowLog(sysUser.getSchoolId(), sysUser.getOrgId(), flowId, examTask.getId(), sysUser.getId(), sysUser.getId(), remark);
+                tfFlowLog = new TFFlowLog(sysUser.getSchoolId(), sysUser.getOrgId(), flowId, examTask.getId(), sysUser.getId(), sysUser.getId(), remark, tfFlowJoin.getObjectTable());
                 //判断流程审批是通过还是驳回
                 FlowApprovePassEnum approvePass = (FlowApprovePassEnum) map.get(SystemConstant.APPROVE_OPERATION);
                 Map<String, FlowTaskResult> setupMap = (Map<String, FlowTaskResult>) flowProcessVarMap.get(SystemConstant.SETUP_MAP);
@@ -1090,8 +1097,11 @@ public class ActivitiServiceImpl implements ActivitiService {
 
         ExamTask examTask = examTaskService.findByFlowId(SystemConstant.convertIdToLong(flowId));
         SysUser exchangeUser = sysUserService.getById(userId);
+
+        TFFlowJoin tfFlowJoin = tfFlowJoinService.findByRootLevel(SystemConstant.convertIdToLong(flowId));
+
         //流程流水日志
-        TFFlowLog tfFlowLog = new TFFlowLog(sysUser.getSchoolId(), sysUser.getOrgId(), examTask.getFlowId(), examTask.getId(), sysUser.getId(), sysUser.getRealName() + "转" + exchangeUser.getRealName() + "审批", FlowApproveOperationEnum.EXCHANGE, sysUser.getId(), String.valueOf(exchangeUser.getId()));
+        TFFlowLog tfFlowLog = new TFFlowLog(sysUser.getSchoolId(), sysUser.getOrgId(), examTask.getFlowId(), examTask.getId(), sysUser.getId(), sysUser.getRealName() + "转" + exchangeUser.getRealName() + "审批", FlowApproveOperationEnum.EXCHANGE, sysUser.getId(), String.valueOf(exchangeUser.getId()), tfFlowJoin.getObjectTable());
         Gson gson = new Gson();
         CustomFlowVarDto customFlowVarDto = gson.fromJson(gson.toJson(agginessMap.get(userTask.getId())), CustomFlowVarDto.class);
         if (customFlowVarDto.getApproveIds().size() == 1) {
@@ -1375,7 +1385,7 @@ public class ActivitiServiceImpl implements ActivitiService {
     @Override
     public List<FlowTaskSubmitPeopleAllResult> taskApproverSubmitList(String examTaskId) {
         List<FlowTaskSubmitPeopleAllResult> flowTaskSubmitPeopleAllResultList = null;
-        List<TFFlowLogResult> tfFlowLogResultList = tfFlowLogService.findByExamTaskId(SystemConstant.convertIdToLong(examTaskId));
+        List<TFFlowLogResult> tfFlowLogResultList = tfFlowLogService.findByObjectId(SystemConstant.convertIdToLong(examTaskId));
         if (Objects.nonNull(tfFlowLogResultList) && tfFlowLogResultList.size() > 0) {
             flowTaskSubmitPeopleAllResultList = new LinkedList<>();
             for (TFFlowLogResult t : tfFlowLogResultList) {
@@ -2262,8 +2272,8 @@ public class ActivitiServiceImpl implements ActivitiService {
         Optional.ofNullable(tfCustomFlowEntity).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("自定义流程实体数据为空"));
 
         //获取流程id
-        List<TExamTaskFlow> tExamTaskFlowList = tExamTaskFlowService.findByFlowEntityId(tfCustomFlowEntity.getId());
-        Optional.ofNullable(tExamTaskFlowList).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程数据为空"));
+        List<TFFlowJoin> tfFlowJoinList = tfFlowJoinService.findByFlowEntityId(tfCustomFlowEntity.getId());
+        Optional.ofNullable(tfFlowJoinList).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程数据为空"));
 
         //获取当前流程节点
         TFFlowApprove tfFlowApprove = tfFlowApproveService.findByFlowId(flowId, sysUser.getSchoolId());
@@ -2290,7 +2300,7 @@ public class ActivitiServiceImpl implements ActivitiService {
         }
 
         //获取流程审批历史
-        List<TFFlowLogResult> tfFlowLogResultList = tfFlowLogService.findByExamTaskId(tExamTaskFlowList.get(0).getTaskId());
+        List<TFFlowLogResult> tfFlowLogResultList = tfFlowLogService.findByObjectId(tfFlowJoinList.get(0).getObjectId());
         if (Objects.nonNull(tfFlowLogResultList) && tfFlowLogResultList.size() > 0) {
             List<TFFlowViewLogResult> flowViewTaskResultList = gson.fromJson(gson.toJson(tfFlowLogResultList), new TypeToken<List<TFFlowViewLogResult>>() {
             }.getType());

+ 5 - 3
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskDetailServiceImpl.java

@@ -11,6 +11,7 @@ import com.qmth.distributed.print.business.bean.params.RelatePaperParam;
 import com.qmth.distributed.print.business.entity.*;
 import com.qmth.distributed.print.business.enums.ExamDetailStatusEnum;
 import com.qmth.distributed.print.business.enums.PrintPlanStatusEnum;
+import com.qmth.distributed.print.business.enums.TFCustomTypeEnum;
 import com.qmth.distributed.print.business.mapper.ExamTaskDetailMapper;
 import com.qmth.distributed.print.business.service.*;
 import com.qmth.distributed.print.business.templete.execute.AsyncCreatePdfTempleteService;
@@ -89,7 +90,7 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
     TFFlowApproveService tfFlowApproveService;
 
     @Resource
-    TExamTaskFlowService tExamTaskFlowService;
+    TFFlowJoinService tfFlowJoinService;
 
     @Resource
     SysUserService sysUserService;
@@ -371,7 +372,8 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
         if (examTask.getReview() || !sysUserService.isAdminDataAuth(requestUser.getId())) {
             // 发起新流程
             Map<String, Object> map = new HashMap<>();
-            map.computeIfAbsent(SystemConstant.EXAM_TASK_ID, v -> examTask.getId());
+            map.computeIfAbsent(SystemConstant.OBJECT_ID, v -> examTask.getId());
+            map.computeIfAbsent(SystemConstant.FLOW_TYPE, v -> TFCustomTypeEnum.ELECTRON_FLOW);
             map.computeIfAbsent(SystemConstant.APPROVE_ID, v -> examTask.getUserId());
 
             map = activitiService.customFlowStart(map);
@@ -379,7 +381,7 @@ public class ExamTaskDetailServiceImpl extends ServiceImpl<ExamTaskDetailMapper,
             UpdateWrapper<ExamTask> updateWrapper = new UpdateWrapper<>();
             updateWrapper.lambda().set(ExamTask::getFlowId, flowId).eq(ExamTask::getId, examTaskDetail.getExamTaskId());
             examTaskService.update(updateWrapper);
-            tExamTaskFlowService.saveOrUpdate(map);
+            tfFlowJoinService.saveOrUpdate(map);
             if (Objects.nonNull(flowId)) {
                 // 审核一级
                 Task task = taskService.createTaskQuery().processInstanceId(String.valueOf(flowId)).singleResult();

+ 19 - 13
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskServiceImpl.java

@@ -168,7 +168,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
     ExamStudentService examStudentService;
 
     @Resource
-    TExamTaskFlowService tExamTaskFlowService;
+    TFFlowJoinService tfFlowJoinService;
 
     @Resource
     CreatePdfUtil createPdfUtil;
@@ -282,10 +282,11 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
 //                tExamTaskFlowService.saveOrUpdate(texamTaskFlowMap);
 
                 Map<String, Object> map = new HashMap<>();
-                map.computeIfAbsent(SystemConstant.EXAM_TASK_ID, v -> examTask.getId());
+                map.computeIfAbsent(SystemConstant.OBJECT_ID, v -> examTask.getId());
+                map.computeIfAbsent(SystemConstant.FLOW_TYPE, v -> TFCustomTypeEnum.ELECTRON_FLOW);
                 map.computeIfAbsent(SystemConstant.APPROVE_ID, v -> examTask.getUserId());
                 map = activitiService.customFlowStart(map);
-                tExamTaskFlowService.saveOrUpdate(map);
+                tfFlowJoinService.saveOrUpdate(map);
             }
         }
         // 更改命题老师
@@ -301,10 +302,11 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
 
                 if (examTask.getUserId().longValue() != task.getUserId().longValue()) {
                     Map<String, Object> map = new HashMap<>();
-                    map.computeIfAbsent(SystemConstant.EXAM_TASK_ID, v -> examTask.getId());
+                    map.computeIfAbsent(SystemConstant.OBJECT_ID, v -> examTask.getId());
+                    map.computeIfAbsent(SystemConstant.FLOW_TYPE, v -> TFCustomTypeEnum.ELECTRON_FLOW);
                     map.computeIfAbsent(SystemConstant.APPROVE_ID, v -> examTask.getUserId());
                     map = activitiService.customFlowStart(map);
-                    tExamTaskFlowService.saveOrUpdate(map);
+                    tfFlowJoinService.saveOrUpdate(map);
                 } else {
                     flowId = task.getFlowId();
                 }
@@ -428,7 +430,8 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
             examTask.setOrgId(teachingRoomId);
             examTask.setTeachingRoomId(teachingRoomId);
             Map<String, Object> map = new HashMap<>();
-            map.computeIfAbsent(SystemConstant.EXAM_TASK_ID, v -> examTask.getId());
+            map.computeIfAbsent(SystemConstant.OBJECT_ID, v -> examTask.getId());
+            map.computeIfAbsent(SystemConstant.FLOW_TYPE, v -> TFCustomTypeEnum.ELECTRON_FLOW);
             map.computeIfAbsent(SystemConstant.APPROVE_ID, v -> examTask.getUserId());
             if (examTask.getUserId() == null) {
                 examTask.setStatus(ExamStatusEnum.DRAFT);
@@ -440,7 +443,7 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
                 examTask.setStatus(ExamStatusEnum.STAGE);
             }
             this.save(examTask);
-            tExamTaskFlowService.saveOrUpdate(map);
+            tfFlowJoinService.saveOrUpdate(map);
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);
             if (e instanceof ActivitiObjectNotFoundException) {
@@ -735,12 +738,13 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
             examTask.setReview(false);
             if (examTask.getReview() && Objects.nonNull(examTask.getUserId()) && Objects.isNull(examTask.getFlowId())) {
                 Map<String, Object> map = new HashMap<>();
-                map.computeIfAbsent(SystemConstant.EXAM_TASK_ID, v -> examTask.getId());
+                map.computeIfAbsent(SystemConstant.OBJECT_ID, v -> examTask.getId());
+                map.computeIfAbsent(SystemConstant.FLOW_TYPE, v -> TFCustomTypeEnum.ELECTRON_FLOW);
                 map.computeIfAbsent(SystemConstant.APPROVE_ID, v -> examTask.getUserId());
 
                 map = activitiService.customFlowStart(map);
                 examTask.setFlowId(SystemConstant.convertIdToLong((String) map.get(SystemConstant.FLOW_ID)));
-                tExamTaskFlowService.saveOrUpdate(map);
+                tfFlowJoinService.saveOrUpdate(map);
                 examTask.updateInfo(sysUser.getId());
                 this.updateById(examTask);
             }
@@ -1527,11 +1531,12 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
             if (Objects.isNull(examTask.getFlowId())) {
                 if (basicExamRule.getReview()) {
                     Map<String, Object> map = new HashMap<>();
-                    map.computeIfAbsent(SystemConstant.EXAM_TASK_ID, v -> examTask.getId());
+                    map.computeIfAbsent(SystemConstant.OBJECT_ID, v -> examTask.getId());
+                    map.computeIfAbsent(SystemConstant.FLOW_TYPE, v -> TFCustomTypeEnum.ELECTRON_FLOW);
                     map.computeIfAbsent(SystemConstant.APPROVE_ID, v -> examTask.getUserId());
                     map = activitiService.customFlowStart(map);
                     examTask.setFlowId(SystemConstant.convertIdToLong((String) map.get(SystemConstant.FLOW_ID)));
-                    tExamTaskFlowService.saveOrUpdate(map);
+                    tfFlowJoinService.saveOrUpdate(map);
                 }
             }
             this.saveOrUpdate(examTask);
@@ -1665,11 +1670,12 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
             if (Objects.isNull(examTask.getFlowId())) {
                 if (basicExamRule.getReview()) {
                     Map<String, Object> map = new HashMap<>();
-                    map.computeIfAbsent(SystemConstant.EXAM_TASK_ID, v -> examTask.getId());
+                    map.computeIfAbsent(SystemConstant.OBJECT_ID, v -> examTask.getId());
+                    map.computeIfAbsent(SystemConstant.FLOW_TYPE, v -> TFCustomTypeEnum.ELECTRON_FLOW);
                     map.computeIfAbsent(SystemConstant.APPROVE_ID, v -> examTask.getUserId());
                     map = activitiService.customFlowStart(map);
                     examTask.setFlowId(SystemConstant.convertIdToLong((String) map.get(SystemConstant.FLOW_ID)));
-                    tExamTaskFlowService.saveOrUpdate(map);
+                    tfFlowJoinService.saveOrUpdate(map);
                 }
             }
             this.save(examTask);

+ 0 - 139
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TExamTaskFlowServiceImpl.java

@@ -1,139 +0,0 @@
-package com.qmth.distributed.print.business.service.impl;
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.qmth.boot.api.exception.ApiException;
-import com.qmth.distributed.print.business.entity.TExamTaskFlow;
-import com.qmth.distributed.print.business.enums.ExamTaskFlowTypeEnum;
-import com.qmth.distributed.print.business.mapper.TExamTaskFlowMapper;
-import com.qmth.distributed.print.business.service.TExamTaskFlowService;
-import com.qmth.teachcloud.common.contant.SystemConstant;
-import com.qmth.teachcloud.common.entity.SysUser;
-import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
-import com.qmth.teachcloud.common.util.RedisUtil;
-import com.qmth.teachcloud.common.util.ResultUtil;
-import com.qmth.teachcloud.common.util.ServletUtil;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-
-/**
- * <p>
- * 考试任务和流程关联表 服务实现类
- * </p>
- *
- * @author wangliang
- * @since 2021-11-22
- */
-@Service
-public class TExamTaskFlowServiceImpl extends ServiceImpl<TExamTaskFlowMapper, TExamTaskFlow> implements TExamTaskFlowService {
-
-    @Resource
-    RedisUtil redisUtil;
-
-    @Resource
-    TExamTaskFlowMapper taskFlowMapper;
-
-    /**
-     * 保存TExamTaskFlow
-     *
-     * @param map
-     */
-    @Override
-    public boolean saveOrUpdate(Map<String, Object> map) {
-        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
-        Long taskId = (Long) map.get(SystemConstant.EXAM_TASK_ID);
-        Long flowId = SystemConstant.convertIdToLong((String) map.get(SystemConstant.FLOW_ID));
-        Long flowEntityId = SystemConstant.convertIdToLong((String) map.get(SystemConstant.FLOW_ENTITY_ID));
-        boolean lock = redisUtil.lock(SystemConstant.REDIS_LOCK_EXAM_TASK_FLOW_PREFIX + flowId, SystemConstant.REDIS_LOCK_EXAM_TASK_FLOW_TIME_OUT);
-        if (!lock) {
-            throw ExceptionResultEnum.ERROR.exception("该流程正在审批中,请稍候再试!");
-        }
-        try {
-            QueryWrapper<TExamTaskFlow> taskFlowQueryWrapper = new QueryWrapper<>();
-            taskFlowQueryWrapper.lambda().eq(TExamTaskFlow::getTaskId, taskId);
-            List<TExamTaskFlow> tExamTaskFlowList = this.list(taskFlowQueryWrapper);
-            if (Objects.isNull(tExamTaskFlowList) || tExamTaskFlowList.size() == 0) {
-                TExamTaskFlow tExamTaskFlow = new TExamTaskFlow(flowEntityId, taskId, flowId, 1, ExamTaskFlowTypeEnum.NEW, sysUser.getId());
-                this.save(tExamTaskFlow);
-            } else if (Objects.nonNull(tExamTaskFlowList) && tExamTaskFlowList.size() == 1) {
-                TExamTaskFlow tExamTaskFlow = tExamTaskFlowList.get(0);
-                Integer level = tExamTaskFlow.getLevel();
-                TExamTaskFlow tExamTaskFlowSub = new TExamTaskFlow(flowEntityId, taskId, flowId, ++level, ExamTaskFlowTypeEnum.NEW, sysUser.getId());
-                this.save(tExamTaskFlowSub);
-            }
-        } catch (Exception e) {
-            log.error(SystemConstant.LOG_ERROR, e);
-            if (e instanceof ApiException) {
-                ResultUtil.error((ApiException) e, e.getMessage());
-            } else {
-                ResultUtil.error(e.getMessage());
-            }
-        } finally {
-            redisUtil.releaseLock(SystemConstant.REDIS_LOCK_EXAM_TASK_FLOW_PREFIX + flowId);
-        }
-        return true;
-    }
-
-    /**
-     * 根据考试任务id查找
-     *
-     * @param taskId
-     * @return
-     */
-    @Override
-    public TExamTaskFlow findByFlowLevel(Long taskId) {
-        Integer level = taskFlowMapper.findByFlowLevel(taskId);
-        Optional.ofNullable(level).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未找到子流程信息"));
-        QueryWrapper<TExamTaskFlow> tExamTaskFlowQueryWrapper = new QueryWrapper<>();
-        tExamTaskFlowQueryWrapper.lambda().eq(TExamTaskFlow::getTaskId, taskId)
-                .eq(TExamTaskFlow::getLevel, level);
-        return this.getOne(tExamTaskFlowQueryWrapper);
-    }
-
-    /**
-     * 根据考试任务id查找
-     *
-     * @param taskId
-     * @return
-     */
-    @Override
-    public List<TExamTaskFlow> findByExamTaskId(Long taskId) {
-        return this.list(new QueryWrapper<TExamTaskFlow>().lambda().eq(TExamTaskFlow::getTaskId, taskId));
-    }
-
-    /**
-     * 根据流程id查找
-     *
-     * @param flowId
-     * @return
-     */
-    @Override
-    public TExamTaskFlow findByRootLevel(Long flowId) {
-        Long examTaskId = taskFlowMapper.findByRootLevel(flowId);
-        Optional.ofNullable(examTaskId).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未找到考试任务id信息"));
-        Integer level = taskFlowMapper.findByRootLevelByExamTaskId(examTaskId);
-        Optional.ofNullable(level).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未找到主流程信息"));
-        QueryWrapper<TExamTaskFlow> tExamTaskFlowQueryWrapper = new QueryWrapper<>();
-        tExamTaskFlowQueryWrapper.lambda().eq(TExamTaskFlow::getTaskId, examTaskId)
-                .eq(TExamTaskFlow::getLevel, level);
-        return this.getOne(tExamTaskFlowQueryWrapper);
-    }
-
-    /**
-     * 根据自定义流程实体id查询
-     *
-     * @param flowEntityId
-     * @return
-     */
-    @Override
-    public List<TExamTaskFlow> findByFlowEntityId(Long flowEntityId) {
-        QueryWrapper<TExamTaskFlow> tExamTaskFlowQueryWrapper = new QueryWrapper<>();
-        tExamTaskFlowQueryWrapper.lambda().eq(TExamTaskFlow::getFlowEntityId, flowEntityId);
-        return this.list(tExamTaskFlowQueryWrapper);
-    }
-}

+ 143 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TFFlowJoinServiceImpl.java

@@ -0,0 +1,143 @@
+package com.qmth.distributed.print.business.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.boot.api.exception.ApiException;
+import com.qmth.distributed.print.business.entity.TFFlowJoin;
+import com.qmth.distributed.print.business.enums.ExamTaskFlowTypeEnum;
+import com.qmth.distributed.print.business.enums.TFCustomTypeEnum;
+import com.qmth.distributed.print.business.mapper.TFFlowJoinMapper;
+import com.qmth.distributed.print.business.service.TFFlowJoinService;
+import com.qmth.teachcloud.common.contant.SystemConstant;
+import com.qmth.teachcloud.common.entity.SysUser;
+import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
+import com.qmth.teachcloud.common.util.RedisUtil;
+import com.qmth.teachcloud.common.util.ResultUtil;
+import com.qmth.teachcloud.common.util.ServletUtil;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+
+/**
+ * <p>
+ * 考试任务和流程关联表 服务实现类
+ * </p>
+ *
+ * @author wangliang
+ * @since 2021-11-22
+ */
+@Service
+public class TFFlowJoinServiceImpl extends ServiceImpl<TFFlowJoinMapper, TFFlowJoin> implements TFFlowJoinService {
+
+    @Resource
+    RedisUtil redisUtil;
+
+    @Resource
+    TFFlowJoinMapper taskFlowMapper;
+
+    /**
+     * 保存TExamTaskFlow
+     *
+     * @param map
+     */
+    @Override
+    public boolean saveOrUpdate(Map<String, Object> map) {
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+        Long objectId = (Long) map.get(SystemConstant.OBJECT_ID);
+        Long flowId = SystemConstant.convertIdToLong((String) map.get(SystemConstant.FLOW_ID));
+        Long flowEntityId = SystemConstant.convertIdToLong((String) map.get(SystemConstant.FLOW_ENTITY_ID));
+        TFCustomTypeEnum flowType = (TFCustomTypeEnum) map.get(SystemConstant.FLOW_TYPE);
+        Optional.ofNullable(flowType).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程类型不能为空"));
+
+        boolean lock = redisUtil.lock(SystemConstant.REDIS_LOCK_EXAM_TASK_FLOW_PREFIX + flowId, SystemConstant.REDIS_LOCK_EXAM_TASK_FLOW_TIME_OUT);
+        if (!lock) {
+            throw ExceptionResultEnum.ERROR.exception("该流程正在审批中,请稍候再试!");
+        }
+        try {
+            QueryWrapper<TFFlowJoin> tfFlowJoinQueryWrapper = new QueryWrapper<>();
+            tfFlowJoinQueryWrapper.lambda().eq(TFFlowJoin::getObjectId, objectId);
+            List<TFFlowJoin> tfFlowJoinList = this.list(tfFlowJoinQueryWrapper);
+            if (Objects.isNull(tfFlowJoinList) || tfFlowJoinList.size() == 0) {
+                TFFlowJoin tfFlowJoin = new TFFlowJoin(flowEntityId, objectId, flowId, 1, ExamTaskFlowTypeEnum.NEW, sysUser.getId(), flowType.getTable());
+                this.save(tfFlowJoin);
+            } else if (Objects.nonNull(tfFlowJoinList) && tfFlowJoinList.size() == 1) {
+                TFFlowJoin tfFlowJoin = tfFlowJoinList.get(0);
+                Integer level = tfFlowJoin.getLevel();
+                TFFlowJoin tfFlowJoinSub = new TFFlowJoin(flowEntityId, objectId, flowId, ++level, ExamTaskFlowTypeEnum.NEW, sysUser.getId(), flowType.getTable());
+                this.save(tfFlowJoinSub);
+            }
+        } catch (Exception e) {
+            log.error(SystemConstant.LOG_ERROR, e);
+            if (e instanceof ApiException) {
+                ResultUtil.error((ApiException) e, e.getMessage());
+            } else {
+                ResultUtil.error(e.getMessage());
+            }
+        } finally {
+            redisUtil.releaseLock(SystemConstant.REDIS_LOCK_EXAM_TASK_FLOW_PREFIX + flowId);
+        }
+        return true;
+    }
+
+    /**
+     * 根据实体id查找
+     *
+     * @param objectId
+     * @return
+     */
+    @Override
+    public TFFlowJoin findByFlowLevel(Long objectId) {
+        Integer level = taskFlowMapper.findByFlowLevel(objectId);
+        Optional.ofNullable(level).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未找到子流程信息"));
+        QueryWrapper<TFFlowJoin> tfFlowJoinQueryWrapper = new QueryWrapper<>();
+        tfFlowJoinQueryWrapper.lambda().eq(TFFlowJoin::getObjectId, objectId)
+                .eq(TFFlowJoin::getLevel, level);
+        return this.getOne(tfFlowJoinQueryWrapper);
+    }
+
+    /**
+     * 根据实体id查找
+     *
+     * @param objectId
+     * @return
+     */
+    @Override
+    public List<TFFlowJoin> findByObjectId(Long objectId) {
+        return this.list(new QueryWrapper<TFFlowJoin>().lambda().eq(TFFlowJoin::getObjectId, objectId));
+    }
+
+    /**
+     * 根据流程id查找
+     *
+     * @param flowId
+     * @return
+     */
+    @Override
+    public TFFlowJoin findByRootLevel(Long flowId) {
+        Long objectId = taskFlowMapper.findByRootLevel(flowId);
+        Optional.ofNullable(objectId).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未找到实体id信息"));
+        Integer level = taskFlowMapper.findByRootLevelByObjectId(objectId);
+        Optional.ofNullable(level).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未找到主流程信息"));
+        QueryWrapper<TFFlowJoin> tfFlowJoinQueryWrapper = new QueryWrapper<>();
+        tfFlowJoinQueryWrapper.lambda().eq(TFFlowJoin::getObjectId, objectId)
+                .eq(TFFlowJoin::getLevel, level);
+        return this.getOne(tfFlowJoinQueryWrapper);
+    }
+
+    /**
+     * 根据自定义流程实体id查询
+     *
+     * @param flowEntityId
+     * @return
+     */
+    @Override
+    public List<TFFlowJoin> findByFlowEntityId(Long flowEntityId) {
+        QueryWrapper<TFFlowJoin> tfFlowJoinQueryWrapper = new QueryWrapper<>();
+        tfFlowJoinQueryWrapper.lambda().eq(TFFlowJoin::getFlowEntityId, flowEntityId);
+        return this.list(tfFlowJoinQueryWrapper);
+    }
+}

+ 4 - 4
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TFFlowLogServiceImpl.java

@@ -39,14 +39,14 @@ public class TFFlowLogServiceImpl extends ServiceImpl<TFFlowLogMapper, TFFlowLog
     }
 
     /**
-     * 根据考试任务id查询
+     * 根据实体id查询
      *
-     * @param taskId
+     * @param objectId
      * @return
      */
     @Override
-    public List<TFFlowLogResult> findByExamTaskId(Long taskId) {
-        return tfFlowLogMapper.findByExamTaskId(taskId);
+    public List<TFFlowLogResult> findByObjectId(Long objectId) {
+        return tfFlowLogMapper.findByObjectId(objectId);
     }
 
     /**

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

@@ -281,10 +281,10 @@
         bs.name semesterName,
         true as myself
         FROM ACT_RU_TASK art
-        left join t_exam_task_flow tetf on
-            tetf.flow_id = art.PROC_INST_ID_
+        left join t_f_flow_join tffj on
+        tffj.flow_id = art.PROC_INST_ID_
         left join exam_task a on
-            a.id = tetf.task_id
+            a.id = tffj.object_id
         left join act_ru_identitylink ari on
             ari.TASK_ID_ = art.ID_
         LEFT JOIN
@@ -379,8 +379,8 @@
         e.name teachingRoomName
         FROM
         exam_task a
-        left join t_exam_task_flow tetf on
-            a.id = tetf.task_id
+        left join t_f_flow_join tffj on
+            a.id = tffj.object_id
         LEFT JOIN
         basic_card_rule b ON a.card_rule_id = b.id
         LEFT JOIN
@@ -427,8 +427,8 @@
             and ahi.USER_ID_ = cast(#{currentUserId} as char)) temp
             join ACT_HI_TASKINST t on
                 t.ID_ = temp.TASK_ID_
-            join t_exam_task_flow tetf on
-                tetf.flow_id = t.PROC_INST_ID_
+            join t_f_flow_join tffj on
+                tffj.flow_id = t.PROC_INST_ID_
             <if test="schoolId != null and schoolId != ''">
                 and a.school_id = #{schoolId}
             </if>
@@ -885,10 +885,10 @@
                 so.name teachingRoomName
             from
                 ACT_RU_TASK art
-            left join t_exam_task_flow tetf on
-                tetf.flow_id = art.PROC_INST_ID_
+            left join t_f_flow_join tffj on
+                tffj.flow_id = art.PROC_INST_ID_
             left join exam_task et on
-                et.id = tetf.task_id
+                et.id = tffj.object_id
             left join basic_card_rule b ON
                 et.card_rule_id = b.id
             left join t_f_flow_approve tffa on
@@ -940,10 +940,10 @@
                 so.name teachingRoomName
             from
                 ACT_RU_TASK art
-            left join t_exam_task_flow tetf on
-                tetf.flow_id = art.PROC_INST_ID_
+            left join t_f_flow_join tffj on
+                tffj.flow_id = art.PROC_INST_ID_
             left join exam_task et on
-                et.id = tetf.task_id
+                et.id = tffj.object_id
             left join act_ru_identitylink ari on
                 ari.TASK_ID_ = art.ID_
             left join basic_card_rule b ON
@@ -1185,8 +1185,8 @@
     <select id="findByFlowId" resultType="com.qmth.distributed.print.business.entity.ExamTask">
         select * from exam_task et where
             EXISTS(
-            select tetf.task_id from t_exam_task_flow tetf
-            where tetf.flow_id = #{flowId} and tetf.task_id = et.id
+            select tffj.object_id from t_f_flow_join tffj
+            where tffj.flow_id = #{flowId} and tffj.object_id = et.id
             )
     </select>
 

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

@@ -31,9 +31,9 @@
             t_f_flow_log tffl
         left join sys_user su on tffl.approve_id = su.id
         where EXISTS(
-            select t.flow_id from t_exam_task_flow t
-        where EXISTS (select tetf.task_id from t_exam_task_flow tetf
-                where tetf.flow_id = #{flowId} and tetf.task_id = t.task_id)
+            select t.flow_id from t_f_flow_join t
+        where EXISTS (select tffj.object_id from t_f_flow_join tffj
+                where tffj.flow_id = #{flowId} and tffj.object_id = t.object_id)
         and tffl.flow_id = t.flow_id)
         order by tffl.create_time desc
     </select>
@@ -54,9 +54,9 @@
             AND tffl.approve_operation = 'APPROVE'
             <if test="flowId > 0 and flowId != ''">
                 AND EXISTS(
-                select t.flow_id from t_exam_task_flow t
-                where EXISTS (select tetf.task_id from t_exam_task_flow tetf
-                where tetf.flow_id = #{flowId} and tetf.task_id = t.task_id)
+                select t.flow_id from t_f_flow_join t
+                where EXISTS (select tffj.object_id from t_f_flow_join tffj
+                where tffj.flow_id = #{flowId} and tffj.object_id = t.object_id)
                 and tffl.flow_id = t.flow_id)
             </if>
             <if test="setup != null and setup != ''">

+ 0 - 19
distributed-print-business/src/main/resources/mapper/TExamTaskFlowMapper.xml

@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!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.TExamTaskFlowMapper">
-
-    <select id="findByFlowLevel" resultType="java.lang.Integer">
-        SELECT max(t.level) FROM t_exam_task_flow t WHERE t.task_id = #{taskId}
-    </select>
-
-    <select id="findByRootLevel" resultType="java.lang.Long">
-        SELECT t.task_id FROM t_exam_task_flow t WHERE t.flow_id = #{flowId}
-    </select>
-
-    <select id="findByRootLevelByExamTaskId" resultType="java.lang.Integer">
-        SELECT min(t.level) FROM t_exam_task_flow t WHERE t.task_id = #{taskId}
-    </select>
-    <select id="selectMaxFlowIdByExamTaskId" resultType="java.lang.Long">
-        select max(flow_id) from t_exam_task_flow t where t.task_id = #{taskId}
-    </select>
-</mapper>

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

@@ -5,9 +5,9 @@
     <select id="findByFlowId" resultType="com.qmth.distributed.print.business.entity.TFFlowApprove">
         select * from t_f_flow_approve tffa
         where EXISTS(
-            select t.flow_id from t_exam_task_flow t
-            where EXISTS (select tetf.task_id from t_exam_task_flow tetf
-            where tetf.flow_id = #{flowId} and t.task_id = tetf.task_id)
+            select t.flow_id from t_f_flow_join t
+            where EXISTS (select tffj.object_id from t_f_flow_join tffj
+            where tffj.flow_id = #{flowId} and t.object_id = tffj.object_id)
             and t.`level` = 1 and tffa.school_id = #{schoolId} and tffa.flow_id = t.flow_id
             )
     </select>
@@ -19,7 +19,8 @@
         select
         t.*,
         tffl.pend_approve_id as pendApproveId,
-        tffl.task_id as taskId,
+        tffl.object_id as objectId,
+        tffl.object_table as objectTable,
         (
         select
         group_concat(su.real_name,'(',so.name,')')

+ 20 - 0
distributed-print-business/src/main/resources/mapper/TFFlowJoinMapper.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!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.TFFlowJoinMapper">
+
+    <select id="findByFlowLevel" resultType="java.lang.Integer">
+        SELECT max(t.level) FROM t_f_flow_join t WHERE t.object_id = #{objectId}
+    </select>
+
+    <select id="findByRootLevel" resultType="java.lang.Long">
+        SELECT t.object_id FROM t_f_flow_join t WHERE t.flow_id = #{flowId}
+    </select>
+
+    <select id="findByRootLevelByObjectId" resultType="java.lang.Integer">
+        SELECT min(t.level) FROM t_f_flow_join t WHERE t.object_id = #{objectId}
+    </select>
+
+    <select id="selectMaxFlowIdByObjectId" resultType="java.lang.Long">
+        select max(flow_id) from t_f_flow_join t where t.object_id = #{objectId}
+    </select>
+</mapper>

+ 8 - 7
distributed-print-business/src/main/resources/mapper/TFFlowLogMapper.xml

@@ -4,12 +4,12 @@
 
     <select id="findByFlowId" resultType="com.qmth.distributed.print.business.entity.TFFlowLog">
         select * from t_f_flow_log tffl
-         join t_exam_task_flow tetf on
-         tetf.flow_id = tffl.flow_id
+         join t_f_flow_join tffj on
+            tffj.flow_id = tffl.flow_id
          where tffl.school_id = #{schoolId} and tffl.flow_id = #{flowId}
     </select>
 
-    <select id="findByExamTaskId" resultType="com.qmth.distributed.print.business.bean.result.TFFlowLogResult">
+    <select id="findByObjectId" resultType="com.qmth.distributed.print.business.bean.result.TFFlowLogResult">
         select
             DISTINCT tffl.approve_id as approveId,
             tffl.approve_setup as approveSetup,
@@ -18,7 +18,8 @@
             tffl.pend_approve_id as pendApproveId,
             tffl.create_time as createTime,
             tffl.flow_id as flowId,
-            tffl.task_id as taskId,
+            tffl.object_id as objectId,
+            tffl.object_table as objectTable,
             tffl.id,
             tffl.paper_attachment_id as paperAttachmentId,
             su.school_id as schoolId,
@@ -54,7 +55,7 @@
         join sys_org so on
             so.id = su.org_id
         where
-            tffl.task_id = #{taskId}
+            tffl.object_id = #{objectId}
             and tffl.enable = 1
         order by
             tffl.create_time
@@ -62,8 +63,8 @@
 
     <select id="findByLast" resultType="com.qmth.distributed.print.business.entity.TFFlowLog">
         select * from t_f_flow_log tffl
-                          join t_exam_task_flow tetf on
-            tetf.flow_id = tffl.flow_id
+                          join t_f_flow_join tffj on
+            tffj.flow_id = tffl.flow_id
         where tffl.school_id = #{schoolId} and tffl.flow_id = #{flowId}
         and tffl.approve_operation = #{approveOperation}
         order by tffl.create_time desc

+ 4 - 4
distributed-print/src/main/java/com/qmth/distributed/print/api/ExamTaskController.java

@@ -98,7 +98,7 @@ public class ExamTaskController {
     ExamTaskApplyTempService examTaskApplyTempService;
 
     @Resource
-    TExamTaskFlowService tExamTaskFlowService;
+    TFFlowJoinService tfFlowJoinService;
 
     /**
      * 命题任务管理-查询
@@ -307,12 +307,12 @@ public class ExamTaskController {
             if (Objects.nonNull(task)) {
                 detail.setFlowTaskId(task.getId());
             } else {
-                TExamTaskFlow tExamTaskFlow = tExamTaskFlowService.findByFlowLevel(Long.parseLong(detail.getExamTaskId()));
-                task = taskService.createTaskQuery().processInstanceId(String.valueOf(tExamTaskFlow.getFlowId())).singleResult();
+                TFFlowJoin tfFlowJoin = tfFlowJoinService.findByFlowLevel(Long.parseLong(detail.getExamTaskId()));
+                task = taskService.createTaskQuery().processInstanceId(String.valueOf(tfFlowJoin.getFlowId())).singleResult();
                 if (Objects.nonNull(task)) {
                     detail.setSubFlowReject(true);
                     detail.setFlowTaskId(task.getId());
-                    detail.setFlowId(String.valueOf(tExamTaskFlow.getFlowId()));
+                    detail.setFlowId(String.valueOf(tfFlowJoin.getFlowId()));
                 }
             }
         }

+ 6 - 4
distributed-print/src/main/java/com/qmth/distributed/print/api/TFCustomFlowController.java

@@ -62,7 +62,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 @Api(tags = "自定义流程Controller")
 @RestController
 @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/${prefix.url.customFlow}")
-//@Aac(auth = BOOL.FALSE, strict = BOOL.FALSE)
+@Aac(auth = BOOL.FALSE, strict = BOOL.FALSE)
 @Validated
 public class TFCustomFlowController {
     private final static Logger log = LoggerFactory.getLogger(TFCustomFlowController.class);
@@ -151,11 +151,13 @@ public class TFCustomFlowController {
     @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = ResultUtil.class)})
     @RequestMapping(value = "/testStart", method = RequestMethod.POST)
     @Transactional
-    public Result testStart(@ApiParam(value = "命题任务id", required = true) @RequestParam String taskId,
-                            @ApiParam(value = "命题老师id", required = true) @RequestParam String approveId) {
+    public Result testStart(@ApiParam(value = "实体id", required = true) @RequestParam String objectId,
+                            @ApiParam(value = "命题老师id", required = true) @RequestParam String approveId,
+                            @ApiParam(value = "实体表", required = true) @RequestParam TFCustomTypeEnum flowType) {
         Map<String, Object> map = new HashMap<>();
-        map.computeIfAbsent(SystemConstant.EXAM_TASK_ID, v -> SystemConstant.convertIdToLong(taskId));
+        map.computeIfAbsent(SystemConstant.OBJECT_ID, v -> SystemConstant.convertIdToLong(objectId));
         map.computeIfAbsent(SystemConstant.APPROVE_ID, v -> SystemConstant.convertIdToLong(approveId));
+        map.computeIfAbsent(SystemConstant.FLOW_TYPE, v -> flowType);
         activitiService.customFlowStart(map);
         return ResultUtil.ok(true);
     }

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

@@ -209,6 +209,7 @@ public class SystemConstant {
     public static final String GDYKDX_SUB_FLOW_KEY = "GdykdxPaperSubPrintApprove";//广药子流程key
     public static final String JXZYY_FLOW_KEY = "JxzyyPaperApprove";//江西流程key
     public static final String APPROVE_ID = "approveId";//审批id
+    public static final String FLOW_TYPE = "flowType";//流程类型
 //    public static final String TEACHING_ROOM_ID = "teachingRoomId";//教研室机构id
     public static final String FLOW_ID = "flowId";//流程id
     public static final String FLOW_TASK_ID = "flowTaskId";//流程任务id
@@ -230,7 +231,8 @@ public class SystemConstant {
     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 EXAM_TASK_ID = "examTaskId";
+//    public static final String EXAM_TASK_ID = "examTaskId";
+    public static final String OBJECT_ID = "objectId";
     public static final String APPROVE_TF_FLOW_LOG = "TFFlowLog";//流程院长自动审批
     public static final String PAPAER_ATTACHMENT_IDS = "paperAttachmentIds";//命题附件ids
     public static final String REDIS_LOCK_FLOW_TASK_PREFIX = "redis:lock:flow:task:";//流程节点锁