mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-08 04:39:00 +08:00
feat(flow): 适配 form-design 表单设计器
This commit is contained in:
1 parent
667cc7397f
commit
b8a4086970
41 files changed
+672
-794
No files matched your search
@@ -74,6 +74,11 @@
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-common-sentinel</artifactId>
|
||||
</dependency>
|
||||
<!--必备: API加解密 -->
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-common-encrypt-api</artifactId>
|
||||
</dependency>
|
||||
<!--必备: feign 依赖-->
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
|
||||
-2
@@ -11,7 +11,6 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.security.annotation.Inner;
|
||||
import com.pig4cloud.pigx.flow.engine.utils.ModelUtil;
|
||||
import com.pig4cloud.pigx.flow.task.dto.*;
|
||||
import com.pig4cloud.pigx.flow.task.entity.Process;
|
||||
@@ -96,7 +95,6 @@ public class EngineFlowController {
|
||||
* @param processInstanceParamDto 启动参数
|
||||
* @return 流程实例ID
|
||||
*/
|
||||
@Inner
|
||||
@PostMapping("/start")
|
||||
public R start(@RequestBody ProcessInstanceParamDto processInstanceParamDto) {
|
||||
Authentication.setAuthenticatedUserId(processInstanceParamDto.getStartUserId());
|
||||
|
||||
+4
-2
@@ -46,8 +46,10 @@ public class EngineProcessInstanceController {
|
||||
|
||||
long completedNum = historicActivityInstanceQuery.taskAssignee(String.valueOf(userId)).finished().count();
|
||||
|
||||
IndexPageStatistics indexPageStatistics = IndexPageStatistics.builder().pendingNum(pendingNum)
|
||||
.completedNum(completedNum).build();
|
||||
IndexPageStatistics indexPageStatistics = IndexPageStatistics.builder()
|
||||
.pendingNum(pendingNum)
|
||||
.completedNum(completedNum)
|
||||
.build();
|
||||
|
||||
return R.ok(indexPageStatistics);
|
||||
}
|
||||
|
||||
+24
@@ -154,4 +154,28 @@ public class EngineTaskController {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置执行人 (转办)
|
||||
*
|
||||
* @param taskParamDto 任务参数DTO
|
||||
* @return 操作结果
|
||||
*/
|
||||
@PostMapping("/transferTask")
|
||||
public R transferTask(@RequestBody TaskParamDto taskParamDto) {
|
||||
Map<String, Object> taskLocalParamMap = taskParamDto.getTaskLocalParamMap();
|
||||
if (CollUtil.isNotEmpty(taskLocalParamMap)) {
|
||||
taskService.setVariablesLocal(taskParamDto.getTaskId(), taskLocalParamMap);
|
||||
}
|
||||
|
||||
// 设置任务的 owner 为当前任务的 assignee
|
||||
Task task = taskService.createTaskQuery().taskId(taskParamDto.getTaskId()).includeTaskLocalVariables().singleResult();
|
||||
taskService.setOwner(taskParamDto.getTaskId(), task.getAssignee());
|
||||
|
||||
// 设置任务的 assignee 为目标用户 (转办用户)
|
||||
for (Long targetUserId : taskParamDto.getTargetUserIdList()) {
|
||||
taskService.setAssignee(taskParamDto.getTaskId(), targetUserId.toString());
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
+6
-3
@@ -44,7 +44,8 @@ public class ExpressionHandler {
|
||||
Object variable = execution.getVariable(key);
|
||||
NodeUser nodeUserDto = objectMapper
|
||||
.readValue(objectMapper.writeValueAsString(variable), new TypeReference<List<NodeUser>>() {
|
||||
}).get(0);
|
||||
})
|
||||
.get(0);
|
||||
return nodeUserDto.getId();
|
||||
}
|
||||
|
||||
@@ -289,11 +290,13 @@ public class ExpressionHandler {
|
||||
});
|
||||
|
||||
List<Long> deptIdList = paramDeptList.stream()
|
||||
.filter(w -> StrUtil.equals(w.getType(), NodeUserTypeEnum.DEPT.getKey())).map(NodeUser::getId)
|
||||
.filter(w -> StrUtil.equals(w.getType(), NodeUserTypeEnum.DEPT.getKey()))
|
||||
.map(NodeUser::getId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<Long> userIdList = paramDeptList.stream()
|
||||
.filter(w -> StrUtil.equals(w.getType(), NodeUserTypeEnum.USER.getKey())).map(NodeUser::getId)
|
||||
.filter(w -> StrUtil.equals(w.getType(), NodeUserTypeEnum.USER.getKey()))
|
||||
.map(NodeUser::getId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (CollUtil.isNotEmpty(deptIdList)) {
|
||||
|
||||
+14
-5
@@ -10,18 +10,27 @@ import com.pig4cloud.pigx.flow.task.dto.Node;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class NodeExpressionStrategyFactory {
|
||||
|
||||
public static String handleSingleCondition(Condition nodeConditionDto) {
|
||||
Map<String, NodeConditionStrategy> nodeConditionStrategyMap = SpringUtil
|
||||
.getBeansOfType(NodeConditionStrategy.class);
|
||||
NodeConditionStrategy nodeConditionHandler = nodeConditionStrategyMap
|
||||
.get(nodeConditionDto.getKeyType() + "NodeConditionStrategy");
|
||||
if (nodeConditionHandler == null) {
|
||||
.getBeansOfType(NodeConditionStrategy.class);
|
||||
|
||||
// 通过keyType获取对应的处理器, 忽略大小写
|
||||
AtomicReference<NodeConditionStrategy> nodeConditionHandler = new AtomicReference<>();
|
||||
nodeConditionStrategyMap.forEach((k, v) -> {
|
||||
if (k.equalsIgnoreCase(nodeConditionDto.getKeyType() + "NodeConditionStrategy")) {
|
||||
nodeConditionHandler.set(v);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (nodeConditionHandler.get() == null) {
|
||||
return "(1==1)";
|
||||
}
|
||||
return nodeConditionHandler.handle(nodeConditionDto);
|
||||
return nodeConditionHandler.get().handle(nodeConditionDto);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import org.springframework.stereotype.Component;
|
||||
/**
|
||||
* 字符类型处理器
|
||||
*/
|
||||
@Component("DateNodeConditionStrategy")
|
||||
@Component("datePickerNodeConditionStrategy")
|
||||
public class DateNodeConditionStrategy implements NodeConditionStrategy {
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import org.springframework.stereotype.Component;
|
||||
/**
|
||||
* 字符类型处理器
|
||||
*/
|
||||
@Component("InputNodeConditionStrategy")
|
||||
@Component("inputNodeConditionStrategy")
|
||||
public class InputNodeConditionStrategy implements NodeConditionStrategy {
|
||||
|
||||
/**
|
||||
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
package com.pig4cloud.pigx.flow.engine.expression.condition.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.pig4cloud.pigx.flow.engine.expression.condition.NodeConditionStrategy;
|
||||
import com.pig4cloud.pigx.flow.task.dto.Condition;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 字符类型处理器
|
||||
*/
|
||||
@Component("MoneyNodeConditionStrategy")
|
||||
public class MoneyNodeConditionStrategy implements NodeConditionStrategy {
|
||||
|
||||
/**
|
||||
* 抽象方法 处理表达式
|
||||
*/
|
||||
@Override
|
||||
public String handle(Condition condition) {
|
||||
|
||||
String compare = condition.getExpression();
|
||||
String id = condition.getKey();
|
||||
Object value = condition.getValue();
|
||||
|
||||
return StrUtil.format("(expressionHandler.numberCompare(\"{}\",\"{}\",{},execution))", id, compare, value);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -8,7 +8,7 @@ import org.springframework.stereotype.Component;
|
||||
/**
|
||||
* 字符类型处理器
|
||||
*/
|
||||
@Component("NumberNodeConditionStrategy")
|
||||
@Component("inputNumberNodeConditionStrategy")
|
||||
public class NumberNodeConditionStrategy implements NodeConditionStrategy {
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ import org.springframework.stereotype.Component;
|
||||
/**
|
||||
* 字符类型处理器
|
||||
*/
|
||||
@Component("TimeNodeConditionStrategy")
|
||||
@Component("timePickerNodeConditionStrategy")
|
||||
public class TimeNodeConditionStrategy implements NodeConditionStrategy {
|
||||
|
||||
/**
|
||||
|
||||
+10
-7
@@ -72,10 +72,12 @@ public class FlowProcessEventListener implements FlowableEventListener {
|
||||
remoteFlowTaskService.startNodeEvent(processNodeRecordParamDto);
|
||||
}
|
||||
|
||||
if (event.getType().toString()
|
||||
if (event.getType()
|
||||
.toString()
|
||||
.equals(FlowableEngineEventType.MULTI_INSTANCE_ACTIVITY_COMPLETED_WITH_CONDITION.toString())
|
||||
|| event.getType().toString()
|
||||
.equals(FlowableEngineEventType.MULTI_INSTANCE_ACTIVITY_COMPLETED.toString())) {
|
||||
|| event.getType()
|
||||
.toString()
|
||||
.equals(FlowableEngineEventType.MULTI_INSTANCE_ACTIVITY_COMPLETED.toString())) {
|
||||
// 多实例任务
|
||||
FlowableMultiInstanceActivityCompletedEventImpl flowableActivityEvent = (FlowableMultiInstanceActivityCompletedEventImpl) event;
|
||||
String activityId = flowableActivityEvent.getActivityId();
|
||||
@@ -140,7 +142,8 @@ public class FlowProcessEventListener implements FlowableEventListener {
|
||||
log.debug("变量[{}]删除了:{} ", flowableVariableEvent.getVariableName(),
|
||||
flowableVariableEvent.getVariableValue());
|
||||
}
|
||||
if (event.getType().toString()
|
||||
if (event.getType()
|
||||
.toString()
|
||||
.equals(FlowableEngineEventType.PROCESS_COMPLETED_WITH_TERMINATE_END_EVENT.toString())) {
|
||||
// 流程开完成
|
||||
FlowableProcessTerminatedEventImpl e = (FlowableProcessTerminatedEventImpl) event;
|
||||
@@ -223,9 +226,9 @@ public class FlowProcessEventListener implements FlowableEventListener {
|
||||
processNodeRecordAssignUserParamDto.setTaskId(task.getId());
|
||||
processNodeRecordAssignUserParamDto.setNodeName(task.getName());
|
||||
processNodeRecordAssignUserParamDto
|
||||
.setTaskType(StrUtil.equals(DelegationState.PENDING.toString(), delegationStateString)
|
||||
? "DELEGATION" : (StrUtil.equals(DelegationState.RESOLVED.toString(), delegationStateString)
|
||||
? "RESOLVED" : ""));
|
||||
.setTaskType(StrUtil.equals(DelegationState.PENDING.toString(), delegationStateString) ? "DELEGATION"
|
||||
: (StrUtil.equals(DelegationState.RESOLVED.toString(), delegationStateString) ? "RESOLVED"
|
||||
: ""));
|
||||
processNodeRecordAssignUserParamDto.setApproveDesc(Convert.toStr(task.getVariableLocal("approveDesc")));
|
||||
processNodeRecordAssignUserParamDto.setExecutionId(task.getExecutionId());
|
||||
|
||||
|
||||
+6
-4
@@ -44,12 +44,14 @@ public class AssignUserFixedStrategyImpl implements AssignUserStrategy {
|
||||
List<NodeUser> userDtoList = node.getNodeUserList();
|
||||
// 用户ID列表
|
||||
List<Long> userIdList = userDtoList.stream()
|
||||
.filter(w -> StrUtil.equals(w.getType(), NodeUserTypeEnum.USER.getKey())).map(NodeUser::getId)
|
||||
.collect(Collectors.toList());
|
||||
.filter(w -> StrUtil.equals(w.getType(), NodeUserTypeEnum.USER.getKey()))
|
||||
.map(NodeUser::getId)
|
||||
.collect(Collectors.toList());
|
||||
// 部门ID列表
|
||||
List<Long> deptIdList = userDtoList.stream()
|
||||
.filter(w -> StrUtil.equals(w.getType(), NodeUserTypeEnum.DEPT.getKey())).map(NodeUser::getId)
|
||||
.collect(Collectors.toList());
|
||||
.filter(w -> StrUtil.equals(w.getType(), NodeUserTypeEnum.DEPT.getKey()))
|
||||
.map(NodeUser::getId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (CollUtil.isNotEmpty(deptIdList)) {
|
||||
R<List<SysUser>> r = remoteUserService.getUserIdListByDeptIdList(deptIdList);
|
||||
|
||||
+1
-2
@@ -14,7 +14,6 @@ import org.springframework.stereotype.Component;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 来自表单
|
||||
@@ -38,7 +37,7 @@ public class AssignUserFormStrategyImpl implements AssignUserStrategy {
|
||||
if (variable != null && !StrUtil.isBlankIfStr(variable)) {
|
||||
String jsonString = objectMapper.writeValueAsString(variable);
|
||||
List<NodeUser> nodeUserDtoList = JSONUtil.toList(jsonString, NodeUser.class);
|
||||
assignList.addAll(nodeUserDtoList.stream().map(NodeUser::getId).collect(Collectors.toList()));
|
||||
assignList.addAll(nodeUserDtoList.stream().map(NodeUser::getId).toList());
|
||||
}
|
||||
|
||||
return assignList;
|
||||
|
||||
+3
-2
@@ -40,8 +40,9 @@ public class AssignUserRoleStrategyImpl implements AssignUserStrategy {
|
||||
// 使用 lambda 表达式和方法引用从 NodeUser 列表中提取角色 ID
|
||||
List<Long> roleIds = node.getNodeUserList().stream().map(NodeUser::getId).collect(Collectors.toList());
|
||||
// 提取 Optional 结果中的数据
|
||||
List<Long> data = RetOps.of(remoteUserService.getUserIdListByRoleIdList(roleIds)).getData()
|
||||
.orElseGet(Collections::emptyList);
|
||||
List<Long> data = RetOps.of(remoteUserService.getUserIdListByRoleIdList(roleIds))
|
||||
.getData()
|
||||
.orElseGet(Collections::emptyList);
|
||||
|
||||
// 返回用户 ID 列表
|
||||
return new ArrayList<>(data);
|
||||
|
||||
+8
-4
@@ -41,12 +41,16 @@ public class ApproveServiceTask implements JavaDelegate {
|
||||
if (refuse != null) {
|
||||
String handler = refuse.getHandler();
|
||||
if (StrUtil.equals(handler, "TO_NODE")) {
|
||||
runtimeService.createChangeActivityStateBuilder().processInstanceId(processInstanceId)
|
||||
.moveActivityIdTo(nodeIdO, refuse.getNodeId()).changeState();
|
||||
runtimeService.createChangeActivityStateBuilder()
|
||||
.processInstanceId(processInstanceId)
|
||||
.moveActivityIdTo(nodeIdO, refuse.getNodeId())
|
||||
.changeState();
|
||||
}
|
||||
else {
|
||||
runtimeService.createChangeActivityStateBuilder().processInstanceId(processInstanceId)
|
||||
.moveActivityIdTo(nodeIdO, "end").changeState();
|
||||
runtimeService.createChangeActivityStateBuilder()
|
||||
.processInstanceId(processInstanceId)
|
||||
.moveActivityIdTo(nodeIdO, "end")
|
||||
.changeState();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-6
@@ -46,12 +46,14 @@ public class CopyServiceTask implements JavaDelegate {
|
||||
List<NodeUser> userDtoList = node.getNodeUserList();
|
||||
// 用户ID列表
|
||||
List<String> userIdList = userDtoList.stream()
|
||||
.filter(w -> StrUtil.equals(w.getType(), NodeUserTypeEnum.USER.getKey()))
|
||||
.map(w -> Convert.toStr(w.getId())).collect(Collectors.toList());
|
||||
.filter(w -> StrUtil.equals(w.getType(), NodeUserTypeEnum.USER.getKey()))
|
||||
.map(w -> Convert.toStr(w.getId()))
|
||||
.collect(Collectors.toList());
|
||||
// 部门ID列表
|
||||
List<String> deptIdList = userDtoList.stream()
|
||||
.filter(w -> StrUtil.equals(w.getType(), NodeUserTypeEnum.DEPT.getKey()))
|
||||
.map(w -> Convert.toStr(w.getId())).collect(Collectors.toList());
|
||||
.filter(w -> StrUtil.equals(w.getType(), NodeUserTypeEnum.DEPT.getKey()))
|
||||
.map(w -> Convert.toStr(w.getId()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (CollUtil.isNotEmpty(deptIdList)) {
|
||||
|
||||
@@ -71,8 +73,9 @@ public class CopyServiceTask implements JavaDelegate {
|
||||
// 获取发起人
|
||||
Object rootUserObj = execution.getVariable("root");
|
||||
NodeUser rootUser = objectMapper
|
||||
.readValue(objectMapper.writeValueAsString(rootUserObj), new TypeReference<List<NodeUser>>() {
|
||||
}).get(0);
|
||||
.readValue(objectMapper.writeValueAsString(rootUserObj), new TypeReference<List<NodeUser>>() {
|
||||
})
|
||||
.get(0);
|
||||
|
||||
Map<String, Object> variables = execution.getVariables();
|
||||
|
||||
|
||||
+7
-7
@@ -128,7 +128,7 @@ public class FlowableUtils {
|
||||
// 获取子流程用户任务节点
|
||||
List<UserTask> childUserTaskList = findChildProcessUserTasks(
|
||||
(StartEvent) ((SubProcess) sequenceFlow.getSourceFlowElement()).getFlowElements()
|
||||
.toArray()[0],
|
||||
.toArray()[0],
|
||||
null, null);
|
||||
// 如果找到节点,则说明该线路找到节点,不继续向下找,反之继续
|
||||
if (childUserTaskList != null && childUserTaskList.size() > 0) {
|
||||
@@ -189,7 +189,7 @@ public class FlowableUtils {
|
||||
if (sequenceFlow.getTargetFlowElement() instanceof SubProcess) {
|
||||
List<FlowElement> childUserTaskList = iteratorFindChildUserTasks(
|
||||
(FlowElement) (((SubProcess) sequenceFlow.getTargetFlowElement()).getFlowElements()
|
||||
.toArray()[0]),
|
||||
.toArray()[0]),
|
||||
runActiveIdList, hasSequenceFlow, null);
|
||||
// 如果找到节点,则说明该线路找到节点,不继续向下找,反之继续
|
||||
if (childUserTaskList != null && childUserTaskList.size() > 0) {
|
||||
@@ -240,7 +240,7 @@ public class FlowableUtils {
|
||||
if (sequenceFlow.getTargetFlowElement() instanceof SubProcess) {
|
||||
List<UserTask> childUserTaskList = findChildProcessUserTasks(
|
||||
(FlowElement) (((SubProcess) sequenceFlow.getTargetFlowElement()).getFlowElements()
|
||||
.toArray()[0]),
|
||||
.toArray()[0]),
|
||||
hasSequenceFlow, null);
|
||||
// 如果找到节点,则说明该线路找到节点,不继续向下找,反之继续
|
||||
if (childUserTaskList != null && childUserTaskList.size() > 0) {
|
||||
@@ -302,12 +302,12 @@ public class FlowableUtils {
|
||||
if (sequenceFlow.getSourceFlowElement() instanceof SubProcess) {
|
||||
dirtyRoads = findChildProcessAllDirtyRoad(
|
||||
(StartEvent) ((SubProcess) sequenceFlow.getSourceFlowElement()).getFlowElements()
|
||||
.toArray()[0],
|
||||
.toArray()[0],
|
||||
null, dirtyRoads);
|
||||
// 是否存在子流程上,true 是,false 否
|
||||
Boolean isInChildProcess = dirtyTargetInChildProcess(
|
||||
(StartEvent) ((SubProcess) sequenceFlow.getSourceFlowElement()).getFlowElements()
|
||||
.toArray()[0],
|
||||
.toArray()[0],
|
||||
null, targets, null);
|
||||
if (isInChildProcess) {
|
||||
// 已在子流程上找到,该路线结束
|
||||
@@ -354,7 +354,7 @@ public class FlowableUtils {
|
||||
if (sequenceFlow.getTargetFlowElement() instanceof SubProcess) {
|
||||
dirtyRoads = findChildProcessAllDirtyRoad(
|
||||
(FlowElement) (((SubProcess) sequenceFlow.getTargetFlowElement()).getFlowElements()
|
||||
.toArray()[0]),
|
||||
.toArray()[0]),
|
||||
hasSequenceFlow, dirtyRoads);
|
||||
}
|
||||
// 继续迭代
|
||||
@@ -401,7 +401,7 @@ public class FlowableUtils {
|
||||
if (sequenceFlow.getTargetFlowElement() instanceof SubProcess) {
|
||||
inChildProcess = dirtyTargetInChildProcess(
|
||||
(FlowElement) (((SubProcess) sequenceFlow.getTargetFlowElement()).getFlowElements()
|
||||
.toArray()[0]),
|
||||
.toArray()[0]),
|
||||
hasSequenceFlow, targets, inChildProcess);
|
||||
}
|
||||
// 继续迭代
|
||||
|
||||
+1
-2
@@ -183,8 +183,7 @@ public class ModelUtil {
|
||||
if (nodeDto.getType() == NodeTypeEnum.EXCLUSIVE_GATEWAY.getValue().intValue()) {
|
||||
if (ord == size) {
|
||||
expression = NodeExpressionStrategyFactory.handleDefaultBranch(branchs, ord - 1);
|
||||
}
|
||||
else if (nodeDto.getType() == NodeTypeEnum.EXCLUSIVE_GATEWAY.getValue().intValue() && ord > 1) {
|
||||
} else if (ord > 1) {
|
||||
expression = NodeExpressionStrategyFactory.handleDefaultBranch(branchs, ord - 1);
|
||||
}
|
||||
else {
|
||||
|
||||
+2
-4
@@ -3,7 +3,6 @@ package com.pig4cloud.pigx.flow.task.api.feign;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.pig4cloud.pigx.common.core.constant.ServiceNameConstants;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.feign.annotation.NoToken;
|
||||
import com.pig4cloud.pigx.flow.task.dto.*;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -49,7 +48,6 @@ public interface RemoteFlowEngineService {
|
||||
* @param processInstanceParamDto 流程实例参数
|
||||
* @return 启动流程结果
|
||||
*/
|
||||
@NoToken
|
||||
@PostMapping("/flow/start")
|
||||
R<String> startProcess(@RequestBody ProcessInstanceParamDto processInstanceParamDto);
|
||||
|
||||
@@ -82,8 +80,8 @@ public interface RemoteFlowEngineService {
|
||||
* @param taskParamDto 任务参数
|
||||
* @return 设置负责人结果
|
||||
*/
|
||||
@PostMapping("/task/setAssignee")
|
||||
R<String> setAssignee(@RequestBody TaskParamDto taskParamDto);
|
||||
@PostMapping("/task/transferTask")
|
||||
R<String> transferTask(@RequestBody TaskParamDto taskParamDto);
|
||||
|
||||
/**
|
||||
* 停止流程实例
|
||||
|
||||
-7
@@ -2,7 +2,6 @@ package com.pig4cloud.pigx.flow.task.api.feign;
|
||||
|
||||
import com.pig4cloud.pigx.common.core.constant.ServiceNameConstants;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.feign.annotation.NoToken;
|
||||
import com.pig4cloud.pigx.flow.task.dto.*;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -23,7 +22,6 @@ public interface RemoteFlowTaskService {
|
||||
* 节点开始事件
|
||||
* @param nodeRecordParamDto
|
||||
*/
|
||||
@NoToken
|
||||
@PostMapping("/remote/startNodeEvent")
|
||||
void startNodeEvent(@RequestBody ProcessNodeRecordParamDto nodeRecordParamDto);
|
||||
|
||||
@@ -31,7 +29,6 @@ public interface RemoteFlowTaskService {
|
||||
* 节点结束事件
|
||||
* @param nodeRecordParamDto
|
||||
*/
|
||||
@NoToken
|
||||
@PostMapping("/remote/endNodeEvent")
|
||||
void endNodeEvent(@RequestBody ProcessNodeRecordParamDto nodeRecordParamDto);
|
||||
|
||||
@@ -46,7 +43,6 @@ public interface RemoteFlowTaskService {
|
||||
* 创建流程事件
|
||||
* @param processInstanceRecordParamDto
|
||||
*/
|
||||
@NoToken
|
||||
@PostMapping("/remote/createProcessEvent")
|
||||
void createProcessEvent(@RequestBody ProcessInstanceRecordParamDto processInstanceRecordParamDto);
|
||||
|
||||
@@ -77,7 +73,6 @@ public interface RemoteFlowTaskService {
|
||||
* @param nodeId 节点id
|
||||
* @return
|
||||
*/
|
||||
@NoToken
|
||||
@GetMapping("/processNodeData/getNodeData")
|
||||
R<Node> queryNodeOriData(@RequestParam("flowId") String flowId, @RequestParam("nodeId") String nodeId);
|
||||
|
||||
@@ -85,7 +80,6 @@ public interface RemoteFlowTaskService {
|
||||
* 节点开始指派用户了
|
||||
* @param processNodeRecordAssignUserParamDto
|
||||
*/
|
||||
@NoToken
|
||||
@PostMapping("/remote/startAssignUser")
|
||||
R startAssignUser(@RequestBody ProcessNodeRecordAssignUserParamDto processNodeRecordAssignUserParamDto);
|
||||
|
||||
@@ -93,7 +87,6 @@ public interface RemoteFlowTaskService {
|
||||
* 任务结束事件
|
||||
* @param processNodeRecordAssignUserParamDto
|
||||
*/
|
||||
@NoToken
|
||||
@PostMapping("/remote/taskEndEvent")
|
||||
R taskEndEvent(@RequestBody ProcessNodeRecordAssignUserParamDto processNodeRecordAssignUserParamDto);
|
||||
|
||||
|
||||
+4
-2
@@ -61,8 +61,10 @@ public interface IBaseEnum<T> {
|
||||
Objects.requireNonNull(label);
|
||||
EnumSet<E> allEnums = EnumSet.allOf(clazz); // 获取类型下的所有枚举
|
||||
String finalLabel = label;
|
||||
E matchEnum = allEnums.stream().filter(e -> ObjectUtil.equal(e.getLabel(), finalLabel)).findFirst()
|
||||
.orElse(null);
|
||||
E matchEnum = allEnums.stream()
|
||||
.filter(e -> ObjectUtil.equal(e.getLabel(), finalLabel))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
Object value = null;
|
||||
if (matchEnum != null) {
|
||||
|
||||
+38
-35
@@ -7,53 +7,56 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
* 任务完成参数对象
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
public class TaskParamDto {
|
||||
|
||||
private String processInstanceId;
|
||||
private String processInstanceId;
|
||||
|
||||
private List<String> processInstanceIdList;
|
||||
private List<String> processInstanceIdList;
|
||||
|
||||
/**
|
||||
* 节点id
|
||||
*/
|
||||
private String nodeId;
|
||||
/**
|
||||
* 节点id
|
||||
*/
|
||||
private String nodeId;
|
||||
|
||||
/**
|
||||
* 添加子流程发起人
|
||||
*/
|
||||
private Boolean appendChildProcessRootId;
|
||||
/**
|
||||
* 添加子流程发起人
|
||||
*/
|
||||
private Boolean appendChildProcessRootId;
|
||||
|
||||
/**
|
||||
* 任务id
|
||||
*/
|
||||
private String taskId;
|
||||
/**
|
||||
* 任务id
|
||||
*/
|
||||
private String taskId;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private String userId;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 模板用户id
|
||||
*/
|
||||
private String targetUserId;
|
||||
/**
|
||||
* 模板用户id
|
||||
*/
|
||||
private String targetUserId;
|
||||
|
||||
/**
|
||||
* 参数
|
||||
*/
|
||||
private Map<String, Object> paramMap;
|
||||
/**
|
||||
* 参数
|
||||
*/
|
||||
private Map<String, Object> paramMap;
|
||||
|
||||
/**
|
||||
* 任务本地变量
|
||||
*/
|
||||
private Map<String, Object> taskLocalParamMap;
|
||||
/**
|
||||
* 任务本地变量
|
||||
*/
|
||||
private Map<String, Object> taskLocalParamMap;
|
||||
|
||||
/**
|
||||
* 模板节点
|
||||
*/
|
||||
private String targetNodeId;
|
||||
/**
|
||||
* 模板节点
|
||||
*/
|
||||
private String targetNodeId;
|
||||
|
||||
/**
|
||||
* 转办目标用户 ID 列表
|
||||
*/
|
||||
private List<Long> targetUserIdList;
|
||||
}
|
||||
+4
-1
@@ -2,12 +2,14 @@ package com.pig4cloud.pigx.flow.task.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.FieldNameConstants;
|
||||
|
||||
/**
|
||||
* 表单
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@FieldNameConstants
|
||||
public class FormItemVO {
|
||||
|
||||
private String id;
|
||||
@@ -26,10 +28,11 @@ public class FormItemVO {
|
||||
|
||||
private String placeholder;
|
||||
|
||||
private Props props;
|
||||
private Props props = new Props();
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@FieldNameConstants
|
||||
public static class Props {
|
||||
|
||||
private Object value;
|
||||
|
||||
+5
@@ -16,4 +16,9 @@ public class ProcessVO extends Process {
|
||||
|
||||
private Map<String, Object> variableMap;
|
||||
|
||||
/**
|
||||
* 发起人节点的表单权限
|
||||
*/
|
||||
private Map<String, String> formPerms;
|
||||
|
||||
}
|
||||
@@ -73,6 +73,11 @@
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-common-log</artifactId>
|
||||
</dependency>
|
||||
<!--必备: API加解密 -->
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-common-encrypt-api</artifactId>
|
||||
</dependency>
|
||||
<!--选配: mybatis 依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
|
||||
+7
-6
@@ -28,11 +28,12 @@ public class SequenceConfiguration {
|
||||
@Bean
|
||||
public Sequence flowSequence(DataSource dataSource, BaseSequenceProperties properties) {
|
||||
return DbSeqBuilder.create()
|
||||
.bizName(() -> String.format("flow_%s_%s", TenantContextHolder.getTenantId(), DateUtil.today()))
|
||||
.dataSource(dataSource)
|
||||
.step(properties.getStep())
|
||||
.retryTimes(properties.getDb().getRetryTimes())
|
||||
.tableName(properties.getDb().getTableName())
|
||||
.build();
|
||||
.bizName(() -> String.format("flow_%s_%s", TenantContextHolder.getTenantId(), DateUtil.today()))
|
||||
.dataSource(dataSource)
|
||||
.step(properties.getStep())
|
||||
.retryTimes(properties.getDb().getRetryTimes())
|
||||
.tableName(properties.getDb().getTableName())
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
+10
-21
@@ -1,7 +1,6 @@
|
||||
package com.pig4cloud.pigx.flow.task.controller;
|
||||
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.security.annotation.Inner;
|
||||
import com.pig4cloud.pigx.flow.task.dto.ProcessInstanceParamDto;
|
||||
import com.pig4cloud.pigx.flow.task.dto.TaskQueryParamDto;
|
||||
import com.pig4cloud.pigx.flow.task.service.IProcessInstanceService;
|
||||
@@ -32,23 +31,11 @@ public class ProcessInstanceController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动内部流程实例
|
||||
* 查询挖矿任务
|
||||
*
|
||||
* @param processInstanceParamDto 进程实例参数 DTO
|
||||
* @param queryParamDto Query param DTO
|
||||
* @return {@link R }
|
||||
*/
|
||||
@Inner
|
||||
@SneakyThrows
|
||||
@PostMapping("startInnerProcessInstance")
|
||||
public R startInnerProcessInstance(@RequestBody ProcessInstanceParamDto processInstanceParamDto) {
|
||||
return processInstanceService.startProcessInstance(processInstanceParamDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前登录用户的待办任务
|
||||
* @param pageDto
|
||||
* @return
|
||||
*/
|
||||
@SneakyThrows
|
||||
@PostMapping("queryMineTask")
|
||||
public R queryMineTask(@RequestBody TaskQueryParamDto queryParamDto) {
|
||||
@@ -67,9 +54,10 @@ public class ProcessInstanceController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询我发起的
|
||||
* @param pageDto
|
||||
* @return
|
||||
* 查询我已启动
|
||||
*
|
||||
* @param taskQueryParamDto task query param dto
|
||||
* @return {@link R }
|
||||
*/
|
||||
@SneakyThrows
|
||||
@PostMapping("queryMineStarted")
|
||||
@@ -78,9 +66,10 @@ public class ProcessInstanceController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询抄送我的
|
||||
* @param pageDto
|
||||
* @return
|
||||
* 查询我 CC
|
||||
*
|
||||
* @param taskQueryParamDto task query param dto
|
||||
* @return {@link R }
|
||||
*/
|
||||
@SneakyThrows
|
||||
@PostMapping("queryMineCC")
|
||||
|
||||
-2
@@ -1,7 +1,6 @@
|
||||
package com.pig4cloud.pigx.flow.task.controller;
|
||||
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.security.annotation.Inner;
|
||||
import com.pig4cloud.pigx.flow.task.dto.Node;
|
||||
import com.pig4cloud.pigx.flow.task.dto.ProcessNodeDataDto;
|
||||
import com.pig4cloud.pigx.flow.task.service.IProcessNodeDataService;
|
||||
@@ -39,7 +38,6 @@ public class ProcessNodeDataController {
|
||||
* @param nodeId
|
||||
* @return
|
||||
*/
|
||||
@Inner
|
||||
@GetMapping("getNodeData")
|
||||
public R<Node> getNodeData(String flowId, String nodeId) {
|
||||
return processNodeDataService.getNodeData(flowId, nodeId);
|
||||
|
||||
+11
-19
@@ -1,7 +1,6 @@
|
||||
package com.pig4cloud.pigx.flow.task.controller;
|
||||
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.security.annotation.Inner;
|
||||
import com.pig4cloud.pigx.flow.task.dto.*;
|
||||
import com.pig4cloud.pigx.flow.task.service.IRemoteService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -92,8 +91,7 @@ public class RemoteController {
|
||||
* @param recordParamDto
|
||||
* @return
|
||||
*/
|
||||
@Inner
|
||||
@PostMapping("/startNodeEvent")
|
||||
@PostMapping("startNodeEvent")
|
||||
public R startNodeEvent(@RequestBody ProcessNodeRecordParamDto recordParamDto) {
|
||||
return remoteService.startNodeEvent(recordParamDto);
|
||||
}
|
||||
@@ -104,7 +102,6 @@ public class RemoteController {
|
||||
* @param processInstanceRecordParamDto
|
||||
* @return
|
||||
*/
|
||||
@Inner
|
||||
@PostMapping("createProcessEvent")
|
||||
public R createProcessEvent(@RequestBody ProcessInstanceRecordParamDto processInstanceRecordParamDto) {
|
||||
return remoteService.createProcessEvent(processInstanceRecordParamDto);
|
||||
@@ -116,7 +113,6 @@ public class RemoteController {
|
||||
* @param recordParamDto
|
||||
* @return
|
||||
*/
|
||||
@Inner
|
||||
@PostMapping("endNodeEvent")
|
||||
public R endNodeEvent(@RequestBody ProcessNodeRecordParamDto recordParamDto) {
|
||||
return remoteService.endNodeEvent(recordParamDto);
|
||||
@@ -128,7 +124,6 @@ public class RemoteController {
|
||||
* @param processNodeRecordAssignUserParamDto
|
||||
* @return
|
||||
*/
|
||||
@Inner
|
||||
@PostMapping("startAssignUser")
|
||||
public R startAssignUser(@RequestBody ProcessNodeRecordAssignUserParamDto processNodeRecordAssignUserParamDto) {
|
||||
return remoteService.startAssignUser(processNodeRecordAssignUserParamDto);
|
||||
@@ -140,7 +135,6 @@ public class RemoteController {
|
||||
* @param processNodeRecordAssignUserParamDto
|
||||
* @return
|
||||
*/
|
||||
@Inner
|
||||
@PostMapping("taskEndEvent")
|
||||
public R taskEndEvent(@RequestBody ProcessNodeRecordAssignUserParamDto processNodeRecordAssignUserParamDto) {
|
||||
return remoteService.taskEndEvent(processNodeRecordAssignUserParamDto);
|
||||
@@ -148,24 +142,22 @@ public class RemoteController {
|
||||
|
||||
/**
|
||||
* 实例结束
|
||||
*
|
||||
* @param processInstanceParamDto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("endProcess")
|
||||
public R endProcess(@RequestBody ProcessInstanceParamDto processInstanceParamDto) {
|
||||
return remoteService.endProcess(processInstanceParamDto.getProcessInstanceId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询流程管理员
|
||||
*
|
||||
* @param flowId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("queryProcessAdmin")
|
||||
public R<Long> queryProcessAdmin(String flowId) {
|
||||
return remoteService.queryProcessAdmin(flowId);
|
||||
}
|
||||
/**
|
||||
* 查询流程管理员
|
||||
* @param flowId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("queryProcessAdmin")
|
||||
public R<Long> queryProcessAdmin(String flowId) {
|
||||
return remoteService.queryProcessAdmin(flowId);
|
||||
}
|
||||
|
||||
}
|
||||
+37
-17
@@ -39,8 +39,12 @@ public class CombinationGroupServiceImpl implements ICombinationGroupService {
|
||||
*/
|
||||
@Override
|
||||
public R listGroupWithProcess(Page page, Long groupId) {
|
||||
return R.ok(processService.lambdaQuery().eq(Process::getGroupId, groupId).eq(Process::getHidden, false)
|
||||
.orderByAsc(Process::getSort).orderByDesc(Process::getCreateTime).page(page));
|
||||
return R.ok(processService.lambdaQuery()
|
||||
.eq(Process::getGroupId, groupId)
|
||||
.eq(Process::getHidden, false)
|
||||
.orderByAsc(Process::getSort)
|
||||
.orderByDesc(Process::getCreateTime)
|
||||
.page(page));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,16 +57,24 @@ public class CombinationGroupServiceImpl implements ICombinationGroupService {
|
||||
|
||||
List<FormGroupVo> formGroupVos = new LinkedList<>();
|
||||
|
||||
List<ProcessGroup> processGroupList = processGroupService.lambdaQuery().orderByAsc(ProcessGroup::getSort)
|
||||
.list();
|
||||
List<ProcessGroup> processGroupList = processGroupService.lambdaQuery()
|
||||
.orderByAsc(ProcessGroup::getSort)
|
||||
.list();
|
||||
|
||||
processGroupList.forEach(group -> {
|
||||
FormGroupVo formGroupVo = FormGroupVo.builder().id(group.getId()).name(group.getGroupName())
|
||||
.items(new LinkedList<>()).build();
|
||||
FormGroupVo formGroupVo = FormGroupVo.builder()
|
||||
.id(group.getId())
|
||||
.name(group.getGroupName())
|
||||
.items(new LinkedList<>())
|
||||
.build();
|
||||
formGroupVos.add(formGroupVo);
|
||||
|
||||
List<Process> processList = processService.lambdaQuery().eq(Process::getGroupId, group.getId())
|
||||
.eq(Process::getHidden, YesNoEnum.NO.getCode()).eq(Process::getStop, YesNoEnum.NO.getCode()).orderByAsc(Process::getSort).list();
|
||||
List<Process> processList = processService.lambdaQuery()
|
||||
.eq(Process::getGroupId, group.getId())
|
||||
.eq(Process::getHidden, YesNoEnum.NO.getCode())
|
||||
.eq(Process::getStop, YesNoEnum.NO.getCode())
|
||||
.orderByAsc(Process::getSort)
|
||||
.list();
|
||||
|
||||
Map<Long, Boolean> existMap = new HashMap<>();
|
||||
|
||||
@@ -70,9 +82,10 @@ public class CombinationGroupServiceImpl implements ICombinationGroupService {
|
||||
List<Long> idList = processList.stream().map(Process::getId).collect(Collectors.toList());
|
||||
// 查询发起人集合
|
||||
List<ProcessStarter> processStarterList = processStarterService.lambdaQuery()
|
||||
.in(ProcessStarter::getProcessId, idList).list();
|
||||
.in(ProcessStarter::getProcessId, idList)
|
||||
.list();
|
||||
Map<Long, List<ProcessStarter>> groupmap = processStarterList.stream()
|
||||
.collect(Collectors.groupingBy(ProcessStarter::getProcessId));
|
||||
.collect(Collectors.groupingBy(ProcessStarter::getProcessId));
|
||||
|
||||
for (Process process : processList) {
|
||||
List<ProcessStarter> processStarters = groupmap.get(process.getId());
|
||||
@@ -80,15 +93,17 @@ public class CombinationGroupServiceImpl implements ICombinationGroupService {
|
||||
existMap.put(process.getId(), true);
|
||||
continue;
|
||||
}
|
||||
boolean match = processStarters.stream().anyMatch(w -> w.getTypeId().longValue() == user.getId()
|
||||
&& w.getType().equals(NodeUserTypeEnum.USER.getKey()));
|
||||
boolean match = processStarters.stream()
|
||||
.anyMatch(w -> w.getTypeId().longValue() == user.getId()
|
||||
&& w.getType().equals(NodeUserTypeEnum.USER.getKey()));
|
||||
if (match) {
|
||||
existMap.put(process.getId(), true);
|
||||
continue;
|
||||
}
|
||||
Set<Long> deptIdSet = processStarters.stream()
|
||||
.filter(w -> w.getType().equals(NodeUserTypeEnum.DEPT.getKey())).map(w -> w.getTypeId())
|
||||
.collect(Collectors.toSet());
|
||||
.filter(w -> w.getType().equals(NodeUserTypeEnum.DEPT.getKey()))
|
||||
.map(w -> w.getTypeId())
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
existMap.put(process.getId(), deptIdSet.contains(user.getDeptId()));
|
||||
|
||||
@@ -103,9 +118,14 @@ public class CombinationGroupServiceImpl implements ICombinationGroupService {
|
||||
}
|
||||
|
||||
formGroupVo.getItems()
|
||||
.add(FormGroupVo.FlowVo.builder().flowId(process.getFlowId()).name(process.getName())
|
||||
.logo(process.getLogo()).remark(process.getRemark()).stop(process.getStop())
|
||||
.updated(process.getUpdateTime()).build());
|
||||
.add(FormGroupVo.FlowVo.builder()
|
||||
.flowId(process.getFlowId())
|
||||
.name(process.getName())
|
||||
.logo(process.getLogo())
|
||||
.remark(process.getRemark())
|
||||
.stop(process.getStop())
|
||||
.updated(process.getUpdateTime())
|
||||
.build());
|
||||
});
|
||||
});
|
||||
return R.ok(formGroupVos);
|
||||
|
||||
+29
-85
@@ -1,15 +1,9 @@
|
||||
package com.pig4cloud.pigx.flow.task.service.impl;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.flow.task.constant.FormTypeEnum;
|
||||
import com.pig4cloud.pigx.flow.task.constant.ProcessInstanceConstant;
|
||||
import com.pig4cloud.pigx.flow.task.dto.Node;
|
||||
import com.pig4cloud.pigx.flow.task.entity.Process;
|
||||
import com.pig4cloud.pigx.flow.task.entity.ProcessCopy;
|
||||
@@ -17,13 +11,10 @@ import com.pig4cloud.pigx.flow.task.mapper.ProcessCopyMapper;
|
||||
import com.pig4cloud.pigx.flow.task.service.IProcessCopyService;
|
||||
import com.pig4cloud.pigx.flow.task.service.IProcessNodeDataService;
|
||||
import com.pig4cloud.pigx.flow.task.service.IProcessService;
|
||||
import com.pig4cloud.pigx.flow.task.vo.FormItemVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -38,86 +29,39 @@ import java.util.Map;
|
||||
@RequiredArgsConstructor
|
||||
public class ProcessCopyServiceImpl extends ServiceImpl<ProcessCopyMapper, ProcessCopy> implements IProcessCopyService {
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
private final IProcessService processService;
|
||||
private final IProcessService processService;
|
||||
|
||||
private final IProcessNodeDataService nodeDataService;
|
||||
private final IProcessNodeDataService nodeDataService;
|
||||
|
||||
/**
|
||||
* 查询单个抄送详细信息
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public R querySingleDetail(long id) {
|
||||
ProcessCopy processCopy = this.getById(id);
|
||||
String flowId = processCopy.getFlowId();
|
||||
Process oaForms = processService.getByFlowId(flowId);
|
||||
if (oaForms == null) {
|
||||
return R.failed("流程不存在");
|
||||
}
|
||||
String formData = processCopy.getFormData();
|
||||
/**
|
||||
* 查询单个抄送详细信息
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public R querySingleDetail(long id) {
|
||||
ProcessCopy processCopy = this.getById(id);
|
||||
String flowId = processCopy.getFlowId();
|
||||
Process oaForms = processService.getByFlowId(flowId);
|
||||
if (oaForms == null) {
|
||||
return R.failed("流程不存在");
|
||||
}
|
||||
String formData = processCopy.getFormData();
|
||||
String nodeId = processCopy.getNodeId();
|
||||
|
||||
Map<String, Object> variableMap = objectMapper.readValue(formData, new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
Node node = nodeDataService.getNodeData(flowId, nodeId).getData();
|
||||
Map<String, String> formPerms = node.getFormPerms();
|
||||
|
||||
String nodeId = processCopy.getNodeId();
|
||||
|
||||
Node node = nodeDataService.getNodeData(flowId, nodeId).getData();
|
||||
Map<String, String> formPerms = node.getFormPerms();
|
||||
|
||||
List<FormItemVO> jsonObjectList = objectMapper.readValue(oaForms.getFormItems(),
|
||||
new TypeReference<List<FormItemVO>>() {
|
||||
});
|
||||
for (FormItemVO formItemVO : jsonObjectList) {
|
||||
String fid = formItemVO.getId();
|
||||
String perm = formPerms.get(fid);
|
||||
formItemVO.setPerm(StrUtil.isBlankIfStr(perm) ? ProcessInstanceConstant.FormPermClass.HIDE : perm);
|
||||
|
||||
if (formItemVO.getType().equals(FormTypeEnum.LAYOUT.getType())) {
|
||||
// 明细
|
||||
|
||||
List<Map<String, Object>> subParamList = MapUtil.get(variableMap, fid,
|
||||
new cn.hutool.core.lang.TypeReference<List<Map<String, Object>>>() {
|
||||
});
|
||||
|
||||
Object value = formItemVO.getProps().getValue();
|
||||
|
||||
List<List<FormItemVO>> l = new ArrayList<>();
|
||||
for (Map<String, Object> map : subParamList) {
|
||||
List<FormItemVO> subItemList = Convert.toList(FormItemVO.class, value);
|
||||
for (FormItemVO itemVO : subItemList) {
|
||||
itemVO.getProps().setValue(map.get(itemVO.getId()));
|
||||
|
||||
String permSub = formPerms.get(itemVO.getId());
|
||||
if (StrUtil.isNotBlank(permSub)) {
|
||||
itemVO.setPerm(ProcessInstanceConstant.FormPermClass.EDIT.equals(permSub)
|
||||
? ProcessInstanceConstant.FormPermClass.READ : permSub
|
||||
|
||||
);
|
||||
|
||||
}
|
||||
else {
|
||||
itemVO.setPerm(ProcessInstanceConstant.FormPermClass.HIDE);
|
||||
}
|
||||
|
||||
}
|
||||
l.add(subItemList);
|
||||
}
|
||||
formItemVO.getProps().setValue(l);
|
||||
|
||||
}
|
||||
else {
|
||||
formItemVO.getProps().setValue(variableMap.get(fid));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Dict set = Dict.create().set("formItems", jsonObjectList);
|
||||
|
||||
return R.ok(set);
|
||||
}
|
||||
Dict set = Dict.create()
|
||||
.set("process", oaForms.getProcess())
|
||||
.set("formItems", oaForms.getFormItems())
|
||||
.set("formData", formData)
|
||||
.set("formPerms", formPerms);
|
||||
return R.ok(set);
|
||||
}
|
||||
|
||||
}
|
||||
+12
-61
@@ -2,9 +2,7 @@ package com.pig4cloud.pigx.flow.task.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -16,16 +14,13 @@ import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.security.service.PigxUser;
|
||||
import com.pig4cloud.pigx.common.security.util.SecurityUtils;
|
||||
import com.pig4cloud.pigx.flow.task.api.feign.RemoteFlowEngineService;
|
||||
import com.pig4cloud.pigx.flow.task.constant.FormTypeEnum;
|
||||
import com.pig4cloud.pigx.flow.task.constant.NodeStatusEnum;
|
||||
import com.pig4cloud.pigx.flow.task.constant.NodeUserTypeEnum;
|
||||
import com.pig4cloud.pigx.flow.task.constant.ProcessInstanceConstant;
|
||||
import com.pig4cloud.pigx.flow.task.dto.*;
|
||||
import com.pig4cloud.pigx.flow.task.entity.Process;
|
||||
import com.pig4cloud.pigx.flow.task.entity.*;
|
||||
import com.pig4cloud.pigx.flow.task.service.*;
|
||||
import com.pig4cloud.pigx.flow.task.utils.NodeFormatUtil;
|
||||
import com.pig4cloud.pigx.flow.task.vo.FormItemVO;
|
||||
import com.pig4cloud.pigx.flow.task.vo.NodeFormatParamVo;
|
||||
import com.pig4cloud.pigx.flow.task.vo.NodeVo;
|
||||
import com.pig4cloud.pigx.flow.task.vo.ProcessCopyVo;
|
||||
@@ -69,18 +64,16 @@ public class ProcessInstanceServiceImpl implements IProcessInstanceService {
|
||||
*/
|
||||
@Override
|
||||
public R startProcessInstance(ProcessInstanceParamDto processInstanceParamDto) {
|
||||
// 如果没有传递根节点(发起人),则根据当前用户初始化一个
|
||||
if (StrUtil.isBlank(processInstanceParamDto.getStartUserId())) {
|
||||
PigxUser user = SecurityUtils.getUser();
|
||||
processInstanceParamDto.setStartUserId(String.valueOf(user.getId()));
|
||||
Map<String, Object> paramMap = processInstanceParamDto.getParamMap();
|
||||
Dict rootUser = Dict.create()
|
||||
.set("id", user.getId())
|
||||
.set("name", user.getUsername())
|
||||
.set("type", NodeUserTypeEnum.USER.getKey());
|
||||
paramMap.put("root", CollUtil.newArrayList(rootUser));
|
||||
}
|
||||
|
||||
PigxUser user = SecurityUtils.getUser();
|
||||
|
||||
processInstanceParamDto.setStartUserId(String.valueOf(user.getId()));
|
||||
Map<String, Object> paramMap = processInstanceParamDto.getParamMap();
|
||||
Dict rootUser = Dict.create()
|
||||
.set("id", user.getId())
|
||||
.set("name", user.getUsername())
|
||||
.set("type", NodeUserTypeEnum.USER.getKey());
|
||||
paramMap.put("root", CollUtil.newArrayList(rootUser));
|
||||
return flowEngineService.startProcess(processInstanceParamDto);
|
||||
}
|
||||
|
||||
@@ -385,60 +378,18 @@ public class ProcessInstanceServiceImpl implements IProcessInstanceService {
|
||||
|
||||
// 发起人变量数据
|
||||
String formData = processInstanceRecord.getFormData();
|
||||
Map<String, Object> variableMap = objectMapper.readValue(formData, new TypeReference< Map<String, Object>>() {
|
||||
});
|
||||
// 发起人表单权限
|
||||
String process = oaForms.getProcess();
|
||||
|
||||
Node nodeDto = objectMapper.readValue(process, Node.class);
|
||||
Map<String, String> formPerms1 = nodeDto.getFormPerms();
|
||||
|
||||
List<FormItemVO> jsonObjectList = objectMapper.readValue(oaForms.getFormItems(), new TypeReference<List<FormItemVO>>() {
|
||||
});
|
||||
for (FormItemVO formItemVO : jsonObjectList) {
|
||||
String id = formItemVO.getId();
|
||||
String perm = formPerms1.get(id);
|
||||
|
||||
formItemVO.setPerm(StrUtil.isBlankIfStr(perm) ? ProcessInstanceConstant.FormPermClass.READ
|
||||
: (StrUtil.equals(perm, ProcessInstanceConstant.FormPermClass.HIDE) ? perm
|
||||
: ProcessInstanceConstant.FormPermClass.READ));
|
||||
|
||||
if (formItemVO.getType().equals(FormTypeEnum.LAYOUT.getType())) {
|
||||
// 明细
|
||||
List<Map<String, Object>> subParamList = MapUtil.get(variableMap, id,
|
||||
new cn.hutool.core.lang.TypeReference< List<Map<String, Object>>>() {
|
||||
});
|
||||
|
||||
Object value = formItemVO.getProps().getValue();
|
||||
|
||||
List<List<FormItemVO>> l = new ArrayList<>();
|
||||
for (Map<String, Object> map : subParamList) {
|
||||
List<FormItemVO> subItemList = Convert.toList(FormItemVO.class, value);
|
||||
for (FormItemVO itemVO : subItemList) {
|
||||
itemVO.getProps().setValue(map.get(itemVO.getId()));
|
||||
|
||||
String permSub = formPerms1.get(itemVO.getId());
|
||||
|
||||
itemVO.setPerm(StrUtil.isBlankIfStr(permSub) ? ProcessInstanceConstant.FormPermClass.READ
|
||||
: (StrUtil.equals(permSub, ProcessInstanceConstant.FormPermClass.HIDE) ? permSub
|
||||
: ProcessInstanceConstant.FormPermClass.READ));
|
||||
|
||||
}
|
||||
l.add(subItemList);
|
||||
}
|
||||
formItemVO.getProps().setValue(l);
|
||||
|
||||
} else {
|
||||
formItemVO.getProps().setValue(variableMap.get(id));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Dict set = Dict.create()
|
||||
.set("processInstanceId", processInstanceId)
|
||||
.set("process", oaForms.getProcess())
|
||||
|
||||
.set("formItems", jsonObjectList);
|
||||
.set("formItems", oaForms.getFormItems())
|
||||
.set("formData", formData)
|
||||
.set("formPerms", formPerms1);
|
||||
|
||||
return R.ok(set);
|
||||
}
|
||||
|
||||
+6
-3
@@ -45,11 +45,14 @@ public class ProcessNodeDataServiceImpl extends ServiceImpl<ProcessNodeDataMappe
|
||||
*/
|
||||
@Override
|
||||
public R<Node> getNodeData(String flowId, String nodeId) {
|
||||
Optional<ProcessNodeData> processNodeDataOptional = this.lambdaQuery().eq(ProcessNodeData::getFlowId, flowId)
|
||||
.eq(ProcessNodeData::getNodeId, nodeId).oneOpt();
|
||||
Optional<ProcessNodeData> processNodeDataOptional = this.lambdaQuery()
|
||||
.eq(ProcessNodeData::getFlowId, flowId)
|
||||
.eq(ProcessNodeData::getNodeId, nodeId)
|
||||
.oneOpt();
|
||||
|
||||
Node node = processNodeDataOptional
|
||||
.map(processNodeData -> JSONUtil.toBean(processNodeData.getData(), Node.class)).orElse(null);
|
||||
.map(processNodeData -> JSONUtil.toBean(processNodeData.getData(), Node.class))
|
||||
.orElse(null);
|
||||
|
||||
return R.ok(node);
|
||||
}
|
||||
|
||||
+13
-9
@@ -35,8 +35,10 @@ public class ProcessNodeRecordAssignUserServiceImpl
|
||||
public R addAssignUser(ProcessNodeRecordAssignUserParamDto processNodeRecordAssignUserParamDto) {
|
||||
if (StrUtil.isNotBlank(processNodeRecordAssignUserParamDto.getApproveDesc())) {
|
||||
ProcessNodeRecordAssignUser processNodeRecordAssignUser = this.lambdaQuery()
|
||||
.eq(ProcessNodeRecordAssignUser::getTaskId, processNodeRecordAssignUserParamDto.getTaskId())
|
||||
.orderByDesc(ProcessNodeRecordAssignUser::getId).last("limit 1").one();
|
||||
.eq(ProcessNodeRecordAssignUser::getTaskId, processNodeRecordAssignUserParamDto.getTaskId())
|
||||
.orderByDesc(ProcessNodeRecordAssignUser::getId)
|
||||
.last("limit 1")
|
||||
.one();
|
||||
if (processNodeRecordAssignUser != null) {
|
||||
processNodeRecordAssignUser.setApproveDesc(processNodeRecordAssignUserParamDto.getApproveDesc());
|
||||
processNodeRecordAssignUser.setTaskType(processNodeRecordAssignUserParamDto.getTaskType());
|
||||
@@ -48,7 +50,7 @@ public class ProcessNodeRecordAssignUserServiceImpl
|
||||
}
|
||||
|
||||
ProcessNodeRecordAssignUser processNodeRecordAssignUser = BeanUtil
|
||||
.copyProperties(processNodeRecordAssignUserParamDto, ProcessNodeRecordAssignUser.class);
|
||||
.copyProperties(processNodeRecordAssignUserParamDto, ProcessNodeRecordAssignUser.class);
|
||||
processNodeRecordAssignUser.setStartTime(LocalDateTime.now());
|
||||
processNodeRecordAssignUser.setStatus(NodeStatusEnum.JXZ.getCode());
|
||||
processNodeRecordAssignUser.setApproveDesc("");
|
||||
@@ -66,12 +68,14 @@ public class ProcessNodeRecordAssignUserServiceImpl
|
||||
@Override
|
||||
public R completeTaskEvent(ProcessNodeRecordAssignUserParamDto processNodeRecordAssignUserParamDto) {
|
||||
ProcessNodeRecordAssignUser processNodeRecordAssignUser = this.lambdaQuery()
|
||||
.eq(ProcessNodeRecordAssignUser::getTaskId, processNodeRecordAssignUserParamDto.getTaskId())
|
||||
.eq(ProcessNodeRecordAssignUser::getUserId, processNodeRecordAssignUserParamDto.getUserId())
|
||||
.eq(ProcessNodeRecordAssignUser::getProcessInstanceId,
|
||||
processNodeRecordAssignUserParamDto.getProcessInstanceId())
|
||||
.eq(ProcessNodeRecordAssignUser::getStatus, NodeStatusEnum.JXZ.getCode())
|
||||
.orderByDesc(ProcessNodeRecordAssignUser::getId).last("limit 1").one();
|
||||
.eq(ProcessNodeRecordAssignUser::getTaskId, processNodeRecordAssignUserParamDto.getTaskId())
|
||||
.eq(ProcessNodeRecordAssignUser::getUserId, processNodeRecordAssignUserParamDto.getUserId())
|
||||
.eq(ProcessNodeRecordAssignUser::getProcessInstanceId,
|
||||
processNodeRecordAssignUserParamDto.getProcessInstanceId())
|
||||
.eq(ProcessNodeRecordAssignUser::getStatus, NodeStatusEnum.JXZ.getCode())
|
||||
.orderByDesc(ProcessNodeRecordAssignUser::getId)
|
||||
.last("limit 1")
|
||||
.one();
|
||||
processNodeRecordAssignUser.setStatus(NodeStatusEnum.YJS.getCode());
|
||||
processNodeRecordAssignUser.setApproveDesc(processNodeRecordAssignUserParamDto.getApproveDesc());
|
||||
processNodeRecordAssignUser.setEndTime(LocalDateTime.now());
|
||||
|
||||
+6
-5
@@ -54,11 +54,12 @@ public class ProcessNodeRecordServiceImpl extends ServiceImpl<ProcessNodeRecordM
|
||||
log.info("节点结束---{}", processNodeRecordParamDto);
|
||||
|
||||
// TODO 完成节点和完成任务要区分下
|
||||
this.lambdaUpdate().set(ProcessNodeRecord::getStatus, NodeStatusEnum.YJS.getCode())
|
||||
.set(ProcessNodeRecord::getEndTime, new Date())
|
||||
.eq(ProcessNodeRecord::getProcessInstanceId, processNodeRecordParamDto.getProcessInstanceId())
|
||||
.eq(ProcessNodeRecord::getNodeId, processNodeRecordParamDto.getNodeId())
|
||||
.update(new ProcessNodeRecord());
|
||||
this.lambdaUpdate()
|
||||
.set(ProcessNodeRecord::getStatus, NodeStatusEnum.YJS.getCode())
|
||||
.set(ProcessNodeRecord::getEndTime, new Date())
|
||||
.eq(ProcessNodeRecord::getProcessInstanceId, processNodeRecordParamDto.getProcessInstanceId())
|
||||
.eq(ProcessNodeRecord::getNodeId, processNodeRecordParamDto.getNodeId())
|
||||
.update(new ProcessNodeRecord());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
+171
-179
@@ -2,10 +2,11 @@ package com.pig4cloud.pigx.flow.task.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@@ -14,7 +15,6 @@ import com.pig4cloud.pigx.common.security.util.SecurityUtils;
|
||||
import com.pig4cloud.pigx.common.sequence.sequence.Sequence;
|
||||
import com.pig4cloud.pigx.flow.task.api.feign.RemoteFlowEngineService;
|
||||
import com.pig4cloud.pigx.flow.task.constant.FormTypeEnum;
|
||||
import com.pig4cloud.pigx.flow.task.constant.ProcessInstanceConstant;
|
||||
import com.pig4cloud.pigx.flow.task.dto.Node;
|
||||
import com.pig4cloud.pigx.flow.task.dto.NodeUser;
|
||||
import com.pig4cloud.pigx.flow.task.entity.Process;
|
||||
@@ -32,6 +32,7 @@ import org.springframework.stereotype.Service;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -45,210 +46,201 @@ import java.util.Map;
|
||||
@RequiredArgsConstructor
|
||||
public class ProcessServiceImpl extends ServiceImpl<ProcessMapper, Process> implements IProcessService {
|
||||
|
||||
private final IProcessStarterService processStarterService;
|
||||
private final IProcessStarterService processStarterService;
|
||||
|
||||
private final RemoteFlowEngineService flowEngineService;
|
||||
private final RemoteFlowEngineService flowEngineService;
|
||||
|
||||
private final Sequence flowSequence;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
private final Sequence flowSequence;
|
||||
|
||||
/**
|
||||
* 获取详细数据
|
||||
* @param flowId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R<ProcessVO> getDetail(String flowId) {
|
||||
// 获取流程详情
|
||||
ProcessVO processVO = this.getProcessVO(flowId);
|
||||
return R.ok(processVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据流程ID获取流程详情
|
||||
* @param flowId 流程ID
|
||||
* @return 流程详情
|
||||
*/
|
||||
@SneakyThrows
|
||||
private ProcessVO getProcessVO(String flowId) {
|
||||
/**
|
||||
* 获取详细数据
|
||||
*
|
||||
* @param flowId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R<ProcessVO> getDetail(String flowId) {
|
||||
// 获取流程详情
|
||||
ProcessVO processVO = this.getProcessVO(flowId);
|
||||
return R.ok(processVO);
|
||||
}
|
||||
|
||||
Process oaForms = getByFlowId(flowId);
|
||||
String process = oaForms.getProcess();
|
||||
String formItems = oaForms.getFormItems();
|
||||
Node startNode = objectMapper.readValue(process, new TypeReference<Node>() {
|
||||
});
|
||||
/**
|
||||
* 根据流程ID获取流程详情
|
||||
*
|
||||
* @param flowId 流程ID
|
||||
* @return 流程详情
|
||||
*/
|
||||
@SneakyThrows
|
||||
private ProcessVO getProcessVO(String flowId) {
|
||||
|
||||
Map<String, String> formPerms = startNode.getFormPerms();
|
||||
Process oaForms = getByFlowId(flowId);
|
||||
String process = oaForms.getProcess();
|
||||
String formItems = oaForms.getFormItems();
|
||||
Node startNode = objectMapper.readValue(process, new TypeReference<Node>() {
|
||||
});
|
||||
|
||||
List<FormItemVO> formItemVOList = objectMapper.readValue(formItems, new TypeReference<List<FormItemVO>>() {
|
||||
});
|
||||
for (FormItemVO formItemVO : formItemVOList) {
|
||||
String perm = MapUtil.getStr(formPerms, formItemVO.getId(), ProcessInstanceConstant.FormPermClass.EDIT);
|
||||
formItemVO.setPerm(perm);
|
||||
List<String> selectUserNodeId = NodeUtil.selectUserNodeId(startNode);
|
||||
|
||||
// 发号器赋值
|
||||
if (StrUtil.equals(formItemVO.getType(), FormTypeEnum.SEQUENCE.getType())) {
|
||||
FormItemVO.Props props = formItemVO.getProps();
|
||||
String prefix = props.getPrefix();
|
||||
String nextNo = flowSequence.nextNo();
|
||||
formItemVO.setPlaceholder(StrUtil.isNotBlank(prefix) ? prefix + nextNo : nextNo);
|
||||
props.setValue(StrUtil.isNotBlank(prefix) ? prefix + nextNo : nextNo);
|
||||
formItemVO.setProps(props);
|
||||
}
|
||||
ProcessVO processVO = BeanUtil.copyProperties(oaForms, ProcessVO.class);
|
||||
processVO.setSelectUserNodeId(selectUserNodeId);
|
||||
|
||||
if (StrUtil.equals(formItemVO.getType(), FormTypeEnum.LAYOUT.getType())) {
|
||||
// 明细
|
||||
Object value = formItemVO.getProps().getValue();
|
||||
List<FormItemVO> subList = Convert.toList(FormItemVO.class, value);
|
||||
for (FormItemVO itemVO : subList) {
|
||||
String perm1 = MapUtil.getStr(formPerms, itemVO.getId(),
|
||||
ProcessInstanceConstant.FormPermClass.EDIT);
|
||||
itemVO.setPerm(perm1);
|
||||
}
|
||||
JSONArray formItemJsonArray = JSONUtil.parseArray(formItems);
|
||||
// 特殊字段复制
|
||||
for (Object object : formItemJsonArray) {
|
||||
if (object instanceof JSONObject) {
|
||||
JSONObject formVO = (JSONObject) object;
|
||||
JSONObject props = formVO.getJSONObject(FormItemVO.Fields.props);
|
||||
if (Objects.nonNull(props) && FormTypeEnum.SEQUENCE.getType().equals(props.getStr(FormItemVO.Fields.type))) {
|
||||
String nextNo = flowSequence.nextNo();
|
||||
props.set(FormItemVO.Props.Fields.value, nextNo);
|
||||
formVO.set(FormItemVO.Props.Fields.value, nextNo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
formItemVO.getProps().setValue(subList);
|
||||
formItemVO.getProps();
|
||||
}
|
||||
processVO.setFormItems(formItemJsonArray.toStringPretty());
|
||||
processVO.setFormPerms(startNode.getFormPerms());
|
||||
return processVO;
|
||||
}
|
||||
|
||||
}
|
||||
oaForms.setFormItems(objectMapper.writeValueAsString(formItemVOList));
|
||||
/**
|
||||
* 根据流程ID获取流程
|
||||
*
|
||||
* @param flowId 流程ID
|
||||
* @return 流程
|
||||
*/
|
||||
@Override
|
||||
public Process getByFlowId(String flowId) {
|
||||
return this.lambdaQuery().eq(Process::getFlowId, flowId).one();
|
||||
}
|
||||
|
||||
List<String> selectUserNodeId = NodeUtil.selectUserNodeId(startNode);
|
||||
/**
|
||||
* 更新流程
|
||||
*
|
||||
* @param process 流程
|
||||
*/
|
||||
@Override
|
||||
public void updateByFlowId(Process process) {
|
||||
this.lambdaUpdate().eq(Process::getFlowId, process.getFlowId()).update(process);
|
||||
}
|
||||
|
||||
ProcessVO processVO = BeanUtil.copyProperties(oaForms, ProcessVO.class);
|
||||
processVO.setSelectUserNodeId(selectUserNodeId);
|
||||
/**
|
||||
* 隐藏流程
|
||||
*
|
||||
* @param flowId 流程ID
|
||||
*/
|
||||
@Override
|
||||
public void hide(String flowId) {
|
||||
this.lambdaUpdate().set(Process::getHidden, true).eq(Process::getFlowId, flowId).update(new Process());
|
||||
}
|
||||
|
||||
return processVO;
|
||||
}
|
||||
/**
|
||||
* 创建流程
|
||||
*
|
||||
* @param process 流程
|
||||
* @return 操作结果
|
||||
*/
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public R create(Process process) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("process", process);
|
||||
map.put("userId", SecurityUtils.getUser().getId());
|
||||
R<String> r = flowEngineService.createFlow(map);
|
||||
if (!r.isOk()) {
|
||||
return R.failed(r.getMsg());
|
||||
}
|
||||
String flowId = r.getData();
|
||||
NodeUser nodeUser = objectMapper.readValue(process.getAdminList(), new TypeReference<List<NodeUser>>() {
|
||||
}).get(0);
|
||||
|
||||
/**
|
||||
* 根据流程ID获取流程
|
||||
* @param flowId 流程ID
|
||||
* @return 流程
|
||||
*/
|
||||
@Override
|
||||
public Process getByFlowId(String flowId) {
|
||||
return this.lambdaQuery().eq(Process::getFlowId, flowId).one();
|
||||
}
|
||||
// 更新流程
|
||||
if (StrUtil.isNotBlank(process.getFlowId())) {
|
||||
|
||||
/**
|
||||
* 更新流程
|
||||
* @param process 流程
|
||||
*/
|
||||
@Override
|
||||
public void updateByFlowId(Process process) {
|
||||
this.lambdaUpdate().eq(Process::getFlowId, process.getFlowId()).update(process);
|
||||
}
|
||||
Process oldProcess = this.getByFlowId(process.getFlowId());
|
||||
this.hide(process.getFlowId());
|
||||
// 修改所有的管理员
|
||||
this.lambdaUpdate()
|
||||
.set(Process::getAdminId, nodeUser.getId())
|
||||
.eq(Process::getUniqueId, oldProcess.getUniqueId())
|
||||
.update(new Process());
|
||||
|
||||
/**
|
||||
* 隐藏流程
|
||||
* @param flowId 流程ID
|
||||
*/
|
||||
@Override
|
||||
public void hide(String flowId) {
|
||||
this.lambdaUpdate().set(Process::getHidden, true).eq(Process::getFlowId, flowId).update(new Process());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建流程
|
||||
* @param process 流程
|
||||
* @return 操作结果
|
||||
*/
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public R create(Process process) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("process", process);
|
||||
map.put("userId", SecurityUtils.getUser().getId());
|
||||
R<String> r = flowEngineService.createFlow(map);
|
||||
if (!r.isOk()) {
|
||||
return R.failed(r.getMsg());
|
||||
}
|
||||
String flowId = r.getData();
|
||||
NodeUser nodeUser = objectMapper.readValue(process.getAdminList(), new TypeReference<List<NodeUser>>() {
|
||||
}).get(0);
|
||||
Node startNode = objectMapper.readValue(process.getProcess(), Node.class);
|
||||
|
||||
// 更新流程
|
||||
if (StrUtil.isNotBlank(process.getFlowId())) {
|
||||
List<NodeUser> nodeUserList = startNode.getNodeUserList();
|
||||
|
||||
Process oldProcess = this.getByFlowId(process.getFlowId());
|
||||
this.hide(process.getFlowId());
|
||||
// 修改所有的管理员
|
||||
this.lambdaUpdate().set(Process::getAdminId, nodeUser.getId())
|
||||
.eq(Process::getUniqueId, oldProcess.getUniqueId()).update(new Process());
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
if (CollUtil.isNotEmpty(nodeUserList)) {
|
||||
int index = 0;
|
||||
|
||||
}
|
||||
for (NodeUser user : nodeUserList) {
|
||||
if (index > 0) {
|
||||
stringBuilder.append(",");
|
||||
}
|
||||
stringBuilder.append(user.getName());
|
||||
index++;
|
||||
if (index > 5) {
|
||||
break;
|
||||
}
|
||||
|
||||
Node startNode = objectMapper.readValue(process.getProcess(), Node.class);
|
||||
}
|
||||
}
|
||||
|
||||
List<NodeUser> nodeUserList = startNode.getNodeUserList();
|
||||
Process p = new Process();
|
||||
p.setFlowId(flowId);
|
||||
p.setName(process.getName());
|
||||
p.setLogo(process.getLogo());
|
||||
p.setSettings(process.getSettings());
|
||||
p.setGroupId(process.getGroupId());
|
||||
p.setFormItems(process.getFormItems());
|
||||
p.setProcess(process.getProcess());
|
||||
p.setRemark(process.getRemark());
|
||||
p.setSort(0);
|
||||
p.setHidden("0");
|
||||
p.setStop("0");
|
||||
p.setAdminId(nodeUser.getId());
|
||||
p.setUniqueId(IdUtil.fastSimpleUUID());
|
||||
p.setAdminList(process.getAdminList());
|
||||
p.setRangeShow(stringBuilder.toString());
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
if (CollUtil.isNotEmpty(nodeUserList)) {
|
||||
int index = 0;
|
||||
this.save(p);
|
||||
|
||||
for (NodeUser user : nodeUserList) {
|
||||
if (index > 0) {
|
||||
stringBuilder.append(",");
|
||||
}
|
||||
stringBuilder.append(user.getName());
|
||||
index++;
|
||||
if (index > 5) {
|
||||
break;
|
||||
}
|
||||
// 保存范围
|
||||
for (NodeUser nodeUserDto : nodeUserList) {
|
||||
ProcessStarter processStarter = new ProcessStarter();
|
||||
|
||||
}
|
||||
}
|
||||
processStarter.setProcessId(p.getId());
|
||||
processStarter.setTypeId(nodeUserDto.getId());
|
||||
processStarter.setType(nodeUserDto.getType());
|
||||
processStarterService.save(processStarter);
|
||||
}
|
||||
|
||||
Process p = new Process();
|
||||
p.setFlowId(flowId);
|
||||
p.setName(process.getName());
|
||||
p.setLogo(process.getLogo());
|
||||
p.setSettings(process.getSettings());
|
||||
p.setGroupId(process.getGroupId());
|
||||
p.setFormItems(process.getFormItems());
|
||||
p.setProcess(process.getProcess());
|
||||
p.setRemark(process.getRemark());
|
||||
p.setSort(0);
|
||||
p.setHidden("0");
|
||||
p.setStop("0");
|
||||
p.setAdminId(nodeUser.getId());
|
||||
p.setUniqueId(IdUtil.fastSimpleUUID());
|
||||
p.setAdminList(process.getAdminList());
|
||||
p.setRangeShow(stringBuilder.toString());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
this.save(p);
|
||||
|
||||
// 保存范围
|
||||
for (NodeUser nodeUserDto : nodeUserList) {
|
||||
ProcessStarter processStarter = new ProcessStarter();
|
||||
|
||||
processStarter.setProcessId(p.getId());
|
||||
processStarter.setTypeId(nodeUserDto.getId());
|
||||
processStarter.setType(nodeUserDto.getType());
|
||||
processStarterService.save(processStarter);
|
||||
}
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑表单
|
||||
* @param flowId 流程ID
|
||||
* @param type 类型 stop using delete
|
||||
* @param groupId 分组ID
|
||||
* @return 操作结果
|
||||
*/
|
||||
@Override
|
||||
public R update(String flowId, String type, Long groupId) {
|
||||
Process process = new Process();
|
||||
process.setFlowId(flowId);
|
||||
process.setStop("stop".equals(type) ? "1" : "0");
|
||||
process.setHidden("delete".equals(type) ? "1" : "0");
|
||||
process.setGroupId(groupId);
|
||||
this.updateByFlowId(process);
|
||||
return R.ok();
|
||||
}
|
||||
/**
|
||||
* 编辑表单
|
||||
*
|
||||
* @param flowId 流程ID
|
||||
* @param type 类型 stop using delete
|
||||
* @param groupId 分组ID
|
||||
* @return 操作结果
|
||||
*/
|
||||
@Override
|
||||
public R update(String flowId, String type, Long groupId) {
|
||||
Process process = new Process();
|
||||
process.setFlowId(flowId);
|
||||
process.setStop("stop".equals(type) ? "1" : "0");
|
||||
process.setHidden("delete".equals(type) ? "1" : "0");
|
||||
process.setGroupId(groupId);
|
||||
this.updateByFlowId(process);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
+9
-4
@@ -73,13 +73,15 @@ public class RemoteServiceImpl implements IRemoteService {
|
||||
ThreadUtil.execute(() -> {
|
||||
try {
|
||||
ProcessInstanceRecord processInstanceRecord = processInstanceRecordService.lambdaQuery()
|
||||
.eq(ProcessInstanceRecord::getProcessInstanceId, processInstanceId).one();
|
||||
.eq(ProcessInstanceRecord::getProcessInstanceId, processInstanceId)
|
||||
.one();
|
||||
|
||||
int index = 10;
|
||||
while (index > 0 && processInstanceRecord == null) {
|
||||
TimeUnit.SECONDS.sleep(5);
|
||||
processInstanceRecord = processInstanceRecordService.lambdaQuery()
|
||||
.eq(ProcessInstanceRecord::getProcessInstanceId, processInstanceId).one();
|
||||
.eq(ProcessInstanceRecord::getProcessInstanceId, processInstanceId)
|
||||
.one();
|
||||
index--;
|
||||
}
|
||||
|
||||
@@ -128,8 +130,11 @@ public class RemoteServiceImpl implements IRemoteService {
|
||||
*/
|
||||
@Override
|
||||
public R<List<Long>> queryUserIdListByDepIdList(List<Long> depIdList) {
|
||||
List<Long> list = userService.getUserIdListByDeptIdList(depIdList).getData().stream().map(SysUser::getUserId)
|
||||
.collect(Collectors.toList());
|
||||
List<Long> list = userService.getUserIdListByDeptIdList(depIdList)
|
||||
.getData()
|
||||
.stream()
|
||||
.map(SysUser::getUserId)
|
||||
.toList();
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
|
||||
+185
-250
@@ -1,19 +1,14 @@
|
||||
package com.pig4cloud.pigx.flow.task.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.Dict;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.security.util.SecurityUtils;
|
||||
import com.pig4cloud.pigx.flow.task.api.feign.RemoteFlowEngineService;
|
||||
import com.pig4cloud.pigx.flow.task.constant.FormTypeEnum;
|
||||
import com.pig4cloud.pigx.flow.task.constant.NodeStatusEnum;
|
||||
import com.pig4cloud.pigx.flow.task.constant.ProcessInstanceConstant;
|
||||
import com.pig4cloud.pigx.flow.task.dto.IndexPageStatistics;
|
||||
import com.pig4cloud.pigx.flow.task.dto.Node;
|
||||
import com.pig4cloud.pigx.flow.task.dto.TaskParamDto;
|
||||
@@ -23,14 +18,12 @@ import com.pig4cloud.pigx.flow.task.entity.ProcessCopy;
|
||||
import com.pig4cloud.pigx.flow.task.entity.ProcessInstanceRecord;
|
||||
import com.pig4cloud.pigx.flow.task.entity.ProcessNodeRecordAssignUser;
|
||||
import com.pig4cloud.pigx.flow.task.service.*;
|
||||
import com.pig4cloud.pigx.flow.task.vo.FormItemVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -40,295 +33,237 @@ import java.util.stream.Collectors;
|
||||
@RequiredArgsConstructor
|
||||
public class TaskServiceImpl implements ITaskService {
|
||||
|
||||
private final RemoteFlowEngineService flowEngineService;
|
||||
private final RemoteFlowEngineService flowEngineService;
|
||||
|
||||
private final IProcessService processService;
|
||||
private final IProcessService processService;
|
||||
|
||||
private final IProcessCopyService processCopyService;
|
||||
private final IProcessCopyService processCopyService;
|
||||
|
||||
private final IProcessNodeDataService nodeDataService;
|
||||
private final IProcessNodeDataService nodeDataService;
|
||||
|
||||
private final IProcessNodeRecordAssignUserService processNodeRecordAssignUserService;
|
||||
private final IProcessNodeRecordAssignUserService processNodeRecordAssignUserService;
|
||||
|
||||
private final IProcessInstanceRecordService processInstanceRecordService;
|
||||
private final IProcessInstanceRecordService processInstanceRecordService;
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
/**
|
||||
* 查询首页数据看板
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R queryTaskData() {
|
||||
R<IndexPageStatistics> indexPageStatisticsR = flowEngineService
|
||||
.querySimpleData(SecurityUtils.getUser().getId());
|
||||
/**
|
||||
* 查询首页数据看板
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R queryTaskData() {
|
||||
R<IndexPageStatistics> indexPageStatisticsR = flowEngineService
|
||||
.querySimpleData(SecurityUtils.getUser().getId());
|
||||
|
||||
// 获取抄送任务
|
||||
Long copyCount = processCopyService.lambdaQuery().eq(ProcessCopy::getUserId, SecurityUtils.getUser().getId())
|
||||
.count();
|
||||
indexPageStatisticsR.getData().setCopyNum(copyCount);
|
||||
return indexPageStatisticsR;
|
||||
}
|
||||
// 获取抄送任务
|
||||
Long copyCount = processCopyService.lambdaQuery()
|
||||
.eq(ProcessCopy::getUserId, SecurityUtils.getUser().getId())
|
||||
.count();
|
||||
indexPageStatisticsR.getData().setCopyNum(copyCount);
|
||||
return indexPageStatisticsR;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询任务
|
||||
* @param taskId
|
||||
* @param view
|
||||
* @return
|
||||
*/
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public R queryTask(String taskId, boolean view) {
|
||||
/**
|
||||
* 查询任务
|
||||
*
|
||||
* @param taskId
|
||||
* @param view
|
||||
* @return
|
||||
*/
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public R queryTask(String taskId, boolean view) {
|
||||
|
||||
long userId = SecurityUtils.getUser().getId();
|
||||
long userId = SecurityUtils.getUser().getId();
|
||||
|
||||
R<TaskResultDto> r = flowEngineService.queryTask(taskId, userId);
|
||||
R<TaskResultDto> r = flowEngineService.queryTask(taskId, userId);
|
||||
|
||||
if (!r.isOk()) {
|
||||
return R.failed(r.getMsg());
|
||||
}
|
||||
if (!r.isOk()) {
|
||||
return R.failed(r.getMsg());
|
||||
}
|
||||
|
||||
TaskResultDto taskResultDto = r.getData();
|
||||
TaskResultDto taskResultDto = r.getData();
|
||||
|
||||
// 变量
|
||||
Map<String, Object> paramMap = taskResultDto.getVariableAll();
|
||||
// 是否是当前活动任务
|
||||
Boolean currentTask = taskResultDto.getCurrentTask();
|
||||
if (!currentTask) {
|
||||
ProcessNodeRecordAssignUser processNodeRecordAssignUser = processNodeRecordAssignUserService.lambdaQuery()
|
||||
.eq(ProcessNodeRecordAssignUser::getTaskId, taskId)
|
||||
.eq(ProcessNodeRecordAssignUser::getUserId, userId)
|
||||
.eq(ProcessNodeRecordAssignUser::getStatus, NodeStatusEnum.YJS.getCode()).last("limit 1")
|
||||
.orderByDesc(ProcessNodeRecordAssignUser::getEndTime).one();
|
||||
// 变量
|
||||
Map<String, Object> paramMap = taskResultDto.getVariableAll();
|
||||
// 是否是当前活动任务
|
||||
Boolean currentTask = taskResultDto.getCurrentTask();
|
||||
if (!currentTask) {
|
||||
ProcessNodeRecordAssignUser processNodeRecordAssignUser = processNodeRecordAssignUserService.lambdaQuery()
|
||||
.eq(ProcessNodeRecordAssignUser::getTaskId, taskId)
|
||||
.eq(ProcessNodeRecordAssignUser::getUserId, userId)
|
||||
.eq(ProcessNodeRecordAssignUser::getStatus, NodeStatusEnum.YJS.getCode())
|
||||
.last("limit 1")
|
||||
.orderByDesc(ProcessNodeRecordAssignUser::getEndTime)
|
||||
.one();
|
||||
|
||||
if (processNodeRecordAssignUser != null) {
|
||||
String data = processNodeRecordAssignUser.getData();
|
||||
if (StrUtil.isNotBlank(data)) {
|
||||
Map<String, Object> collect = objectMapper.readValue(data,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
paramMap.putAll(collect);
|
||||
if (processNodeRecordAssignUser != null) {
|
||||
String data = processNodeRecordAssignUser.getData();
|
||||
if (StrUtil.isNotBlank(data)) {
|
||||
Map<String, Object> collect = objectMapper.readValue(data, new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
paramMap.putAll(collect);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 当前节点数据
|
||||
Node node = nodeDataService.getNodeData(taskResultDto.getFlowId(), taskResultDto.getNodeId()).getData();
|
||||
Map<String, String> formPerms = node.getFormPerms();
|
||||
// 当前节点数据
|
||||
Node node = nodeDataService.getNodeData(taskResultDto.getFlowId(), taskResultDto.getNodeId()).getData();
|
||||
Map<String, String> formPerms = node.getFormPerms();
|
||||
|
||||
Process oaForms = processService.getByFlowId(taskResultDto.getFlowId());
|
||||
if (oaForms == null) {
|
||||
return R.failed("流程不存在");
|
||||
}
|
||||
Process oaForms = processService.getByFlowId(taskResultDto.getFlowId());
|
||||
if (oaForms == null) {
|
||||
return R.failed("流程不存在");
|
||||
}
|
||||
|
||||
List<FormItemVO> formItemVOList = JSONUtil.toList(oaForms.getFormItems(), FormItemVO.class);
|
||||
for (FormItemVO formItemVO : formItemVOList) {
|
||||
Dict set = Dict.create()
|
||||
.set("processInstanceId", taskResultDto.getProcessInstanceId())
|
||||
.set("node", taskResultDto.getTaskNode())
|
||||
.set("process", oaForms.getProcess())
|
||||
.set("delegateAgain", taskResultDto.getDelegate())
|
||||
.set("delegationTask", StrUtil.equals(taskResultDto.getDelegationState(), "PENDING"))
|
||||
.set("formItems", oaForms.getFormItems())
|
||||
.set("formData", paramMap)
|
||||
.set("formPerms", formPerms);
|
||||
|
||||
String id = formItemVO.getId();
|
||||
return R.ok(set);
|
||||
}
|
||||
|
||||
String perm = formPerms.get(id);
|
||||
/**
|
||||
* 完成任务
|
||||
*
|
||||
* @param taskParamDto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R completeTask(TaskParamDto taskParamDto) {
|
||||
long userId = SecurityUtils.getUser().getId();
|
||||
taskParamDto.setUserId(String.valueOf(userId));
|
||||
|
||||
if (StrUtil.isNotBlank(perm)) {
|
||||
R r = flowEngineService.completeTask(taskParamDto);
|
||||
|
||||
formItemVO.setPerm(view ? (ProcessInstanceConstant.FormPermClass.EDIT.equals(perm)
|
||||
? ProcessInstanceConstant.FormPermClass.READ : perm) : perm);
|
||||
if (!r.isOk()) {
|
||||
return R.failed(r.getMsg());
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
formItemVO.setPerm(ProcessInstanceConstant.FormPermClass.HIDE);
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
if (formItemVO.getType().equals(FormTypeEnum.LAYOUT.getType())) {
|
||||
// 明细
|
||||
/**
|
||||
* 前加签
|
||||
*
|
||||
* @param taskParamDto
|
||||
* @return
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public R delegateTask(TaskParamDto taskParamDto) {
|
||||
|
||||
List<Map<String, Object>> subParamList = MapUtil.get(paramMap, id,
|
||||
new cn.hutool.core.lang.TypeReference<List<Map<String, Object>>>() {
|
||||
});
|
||||
taskParamDto.setUserId(SecurityUtils.getUser().getId().toString());
|
||||
|
||||
Object value = formItemVO.getProps().getValue();
|
||||
R r = flowEngineService.delegateTask(taskParamDto);
|
||||
if (!r.isOk()) {
|
||||
return R.failed(r.getMsg());
|
||||
}
|
||||
|
||||
List<List<FormItemVO>> l = new ArrayList<>();
|
||||
for (Map<String, Object> map : subParamList) {
|
||||
List<FormItemVO> subItemList = Convert.toList(FormItemVO.class, value);
|
||||
for (FormItemVO itemVO : subItemList) {
|
||||
itemVO.getProps().setValue(map.get(itemVO.getId()));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
String permSub = formPerms.get(itemVO.getId());
|
||||
if (StrUtil.isNotBlank(permSub)) {
|
||||
itemVO.setPerm(view ? (ProcessInstanceConstant.FormPermClass.EDIT.equals(permSub)
|
||||
? ProcessInstanceConstant.FormPermClass.READ : permSub) : permSub);
|
||||
/**
|
||||
* 加签完成任务
|
||||
*
|
||||
* @param taskParamDto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R resolveTask(TaskParamDto taskParamDto) {
|
||||
R r = flowEngineService.resolveTask(taskParamDto);
|
||||
if (!r.isOk()) {
|
||||
return R.failed(r.getMsg());
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
itemVO.setPerm(ProcessInstanceConstant.FormPermClass.HIDE);
|
||||
}
|
||||
|
||||
}
|
||||
l.add(subItemList);
|
||||
}
|
||||
formItemVO.getProps().setValue(l);
|
||||
{
|
||||
List<FormItemVO> subItemList = Convert.toList(FormItemVO.class, value);
|
||||
for (FormItemVO itemVO : subItemList) {
|
||||
|
||||
String permSub = formPerms.get(itemVO.getId());
|
||||
if (StrUtil.isNotBlank(permSub)) {
|
||||
|
||||
itemVO.setPerm(permSub);
|
||||
|
||||
}
|
||||
else {
|
||||
itemVO.setPerm(ProcessInstanceConstant.FormPermClass.HIDE);
|
||||
}
|
||||
|
||||
}
|
||||
formItemVO.getProps().setOriForm(subItemList);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
formItemVO.getProps().setValue(paramMap.get(id));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Dict set = Dict.create().set("processInstanceId", taskResultDto.getProcessInstanceId())
|
||||
.set("node", taskResultDto.getTaskNode()).set("process", oaForms.getProcess())
|
||||
.set("delegateAgain", taskResultDto.getDelegate())
|
||||
.set("delegationTask", StrUtil.equals(taskResultDto.getDelegationState(), "PENDING"))
|
||||
|
||||
.set("formItems", formItemVOList);
|
||||
|
||||
return R.ok(set);
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成任务
|
||||
* @param taskParamDto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R completeTask(TaskParamDto taskParamDto) {
|
||||
long userId = SecurityUtils.getUser().getId();
|
||||
taskParamDto.setUserId(String.valueOf(userId));
|
||||
|
||||
R r = flowEngineService.completeTask(taskParamDto);
|
||||
|
||||
if (!r.isOk()) {
|
||||
return R.failed(r.getMsg());
|
||||
}
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 前加签
|
||||
* @param taskParamDto
|
||||
* @return
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public R delegateTask(TaskParamDto taskParamDto) {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置执行人
|
||||
*
|
||||
* @param taskParamDto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R setAssignee(TaskParamDto taskParamDto) {
|
||||
taskParamDto.setUserId(SecurityUtils.getUser().getId().toString());
|
||||
R r = flowEngineService.transferTask(taskParamDto);
|
||||
if (!r.isOk()) {
|
||||
return R.failed(r.getMsg());
|
||||
}
|
||||
|
||||
R r = flowEngineService.delegateTask(taskParamDto);
|
||||
if (!r.isOk()) {
|
||||
return R.failed(r.getMsg());
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
/**
|
||||
* 结束流程
|
||||
*
|
||||
* @param taskParamDto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R stopProcessInstance(TaskParamDto taskParamDto) {
|
||||
|
||||
/**
|
||||
* 加签完成任务
|
||||
* @param taskParamDto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R resolveTask(TaskParamDto taskParamDto) {
|
||||
R r = flowEngineService.resolveTask(taskParamDto);
|
||||
if (!r.isOk()) {
|
||||
return R.failed(r.getMsg());
|
||||
}
|
||||
String processInstanceId = taskParamDto.getProcessInstanceId();
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
List<String> allStopProcessInstanceIdList = getAllStopProcessInstanceIdList(processInstanceId);
|
||||
CollUtil.reverse(allStopProcessInstanceIdList);
|
||||
allStopProcessInstanceIdList.add(processInstanceId);
|
||||
|
||||
/**
|
||||
* 设置执行人
|
||||
* @param taskParamDto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R setAssignee(TaskParamDto taskParamDto) {
|
||||
taskParamDto.setUserId(SecurityUtils.getUser().getId().toString());
|
||||
R r = flowEngineService.setAssignee(taskParamDto);
|
||||
if (!r.isOk()) {
|
||||
return R.failed(r.getMsg());
|
||||
}
|
||||
taskParamDto.setProcessInstanceIdList(allStopProcessInstanceIdList);
|
||||
taskParamDto.setUserId(SecurityUtils.getUser().getId().toString());
|
||||
R r = flowEngineService.stopProcessInstance(taskParamDto);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
if (!r.isOk()) {
|
||||
return R.failed(r.getMsg());
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束流程
|
||||
* @param taskParamDto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R stopProcessInstance(TaskParamDto taskParamDto) {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
String processInstanceId = taskParamDto.getProcessInstanceId();
|
||||
/**
|
||||
* 退回
|
||||
*
|
||||
* @param taskParamDto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R back(TaskParamDto taskParamDto) {
|
||||
taskParamDto.setUserId(SecurityUtils.getUser().getId().toString());
|
||||
R r = flowEngineService.back(taskParamDto);
|
||||
if (!r.isOk()) {
|
||||
return R.failed(r.getMsg());
|
||||
}
|
||||
|
||||
List<String> allStopProcessInstanceIdList = getAllStopProcessInstanceIdList(processInstanceId);
|
||||
CollUtil.reverse(allStopProcessInstanceIdList);
|
||||
allStopProcessInstanceIdList.add(processInstanceId);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
taskParamDto.setProcessInstanceIdList(allStopProcessInstanceIdList);
|
||||
taskParamDto.setUserId(SecurityUtils.getUser().getId().toString());
|
||||
R r = flowEngineService.stopProcessInstance(taskParamDto);
|
||||
private List<String> getAllStopProcessInstanceIdList(String processInstanceId) {
|
||||
List<ProcessInstanceRecord> list = processInstanceRecordService.lambdaQuery()
|
||||
.eq(ProcessInstanceRecord::getParentProcessInstanceId, processInstanceId)
|
||||
.list();
|
||||
|
||||
if (!r.isOk()) {
|
||||
return R.failed(r.getMsg());
|
||||
}
|
||||
List<String> collect = list.stream().map(w -> w.getProcessInstanceId()).collect(Collectors.toList());
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
for (ProcessInstanceRecord processInstanceRecord : list) {
|
||||
List<String> allStopProcessInstanceIdList = getAllStopProcessInstanceIdList(
|
||||
processInstanceRecord.getProcessInstanceId());
|
||||
|
||||
/**
|
||||
* 退回
|
||||
* @param taskParamDto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public R back(TaskParamDto taskParamDto) {
|
||||
taskParamDto.setUserId(SecurityUtils.getUser().getId().toString());
|
||||
R r = flowEngineService.back(taskParamDto);
|
||||
if (!r.isOk()) {
|
||||
return R.failed(r.getMsg());
|
||||
}
|
||||
collect.addAll(allStopProcessInstanceIdList);
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
private List<String> getAllStopProcessInstanceIdList(String processInstanceId) {
|
||||
List<ProcessInstanceRecord> list = processInstanceRecordService.lambdaQuery()
|
||||
.eq(ProcessInstanceRecord::getParentProcessInstanceId, processInstanceId).list();
|
||||
|
||||
List<String> collect = list.stream().map(w -> w.getProcessInstanceId()).collect(Collectors.toList());
|
||||
|
||||
for (ProcessInstanceRecord processInstanceRecord : list) {
|
||||
List<String> allStopProcessInstanceIdList = getAllStopProcessInstanceIdList(
|
||||
processInstanceRecord.getProcessInstanceId());
|
||||
|
||||
collect.addAll(allStopProcessInstanceIdList);
|
||||
|
||||
}
|
||||
return collect;
|
||||
}
|
||||
}
|
||||
return collect;
|
||||
}
|
||||
|
||||
}
|
||||
+6
-4
@@ -40,8 +40,9 @@ public class DataUtil {
|
||||
List<SysDept> list = new ArrayList<>();
|
||||
list.add(allDeptList.stream().filter(w -> w.getDeptId() == deptId).findFirst().get());
|
||||
|
||||
List<SysDept> collect = allDeptList.stream().filter(w -> w.getParentId() == deptId)
|
||||
.collect(Collectors.toList());
|
||||
List<SysDept> collect = allDeptList.stream()
|
||||
.filter(w -> w.getParentId() == deptId)
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(collect)) {
|
||||
return list;
|
||||
}
|
||||
@@ -63,8 +64,9 @@ public class DataUtil {
|
||||
List<SysMenu> list = new ArrayList<>();
|
||||
list.add(allMenuList.stream().filter(w -> w.getMenuId() == menuId).findFirst().get());
|
||||
|
||||
List<SysMenu> collect = allMenuList.stream().filter(w -> w.getParentId() == menuId)
|
||||
.collect(Collectors.toList());
|
||||
List<SysMenu> collect = allMenuList.stream()
|
||||
.filter(w -> w.getParentId() == menuId)
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(collect)) {
|
||||
return list;
|
||||
}
|
||||
|
||||
+10
-2
@@ -8,6 +8,7 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.pig4cloud.pigx.admin.api.entity.SysUser;
|
||||
import com.pig4cloud.pigx.admin.api.feign.RemoteUserService;
|
||||
import com.pig4cloud.pigx.common.core.util.RetOps;
|
||||
import com.pig4cloud.pigx.common.security.util.SecurityUtils;
|
||||
import com.pig4cloud.pigx.flow.task.constant.NodeStatusEnum;
|
||||
import com.pig4cloud.pigx.flow.task.constant.NodeTypeEnum;
|
||||
@@ -101,12 +102,16 @@ public class NodeFormatUtil {
|
||||
List<ProcessNodeRecordAssignUser> value = entry.getValue();
|
||||
List<UserVo> collect = value.stream().map(w -> {
|
||||
UserVo userVo = buildUser(Long.parseLong(w.getUserId()));
|
||||
if (userVo == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
userVo.setShowTime(w.getEndTime());
|
||||
userVo.setApproveDesc(w.getApproveDesc());
|
||||
userVo.setStatus(w.getStatus());
|
||||
userVo.setOperType(w.getTaskType());
|
||||
return userVo;
|
||||
}).collect(Collectors.toList());
|
||||
}).filter(Objects::nonNull).collect(Collectors.toList());
|
||||
userVoList.addAll(collect);
|
||||
}
|
||||
|
||||
@@ -257,7 +262,10 @@ public class NodeFormatUtil {
|
||||
}
|
||||
|
||||
RemoteUserService userService = SpringUtil.getBean(RemoteUserService.class);
|
||||
SysUser user = userService.getUserById(CollUtil.newArrayList(userId)).getData().get(0);
|
||||
SysUser user = RetOps.of(userService.getUserById(CollUtil.newArrayList(userId)))
|
||||
.getData()
|
||||
.map(sysUsers -> sysUsers.isEmpty() ? null : sysUsers.get(0))
|
||||
.orElse(null);
|
||||
if (user == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user