|
@@ -8,6 +8,7 @@ import com.flow.common.core.exception.BaseException;
|
|
|
import com.flow.common.core.model.PageResult;
|
|
|
import com.flow.common.core.util.SecurityContextUtil;
|
|
|
import com.flow.common.mybatis.service.impl.BaseServiceImpl;
|
|
|
+import com.flow.common.redis.service.RedisService;
|
|
|
import com.flow.dao.FlowTaskDao;
|
|
|
import com.flow.entity.FlowDefine;
|
|
|
import com.flow.entity.FlowInstance;
|
|
@@ -62,6 +63,8 @@ public class FlowTaskServiceImpl extends BaseServiceImpl<FlowTaskDao, FlowTask>
|
|
|
private ManagementService managementService;
|
|
|
@Autowired
|
|
|
private RepositoryService repositoryService;
|
|
|
+ @Autowired
|
|
|
+ private RedisService redisService;
|
|
|
|
|
|
@Override
|
|
|
public PageResult<FlowTask> todo(FlowTaskQuery flowTaskQuery) {
|
|
@@ -188,7 +191,7 @@ public class FlowTaskServiceImpl extends BaseServiceImpl<FlowTaskDao, FlowTask>
|
|
|
}
|
|
|
// 回退节点
|
|
|
try {
|
|
|
- runtimeService.removeVariable(task.getProcessInstanceId(), String.format("_%s_", task.getTaskDefinitionKey()));
|
|
|
+ redisService.del(task.getProcessInstanceId());
|
|
|
managementService.executeCommand(new JumpActivityCmd(
|
|
|
task.getProcessInstanceId(),
|
|
|
taskForm.getTargetNode()
|
|
@@ -219,10 +222,8 @@ public class FlowTaskServiceImpl extends BaseServiceImpl<FlowTaskDao, FlowTask>
|
|
|
if (Objects.isNull(task)) {
|
|
|
throw new BaseException("任务不存在");
|
|
|
}
|
|
|
- Map<String, Object> variables = taskService.getVariables(task.getId());
|
|
|
TaskForm taskForm = new TaskForm();
|
|
|
taskForm.setTaskId(task.getId());
|
|
|
- taskForm.setValues(variables);
|
|
|
FlowComment flowComment = new FlowComment();
|
|
|
flowComment.setUserId("admin");
|
|
|
flowComment.setTime(new Date());
|
|
@@ -294,25 +295,22 @@ public class FlowTaskServiceImpl extends BaseServiceImpl<FlowTaskDao, FlowTask>
|
|
|
@Override
|
|
|
public void complete(TaskForm taskForm) {
|
|
|
Task task = this.comment(taskForm);
|
|
|
- DelegationState delegationState = task.getDelegationState();
|
|
|
Map<String, Object> localVariables = new HashMap<>();
|
|
|
Map<String, Object> variables = runtimeService.getVariables(task.getProcessInstanceId());
|
|
|
- Map<String, Object> values = taskForm.getValues();
|
|
|
- if (CollectionUtils.isNotEmpty(values)) {
|
|
|
- values.forEach((key, value) -> {
|
|
|
- if (variables.containsKey(key)) {
|
|
|
- Object obj = variables.get(key);
|
|
|
- if (Objects.nonNull(obj) && !obj.equals(value)) {
|
|
|
- localVariables.put(key, value);
|
|
|
- }
|
|
|
+ Map<String, Object> values = Optional.ofNullable(taskForm.getValues()).orElse(new HashMap<>());
|
|
|
+ values.forEach((key, value) -> {
|
|
|
+ if (variables.containsKey(key)) {
|
|
|
+ Object obj = variables.get(key);
|
|
|
+ if (Objects.nonNull(obj) && !obj.equals(value)) {
|
|
|
+ localVariables.put(key, value);
|
|
|
}
|
|
|
- });
|
|
|
- System.out.println("localVariables = " + localVariables);
|
|
|
- String assignee = SecurityContextUtil.getUserId();
|
|
|
- if (StringUtils.isNotBlank(assignee)) {
|
|
|
- localVariables.put(String.format("_%s_", assignee), task.getTaskDefinitionKey());
|
|
|
}
|
|
|
+ });
|
|
|
+ String assignee = SecurityContextUtil.getUserId();
|
|
|
+ if (StringUtils.isNotBlank(assignee)) {
|
|
|
+ redisService.hset(task.getProcessInstanceId(), assignee, task.getTaskDefinitionKey());
|
|
|
}
|
|
|
+ DelegationState delegationState = task.getDelegationState();
|
|
|
if (Objects.nonNull(delegationState) && delegationState == DelegationState.PENDING) {
|
|
|
taskService.resolveTask(
|
|
|
taskForm.getTaskId(),
|
|
@@ -345,7 +343,7 @@ public class FlowTaskServiceImpl extends BaseServiceImpl<FlowTaskDao, FlowTask>
|
|
|
if (Objects.isNull(task)) {
|
|
|
throw new BaseException("任务不存在");
|
|
|
}
|
|
|
- Map<String, Object> variables = taskService.getVariables(task.getId());
|
|
|
+ Map<String, Object> variables = new HashMap<>();
|
|
|
TaskForm taskForm = new TaskForm();
|
|
|
taskForm.setTaskId(task.getId());
|
|
|
taskForm.setValues(variables);
|