|
@@ -1,8 +1,8 @@
|
|
|
package com.fjhx.feign;
|
|
|
|
|
|
-import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.fjhx.base.BaseEntity;
|
|
|
import com.fjhx.constants.FlowConstant;
|
|
|
import com.fjhx.constants.FlowExplainConstant;
|
|
|
import com.fjhx.constants.StatusConstant;
|
|
@@ -13,8 +13,8 @@ import com.fjhx.entity.process.ProcessNodeButton;
|
|
|
import com.fjhx.entity.process.ProcessTenant;
|
|
|
import com.fjhx.enums.ButtonNameEnum;
|
|
|
import com.fjhx.enums.HandleResultEnum;
|
|
|
-import com.fjhx.enums.ProcessNodeTypeEnum;
|
|
|
-import com.fjhx.params.*;
|
|
|
+import com.fjhx.params.ExampleResult;
|
|
|
+import com.fjhx.params.JumpVo;
|
|
|
import com.fjhx.service.example.ExampleDetailsService;
|
|
|
import com.fjhx.service.example.ExampleInfoService;
|
|
|
import com.fjhx.service.process.ProcessInfoService;
|
|
@@ -52,94 +52,6 @@ public class FlowClient implements IFlowClient {
|
|
|
@Autowired
|
|
|
private ExampleDetailsService exampleDetailsService;
|
|
|
|
|
|
- @PostMapping(GET_FLOW_INFO)
|
|
|
- @Override
|
|
|
- public R<FlowInfoVo> getProcessTenant(Long flowLinkNo, String code) {
|
|
|
-
|
|
|
- ExampleInfo exampleInfo = exampleInfoService.getOne(
|
|
|
- Wrappers.<ExampleInfo>lambdaQuery()
|
|
|
- .eq(ExampleInfo::getFlowLinkNo, flowLinkNo)
|
|
|
- .eq(ExampleInfo::getComplete, StatusConstant.NO));
|
|
|
-
|
|
|
- Assert.empty(exampleInfo, FlowExplainConstant.EXPLAIN_NOT_EXIST);
|
|
|
-
|
|
|
- // 查找通用流程
|
|
|
- ProcessInfo processInfo = processInfoService.getOne(ProcessInfo::getCode, code);
|
|
|
- Assert.notEmpty(processInfo, String.format(FlowExplainConstant.PROCESS_NOT_EXIST, code));
|
|
|
-
|
|
|
- FlowInfoVo flowInfoVo = BeanUtil.toBean(processInfo, FlowInfoVo.class);
|
|
|
-
|
|
|
- // 获取租户流程
|
|
|
- ProcessTenant processTenant = processTenantService.getOne(Wrappers.<ProcessTenant>lambdaQuery()
|
|
|
- .eq(ProcessTenant::getProcessInfoId, processInfo.getId())
|
|
|
- .eq(ProcessTenant::getBindingTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(ProcessTenant::getCurrentVersion, StatusConstant.YES));
|
|
|
-
|
|
|
- flowInfoVo.setProcessTenant(processTenant);
|
|
|
-
|
|
|
- return R.data(flowInfoVo);
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping(GET_NODE_BUTTON)
|
|
|
- @Override
|
|
|
- public R<ProcessNodeButton> getNodeButton(GetNodeButtonVo getNodeButtonVo) {
|
|
|
- Long processTenantId = getNodeButtonVo.getProcessTenantId();
|
|
|
- String nodeCode = getNodeButtonVo.getNodeCode();
|
|
|
- Long buttonId = getNodeButtonVo.getButtonId();
|
|
|
-
|
|
|
-
|
|
|
- ProcessNodeButton processNodeButton = processNodeButtonService.getOne(
|
|
|
- Wrappers.<ProcessNodeButton>lambdaQuery()
|
|
|
- .eq(ProcessNodeButton::getProcessTenantId, processTenantId)
|
|
|
- .eq(ObjectUtil.isNotEmpty(nodeCode), ProcessNodeButton::getProcessNodeCode, nodeCode)
|
|
|
- .eq(ObjectUtil.isEmpty(nodeCode), ProcessNodeButton::getId, buttonId));
|
|
|
-
|
|
|
- Assert.notEmpty(processNodeButton, FlowExplainConstant.SPECIFY_BRANCH_EMPTY);
|
|
|
- return R.data(processNodeButton);
|
|
|
- }
|
|
|
-
|
|
|
- @PostMapping(EXAMPLE_INFO_SAVE)
|
|
|
- @Override
|
|
|
- public R<ExampleInfo> exampleInfoSave(ExampleInfoEx exampleInfo) {
|
|
|
- exampleInfoService.saveOrUpdate(exampleInfo);
|
|
|
-
|
|
|
- ExampleDetails exampleDetails = exampleInfo.getExampleDetails();
|
|
|
- exampleDetails.setExampleInfoId(exampleInfo.getId());
|
|
|
- exampleDetails.setProcessInfoId(exampleInfo.getProcessInfoId());
|
|
|
- exampleDetails.setProcessTenantId(exampleInfo.getProcessTenantId());
|
|
|
- exampleDetails.setHandleUserId(AuthUtil.getUserId());
|
|
|
-
|
|
|
- if (exampleInfo.getComplete().equals(StatusConstant.YES)) {
|
|
|
-
|
|
|
- ExampleDetails endExampleDetails = new ExampleDetails();
|
|
|
- endExampleDetails.setExampleInfoId(exampleInfo.getId());
|
|
|
- endExampleDetails.setProcessInfoId(exampleInfo.getProcessInfoId());
|
|
|
- endExampleDetails.setProcessTenantId(exampleInfo.getProcessTenantId());
|
|
|
- endExampleDetails.setHandleUserId(AuthUtil.getUserId());
|
|
|
- endExampleDetails.setRemarks(FlowConstant.END_REMARKS);
|
|
|
-
|
|
|
- endExampleDetails.setNameType(ProcessNodeTypeEnum.END.getType());
|
|
|
- exampleDetailsService.saveBatch(Arrays.asList(exampleDetails, endExampleDetails));
|
|
|
- } else {
|
|
|
- exampleDetailsService.save(exampleDetails);
|
|
|
- }
|
|
|
-
|
|
|
- return R.data(BeanUtil.toBean(exampleInfo, ExampleInfo.class));
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public R<ExampleInfo> getExampleInfo(Long flowLinkNo) {
|
|
|
-
|
|
|
- ExampleInfo exampleInfo = exampleInfoService.getOne(
|
|
|
- Wrappers.<ExampleInfo>lambdaQuery()
|
|
|
- .eq(ExampleInfo::getFlowLinkNo, flowLinkNo)
|
|
|
- .eq(ExampleInfo::getComplete, StatusConstant.NO));
|
|
|
-
|
|
|
- Assert.notEmpty(exampleInfo, FlowExplainConstant.EXAMPLE_INFO_NULL);
|
|
|
-
|
|
|
- return R.data(exampleInfo);
|
|
|
- }
|
|
|
-
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@GetMapping(CREATE)
|
|
|
@Override
|
|
@@ -178,8 +90,8 @@ public class FlowClient implements IFlowClient {
|
|
|
|
|
|
// 走默认流程,直接完成
|
|
|
if (processTenant == null) {
|
|
|
- exampleInfo.setFlowType(FlowConstant.FLOW_TYPE_DEFAULT);
|
|
|
exampleInfoEnd(exampleInfo);
|
|
|
+ exampleInfo.setFlowType(FlowConstant.FLOW_TYPE_DEFAULT);
|
|
|
exampleInfo.setHandleResult(HandleResultEnum.ADOPT.getType());
|
|
|
exampleInfoService.save(exampleInfo);
|
|
|
|
|
@@ -213,7 +125,10 @@ public class FlowClient implements IFlowClient {
|
|
|
exampleInfoService.save(exampleInfo);
|
|
|
|
|
|
ExampleDetails endExampleDetails = createExampleDetails(exampleInfo, ButtonNameEnum.END.getType());
|
|
|
- exampleDetailsService.saveBatch(Arrays.asList(startExampleDetails, endExampleDetails));
|
|
|
+
|
|
|
+ startExampleDetails.setExampleInfoId(exampleInfo.getId());
|
|
|
+ endExampleDetails.setExampleInfoId(exampleInfo.getId());
|
|
|
+ saveExampleDetails(startExampleDetails, endExampleDetails);
|
|
|
|
|
|
// 返回值
|
|
|
exampleResult.setOldExampleInfo(exampleInfo);
|
|
@@ -233,6 +148,10 @@ public class FlowClient implements IFlowClient {
|
|
|
|
|
|
Assert.notEmpty(processNodeButton, FlowExplainConstant.SPECIFY_BRANCH_EMPTY);
|
|
|
|
|
|
+ // 赋值所在节点
|
|
|
+ startExampleDetails.setProcessNodeId(processNodeButton.getProcessNodeId());
|
|
|
+ startExampleDetails.setProcessNodeButtonId(processNodeButton.getId());
|
|
|
+
|
|
|
// 如果所在节点是开始节点,流转到下一节点,否则所在节点是指定code的节点
|
|
|
Long jumpNodeId;
|
|
|
String jumpNodeCode;
|
|
@@ -253,7 +172,12 @@ public class FlowClient implements IFlowClient {
|
|
|
|
|
|
ExampleDetails endExampleDetails = createExampleDetails(exampleInfo, ButtonNameEnum.END.getType());
|
|
|
|
|
|
- exampleDetailsService.saveBatch(Arrays.asList(startExampleDetails, endExampleDetails));
|
|
|
+ startExampleDetails.setExampleInfoId(exampleInfo.getId());
|
|
|
+
|
|
|
+ endExampleDetails.setExampleInfoId(exampleInfo.getId());
|
|
|
+ endExampleDetails.setProcessNodeId(jumpNodeId);
|
|
|
+
|
|
|
+ saveExampleDetails(startExampleDetails, endExampleDetails);
|
|
|
|
|
|
// 返回值
|
|
|
exampleResult.setExampleDetailsIdList(
|
|
@@ -267,6 +191,7 @@ public class FlowClient implements IFlowClient {
|
|
|
exampleInfo.setHandleResult(HandleResultEnum.NOT_START.getType());
|
|
|
exampleInfoService.save(exampleInfo);
|
|
|
|
|
|
+ startExampleDetails.setExampleInfoId(exampleInfo.getId());
|
|
|
exampleDetailsService.save(startExampleDetails);
|
|
|
|
|
|
// 返回值
|
|
@@ -290,7 +215,7 @@ public class FlowClient implements IFlowClient {
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- @GetMapping(JUMP)
|
|
|
+ @PostMapping(JUMP)
|
|
|
@Override
|
|
|
public R<ExampleResult> jump(JumpVo jumpVo) {
|
|
|
|
|
@@ -329,11 +254,14 @@ public class FlowClient implements IFlowClient {
|
|
|
// 结束明细
|
|
|
ExampleDetails endExampleDetails = createExampleDetails(exampleInfo, ButtonNameEnum.END.getType());
|
|
|
|
|
|
+ exampleDetails.setExampleInfoId(exampleInfo.getId());
|
|
|
+ endExampleDetails.setExampleInfoId(exampleInfo.getId());
|
|
|
+ saveExampleDetails(exampleDetails, endExampleDetails);
|
|
|
+
|
|
|
exampleResult.setOldExampleInfo(oleExampleInfo);
|
|
|
exampleResult.setCacheDataStr(exampleInfo.getCacheData());
|
|
|
exampleResult.setExampleDetailsIdList(Arrays.asList(exampleDetails.getId(), endExampleDetails.getId()));
|
|
|
exampleResult.setHandleType(ButtonNameEnum.END.getType());
|
|
|
-
|
|
|
return R.data(exampleResult);
|
|
|
}
|
|
|
|
|
@@ -361,14 +289,29 @@ public class FlowClient implements IFlowClient {
|
|
|
if (ButtonNameEnum.END.getType().equals(jumpVo.getNameType())) {
|
|
|
exampleInfoEnd(exampleInfo);
|
|
|
exampleInfo.setHandleResult(HandleResultEnum.ADOPT.getType());
|
|
|
+
|
|
|
ExampleDetails endExampleDetails = createExampleDetails(exampleInfo, ButtonNameEnum.END.getType());
|
|
|
+ endExampleDetails.setProcessNodeId(jumpVo.getJumpNodeId());
|
|
|
+
|
|
|
+ exampleDetails.setExampleInfoId(exampleInfo.getId());
|
|
|
+ endExampleDetails.setExampleInfoId(exampleInfo.getId());
|
|
|
+ saveExampleDetails(exampleDetails, endExampleDetails);
|
|
|
+ // 流程实例明细id
|
|
|
exampleResult.setExampleDetailsIdList(Arrays.asList(exampleDetails.getId(), endExampleDetails.getId()));
|
|
|
}
|
|
|
// 驳回结束
|
|
|
else if (ButtonNameEnum.REJECT.getType().equals(jumpVo.getNameType())) {
|
|
|
exampleInfoEnd(exampleInfo);
|
|
|
exampleInfo.setHandleResult(HandleResultEnum.FAIL.getType());
|
|
|
+
|
|
|
ExampleDetails endExampleDetails = createExampleDetails(exampleInfo, ButtonNameEnum.END.getType());
|
|
|
+ endExampleDetails.setProcessNodeId(jumpVo.getJumpNodeId());
|
|
|
+
|
|
|
+ exampleDetails.setExampleInfoId(exampleInfo.getId());
|
|
|
+ endExampleDetails.setExampleInfoId(exampleInfo.getId());
|
|
|
+ saveExampleDetails(exampleDetails, exampleDetails);
|
|
|
+
|
|
|
+ // 流程实例明细id
|
|
|
exampleResult.setExampleDetailsIdList(Arrays.asList(exampleDetails.getId(), endExampleDetails.getId()));
|
|
|
}
|
|
|
// 流程流转
|
|
@@ -376,6 +319,11 @@ public class FlowClient implements IFlowClient {
|
|
|
exampleInfo.setProcessNodeId(jumpVo.getJumpNodeId());
|
|
|
exampleInfo.setProcessNodeCode(jumpVo.getJumpNodeCode());
|
|
|
exampleInfo.setHandleResult(HandleResultEnum.START.getType());
|
|
|
+
|
|
|
+ exampleDetails.setExampleInfoId(exampleInfo.getId());
|
|
|
+ exampleDetailsService.save(exampleDetails);
|
|
|
+
|
|
|
+ // 流程实例明细id
|
|
|
exampleResult.setExampleDetailsIdList(Collections.singletonList(exampleDetails.getId()));
|
|
|
}
|
|
|
|
|
@@ -387,30 +335,39 @@ public class FlowClient implements IFlowClient {
|
|
|
return R.data(exampleResult);
|
|
|
}
|
|
|
|
|
|
- @GetMapping(ROLL_BACK)
|
|
|
+ @PostMapping(ROLL_BACK)
|
|
|
@Override
|
|
|
public void rollBack(ExampleResult result) {
|
|
|
ExampleInfo oldExampleInfo = result.getOldExampleInfo();
|
|
|
|
|
|
if (result.isDeleteExample()) {
|
|
|
- exampleInfoService.removeById(oldExampleInfo.getId());
|
|
|
+ exampleInfoService.update(Wrappers.<ExampleInfo>lambdaUpdate()
|
|
|
+ .eq(BaseEntity::getId, oldExampleInfo.getId())
|
|
|
+ .set(ExampleInfo::getDelFlag, 1)
|
|
|
+ .set(ExampleInfo::getRemarks, "业务异常,本次流程实例已删除")
|
|
|
+ );
|
|
|
} else {
|
|
|
exampleInfoService.updateById(oldExampleInfo);
|
|
|
}
|
|
|
|
|
|
- List<Long> exampleDetailsIdList = result.getExampleDetailsIdList();
|
|
|
- exampleDetailsService.removeByIds(exampleDetailsIdList);
|
|
|
+ exampleDetailsService.update(Wrappers.<ExampleDetails>lambdaUpdate()
|
|
|
+ .in(BaseEntity::getId, result.getExampleDetailsIdList())
|
|
|
+ .set(ExampleDetails::getDelFlag, 1)
|
|
|
+ .set(ExampleDetails::getRemarks, "业务异常,本次流程明细已删除")
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 获取流程结束明细
|
|
|
+ * 创建流程实例明细
|
|
|
*/
|
|
|
private ExampleDetails createExampleDetails(ExampleInfo exampleInfo, Integer nameType) {
|
|
|
return createExampleDetails(
|
|
|
exampleInfo.getId(), exampleInfo.getProcessInfoId(), exampleInfo.getProcessTenantId(), nameType);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 创建流程实例明细
|
|
|
+ */
|
|
|
private ExampleDetails createExampleDetails(Long exampleInfoId, Long processInfoId, Long processTenantId, Integer nameType) {
|
|
|
ExampleDetails endExampleDetails = new ExampleDetails();
|
|
|
endExampleDetails.setExampleInfoId(exampleInfoId);
|
|
@@ -429,4 +386,11 @@ public class FlowClient implements IFlowClient {
|
|
|
exampleInfo.setProcessNodeCode(FlowConstant.END_CODE);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 保存流程明细
|
|
|
+ */
|
|
|
+ private void saveExampleDetails(ExampleDetails... exampleDetails) {
|
|
|
+ exampleDetailsService.saveBatch(Arrays.asList(exampleDetails));
|
|
|
+ }
|
|
|
+
|
|
|
}
|