Преглед изворни кода

待办中心列表展示修改

master
CMM пре 1 година
родитељ
комит
6961e8cd90
4 измењених фајлова са 214 додато и 197 уклоњено
  1. +170
    -170
      pmapi/src/main/java/com/ningdatech/pmapi/ding/task/OrganizationBatchGetTask.java
  2. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/controller/TodoCenterController.java
  3. +41
    -26
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java
  4. +2
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/req/ReqToBeProcessedDTO.java

+ 170
- 170
pmapi/src/main/java/com/ningdatech/pmapi/ding/task/OrganizationBatchGetTask.java Прегледај датотеку

@@ -1,171 +1,171 @@

package com.ningdatech.pmapi.ding.task;

import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.google.common.collect.Lists;
import com.ningdatech.basic.model.GenericResult;
import com.ningdatech.pmapi.ding.model.DingOrgInfoTreeDTO;
import com.ningdatech.pmapi.organization.entity.DingOrganization;
import com.ningdatech.pmapi.organization.service.IDingOrganizationService;
import com.ningdatech.zwdd.client.ZwddAuthClient;
import com.ningdatech.zwdd.client.ZwddClient;
import com.ningdatech.zwdd.model.dto.DingOrgInfoDTO;
import com.ningdatech.zwdd.model.dto.DingScopesV2DTO;
import com.ningdatech.zwdd.model.dto.PageSubOrganizationCodeDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
* @author liuxinxin
* @date 2023/2/7 上午10:15
*/

