|
@@ -19,6 +19,8 @@ import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
* 租户流程表 服务实现类
|
|
@@ -36,36 +38,59 @@ public class ProcessTenantServiceImpl extends ServiceImpl<ProcessTenantMapper, P
|
|
|
@Override
|
|
|
public void add(ProcessTenant processTenant) {
|
|
|
|
|
|
- // 流程id
|
|
|
- Long processInfoId = processTenant.getProcessInfoId();
|
|
|
- Assert.notEmpty(processInfoId, FlowExplainConstant.PROCESS_INFO_ID_EMPTY);
|
|
|
-
|
|
|
- // 流程名称
|
|
|
- String name = processTenant.getName();
|
|
|
- Assert.notEmpty(name, FlowExplainConstant.PROCESS_NAME);
|
|
|
-
|
|
|
- // 租户id
|
|
|
- String bindingTenantId = processTenant.getBindingTenantId();
|
|
|
- if (ObjectUtil.isEmpty(bindingTenantId)) {
|
|
|
- processTenant.setBindingTenantId(AuthUtil.getTenantId());
|
|
|
- }
|
|
|
+ dataHandle(processTenant);
|
|
|
|
|
|
+ // 判断流程是否存在
|
|
|
int count = count(Wrappers.<ProcessTenant>lambdaQuery()
|
|
|
.eq(ProcessTenant::getBindingTenantId, processTenant.getBindingTenantId())
|
|
|
- .eq(ProcessTenant::getProcessInfoId, processInfoId));
|
|
|
-
|
|
|
+ .eq(ProcessTenant::getProcessInfoId, processTenant.getProcessInfoId()));
|
|
|
Assert.eqZero(count, FlowExplainConstant.PROCESS_EXIST);
|
|
|
|
|
|
+ // 赋值默认版本号
|
|
|
processTenant.setVersionNumber(FlowConstant.DEFAULT_VERSION_NUMBER);
|
|
|
-
|
|
|
processTenant.setCurrent(StatusConstant.YES);
|
|
|
|
|
|
+ // 保存数据
|
|
|
save(processTenant);
|
|
|
|
|
|
+ // 生成默认节点
|
|
|
createProcess(processTenant.getId());
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void addVersion(ProcessTenant processTenant) {
|
|
|
+
|
|
|
+ dataHandle(processTenant);
|
|
|
+
|
|
|
+ // 赋值版本号
|
|
|
+ processTenant.setVersionNumber(getNewestVersion(processTenant));
|
|
|
+ processTenant.setCurrent(StatusConstant.No);
|
|
|
+
|
|
|
+ // 保存数据
|
|
|
+ save(processTenant);
|
|
|
+
|
|
|
+ // 生成默认节点
|
|
|
+ createProcess(processTenant.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取最新版本号
|
|
|
+ *
|
|
|
+ * @return 最新版本号
|
|
|
+ */
|
|
|
+ private Integer getNewestVersion(ProcessTenant processTenant) {
|
|
|
+ // 判断流程是否已存在
|
|
|
+ ProcessTenant one = getOne(Wrappers.<ProcessTenant>lambdaQuery()
|
|
|
+ .eq(ProcessTenant::getProcessInfoId, processTenant.getProcessInfoId())
|
|
|
+ .eq(ProcessTenant::getBindingTenantId, processTenant.getBindingTenantId())
|
|
|
+ .orderByDesc(ProcessTenant::getVersionNumber)
|
|
|
+ .last("limit 1")
|
|
|
+ );
|
|
|
+
|
|
|
+ return one.getVersionNumber() + 1;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 生成默认流程
|
|
|
*/
|
|
@@ -91,6 +116,29 @@ public class ProcessTenantServiceImpl extends ServiceImpl<ProcessTenantMapper, P
|
|
|
endProcessNode.setCode(FlowConstant.END_CODE);
|
|
|
processNodeService.save(endProcessNode);
|
|
|
|
|
|
+ processNodeService.editNodeList(Arrays.asList(startProcessNode, endProcessNode));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 数据处理
|
|
|
+ */
|
|
|
+ private void dataHandle(ProcessTenant processTenant) {
|
|
|
+
|
|
|
+ // 流程id
|
|
|
+ Long processInfoId = processTenant.getProcessInfoId();
|
|
|
+ Assert.notEmpty(processInfoId, FlowExplainConstant.PROCESS_INFO_ID_EMPTY);
|
|
|
+
|
|
|
+ // 流程名称
|
|
|
+ String name = processTenant.getName();
|
|
|
+ Assert.notEmpty(name, FlowExplainConstant.PROCESS_NAME);
|
|
|
+
|
|
|
+ // 租户id
|
|
|
+ String bindingTenantId = processTenant.getBindingTenantId();
|
|
|
+ if (ObjectUtil.isEmpty(bindingTenantId)) {
|
|
|
+ processTenant.setBindingTenantId(AuthUtil.getTenantId());
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|