|
|
@@ -44,12 +44,14 @@ import com.qqflow.engine.domain.system.mapper.SysUserMapper;
|
|
|
import com.qqflow.engine.domain.system.mapper.SysUserRoleMapper;
|
|
|
import com.qqflow.engine.domain.system.service.SysUserService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.context.ApplicationEventPublisher;
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.time.LocalDateTime;
|
|
|
@@ -67,6 +69,7 @@ import static com.qqflow.engine.common.constant.SecurityConstants.ROLE_SUPER_ADM
|
|
|
import static com.qqflow.engine.common.constant.SecurityConstants.USER_TYPE_ROLE;
|
|
|
import static com.qqflow.engine.common.constant.SecurityConstants.USER_TYPE_SYSTEM;
|
|
|
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
@RequiredArgsConstructor
|
|
|
public class ApprovalTaskServiceImpl implements ApprovalTaskService {
|
|
|
@@ -89,10 +92,11 @@ public class ApprovalTaskServiceImpl implements ApprovalTaskService {
|
|
|
private final SysUserService sysUserService;
|
|
|
|
|
|
@Override
|
|
|
- public PageResult<ApprovalTaskDTO> todoList(Long assigneeId, String assigneeType, String processName, Integer pageNum, Integer pageSize) {
|
|
|
+ public PageResult<ApprovalTaskDTO> todoList(Long assigneeId, String assigneeType, String processName, String formFilters, Integer pageNum, Integer pageSize) {
|
|
|
List<Long> roleIds = loadRoleIdsIfSystemUser(assigneeId, assigneeType);
|
|
|
Page<ApprovalTask> page = new Page<>(pageNum, pageSize);
|
|
|
- this.approvalTaskMapper.selectTodoList(page, assigneeId, assigneeType, roleIds, processName);
|
|
|
+ Map<String, String> filterMap = this.parseFormFilters(formFilters);
|
|
|
+ this.approvalTaskMapper.selectTodoList(page, assigneeId, assigneeType, roleIds, processName, filterMap);
|
|
|
List<ApprovalTaskDTO> records = page.getRecords().stream()
|
|
|
.map(ApprovalTaskDTO::of)
|
|
|
.peek(this::fillUrgency)
|
|
|
@@ -101,6 +105,18 @@ public class ApprovalTaskServiceImpl implements ApprovalTaskService {
|
|
|
return PageResult.of(page.getTotal(), records);
|
|
|
}
|
|
|
|
|
|
+ private Map<String, String> parseFormFilters(String formFilters) {
|
|
|
+ if (!StringUtils.hasText(formFilters)) {
|
|
|
+ return Collections.emptyMap();
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ return this.objectMapper.readValue(formFilters, new TypeReference<Map<String, String>>() {});
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("解析表单筛选条件失败: {}", e.getMessage());
|
|
|
+ return Collections.emptyMap();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void fillUrgency(ApprovalTaskDTO dto) {
|
|
|
if (dto == null || dto.getTimeoutTime() == null) {
|
|
|
dto.setUrgency(0);
|
|
|
@@ -573,16 +589,41 @@ public class ApprovalTaskServiceImpl implements ApprovalTaskService {
|
|
|
if (definition == null) throw new BusinessException("流程定义不存在");
|
|
|
FlowModel model = this.flowEngineService.parseModel(definition.getModelJson());
|
|
|
// 返回所有下游节点(忽略条件),审批人手动选分支
|
|
|
- return this.flowEngineService.getNextNodes(model, task.getNodeId()).stream()
|
|
|
+ List<FlowNode> nextNodes = this.flowEngineService.getNextNodes(model, task.getNodeId()).stream()
|
|
|
.filter(n -> !NodeType.START.getCode().equals(n.getType())
|
|
|
&& !NodeType.END.getCode().equals(n.getType()))
|
|
|
- .map(n -> {
|
|
|
- NextNodeDTO dto = new NextNodeDTO();
|
|
|
- dto.setNodeId(n.getId());
|
|
|
- dto.setNodeName(n.getName());
|
|
|
- dto.setNodeType(n.getType());
|
|
|
- return dto;
|
|
|
- }).collect(Collectors.toList());
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (model.getEdges() == null) {
|
|
|
+ return nextNodes.stream().map(this::buildNextNodeDto).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ return nextNodes.stream().map(n -> {
|
|
|
+ NextNodeDTO dto = this.buildNextNodeDto(n);
|
|
|
+ model.getEdges().stream()
|
|
|
+ .filter(e -> Objects.equals(e.getSourceNodeId(), task.getNodeId())
|
|
|
+ && Objects.equals(e.getTargetNodeId(), n.getId()))
|
|
|
+ .findFirst()
|
|
|
+ .ifPresent(edge -> {
|
|
|
+ if (edge.getCondition() != null) {
|
|
|
+ Object branchName = edge.getCondition().get("branchName");
|
|
|
+ Object condition = edge.getCondition().get("condition");
|
|
|
+ if (branchName != null) {
|
|
|
+ dto.setBranchName(branchName.toString());
|
|
|
+ }
|
|
|
+ if (condition != null) {
|
|
|
+ dto.setCondition(condition.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return dto;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ private NextNodeDTO buildNextNodeDto(FlowNode node) {
|
|
|
+ NextNodeDTO dto = new NextNodeDTO();
|
|
|
+ dto.setNodeId(node.getId());
|
|
|
+ dto.setNodeName(StringUtils.hasText(node.getName()) ? node.getName() : node.getId());
|
|
|
+ dto.setNodeType(node.getType());
|
|
|
+ return dto;
|
|
|
}
|
|
|
|
|
|
@Override
|