diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java index ac14006..76a8aba 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java @@ -22,6 +22,7 @@ import com.ningdatech.pmapi.common.constant.RegionConst; import com.ningdatech.pmapi.common.enumeration.CommonEnum; import com.ningdatech.pmapi.common.enumeration.ProjectProcessStageEnum; import com.ningdatech.pmapi.common.helper.RegionCacheHelper; +import com.ningdatech.pmapi.common.helper.UserInfoHelper; import com.ningdatech.pmapi.common.model.entity.ExcelExportWriter; import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils; import com.ningdatech.pmapi.common.util.BizUtils; @@ -72,6 +73,7 @@ import com.ningdatech.pmapi.safety.service.IPersonSafetyInfoService; import com.ningdatech.pmapi.safety.service.ISupplierSafetyQualificationService; import com.ningdatech.pmapi.todocenter.model.req.ProcessDetailReq; import com.ningdatech.pmapi.todocenter.service.ITodoService; +import com.ningdatech.pmapi.user.entity.UserInfo; import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; import com.ningdatech.pmapi.user.util.LoginUserUtil; @@ -80,6 +82,8 @@ import com.wflow.workflow.bean.vo.ProcessDetailVO; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.flowable.engine.TaskService; +import org.flowable.task.api.Task; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Component; @@ -133,6 +137,10 @@ public class ProjectLibManage { private final ApplicationHandler applicationHandler; + private final TaskService taskService; + + private final UserInfoHelper userInfoHelper; + public PageVo projectLibList(ProjectListReq req) { LambdaQueryWrapper query = ProjectHelper.projectQuery(req); query.eq(Project::getNewest, Boolean.TRUE); @@ -272,6 +280,97 @@ public class ProjectLibManage { } /** + * 项目列表带当前审批人(工作流的) + * @param req + * @param user + * @return + */ + public PageVo projectLibListApprove(ProjectListReq req, UserFullInfoDTO user) { + LambdaQueryWrapper query = ProjectHelper.projectQuery(req); + user = buildProjectLibPermission(query, user); + //项目查最新 + query.eq(Project::getNewest, Boolean.TRUE); + Page page = projectService.page(req.page(), query); + if (CollUtil.isEmpty(page.getRecords())) { + return PageVo.empty(); + } + UserFullInfoDTO finalUser = user; + + Set projectCodes = page.getRecords().stream() + .map(Project::getProjectCode).collect(Collectors.toSet()); + Set instCodes = page.getRecords().stream() + .map(Project::getInstCode).collect(Collectors.toSet()); + List tasks = taskService.createTaskQuery() + .processInstanceIdIn(instCodes) + .orderByTaskCreateTime() + .asc() + .list(); + Map> map = Maps.newHashMap(); + Map userMap = Maps.newHashMap(); + if(CollUtil.isNotEmpty(tasks)){ + map = tasks.stream() + .collect(Collectors.groupingBy(Task::getProcessInstanceId)); + userMap = searchUser(tasks,userInfoHelper); + } + + List records = Lists.newArrayList(); + for(Project w : page.getRecords()){ + ProjectLibListItemVO item = new ProjectLibListItemVO(); + item.setId(w.getId()); + item.setProjectName(w.getProjectName()); + item.setProjectCode(w.getProjectCode()); + item.setArea(w.getArea()); + item.setAreaCode(w.getAreaCode()); + item.setCreateOn(w.getCreateOn()); + item.setDeclaredAmount(w.getDeclareAmount()); + item.setStage(w.getStage()); + item.setStatus(w.getStatus()); + item.setProjectType(w.getProjectType()); + item.setProjectYear(w.getProjectYear()); + item.setBuildOrg(w.getBuildOrgName()); + item.setBizDomain(w.getBizDomain()); + item.setProcessStatus(w.getProcessStatus()); + item.setInstCode(w.getInstCode()); + item.setIsHigherSuperOrg(w.getIsHigherSuperOrg()); + item.setApproveUsers(buildApproveUsers(w.getInstCode(),map,userMap)); + if (finalUser.getIsOrgAdmin() && + ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode().equals(item.getStatus()) + && StringUtils.isNotBlank(w.getSuperOrgCode()) && StringUtils.isNotBlank(finalUser.getEmpPosUnitCode()) + && w.getSuperOrgCode().equals(finalUser.getEmpPosUnitCode())) { + item.setCanPreDeclared(Boolean.TRUE); + } + item.setApprovedAmount(w.getApprovalAmount()); + item.setAnnualPlanAmount(w.getAnnualPlanAmount()); + item.setPrePlanProjectId(w.getPrePlanProjectId()); + records.add(item); + } + return PageVo.of(records, page.getTotal()); + } + + private List buildApproveUsers(String instCode, Map> map, + Map userMap) { + if(map.containsKey(instCode)){ + List tasks = map.get(instCode); + return tasks.stream().map(task -> userMap.get(task.getAssignee())) + .filter(Objects::nonNull).collect(Collectors.toList()); + } + return Collections.emptyList(); + } + + private Map searchUser(List tasks, UserInfoHelper userInfoHelper) { + if(CollUtil.isNotEmpty(tasks)){ + return Collections.emptyMap(); + } + List users = userInfoHelper.getUserFullInfoByEmployeeCodes( + tasks.stream().map(Task::getAssignee).collect(Collectors.toSet())); + if(CollUtil.isNotEmpty(users)){ + return users.stream().collect(Collectors + .toMap(UserFullInfoDTO::getEmployeeCode,u -> u)); + } + return Collections.emptyMap(); + } + + /** * 项目申报和项目归集的并集 * @param req * @param user diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectLibListItemVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectLibListItemVO.java index 1f619ce..48d1646 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectLibListItemVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectLibListItemVO.java @@ -9,6 +9,8 @@ import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum; import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeNewEnum; import com.ningdatech.pmapi.projectlib.model.entity.ProjectRenewalFundDeclaration; +import com.ningdatech.pmapi.user.entity.UserInfo; +import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; import com.ningdatech.pmapi.user.util.LoginUserUtil; import io.swagger.annotations.ApiModel; @@ -163,6 +165,9 @@ public class ProjectLibListItemVO { //预审申报时候 需不需要上传上级条线意见文件 private Boolean needUploadSuperLineFile; + @ApiModelProperty("当前审批人") + private List approveUsers; + @ApiModelProperty("年度投资金额总额") private BigDecimal annualAccumulateAmount; private List annualAccumulateAmountList; diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java index 67c610c..6064de3 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/workbench/manage/WorkbenchManage.java @@ -130,7 +130,7 @@ public class WorkbenchManage { projectListReq.setPageSize(5); projectListReq.setProjectYear(year); projectListReq.setBuildOrgCode(user.getEmpPosUnitCode()); - res.setProjects(new ArrayList<>(projectLibManage.projectLibListWithPermission(projectListReq, user).getRecords())); + res.setProjects(new ArrayList<>(projectLibManage.projectLibListApprove(projectListReq, user).getRecords())); return res; } }