Ver código fonte

新增自定义流程属性-功能BUG修改

wangliang 3 anos atrás
pai
commit
c60cec3dc2

+ 7 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/flow/CustomFlowDto.java

@@ -6,7 +6,9 @@ import io.swagger.annotations.ApiModelProperty;
 import javax.validation.constraints.NotBlank;
 import javax.validation.constraints.NotNull;
 import java.io.Serializable;
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
 
 /**
  * @Description: 自定义流程dto
@@ -75,7 +77,11 @@ public class CustomFlowDto implements Serializable {
     }
 
     public List<CustomFlowSequenceDto> getBeforeFlowTaskIds() {
-        return beforeFlowTaskIds;
+        if (Objects.isNull(beforeFlowTaskIds)) {
+            return new ArrayList<>();
+        } else {
+            return beforeFlowTaskIds;
+        }
     }
 
     public void setBeforeFlowTaskIds(List<CustomFlowSequenceDto> beforeFlowTaskIds) {

+ 14 - 5
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/flow/CustomFlowGatewayDto.java

@@ -3,8 +3,10 @@ package com.qmth.distributed.print.business.bean.flow;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 
 /**
  * @Description: 自定义流程网关 dto
@@ -16,7 +18,7 @@ import java.util.Map;
 public class CustomFlowGatewayDto implements Serializable {
 
     @ApiModelProperty(value = "审批通过排他网关节点id")
-    String beforeExclusiveGatewayId;
+    List<String> beforeExclusiveGatewayId;
 
     @ApiModelProperty(value = "审批驳回排他网关节点id")
     String afterExclusiveGatewayId;
@@ -30,18 +32,25 @@ public class CustomFlowGatewayDto implements Serializable {
 
     public CustomFlowGatewayDto(String exclusiveGatewayId, Map<String, List<CustomFlowSequenceDto>> flowTaskIds, boolean beforeExclusiveGateway) {
         if (beforeExclusiveGateway) {
-            this.beforeExclusiveGatewayId = exclusiveGatewayId;
+            if (Objects.isNull(this.beforeExclusiveGatewayId)) {
+                this.beforeExclusiveGatewayId = new ArrayList<>();
+            }
+            this.beforeExclusiveGatewayId.add(exclusiveGatewayId);
         } else {
             this.afterExclusiveGatewayId = exclusiveGatewayId;
         }
         this.flowTaskIds = flowTaskIds;
     }
 
-    public String getBeforeExclusiveGatewayId() {
-        return beforeExclusiveGatewayId;
+    public List<String> getBeforeExclusiveGatewayId() {
+        if (Objects.isNull(beforeExclusiveGatewayId)) {
+            return new ArrayList<>();
+        } else {
+            return beforeExclusiveGatewayId;
+        }
     }
 
-    public void setBeforeExclusiveGatewayId(String beforeExclusiveGatewayId) {
+    public void setBeforeExclusiveGatewayId(List<String> beforeExclusiveGatewayId) {
         this.beforeExclusiveGatewayId = beforeExclusiveGatewayId;
     }
 

+ 3 - 5
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/flow/CustomFlowSaveDto.java

@@ -104,21 +104,19 @@ public class CustomFlowSaveDto implements Serializable {
             return false;
         }
         CustomFlowSaveDto that = (CustomFlowSaveDto) o;
-        return name.equals(that.name) && type == that.type && schoolId.equals(that.schoolId) && orgId.equals(that.orgId);
+        return type == that.type && schoolId.equals(that.schoolId);
     }
 
     @Override
     public int hashCode() {
-        return Objects.hash(name, type, schoolId, orgId);
+        return Objects.hash(type, schoolId);
     }
 
     @Override
     public String toString() {
         return "CustomFlowSaveDto{" +
-                "name='" + name + '\'' +
-                ", type=" + type +
+                "type=" + type +
                 ", schoolId=" + schoolId +
-                ", orgId=" + orgId +
                 '}';
     }
 }

+ 2 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ActivitiService.java

@@ -145,10 +145,11 @@ public interface ActivitiService {
      *
      * @param customFlowSaveDto
      * @param id
+     * @param version
      * @return
      * @throws IOException
      */
