|
|
@@ -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<ProjectLibListItemVO> projectLibList(ProjectListReq req) { |
|
|
|
LambdaQueryWrapper<Project> query = ProjectHelper.projectQuery(req); |
|
|
|
query.eq(Project::getNewest, Boolean.TRUE); |
|
|
@@ -272,6 +280,97 @@ public class ProjectLibManage { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 项目列表带当前审批人(工作流的) |
|
|
|
* @param req |
|
|
|
* @param user |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public PageVo<ProjectLibListItemVO> projectLibListApprove(ProjectListReq req, UserFullInfoDTO user) { |
|
|
|
LambdaQueryWrapper<Project> query = ProjectHelper.projectQuery(req); |
|
|
|
user = buildProjectLibPermission(query, user); |
|
|
|
//项目查最新 |
|
|
|
query.eq(Project::getNewest, Boolean.TRUE); |
|
|
|
Page<Project> page = projectService.page(req.page(), query); |
|
|
|
if (CollUtil.isEmpty(page.getRecords())) { |
|
|
|
return PageVo.empty(); |
|
|
|
} |
|
|
|
UserFullInfoDTO finalUser = user; |
|
|
|
|
|
|
|
Set<String> projectCodes = page.getRecords().stream() |
|
|
|
.map(Project::getProjectCode).collect(Collectors.toSet()); |
|
|
|
Set<String> instCodes = page.getRecords().stream() |
|
|
|
.map(Project::getInstCode).collect(Collectors.toSet()); |
|
|
|
List<Task> tasks = taskService.createTaskQuery() |
|
|
|
.processInstanceIdIn(instCodes) |
|
|
|
.orderByTaskCreateTime() |
|
|
|
.asc() |
|
|
|
.list(); |
|
|
|
Map<String, List<Task>> map = Maps.newHashMap(); |
|
|
|
Map<String,UserFullInfoDTO> userMap = Maps.newHashMap(); |
|
|
|
if(CollUtil.isNotEmpty(tasks)){ |
|
|
|
map = tasks.stream() |
|
|
|
.collect(Collectors.groupingBy(Task::getProcessInstanceId)); |
|
|
|
userMap = searchUser(tasks,userInfoHelper); |
|
|
|
} |
|
|
|
|
|
|
|
List<ProjectLibListItemVO> 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<UserFullInfoDTO> buildApproveUsers(String instCode, Map<String, List<Task>> map, |
|
|
|
Map<String, UserFullInfoDTO> userMap) { |
|
|
|
if(map.containsKey(instCode)){ |
|
|
|
List<Task> tasks = map.get(instCode); |
|
|
|
return tasks.stream().map(task -> userMap.get(task.getAssignee())) |
|
|
|
.filter(Objects::nonNull).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
return Collections.emptyList(); |
|
|
|
} |
|
|
|
|
|
|
|
private Map<String, UserFullInfoDTO> searchUser(List<Task> tasks, UserInfoHelper userInfoHelper) { |
|
|
|
if(CollUtil.isNotEmpty(tasks)){ |
|
|
|
return Collections.emptyMap(); |
|
|
|
} |
|
|
|
List<UserFullInfoDTO> 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 |
|
|
|