@Slf4j
@Component
public class OrganizationBatchGetTask {

@Autowired
private ZwddClient zwddClient;

@Autowired
private ZwddAuthClient zwddAuthClient;

private static final Integer GROUP_SIZE = 100;

@Autowired
private IDingOrganizationService iDingOrganizationService;

/**
* 获取浙政钉组织架构
*/
@Transactional(rollbackFor = Exception.class)
public void batchGetOrganizationTask() {
// List<DingOrganization> allList = iDingOrganizationService.list();
// List<String> currentAllOrganizationCodeList = allList.stream().map(DingOrganization::getOrganizationCode).collect(Collectors.toList());
// 全量删除
// iDingOrganizationService.remove(Wrappers.lambdaQuery(DingOrganization.class).isNotNull(DingOrganization::getId));
// 获取顶级组织code
GenericResult<DingScopesV2DTO> scopesV2Result = zwddClient.getScopesV2();
DingScopesV2DTO scopesV2 = scopesV2Result.getData();

if (Objects.nonNull(scopesV2)) {
// 顶级组织code
List<String> deptVisibleScopes = scopesV2.getDeptVisibleScopes();
log.info("顶级组织code: size = " + deptVisibleScopes.size() + "列表:" + JSONObject.toJSONString(deptVisibleScopes));
// 获取顶级节点信息
GenericResult<List<DingOrgInfoDTO>> listGenericResult = zwddClient.listOrganizationsByCodes(deptVisibleScopes);
List<DingOrgInfoDTO> dingOrgInfoDtos = listGenericResult.getData();
for (String orgCode : deptVisibleScopes) {
// if (currentAllOrganizationCodeList.contains(orgCode)) {
// log.info("已存在组织架构---{}", orgCode);
// continue;
//
//package com.ningdatech.pmapi.ding.task;
//
//import cn.hutool.core.collection.CollUtil;
//import com.alibaba.fastjson.JSONObject;
//import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
//import com.google.common.collect.Lists;
//import com.ningdatech.basic.model.GenericResult;
//import com.ningdatech.pmapi.ding.model.DingOrgInfoTreeDTO;
//import com.ningdatech.pmapi.organization.entity.DingOrganization;
//import com.ningdatech.pmapi.organization.service.IDingOrganizationService;
//import com.ningdatech.zwdd.client.ZwddAuthClient;
//import com.ningdatech.zwdd.client.ZwddClient;
//import com.ningdatech.zwdd.model.dto.DingOrgInfoDTO;
//import com.ningdatech.zwdd.model.dto.DingScopesV2DTO;
//import com.ningdatech.zwdd.model.dto.PageSubOrganizationCodeDTO;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Objects;
//import java.util.stream.Collectors;
//
///**
// * @author liuxinxin
// * @date 2023/2/7 上午10:15
// */
//
//@Slf4j
//@Component
//public class OrganizationBatchGetTask {
//
// @Autowired
// private ZwddClient zwddClient;
//
// @Autowired
// private ZwddAuthClient zwddAuthClient;
//
// private static final Integer GROUP_SIZE = 100;
//
// @Autowired
// private IDingOrganizationService iDingOrganizationService;
//
// /**
// * 获取浙政钉组织架构
// */
// @Transactional(rollbackFor = Exception.class)
// public void batchGetOrganizationTask() {
//// List<DingOrganization> allList = iDingOrganizationService.list();
//// List<String> currentAllOrganizationCodeList = allList.stream().map(DingOrganization::getOrganizationCode).collect(Collectors.toList());
// // 全量删除
// // iDingOrganizationService.remove(Wrappers.lambdaQuery(DingOrganization.class).isNotNull(DingOrganization::getId));
// // 获取顶级组织code
// GenericResult<DingScopesV2DTO> scopesV2Result = zwddClient.getScopesV2();
// DingScopesV2DTO scopesV2 = scopesV2Result.getData();
//
// if (Objects.nonNull(scopesV2)) {
// // 顶级组织code
// List<String> deptVisibleScopes = scopesV2.getDeptVisibleScopes();
// log.info("顶级组织code: size = " + deptVisibleScopes.size() + "列表:" + JSONObject.toJSONString(deptVisibleScopes));
// // 获取顶级节点信息
// GenericResult<List<DingOrgInfoDTO>> listGenericResult = zwddClient.listOrganizationsByCodes(deptVisibleScopes);
// List<DingOrgInfoDTO> dingOrgInfoDtos = listGenericResult.getData();
// for (String orgCode : deptVisibleScopes) {
//// if (currentAllOrganizationCodeList.contains(orgCode)) {
//// log.info("已存在组织架构---{}", orgCode);
//// continue;
//// }
// List<DingOrgInfoTreeDTO> treeDTOList = new ArrayList<>();
//
// DingOrgInfoTreeDTO childDingOrgInfoTreeDTO = new DingOrgInfoTreeDTO();
// //设置节点详情
// if (dingOrgInfoDtos != null && !dingOrgInfoDtos.isEmpty()) {
// for (DingOrgInfoDTO orgInfo : dingOrgInfoDtos) {
// if (orgInfo.getOrganizationCode().equals(orgCode)) {
// childDingOrgInfoTreeDTO.setDingOrgInfoDTO(orgInfo);
// }
// }
// }
List<DingOrgInfoTreeDTO> treeDTOList = new ArrayList<>();

DingOrgInfoTreeDTO childDingOrgInfoTreeDTO = new DingOrgInfoTreeDTO();
//设置节点详情
if (dingOrgInfoDtos != null && !dingOrgInfoDtos.isEmpty()) {
for (DingOrgInfoDTO orgInfo : dingOrgInfoDtos) {
if (orgInfo.getOrganizationCode().equals(orgCode)) {
childDingOrgInfoTreeDTO.setDingOrgInfoDTO(orgInfo);
}
}
}
childDingOrgInfoTreeDTO.setCode(orgCode);
childDingOrgInfoTreeDTO.setChildCodes(new ArrayList<>());
getDingOrgChild(childDingOrgInfoTreeDTO);
treeDTOList.add(childDingOrgInfoTreeDTO);

if (CollectionUtils.isNotEmpty(treeDTOList)) {
List<DingOrganization> saveRecordList = new ArrayList<>();
buildSaveRecordList(treeDTOList, saveRecordList);

// 批量保存
if (saveRecordList.size() <= GROUP_SIZE) {
iDingOrganizationService.saveBatch(saveRecordList);
} else {
List<List<DingOrganization>> split = Lists.partition(saveRecordList, GROUP_SIZE);
for (List<DingOrganization> segment : split) {
iDingOrganizationService.saveBatch(segment);
}
}
}
log.info("----拉取浙政钉组织结构结束---,顶级code:" + orgCode);
}
}
}

private void buildSaveRecordList(List<DingOrgInfoTreeDTO> treeDTOList, List<DingOrganization> saveRecordList) {
if (CollectionUtils.isEmpty(treeDTOList)) {
return;
}
for (DingOrgInfoTreeDTO dingOrgInfoTreeDTO : treeDTOList) {
DingOrganization saveRecord = new DingOrganization();
DingOrgInfoDTO dingOrgInfoDTO = dingOrgInfoTreeDTO.getDingOrgInfoDTO();
List<DingOrgInfoTreeDTO> childCodes = dingOrgInfoTreeDTO.getChildCodes();
saveRecord.setDisplayOrder(dingOrgInfoDTO.getDisplayOrder());
// saveRecord.setEnabled("1");
saveRecord.setParentCode(dingOrgInfoDTO.getParentCode());
saveRecord.setOrganizationCode(dingOrgInfoDTO.getOrganizationCode());
// saveRecord.setSubCount((long) dingOrgInfoTreeDTO.getChildCodes().size());
saveRecord.setOrganizationName(dingOrgInfoDTO.getOrganizationName());
saveRecordList.add(saveRecord);
if (CollectionUtils.isNotEmpty(childCodes)) {
buildSaveRecordList(childCodes, saveRecordList);
}
}

}

private void getDingOrgChild(DingOrgInfoTreeDTO parentDingOrgInfoTreeDTO) {
String parentOrgCode = parentDingOrgInfoTreeDTO.getCode();
DingOrgInfoDTO orgInfoDTO = parentDingOrgInfoTreeDTO.getDingOrgInfoDTO();
boolean leaf = orgInfoDTO.getLeaf();
if (!leaf) {
int currentPage = 1;
int pageSize = 100;
GenericResult<PageSubOrganizationCodeDTO> pageSubOrganizationCodeDTOGenericResult = zwddClient.pageSubOrganizationCodes(currentPage++, pageSize, parentOrgCode);
PageSubOrganizationCodeDTO pageSubOrganizationCodeDTO = pageSubOrganizationCodeDTOGenericResult.getData();

if (CollUtil.isNotEmpty(pageSubOrganizationCodeDTO.getSubOrganizationCodeList())) {
List<String> subOrganizationCodeList = new ArrayList<>(pageSubOrganizationCodeDTO.getSubOrganizationCodeList());
Long totalSize = pageSubOrganizationCodeDTO.getTotalSize();

while (totalSize > (long) currentPage * pageSize) {
GenericResult<PageSubOrganizationCodeDTO> subPageSubOrganizationCodeDTOGenericResult = zwddClient
.pageSubOrganizationCodes(currentPage++, pageSize, parentOrgCode);
PageSubOrganizationCodeDTO subOrganizationCodeDTO = subPageSubOrganizationCodeDTOGenericResult.getData();
if (CollectionUtils.isNotEmpty(subOrganizationCodeDTO.getSubOrganizationCodeList())) {
subOrganizationCodeList.addAll(subOrganizationCodeDTO.getSubOrganizationCodeList());
}
}

if (CollectionUtils.isNotEmpty(subOrganizationCodeList)) {
GenericResult<List<DingOrgInfoDTO>> listGenericResult = zwddClient
.listOrganizationsByCodes(subOrganizationCodeList);
List<DingOrgInfoDTO> dingOrgInfoDtos = listGenericResult.getData();
List<DingOrgInfoTreeDTO> dingOrgInfoTreeDTOList = dingOrgInfoDtos.stream().map(r -> {
DingOrgInfoTreeDTO dingOrgInfoTreeDTO = new DingOrgInfoTreeDTO();
dingOrgInfoTreeDTO.setCode(r.getOrganizationCode());
dingOrgInfoTreeDTO.setDingOrgInfoDTO(r);
dingOrgInfoTreeDTO.setChildCodes(new ArrayList<>());
getDingOrgChild(dingOrgInfoTreeDTO);
return dingOrgInfoTreeDTO;
}).collect(Collectors.toList());
parentDingOrgInfoTreeDTO.setChildCodes(dingOrgInfoTreeDTOList);
}
}
}
}

}