-    public Map<String, Object> dynamicBuildBpmn(CustomFlowSaveDto customFlowSaveDto, String id) throws IOException;
+    public Map<String, Object> dynamicBuildBpmn(CustomFlowSaveDto customFlowSaveDto, String id, Integer version) throws IOException;
 
     /**
      * 启动自定义流程

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

@@ -230,11 +230,12 @@ public class ActivitiServiceImpl implements ActivitiService {
     protected Deployment flowDeployment(Map<String, Object> map) {
         String id = (String) map.get(SystemConstant.ID);
         BpmnModel model = (BpmnModel) map.get(SystemConstant.MODEL);
+        Integer version = (Integer) map.get(SystemConstant.VERSION);
 
         //部署流程
         String bpmnName = id + DefaultInstanceConvertToMultiInstance.FLOW_BPMN_MODEL_NAME;
         String bpmnDeploymentName = id + DefaultInstanceConvertToMultiInstance.FLOW_BPMN_DEPLOYMENT_NAME;
-        String bpmnProcessName = id + DefaultInstanceConvertToMultiInstance.FLOW_BPMN_PROCESS_NAME;
+        String bpmnProcessName = id + "_v" + version + DefaultInstanceConvertToMultiInstance.FLOW_BPMN_PROCESS_NAME;
 
         Deployment deployment = repositoryService.createDeployment().addBpmnModel(bpmnName, model).name(bpmnDeploymentName).deploy();
         map.remove(SystemConstant.MODEL);
@@ -410,62 +411,40 @@ public class ActivitiServiceImpl implements ActivitiService {
                 if (approvePass == FlowApprovePassEnum.PASS) {
                     int currSetup = currFlowTaskResult.getSetup().intValue();
                     currSetup = currSetup == setupMap.size() - 1 ? 0 : currSetup + 1;
-                    //驳回再提交时,需要走网关路线
-                    if (tfFlowApprove.getStatus() == FlowStatusEnum.REJECT) {
-                        //获取驳回路线
-                        FlowTaskResult flowTaskResultRejectLinkDto = null;
-                        Map<String, FlowTaskResult> rejectLinkMap = null;
-                        if (Objects.nonNull(tfFlowApprove.getRejectLink())) {
-                            rejectLinkMap = JacksonUtil.readJson(tfFlowApprove.getRejectLink(), Map.class);
-                            if (Objects.nonNull(rejectLinkMap.get(userTask.getId()))) {
-                                flowTaskResultRejectLinkDto = gson.fromJson(gson.toJson(rejectLinkMap.get(userTask.getId())), FlowTaskResult.class);
-                            }
+                    //驳回再提交时,可能需要走网关路线
+                    //获取驳回路线
+                    FlowTaskResult flowTaskResultRejectLinkDto = null;
+                    Map<String, FlowTaskResult> rejectLinkMap = null;
+                    if (Objects.nonNull(tfFlowApprove.getRejectLink())) {
+                        rejectLinkMap = JacksonUtil.readJson(tfFlowApprove.getRejectLink(), Map.class);
+                        if (Objects.nonNull(rejectLinkMap.get(userTask.getId()))) {
+                            flowTaskResultRejectLinkDto = gson.fromJson(gson.toJson(rejectLinkMap.get(userTask.getId())), FlowTaskResult.class);
                         }
+                    }
 
-                        nextFlowTaskResult = this.getNextFlowTaskResult(nrOfCompletedInstances,
-                                nrOfInstances,
-                                currFlowTaskResult,
-                                nextFlowTaskResult,
-                                Objects.nonNull(flowTaskResultRejectLinkDto) ? flowTaskResultRejectLinkDto.getSetup() : currSetup,
-                                setupMap,
-                                gson,
-                                approvePass);
-
-                        this.approvePass(currFlowTaskResult,
-                                setupMap,
-                                multiInstance,
-                                nrOfCompletedInstances,
-                                nrOfInstances,
-                                tfFlowApprove,
-                                tfFlowLog,
-                                nextFlowTaskResult,
-                                map,
-                                id);
-
-                        if (Objects.nonNull(flowTaskResultRejectLinkDto)) {
-                            rejectLinkMap.remove(userTask.getId());
-                            tfFlowApprove.setRejectLink(rejectLinkMap.size() == 0 ? null : JacksonUtil.parseJson(rejectLinkMap));
-                        }
-                    } else {//走正常路线
-                        nextFlowTaskResult = this.getNextFlowTaskResult(nrOfCompletedInstances,
-                                nrOfInstances,
-                                currFlowTaskResult,
-                                nextFlowTaskResult,
-                                currSetup,
-                                setupMap,
-                                gson,
-                                approvePass);
-
-                        this.approvePass(currFlowTaskResult,
-                                setupMap,
-                                multiInstance,
-                                nrOfCompletedInstances,
-                                nrOfInstances,
-                                tfFlowApprove,
-                                tfFlowLog,
-                                nextFlowTaskResult,
-                                map,
-                                id);
+                    nextFlowTaskResult = this.getNextFlowTaskResult(nrOfCompletedInstances,
+                            nrOfInstances,
+                            currFlowTaskResult,
+                            nextFlowTaskResult,
+                            Objects.nonNull(flowTaskResultRejectLinkDto) ? flowTaskResultRejectLinkDto.getSetup() : currSetup,
+                            setupMap,
+                            gson,
+                            approvePass);
+
+                    this.approvePass(currFlowTaskResult,
+                            setupMap,
+                            multiInstance,
+                            nrOfCompletedInstances,
+                            nrOfInstances,
+                            tfFlowApprove,
+                            tfFlowLog,
+                            nextFlowTaskResult,
+                            map,
+                            id);
+
+                    if (Objects.nonNull(flowTaskResultRejectLinkDto)) {
+                        rejectLinkMap.remove(userTask.getId());
+                        tfFlowApprove.setRejectLink(rejectLinkMap.size() == 0 ? null : JacksonUtil.parseJson(rejectLinkMap));
                     }
                 } else if (approvePass == FlowApprovePassEnum.REJECT) {
                     Optional.ofNullable(map.get(SystemConstant.APPROVE_SETUP)).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("流程驳回节点不能为空"));
@@ -1831,12 +1810,13 @@ public class ActivitiServiceImpl implements ActivitiService {
      *
      * @param customFlowSaveDto
      * @param id
+     * @param version
      * @return
      * @throws IOException
      */
     @Override
     @Transactional
