24282 před 2 roky
rodič
revize
c330f3f3d0

+ 1 - 1
hx-flow/src/main/java/com/fjhx/flow/config/FlowBeanPostProcessor.java

@@ -25,7 +25,7 @@ public class FlowBeanPostProcessor implements BeanPostProcessor {
             log.info("流程Key:{} spring委托对象注册成功", flowKey);
         }
 
-        return BeanPostProcessor.super.postProcessAfterInitialization(bean, beanName);
+        return bean;
     }
 
 }

+ 8 - 0
hx-flow/src/main/java/com/fjhx/flow/controller/flow/FlowDefinitionController.java

@@ -47,4 +47,12 @@ public class FlowDefinitionController {
         flowDefinitionService.addVersion(dto);
     }
 
+    /**
+     * 修改流程版本
+     */
+    @PostMapping("/updateVersion")
+    public void updateVersion(@RequestBody FlowDefinition flowDefinition) {
+        flowDefinitionService.updateVersion(flowDefinition.getId());
+    }
+
 }

+ 5 - 0
hx-flow/src/main/java/com/fjhx/flow/service/flow/FlowDefinitionService.java

@@ -25,4 +25,9 @@ public interface FlowDefinitionService extends BaseService<FlowDefinition> {
      */
     void addVersion(FlowDefinitionDto dto);
 
+    /**
+     * 修改流程版本
+     */
+    void updateVersion(Long flowDefinitionId);
+
 }

+ 19 - 0
hx-flow/src/main/java/com/fjhx/flow/service/flow/impl/FlowDefinitionServiceImpl.java

@@ -1,5 +1,6 @@
 package com.fjhx.flow.service.flow.impl;
 
+import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fjhx.flow.entity.flow.dto.FlowDefinitionDto;
@@ -119,4 +120,22 @@ public class FlowDefinitionServiceImpl extends ServiceImpl<FlowDefinitionMapper,
         flowDefinitionNodeService.saveBatch(flowDefinitionNodeList);
     }
 
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public void updateVersion(Long flowDefinitionId) {
+        if (ObjectUtil.isEmpty(flowDefinitionId)) {
+            throw new ServiceException("租户流程id不能为空");
+        }
+
+        FlowDefinition flowDefinition = getById(flowDefinitionId);
+        flowDefinition.setCurrentVersion(StatusConstant.YES);
+
+        update(q -> q
+                .eq(FlowDefinition::getFlowInfoId, flowDefinition.getFlowInfoId())
+                .eq(FlowDefinition::getTenantId, flowDefinition.getTenantId())
+                .set(FlowDefinition::getCurrentVersion, StatusConstant.NO)
+        );
+        updateById(flowDefinition);
+    }
+
 }

+ 4 - 4
hx-flow/src/main/java/com/fjhx/flow/service/flow/impl/FlowProcessServiceImpl.java

@@ -120,12 +120,12 @@ public class FlowProcessServiceImpl implements FlowProcessService {
             else {
                 return handleUser;
             }
-            // 流程已通过
-            flowExample.setStatus(FlowStatusEnum.HAVE_PASSED.getKey());
-            FlowThreadLocalUtil.setFlowStatusEnum(FlowStatusEnum.IN_PROGRESS);
-        } else {
             // 流程进行中
             flowExample.setStatus(FlowStatusEnum.IN_PROGRESS.getKey());
+            FlowThreadLocalUtil.setFlowStatusEnum(FlowStatusEnum.IN_PROGRESS);
+        } else {
+            // 流程已通过
+            flowExample.setStatus(FlowStatusEnum.HAVE_PASSED.getKey());
             FlowThreadLocalUtil.setFlowStatusEnum(FlowStatusEnum.HAVE_PASSED);
         }