// childDingOrgInfoTreeDTO.setCode(orgCode);
// childDingOrgInfoTreeDTO.setChildCodes(new ArrayList<>());
// getDingOrgChild(childDingOrgInfoTreeDTO);
// treeDTOList.add(childDingOrgInfoTreeDTO);
//
// if (CollectionUtils.isNotEmpty(treeDTOList)) {
// List<DingOrganization> saveRecordList = new ArrayList<>();
// buildSaveRecordList(treeDTOList, saveRecordList);
//
// // 批量保存
// if (saveRecordList.size() <= GROUP_SIZE) {
// iDingOrganizationService.saveBatch(saveRecordList);
// } else {
// List<List<DingOrganization>> split = Lists.partition(saveRecordList, GROUP_SIZE);
// for (List<DingOrganization> segment : split) {
// iDingOrganizationService.saveBatch(segment);
// }
// }
// }
// log.info("----拉取浙政钉组织结构结束---,顶级code:" + orgCode);
// }
// }
// }
//
// private void buildSaveRecordList(List<DingOrgInfoTreeDTO> treeDTOList, List<DingOrganization> saveRecordList) {
// if (CollectionUtils.isEmpty(treeDTOList)) {
// return;
// }
// for (DingOrgInfoTreeDTO dingOrgInfoTreeDTO : treeDTOList) {
// DingOrganization saveRecord = new DingOrganization();
// DingOrgInfoDTO dingOrgInfoDTO = dingOrgInfoTreeDTO.getDingOrgInfoDTO();
// List<DingOrgInfoTreeDTO> childCodes = dingOrgInfoTreeDTO.getChildCodes();
// saveRecord.setDisplayOrder(dingOrgInfoDTO.getDisplayOrder());
//// saveRecord.setEnabled("1");
// saveRecord.setParentCode(dingOrgInfoDTO.getParentCode());
// saveRecord.setOrganizationCode(dingOrgInfoDTO.getOrganizationCode());
//// saveRecord.setSubCount((long) dingOrgInfoTreeDTO.getChildCodes().size());
// saveRecord.setOrganizationName(dingOrgInfoDTO.getOrganizationName());
// saveRecordList.add(saveRecord);
// if (CollectionUtils.isNotEmpty(childCodes)) {
// buildSaveRecordList(childCodes, saveRecordList);
// }
// }
//
// }
//
// private void getDingOrgChild(DingOrgInfoTreeDTO parentDingOrgInfoTreeDTO) {
// String parentOrgCode = parentDingOrgInfoTreeDTO.getCode();
// DingOrgInfoDTO orgInfoDTO = parentDingOrgInfoTreeDTO.getDingOrgInfoDTO();
// boolean leaf = orgInfoDTO.getLeaf();
// if (!leaf) {
// int currentPage = 1;
// int pageSize = 100;
// GenericResult<PageSubOrganizationCodeDTO> pageSubOrganizationCodeDTOGenericResult = zwddClient.pageSubOrganizationCodes(currentPage++, pageSize, parentOrgCode);
// PageSubOrganizationCodeDTO pageSubOrganizationCodeDTO = pageSubOrganizationCodeDTOGenericResult.getData();
//
// if (CollUtil.isNotEmpty(pageSubOrganizationCodeDTO.getSubOrganizationCodeList())) {
// List<String> subOrganizationCodeList = new ArrayList<>(pageSubOrganizationCodeDTO.getSubOrganizationCodeList());
// Long totalSize = pageSubOrganizationCodeDTO.getTotalSize();
//
// while (totalSize > (long) currentPage * pageSize) {
// GenericResult<PageSubOrganizationCodeDTO> subPageSubOrganizationCodeDTOGenericResult = zwddClient
// .pageSubOrganizationCodes(currentPage++, pageSize, parentOrgCode);
// PageSubOrganizationCodeDTO subOrganizationCodeDTO = subPageSubOrganizationCodeDTOGenericResult.getData();
// if (CollectionUtils.isNotEmpty(subOrganizationCodeDTO.getSubOrganizationCodeList())) {
// subOrganizationCodeList.addAll(subOrganizationCodeDTO.getSubOrganizationCodeList());
// }
// }
//
// if (CollectionUtils.isNotEmpty(subOrganizationCodeList)) {
// GenericResult<List<DingOrgInfoDTO>> listGenericResult = zwddClient
// .listOrganizationsByCodes(subOrganizationCodeList);
// List<DingOrgInfoDTO> dingOrgInfoDtos = listGenericResult.getData();
// List<DingOrgInfoTreeDTO> dingOrgInfoTreeDTOList = dingOrgInfoDtos.stream().map(r -> {
// DingOrgInfoTreeDTO dingOrgInfoTreeDTO = new DingOrgInfoTreeDTO();
// dingOrgInfoTreeDTO.setCode(r.getOrganizationCode());
// dingOrgInfoTreeDTO.setDingOrgInfoDTO(r);
// dingOrgInfoTreeDTO.setChildCodes(new ArrayList<>());
// getDingOrgChild(dingOrgInfoTreeDTO);
// return dingOrgInfoTreeDTO;
// }).collect(Collectors.toList());
// parentDingOrgInfoTreeDTO.setChildCodes(dingOrgInfoTreeDTOList);
// }
// }
// }
// }
//
//}
//

