Browse Source

Merge remote-tracking branch 'origin/master'

tags/24080901
liuxinxin 1 year ago
parent
commit
fd4c87bf7c
4 changed files with 177 additions and 67 deletions
  1. +5
    -4
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/controller/TodoCenterController.java
  2. +119
    -57
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java
  3. +1
    -6
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/req/ReqToBeProcessedDTO.java
  4. +52
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/req/ReqToBeProcessedExportDTO.java

+ 5
- 4
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/controller/TodoCenterController.java View File

@@ -7,6 +7,7 @@ import javax.validation.Valid;
import com.ningdatech.pmapi.common.util.ExcelDownUtil; import com.ningdatech.pmapi.common.util.ExcelDownUtil;
import com.ningdatech.pmapi.todocenter.bean.vo.ProcessProgressDetailVo; import com.ningdatech.pmapi.todocenter.bean.vo.ProcessProgressDetailVo;
import com.ningdatech.pmapi.todocenter.model.dto.req.ReqProcessHandlerDTO; import com.ningdatech.pmapi.todocenter.model.dto.req.ReqProcessHandlerDTO;
import com.ningdatech.pmapi.todocenter.model.dto.req.ReqToBeProcessedExportDTO;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;


import com.ningdatech.basic.model.ApiResponse; import com.ningdatech.basic.model.ApiResponse;
@@ -53,7 +54,7 @@ public class TodoCenterController {
* @return void * @return void
*/ */
@PostMapping("/exportPending") @PostMapping("/exportPending")
public void exportPendingProjectList(@Valid @RequestBody ReqToBeProcessedDTO param, HttpServletResponse response){
public void exportPendingProjectList(@Valid @RequestBody ReqToBeProcessedExportDTO param, HttpServletResponse response){
todoCenterManage.exportPendingProjectList(response,param); todoCenterManage.exportPendingProjectList(response,param);
} }


@@ -98,7 +99,7 @@ public class TodoCenterController {
* @return void * @return void
*/ */
@PostMapping("/exportHandled") @PostMapping("/exportHandled")
public void exportHandledProjectList(@Valid @RequestBody ReqToBeProcessedDTO param, HttpServletResponse response){
public void exportHandledProjectList(@Valid @RequestBody ReqToBeProcessedExportDTO param, HttpServletResponse response){
todoCenterManage.exportHandledProjectList(response,param); todoCenterManage.exportHandledProjectList(response,param);
} }


@@ -121,7 +122,7 @@ public class TodoCenterController {
* @return void * @return void
*/ */
@PostMapping("/exportMySubmitted") @PostMapping("/exportMySubmitted")
public void exportMySubmittedProjectList(@Valid @RequestBody ReqToBeProcessedDTO param, HttpServletResponse response){
public void exportMySubmittedProjectList(@Valid @RequestBody ReqToBeProcessedExportDTO param, HttpServletResponse response){
todoCenterManage.exportMySubmittedProjectList(response,param); todoCenterManage.exportMySubmittedProjectList(response,param);
} }


@@ -144,7 +145,7 @@ public class TodoCenterController {
* @return void * @return void
*/ */
@PostMapping("/exportCcMe") @PostMapping("/exportCcMe")
public void exportCcMeProjectList(@Valid @RequestBody ReqToBeProcessedDTO param, HttpServletResponse response){
public void exportCcMeProjectList(@Valid @RequestBody ReqToBeProcessedExportDTO param, HttpServletResponse response){
todoCenterManage.exportCcMeProjectList(response,param); todoCenterManage.exportCcMeProjectList(response,param);
} }
} }

+ 119
- 57
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java View File

@@ -1,5 +1,6 @@
package com.ningdatech.pmapi.todocenter.manage; package com.ningdatech.pmapi.todocenter.manage;


import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
@@ -38,6 +39,7 @@ import com.ningdatech.pmapi.todocenter.extension.cmd.BackToHisApprovalNodeCmd;
import com.ningdatech.pmapi.todocenter.extension.cmd.SaveCommentCmd; import com.ningdatech.pmapi.todocenter.extension.cmd.SaveCommentCmd;
import com.ningdatech.pmapi.todocenter.model.dto.req.ReqProcessHandlerDTO; import com.ningdatech.pmapi.todocenter.model.dto.req.ReqProcessHandlerDTO;
import com.ningdatech.pmapi.todocenter.model.dto.req.ReqToBeProcessedDTO; import com.ningdatech.pmapi.todocenter.model.dto.req.ReqToBeProcessedDTO;
import com.ningdatech.pmapi.todocenter.model.dto.req.ReqToBeProcessedExportDTO;
import com.ningdatech.pmapi.todocenter.model.dto.res.ResToBeProcessedDTO; import com.ningdatech.pmapi.todocenter.model.dto.res.ResToBeProcessedDTO;
import com.ningdatech.pmapi.todocenter.zwdd.model.MessageContent; import com.ningdatech.pmapi.todocenter.zwdd.model.MessageContent;
import com.ningdatech.pmapi.todocenter.zwdd.model.MessageText; import com.ningdatech.pmapi.todocenter.zwdd.model.MessageText;
@@ -96,6 +98,8 @@ import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;


import static cn.hutool.core.collection.CollUtil.isEmpty;
import static cn.hutool.core.collection.CollUtil.isNotEmpty;
import static com.ningdatech.pmapi.todocenter.constant.WorkNotice.PASS_MSG_TEMPLATE; import static com.ningdatech.pmapi.todocenter.constant.WorkNotice.PASS_MSG_TEMPLATE;
import static com.ningdatech.pmapi.todocenter.constant.WorkNotice.PASS_MSG_TEMPLATE2; import static com.ningdatech.pmapi.todocenter.constant.WorkNotice.PASS_MSG_TEMPLATE2;


@@ -138,13 +142,22 @@ public class TodoCenterManage {
// 获取登录用户ID // 获取登录用户ID
// long userId = LoginUserUtil.getUserId(); // long userId = LoginUserUtil.getUserId();


Long userId = 381496L;
// Long userId = 6418616L;
// Long userId = 381496L;
Long userId = 6418616L;
// Long userId = 61769799L; // Long userId = 61769799L;
TaskQuery taskQuery = taskService.createTaskQuery(); TaskQuery taskQuery = taskService.createTaskQuery();
taskQuery.active().taskCandidateOrAssigned(String.valueOf(userId)).orderByTaskCreateTime().desc(); taskQuery.active().taskCandidateOrAssigned(String.valueOf(userId)).orderByTaskCreateTime().desc();
List<Task> taskList = taskQuery.list(); List<Task> taskList = taskQuery.list();
List<Project> results = getToBeProcessedProjects(param, taskList); List<Project> results = getToBeProcessedProjects(param, taskList);
// 总数
int total = results.size();
// 获取传入的分页参数
Integer pageNumber = param.getPageNumber();
Integer pageSize = param.getPageSize();
List<Project> records = results.stream()
.skip((long) (pageNumber - 1) * pageSize)
.limit(pageSize)
.collect(Collectors.toList());


Map<String, Task> taskMap = taskList.stream() Map<String, Task> taskMap = taskList.stream()
.collect(Collectors.toMap(Task::getProcessInstanceId, t -> t)); .collect(Collectors.toMap(Task::getProcessInstanceId, t -> t));
@@ -154,13 +167,13 @@ public class TodoCenterManage {


Set<String> staterUsers = new HashSet<>(); Set<String> staterUsers = new HashSet<>();
// 将申报项目待登录用户处理的流程实例一次性取出来,减少查询次数 // 将申报项目待登录用户处理的流程实例一次性取出来,减少查询次数
Map<String, HistoricProcessInstance> instanceMap = CollectionUtil.isNotEmpty(taskList)
Map<String, HistoricProcessInstance> instanceMap = isNotEmpty(taskList)
? historyService.createHistoricProcessInstanceQuery() ? historyService.createHistoricProcessInstanceQuery()
.processInstanceIds(processInsIds).list().stream() .processInstanceIds(processInsIds).list().stream()
.collect(Collectors.toMap(HistoricProcessInstance::getId, v -> v)) .collect(Collectors.toMap(HistoricProcessInstance::getId, v -> v))
: new HashMap<>(); : new HashMap<>();


List<ResToBeProcessedDTO> resVos = results.stream().map(d -> {
List<ResToBeProcessedDTO> resVos = records.stream().map(d -> {
ResToBeProcessedDTO res = new ResToBeProcessedDTO(); ResToBeProcessedDTO res = new ResToBeProcessedDTO();
BeanUtils.copyProperties(d, res); BeanUtils.copyProperties(d, res);
res.setProjectId(d.getId()); res.setProjectId(d.getId());
@@ -186,17 +199,19 @@ public class TodoCenterManage {
return res; return res;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
// 取用户信息,减少数据库查询,一次构建 // 取用户信息,减少数据库查询,一次构建
List<ResToBeProcessedDTO> result = null;
if (CollectionUtil.isNotEmpty(staterUsers)) {
if (isNotEmpty(staterUsers)) {
Map<String, OrgUser> userMap = userDeptOrLeaderService.getUserMapByIds(staterUsers); Map<String, OrgUser> userMap = userDeptOrLeaderService.getUserMapByIds(staterUsers);
result = resVos.stream()
resVos.stream()
.peek(v -> v.getProcessTaskInfo().setOwner(userMap.get(v.getProcessTaskInfo().getOwnerId()))) .peek(v -> v.getProcessTaskInfo().setOwner(userMap.get(v.getProcessTaskInfo().getOwnerId())))
.collect(Collectors.toList()); .collect(Collectors.toList());
// Map<Long,UserInfo> userMap = userInfoService.getUserMapByIds(staterUsers); // Map<Long,UserInfo> userMap = userInfoService.getUserMapByIds(staterUsers);
// result = resVos.stream().peek(v -> v.setOwner(userMap.get(userId))) // result = resVos.stream().peek(v -> v.setOwner(userMap.get(userId)))
// .collect(Collectors.toList()); // .collect(Collectors.toList());
} }
return PageVo.of(result, result.size());
if (isEmpty(resVos)){
return PageVo.empty();
}
return PageVo.of(resVos, total);
} }


/** /**
@@ -208,7 +223,7 @@ public class TodoCenterManage {
* @author CMM * @author CMM
* @since 2023/02/01 * @since 2023/02/01
*/ */
public void exportPendingProjectList(HttpServletResponse response, ReqToBeProcessedDTO param) {
public void exportPendingProjectList(HttpServletResponse response, ReqToBeProcessedExportDTO param) {
param.setPageNumber(1); param.setPageNumber(1);
param.setPageSize(10000); param.setPageSize(10000);
// 获取登录用户ID // 获取登录用户ID
@@ -219,8 +234,9 @@ public class TodoCenterManage {
TaskQuery taskQuery = taskService.createTaskQuery(); TaskQuery taskQuery = taskService.createTaskQuery();
taskQuery.active().taskCandidateOrAssigned(String.valueOf(userId)).orderByTaskCreateTime().desc(); taskQuery.active().taskCandidateOrAssigned(String.valueOf(userId)).orderByTaskCreateTime().desc();
List<Task> taskList = taskQuery.list(); List<Task> taskList = taskQuery.list();
List<Project> records = getToBeProcessedProjects(param, taskList);

ReqToBeProcessedDTO reqToBeProcessedDTO = new ReqToBeProcessedDTO();
BeanUtils.copyProperties(param,reqToBeProcessedDTO);
List<Project> records = getToBeProcessedProjects(reqToBeProcessedDTO, taskList);
ExcelExportWriter excelExportWriter = new ExcelExportWriter(); ExcelExportWriter excelExportWriter = new ExcelExportWriter();


String fileName = null; String fileName = null;
@@ -270,7 +286,6 @@ public class TodoCenterManage {
* @since 2023/02/11 * @since 2023/02/11
*/ */
private List<Project> getToBeProcessedProjects(ReqToBeProcessedDTO param, List<Task> taskList) { private List<Project> getToBeProcessedProjects(ReqToBeProcessedDTO param, List<Task> taskList) {
Page<Project> page = param.page();
LambdaQueryWrapper<Project> wrapper = Wrappers.lambdaQuery(Project.class); LambdaQueryWrapper<Project> wrapper = Wrappers.lambdaQuery(Project.class);
wrapper.like(StrUtil.isNotBlank(param.getProjectName()), Project::getProjectName, param.getProjectName()) wrapper.like(StrUtil.isNotBlank(param.getProjectName()), Project::getProjectName, param.getProjectName())
.like(StrUtil.isNotBlank(param.getBuildUnitName()), Project::getBuildOrgName, param.getBuildUnitName()) .like(StrUtil.isNotBlank(param.getBuildUnitName()), Project::getBuildOrgName, param.getBuildUnitName())
@@ -279,12 +294,13 @@ public class TodoCenterManage {
.ge(Objects.nonNull(param.getProcessLaunchStartTime()), Project::getBeginTime, .ge(Objects.nonNull(param.getProcessLaunchStartTime()), Project::getBeginTime,
param.getProcessLaunchStartTime()) param.getProcessLaunchStartTime())
.le(Objects.nonNull(param.getProcessLaunchEndTime()), Project::getEndTime, param.getProcessLaunchEndTime()); .le(Objects.nonNull(param.getProcessLaunchEndTime()), Project::getEndTime, param.getProcessLaunchEndTime());
projectService.page(page, wrapper);
List<Project> results = projectService.list(wrapper);


List<String> taskProcessInsIds = taskList.stream().map(Task::getProcessInstanceId).collect(Collectors.toList()); List<String> taskProcessInsIds = taskList.stream().map(Task::getProcessInstanceId).collect(Collectors.toList());



// 过滤申报项目中待登录用户审核的项目 // 过滤申报项目中待登录用户审核的项目
return page.getRecords().stream().filter(w -> taskProcessInsIds.contains(w.getInstCode()))
return results.stream().filter(w -> taskProcessInsIds.contains(w.getInstCode()))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }


@@ -302,9 +318,9 @@ public class TodoCenterManage {


// Long userId = LoginUserUtil.getUserId(); // Long userId = LoginUserUtil.getUserId();


Long userId = 381496L;
// Long userId = 381496L;


// Long userId = 6418616L;
Long userId = 6418616L;


// 若进行的是撤回操作(流程发起人和当前流程审核人的前一个审核人操作) // 若进行的是撤回操作(流程发起人和当前流程审核人的前一个审核人操作)
if (param.getAction().equals(ProcessHandlerEnum.WITHDRAW)){ if (param.getAction().equals(ProcessHandlerEnum.WITHDRAW)){
@@ -642,7 +658,7 @@ public class TodoCenterManage {
*/ */
private boolean hasComment(ProcessComment comment) { private boolean hasComment(ProcessComment comment) {
return Objects.nonNull(comment) return Objects.nonNull(comment)
&& (StrUtil.isNotBlank(comment.getText()) || CollectionUtil.isNotEmpty(comment.getAttachments()));
&& (StrUtil.isNotBlank(comment.getText()) || isNotEmpty(comment.getAttachments()));
} }


/** /**
@@ -744,7 +760,20 @@ public class TodoCenterManage {
.collect(Collectors.toList()), HisProInsEndActId.WITHDRAW) .collect(Collectors.toList()), HisProInsEndActId.WITHDRAW)
.changeState(); .changeState();
} else { } else {
// TODO 获取前一个审核节点审核人信息
// 获取当前流程待审核节点
FlowNode currentNode = (FlowNode) bpmnModel.getFlowElement(task.getTaskDefinitionKey());
SequenceFlow sequenceFlow = currentNode.getIncomingFlows().get(0);
// 获取上一个节点的activityId
String sourceRef = sequenceFlow.getSourceRef();

HistoricActivityInstance lastInstance = historyService.createHistoricActivityInstanceQuery()
.processInstanceId(task.getProcessInstanceId())
.activityId(sourceRef)
.activityType("userTask")
.finished()
.singleResult();
// 获取前一个审核节点审核人信息
String beforeUserId = lastInstance.getAssignee();


// TODO 判断前一个审核人的部门和当前登录用户的部门是否是同一个,如果是同一个才可以撤回,否则抛出异常 // TODO 判断前一个审核人的部门和当前登录用户的部门是否是同一个,如果是同一个才可以撤回,否则抛出异常
Boolean orgFlag = true; Boolean orgFlag = true;
@@ -929,7 +958,7 @@ public class TodoCenterManage {
.name(task.getNodeName()).user(OrgUser.builder().id(task.getUserId()).build()) .name(task.getNodeName()).user(OrgUser.builder().id(task.getUserId()).build())
.startTime(task.getCreateTime()).finishTime(task.getCreateTime()).build(); .startTime(task.getCreateTime()).finishTime(task.getCreateTime()).build();
}).collect(Collectors.toList()); }).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(ccUsers)) {
if (isNotEmpty(ccUsers)) {
Map<String, OrgUser> userMap = userDeptOrLeaderService.getUserMapByIds(ccUsers); Map<String, OrgUser> userMap = userDeptOrLeaderService.getUserMapByIds(ccUsers);
ccList.stream().peek(v -> v.setUser(userMap.get(v.getUser().getId()))).collect(Collectors.toList()); ccList.stream().peek(v -> v.setUser(userMap.get(v.getUser().getId()))).collect(Collectors.toList());
} }
@@ -990,7 +1019,7 @@ public class TodoCenterManage {
.approvalMode(approvalMode).auditInfo(commentsMap.get(his.getTaskId())) .approvalMode(approvalMode).auditInfo(commentsMap.get(his.getTaskId()))
.result(varMap.get("approve_" + his.getTaskId())).build(); .result(varMap.get("approve_" + his.getTaskId())).build();
}).collect(Collectors.toList()); }).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(userSet)) {
if (isNotEmpty(userSet)) {
Map<String, OrgUser> map = userDeptOrLeaderService.getUserMapByIds(userSet); Map<String, OrgUser> map = userDeptOrLeaderService.getUserMapByIds(userSet);
progressNodes.forEach(n -> n.setUser(map.get(n.getUser().getId()))); progressNodes.forEach(n -> n.setUser(map.get(n.getUser().getId())));
} }
@@ -1014,8 +1043,8 @@ public class TodoCenterManage {
// 获取登录用户ID // 获取登录用户ID
// long userId = LoginUserUtil.getUserId(); // long userId = LoginUserUtil.getUserId();


// Long userId = 381496L;
Long userId = 6418616L;
Long userId = 381496L;
// Long userId = 6418616L;
// Long userId = 61769799L; // Long userId = 61769799L;


// 自定义sql查询所有已办的任务实例 // 自定义sql查询所有已办的任务实例
@@ -1031,18 +1060,29 @@ public class TodoCenterManage {
.collect(Collectors.toSet()); .collect(Collectors.toSet());
List<Project> results = getHandledProjects(param, taskProcessInsIds); List<Project> results = getHandledProjects(param, taskProcessInsIds);


// 总数
int total = results.size();
// 获取传入的分页参数
Integer pageNumber = param.getPageNumber();
Integer pageSize = param.getPageSize();
List<Project> records = results.stream()
.skip((long) (pageNumber - 1) * pageSize)
.limit(pageSize)
.collect(Collectors.toList());


// 把已办任务实例一次性取出来,减少查询次数 // 把已办任务实例一次性取出来,减少查询次数
Map<String, HistoricTaskInstance> taskInstanceMap = taskInstances.stream() Map<String, HistoricTaskInstance> taskInstanceMap = taskInstances.stream()
.collect(Collectors.toMap(HistoricTaskInstance::getProcessInstanceId, v -> v)); .collect(Collectors.toMap(HistoricTaskInstance::getProcessInstanceId, v -> v));


Map<String, HistoricProcessInstance> instanceMap = CollectionUtil.isNotEmpty(taskInstances)
Map<String, HistoricProcessInstance> instanceMap = isNotEmpty(taskInstances)
? historyService.createHistoricProcessInstanceQuery() ? historyService.createHistoricProcessInstanceQuery()
.processInstanceIds(taskProcessInsIds) .processInstanceIds(taskProcessInsIds)
.list().stream().collect(Collectors.toMap(HistoricProcessInstance::getId, v -> v)) .list().stream().collect(Collectors.toMap(HistoricProcessInstance::getId, v -> v))
: new HashMap<>(); : new HashMap<>();
Set<String> staterUsers = new HashSet<>(); Set<String> staterUsers = new HashSet<>();


List<ResToBeProcessedDTO> resVos = results.stream().map(d -> {
List<ResToBeProcessedDTO> resVos = records.stream().map(d -> {


ResToBeProcessedDTO res = new ResToBeProcessedDTO(); ResToBeProcessedDTO res = new ResToBeProcessedDTO();
BeanUtils.copyProperties(d, res); BeanUtils.copyProperties(d, res);
@@ -1075,18 +1115,19 @@ public class TodoCenterManage {
return res; return res;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
// 取用户信息,减少数据库查询,一次构建 // 取用户信息,减少数据库查询,一次构建
List<ResToBeProcessedDTO> result = null;
if (CollectionUtil.isNotEmpty(staterUsers)) {
if (isNotEmpty(staterUsers)) {
Map<String, OrgUser> userMap = userDeptOrLeaderService.getUserMapByIds(staterUsers); Map<String, OrgUser> userMap = userDeptOrLeaderService.getUserMapByIds(staterUsers);
result = resVos.stream()
resVos.stream()
.peek(v -> v.getProcessTaskInfo().setOwner(userMap.get(v.getProcessTaskInfo().getOwnerId()))) .peek(v -> v.getProcessTaskInfo().setOwner(userMap.get(v.getProcessTaskInfo().getOwnerId())))
.collect(Collectors.toList()); .collect(Collectors.toList());
// Map<Long,UserInfo> userMap = userInfoService.getUserMapByIds(staterUsers); // Map<Long,UserInfo> userMap = userInfoService.getUserMapByIds(staterUsers);
// result = resVos.stream().peek(v -> v.setOwner(userMap.get(userId))) // result = resVos.stream().peek(v -> v.setOwner(userMap.get(userId)))
// .collect(Collectors.toList()); // .collect(Collectors.toList());

} }
return PageVo.of(result, result.size());
if (isEmpty(resVos)){
return PageVo.empty();
}
return PageVo.of(resVos,total);
} }


/** /**
@@ -1099,8 +1140,6 @@ public class TodoCenterManage {
* @since 2023/02/11 * @since 2023/02/11
*/ */
private List<Project> getHandledProjects(ReqToBeProcessedDTO param, Set<String> taskProcessInsIds) { private List<Project> getHandledProjects(ReqToBeProcessedDTO param, Set<String> taskProcessInsIds) {
// 获取入参分页信息
Page<Project> page = param.page();
LambdaQueryWrapper<Project> wrapper = Wrappers.lambdaQuery(Project.class); LambdaQueryWrapper<Project> wrapper = Wrappers.lambdaQuery(Project.class);
wrapper.like(StrUtil.isNotBlank(param.getProjectName()), Project::getProjectName, param.getProjectName()) wrapper.like(StrUtil.isNotBlank(param.getProjectName()), Project::getProjectName, param.getProjectName())
.like(StrUtil.isNotBlank(param.getBuildUnitName()), Project::getBuildOrgName, param.getBuildUnitName()) .like(StrUtil.isNotBlank(param.getBuildUnitName()), Project::getBuildOrgName, param.getBuildUnitName())
@@ -1109,10 +1148,10 @@ public class TodoCenterManage {
.ge(Objects.nonNull(param.getProcessLaunchStartTime()), Project::getBeginTime, .ge(Objects.nonNull(param.getProcessLaunchStartTime()), Project::getBeginTime,
param.getProcessLaunchStartTime()) param.getProcessLaunchStartTime())
.le(Objects.nonNull(param.getProcessLaunchEndTime()), Project::getEndTime, param.getProcessLaunchEndTime()); .le(Objects.nonNull(param.getProcessLaunchEndTime()), Project::getEndTime, param.getProcessLaunchEndTime());
projectService.page(page, wrapper);
List<Project> results = projectService.list(wrapper);


// 过滤申报项目中登录用户已审核的项目 // 过滤申报项目中登录用户已审核的项目
return page.getRecords().stream()
return results.stream()
.filter(w -> taskProcessInsIds.contains(w.getInstCode())) .filter(w -> taskProcessInsIds.contains(w.getInstCode()))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
@@ -1126,7 +1165,7 @@ public class TodoCenterManage {
* @author CMM * @author CMM
* @since 2023/02/06 * @since 2023/02/06
*/ */
public void exportHandledProjectList(HttpServletResponse response, ReqToBeProcessedDTO param) {
public void exportHandledProjectList(HttpServletResponse response, ReqToBeProcessedExportDTO param) {
param.setPageNumber(1); param.setPageNumber(1);
param.setPageSize(10000); param.setPageSize(10000);
// 获取登录用户ID // 获取登录用户ID
@@ -1144,7 +1183,9 @@ public class TodoCenterManage {
Set<String> taskProcessInsIds = taskInstances.stream() Set<String> taskProcessInsIds = taskInstances.stream()
.map(HistoricTaskInstance::getProcessInstanceId) .map(HistoricTaskInstance::getProcessInstanceId)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
List<Project> records = getHandledProjects(param, taskProcessInsIds);
ReqToBeProcessedDTO reqToBeProcessedDTO = new ReqToBeProcessedDTO();
BeanUtils.copyProperties(param,reqToBeProcessedDTO);
List<Project> records = getHandledProjects(reqToBeProcessedDTO, taskProcessInsIds);


ExcelExportWriter excelExportWriter = new ExcelExportWriter(); ExcelExportWriter excelExportWriter = new ExcelExportWriter();


@@ -1203,20 +1244,30 @@ public class TodoCenterManage {
List<HistoricProcessInstance> historicProcessInstances = List<HistoricProcessInstance> historicProcessInstances =
instanceQuery.orderByProcessInstanceStartTime().desc().orderByProcessInstanceEndTime().desc().list(); instanceQuery.orderByProcessInstanceStartTime().desc().orderByProcessInstanceEndTime().desc().list();
Set<String> historicProcessInstanceIds = Set<String> historicProcessInstanceIds =
historicProcessInstances.stream().map(h -> h.getId()).collect(Collectors.toSet());
historicProcessInstances.stream().map(HistoricProcessInstance::getId).collect(Collectors.toSet());


List<Project> results = getMySubmittedProjects(param, historicProcessInstanceIds); List<Project> results = getMySubmittedProjects(param, historicProcessInstanceIds);


// 总数
int total = results.size();
// 获取传入的分页参数
Integer pageNumber = param.getPageNumber();
Integer pageSize = param.getPageSize();
List<Project> records = results.stream()
.skip((long) (pageNumber - 1) * pageSize)
.limit(pageSize)
.collect(Collectors.toList());

// 把已办任务流程实例一次性取出来,减少查询次数 // 把已办任务流程实例一次性取出来,减少查询次数
Map<String, HistoricProcessInstance> instanceMap = CollectionUtil.isNotEmpty(historicProcessInstances) ? historyService
Map<String, HistoricProcessInstance> instanceMap = isNotEmpty(historicProcessInstances) ? historyService
.createHistoricProcessInstanceQuery() .createHistoricProcessInstanceQuery()
.processInstanceIds(historicProcessInstances.stream().map(h -> h.getId()).collect(Collectors.toSet()))
.processInstanceIds(historicProcessInstances.stream().map(HistoricProcessInstance::getId).collect(Collectors.toSet()))
.list().stream().collect(Collectors.toMap(HistoricProcessInstance::getId, v -> v)) : new HashMap<>(); .list().stream().collect(Collectors.toMap(HistoricProcessInstance::getId, v -> v)) : new HashMap<>();


Set<String> staterUsers = new HashSet<>(); Set<String> staterUsers = new HashSet<>();


List<ResToBeProcessedDTO> resVos = List<ResToBeProcessedDTO> resVos =
results.stream().map(d -> {
records.stream().map(d -> {
ResToBeProcessedDTO res = new ResToBeProcessedDTO(); ResToBeProcessedDTO res = new ResToBeProcessedDTO();
BeanUtils.copyProperties(d, res); BeanUtils.copyProperties(d, res);
res.setProjectId(d.getId()); res.setProjectId(d.getId());
@@ -1233,7 +1284,7 @@ public class TodoCenterManage {
return res; return res;
}).collect(Collectors.toList()); }).collect(Collectors.toList());


if (CollectionUtil.isNotEmpty(staterUsers)) {
if (isNotEmpty(staterUsers)) {
Map<String, OrgUser> userMap = userDeptOrLeaderService.getUserMapByIds(staterUsers); Map<String, OrgUser> userMap = userDeptOrLeaderService.getUserMapByIds(staterUsers);
resVos.stream().map(v -> { resVos.stream().map(v -> {
v.getProcessInstanceInfo().setStaterUser(userMap.get(v.getProcessInstanceInfo().getStaterUserId())); v.getProcessInstanceInfo().setStaterUser(userMap.get(v.getProcessInstanceInfo().getStaterUserId()));
@@ -1246,7 +1297,7 @@ public class TodoCenterManage {
// resVos.stream().peek(v -> v.setOwner(userMap.get(startUserId))) // resVos.stream().peek(v -> v.setOwner(userMap.get(startUserId)))
// .collect(Collectors.toList()); // .collect(Collectors.toList());
// } // }
return PageVo.of(resVos, resVos.size());
return PageVo.of(resVos, total);
} }


/** /**
@@ -1259,7 +1310,6 @@ public class TodoCenterManage {
* @since 2023/02/11 * @since 2023/02/11
*/ */
private List<Project> getMySubmittedProjects(ReqToBeProcessedDTO param, Set<String> historicProcessInstanceIds) { private List<Project> getMySubmittedProjects(ReqToBeProcessedDTO param, Set<String> historicProcessInstanceIds) {
Page<Project> page = param.page();
LambdaQueryWrapper<Project> wrapper = Wrappers.lambdaQuery(Project.class); LambdaQueryWrapper<Project> wrapper = Wrappers.lambdaQuery(Project.class);
wrapper.like(StrUtil.isNotBlank(param.getProjectName()), Project::getProjectName, param.getProjectName()) wrapper.like(StrUtil.isNotBlank(param.getProjectName()), Project::getProjectName, param.getProjectName())
.like(StrUtil.isNotBlank(param.getBuildUnitName()), Project::getBuildOrgName, param.getBuildUnitName()) .like(StrUtil.isNotBlank(param.getBuildUnitName()), Project::getBuildOrgName, param.getBuildUnitName())
@@ -1268,13 +1318,12 @@ public class TodoCenterManage {
.ge(Objects.nonNull(param.getProcessLaunchStartTime()), Project::getBeginTime, .ge(Objects.nonNull(param.getProcessLaunchStartTime()), Project::getBeginTime,
param.getProcessLaunchStartTime()) param.getProcessLaunchStartTime())
.le(Objects.nonNull(param.getProcessLaunchEndTime()), Project::getEndTime, param.getProcessLaunchEndTime()); .le(Objects.nonNull(param.getProcessLaunchEndTime()), Project::getEndTime, param.getProcessLaunchEndTime());
projectService.page(page, wrapper);
List<Project> results = projectService.list(wrapper);


// 筛选出申报项目中我发起的项目 // 筛选出申报项目中我发起的项目
List<Project> results = page.getRecords().stream()
return results.stream()
.filter(d -> historicProcessInstanceIds.contains(d.getInstCode())) .filter(d -> historicProcessInstanceIds.contains(d.getInstCode()))
.collect(Collectors.toList()); .collect(Collectors.toList());
return results;
} }


/** /**
@@ -1309,7 +1358,7 @@ public class TodoCenterManage {
List<Task> list = List<Task> list =
taskService.createTaskQuery().processInstanceId(ist.getId()).includeIdentityLinks().active().list(); taskService.createTaskQuery().processInstanceId(ist.getId()).includeIdentityLinks().active().list();
instanceVo.setNodeId(Optional.ofNullable(instanceVo.getNodeId()).orElseGet(() -> { instanceVo.setNodeId(Optional.ofNullable(instanceVo.getNodeId()).orElseGet(() -> {
if (CollectionUtil.isNotEmpty(list)) {
if (isNotEmpty(list)) {
return list.get(0).getTaskDefinitionKey(); return list.get(0).getTaskDefinitionKey();
} }
return null; return null;
@@ -1337,7 +1386,7 @@ public class TodoCenterManage {
* @author CMM * @author CMM
* @since 2023/02/11 * @since 2023/02/11
*/ */
public void exportMySubmittedProjectList(HttpServletResponse response, ReqToBeProcessedDTO param) {
public void exportMySubmittedProjectList(HttpServletResponse response, ReqToBeProcessedExportDTO param) {


param.setPageNumber(1); param.setPageNumber(1);
param.setPageSize(10000); param.setPageSize(10000);
@@ -1352,7 +1401,9 @@ public class TodoCenterManage {
Set<String> historicProcessInstanceIds = historicProcessInstances.stream() Set<String> historicProcessInstanceIds = historicProcessInstances.stream()
.map(h -> h.getId()) .map(h -> h.getId())
.collect(Collectors.toSet()); .collect(Collectors.toSet());
List<Project> records = getMySubmittedProjects(param, historicProcessInstanceIds);
ReqToBeProcessedDTO reqToBeProcessedDTO = new ReqToBeProcessedDTO();
BeanUtils.copyProperties(param,reqToBeProcessedDTO);
List<Project> records = getMySubmittedProjects(reqToBeProcessedDTO, historicProcessInstanceIds);


ExcelExportWriter excelExportWriter = new ExcelExportWriter(); ExcelExportWriter excelExportWriter = new ExcelExportWriter();


@@ -1415,15 +1466,25 @@ public class TodoCenterManage {


List<Project> results = getCcMeProjects(param, processInsIds); List<Project> results = getCcMeProjects(param, processInsIds);


// 总数
int total = results.size();
// 获取传入的分页参数
Integer pageNumber = param.getPageNumber();
Integer pageSize = param.getPageSize();
List<Project> records = results.stream()
.skip((long) (pageNumber - 1) * pageSize)
.limit(pageSize)
.collect(Collectors.toList());

Set<String> staterUsers = new HashSet<>(); Set<String> staterUsers = new HashSet<>();
// 将抄送我的流程实例一次性取出来,减少查询次数 // 将抄送我的流程实例一次性取出来,减少查询次数
Map<String, HistoricProcessInstance> instanceMap = CollectionUtil.isNotEmpty(ccTasks)
Map<String, HistoricProcessInstance> instanceMap = isNotEmpty(ccTasks)
? historyService.createHistoricProcessInstanceQuery() ? historyService.createHistoricProcessInstanceQuery()
.processInstanceIds(ccTasks.stream().map(WflowCcTasks::getInstanceId).collect(Collectors.toSet())) .processInstanceIds(ccTasks.stream().map(WflowCcTasks::getInstanceId).collect(Collectors.toSet()))
.list().stream().collect(Collectors.toMap(HistoricProcessInstance::getId, v -> v)) .list().stream().collect(Collectors.toMap(HistoricProcessInstance::getId, v -> v))
: new HashMap<>(); : new HashMap<>();
List<ResToBeProcessedDTO> resVos = List<ResToBeProcessedDTO> resVos =
results.stream().map(d -> {
records.stream().map(d -> {
ResToBeProcessedDTO res = new ResToBeProcessedDTO(); ResToBeProcessedDTO res = new ResToBeProcessedDTO();
BeanUtils.copyProperties(d, res); BeanUtils.copyProperties(d, res);
res.setProjectId(d.getId()); res.setProjectId(d.getId());
@@ -1440,7 +1501,7 @@ public class TodoCenterManage {
return res; return res;
}).collect(Collectors.toList()); }).collect(Collectors.toList());


if (CollectionUtil.isNotEmpty(staterUsers)) {
if (isNotEmpty(staterUsers)) {
Map<String, OrgUser> userMap = userDeptOrLeaderService.getUserMapByIds(staterUsers); Map<String, OrgUser> userMap = userDeptOrLeaderService.getUserMapByIds(staterUsers);
resVos.stream().map(v -> { resVos.stream().map(v -> {
v.getProcessInstanceInfo().setStaterUser(userMap.get(v.getProcessInstanceInfo().getStaterUserId())); v.getProcessInstanceInfo().setStaterUser(userMap.get(v.getProcessInstanceInfo().getStaterUserId()));
@@ -1453,7 +1514,7 @@ public class TodoCenterManage {
// resVos.stream().peek(v -> v.setOwner(userMap.get(startUserId))) // resVos.stream().peek(v -> v.setOwner(userMap.get(startUserId)))
// .collect(Collectors.toList()); // .collect(Collectors.toList());
// } // }
return PageVo.of(resVos, resVos.size());
return PageVo.of(resVos, total);
} }


/** /**
@@ -1466,7 +1527,6 @@ public class TodoCenterManage {
* @since 2023/02/11 * @since 2023/02/11
*/ */
private List<Project> getCcMeProjects(ReqToBeProcessedDTO param, List<String> processInsIds) { private List<Project> getCcMeProjects(ReqToBeProcessedDTO param, List<String> processInsIds) {
Page<Project> page = param.page();
LambdaQueryWrapper<Project> wrapper = Wrappers.lambdaQuery(Project.class); LambdaQueryWrapper<Project> wrapper = Wrappers.lambdaQuery(Project.class);
wrapper.like(StrUtil.isNotBlank(param.getProjectName()), Project::getProjectName, param.getProjectName()) wrapper.like(StrUtil.isNotBlank(param.getProjectName()), Project::getProjectName, param.getProjectName())
.like(StrUtil.isNotBlank(param.getBuildUnitName()), Project::getBuildOrgName, param.getBuildUnitName()) .like(StrUtil.isNotBlank(param.getBuildUnitName()), Project::getBuildOrgName, param.getBuildUnitName())
@@ -1475,9 +1535,9 @@ public class TodoCenterManage {
.ge(Objects.nonNull(param.getProcessLaunchStartTime()), Project::getBeginTime, .ge(Objects.nonNull(param.getProcessLaunchStartTime()), Project::getBeginTime,
param.getProcessLaunchStartTime()) param.getProcessLaunchStartTime())
.le(Objects.nonNull(param.getProcessLaunchEndTime()), Project::getEndTime, param.getProcessLaunchEndTime()); .le(Objects.nonNull(param.getProcessLaunchEndTime()), Project::getEndTime, param.getProcessLaunchEndTime());
projectService.page(page, wrapper);
List<Project> results = projectService.list(wrapper);


return page.getRecords().stream()
return results.stream()
.filter(d -> processInsIds.contains(d.getInstCode())) .filter(d -> processInsIds.contains(d.getInstCode()))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
@@ -1491,7 +1551,7 @@ public class TodoCenterManage {
* @author CMM * @author CMM
* @since 2023/02/11 * @since 2023/02/11
*/ */
public void exportCcMeProjectList(HttpServletResponse response, ReqToBeProcessedDTO param) {
public void exportCcMeProjectList(HttpServletResponse response, ReqToBeProcessedExportDTO param) {


param.setPageNumber(1); param.setPageNumber(1);
param.setPageSize(10000); param.setPageSize(10000);
@@ -1505,7 +1565,9 @@ public class TodoCenterManage {
.map(WflowCcTasks::getInstanceId) .map(WflowCcTasks::getInstanceId)
.collect(Collectors.toList()); .collect(Collectors.toList());


List<Project> records = getCcMeProjects(param, processInsIds);
ReqToBeProcessedDTO reqToBeProcessedDTO = new ReqToBeProcessedDTO();
BeanUtils.copyProperties(param,reqToBeProcessedDTO);
List<Project> records = getCcMeProjects(reqToBeProcessedDTO, processInsIds);


ExcelExportWriter excelExportWriter = new ExcelExportWriter(); ExcelExportWriter excelExportWriter = new ExcelExportWriter();




+ 1
- 6
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/req/ReqToBeProcessedDTO.java View File

@@ -15,7 +15,7 @@ import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;


/** /**
* 待办中心-待我处理查询实体信息
* 待办中心-列表查询实体信息
* *
* @author CMM * @author CMM
* @since 2023/01/12 16:01 * @since 2023/01/12 16:01
@@ -44,9 +44,4 @@ public class ReqToBeProcessedDTO extends PagePo implements Serializable {
@ApiModelProperty(value = "是否增补项目",allowableValues = "非增补项目 0,增补项目 1") @ApiModelProperty(value = "是否增补项目",allowableValues = "非增补项目 0,增补项目 1")
@NotNull(message = "是否增补字段不能为空!") @NotNull(message = "是否增补字段不能为空!")
private Integer isSupplement; private Integer isSupplement;

@ApiModelProperty("导出选项")
@NotNull(message = "导出选项不能为空")
private List<ExportOptionEnum> exportOptionList;

} }

+ 52
- 0
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/req/ReqToBeProcessedExportDTO.java View File

@@ -0,0 +1,52 @@
package com.ningdatech.pmapi.todocenter.model.dto.req;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

import javax.validation.constraints.NotNull;

import com.ningdatech.basic.model.PagePo;
import com.ningdatech.pmapi.common.enumeration.ExportOptionEnum;

import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
* 待办中心-导出查询实体信息
*
* @author CMM
* @since 2023/01/12 16:01
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ReqToBeProcessedExportDTO extends PagePo implements Serializable {
private static final long serialVersionUID = 1L;

@ApiModelProperty("项目名称")
private String projectName;

@ApiModelProperty("申报单位名称")
private String buildUnitName;

@ApiModelProperty("预算年度")
private Integer projectYear;

@ApiModelProperty("流程发起开始时间")
private LocalDateTime processLaunchStartTime;

@ApiModelProperty("流程发起结束时间")
private LocalDateTime processLaunchEndTime;

@ApiModelProperty(value = "是否增补项目",allowableValues = "非增补项目 0,增补项目 1")
@NotNull(message = "是否增补字段不能为空!")
private Integer isSupplement;

@ApiModelProperty("导出选项")
@NotNull(message = "导出选项不能为空")
private List<ExportOptionEnum> exportOptionList;

}

Loading…
Cancel
Save