-    public Map<String, Object> dynamicBuildBpmn(CustomFlowSaveDto customFlowSaveDto, String id) throws IOException {
+    public Map<String, Object> dynamicBuildBpmn(CustomFlowSaveDto customFlowSaveDto, String id, Integer version) throws IOException {
         BpmnModel model = new BpmnModel();
         Process process = new Process();
         model.addProcess(process);
@@ -2074,6 +2054,7 @@ public class ActivitiServiceImpl implements ActivitiService {
         map.computeIfAbsent(SystemConstant.ID, v -> id);
         map.computeIfAbsent(SystemConstant.MODEL, v -> model);
         map.computeIfAbsent(SystemConstant.FLOW_PROCESS_VAR_MAP, v -> flowProcessVarMap);
+        map.computeIfAbsent(SystemConstant.VERSION, v -> version);
         this.flowDeployment(map);
         return map;
     }
@@ -2160,10 +2141,12 @@ public class ActivitiServiceImpl implements ActivitiService {
             customFlowGatewayDto = new CustomFlowGatewayDto();
         }
         //是否存在审批网关
-        if (Objects.isNull(customFlowExclusiveGatewayTaskNode) && Objects.isNull(customFlowGatewayDto.getBeforeExclusiveGatewayId())) {
+        if (Objects.isNull(customFlowExclusiveGatewayTaskNode) && (Objects.isNull(customFlowGatewayDto.getBeforeExclusiveGatewayId()) || customFlowGatewayDto.getBeforeExclusiveGatewayId().size() == 0)) {
             customFlowExclusiveGatewayTaskNode = createCustomFlowExclusiveGateway(flowTaskLink, index, process, gatewayId);
         }
-        customFlowGatewayDto.setBeforeExclusiveGatewayId(customFlowExclusiveGatewayTaskNode.getTask().getFlowTaskId());
+        List<String> beforeExclusiveGatewayIdList = customFlowGatewayDto.getBeforeExclusiveGatewayId();
+        beforeExclusiveGatewayIdList.add(customFlowExclusiveGatewayTaskNode.getTask().getFlowTaskId());
+        customFlowGatewayDto.setBeforeExclusiveGatewayId(beforeExclusiveGatewayIdList);
 
         CustomFlowSequenceDto customFlowSequenceRejectDto = new CustomFlowSequenceDto(flowTaskId, DefaultInstanceConvertToMultiInstance.EXP_PREFIX + SystemConstant.APPROVE + DefaultInstanceConvertToMultiInstance.EXP_EQUAL + "'" + flowTaskId + "'" + DefaultInstanceConvertToMultiInstance.EXP_SUFFIX, pass, setup);
         Map<String, List<CustomFlowSequenceDto>> flowTaskIds = customFlowGatewayDto.getFlowTaskIds();
@@ -2174,10 +2157,12 @@ public class ActivitiServiceImpl implements ActivitiService {
             customFlowSequenceDtoList = new ArrayList<>();
         }
         customFlowSequenceDtoList.add(customFlowSequenceRejectDto);
-        flowTaskIds.put(customFlowGatewayDto.getBeforeExclusiveGatewayId(), customFlowSequenceDtoList);
+        flowTaskIds.put(customFlowExclusiveGatewayTaskNode.getTask().getFlowTaskId(), customFlowSequenceDtoList);
         customFlowGatewayDto.setFlowTaskIds(flowTaskIds);
         approveDataMap.put(node.getTask().getFlowTaskId(), customFlowGatewayDto);
-        customFlowExclusiveGatewayTaskNode.getTask().setBeforeFlowTaskIds(flowTaskIds.get(customFlowExclusiveGatewayTaskNode.getTask().getFlowTaskId()));
+        List<CustomFlowSequenceDto> customFlowSequenceGateWayDtoList = customFlowExclusiveGatewayTaskNode.getTask().getBeforeFlowTaskIds();
+        customFlowSequenceGateWayDtoList.addAll(flowTaskIds.get(customFlowExclusiveGatewayTaskNode.getTask().getFlowTaskId()));
+        customFlowExclusiveGatewayTaskNode.getTask().setBeforeFlowTaskIds(customFlowSequenceGateWayDtoList);
     }
 
     /**

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

@@ -13,7 +13,6 @@ import com.qmth.distributed.print.business.bean.result.FlowTaskApprovePeopleAllR
 import com.qmth.distributed.print.business.bean.result.FlowTaskResult;
 import com.qmth.distributed.print.business.entity.TFCustomFlow;
 import com.qmth.distributed.print.business.service.ActivitiService;
-import com.qmth.distributed.print.business.service.TFCustomFlowListService;
 import com.qmth.distributed.print.business.service.TFCustomFlowService;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.BasicSchool;
@@ -68,9 +67,6 @@ public class TFCustomFlowController {
     @Resource
     CommonCacheService commonCacheService;
 
-    @Resource
-    TFCustomFlowListService tfCustomFlowListService;
-
     @ApiOperation(value = "保存和发布流程")
     @ApiResponses({@ApiResponse(code = 200, message = "常规信息", response = ResultUtil.class)})
     @RequestMapping(value = "/save", method = RequestMethod.POST)
@@ -100,7 +96,7 @@ public class TFCustomFlowController {
                 tfCustomFlow.setVersion(atomicInteger.incrementAndGet());
             }
             //自定义流程处理开始
-            Map<String, Object> map = activitiService.dynamicBuildBpmn(customFlowSaveDto, flowBpmnId);
+            Map<String, Object> map = activitiService.dynamicBuildBpmn(customFlowSaveDto, flowBpmnId, tfCustomFlow.getVersion());
             tfCustomFlow.setFlowProcessVar(JacksonUtil.parseJson(map));
             tfCustomFlowService.save(tfCustomFlow);
         } catch (Exception e) {

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

@@ -57,6 +57,7 @@ public class SystemConstant {
     public static final String HTTP = "http://";
     public static final String ID = "id";
     public static final String MODEL = "model";
+    public static final String VERSION = "version";
     public static final String FLOW_LIST_ID = "flowListId";
     public static final String FLOW_PROCESS_VAR_MAP = "flowProcessVarMap";
     public static final String PROCESS_DEFINITION_ID = "processDefinitionId";