|
|
@@ -89,6 +89,7 @@ import org.springblade.system.user.entity.User;
|
|
|
import org.springblade.system.user.feign.IUserClient;
|
|
|
import org.springblade.websocket.feign.WebSocketClient;
|
|
|
import org.springblade.websocket.vo.UserInfoVO;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.dao.DataAccessException;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
@@ -117,6 +118,7 @@ import java.util.regex.Matcher;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.IntStream;
|
|
|
|
|
|
+import static cn.hutool.core.util.ArrayUtil.join;
|
|
|
import static java.util.stream.Collectors.toMap;
|
|
|
|
|
|
@RestController
|
|
|
@@ -1221,268 +1223,833 @@ public class TaskController extends BladeController {
|
|
|
/**
|
|
|
* 分页查询
|
|
|
*/
|
|
|
+// @PostMapping("/page")
|
|
|
+// @ApiOperationSupport(order = 4)
|
|
|
+// @ApiOperation(value = "分页查询", notes = "传入TaskPageDTO")
|
|
|
+// public R<IPage<TaskPageVO>> page(@RequestBody TaskPageDTO dto) throws IOException {
|
|
|
+// if (ObjectUtil.isEmpty(dto.getProjectId()) || ObjectUtil.isEmpty(dto.getContractId())) {
|
|
|
+// throw new ServiceException("未获取到当前项目或合同段信息");
|
|
|
+// }
|
|
|
+// /*封装入参SQL*/
|
|
|
+// int current = dto.getCurrent();
|
|
|
+// int size = dto.getSize();
|
|
|
+// List<Object> params = new ArrayList<>();
|
|
|
+// StringBuilder sqlString = new StringBuilder("SELECT * FROM u_task WHERE 1=1 AND is_deleted = 0 AND approval_type in (5,6,7,11) "); //approval_type = 5 计量任务
|
|
|
+// Long userId1 = SecureUtil.getUserId();
|
|
|
+// List<Long> projectIdss = jdbcTemplate.query("select project_id from m_project_assignment_user where user_id=" + userId1, new SingleColumnRowMapper<>(Long.class));
|
|
|
+// sqlString.append(" AND project_id in(").append(StringUtils.join(projectIdss, ",")).append(")");
|
|
|
+//
|
|
|
+// if (ObjectUtil.isNotEmpty(dto.getTypeValue())) {
|
|
|
+// sqlString.append(" AND meter_task_type = ?");
|
|
|
+// params.add(dto.getTypeValue());
|
|
|
+// }
|
|
|
+// if (ObjectUtil.isNotEmpty(dto.getStatusValue())) {
|
|
|
+// if(dto.getStatusValue() .equals(4) ){//----先查询出所有待审批的 然后根据条件进行过滤出任务已经到当前登陆人的任务为可审批
|
|
|
+// sqlString.append(" AND status = 1");
|
|
|
+// }else {
|
|
|
+// sqlString.append(" AND status = ?");
|
|
|
+// params.add(dto.getStatusValue());
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if (ObjectUtil.isNotEmpty(dto.getBatchValue())) {
|
|
|
+// sqlString.append(" AND batch = ?");
|
|
|
+// params.add(dto.getBatchValue());
|
|
|
+// }
|
|
|
+// if (StringUtils.isNotBlank(dto.getStartTimeValue()) && StringUtils.isNotBlank(dto.getEndTimeValue())) {
|
|
|
+// sqlString.append(" AND start_time >= ?").append(" AND end_time <= ?");
|
|
|
+// params.add(dto.getStartTimeValue());
|
|
|
+// params.add(dto.getEndTimeValue());
|
|
|
+// }
|
|
|
+// if (StringUtils.isNotBlank(dto.getQueryValue())) {
|
|
|
+// sqlString.append(" AND task_name LIKE ?");
|
|
|
+// params.add("%" + dto.getQueryValue() + "%");
|
|
|
+// }
|
|
|
+// if (ObjectUtil.isNotEmpty(dto.getSelectedType())) {
|
|
|
+// sqlString.append(" AND (");
|
|
|
+// if (dto.getSelectedType().equals(1)) { //待办页面
|
|
|
+//
|
|
|
+// /*如果是待办页面,且 任务状态下拉框 选择的是 待审批或可审批状态 的任务,那么才查询数据*/
|
|
|
+// if (ObjectUtil.isNotEmpty(dto.getStatusValue()) && (dto.getStatusValue().equals(1) || dto.getStatusValue().equals(4))) {
|
|
|
+// sqlString.append("EXISTS (SELECT 1 FROM u_task_parallel WHERE u_task.process_instance_id = u_task_parallel.process_instance_id AND u_task_parallel.status = ? AND u_task_parallel.task_user = ?)");
|
|
|
+// params.add(1);
|
|
|
+// params.add(SecureUtil.getUserId());
|
|
|
+//
|
|
|
+// /*如果是待办页面,且 任务状态下拉框 选择的不是 待审批状态 的任务,那么直接返回null*/
|
|
|
+// } else if (ObjectUtil.isNotEmpty(dto.getStatusValue()) && !dto.getStatusValue().equals(1)) {
|
|
|
+// return null;
|
|
|
+//
|
|
|
+// /*如果是待办页面,没选择 任务状态下拉框,那么就默认查询 待审批状态 任务*/
|
|
|
+// } else if (ObjectUtil.isEmpty(dto.getStatusValue())) {
|
|
|
+// sqlString.append("EXISTS (SELECT 1 FROM u_task_parallel WHERE u_task.process_instance_id = u_task_parallel.process_instance_id AND u_task_parallel.status = ? AND u_task_parallel.task_user = ?)");
|
|
|
+// params.add(1);
|
|
|
+// params.add(SecureUtil.getUserId());
|
|
|
+// sqlString.append(" AND status = 1");
|
|
|
+// }
|
|
|
+//
|
|
|
+// } else if (dto.getSelectedType().equals(2)) { //已办页面
|
|
|
+// sqlString.append("EXISTS (SELECT 1 FROM u_task_parallel WHERE u_task.process_instance_id = u_task_parallel.process_instance_id AND u_task_parallel.status in(2,3) AND u_task_parallel.task_user = ?)");
|
|
|
+// /*当前自己的任务必须是已审批、已废除 status = 2,3 ,才视为已办*/
|
|
|
+// params.add(SecureUtil.getUserId());
|
|
|
+//
|
|
|
+// } else if (dto.getSelectedType().equals(3)) { //我发起页面
|
|
|
+// sqlString.append("report_user = ?");
|
|
|
+// params.add(SecureUtil.getUserId());
|
|
|
+// }
|
|
|
+// sqlString.append(")");
|
|
|
+// }
|
|
|
+//
|
|
|
+// /*总数量*/
|
|
|
+// String sqlCount = sqlString.toString().replace("*", "count(1)");
|
|
|
+// Optional<Integer> totalCountOptional = Optional.ofNullable(jdbcTemplate.queryForObject(sqlCount, Integer.class, params.toArray()));
|
|
|
+// int totalCount = totalCountOptional.orElse(0);
|
|
|
+//
|
|
|
+// /*分页*/
|
|
|
+// sqlString.append(" ORDER BY create_time DESC LIMIT ? OFFSET ?;");
|
|
|
+// params.add(size);
|
|
|
+// params.add((current - 1) * size);
|
|
|
+//
|
|
|
+// /*执行SQL获取数据*/
|
|
|
+// String sqlPage = sqlString.toString();
|
|
|
+// List<Task> resultList = jdbcTemplate.query(sqlPage, new BeanPropertyRowMapper<>(Task.class), params.toArray());
|
|
|
+//
|
|
|
+// /*获取任务详情信息Map*/
|
|
|
+// Set<String> processInstanceIds = resultList.stream().map(Task::getProcessInstanceId).collect(Collectors.toSet());
|
|
|
+// Map<String, List<TaskParallel>> taskParallelGroupMap = new HashMap<>();
|
|
|
+// if (processInstanceIds.size() > 0) {
|
|
|
+// String resultIds = processInstanceIds.stream().map(id -> "'" + id + "'").collect(Collectors.joining(","));
|
|
|
+// taskParallelGroupMap = jdbcTemplate.query("select process_instance_id,task_user,task_user_name,e_visa_status,e_visa_content,status,initiative,sort from u_task_parallel where process_instance_id in(" + resultIds + ") order by id", new BeanPropertyRowMapper<>(TaskParallel.class)).stream().collect(Collectors.groupingBy(TaskParallel::getProcessInstanceId));
|
|
|
+// }
|
|
|
+// Map<String, List<TaskParallel>> finalTaskParallelGroupMap = taskParallelGroupMap;
|
|
|
+//
|
|
|
+// /*获取用户信息Map*/
|
|
|
+// Map<Long, String> nameMap = jdbcTemplate.query("select id,name from blade_user where is_deleted = 0", new BeanPropertyRowMapper<>(User.class)).stream().collect(Collectors.toMap(User::getId, User::getName, (key1, key2) -> key1));
|
|
|
+// /*获取预设流程Map*/
|
|
|
+// // Map<Long, String> flowMap = jdbcTemplate.query("select id,fixed_flow_name from u_fixed_flow where is_deleted = 0 and contract_id = "+dto.getContractId(), new BeanPropertyRowMapper<>(FixedFlow.class)).stream().collect(Collectors.toMap(FixedFlow::getId, FixedFlow::getFixedFlowName, (key1, key2) -> key1));
|
|
|
+// Map<Long, String> flowMap = jdbcTemplate.query("select id,fixed_flow_name from u_fixed_flow where is_deleted = 0 ", new BeanPropertyRowMapper<>(FixedFlow.class)).stream().collect(Collectors.toMap(FixedFlow::getId, FixedFlow::getFixedFlowName, (key1, key2) -> key1));
|
|
|
+//
|
|
|
+// //筛选出可审批的数据
|
|
|
+// if(ObjectUtil.isNotEmpty(dto.getStatusValue()) && dto.getStatusValue() .equals(4) && ObjectUtil.isNotEmpty(resultList)){
|
|
|
+// //获取当前用户id
|
|
|
+// Long userId = AuthUtil.getUserId();
|
|
|
+//
|
|
|
+// String processIdsStr = resultList.stream().map(task -> task.getProcessInstanceId()).collect(Collectors.joining(","));
|
|
|
+// //查询出所有proccesId的数据转换成map map为processId键为u_task_papallel对象
|
|
|
+// Map<String, List<TaskParallel>> taskParallelMap = jdbcTemplate.query("select * from u_task_parallel where process_instance_id in (" + processIdsStr + ")", new BeanPropertyRowMapper<>(TaskParallel.class)).stream().collect(Collectors.groupingBy(TaskParallel::getProcessInstanceId));
|
|
|
+//
|
|
|
+// //根据条件过滤出可审批的数据(流程审批-非自定义流程) flowid为0的是自定义审批的流程
|
|
|
+// Map<Long, List<Task>> flowIdMaps = resultList.stream().filter(task->!"0".equals(task.getFixedFlowId().toString())).collect(Collectors.groupingBy(Task::getFixedFlowId));
|
|
|
+// if(ObjectUtil.isNotEmpty(flowIdMaps)){
|
|
|
+// String join = StringUtils.join(flowIdMaps.keySet(), ",");
|
|
|
+// //结果集所有数据
|
|
|
+// String sql = "select fixed_flow_id ,fixed_flow_branch_sort,fixed_flow_link_type,fixed_flow_link_sort from u_fixed_flow_link where is_deleted = 0 and fixed_flow_id in ( "+join+")";
|
|
|
+// List<FixedFlowLink> fixedFlowLinks = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(FixedFlowLink.class));
|
|
|
+// Map<Long, List<FixedFlowLink>> fixedsMap = fixedFlowLinks.stream().collect(Collectors.groupingBy(FixedFlowLink::getFixedFlowId));
|
|
|
+// for (Long l : flowIdMaps.keySet()) {
|
|
|
+// List<Task> tasks = flowIdMaps.get(l);
|
|
|
+// for (Task task : tasks) {
|
|
|
+// handleTaskParallel1(task,fixedsMap, taskParallelMap,userId, resultList);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// //自定义流程判断 查询出所有垂直审批的项目
|
|
|
+// //String sqlForchuizhi = "select id from m_project_info where approval_type = 1 and is_deleted = 0";
|
|
|
+// //目前默认所有项目都是垂直审批 上面的注释掉的是以后要用的内容 1为垂直审批2为流程审批
|
|
|
+// String sqlForchuizhi = "select id from m_project_info where is_deleted = 0";
|
|
|
+// List<Long> projectIds = jdbcTemplate.query(sqlForchuizhi, new BeanPropertyRowMapper<>(ProjectInfo.class)).stream().map(ProjectInfo::getId).collect(Collectors.toList());
|
|
|
+// if(ObjectUtil.isNotEmpty(projectIds)){
|
|
|
+// //所有自定义审批的任务
|
|
|
+// Set<Task> tasks = resultList.stream().filter(task -> "0".equals(task.getFixedFlowId().toString())).collect(Collectors.toSet());
|
|
|
+// if(ObjectUtil.isNotEmpty(tasks)){
|
|
|
+// for (Task task : tasks) {
|
|
|
+// if(projectIds.contains(Long.parseLong(task.getProjectId()))){
|
|
|
+// //是自定义垂直审批
|
|
|
+// handleTaskParallel(task, taskParallelMap,userId, resultList);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// /*解析page分页数据*/
|
|
|
+// IPage<TaskPageVO> page = new Page<>(current, size);
|
|
|
+// List<TaskPageVO> pageList = resultList.stream().map(task -> {
|
|
|
+// TaskPageVO vo = new TaskPageVO();
|
|
|
+// vo.setRejectDesc(task.getMeterTaskRepealDesc());
|
|
|
+// vo.setId(task.getId());
|
|
|
+// vo.setTaskName(task.getTaskName());
|
|
|
+// vo.setTaskTypeName(task.getType().equals(1) ? "普通任务" : task.getType().equals(2) ? "验收任务" : "移交任务");
|
|
|
+// vo.setTaskStatusName(task.getStatus().equals(1) ? "待审批" : task.getStatus().equals(2) ? "已审批" : "已废除");
|
|
|
+// vo.setStartTime(task.getStartTime());
|
|
|
+// vo.setEndTime(task.getEndTime());
|
|
|
+// vo.setType(task.getType());
|
|
|
+// vo.setMeterType(task.getMeterTaskType());
|
|
|
+// vo.setTaskDesc(task.getTaskContent());
|
|
|
+// vo.setTaskReportUserName(nameMap.get(Long.parseLong(task.getReportUser())));
|
|
|
+// vo.setFixedFlowId(ObjectUtil.isNotEmpty(task.getFixedFlowId()) ? task.getFixedFlowId().equals(0L) ? null : task.getFixedFlowId() : null);
|
|
|
+// vo.setFixedFlowName(vo.getFixedFlowId() == null ? "自定义流程" : flowMap.get(vo.getFixedFlowId()));
|
|
|
+// List<TaskParallel> taskParallelList = finalTaskParallelGroupMap.get(task.getProcessInstanceId());
|
|
|
+// if (taskParallelList != null && taskParallelList.size() > 0) {
|
|
|
+// List<String> names = taskParallelList.stream().map(TaskParallel::getTaskUserName).collect(Collectors.toList());
|
|
|
+// if (names.size() > 0) {
|
|
|
+// vo.setTaskApproveUserNames(StringUtils.join(names, ","));
|
|
|
+// }
|
|
|
+//
|
|
|
+// /*电签状态(始终只获取自己的电签任务状态信息)*/
|
|
|
+// TaskParallel taskParallel = taskParallelList.stream().filter(f -> ObjectUtil.isNotEmpty(f.getTaskUser()) && f.getTaskUser().equals(SecureUtil.getUserId().toString())).findAny().orElse(null);
|
|
|
+// if (taskParallel != null) {
|
|
|
+//// vo.setEVisaStatus((taskParallel.getEVisaContent() != null && !"null".equals(taskParallel.getEVisaContent())) ? taskParallel.getEVisaContent() : "");
|
|
|
+// if (taskParallel.getEVisaStatus() != null){
|
|
|
+// vo.setEVisaStatus(taskParallel.getEVisaStatus() == 1 ? "电签成功":(StringUtils.isBlank(taskParallel.getEVisaContent()) || "null".equals(taskParallel.getEVisaContent()))?"电签失败":taskParallel.getEVisaContent());
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// taskParallel = taskParallelList.get(0);
|
|
|
+// if (taskParallel.getEVisaStatus() != null){
|
|
|
+// vo.setEVisaStatus(taskParallel.getEVisaStatus() == 1 ? "电签成功":(StringUtils.isBlank(taskParallel.getEVisaContent()) || "null".equals(taskParallel.getEVisaContent()))?"电签失败":taskParallel.getEVisaContent());
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if (vo.getTaskStatusName().equals("已废除")) {
|
|
|
+// if (!"撤回成功".equals(vo.getEVisaStatus()) && !"驳回成功".equals(vo.getEVisaStatus())) {
|
|
|
+// vo.setEVisaStatus("废除成功");
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// /*判断签字人的验证 2=绿色 3=黄色 999=红色 其他代表=灰色*/
|
|
|
+// List<TaskParallel> statList = new ArrayList<>();
|
|
|
+// for (TaskParallel taskPa : taskParallelList) {
|
|
|
+// if (taskPa.getStatus() == 2 && ObjectUtil.isNotEmpty(taskPa.getEVisaStatus()) && taskPa.getEVisaStatus() == 1) {
|
|
|
+// taskPa.setEVisaStatus(2);
|
|
|
+// } else if (taskPa.getStatus() == 3) {
|
|
|
+// if (taskPa.getInitiative() == 2) {
|
|
|
+// taskPa.setEVisaStatus(3);
|
|
|
+// }
|
|
|
+// } else if (ObjectUtil.isNotEmpty(taskPa.getEVisaStatus()) && taskPa.getEVisaStatus() == 99) {
|
|
|
+// taskPa.setEVisaStatus(999);
|
|
|
+// } else {
|
|
|
+// taskPa.setEVisaStatus(1);
|
|
|
+// }
|
|
|
+// statList.add(taskPa);
|
|
|
+// }
|
|
|
+// if (statList.size() > 0) {
|
|
|
+// List<Object> objectList = statList.stream().map(taskPa -> (Object) taskPa).collect(Collectors.toList());
|
|
|
+// vo.setTaskApproveUserNamesList(objectList);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return vo;
|
|
|
+// }).collect(Collectors.toList());
|
|
|
+// Map<Long, Task> taskMap = new HashMap<>();
|
|
|
+// Map<String, List<OperationLog>> operationLogMap = new HashMap<>();
|
|
|
+// List<Long> taskIds = pageList.stream().filter(b -> "已废除".equals(b.getTaskStatusName())).map(TaskPageVO::getId).collect(Collectors.toList());
|
|
|
+// if (ObjectUtil.isNotEmpty(taskIds)){
|
|
|
+// String joinTaskIds = StringUtils.join(taskIds, ",");
|
|
|
+// List<Task> tasks = jdbcTemplate.query("select id, create_time,form_data_id from u_task where id in ( " + joinTaskIds+")", new BeanPropertyRowMapper<>(Task.class));
|
|
|
+// taskMap = tasks.stream()
|
|
|
+// .collect(Collectors.toMap(
|
|
|
+// Task::getId,
|
|
|
+// task -> task));
|
|
|
+// }
|
|
|
+//
|
|
|
+// //所有满足条件的日志 转map
|
|
|
+// //String logQuery = "select business_id,create_user_name ,create_time, operation_type from u_operation_log where operation_content like '%废除%'";
|
|
|
+// String logQuery="select business_id,create_user_name ,create_time, operation_type from u_operation_log where operation_type IN (6,9,26,61,62)";
|
|
|
+// List<OperationLog> operationLogs = jdbcTemplate.query(logQuery, new BeanPropertyRowMapper<>(OperationLog.class));
|
|
|
+// if(ObjectUtil.isNotEmpty(operationLogs)){
|
|
|
+// operationLogMap = operationLogs.stream().collect(Collectors.groupingBy(OperationLog::getBusinessId));
|
|
|
+// }
|
|
|
+// for (TaskPageVO businessTaskPageVO : pageList) {
|
|
|
+// if("已废除".equals(businessTaskPageVO.getTaskStatusName())){
|
|
|
+// Long taskId = businessTaskPageVO.getId();
|
|
|
+// Task task = taskMap.get(taskId);
|
|
|
+// if (ObjectUtil.isEmpty(task)){
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+// //任务创建时间
|
|
|
+// Date createTime = task.getCreateTime();
|
|
|
+// //废除时间肯定在任务创建时间之后 选择距离当前任务创建时间最近的一条数据
|
|
|
+// List<OperationLog> operationLogsF = operationLogMap.get(task.getFormDataId());
|
|
|
+//
|
|
|
+// if(ObjectUtil.isNotEmpty(operationLogsF)){
|
|
|
+// Optional<OperationLog> min = operationLogsF.stream().filter(o -> o.getCreateTime().compareTo(createTime) >= 0)
|
|
|
+// .min(Comparator.comparing(t -> t.getCreateTime().getTime() - createTime.getTime()));
|
|
|
+// if (min.isPresent()){
|
|
|
+// OperationLog operationLog = min.get();
|
|
|
+// if (operationLog.getOperationType() != null && operationLog.getOperationType() == 61) {
|
|
|
+// businessTaskPageVO.setEVisaStatus("驳回成功:"+operationLog.getCreateUserName()+"-"+operationLog.getCreateTime());
|
|
|
+// } else if (operationLog.getOperationType() != null && operationLog.getOperationType() == 62) {
|
|
|
+// businessTaskPageVO.setEVisaStatus("撤回成功:"+operationLog.getCreateUserName()+"-"+operationLog.getCreateTime());
|
|
|
+// } else {
|
|
|
+// businessTaskPageVO.setEVisaStatus(businessTaskPageVO.getEVisaStatus()+":"+operationLog.getCreateUserName()+"-"+operationLog.getCreateTime());
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// page.setRecords(pageList);
|
|
|
+// page.setTotal(totalCount);
|
|
|
+// return R.data(page);
|
|
|
+// }
|
|
|
+
|
|
|
@PostMapping("/page")
|
|
|
@ApiOperationSupport(order = 4)
|
|
|
@ApiOperation(value = "分页查询", notes = "传入TaskPageDTO")
|
|
|
public R<IPage<TaskPageVO>> page(@RequestBody TaskPageDTO dto) throws IOException {
|
|
|
+ // 1. 基础参数校验(保持原有逻辑)
|
|
|
if (ObjectUtil.isEmpty(dto.getProjectId()) || ObjectUtil.isEmpty(dto.getContractId())) {
|
|
|
throw new ServiceException("未获取到当前项目或合同段信息");
|
|
|
}
|
|
|
- /*封装入参SQL*/
|
|
|
- int current = dto.getCurrent();
|
|
|
- int size = dto.getSize();
|
|
|
+
|
|
|
+ // 2. 缓存当前用户ID(避免重复调用)
|
|
|
+ Long currentUserId = SecureUtil.getUserId();
|
|
|
+ if (currentUserId == null) {
|
|
|
+ throw new ServiceException("未获取到当前登录用户信息");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. 构建查询参数和SQL(优化参数化、减少拼接)
|
|
|
+ int current = dto.getCurrent() <= 0 ? 1 : dto.getCurrent();
|
|
|
+ int size = dto.getSize() <= 0 ? 10 : dto.getSize();
|
|
|
List<Object> params = new ArrayList<>();
|
|
|
- StringBuilder sqlString = new StringBuilder("SELECT * FROM u_task WHERE 1=1 AND is_deleted = 0 AND approval_type in (5,6,7,11) "); //approval_type = 5 计量任务
|
|
|
- Long userId1 = SecureUtil.getUserId();
|
|
|
- List<Long> projectIdss = jdbcTemplate.query("select project_id from m_project_assignment_user where user_id=" + userId1, new SingleColumnRowMapper<>(Long.class));
|
|
|
- sqlString.append(" AND project_id in(").append(StringUtils.join(projectIdss, ",")).append(")");
|
|
|
+ StringBuilder sqlBuilder = new StringBuilder()
|
|
|
+ .append("SELECT id, task_name, type, meter_task_type, status, start_time, end_time, ")
|
|
|
+ .append("task_content, report_user, fixed_flow_id, process_instance_id, ")
|
|
|
+ .append("meter_task_repeal_desc, form_data_id ")
|
|
|
+ .append("FROM u_task ")
|
|
|
+ .append("WHERE is_deleted = 0 ")
|
|
|
+ .append(" AND approval_type IN (5,6,7,11) ");
|
|
|
+ // 3.1 项目权限过滤(参数化IN条件,避免SQL注入和字符串拼接开销)
|
|
|
+ List<Long> projectIds = jdbcTemplate.query(
|
|
|
+ "SELECT project_id FROM m_project_assignment_user WHERE user_id = ?",
|
|
|
+ new SingleColumnRowMapper<>(Long.class), // 关键修改:替换BeanPropertyRowMapper为SingleColumnRowMapper
|
|
|
+ currentUserId
|
|
|
+ );
|
|
|
+ if (projectIds.isEmpty()) {
|
|
|
+ return R.data(new Page<>(current, size));
|
|
|
+ }
|
|
|
+ sqlBuilder.append(" AND project_id IN (").append(joinPlaceholders(projectIds.size())).append(")");
|
|
|
+ params.addAll(projectIds);
|
|
|
+
|
|
|
+ // 3.2 业务条件过滤(保持原有逻辑,统一参数化)
|
|
|
+ buildBusinessConditions(sqlBuilder, params, dto, currentUserId);
|
|
|
+
|
|
|
+ // 3.3 排序(保持原有逻辑)
|
|
|
+ sqlBuilder.append(" ORDER BY create_time DESC");
|
|
|
+
|
|
|
+ // 4. 分页查询主表数据(先查count,再查列表,避免重复计算)
|
|
|
+ long totalCount = countTotal(sqlBuilder.toString(), params);
|
|
|
+ if (totalCount == 0) {
|
|
|
+ return R.data(new Page<>(current, size));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 4.1 分页参数(LIMIT OFFSET保持原有,大数据量可考虑游标分页)
|
|
|
+ sqlBuilder.append(" LIMIT ? OFFSET ?");
|
|
|
+ params.add(size);
|
|
|
+ params.add((current - 1) * size);
|
|
|
+
|
|
|
+ // 4.2 查询主表核心数据(只查需要的字段,减少数据传输)
|
|
|
+ List<Task> taskList = jdbcTemplate.query(
|
|
|
+ sqlBuilder.toString(),
|
|
|
+ new BeanPropertyRowMapper<>(Task.class),
|
|
|
+ params.toArray()
|
|
|
+ );
|
|
|
+ if (taskList.isEmpty()) {
|
|
|
+ return R.data(new Page<>(current, size));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 5. 批量获取关联数据(减少数据库交互次数)
|
|
|
+ Map<String, List<TaskParallel>> taskParallelMap = getTaskParallelMap(taskList);
|
|
|
+ Map<Long, String> userNameMap = getUserNameMap(taskList, taskParallelMap);
|
|
|
+ Map<Long, String> flowNameMap = getFlowNameMap(taskList);
|
|
|
+ Map<String, List<OperationLog>> operationLogMap = getOperationLogMap(taskList);
|
|
|
|
|
|
+ // 6. 处理可审批数据过滤(优化循环逻辑,减少重复判断)
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getStatusValue()) && dto.getStatusValue().equals(4)) {
|
|
|
+ filterApprovalAbleTasks(taskList, taskParallelMap, currentUserId);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 7. 转换VO(合并stream处理,减少循环)
|
|
|
+ List<TaskPageVO> voList = convertToVOList(
|
|
|
+ taskList, taskParallelMap, userNameMap, flowNameMap, operationLogMap, currentUserId
|
|
|
+ );
|
|
|
+
|
|
|
+ // 8. 构建分页结果
|
|
|
+ IPage<TaskPageVO> page = new Page<>(current, size);
|
|
|
+ page.setRecords(voList);
|
|
|
+ page.setTotal(totalCount);
|
|
|
+
|
|
|
+ return R.data(page);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 构建业务查询条件(提取复用方法,保持代码清晰)
|
|
|
+ */
|
|
|
+ private void buildBusinessConditions(StringBuilder sqlBuilder, List<Object> params, TaskPageDTO dto, Long currentUserId) {
|
|
|
+ // 任务类型过滤
|
|
|
if (ObjectUtil.isNotEmpty(dto.getTypeValue())) {
|
|
|
- sqlString.append(" AND meter_task_type = ?");
|
|
|
+ sqlBuilder.append(" AND meter_task_type = ?");
|
|
|
params.add(dto.getTypeValue());
|
|
|
}
|
|
|
+
|
|
|
+ // 状态过滤(保持原有业务逻辑)
|
|
|
if (ObjectUtil.isNotEmpty(dto.getStatusValue())) {
|
|
|
- if(dto.getStatusValue() .equals(4) ){//----先查询出所有待审批的 然后根据条件进行过滤出任务已经到当前登陆人的任务为可审批
|
|
|
- sqlString.append(" AND status = 1");
|
|
|
- }else {
|
|
|
- sqlString.append(" AND status = ?");
|
|
|
+ if (dto.getStatusValue().equals(4)) {
|
|
|
+ sqlBuilder.append(" AND status = 1");
|
|
|
+ } else {
|
|
|
+ sqlBuilder.append(" AND status = ?");
|
|
|
params.add(dto.getStatusValue());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 批次过滤
|
|
|
if (ObjectUtil.isNotEmpty(dto.getBatchValue())) {
|
|
|
- sqlString.append(" AND batch = ?");
|
|
|
+ sqlBuilder.append(" AND batch = ?");
|
|
|
params.add(dto.getBatchValue());
|
|
|
}
|
|
|
+
|
|
|
+ // 时间范围过滤
|
|
|
if (StringUtils.isNotBlank(dto.getStartTimeValue()) && StringUtils.isNotBlank(dto.getEndTimeValue())) {
|
|
|
- sqlString.append(" AND start_time >= ?").append(" AND end_time <= ?");
|
|
|
+ sqlBuilder.append(" AND start_time >= ? AND end_time <= ?");
|
|
|
params.add(dto.getStartTimeValue());
|
|
|
params.add(dto.getEndTimeValue());
|
|
|
}
|
|
|
+
|
|
|
+ // 关键词过滤
|
|
|
if (StringUtils.isNotBlank(dto.getQueryValue())) {
|
|
|
- sqlString.append(" AND task_name LIKE ?");
|
|
|
+ sqlBuilder.append(" AND task_name LIKE ?");
|
|
|
params.add("%" + dto.getQueryValue() + "%");
|
|
|
}
|
|
|
+
|
|
|
+ // 页面类型过滤(待办/已办/我发起,保持原有逻辑)
|
|
|
if (ObjectUtil.isNotEmpty(dto.getSelectedType())) {
|
|
|
- sqlString.append(" AND (");
|
|
|
- if (dto.getSelectedType().equals(1)) { //待办页面
|
|
|
+ sqlBuilder.append(" AND (");
|
|
|
+ switch (dto.getSelectedType()) {
|
|
|
+ case 1: // 待办页面
|
|
|
+ buildTodoCondition(sqlBuilder, params, dto, currentUserId);
|
|
|
+ break;
|
|
|
+ case 2: // 已办页面
|
|
|
+ sqlBuilder.append("EXISTS (SELECT 1 FROM u_task_parallel tp " +
|
|
|
+ "WHERE tp.process_instance_id = u_task.process_instance_id " +
|
|
|
+ "AND tp.status IN (2,3) AND tp.task_user = ?)");
|
|
|
+ params.add(currentUserId.toString());
|
|
|
+ break;
|
|
|
+ case 3: // 我发起页面
|
|
|
+ sqlBuilder.append("report_user = ?");
|
|
|
+ params.add(currentUserId.toString());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ sqlBuilder.append(")");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- /*如果是待办页面,且 任务状态下拉框 选择的是 待审批或可审批状态 的任务,那么才查询数据*/
|
|
|
- if (ObjectUtil.isNotEmpty(dto.getStatusValue()) && (dto.getStatusValue().equals(1) || dto.getStatusValue().equals(4))) {
|
|
|
- sqlString.append("EXISTS (SELECT 1 FROM u_task_parallel WHERE u_task.process_instance_id = u_task_parallel.process_instance_id AND u_task_parallel.status = ? AND u_task_parallel.task_user = ?)");
|
|
|
- params.add(1);
|
|
|
- params.add(SecureUtil.getUserId());
|
|
|
+ /**
|
|
|
+ * 构建待办页面查询条件(保持原有业务逻辑)
|
|
|
+ */
|
|
|
+ private void buildTodoCondition(StringBuilder sqlBuilder, List<Object> params, TaskPageDTO dto, Long currentUserId) {
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getStatusValue())) {
|
|
|
+ if (dto.getStatusValue().equals(1) || dto.getStatusValue().equals(4)) {
|
|
|
+ sqlBuilder.append("EXISTS (SELECT 1 FROM u_task_parallel tp " +
|
|
|
+ "WHERE tp.process_instance_id = u_task.process_instance_id " +
|
|
|
+ "AND tp.status = ? AND tp.task_user = ?)");
|
|
|
+ params.add(1);
|
|
|
+ params.add(currentUserId.toString());
|
|
|
+ } else {
|
|
|
+ // 直接返回空结果(保持原有逻辑)
|
|
|
+ sqlBuilder.append("1 = 0");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ sqlBuilder.append("EXISTS (SELECT 1 FROM u_task_parallel tp " +
|
|
|
+ "WHERE tp.process_instance_id = u_task.process_instance_id " +
|
|
|
+ "AND tp.status = ? AND tp.task_user = ?)");
|
|
|
+ params.add(1);
|
|
|
+ params.add(currentUserId.toString());
|
|
|
+ sqlBuilder.append(" AND status = 1");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- /*如果是待办页面,且 任务状态下拉框 选择的不是 待审批状态 的任务,那么直接返回null*/
|
|
|
- } else if (ObjectUtil.isNotEmpty(dto.getStatusValue()) && !dto.getStatusValue().equals(1)) {
|
|
|
- return null;
|
|
|
+ /**
|
|
|
+ * 计算总条数(复用查询条件,只改SELECT部分)
|
|
|
+ */
|
|
|
+ private long countTotal(String sql, List<Object> params) {
|
|
|
+ String countSql = sql.replaceFirst("SELECT .*? FROM", "SELECT COUNT(1) FROM");
|
|
|
+ try {
|
|
|
+ return jdbcTemplate.queryForObject(
|
|
|
+ countSql,
|
|
|
+ Long.class,
|
|
|
+ params.toArray()
|
|
|
+ );
|
|
|
+ } catch (Exception e) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- /*如果是待办页面,没选择 任务状态下拉框,那么就默认查询 待审批状态 任务*/
|
|
|
- } else if (ObjectUtil.isEmpty(dto.getStatusValue())) {
|
|
|
- sqlString.append("EXISTS (SELECT 1 FROM u_task_parallel WHERE u_task.process_instance_id = u_task_parallel.process_instance_id AND u_task_parallel.status = ? AND u_task_parallel.task_user = ?)");
|
|
|
- params.add(1);
|
|
|
- params.add(SecureUtil.getUserId());
|
|
|
- sqlString.append(" AND status = 1");
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 批量获取任务并行数据(一次查询所有需要的processInstanceIds)
|
|
|
+ */
|
|
|
+ private Map<String, List<TaskParallel>> getTaskParallelMap(List<Task> taskList) {
|
|
|
+ Set<String> processInstanceIds = taskList.stream()
|
|
|
+ .map(Task::getProcessInstanceId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+
|
|
|
+ if (processInstanceIds.isEmpty()) {
|
|
|
+ return Collections.emptyMap();
|
|
|
+ }
|
|
|
+
|
|
|
+ String sql = "SELECT process_instance_id, task_user, task_user_name, e_visa_status, " +
|
|
|
+ "e_visa_content, status, initiative, sort " +
|
|
|
+ "FROM u_task_parallel " +
|
|
|
+ "WHERE process_instance_id IN (" + joinPlaceholders(processInstanceIds.size()) + ") " +
|
|
|
+ "ORDER BY id";
|
|
|
+
|
|
|
+ List<Object> params = new ArrayList<>(processInstanceIds);
|
|
|
+ return jdbcTemplate.query(
|
|
|
+ sql,
|
|
|
+ new BeanPropertyRowMapper<>(TaskParallel.class),
|
|
|
+ params.toArray()
|
|
|
+ ).stream()
|
|
|
+ .collect(Collectors.groupingBy(TaskParallel::getProcessInstanceId));
|
|
|
+ }
|
|
|
|
|
|
- } else if (dto.getSelectedType().equals(2)) { //已办页面
|
|
|
- sqlString.append("EXISTS (SELECT 1 FROM u_task_parallel WHERE u_task.process_instance_id = u_task_parallel.process_instance_id AND u_task_parallel.status in(2,3) AND u_task_parallel.task_user = ?)");
|
|
|
- /*当前自己的任务必须是已审批、已废除 status = 2,3 ,才视为已办*/
|
|
|
- params.add(SecureUtil.getUserId());
|
|
|
+ /**
|
|
|
+ * 批量获取用户名(只查用到的用户ID,避免全表扫描)
|
|
|
+ */
|
|
|
+ private Map<Long, String> getUserNameMap(List<Task> taskList, Map<String, List<TaskParallel>> taskParallelMap) {
|
|
|
+ Set<Long> userIds = new HashSet<>();
|
|
|
+
|
|
|
+ // 收集reportUser
|
|
|
+ taskList.stream()
|
|
|
+ .filter(t->StringUtils.isNotBlank(t.getReportUser()))
|
|
|
+ .map(Task::getReportUser)
|
|
|
+ .map(Long::valueOf)
|
|
|
+ .forEach(userIds::add);
|
|
|
+
|
|
|
+ // 收集taskParallel中的taskUser
|
|
|
+ taskParallelMap.values().stream()
|
|
|
+ .flatMap(List::stream)
|
|
|
+ .map(TaskParallel::getTaskUser)
|
|
|
+ .filter(t->StringUtils.isNotEmpty(t))
|
|
|
+ .map(Long::valueOf)
|
|
|
+ .forEach(userIds::add);
|
|
|
+
|
|
|
+ if (userIds.isEmpty()) {
|
|
|
+ return Collections.emptyMap();
|
|
|
+ }
|
|
|
+
|
|
|
+ String sql = "SELECT id, name FROM blade_user WHERE is_deleted = 0 AND id IN (" + joinPlaceholders(userIds.size()) + ")";
|
|
|
+ List<Object> params = new ArrayList<>(userIds);
|
|
|
+
|
|
|
+ return jdbcTemplate.query(
|
|
|
+ sql,
|
|
|
+ new BeanPropertyRowMapper<>(User.class),
|
|
|
+ params.toArray()
|
|
|
+ ).stream()
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ User::getId,
|
|
|
+ User::getName,
|
|
|
+ (v1, v2) -> v1 // 避免ID重复冲突
|
|
|
+ ));
|
|
|
+ }
|
|
|
|
|
|
- } else if (dto.getSelectedType().equals(3)) { //我发起页面
|
|
|
- sqlString.append("report_user = ?");
|
|
|
- params.add(SecureUtil.getUserId());
|
|
|
- }
|
|
|
- sqlString.append(")");
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 批量获取流程名称(只查用到的流程ID,避免全表扫描)
|
|
|
+ */
|
|
|
+ private Map<Long, String> getFlowNameMap(List<Task> taskList) {
|
|
|
+ Set<Long> flowIds = taskList.stream()
|
|
|
+ .map(Task::getFixedFlowId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .filter(flowId -> !flowId.equals(0L)) // 排除自定义流程
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+
|
|
|
+ if (flowIds.isEmpty()) {
|
|
|
+ return Collections.emptyMap();
|
|
|
+ }
|
|
|
+
|
|
|
+ String sql = "SELECT id, fixed_flow_name FROM u_fixed_flow WHERE is_deleted = 0 AND id IN (" + joinPlaceholders(flowIds.size()) + ")";
|
|
|
+ List<Object> params = new ArrayList<>(flowIds);
|
|
|
+
|
|
|
+ return jdbcTemplate.query(
|
|
|
+ sql,
|
|
|
+ new BeanPropertyRowMapper<>(FixedFlow.class),
|
|
|
+ params.toArray()
|
|
|
+ ).stream()
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ FixedFlow::getId,
|
|
|
+ FixedFlow::getFixedFlowName,
|
|
|
+ (v1, v2) -> v1
|
|
|
+ ));
|
|
|
+ }
|
|
|
|
|
|
- /*总数量*/
|
|
|
- String sqlCount = sqlString.toString().replace("*", "count(1)");
|
|
|
- Optional<Integer> totalCountOptional = Optional.ofNullable(jdbcTemplate.queryForObject(sqlCount, Integer.class, params.toArray()));
|
|
|
- int totalCount = totalCountOptional.orElse(0);
|
|
|
+ /**
|
|
|
+ * 批量获取操作日志(只查需要的formDataId,避免全表扫描)
|
|
|
+ */
|
|
|
+ private Map<String, List<OperationLog>> getOperationLogMap(List<Task> taskList) {
|
|
|
+ Set<String> formDataIds = taskList.stream()
|
|
|
+ .filter(task -> task.getStatus() != null && task.getStatus().equals(3)) // 只查已废除的任务
|
|
|
+ .map(Task::getFormDataId)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+
|
|
|
+ if (formDataIds.isEmpty()) {
|
|
|
+ return Collections.emptyMap();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 修复:移除true参数,使用普通占位符?(JDBC自动处理字符串类型)
|
|
|
+ String sql = "SELECT business_id, create_user_name, create_time, operation_type " +
|
|
|
+ "FROM u_operation_log " +
|
|
|
+ "WHERE operation_type IN (6,9,26,61,62) " +
|
|
|
+ "AND business_id IN (" + joinPlaceholders(formDataIds.size()) + ")"; // 关键修改:去掉true
|
|
|
+
|
|
|
+ List<Object> params = new ArrayList<>(formDataIds);
|
|
|
+ return jdbcTemplate.query(
|
|
|
+ sql,
|
|
|
+ new BeanPropertyRowMapper<>(OperationLog.class),
|
|
|
+ params.toArray()
|
|
|
+ ).stream()
|
|
|
+ .collect(Collectors.groupingBy(OperationLog::getBusinessId));
|
|
|
+ }
|
|
|
|
|
|
- /*分页*/
|
|
|
- sqlString.append(" ORDER BY create_time DESC LIMIT ? OFFSET ?;");
|
|
|
- params.add(size);
|
|
|
- params.add((current - 1) * size);
|
|
|
+ /**
|
|
|
+ * 过滤可审批数据(优化原有逻辑,减少重复查询)
|
|
|
+ */
|
|
|
+ private void filterApprovalAbleTasks(List<Task> taskList, Map<String, List<TaskParallel>> taskParallelMap, Long currentUserId) {
|
|
|
+ // 分离自定义流程和固定流程任务
|
|
|
+ Map<Boolean, List<Task>> flowTypeMap = taskList.stream()
|
|
|
+ .collect(Collectors.partitioningBy(task -> "0".equals(task.getFixedFlowId().toString())));
|
|
|
|
|
|
- /*执行SQL获取数据*/
|
|
|
- String sqlPage = sqlString.toString();
|
|
|
- List<Task> resultList = jdbcTemplate.query(sqlPage, new BeanPropertyRowMapper<>(Task.class), params.toArray());
|
|
|
+ List<Task> fixedFlowTasks = flowTypeMap.get(false);
|
|
|
+ List<Task> customFlowTasks = flowTypeMap.get(true);
|
|
|
|
|
|
- /*获取任务详情信息Map*/
|
|
|
- Set<String> processInstanceIds = resultList.stream().map(Task::getProcessInstanceId).collect(Collectors.toSet());
|
|
|
- Map<String, List<TaskParallel>> taskParallelGroupMap = new HashMap<>();
|
|
|
- if (processInstanceIds.size() > 0) {
|
|
|
- String resultIds = processInstanceIds.stream().map(id -> "'" + id + "'").collect(Collectors.joining(","));
|
|
|
- taskParallelGroupMap = jdbcTemplate.query("select process_instance_id,task_user,task_user_name,e_visa_status,e_visa_content,status,initiative,sort from u_task_parallel where process_instance_id in(" + resultIds + ") order by id", new BeanPropertyRowMapper<>(TaskParallel.class)).stream().collect(Collectors.groupingBy(TaskParallel::getProcessInstanceId));
|
|
|
+ // 处理固定流程任务
|
|
|
+ if (ObjectUtil.isNotEmpty(fixedFlowTasks)) {
|
|
|
+ handleFixedFlowApprovalTasks(fixedFlowTasks, taskParallelMap, currentUserId,taskList);
|
|
|
}
|
|
|
- Map<String, List<TaskParallel>> finalTaskParallelGroupMap = taskParallelGroupMap;
|
|
|
|
|
|
- /*获取用户信息Map*/
|
|
|
- Map<Long, String> nameMap = jdbcTemplate.query("select id,name from blade_user where is_deleted = 0", new BeanPropertyRowMapper<>(User.class)).stream().collect(Collectors.toMap(User::getId, User::getName, (key1, key2) -> key1));
|
|
|
- /*获取预设流程Map*/
|
|
|
- // Map<Long, String> flowMap = jdbcTemplate.query("select id,fixed_flow_name from u_fixed_flow where is_deleted = 0 and contract_id = "+dto.getContractId(), new BeanPropertyRowMapper<>(FixedFlow.class)).stream().collect(Collectors.toMap(FixedFlow::getId, FixedFlow::getFixedFlowName, (key1, key2) -> key1));
|
|
|
- Map<Long, String> flowMap = jdbcTemplate.query("select id,fixed_flow_name from u_fixed_flow where is_deleted = 0 ", new BeanPropertyRowMapper<>(FixedFlow.class)).stream().collect(Collectors.toMap(FixedFlow::getId, FixedFlow::getFixedFlowName, (key1, key2) -> key1));
|
|
|
+ // 处理自定义流程任务(垂直审批)
|
|
|
+ if (ObjectUtil.isNotEmpty(customFlowTasks)) {
|
|
|
+ handleCustomFlowApprovalTasks(customFlowTasks, taskParallelMap, currentUserId,taskList);
|
|
|
+ }
|
|
|
|
|
|
- //筛选出可审批的数据
|
|
|
- if(ObjectUtil.isNotEmpty(dto.getStatusValue()) && dto.getStatusValue() .equals(4) && ObjectUtil.isNotEmpty(resultList)){
|
|
|
- //获取当前用户id
|
|
|
- Long userId = AuthUtil.getUserId();
|
|
|
+ // 过滤掉不可审批的任务
|
|
|
+ taskList.removeIf(task -> !task.getIsApprovalAble());
|
|
|
+ }
|
|
|
|
|
|
- String processIdsStr = resultList.stream().map(task -> task.getProcessInstanceId()).collect(Collectors.joining(","));
|
|
|
- //查询出所有proccesId的数据转换成map map为processId键为u_task_papallel对象
|
|
|
- Map<String, List<TaskParallel>> taskParallelMap = jdbcTemplate.query("select * from u_task_parallel where process_instance_id in (" + processIdsStr + ")", new BeanPropertyRowMapper<>(TaskParallel.class)).stream().collect(Collectors.groupingBy(TaskParallel::getProcessInstanceId));
|
|
|
+ /**
|
|
|
+ * 处理固定流程可审批任务
|
|
|
+ */
|
|
|
+ private void handleFixedFlowApprovalTasks(List<Task> fixedFlowTasks, Map<String, List<TaskParallel>> taskParallelMap, Long currentUserId,List<Task>taskList) {
|
|
|
+ Set<Long> flowIds = fixedFlowTasks.stream()
|
|
|
+ .map(Task::getFixedFlowId)
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+
|
|
|
+ String sql = "SELECT fixed_flow_id, fixed_flow_branch_sort, fixed_flow_link_type, fixed_flow_link_sort " +
|
|
|
+ "FROM u_fixed_flow_link " +
|
|
|
+ "WHERE is_deleted = 0 AND fixed_flow_id IN (" + joinPlaceholders(flowIds.size()) + ")";
|
|
|
+
|
|
|
+ List<Object> params = new ArrayList<>(flowIds);
|
|
|
+ Map<Long, List<FixedFlowLink>> flowLinkMap = jdbcTemplate.query(
|
|
|
+ sql,
|
|
|
+ new BeanPropertyRowMapper<>(FixedFlowLink.class),
|
|
|
+ params.toArray()
|
|
|
+ ).stream()
|
|
|
+ .collect(Collectors.groupingBy(FixedFlowLink::getFixedFlowId));
|
|
|
+
|
|
|
+ // 沿用原有处理逻辑,优化循环效率
|
|
|
+ for (Task task : fixedFlowTasks) {
|
|
|
+ handleTaskParallel1(task, flowLinkMap, taskParallelMap, currentUserId,taskList);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- //根据条件过滤出可审批的数据(流程审批-非自定义流程) flowid为0的是自定义审批的流程
|
|
|
- Map<Long, List<Task>> flowIdMaps = resultList.stream().filter(task->!"0".equals(task.getFixedFlowId().toString())).collect(Collectors.groupingBy(Task::getFixedFlowId));
|
|
|
- if(ObjectUtil.isNotEmpty(flowIdMaps)){
|
|
|
- String join = StringUtils.join(flowIdMaps.keySet(), ",");
|
|
|
- //结果集所有数据
|
|
|
- String sql = "select fixed_flow_id ,fixed_flow_branch_sort,fixed_flow_link_type,fixed_flow_link_sort from u_fixed_flow_link where is_deleted = 0 and fixed_flow_id in ( "+join+")";
|
|
|
- List<FixedFlowLink> fixedFlowLinks = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(FixedFlowLink.class));
|
|
|
- Map<Long, List<FixedFlowLink>> fixedsMap = fixedFlowLinks.stream().collect(Collectors.groupingBy(FixedFlowLink::getFixedFlowId));
|
|
|
- for (Long l : flowIdMaps.keySet()) {
|
|
|
- List<Task> tasks = flowIdMaps.get(l);
|
|
|
- for (Task task : tasks) {
|
|
|
- handleTaskParallel1(task,fixedsMap, taskParallelMap,userId, resultList);
|
|
|
- }
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 处理自定义流程可审批任务(垂直审批)
|
|
|
+ */
|
|
|
+ private void handleCustomFlowApprovalTasks(List<Task> customFlowTasks, Map<String, List<TaskParallel>> taskParallelMap, Long currentUserId,List<Task>taskList) {
|
|
|
+ // 查询所有垂直审批项目(保持原有逻辑,默认所有项目)
|
|
|
+ List<Long> verticalProjectIds = jdbcTemplate.query(
|
|
|
+ "SELECT id FROM m_project_info WHERE is_deleted = 0",
|
|
|
+ new BeanPropertyRowMapper<>(ProjectInfo.class)
|
|
|
+ ).stream()
|
|
|
+ .map(ProjectInfo::getId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ if (ObjectUtil.isEmpty(verticalProjectIds)) {
|
|
|
+ customFlowTasks.forEach(task -> task.setIsApprovalAble(false));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 沿用原有处理逻辑
|
|
|
+ for (Task task : customFlowTasks) {
|
|
|
+ if (verticalProjectIds.contains(Long.parseLong(task.getProjectId()))) {
|
|
|
+ handleTaskParallel(task, taskParallelMap, currentUserId,taskList);
|
|
|
+ } else {
|
|
|
+ task.setIsApprovalAble(false);
|
|
|
}
|
|
|
- //自定义流程判断 查询出所有垂直审批的项目
|
|
|
- //String sqlForchuizhi = "select id from m_project_info where approval_type = 1 and is_deleted = 0";
|
|
|
- //目前默认所有项目都是垂直审批 上面的注释掉的是以后要用的内容 1为垂直审批2为流程审批
|
|
|
- String sqlForchuizhi = "select id from m_project_info where is_deleted = 0";
|
|
|
- List<Long> projectIds = jdbcTemplate.query(sqlForchuizhi, new BeanPropertyRowMapper<>(ProjectInfo.class)).stream().map(ProjectInfo::getId).collect(Collectors.toList());
|
|
|
- if(ObjectUtil.isNotEmpty(projectIds)){
|
|
|
- //所有自定义审批的任务
|
|
|
- Set<Task> tasks = resultList.stream().filter(task -> "0".equals(task.getFixedFlowId().toString())).collect(Collectors.toSet());
|
|
|
- if(ObjectUtil.isNotEmpty(tasks)){
|
|
|
- for (Task task : tasks) {
|
|
|
- if(projectIds.contains(Long.parseLong(task.getProjectId()))){
|
|
|
- //是自定义垂直审批
|
|
|
- handleTaskParallel(task, taskParallelMap,userId, resultList);
|
|
|
- }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 转换为VO列表(合并stream处理,减少循环次数)
|
|
|
+ */
|
|
|
+ private List<TaskPageVO> convertToVOList(List<Task> taskList, Map<String, List<TaskParallel>> taskParallelMap,
|
|
|
+ Map<Long, String> userNameMap, Map<Long, String> flowNameMap,
|
|
|
+ Map<String, List<OperationLog>> operationLogMap, Long currentUserId) {
|
|
|
+ return taskList.stream()
|
|
|
+ .map(task -> {
|
|
|
+ TaskPageVO vo = new TaskPageVO();
|
|
|
+ vo.setId(task.getId());
|
|
|
+ vo.setTaskName(task.getTaskName());
|
|
|
+ vo.setRejectDesc(task.getMeterTaskRepealDesc());
|
|
|
+ // 任务类型名称
|
|
|
+ vo.setTaskTypeName(task.getType().equals(1) ? "普通任务" : task.getType().equals(2) ? "验收任务" : "移交任务");
|
|
|
+ // 任务状态名称
|
|
|
+ vo.setTaskStatusName(task.getStatus().equals(1) ? "待审批" : task.getStatus().equals(2) ? "已审批" : "已废除");
|
|
|
+ vo.setStartTime(task.getStartTime());
|
|
|
+ vo.setEndTime(task.getEndTime());
|
|
|
+ vo.setType(task.getType());
|
|
|
+ vo.setMeterType(task.getMeterTaskType());
|
|
|
+ vo.setTaskDesc(task.getTaskContent());
|
|
|
+ // 上报人名称
|
|
|
+ vo.setTaskReportUserName(userNameMap.getOrDefault(Long.parseLong(task.getReportUser()), ""));
|
|
|
+ // 流程信息
|
|
|
+ Long fixedFlowId = task.getFixedFlowId();
|
|
|
+ vo.setFixedFlowId(ObjectUtil.isEmpty(fixedFlowId) || fixedFlowId.equals(0L) ? null : fixedFlowId);
|
|
|
+ vo.setFixedFlowName(vo.getFixedFlowId() == null ? "自定义流程" : flowNameMap.getOrDefault(vo.getFixedFlowId(), ""));
|
|
|
+
|
|
|
+ // 处理并行任务信息
|
|
|
+ List<TaskParallel> taskParallelList = taskParallelMap.getOrDefault(task.getProcessInstanceId(), Collections.emptyList());
|
|
|
+ handleTaskParallelVO(vo, taskParallelList, currentUserId);
|
|
|
+
|
|
|
+ // 处理已废除任务的日志信息
|
|
|
+ if ("已废除".equals(vo.getTaskStatusName())) {
|
|
|
+ handleAbolishedTaskLog(vo, task, operationLogMap);
|
|
|
}
|
|
|
- }
|
|
|
+
|
|
|
+ return vo;
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理并行任务VO信息
|
|
|
+ */
|
|
|
+ private void handleTaskParallelVO(TaskPageVO vo, List<TaskParallel> taskParallelList, Long currentUserId) {
|
|
|
+ if (taskParallelList.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 审批人名称列表
|
|
|
+ List<String> approveNames = taskParallelList.stream()
|
|
|
+ .map(TaskParallel::getTaskUserName)
|
|
|
+ .filter(t->StringUtils.isNotBlank(t))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (ObjectUtil.isNotEmpty(approveNames)) {
|
|
|
+ vo.setTaskApproveUserNames(StringUtils.join(approveNames, ","));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 电签状态(优先当前用户)
|
|
|
+ TaskParallel currentUserParallel = taskParallelList.stream()
|
|
|
+ .filter(tp -> StringUtils.isNotBlank(tp.getTaskUser()) && tp.getTaskUser().equals(currentUserId.toString()))
|
|
|
+ .findAny()
|
|
|
+ .orElse(taskParallelList.get(0));
|
|
|
+
|
|
|
+ if (currentUserParallel.getEVisaStatus() != null) {
|
|
|
+ if (currentUserParallel.getEVisaStatus() == 1) {
|
|
|
+ vo.setEVisaStatus("电签成功");
|
|
|
+ } else if (StringUtils.isBlank(currentUserParallel.getEVisaContent()) || "null".equals(currentUserParallel.getEVisaContent())) {
|
|
|
+ vo.setEVisaStatus("电签失败");
|
|
|
+ } else {
|
|
|
+ vo.setEVisaStatus(currentUserParallel.getEVisaContent());
|
|
|
}
|
|
|
}
|
|
|
- /*解析page分页数据*/
|
|
|
- IPage<TaskPageVO> page = new Page<>(current, size);
|
|
|
- List<TaskPageVO> pageList = resultList.stream().map(task -> {
|
|
|
- TaskPageVO vo = new TaskPageVO();
|
|
|
- vo.setRejectDesc(task.getMeterTaskRepealDesc());
|
|
|
- vo.setId(task.getId());
|
|
|
- vo.setTaskName(task.getTaskName());
|
|
|
- vo.setTaskTypeName(task.getType().equals(1) ? "普通任务" : task.getType().equals(2) ? "验收任务" : "移交任务");
|
|
|
- vo.setTaskStatusName(task.getStatus().equals(1) ? "待审批" : task.getStatus().equals(2) ? "已审批" : "已废除");
|
|
|
- vo.setStartTime(task.getStartTime());
|
|
|
- vo.setEndTime(task.getEndTime());
|
|
|
- vo.setType(task.getType());
|
|
|
- vo.setMeterType(task.getMeterTaskType());
|
|
|
- vo.setTaskDesc(task.getTaskContent());
|
|
|
- vo.setTaskReportUserName(nameMap.get(Long.parseLong(task.getReportUser())));
|
|
|
- vo.setFixedFlowId(ObjectUtil.isNotEmpty(task.getFixedFlowId()) ? task.getFixedFlowId().equals(0L) ? null : task.getFixedFlowId() : null);
|
|
|
- vo.setFixedFlowName(vo.getFixedFlowId() == null ? "自定义流程" : flowMap.get(vo.getFixedFlowId()));
|
|
|
- List<TaskParallel> taskParallelList = finalTaskParallelGroupMap.get(task.getProcessInstanceId());
|
|
|
- if (taskParallelList != null && taskParallelList.size() > 0) {
|
|
|
- List<String> names = taskParallelList.stream().map(TaskParallel::getTaskUserName).collect(Collectors.toList());
|
|
|
- if (names.size() > 0) {
|
|
|
- vo.setTaskApproveUserNames(StringUtils.join(names, ","));
|
|
|
- }
|
|
|
-
|
|
|
- /*电签状态(始终只获取自己的电签任务状态信息)*/
|
|
|
- TaskParallel taskParallel = taskParallelList.stream().filter(f -> ObjectUtil.isNotEmpty(f.getTaskUser()) && f.getTaskUser().equals(SecureUtil.getUserId().toString())).findAny().orElse(null);
|
|
|
- if (taskParallel != null) {
|
|
|
-// vo.setEVisaStatus((taskParallel.getEVisaContent() != null && !"null".equals(taskParallel.getEVisaContent())) ? taskParallel.getEVisaContent() : "");
|
|
|
- if (taskParallel.getEVisaStatus() != null){
|
|
|
- vo.setEVisaStatus(taskParallel.getEVisaStatus() == 1 ? "电签成功":(StringUtils.isBlank(taskParallel.getEVisaContent()) || "null".equals(taskParallel.getEVisaContent()))?"电签失败":taskParallel.getEVisaContent());
|
|
|
- }
|
|
|
- } else {
|
|
|
- taskParallel = taskParallelList.get(0);
|
|
|
- if (taskParallel.getEVisaStatus() != null){
|
|
|
- vo.setEVisaStatus(taskParallel.getEVisaStatus() == 1 ? "电签成功":(StringUtils.isBlank(taskParallel.getEVisaContent()) || "null".equals(taskParallel.getEVisaContent()))?"电签失败":taskParallel.getEVisaContent());
|
|
|
- }
|
|
|
- }
|
|
|
- if (vo.getTaskStatusName().equals("已废除")) {
|
|
|
- if (!"撤回成功".equals(vo.getEVisaStatus()) && !"驳回成功".equals(vo.getEVisaStatus())) {
|
|
|
- vo.setEVisaStatus("废除成功");
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- /*判断签字人的验证 2=绿色 3=黄色 999=红色 其他代表=灰色*/
|
|
|
- List<TaskParallel> statList = new ArrayList<>();
|
|
|
- for (TaskParallel taskPa : taskParallelList) {
|
|
|
- if (taskPa.getStatus() == 2 && ObjectUtil.isNotEmpty(taskPa.getEVisaStatus()) && taskPa.getEVisaStatus() == 1) {
|
|
|
- taskPa.setEVisaStatus(2);
|
|
|
- } else if (taskPa.getStatus() == 3) {
|
|
|
- if (taskPa.getInitiative() == 2) {
|
|
|
- taskPa.setEVisaStatus(3);
|
|
|
- }
|
|
|
- } else if (ObjectUtil.isNotEmpty(taskPa.getEVisaStatus()) && taskPa.getEVisaStatus() == 99) {
|
|
|
- taskPa.setEVisaStatus(999);
|
|
|
+ // 已废除状态特殊处理
|
|
|
+ if ("已废除".equals(vo.getTaskStatusName()) && !"撤回成功".equals(vo.getEVisaStatus()) && !"驳回成功".equals(vo.getEVisaStatus())) {
|
|
|
+ vo.setEVisaStatus("废除成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 签字人状态标记
|
|
|
+ List<Object> statusList = taskParallelList.stream()
|
|
|
+ .map(tp -> {
|
|
|
+ TaskParallel copy = new TaskParallel();
|
|
|
+ BeanUtils.copyProperties(tp, copy);
|
|
|
+ if (copy.getStatus() == 2 && ObjectUtil.isNotEmpty(copy.getEVisaStatus()) && copy.getEVisaStatus() == 1) {
|
|
|
+ copy.setEVisaStatus(2);
|
|
|
+ } else if (copy.getStatus() == 3 && copy.getInitiative() == 2) {
|
|
|
+ copy.setEVisaStatus(3);
|
|
|
+ } else if (ObjectUtil.isNotEmpty(copy.getEVisaStatus()) && copy.getEVisaStatus() == 99) {
|
|
|
+ copy.setEVisaStatus(999);
|
|
|
} else {
|
|
|
- taskPa.setEVisaStatus(1);
|
|
|
- }
|
|
|
- statList.add(taskPa);
|
|
|
- }
|
|
|
- if (statList.size() > 0) {
|
|
|
- List<Object> objectList = statList.stream().map(taskPa -> (Object) taskPa).collect(Collectors.toList());
|
|
|
- vo.setTaskApproveUserNamesList(objectList);
|
|
|
- }
|
|
|
- }
|
|
|
- return vo;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- Map<Long, Task> taskMap = new HashMap<>();
|
|
|
- Map<String, List<OperationLog>> operationLogMap = new HashMap<>();
|
|
|
- List<Long> taskIds = pageList.stream().filter(b -> "已废除".equals(b.getTaskStatusName())).map(TaskPageVO::getId).collect(Collectors.toList());
|
|
|
- if (ObjectUtil.isNotEmpty(taskIds)){
|
|
|
- String joinTaskIds = StringUtils.join(taskIds, ",");
|
|
|
- List<Task> tasks = jdbcTemplate.query("select id, create_time,form_data_id from u_task where id in ( " + joinTaskIds+")", new BeanPropertyRowMapper<>(Task.class));
|
|
|
- taskMap = tasks.stream()
|
|
|
- .collect(Collectors.toMap(
|
|
|
- Task::getId,
|
|
|
- task -> task));
|
|
|
- }
|
|
|
-
|
|
|
- //所有满足条件的日志 转map
|
|
|
- //String logQuery = "select business_id,create_user_name ,create_time, operation_type from u_operation_log where operation_content like '%废除%'";
|
|
|
- String logQuery="select business_id,create_user_name ,create_time, operation_type from u_operation_log where operation_type IN (6,9,26,61,62)";
|
|
|
- List<OperationLog> operationLogs = jdbcTemplate.query(logQuery, new BeanPropertyRowMapper<>(OperationLog.class));
|
|
|
- if(ObjectUtil.isNotEmpty(operationLogs)){
|
|
|
- operationLogMap = operationLogs.stream().collect(Collectors.groupingBy(OperationLog::getBusinessId));
|
|
|
- }
|
|
|
- for (TaskPageVO businessTaskPageVO : pageList) {
|
|
|
- if("已废除".equals(businessTaskPageVO.getTaskStatusName())){
|
|
|
- Long taskId = businessTaskPageVO.getId();
|
|
|
- Task task = taskMap.get(taskId);
|
|
|
- if (ObjectUtil.isEmpty(task)){
|
|
|
- continue;
|
|
|
- }
|
|
|
- //任务创建时间
|
|
|
- Date createTime = task.getCreateTime();
|
|
|
- //废除时间肯定在任务创建时间之后 选择距离当前任务创建时间最近的一条数据
|
|
|
- List<OperationLog> operationLogsF = operationLogMap.get(task.getFormDataId());
|
|
|
-
|
|
|
- if(ObjectUtil.isNotEmpty(operationLogsF)){
|
|
|
- Optional<OperationLog> min = operationLogsF.stream().filter(o -> o.getCreateTime().compareTo(createTime) >= 0)
|
|
|
- .min(Comparator.comparing(t -> t.getCreateTime().getTime() - createTime.getTime()));
|
|
|
- if (min.isPresent()){
|
|
|
- OperationLog operationLog = min.get();
|
|
|
- if (operationLog.getOperationType() != null && operationLog.getOperationType() == 61) {
|
|
|
- businessTaskPageVO.setEVisaStatus("驳回成功:"+operationLog.getCreateUserName()+"-"+operationLog.getCreateTime());
|
|
|
- } else if (operationLog.getOperationType() != null && operationLog.getOperationType() == 62) {
|
|
|
- businessTaskPageVO.setEVisaStatus("撤回成功:"+operationLog.getCreateUserName()+"-"+operationLog.getCreateTime());
|
|
|
- } else {
|
|
|
- businessTaskPageVO.setEVisaStatus(businessTaskPageVO.getEVisaStatus()+":"+operationLog.getCreateUserName()+"-"+operationLog.getCreateTime());
|
|
|
- }
|
|
|
+ copy.setEVisaStatus(1);
|
|
|
}
|
|
|
+ return (Object) copy;
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ vo.setTaskApproveUserNamesList(statusList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理已废除任务的日志信息
|
|
|
+ */
|
|
|
+ private void handleAbolishedTaskLog(TaskPageVO vo, Task task, Map<String, List<OperationLog>> operationLogMap) {
|
|
|
+ String formDataId = task.getFormDataId();
|
|
|
+ if (StringUtils.isBlank(formDataId)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<OperationLog> logs = operationLogMap.getOrDefault(formDataId, Collections.emptyList());
|
|
|
+ if (logs.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 1. 先获取任务创建时间,为空则直接返回(避免后续比较空指针)
|
|
|
+ Date taskCreateTime = task.getCreateTime();
|
|
|
+ if (taskCreateTime == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 过滤:日志创建时间不为空 + 日志时间晚于任务创建时间
|
|
|
+ Optional<OperationLog> latestLog = logs.stream()
|
|
|
+ .filter(log -> log.getCreateTime() != null) // 关键:过滤掉创建时间为null的日志
|
|
|
+ .filter(log -> log.getCreateTime().compareTo(taskCreateTime) >= 0)
|
|
|
+ .min(Comparator.comparing(log -> log.getCreateTime().getTime() - taskCreateTime.getTime()));
|
|
|
+
|
|
|
+ // 3. 处理日志信息(保持原有业务逻辑)
|
|
|
+ latestLog.ifPresent(log -> {
|
|
|
+ String createUserName = log.getCreateUserName();
|
|
|
+ Date logCreateTime = log.getCreateTime();
|
|
|
+ // 补充用户名和时间的非空判断,避免拼接时出现null
|
|
|
+ String userName = StringUtils.isNotBlank(createUserName) ? createUserName : "未知用户";
|
|
|
+ String timeStr = logCreateTime != null ? logCreateTime.toString() : "未知时间";
|
|
|
+ String logInfo = userName + "-" + timeStr;
|
|
|
+
|
|
|
+ if (log.getOperationType() != null) {
|
|
|
+ switch (log.getOperationType()) {
|
|
|
+ case 61:
|
|
|
+ vo.setEVisaStatus("驳回成功:" + logInfo);
|
|
|
+ break;
|
|
|
+ case 62:
|
|
|
+ vo.setEVisaStatus("撤回成功:" + logInfo);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ // 补充vo.getEVisaStatus()非空判断,避免拼接null
|
|
|
+ String originalStatus = vo.getEVisaStatus() != null ? vo.getEVisaStatus() : "废除成功";
|
|
|
+ vo.setEVisaStatus(originalStatus + ":" + logInfo);
|
|
|
}
|
|
|
}
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成IN条件的占位符(如 ?,?,?)
|
|
|
+ */
|
|
|
+ private String joinPlaceholders(int count) {
|
|
|
+ return joinPlaceholders(count, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成IN条件的占位符(支持字符串类型,添加单引号)
|
|
|
+ */
|
|
|
+ private String joinPlaceholders(int count, boolean isString) {
|
|
|
+ if (count <= 0) {
|
|
|
+ return "";
|
|
|
}
|
|
|
- page.setRecords(pageList);
|
|
|
- page.setTotal(totalCount);
|
|
|
- return R.data(page);
|
|
|
+ String placeholder = isString ? "'?'" : "?";
|
|
|
+ return String.join(",", Collections.nCopies(count, placeholder));
|
|
|
}
|
|
|
|
|
|
private void handleTaskParallel1(Task task, Map<Long, List<FixedFlowLink>> fixedsMap, Map<String, List<TaskParallel>> taskParallelMap, Long userId, List<Task> resultList) {
|