|
@@ -1,11 +1,12 @@
|
|
|
package com.fjhx.service.process.impl;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.constants.FlowConstant;
|
|
|
import com.fjhx.constants.FlowExplainConstant;
|
|
|
-import com.fjhx.constants.StatusConstant;
|
|
|
import com.fjhx.entity.process.ProcessInfo;
|
|
|
import com.fjhx.enums.ProcessInfoParallelRulesEnum;
|
|
|
import com.fjhx.enums.ProcessNodeHandleObjectTypeEnum;
|
|
@@ -19,9 +20,10 @@ import com.fjhx.utils.Assert;
|
|
|
import org.springblade.common.constant.CommonConstant;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -37,57 +39,33 @@ public class ProcessInfoServiceImpl extends ServiceImpl<ProcessInfoMapper, Proce
|
|
|
@Autowired
|
|
|
private ProcessNodeService processNodeService;
|
|
|
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public ProcessObject addSystem(ProcessInfo processInfo) {
|
|
|
+ public List<ProcessInfo> getList(Map<String, String> condition) {
|
|
|
|
|
|
- // 验证字段
|
|
|
- verificationField(processInfo);
|
|
|
+ String serviceName = condition.get("serviceName");
|
|
|
|
|
|
- // 验证编码唯一性
|
|
|
- Integer count = count(ProcessInfo::getCode, processInfo.getCode());
|
|
|
- Assert.eqZero(count, FlowExplainConstant.PROCESS_EXIST);
|
|
|
-
|
|
|
- // 设为当前版本
|
|
|
- processInfo.setCurrent(StatusConstant.YES);
|
|
|
-
|
|
|
- // 系统流程不绑定任何租户
|
|
|
- processInfo.setBindingTenantId(null);
|
|
|
-
|
|
|
- // 版本号为空,设为默认值
|
|
|
- if (ObjectUtil.isEmpty(processInfo.getVersionNumber())) {
|
|
|
- processInfo.setVersionNumber(FlowConstant.DEFAULT_VERSION_NUMBER);
|
|
|
- }
|
|
|
-
|
|
|
- // 并行规则
|
|
|
- if (ObjectUtil.isEmpty(processInfo.getParallelRules())) {
|
|
|
- processInfo.setParallelRules(ProcessInfoParallelRulesEnum.NO.getType());
|
|
|
- }
|
|
|
-
|
|
|
- // 创建流程
|
|
|
- return createProcess(processInfo);
|
|
|
+ LambdaQueryWrapper<ProcessInfo> wrapper = Wrappers.lambdaQuery();
|
|
|
+ wrapper.eq(ObjectUtil.isNotEmpty(serviceName), ProcessInfo::getServiceName, serviceName);
|
|
|
|
|
|
+ return list(wrapper);
|
|
|
}
|
|
|
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public void editSystem(ProcessObject processObject) {
|
|
|
-
|
|
|
- ProcessInfo processInfo = processObject.getProcessInfo();
|
|
|
+ public Page<ProcessInfo> getPage(Map<String, String> condition) {
|
|
|
|
|
|
- Long id = processInfo.getId();
|
|
|
- Assert.notEmpty(id, FlowExplainConstant.PROCESS_INFO_ID_EMPTY);
|
|
|
+ String serviceName = condition.get("serviceName");
|
|
|
+ String moduleName = condition.get("moduleName");
|
|
|
|
|
|
- verificationField(processInfo);
|
|
|
+ LambdaQueryWrapper<ProcessInfo> wrapper = Wrappers.lambdaQuery();
|
|
|
|
|
|
- processNodeService.addOrEditNodeList(id, processObject.getProcessNodeList());
|
|
|
+ wrapper.eq(ObjectUtil.isNotEmpty(serviceName), ProcessInfo::getServiceName, serviceName);
|
|
|
+ wrapper.eq(ObjectUtil.isNotEmpty(moduleName), ProcessInfo::getModuleName, moduleName);
|
|
|
|
|
|
+ return page(createPage(condition), wrapper);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 验证字段
|
|
|
- */
|
|
|
- private void verificationField(ProcessInfo processInfo) {
|
|
|
+ @Override
|
|
|
+ public void add(ProcessInfo processInfo) {
|
|
|
|
|
|
// 编码非空
|
|
|
String code = processInfo.getCode();
|
|
@@ -101,12 +79,19 @@ public class ProcessInfoServiceImpl extends ServiceImpl<ProcessInfoMapper, Proce
|
|
|
String moduleName = processInfo.getModuleName();
|
|
|
Assert.notEmpty(moduleName, FlowExplainConstant.MODULE_NAME_EMPTY);
|
|
|
|
|
|
- // 流程名称非空
|
|
|
- String name = processInfo.getName();
|
|
|
- Assert.notEmpty(name, FlowExplainConstant.PROCESS_NAME);
|
|
|
+ // 验证编码唯一性
|
|
|
+ Integer count = count(ProcessInfo::getCode, processInfo.getCode());
|
|
|
+ Assert.eqZero(count, FlowExplainConstant.PROCESS_EXIST);
|
|
|
|
|
|
- }
|
|
|
+ // 并行规则
|
|
|
+ if (ObjectUtil.isEmpty(processInfo.getParallelRules())) {
|
|
|
+ processInfo.setParallelRules(ProcessInfoParallelRulesEnum.NO.getType());
|
|
|
+ }
|
|
|
|
|
|
+ // 创建流程
|
|
|
+ save(processInfo);
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 生成默认流程
|
|
@@ -153,21 +138,33 @@ public class ProcessInfoServiceImpl extends ServiceImpl<ProcessInfoMapper, Proce
|
|
|
* @param bindingTenantId 租户id
|
|
|
* @return 最新版本号
|
|
|
*/
|
|
|
- private Integer getNewestVersion(String code, String bindingTenantId) {
|
|
|
- // 判断流程是否已存在
|
|
|
- ProcessInfo processInfo = getOne(Wrappers.<ProcessInfo>lambdaQuery()
|
|
|
- .eq(ProcessInfo::getCode, code)
|
|
|
- .eq(ObjectUtil.isNotEmpty(bindingTenantId), ProcessInfo::getBindingTenantId, bindingTenantId)
|
|
|
- .orderByDesc(ProcessInfo::getVersionNumber)
|
|
|
- .last("limit 1")
|
|
|
- );
|
|
|
-
|
|
|
- if (processInfo == null) {
|
|
|
- return FlowConstant.DEFAULT_VERSION_NUMBER;
|
|
|
- }
|
|
|
-
|
|
|
- return processInfo.getVersionNumber() + 1;
|
|
|
- }
|
|
|
-
|
|
|
+// private Integer getNewestVersion(String code, String bindingTenantId) {
|
|
|
+// // 判断流程是否已存在
|
|
|
+// ProcessInfo processInfo = getOne(Wrappers.<ProcessInfo>lambdaQuery()
|
|
|
+// .eq(ProcessInfo::getCode, code)
|
|
|
+// .eq(ObjectUtil.isNotEmpty(bindingTenantId), ProcessInfo::getBindingTenantId, bindingTenantId)
|
|
|
+// .orderByDesc(ProcessInfo::getVersionNumber)
|
|
|
+// .last("limit 1")
|
|
|
+// );
|
|
|
+//
|
|
|
+// if (processInfo == null) {
|
|
|
+// return FlowConstant.DEFAULT_VERSION_NUMBER;
|
|
|
+// }
|
|
|
+//
|
|
|
+// return processInfo.getVersionNumber() + 1;
|
|
|
+// }
|
|
|
+
|
|
|
+// // 设为当前版本
|
|
|
+// processInfo.setCurrent(StatusConstant.YES);
|
|
|
+// // 版本号为空,设为默认值
|
|
|
+// if (ObjectUtil.isEmpty(processInfo.getVersionNumber())) {
|
|
|
+// processInfo.setVersionNumber(FlowConstant.DEFAULT_VERSION_NUMBER);
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+// ProcessInfo processInfo = processObject.getProcessInfo();
|
|
|
+// Long id = processInfo.getId();
|
|
|
+// Assert.notEmpty(id, FlowExplainConstant.PROCESS_INFO_ID_EMPTY);
|
|
|
+// processNodeService.addOrEditNodeList(id, processObject.getProcessNodeList());
|
|
|
|
|
|
}
|