|
@@ -1,21 +1,21 @@
|
|
|
package com.fjhx.service.process.impl;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
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.StatusConstant;
|
|
|
+import com.fjhx.constants.FlowExplainConstant;
|
|
|
+import com.fjhx.constants.ProcessConstant;
|
|
|
import com.fjhx.entity.process.ProcessInfo;
|
|
|
+import com.fjhx.entity.process.ProcessNode;
|
|
|
+import com.fjhx.enums.ProcessNodeHandleObjectTypeEnum;
|
|
|
+import com.fjhx.enums.ProcessNodeTypeEnum;
|
|
|
import com.fjhx.mapper.process.ProcessInfoMapper;
|
|
|
-import com.fjhx.params.process.ProcessInfoVo;
|
|
|
import com.fjhx.service.process.ProcessInfoService;
|
|
|
+import com.fjhx.service.process.ProcessNodeService;
|
|
|
import com.fjhx.utils.Assert;
|
|
|
-import com.fjhx.utils.WrapperUtil;
|
|
|
+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.Map;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -28,50 +28,55 @@ import java.util.Map;
|
|
|
@Service
|
|
|
public class ProcessInfoServiceImpl extends ServiceImpl<ProcessInfoMapper, ProcessInfo> implements ProcessInfoService {
|
|
|
|
|
|
- @Override
|
|
|
- public Page<ProcessInfo> getPage(Map<String, String> condition) {
|
|
|
-
|
|
|
- QueryWrapper<ProcessInfo> wrapper = Wrappers.query();
|
|
|
-
|
|
|
- WrapperUtil.init(condition, wrapper)
|
|
|
- .createTimeDesc();
|
|
|
+ @Autowired
|
|
|
+ private ProcessNodeService processNodeService;
|
|
|
|
|
|
- Page<ProcessInfo> page = page(condition, wrapper);
|
|
|
- return page;
|
|
|
- }
|
|
|
-
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public void add(ProcessInfoVo processInfoVo) {
|
|
|
- // 编码
|
|
|
- String code = processInfoVo.getCode();
|
|
|
- Assert.notEmpty(code, "流程编码不能为空");
|
|
|
-
|
|
|
- // 绑定租户id
|
|
|
- String bindingTenantId = processInfoVo.getBindingTenantId();
|
|
|
-
|
|
|
- // 最新版本号
|
|
|
- Integer newestVersion = getNewestVersion(code, bindingTenantId);
|
|
|
+ public void addSystem(ProcessInfo processInfo) {
|
|
|
+ // 编码非空
|
|
|
+ String code = processInfo.getCode();
|
|
|
+ Assert.notEmpty(code, FlowExplainConstant.CODE_EMPTY);
|
|
|
|
|
|
- // 如果最新版本号为1,赋值为当前版本
|
|
|
- if (newestVersion == 1) {
|
|
|
- processInfoVo.setCurrentVersion(StatusConstant.YES);
|
|
|
- }
|
|
|
+ // 验证编码唯一性
|
|
|
+ Integer count = count(ProcessInfo::getCode, code);
|
|
|
+ Assert.eqZero(count, FlowExplainConstant.PROCESS_EXIST);
|
|
|
|
|
|
- save(processInfoVo);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public void edit(ProcessInfoVo processInfoVo) {
|
|
|
- updateById(processInfoVo);
|
|
|
- }
|
|
|
|
|
|
- @Override
|
|
|
- public void delete(ProcessInfoVo processInfoVo) {
|
|
|
- removeById(processInfoVo.getId());
|
|
|
+ /**
|
|
|
+ * 生成默认流程
|
|
|
+ */
|
|
|
+ private void createProcess(ProcessInfo processInfo) {
|
|
|
+
|
|
|
+ // 保存流程
|
|
|
+ save(processInfo);
|
|
|
+
|
|
|
+ Long processInfoId = processInfo.getId();
|
|
|
+
|
|
|
+ // 生成默认开始节点
|
|
|
+ ProcessNode startProcessNode = new ProcessNode();
|
|
|
+ startProcessNode.setType(ProcessNodeTypeEnum.start.getType());
|
|
|
+ startProcessNode.setProcessInfoId(processInfoId);
|
|
|
+ startProcessNode.setParentId(CommonConstant.TOP_PARENT_ID);
|
|
|
+ startProcessNode.setName(ProcessConstant.START_NAME);
|
|
|
+ startProcessNode.setCode(ProcessConstant.START_CODE);
|
|
|
+ startProcessNode.setHandleObjectType(ProcessNodeHandleObjectTypeEnum.all.getType());
|
|
|
+ processNodeService.save(startProcessNode);
|
|
|
+
|
|
|
+ // 生成默认结束节点
|
|
|
+ Long startProcessNodeId = startProcessNode.getId();
|
|
|
+ ProcessNode endProcessNode = new ProcessNode();
|
|
|
+ endProcessNode.setType(ProcessNodeTypeEnum.end.getType());
|
|
|
+ endProcessNode.setProcessInfoId(processInfoId);
|
|
|
+ endProcessNode.setParentId(startProcessNodeId);
|
|
|
+ endProcessNode.setName(ProcessConstant.END_NAME);
|
|
|
+ endProcessNode.setCode(ProcessConstant.END_CODE);
|
|
|
+ processNodeService.save(endProcessNode);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -86,15 +91,16 @@ public class ProcessInfoServiceImpl extends ServiceImpl<ProcessInfoMapper, Proce
|
|
|
ProcessInfo processInfo = getOne(Wrappers.<ProcessInfo>lambdaQuery()
|
|
|
.eq(ProcessInfo::getCode, code)
|
|
|
.eq(ObjectUtil.isNotEmpty(bindingTenantId), ProcessInfo::getBindingTenantId, bindingTenantId)
|
|
|
- .orderByDesc(ProcessInfo::getParallelVersion)
|
|
|
+ .orderByDesc(ProcessInfo::getVersionNumber)
|
|
|
.last("limit 1")
|
|
|
);
|
|
|
|
|
|
if (processInfo == null) {
|
|
|
- return 1;
|
|
|
+ return ProcessConstant.DEFAULT_VERSION_NUMBER;
|
|
|
}
|
|
|
|
|
|
- return processInfo.getParallelVersion() + 1;
|
|
|
+ return processInfo.getVersionNumber() + 1;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
}
|