|
@@ -11,8 +11,10 @@ import com.fjhx.entity.example.ExampleInfo;
|
|
import com.fjhx.entity.process.ProcessInfo;
|
|
import com.fjhx.entity.process.ProcessInfo;
|
|
import com.fjhx.entity.process.ProcessNodeButton;
|
|
import com.fjhx.entity.process.ProcessNodeButton;
|
|
import com.fjhx.entity.process.ProcessTenant;
|
|
import com.fjhx.entity.process.ProcessTenant;
|
|
|
|
+import com.fjhx.enums.ButtonNameEnum;
|
|
import com.fjhx.enums.ProcessNodeTypeEnum;
|
|
import com.fjhx.enums.ProcessNodeTypeEnum;
|
|
import com.fjhx.params.ExampleInfoEx;
|
|
import com.fjhx.params.ExampleInfoEx;
|
|
|
|
+import com.fjhx.params.ExampleResult;
|
|
import com.fjhx.params.FlowInfoVo;
|
|
import com.fjhx.params.FlowInfoVo;
|
|
import com.fjhx.params.GetNodeButtonVo;
|
|
import com.fjhx.params.GetNodeButtonVo;
|
|
import com.fjhx.service.example.ExampleDetailsService;
|
|
import com.fjhx.service.example.ExampleDetailsService;
|
|
@@ -54,7 +56,7 @@ public class FlowClient implements IFlowClient {
|
|
ExampleInfo exampleInfo = exampleInfoService.getOne(
|
|
ExampleInfo exampleInfo = exampleInfoService.getOne(
|
|
Wrappers.<ExampleInfo>lambdaQuery()
|
|
Wrappers.<ExampleInfo>lambdaQuery()
|
|
.eq(ExampleInfo::getFlowLinkNo, flowLinkNo)
|
|
.eq(ExampleInfo::getFlowLinkNo, flowLinkNo)
|
|
- .eq(ExampleInfo::getComplete, StatusConstant.No));
|
|
|
|
|
|
+ .eq(ExampleInfo::getComplete, StatusConstant.NO));
|
|
|
|
|
|
Assert.empty(exampleInfo, FlowExplainConstant.EXPLAIN_NOT_EXIST);
|
|
Assert.empty(exampleInfo, FlowExplainConstant.EXPLAIN_NOT_EXIST);
|
|
|
|
|
|
@@ -128,11 +130,117 @@ public class FlowClient implements IFlowClient {
|
|
ExampleInfo exampleInfo = exampleInfoService.getOne(
|
|
ExampleInfo exampleInfo = exampleInfoService.getOne(
|
|
Wrappers.<ExampleInfo>lambdaQuery()
|
|
Wrappers.<ExampleInfo>lambdaQuery()
|
|
.eq(ExampleInfo::getFlowLinkNo, flowLinkNo)
|
|
.eq(ExampleInfo::getFlowLinkNo, flowLinkNo)
|
|
- .eq(ExampleInfo::getComplete, StatusConstant.No));
|
|
|
|
|
|
+ .eq(ExampleInfo::getComplete, StatusConstant.NO));
|
|
|
|
|
|
Assert.notEmpty(exampleInfo, FlowExplainConstant.EXAMPLE_INFO_NULL);
|
|
Assert.notEmpty(exampleInfo, FlowExplainConstant.EXAMPLE_INFO_NULL);
|
|
|
|
|
|
return R.data(exampleInfo);
|
|
return R.data(exampleInfo);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public R<ExampleResult> create(Long flowLinkNo, String code, String nodeCode, String remarks, String cacheData) {
|
|
|
|
+
|
|
|
|
+ ExampleResult exampleResult = new ExampleResult();
|
|
|
|
+
|
|
|
|
+ int count = exampleInfoService.count(
|
|
|
|
+ Wrappers.<ExampleInfo>lambdaQuery()
|
|
|
|
+ .eq(ExampleInfo::getFlowLinkNo, flowLinkNo)
|
|
|
|
+ .eq(ExampleInfo::getComplete, StatusConstant.NO));
|
|
|
|
+
|
|
|
|
+ Assert.eqZero(count, FlowExplainConstant.EXPLAIN_NOT_EXIST);
|
|
|
|
+
|
|
|
|
+ // 查找通用流程
|
|
|
|
+ ProcessInfo processInfo = processInfoService.getOne(ProcessInfo::getCode, code);
|
|
|
|
+ Assert.notEmpty(processInfo, String.format(FlowExplainConstant.PROCESS_NOT_EXIST, code));
|
|
|
|
+
|
|
|
|
+ // 获取租户流程
|
|
|
|
+ ProcessTenant processTenant = processTenantService.getOne(Wrappers.<ProcessTenant>lambdaQuery()
|
|
|
|
+ .eq(ProcessTenant::getProcessInfoId, processInfo.getId())
|
|
|
|
+ .eq(ProcessTenant::getBindingTenantId, AuthUtil.getTenantId())
|
|
|
|
+ .eq(ProcessTenant::getCurrentVersion, StatusConstant.YES));
|
|
|
|
+
|
|
|
|
+ // 创建流程实例
|
|
|
|
+ ExampleInfo exampleInfo = new ExampleInfo();
|
|
|
|
+ exampleInfo.setProcessInfoId(processInfo.getId());
|
|
|
|
+ exampleInfo.setFlowLinkNo(flowLinkNo);
|
|
|
|
+ exampleInfo.setCacheData(cacheData);
|
|
|
|
+
|
|
|
|
+ // 走默认流程,直接完成
|
|
|
|
+ if (processTenant == null) {
|
|
|
|
+ exampleInfo.setComplete(StatusConstant.YES);
|
|
|
|
+ exampleInfo.setFlowType(FlowConstant.FLOW_TYPE_DEFAULT);
|
|
|
|
+ exampleInfo.setProcessNodeCode(FlowConstant.END_CODE);
|
|
|
|
+ exampleInfoService.save(exampleInfo);
|
|
|
|
+
|
|
|
|
+ ExampleDetails startExampleDetails = new ExampleDetails();
|
|
|
|
+ startExampleDetails.setExampleInfoId(exampleInfo.getId());
|
|
|
|
+ startExampleDetails.setProcessInfoId(processInfo.getId());
|
|
|
|
+ startExampleDetails.setNameType(ButtonNameEnum.START.getType());
|
|
|
|
+ startExampleDetails.setHandleUserId(AuthUtil.getUserId());
|
|
|
|
+ startExampleDetails.setRemarks(remarks);
|
|
|
|
+
|
|
|
|
+ ExampleDetails endExampleDetails = new ExampleDetails();
|
|
|
|
+ endExampleDetails.setExampleInfoId(exampleInfo.getId());
|
|
|
|
+ endExampleDetails.setProcessInfoId(processInfo.getId());
|
|
|
|
+ endExampleDetails.setNameType(ButtonNameEnum.END.getType());
|
|
|
|
+
|
|
|
|
+ exampleDetailsService.saveBatch(Arrays.asList(startExampleDetails, endExampleDetails));
|
|
|
|
+
|
|
|
|
+ // 封装返回值
|
|
|
|
+ exampleResult.setExampleInfo(exampleInfo);
|
|
|
|
+ exampleResult.setExampleDetailsIdList(
|
|
|
|
+ Arrays.asList(startExampleDetails.getId(), endExampleDetails.getId()));
|
|
|
|
+ exampleResult.setHandleType(ButtonNameEnum.END.getType());
|
|
|
|
+ exampleResult.setCacheDataStr(cacheData);
|
|
|
|
+ return R.data(exampleResult);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Long processTenantId = processTenant.getId();
|
|
|
|
+ exampleInfo.setFlowType(FlowConstant.FLOW_TYPE_TENANT);
|
|
|
|
+
|
|
|
|
+ exampleInfo.setProcessTenantId(processTenantId);
|
|
|
|
+
|
|
|
|
+ ExampleDetails startExampleDetails = new ExampleDetails();
|
|
|
|
+ startExampleDetails.setExampleInfoId(exampleInfo.getId());
|
|
|
|
+ startExampleDetails.setProcessInfoId(processInfo.getId());
|
|
|
|
+ startExampleDetails.setProcessTenantId(processTenant.getId());
|
|
|
|
+ startExampleDetails.setNameType(ButtonNameEnum.START.getType());
|
|
|
|
+ startExampleDetails.setHandleUserId(AuthUtil.getUserId());
|
|
|
|
+ startExampleDetails.setRemarks(remarks);
|
|
|
|
+
|
|
|
|
+ // 查询节点
|
|
|
|
+ ProcessNodeButton processNodeButton = processNodeButtonService.getOne(
|
|
|
|
+ Wrappers.<ProcessNodeButton>lambdaQuery()
|
|
|
|
+ .eq(ProcessNodeButton::getProcessTenantId, processTenantId)
|
|
|
|
+ .eq(ProcessNodeButton::getProcessNodeCode, ObjectUtil.isNotEmpty(nodeCode) ? nodeCode : FlowConstant.START_CODE));
|
|
|
|
+
|
|
|
|
+ // 如果所在节点是开始节点,流转到下一节点,否则所在节点是指定code的节点
|
|
|
|
+ Long jumpNodeId;
|
|
|
|
+ if (FlowConstant.START_CODE.equals(processNodeButton.getProcessNodeCode())) {
|
|
|
|
+ jumpNodeId = processNodeButton.getJumpNodeId();
|
|
|
|
+ } else {
|
|
|
|
+ jumpNodeId = processNodeButton.getProcessNodeId();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 如果流程跳转到结束
|
|
|
|
+ if (jumpNodeId.equals(FlowConstant.OVER_PROCESS_FLAG)) {
|
|
|
|
+
|
|
|
|
+ exampleInfo.setComplete(StatusConstant.YES);
|
|
|
|
+
|
|
|
|
+ ExampleDetails endExampleDetails = new ExampleDetails();
|
|
|
|
+ endExampleDetails.setExampleInfoId(exampleInfo.getId());
|
|
|
|
+ endExampleDetails.setProcessInfoId(processInfo.getId());
|
|
|
|
+ endExampleDetails.setProcessTenantId(processTenant.getId());
|
|
|
|
+ endExampleDetails.setNameType(ButtonNameEnum.END.getType());
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ exampleInfo.setComplete(StatusConstant.NO);
|
|
|
|
+ exampleInfo.setProcessNodeId(jumpNodeId);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|