|
@@ -9,8 +9,10 @@ import com.jy.flow.adapter.AbstractWarmFlowAdapter;
|
|
import com.jy.flow.model.dto.FlowHisTaskDto;
|
|
import com.jy.flow.model.dto.FlowHisTaskDto;
|
|
import com.jy.flow.model.dto.FlowTaskDto;
|
|
import com.jy.flow.model.dto.FlowTaskDto;
|
|
import com.jy.flow.model.dto.WarmFlowHandleDto;
|
|
import com.jy.flow.model.dto.WarmFlowHandleDto;
|
|
|
|
+import com.jy.flow.model.enums.FlowStatusEnum;
|
|
import com.jy.flow.model.vo.FlowTaskVo;
|
|
import com.jy.flow.model.vo.FlowTaskVo;
|
|
import com.jy.flow.service.ExecuteService;
|
|
import com.jy.flow.service.ExecuteService;
|
|
|
|
+import com.jy.framework.exception.ServiceException;
|
|
import com.jy.framework.satoken.LoginContext;
|
|
import com.jy.framework.satoken.LoginContext;
|
|
import com.jy.system.dao.SysDeptDao;
|
|
import com.jy.system.dao.SysDeptDao;
|
|
import com.jy.system.dao.SysRoleDao;
|
|
import com.jy.system.dao.SysRoleDao;
|
|
@@ -21,16 +23,20 @@ import com.warm.flow.core.dto.FlowParams;
|
|
import com.warm.flow.core.entity.HisTask;
|
|
import com.warm.flow.core.entity.HisTask;
|
|
import com.warm.flow.core.entity.Instance;
|
|
import com.warm.flow.core.entity.Instance;
|
|
import com.warm.flow.core.entity.Node;
|
|
import com.warm.flow.core.entity.Node;
|
|
|
|
+import com.warm.flow.core.entity.Skip;
|
|
|
|
+import com.warm.flow.core.entity.Task;
|
|
import com.warm.flow.core.entity.User;
|
|
import com.warm.flow.core.entity.User;
|
|
import com.warm.flow.core.enums.SkipType;
|
|
import com.warm.flow.core.enums.SkipType;
|
|
import com.warm.flow.core.enums.UserType;
|
|
import com.warm.flow.core.enums.UserType;
|
|
import com.warm.flow.core.service.HisTaskService;
|
|
import com.warm.flow.core.service.HisTaskService;
|
|
import com.warm.flow.core.service.InsService;
|
|
import com.warm.flow.core.service.InsService;
|
|
import com.warm.flow.core.service.NodeService;
|
|
import com.warm.flow.core.service.NodeService;
|
|
|
|
+import com.warm.flow.core.service.SkipService;
|
|
import com.warm.flow.core.service.TaskService;
|
|
import com.warm.flow.core.service.TaskService;
|
|
import com.warm.flow.core.service.UserService;
|
|
import com.warm.flow.core.service.UserService;
|
|
import com.warm.flow.core.utils.StreamUtils;
|
|
import com.warm.flow.core.utils.StreamUtils;
|
|
import com.warm.flow.orm.entity.FlowHisTask;
|
|
import com.warm.flow.orm.entity.FlowHisTask;
|
|
|
|
+import com.warm.flow.orm.entity.FlowSkip;
|
|
import jakarta.annotation.Resource;
|
|
import jakarta.annotation.Resource;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
@@ -75,6 +81,9 @@ public class ExecuteController {
|
|
@Resource
|
|
@Resource
|
|
private ExecuteService executeService;
|
|
private ExecuteService executeService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private SkipService skipService;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 分页待办任务列表
|
|
* 分页待办任务列表
|
|
*/
|
|
*/
|
|
@@ -83,6 +92,9 @@ public class ExecuteController {
|
|
dto.setPermissionList(AbstractWarmFlowAdapter.permissionList());
|
|
dto.setPermissionList(AbstractWarmFlowAdapter.permissionList());
|
|
Page<FlowTaskVo> page = executeService.toDoPage(dto);
|
|
Page<FlowTaskVo> page = executeService.toDoPage(dto);
|
|
List<FlowTaskVo> list = page.getRecords();
|
|
List<FlowTaskVo> list = page.getRecords();
|
|
|
|
+ if (list.isEmpty()) {
|
|
|
|
+ return page;
|
|
|
|
+ }
|
|
|
|
|
|
List<Long> taskIds = StreamUtils.toList(list, FlowTaskVo::getId);
|
|
List<Long> taskIds = StreamUtils.toList(list, FlowTaskVo::getId);
|
|
List<User> userList = flowUserservice.getByAssociateds(taskIds);
|
|
List<User> userList = flowUserservice.getByAssociateds(taskIds);
|
|
@@ -203,20 +215,86 @@ public class ExecuteController {
|
|
*/
|
|
*/
|
|
@PostMapping("/handle")
|
|
@PostMapping("/handle")
|
|
public void handle(@RequestBody WarmFlowHandleDto dto) {
|
|
public void handle(@RequestBody WarmFlowHandleDto dto) {
|
|
|
|
+ Task task = taskService.getById(dto.getTaskId());
|
|
|
|
+ Long definitionId = task.getDefinitionId();
|
|
|
|
+ String nodeCode = null;
|
|
|
|
+ FlowStatusEnum flowStatus = FlowStatusEnum.UNDER_WAY;
|
|
|
|
+
|
|
Integer handleType = dto.getHandleType();
|
|
Integer handleType = dto.getHandleType();
|
|
String skipType = switch (handleType) {
|
|
String skipType = switch (handleType) {
|
|
- case 1 -> SkipType.PASS.getKey();
|
|
|
|
- case 2 -> SkipType.REJECT.getKey();
|
|
|
|
- default -> null;
|
|
|
|
|
|
+ case 1 -> {
|
|
|
|
+ Node nextNode = nodeService.getNextNode(definitionId, task.getNodeCode(), "", "PASS");
|
|
|
|
+ nodeCode = nextNode.getNodeCode();
|
|
|
|
+ // 如果是结束节点
|
|
|
|
+ if (nextNode.getNodeType() == 2) {
|
|
|
|
+ flowStatus = FlowStatusEnum.COMPLETED;
|
|
|
|
+ }
|
|
|
|
+ yield SkipType.PASS.getKey();
|
|
|
|
+ }
|
|
|
|
+ case 2 -> {
|
|
|
|
+
|
|
|
|
+ nodeCode = task.getNodeCode();
|
|
|
|
+
|
|
|
|
+ List<Skip> skipList = skipService.list(new FlowSkip().setDefinitionId(definitionId));
|
|
|
|
+
|
|
|
|
+ List<Skip> rejectSkipList = skipList.stream()
|
|
|
|
+ .filter(item -> "REJECT".equals(item.getSkipType()))
|
|
|
|
+ .filter(item -> item.getNowNodeCode().equals(task.getNodeCode()))
|
|
|
|
+ .toList();
|
|
|
|
+
|
|
|
|
+ int rejectSkipSize = rejectSkipList.size();
|
|
|
|
+ if (rejectSkipSize == 0) {
|
|
|
|
+ while (true) {
|
|
|
|
+ String tempNodeCode = nodeCode;
|
|
|
|
+
|
|
|
|
+ Skip skip = skipList.stream()
|
|
|
|
+ .filter(item -> "PASS".equals(item.getSkipType()))
|
|
|
|
+ .filter(item -> item.getNextNodeCode().equals(tempNodeCode))
|
|
|
|
+ .findFirst()
|
|
|
|
+ .orElse(null);
|
|
|
|
+
|
|
|
|
+ if (skip == null) {
|
|
|
|
+ throw new ServiceException("流程配置错误:不存在回退节点");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ nodeCode = skip.getNowNodeCode();
|
|
|
|
+
|
|
|
|
+ if (ObjectUtil.notEqual(skip.getNowNodeType(), 3)) {
|
|
|
|
+ // 回退到开始节点
|
|
|
|
+ if (skip.getNowNodeType() == 0) {
|
|
|
|
+ flowStatus = FlowStatusEnum.PRIMED_FOR_ACTION;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else if (rejectSkipSize == 1) {
|
|
|
|
+ Skip skip = rejectSkipList.get(0);
|
|
|
|
+ if (skip.getNextNodeType().equals(3)) {
|
|
|
|
+ throw new ServiceException("流程配置错误:节点回退到网关");
|
|
|
|
+ }
|
|
|
|
+ nodeCode = skip.getNextNodeCode();
|
|
|
|
+ } else {
|
|
|
|
+ throw new ServiceException("流程配置错误:存在多个回退节点");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ yield SkipType.REJECT.getKey();
|
|
|
|
+ }
|
|
|
|
+ case 3 -> {
|
|
|
|
+ flowStatus = FlowStatusEnum.DECLINED;
|
|
|
|
+ yield null;
|
|
|
|
+ }
|
|
|
|
+ default -> throw new ServiceException("办理类型不存在");
|
|
};
|
|
};
|
|
|
|
|
|
FlowParams flowParams = FlowParams.build()
|
|
FlowParams flowParams = FlowParams.build()
|
|
.skipType(skipType)
|
|
.skipType(skipType)
|
|
.handler(LoginContext.getUserId().toString())
|
|
.handler(LoginContext.getUserId().toString())
|
|
- .nodeCode(dto.getNodeCode())
|
|
|
|
|
|
+ .nodeCode(nodeCode)
|
|
.message(dto.getMessage())
|
|
.message(dto.getMessage())
|
|
.permissionFlag(AbstractWarmFlowAdapter.permissionList())
|
|
.permissionFlag(AbstractWarmFlowAdapter.permissionList())
|
|
- .setFlowStatus("");
|
|
|
|
|
|
+ .flowStatus(flowStatus.getKeyStr());
|
|
|
|
|
|
if (handleType == 3) {
|
|
if (handleType == 3) {
|
|
taskService.termination(dto.getTaskId(), flowParams);
|
|
taskService.termination(dto.getTaskId(), flowParams);
|