|
@@ -12,24 +12,27 @@ import com.fjhx.entity.process.ProcessInfo;
|
|
|
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.ExampleInfoEx;
|
|
|
-import com.fjhx.params.ExampleResult;
|
|
|
-import com.fjhx.params.FlowInfoVo;
|
|
|
-import com.fjhx.params.GetNodeButtonVo;
|
|
|
+import com.fjhx.params.*;
|
|
|
import com.fjhx.service.example.ExampleDetailsService;
|
|
|
import com.fjhx.service.example.ExampleInfoService;
|
|
|
import com.fjhx.service.process.ProcessInfoService;
|
|
|
import com.fjhx.service.process.ProcessNodeButtonService;
|
|
|
import com.fjhx.service.process.ProcessTenantService;
|
|
|
import com.fjhx.utils.Assert;
|
|
|
+import org.springblade.core.log.exception.ServiceException;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.List;
|
|
|
|
|
|
@RestController
|
|
|
public class FlowClient implements IFlowClient {
|
|
@@ -137,15 +140,17 @@ public class FlowClient implements IFlowClient {
|
|
|
return R.data(exampleInfo);
|
|
|
}
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @GetMapping(CREATE)
|
|
|
@Override
|
|
|
public R<ExampleResult> create(Long flowLinkNo, String code, String nodeCode, String remarks, String cacheData) {
|
|
|
|
|
|
ExampleResult exampleResult = new ExampleResult();
|
|
|
+ exampleResult.setDeleteExample(true);
|
|
|
|
|
|
- int count = exampleInfoService.count(
|
|
|
- Wrappers.<ExampleInfo>lambdaQuery()
|
|
|
- .eq(ExampleInfo::getFlowLinkNo, flowLinkNo)
|
|
|
- .eq(ExampleInfo::getComplete, StatusConstant.NO));
|
|
|
+ int count = exampleInfoService.count(Wrappers.<ExampleInfo>lambdaQuery()
|
|
|
+ .eq(ExampleInfo::getFlowLinkNo, flowLinkNo)
|
|
|
+ .eq(ExampleInfo::getComplete, StatusConstant.NO));
|
|
|
|
|
|
Assert.eqZero(count, FlowExplainConstant.EXPLAIN_NOT_EXIST);
|
|
|
|
|
@@ -165,29 +170,25 @@ public class FlowClient implements IFlowClient {
|
|
|
exampleInfo.setFlowLinkNo(flowLinkNo);
|
|
|
exampleInfo.setCacheData(cacheData);
|
|
|
|
|
|
+
|
|
|
+ ExampleDetails startExampleDetails = createExampleDetails(
|
|
|
+ exampleInfo.getId(), processInfo.getId(), null, ButtonNameEnum.START.getType());
|
|
|
+ startExampleDetails.setHandleUserId(AuthUtil.getUserId());
|
|
|
+ startExampleDetails.setRemarks(remarks);
|
|
|
+
|
|
|
|
|
|
if (processTenant == null) {
|
|
|
- exampleInfo.setComplete(StatusConstant.YES);
|
|
|
exampleInfo.setFlowType(FlowConstant.FLOW_TYPE_DEFAULT);
|
|
|
- exampleInfo.setProcessNodeCode(FlowConstant.END_CODE);
|
|
|
+ exampleInfoEnd(exampleInfo);
|
|
|
+ exampleInfo.setHandleResult(HandleResultEnum.ADOPT.getType());
|
|
|
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));
|
|
|
+
|
|
|
+ ExampleDetails endExampleDetails = createExampleDetails(
|
|
|
+ exampleInfo.getId(), processInfo.getId(), null, ButtonNameEnum.END.getType());
|
|
|
|
|
|
|
|
|
- exampleResult.setExampleInfo(exampleInfo);
|
|
|
+ exampleResult.setOldExampleInfo(exampleInfo);
|
|
|
exampleResult.setExampleDetailsIdList(
|
|
|
Arrays.asList(startExampleDetails.getId(), endExampleDetails.getId()));
|
|
|
exampleResult.setHandleType(ButtonNameEnum.END.getType());
|
|
@@ -197,50 +198,235 @@ public class FlowClient implements IFlowClient {
|
|
|
|
|
|
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);
|
|
|
+
|
|
|
+
|
|
|
+ nodeCode = ObjectUtil.isNotEmpty(nodeCode) ? nodeCode : FlowConstant.START_CODE;
|
|
|
+
|
|
|
+
|
|
|
+ if (FlowConstant.END_CODE.equals(nodeCode)) {
|
|
|
+ exampleInfoEnd(exampleInfo);
|
|
|
+ exampleInfo.setHandleResult(HandleResultEnum.ADOPT.getType());
|
|
|
+ exampleInfoService.save(exampleInfo);
|
|
|
+
|
|
|
+ ExampleDetails endExampleDetails = createExampleDetails(exampleInfo, ButtonNameEnum.END.getType());
|
|
|
+ exampleDetailsService.saveBatch(Arrays.asList(startExampleDetails, endExampleDetails));
|
|
|
+
|
|
|
+
|
|
|
+ exampleResult.setOldExampleInfo(exampleInfo);
|
|
|
+ exampleResult.setCacheDataStr(cacheData);
|
|
|
+ exampleResult.setExampleDetailsIdList(
|
|
|
+ Arrays.asList(startExampleDetails.getId(), endExampleDetails.getId()));
|
|
|
+ exampleResult.setHandleType(ButtonNameEnum.END.getType());
|
|
|
+
|
|
|
+ return R.data(exampleResult);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
ProcessNodeButton processNodeButton = processNodeButtonService.getOne(
|
|
|
Wrappers.<ProcessNodeButton>lambdaQuery()
|
|
|
.eq(ProcessNodeButton::getProcessTenantId, processTenantId)
|
|
|
- .eq(ProcessNodeButton::getProcessNodeCode, ObjectUtil.isNotEmpty(nodeCode) ? nodeCode : FlowConstant.START_CODE));
|
|
|
+ .eq(ProcessNodeButton::getProcessNodeCode, nodeCode));
|
|
|
+
|
|
|
+ Assert.notEmpty(processNodeButton, FlowExplainConstant.SPECIFY_BRANCH_EMPTY);
|
|
|
|
|
|
|
|
|
Long jumpNodeId;
|
|
|
+ String jumpNodeCode;
|
|
|
if (FlowConstant.START_CODE.equals(processNodeButton.getProcessNodeCode())) {
|
|
|
jumpNodeId = processNodeButton.getJumpNodeId();
|
|
|
+ jumpNodeCode = processNodeButton.getJumpNodeCode();
|
|
|
} else {
|
|
|
jumpNodeId = processNodeButton.getProcessNodeId();
|
|
|
+ jumpNodeCode = processNodeButton.getProcessNodeCode();
|
|
|
}
|
|
|
|
|
|
|
|
|
- if (jumpNodeId.equals(FlowConstant.OVER_PROCESS_FLAG)) {
|
|
|
+ if (FlowConstant.END_CODE.equals(jumpNodeCode)) {
|
|
|
|
|
|
- exampleInfo.setComplete(StatusConstant.YES);
|
|
|
+ exampleInfoEnd(exampleInfo);
|
|
|
+ exampleInfo.setHandleResult(HandleResultEnum.ADOPT.getType());
|
|
|
+ exampleInfoService.save(exampleInfo);
|
|
|
|
|
|
- ExampleDetails endExampleDetails = new ExampleDetails();
|
|
|
- endExampleDetails.setExampleInfoId(exampleInfo.getId());
|
|
|
- endExampleDetails.setProcessInfoId(processInfo.getId());
|
|
|
- endExampleDetails.setProcessTenantId(processTenant.getId());
|
|
|
- endExampleDetails.setNameType(ButtonNameEnum.END.getType());
|
|
|
+ ExampleDetails endExampleDetails = createExampleDetails(exampleInfo, ButtonNameEnum.END.getType());
|
|
|
+
|
|
|
+ exampleDetailsService.saveBatch(Arrays.asList(startExampleDetails, endExampleDetails));
|
|
|
+
|
|
|
+
|
|
|
+ exampleResult.setExampleDetailsIdList(
|
|
|
+ Arrays.asList(startExampleDetails.getId(), endExampleDetails.getId()));
|
|
|
+ exampleResult.setHandleType(ButtonNameEnum.END.getType());
|
|
|
|
|
|
} else {
|
|
|
exampleInfo.setComplete(StatusConstant.NO);
|
|
|
exampleInfo.setProcessNodeId(jumpNodeId);
|
|
|
+ exampleInfo.setProcessNodeCode(jumpNodeCode);
|
|
|
+ exampleInfo.setHandleResult(HandleResultEnum.NOT_START.getType());
|
|
|
+ exampleInfoService.save(exampleInfo);
|
|
|
+
|
|
|
+ exampleDetailsService.save(startExampleDetails);
|
|
|
|
|
|
+
|
|
|
+ exampleResult.setExampleDetailsIdList(Collections.singletonList(startExampleDetails.getId()));
|
|
|
}
|
|
|
|
|
|
+ exampleResult.setOldExampleInfo(exampleInfo);
|
|
|
+ exampleResult.setCacheDataStr(cacheData);
|
|
|
+
|
|
|
+ return R.data(exampleResult);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping(GET_NODE_BUTTON_BY_ID)
|
|
|
+ @Override
|
|
|
+ public R<ProcessNodeButton> getNodeButtonById(Long buttonId) {
|
|
|
+ ProcessNodeButton processNodeButton = processNodeButtonService.getById(buttonId);
|
|
|
+ Assert.notEmpty(processNodeButton, "nodeButton is null");
|
|
|
+
|
|
|
+ return R.data(processNodeButton);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @GetMapping(JUMP)
|
|
|
+ @Override
|
|
|
+ public R<ExampleResult> jump(JumpVo jumpVo) {
|
|
|
+
|
|
|
+
|
|
|
+ ExampleResult exampleResult = new ExampleResult();
|
|
|
+ exampleResult.setDeleteExample(false);
|
|
|
+
|
|
|
+
|
|
|
+ ExampleInfo oleExampleInfo = exampleInfoService.getOne(Wrappers.<ExampleInfo>lambdaQuery()
|
|
|
+ .eq(ExampleInfo::getFlowLinkNo, jumpVo.getFlowLinkNo())
|
|
|
+ .eq(ExampleInfo::getComplete, StatusConstant.NO));
|
|
|
+
|
|
|
+ ExampleInfo exampleInfo = ObjectUtil.clone(oleExampleInfo);
|
|
|
+ Assert.notEmpty(exampleInfo, FlowExplainConstant.EXAMPLE_INFO_NULL);
|
|
|
+
|
|
|
+ String cacheDataStr = jumpVo.getCacheDataStr();
|
|
|
+ if (ObjectUtil.isNotEmpty(cacheDataStr)) {
|
|
|
+ exampleInfo.setCacheData(cacheDataStr);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ExampleDetails exampleDetails = createExampleDetails(exampleInfo, jumpVo.getNameType());
|
|
|
+ exampleDetails.setProcessNodeId(exampleInfo.getProcessNodeId());
|
|
|
+ exampleDetails.setProcessNodeButtonId(jumpVo.getButtonId());
|
|
|
+ exampleDetails.setRemarks(jumpVo.getRemarks());
|
|
|
+ exampleDetails.setHandleUserId(AuthUtil.getUserId());
|
|
|
+
|
|
|
+
|
|
|
+ if (FlowConstant.END_CODE.equals(jumpVo.getJumpNodeCode())) {
|
|
|
+
|
|
|
+
|
|
|
+ exampleInfoEnd(exampleInfo);
|
|
|
+ exampleInfo.setHandleResult(HandleResultEnum.ADOPT.getType());
|
|
|
+ exampleInfoService.updateById(exampleInfo);
|
|
|
+
|
|
|
+
|
|
|
+ ExampleDetails endExampleDetails = createExampleDetails(exampleInfo, ButtonNameEnum.END.getType());
|
|
|
+
|
|
|
+ exampleResult.setOldExampleInfo(oleExampleInfo);
|
|
|
+ exampleResult.setCacheDataStr(exampleInfo.getCacheData());
|
|
|
+ exampleResult.setExampleDetailsIdList(Arrays.asList(exampleDetails.getId(), endExampleDetails.getId()));
|
|
|
+ exampleResult.setHandleType(ButtonNameEnum.END.getType());
|
|
|
+
|
|
|
+ return R.data(exampleResult);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (jumpVo.isSpecifyJump()) {
|
|
|
+ List<ProcessNodeButton> list = processNodeButtonService.list(Wrappers.<ProcessNodeButton>lambdaQuery()
|
|
|
+ .eq(ProcessNodeButton::getProcessTenantId, exampleInfo.getProcessTenantId())
|
|
|
+ .eq(ProcessNodeButton::getProcessNodeCode, jumpVo.getJumpNodeCode()));
|
|
|
+
|
|
|
+ if (list.size() == 0) {
|
|
|
+ throw new ServiceException(FlowExplainConstant.NOT_CODE);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (list.size() > 1) {
|
|
|
+ throw new ServiceException(FlowExplainConstant.MULTIPLE_CODE);
|
|
|
+ }
|
|
|
+
|
|
|
+ ProcessNodeButton processNodeButton = list.get(0);
|
|
|
+ jumpVo.setJumpNodeId(processNodeButton.getJumpNodeId());
|
|
|
+ jumpVo.setJumpNodeCode(processNodeButton.getJumpNodeCode());
|
|
|
+ jumpVo.setNameType(processNodeButton.getNameType());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (ButtonNameEnum.END.getType().equals(jumpVo.getNameType())) {
|
|
|
+ exampleInfoEnd(exampleInfo);
|
|
|
+ exampleInfo.setHandleResult(HandleResultEnum.ADOPT.getType());
|
|
|
+ ExampleDetails endExampleDetails = createExampleDetails(exampleInfo, ButtonNameEnum.END.getType());
|
|
|
+ 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());
|
|
|
+ exampleResult.setExampleDetailsIdList(Arrays.asList(exampleDetails.getId(), endExampleDetails.getId()));
|
|
|
+ }
|
|
|
+
|
|
|
+ else {
|
|
|
+ exampleInfo.setProcessNodeId(jumpVo.getJumpNodeId());
|
|
|
+ exampleInfo.setProcessNodeCode(jumpVo.getJumpNodeCode());
|
|
|
+ exampleInfo.setHandleResult(HandleResultEnum.START.getType());
|
|
|
+ exampleResult.setExampleDetailsIdList(Collections.singletonList(exampleDetails.getId()));
|
|
|
+ }
|
|
|
+
|
|
|
+ exampleInfoService.updateById(exampleInfo);
|
|
|
+ exampleResult.setOldExampleInfo(oleExampleInfo);
|
|
|
+ exampleResult.setCacheDataStr(exampleInfo.getCacheData());
|
|
|
+ exampleResult.setHandleType(jumpVo.getNameType());
|
|
|
+
|
|
|
+ return R.data(exampleResult);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping(ROLL_BACK)
|
|
|
+ @Override
|
|
|
+ public void rollBack(ExampleResult result) {
|
|
|
+ ExampleInfo oldExampleInfo = result.getOldExampleInfo();
|
|
|
+
|
|
|
+ if (result.isDeleteExample()) {
|
|
|
+ exampleInfoService.removeById(oldExampleInfo.getId());
|
|
|
+ } else {
|
|
|
+ exampleInfoService.updateById(oldExampleInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Long> exampleDetailsIdList = result.getExampleDetailsIdList();
|
|
|
+ exampleDetailsService.removeByIds(exampleDetailsIdList);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 获取流程结束明细
|
|
|
+ */
|
|
|
+ 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);
|
|
|
+ endExampleDetails.setProcessInfoId(processInfoId);
|
|
|
+ endExampleDetails.setProcessTenantId(processTenantId);
|
|
|
+ endExampleDetails.setNameType(nameType);
|
|
|
+ return endExampleDetails;
|
|
|
+ }
|
|
|
|
|
|
- return null;
|
|
|
+
|
|
|
+ * 赋值实例结束参数
|
|
|
+ */
|
|
|
+ private void exampleInfoEnd(ExampleInfo exampleInfo) {
|
|
|
+ exampleInfo.setComplete(StatusConstant.YES);
|
|
|
+ exampleInfo.setProcessNodeId(FlowConstant.OVER_PROCESS_FLAG);
|
|
|
+ exampleInfo.setProcessNodeCode(FlowConstant.END_CODE);
|
|
|
}
|
|
|
|
|
|
}
|