Browse Source

自定义流程接口修改

wangliang 3 years ago
parent
commit
95ff63407d

+ 2 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/activiti/custom/service/DefaultInstanceConvertToMultiInstance.java

@@ -22,8 +22,8 @@ public interface DefaultInstanceConvertToMultiInstance extends MultiWorkFlow {
     public static final String ASSIGNEE_USER_EXP = EXP_PREFIX + ASSIGNEE_USER;
     public static final String APPROVE_ID_EXP = EXP_PREFIX + "approveId" + EXP_SUFFIX;
     public static final String DEFAULT_USER_TASK = "_default";
-    public static final String DEFAULT_USER_TASK_NAME = "提交试卷";
-    public static final String USER_TASK_APPROVE_NAME = "审人";
+    public static final String DEFAULT_USER_TASK_NAME = "提交申请";
+    public static final String USER_TASK_APPROVE_NAME = "审人";
     public static final String FLOW_BPMN_MODEL_NAME = "-dynamic-model.bpmn";
     public static final String FLOW_BPMN_PROCESS_NAME = "-multiple-process.bpmn";
     public static final String FLOW_BPMN_PNG_NAME = "-multiple-process-diagram.png";

+ 15 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/flow/CustomFlowSaveDto.java

@@ -2,6 +2,7 @@ package com.qmth.distributed.print.business.bean.flow;
 
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.distributed.print.business.entity.TFCustomFlow;
 import com.qmth.distributed.print.business.enums.TFCustomTypeEnum;
 import io.swagger.annotations.ApiModelProperty;
 
@@ -46,6 +47,20 @@ public class CustomFlowSaveDto implements Serializable {
     @JsonSerialize(using = ToStringSerializer.class)
     Long orgId;
 
+    public CustomFlowSaveDto() {
+
+    }
+
+    public CustomFlowSaveDto(TFCustomFlow tfCustomFlow, List<CustomFlowDto> customFlowLists) {
+        this.customFlowId = tfCustomFlow.getId();
+        this.name = tfCustomFlow.getName();
+        this.type = tfCustomFlow.getType();
+        this.publish = tfCustomFlow.getPublish();
+        this.schoolId = tfCustomFlow.getSchoolId();
+        this.orgId = tfCustomFlow.getOrgId();
+        this.customFlowLists = customFlowLists;
+    }
+
     public void setSchoolAndOrgInfo(Long schoolId, Long orgId) {
         this.schoolId = schoolId;
         this.orgId = orgId;

+ 62 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/result/FlowViewTaskResult.java

@@ -1,9 +1,11 @@
 package com.qmth.distributed.print.business.bean.result;
 
 import com.qmth.distributed.print.business.enums.CustomFlowMultipleUserApproveTypeEnum;
+import com.qmth.teachcloud.common.enums.FlowApproveOperationEnum;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
+import java.util.Objects;
 
 /**
  * @Description: 流程节点result
@@ -14,8 +16,14 @@ import java.io.Serializable;
  */
 public class FlowViewTaskResult extends FlowTaskResult implements Serializable {
 
+    @ApiModelProperty(value = "审批操作,SUBMIT:提交,APPROVE:审批,REJECT:驳回,END:终止,EXCHANGE:转他人审批")
+    private FlowApproveOperationEnum approveOperation;
+
+    @ApiModelProperty(value = "审批操作,SUBMIT:提交,APPROVE:审批,REJECT:驳回,END:终止,EXCHANGE:转他人审批")
+    private String approveOperationStr;
+
     @ApiModelProperty(value = "自定义流程审核类型")
-    CustomFlowMultipleUserApproveTypeEnum multipleUserApproveType;
+    private CustomFlowMultipleUserApproveTypeEnum multipleUserApproveType;
 
     @ApiModelProperty(value = "流程审批人")
     private String pendApproveUsers;
@@ -23,9 +31,54 @@ public class FlowViewTaskResult extends FlowTaskResult implements Serializable {
     @ApiModelProperty(value = "流程已审人")
     private String approveUsers;
 
+    @ApiModelProperty(value = "当前审批人")
+    private String currentApproveUsers;
+
     @ApiModelProperty(value = "是否当前节点")
     private boolean currentTask;
 
+    @ApiModelProperty(value = "审核意见")
+    private String approveRemark;
+
+    @ApiModelProperty(value = "创建时间")
+    private Long createTime;
+
+    public FlowApproveOperationEnum getApproveOperation() {
+        return approveOperation;
+    }
+
+    public void setApproveOperation(FlowApproveOperationEnum approveOperation) {
+        this.approveOperation = approveOperation;
+    }
+
+    public String getApproveOperationStr() {
+        if (Objects.nonNull(approveOperation)) {
+            return approveOperation.getTitle();
+        } else {
+            return approveOperationStr;
+        }
+    }
+
+    public void setApproveOperationStr(String approveOperationStr) {
+        this.approveOperationStr = approveOperationStr;
+    }
+
+    public String getApproveRemark() {
+        return approveRemark;
+    }
+
+    public void setApproveRemark(String approveRemark) {
+        this.approveRemark = approveRemark;
+    }
+
+    public Long getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Long createTime) {
+        this.createTime = createTime;
+    }
+
     public CustomFlowMultipleUserApproveTypeEnum getMultipleUserApproveType() {
         return multipleUserApproveType;
     }
@@ -50,6 +103,14 @@ public class FlowViewTaskResult extends FlowTaskResult implements Serializable {
         this.approveUsers = approveUsers;
     }
 
+    public String getCurrentApproveUsers() {
+        return currentApproveUsers;
+    }
+
+    public void setCurrentApproveUsers(String currentApproveUsers) {
+        this.currentApproveUsers = currentApproveUsers;
+    }
+
     public boolean isCurrentTask() {
         return currentTask;
     }

+ 28 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/result/TFFlowLogResult.java

@@ -7,6 +7,7 @@ import com.qmth.teachcloud.common.enums.FlowApproveOperationEnum;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
+import java.util.Objects;
 
 /**
  * @Description: TFFlowLogResult
@@ -44,6 +45,28 @@ public class TFFlowLogResult extends ApproveUserResult implements Serializable {
     @ApiModelProperty(value = "试卷附件")
     private String paperAttachmentId;
 
+    @ApiModelProperty(value = "待审核人")
+    private String pendApproveUserName;
+
+    @ApiModelProperty(value = "已审核人")
+    private String approveUserName;
+
+    public String getPendApproveUserName() {
+        return pendApproveUserName;
+    }
+
+    public void setPendApproveUserName(String pendApproveUserName) {
+        this.pendApproveUserName = pendApproveUserName;
+    }
+
+    public String getApproveUserName() {
+        return approveUserName;
+    }
+
+    public void setApproveUserName(String approveUserName) {
+        this.approveUserName = approveUserName;
+    }
+
     public String getPaperAttachmentId() {
         return paperAttachmentId;
     }
@@ -77,7 +100,11 @@ public class TFFlowLogResult extends ApproveUserResult implements Serializable {
     }
 
     public Integer getApproveSetup() {
-        return approveSetup;
+        if (Objects.isNull(approveSetup)) {
+            return 10000000;
+        } else {
+            return approveSetup;
+        }
     }
 
     public void setApproveSetup(Integer approveSetup) {

+ 45 - 5
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ActivitiServiceImpl.java

@@ -15,8 +15,10 @@ import com.qmth.distributed.print.business.enums.*;
 import com.qmth.distributed.print.business.service.*;
 import com.qmth.teachcloud.common.bean.params.ApproveUserResult;
 import com.qmth.teachcloud.common.contant.SystemConstant;
+import com.qmth.teachcloud.common.entity.SysOrg;
 import com.qmth.teachcloud.common.entity.SysUser;
 import com.qmth.teachcloud.common.enums.*;
+import com.qmth.teachcloud.common.service.CommonCacheService;
 import com.qmth.teachcloud.common.service.SysUserService;
 import com.qmth.teachcloud.common.util.JacksonUtil;
 import com.qmth.teachcloud.common.util.RedisUtil;
@@ -115,6 +117,9 @@ public class ActivitiServiceImpl implements ActivitiService {
     @Resource
     TFCustomFlowEntityService tfCustomFlowEntityService;
 
+    @Resource
+    CommonCacheService commonCacheService;
+
     /**
      * 注册流程
      *
@@ -775,9 +780,11 @@ public class ActivitiServiceImpl implements ActivitiService {
         List<FlowTaskResult> flowTaskResultList = new ArrayList<>(setupMap.size());
         Gson gson = new Gson();
         for (Map.Entry<String, FlowTaskResult> entry : setupMap.entrySet()) {
-            FlowTaskResult FlowTaskResult = gson.fromJson(gson.toJson(entry.getValue()), FlowTaskResult.class);
-            FlowTaskResult.setFlowId(tfCustomFlowEntity.getFlowId());
-            flowTaskResultList.add(FlowTaskResult);
+            FlowTaskResult flowTaskResult = gson.fromJson(gson.toJson(entry.getValue()), FlowTaskResult.class);
+            if (flowTaskResult.getSetup() > 0) {
+                flowTaskResult.setFlowId(tfCustomFlowEntity.getFlowId());
+                flowTaskResultList.add(flowTaskResult);
+            }
         }
         return flowTaskResultList;
     }
@@ -2248,6 +2255,7 @@ public class ActivitiServiceImpl implements ActivitiService {
     @Override
     public FlowViewResult getFlowView(Long flowId) {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+        SysOrg sysOrg = commonCacheService.orgCache(sysUser.getOrgId());
         TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.findByFlowId(flowId);
         Optional.ofNullable(tfCustomFlowEntity).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("自定义流程实体数据为空"));
 
@@ -2280,6 +2288,7 @@ public class ActivitiServiceImpl implements ActivitiService {
         if (Objects.nonNull(tfFlowApprove.getTransferAssignee())) {
             agginessMap = JacksonUtil.readJson(tfFlowApprove.getTransferAssignee(), Map.class);
         }
+
 //        Map<String, Object> varMap = new HashMap<>();
 //        for (Map.Entry<String, CustomFlowVarDto> entry : agginessMap.entrySet()) {
 //            CustomFlowVarDto customFlowVarDto = gson.fromJson(gson.toJson(entry.getValue()), CustomFlowVarDto.class);
@@ -2288,8 +2297,39 @@ public class ActivitiServiceImpl implements ActivitiService {
 
         //获取流程审批历史
         List<TFFlowLogResult> tfFlowLogResultList = tfFlowLogService.findByExamTaskId(tExamTaskFlowList.get(0).getTaskId());
-        flowViewResult.setFlowTaskResultList(flowViewTaskResultList);
-        flowViewResult.setTfFlowLogResultList(tfFlowLogResultList);
+        if (Objects.nonNull(tfFlowLogResultList) && tfFlowLogResultList.size() > 0) {
+            LinkedMultiValueMap<Integer, TFFlowLogResult> tfFlowLogResultMap = new LinkedMultiValueMap<>();
+            for (TFFlowLogResult t : tfFlowLogResultList) {
+                tfFlowLogResultMap.add(t.getApproveSetup(), t);
+            }
+
+            int nextFlowSetup = 0;
+            for (FlowViewTaskResult f : flowViewTaskResultList) {
+                CustomFlowVarDto customFlowVarDto = gson.fromJson(gson.toJson(agginessMap.get(f.getTaskKey())), CustomFlowVarDto.class);
+                if (flowViewResult.getSetup().intValue() == f.getSetup().intValue()) {//当前审批节点
+                    f.setCurrentTask(true);
+                    f.setCurrentApproveUsers(sysUser.getRealName() + "(" + sysOrg.getName() + ")");
+                    nextFlowSetup = flowViewResult.getSetup().intValue() + 1;
+                    nextFlowSetup = nextFlowSetup == setupMap.size() ? 0 : nextFlowSetup;
+                } else {
+                    //下一节点审批人
+                    if (nextFlowSetup > 0 && nextFlowSetup == f.getSetup().intValue()) {
+                        List<TFFlowLogResult> tfFlowLogResults = tfFlowLogResultMap.get(f.getSetup());
+                        if (Objects.nonNull(tfFlowLogResults) && tfFlowLogResults.size() > 0) {
+                            f.setPendApproveUsers(tfFlowLogResults.get(tfFlowLogResults.size() - 1).getPendApproveUserName());
+                        }
+                    } else {
+                        f.setPendApproveUsers(customFlowVarDto.getApproveIds().toString());
+                    }
+                }
+                f.setMultipleUserApproveType(customFlowVarDto.getMultipleUserApproveType());
+//            flowViewTaskResult.setPendApproveUsers(customFlowVarDto.getApproveIds());
+//            flowViewTaskResult.setApproveUsers(Arrays.asList("1"));
+            }
+
+            flowViewResult.setFlowTaskResultList(flowViewTaskResultList);
+            flowViewResult.setTfFlowLogResultList(tfFlowLogResultList);
+        }
         return flowViewResult;
     }
 

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

@@ -36,7 +36,7 @@
     </select>
 
     <select id="list" resultType="com.qmth.distributed.print.business.entity.TFCustomFlow">
-        select tfcf.id,tfcf.school_id as schoolId,tfcf.org_id as orgId,tfcf.name,tfcf.enable,tfcf.publish from t_f_custom_flow tfcf
+        select tfcf.id,tfcf.school_id as schoolId,tfcf.org_id as orgId,tfcf.name,tfcf.type,tfcf.version,tfcf.enable,tfcf.publish from t_f_custom_flow tfcf
         <where>
             <if test="schoolId != null and schoolId != ''">
                 and tfcf.school_id = #{schoolId}

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

@@ -28,7 +28,25 @@
             su.mobile_number as mobileNumber,
             su.org_id as orgId,
             so.name as orgName,
-            so.`type` as orgType
+            so.`type` as orgType,
+             (
+                 select
+                     group_concat(su.real_name, '(', so.name, ')')
+                 from
+                     sys_user su
+                         join sys_org so on
+                         so.id = su.org_id
+                 where
+                     FIND_IN_SET(su.id, replace(tffl.pend_approve_id, ', ', ','))) as pendApproveUserName,
+             (
+                 select
+                     CONCAT(su.real_name, '(', so.name, ')')
+                 from
+                     sys_user su
+                         join sys_org so on
+                         so.id = su.org_id
+                 where
+                     su.id = tffl.approve_id) as approveUserName
         from
             t_f_flow_log tffl
         join sys_user su on

+ 7 - 1
distributed-print/src/main/java/com/qmth/distributed/print/api/TFCustomFlowController.java

@@ -2,10 +2,13 @@ package com.qmth.distributed.print.api;
 
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
 import com.qmth.boot.api.annotation.Aac;
 import com.qmth.boot.api.annotation.BOOL;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.boot.api.exception.ApiException;
+import com.qmth.distributed.print.business.bean.flow.CustomFlowDto;
 import com.qmth.distributed.print.business.bean.flow.CustomFlowSaveDto;
 import com.qmth.distributed.print.business.bean.params.FlowTaskApproveParam;
 import com.qmth.distributed.print.business.bean.params.customFlowParam;
@@ -229,7 +232,10 @@ public class TFCustomFlowController {
         TFCustomFlow tfCustomFlow = tfCustomFlowService.getById(SystemConstant.convertIdToLong(id));
         Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("自定义流程数据为空"));
         Optional.ofNullable(tfCustomFlow.getObjectData()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("自定义流程绘图数据为空"));
-        return ResultUtil.ok(tfCustomFlow.getObjectData());
+        Gson gson = new Gson();
+        List<CustomFlowDto> customFlowLists = gson.fromJson(tfCustomFlow.getObjectData(), new TypeToken<List<CustomFlowDto>>() {
+        }.getType());
+        return ResultUtil.ok(new CustomFlowSaveDto(tfCustomFlow, customFlowLists), null);
     }
 
     @ApiOperation(value = "流程逻辑删除")