+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/controller/TodoCenterController.java Прегледај датотеку

@@ -84,7 +84,7 @@ public class TodoCenterController {
}

/**
* 待办中心-我处理项目列表查询
* 待办中心-我处理项目列表查询
* @param param
* @return
*/


+ 41
- 26
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/manage/TodoCenterManage.java Прегледај датотеку

@@ -66,6 +66,7 @@ import com.wflow.workflow.service.*;
import com.wflow.workflow.utils.Executor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.sf.jsqlparser.statement.select.Distinct;
import org.assertj.core.util.Maps;
import org.flowable.bpmn.model.*;
import org.flowable.bpmn.model.Process;
@@ -135,7 +136,8 @@ public class TodoCenterManage {
// 获取登录用户ID
// long userId = LoginUserUtil.getUserId();

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

TaskQuery taskQuery = taskService.createTaskQuery();
taskQuery.active().taskCandidateOrAssigned(String.valueOf(userId)).orderByTaskCreateTime().desc();
@@ -144,12 +146,8 @@ public class TodoCenterManage {
Set<String> staterUsers = new HashSet<>();
Page<Project> page = param.page();

// 将待办任务流程实例一次性取出来,减少查询次数
Map<String, HistoricProcessInstance> instanceMap = CollectionUtil.isNotEmpty(taskList) ?
historyService.createHistoricProcessInstanceQuery().processInstanceIds(taskList.stream()
.map(Task::getProcessInstanceId).collect(Collectors.toSet()))
.list().stream().collect(Collectors.toMap(HistoricProcessInstance::getId, v -> v)) : new HashMap<>();
List<String> processInsIds = taskList.stream().map(Task::getProcessInstanceId).collect(Collectors.toList());
Map<String, Task> taskMap = taskList.stream().collect(Collectors.toMap(Task::getProcessInstanceId, t -> t));
List<String> taskProcessInsIds = taskList.stream().map(Task::getProcessInstanceId).collect(Collectors.toList());

LambdaQueryWrapper<Project> wrapper = Wrappers.lambdaQuery(Project.class);
wrapper.like(StrUtil.isNotBlank(param.getProjectName()),Project::getProjectName,param.getProjectName())
@@ -159,9 +157,16 @@ public class TodoCenterManage {
.ge(Objects.nonNull(param.getProcessLaunchStartTime()),Project::getBeginTime,param.getProcessLaunchStartTime())
.le(Objects.nonNull(param.getProcessLaunchEndTime()),Project::getEndTime,param.getProcessLaunchEndTime());
projectService.page(page,wrapper);
Set<String> processInsIds = page.getRecords().stream().map(Project::getInstCode).collect(Collectors.toSet());

List<ResToBeProcessedDTO> resVos = page.getRecords().stream().filter(d -> processInsIds.contains(d.getInstCode())).map(d -> {

// 将申报项目流程实例一次性取出来,减少查询次数
Map<String, HistoricProcessInstance> instanceMap = CollectionUtil.isNotEmpty(taskList) ?
historyService.createHistoricProcessInstanceQuery().processInstanceIds(processInsIds)
.list().stream().collect(Collectors.toMap(HistoricProcessInstance::getId, v -> v)) : new HashMap<>();
// 过滤申报项目中待登录用户审核的项目
List<Project> results = page.getRecords().stream().filter(w -> taskProcessInsIds.contains(w.getInstCode())).collect(Collectors.toList());
List<ResToBeProcessedDTO> resVos = results.stream().map(d -> {
ResToBeProcessedDTO res = new ResToBeProcessedDTO();
BeanUtils.copyProperties(d, res);
res.setProcessStatusName(ProcessStatusEnum.getDescByCode(d.getProcessStatus()));
@@ -170,7 +175,8 @@ public class TodoCenterManage {
LocalDateTime launchTime = LocalDateTime.parse(format, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"));
res.setProcessLaunchTime(launchTime);

HistoricTaskInstance task = historyService.createHistoricTaskInstanceQuery().processInstanceId(d.getInstCode()).singleResult();
// 从待办任务列表中取出当前登录用户及项目实例对应的任务
Task task = taskMap.get(d.getInstCode());
HistoricProcessInstance instance = instanceMap.get(task.getProcessInstanceId());
//从缓存取
staterUsers.add(String.valueOf(userId));
@@ -189,7 +195,7 @@ public class TodoCenterManage {
.createTime(instance.getStartTime())
.taskCreateTime(task.getCreateTime())
.build();
res.setProcessTaskInfo(processTaskVo);
res.setProcessTaskInfo(processTaskVo);
return res;
}).collect(Collectors.toList());
//取用户信息,减少数据库查询,一次构建
@@ -202,7 +208,7 @@ public class TodoCenterManage {
// result = resVos.stream().peek(v -> v.setOwner(userMap.get(userId)))
// .collect(Collectors.toList());
}
return PageVo.of(result,page.getTotal());
return PageVo.of(result,resVos.size());
}
/**
* 待办中心列表导出
@@ -243,9 +249,12 @@ public class TodoCenterManage {
public void handler(ReqProcessHandlerDTO param) {

// 获取登录用户ID

// Long userId = LoginUserUtil.getUserId();

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

Long userId = 6418616L;

Task task = taskService.createTaskQuery().taskId(param.getTaskId()).active().singleResult();
HashMap<String, Object> formData = new HashMap<>(32);
@@ -855,22 +864,26 @@ public class TodoCenterManage {
// 获取入参分页信息
Page<Project> page = param.page();

//自定义sql查询所有已办的任务
//自定义sql查询所有已办的任务实例
String nativeSql = "SELECT aht.* FROM ACT_HI_TASKINST AS aht \n" +
"LEFT JOIN ACT_HI_VARINST AS ahv ON SUBSTRING(ahv.NAME_, 9) = aht.ID_ AND ahv.NAME_ LIKE 'approve_%'\n" +
"WHERE aht.ASSIGNEE_ = " + userId + " AND ahv.NAME_ IS NOT NULL \n" +
"ORDER BY aht.END_TIME_ DESC";

NativeHistoricTaskInstanceQuery taskInstanceQuery = historyService.createNativeHistoricTaskInstanceQuery().sql(nativeSql);
List<HistoricTaskInstance> taskInstances = taskInstanceQuery.list();

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

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

List<String> processInsIds = taskInstances.stream().map(HistoricTaskInstance::getProcessInstanceId).collect(Collectors.toList());
LambdaQueryWrapper<Project> wrapper = Wrappers.lambdaQuery(Project.class);
wrapper.like(StrUtil.isNotBlank(param.getProjectName()),Project::getProjectName,param.getProjectName())
.like(StrUtil.isNotBlank(param.getBuildUnitName()),Project::getBuildUnitName,param.getBuildUnitName())
@@ -880,7 +893,13 @@ public class TodoCenterManage {
.le(Objects.nonNull(param.getProcessLaunchEndTime()),Project::getEndTime,param.getProcessLaunchEndTime());
projectService.page(page,wrapper);
Set<String> staterUsers = new HashSet<>();
List<ResToBeProcessedDTO> resVos = page.getRecords().stream().filter(d -> processInsIds.contains(d.getInstCode())).map(d -> {

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

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

ResToBeProcessedDTO res = new ResToBeProcessedDTO();
BeanUtils.copyProperties(d, res);
@@ -894,10 +913,9 @@ public class TodoCenterManage {
LocalDateTime handleTime = LocalDateTime.parse(handleTimeFormat, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"));
res.setProcessHandleTime(handleTime);

HistoricTaskInstance task = historyService.createHistoricTaskInstanceQuery().processInstanceId(d.getInstCode()).singleResult();
// 从已处理任务实例列表中取出当前登录用户及项目实例对应的任务实例
HistoricTaskInstance task = taskInstanceMap.get(d.getInstCode());
HistoricProcessInstance instance = instanceMap.get(task.getProcessInstanceId());
HistoricVariableInstance variableInstance = historyService.createHistoricVariableInstanceQuery()
.processInstanceId(instance.getId()).variableName("approve_" + task.getId()).singleResult();
//从缓存取
staterUsers.add(instance.getStartUserId());
ProcessTaskVo processTaskVo = ProcessTaskVo.builder()
@@ -914,9 +932,6 @@ public class TodoCenterManage {
.ownerId(instance.getStartUserId())
.createTime(instance.getStartTime())
.taskCreateTime(task.getCreateTime())
.taskEndTime(task.getEndTime())
.taskResult(String.valueOf(Objects.nonNull(variableInstance) ?
variableInstance.getValue() : ProcessHandlerParamsVo.Action.recall))
.build();
res.setProcessTaskInfo(processTaskVo);
return res;


+ 2
- 0
pmapi/src/main/java/com/ningdatech/pmapi/todocenter/model/dto/req/ReqToBeProcessedDTO.java Прегледај датотеку

@@ -42,4 +42,6 @@ public class ReqToBeProcessedDTO extends PagePo implements Serializable {
@ApiModelProperty(value = "是否增补项目",allowableValues = "非增补项目 0,增补项目 1")
@NotNull(message = "是否增补字段不能为空!")
private Integer isSupplement;


}

Loading…
Откажи
Сачувај