From 1a993a7899c2128e78975754502fba0993a8079e Mon Sep 17 00:00:00 2001
From: 疯狂的狮子Li <15040126243@163.com>
Date: 星期二, 12 十一月 2024 18:17:47 +0800
Subject: [PATCH] update 优化 xss包装器 Parameter 处理 兼容某些容器不允许改参数的情况
---
ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActTaskServiceImpl.java | 72 +++++++++++++++++++-----------------
1 files changed, 38 insertions(+), 34 deletions(-)
diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActTaskServiceImpl.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActTaskServiceImpl.java
index 5e9a050..d9a674a 100644
--- a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActTaskServiceImpl.java
+++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActTaskServiceImpl.java
@@ -7,12 +7,12 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
import org.dromara.common.core.domain.dto.RoleDTO;
import org.dromara.common.core.domain.dto.UserDTO;
-import org.dromara.common.core.domain.event.ProcessTaskEvent;
import org.dromara.common.core.exception.ServiceException;
+import org.dromara.common.core.service.OssService;
import org.dromara.common.core.service.UserService;
-import org.dromara.common.core.utils.ServletUtils;
import org.dromara.common.core.utils.StreamUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mybatis.core.page.PageQuery;
@@ -20,7 +20,7 @@
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.common.tenant.helper.TenantHelper;
import org.dromara.workflow.common.constant.FlowConstant;
-import org.dromara.workflow.common.enums.BusinessStatusEnum;
+import org.dromara.common.core.enums.BusinessStatusEnum;
import org.dromara.workflow.common.enums.TaskStatusEnum;
import org.dromara.workflow.domain.ActHiTaskinst;
import org.dromara.workflow.domain.WfTaskBackNode;
@@ -52,6 +52,7 @@
import org.flowable.task.api.history.HistoricTaskInstance;
import org.flowable.task.service.impl.persistence.entity.TaskEntity;
import org.flowable.variable.api.persistence.entity.VariableInstance;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -66,22 +67,29 @@
*
* @author may
*/
+@Slf4j
@RequiredArgsConstructor
@Service
public class ActTaskServiceImpl implements IActTaskService {
- private final RuntimeService runtimeService;
- private final TaskService taskService;
- private final HistoryService historyService;
- private final IdentityService identityService;
- private final ManagementService managementService;
+ @Autowired(required = false)
+ private RuntimeService runtimeService;
+ @Autowired(required = false)
+ private TaskService taskService;
+ @Autowired(required = false)
+ private HistoryService historyService;
+ @Autowired(required = false)
+ private IdentityService identityService;
+ @Autowired(required = false)
+ private ManagementService managementService;
private final ActTaskMapper actTaskMapper;
private final IWfTaskBackNodeService wfTaskBackNodeService;
private final ActHiTaskinstMapper actHiTaskinstMapper;
private final IWfNodeConfigService wfNodeConfigService;
private final IWfDefinitionConfigService wfDefinitionConfigService;
- private final UserService userService;
private final FlowProcessEventHandler flowProcessEventHandler;
+ private final UserService userService;
+ private final OssService ossService;
/**
* 鍚姩浠诲姟
@@ -177,7 +185,7 @@
return true;
}
//闄勪欢涓婁紶
- AttachmentCmd attachmentCmd = new AttachmentCmd(completeTaskBo.getFileId(), task.getId(), task.getProcessInstanceId());
+ AttachmentCmd attachmentCmd = new AttachmentCmd(completeTaskBo.getFileId(), task.getId(), task.getProcessInstanceId(), ossService);
managementService.executeCommand(attachmentCmd);
String businessStatus = WorkflowUtils.getBusinessStatus(processInstance.getBusinessKey());
//娴佺▼鎻愪氦鐩戝惉
@@ -186,8 +194,8 @@
}
runtimeService.updateBusinessStatus(task.getProcessInstanceId(), BusinessStatusEnum.WAITING.getStatus());
//鍔炵悊鐩戝惉
- String keyNode = processInstance.getProcessDefinitionKey() + "_" + task.getTaskDefinitionKey();
- flowProcessEventHandler.processTaskHandler(keyNode, task.getId(), processInstance.getBusinessKey());
+ flowProcessEventHandler.processTaskHandler(processInstance.getProcessDefinitionKey(), task.getTaskDefinitionKey(),
+ task.getId(), processInstance.getBusinessKey());
//鍔炵悊鎰忚
taskService.addComment(completeTaskBo.getTaskId(), task.getProcessInstanceId(), TaskStatusEnum.PASS.getStatus(), StringUtils.isBlank(completeTaskBo.getMessage()) ? "鍚屾剰" : completeTaskBo.getMessage());
//鍔炵悊浠诲姟
@@ -227,6 +235,7 @@
}
return true;
} catch (Exception e) {
+ log.error(e.getMessage(), e);
throw new ServiceException(e.getMessage());
}
}
@@ -241,7 +250,7 @@
*/
@Async
public void sendMessage(List<Task> list, String name, List<String> messageType, String message) {
- WorkflowUtils.sendMessage(list, name, messageType, message);
+ WorkflowUtils.sendMessage(list, name, messageType, message, userService);
}
/**
@@ -257,7 +266,8 @@
String userId = String.valueOf(LoginHelper.getUserId());
queryWrapper.eq("t.business_status_", BusinessStatusEnum.WAITING.getStatus());
queryWrapper.eq(TenantHelper.isEnable(), "t.tenant_id_", TenantHelper.getTenantId());
- queryWrapper.and(w1 -> w1.eq("t.assignee_", userId).or(w2 -> w2.isNull("t.assignee_").apply("exists ( select LINK.ID_ from ACT_RU_IDENTITYLINK LINK where LINK.TASK_ID_ = t.ID_ and LINK.TYPE_ = 'candidate' " + "and (LINK.USER_ID_ = {0} or ( LINK.GROUP_ID_ IN " + getInParam(roleIds) + " ) ))", userId)));
+ String ids = StreamUtils.join(roleIds, x -> "'" + x + "'");
+ queryWrapper.and(w1 -> w1.eq("t.assignee_", userId).or(w2 -> w2.isNull("t.assignee_").apply("exists ( select LINK.ID_ from ACT_RU_IDENTITYLINK LINK where LINK.TASK_ID_ = t.ID_ and LINK.TYPE_ = 'candidate' and (LINK.USER_ID_ = {0} or ( LINK.GROUP_ID_ IN (" + ids + ") ) ))", userId)));
if (StringUtils.isNotBlank(taskBo.getName())) {
queryWrapper.like("t.name_", taskBo.getName());
}
@@ -267,6 +277,7 @@
if (StringUtils.isNotBlank(taskBo.getProcessDefinitionKey())) {
queryWrapper.eq("t.processDefinitionKey", taskBo.getProcessDefinitionKey());
}
+ queryWrapper.orderByDesc("t.CREATE_TIME_");
Page<TaskVo> page = actTaskMapper.getTaskWaitByPage(pageQuery.build(), queryWrapper);
List<TaskVo> taskList = page.getRecords();
@@ -275,7 +286,7 @@
List<WfNodeConfigVo> wfNodeConfigVoList = wfNodeConfigService.selectByDefIds(processDefinitionIds);
for (TaskVo task : taskList) {
task.setBusinessStatusName(BusinessStatusEnum.findByStatus(task.getBusinessStatus()));
- task.setParticipantVo(WorkflowUtils.getCurrentTaskParticipant(task.getId()));
+ task.setParticipantVo(WorkflowUtils.getCurrentTaskParticipant(task.getId(), userService));
task.setMultiInstance(WorkflowUtils.isMultiInstance(task.getProcessDefinitionId(), task.getTaskDefinitionKey()) != null);
if (CollUtil.isNotEmpty(wfNodeConfigVoList)) {
wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && FlowConstant.TRUE.equals(e.getApplyUserTask())).findFirst().ifPresent(task::setWfNodeConfigVo);
@@ -284,19 +295,6 @@
}
}
return TableDataInfo.build(page);
- }
-
- private String getInParam(List<String> param) {
- StringBuilder sb = new StringBuilder();
- sb.append("(");
- for (int i = 0; i < param.size(); i++) {
- sb.append("'").append(param.get(i)).append("'");
- if (i != param.size() - 1) {
- sb.append(",");
- }
- }
- sb.append(")");
- return sb.toString();
}
/**
@@ -340,7 +338,7 @@
});
}
taskVo.setAssignee(StringUtils.isNotBlank(task.getAssignee()) ? Long.valueOf(task.getAssignee()) : null);
- taskVo.setParticipantVo(WorkflowUtils.getCurrentTaskParticipant(task.getId()));
+ taskVo.setParticipantVo(WorkflowUtils.getCurrentTaskParticipant(task.getId(), userService));
taskVo.setMultiInstance(WorkflowUtils.isMultiInstance(task.getProcessDefinitionId(), task.getTaskDefinitionKey()) != null);
if (CollUtil.isNotEmpty(wfNodeConfigVoList)) {
wfNodeConfigVoList.stream().filter(e -> e.getDefinitionId().equals(task.getProcessDefinitionId()) && FlowConstant.TRUE.equals(e.getApplyUserTask())).findFirst().ifPresent(taskVo::setWfNodeConfigVo);
@@ -369,6 +367,7 @@
queryWrapper.like(StringUtils.isNotBlank(taskBo.getProcessDefinitionName()), "t.processDefinitionName", taskBo.getProcessDefinitionName());
queryWrapper.eq(StringUtils.isNotBlank(taskBo.getProcessDefinitionKey()), "t.processDefinitionKey", taskBo.getProcessDefinitionKey());
queryWrapper.eq("t.assignee_", userId);
+ queryWrapper.orderByDesc("t.START_TIME_");
Page<TaskVo> page = actTaskMapper.getTaskFinishByPage(pageQuery.build(), queryWrapper);
List<TaskVo> taskList = page.getRecords();
@@ -405,6 +404,7 @@
queryWrapper.eq("t.processDefinitionKey", taskBo.getProcessDefinitionKey());
}
queryWrapper.eq("t.assignee_", userId);
+ queryWrapper.orderByDesc("t.START_TIME_");
Page<TaskVo> page = actTaskMapper.getTaskCopyByPage(pageQuery.build(), queryWrapper);
List<TaskVo> taskList = page.getRecords();
@@ -475,7 +475,7 @@
taskService.complete(newTask.getId());
return true;
} catch (Exception e) {
- e.printStackTrace();
+ log.error(e.getMessage(), e);
throw new ServiceException(e.getMessage());
}
}
@@ -545,7 +545,7 @@
taskService.setAssignee(task.getId(), transmitBo.getUserId());
return true;
} catch (Exception e) {
- e.printStackTrace();
+ log.error(e.getMessage(), e);
throw new ServiceException(e.getMessage());
}
}
@@ -593,7 +593,7 @@
taskService.complete(newTask.getId());
return true;
} catch (Exception e) {
- e.printStackTrace();
+ log.error(e.getMessage(), e);
throw new ServiceException(e.getMessage());
}
}
@@ -643,7 +643,7 @@
taskService.complete(newTask.getId());
return true;
} catch (Exception e) {
- e.printStackTrace();
+ log.error(e.getMessage(), e);
throw new ServiceException(e.getMessage());
}
}
@@ -692,7 +692,9 @@
MultiInstanceVo multiInstance = WorkflowUtils.isMultiInstance(task.getProcessDefinitionId(), task.getTaskDefinitionKey());
if (multiInstance == null && taskList.size() > 1) {
List<Task> tasks = StreamUtils.filter(taskList, e -> !e.getTaskDefinitionKey().equals(task.getTaskDefinitionKey()));
- actHiTaskinstMapper.deleteBatchIds(StreamUtils.toList(tasks, Task::getId));
+ if (CollUtil.isNotEmpty(tasks)) {
+ actHiTaskinstMapper.deleteByIds(StreamUtils.toList(tasks, Task::getId));
+ }
}
@@ -721,6 +723,7 @@
//鍒犻櫎椹冲洖鍚庣殑娴佺▼鑺傜偣
wfTaskBackNodeService.deleteBackTaskNode(processInstanceId, backProcessBo.getTargetActivityId());
} catch (Exception e) {
+ log.error(e.getMessage(), e);
throw new ServiceException(e.getMessage());
}
return task.getProcessInstanceId();
@@ -741,6 +744,7 @@
taskService.setAssignee(task.getId(), userId);
}
} catch (Exception e) {
+ log.error("淇敼澶辫触锛�" + e.getMessage(), e);
throw new ServiceException("淇敼澶辫触锛�" + e.getMessage());
}
return true;
--
Gitblit v1.9.3