|
|
@@ -23,12 +23,15 @@ import com.hz.pm.api.projectlib.entity.ProjectGovSystemReplaceInfos; |
|
|
|
import com.hz.pm.api.projectlib.entity.PurchaseStatusChange; |
|
|
|
import com.hz.pm.api.projectlib.helper.ProjectManageUtil; |
|
|
|
import com.hz.pm.api.projectlib.manage.ProjectLibManage; |
|
|
|
import com.hz.pm.api.projectlib.model.dto.GovSystemReplaceInfoDTO; |
|
|
|
import com.hz.pm.api.projectlib.model.entity.Project; |
|
|
|
import com.hz.pm.api.projectlib.model.entity.ProjectStatusChange; |
|
|
|
import com.hz.pm.api.projectlib.model.enumeration.GovSystemReplaceTypeEnum; |
|
|
|
import com.hz.pm.api.projectlib.model.enumeration.status.ProjectStatus; |
|
|
|
import com.hz.pm.api.projectlib.model.req.ProjectListReq; |
|
|
|
import com.hz.pm.api.projectlib.model.vo.ProjectLibListItemVO; |
|
|
|
import com.hz.pm.api.projectlib.model.vo.SystemReplaceInfoVO; |
|
|
|
import com.hz.pm.api.projectlib.model.vo.UnitProjectGovSystemReplaceVO; |
|
|
|
import com.hz.pm.api.projectlib.model.vo.UnitProjectGovSystemReplaceVO.ProjectGovSystemReplaceVO; |
|
|
|
import com.hz.pm.api.projectlib.service.IProjectGovSystemReplaceInfosService; |
|
|
|
import com.hz.pm.api.projectlib.service.IProjectService; |
|
|
|
import com.hz.pm.api.projectlib.service.IProjectStatusChangeService; |
|
|
@@ -68,6 +71,7 @@ import java.time.LocalDate; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.temporal.ChronoUnit; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
|
import java.util.function.BiFunction; |
|
|
|
import java.util.function.Predicate; |
|
|
|
import java.util.stream.Collectors; |
|
|
@@ -188,7 +192,7 @@ public class WorkbenchManage { |
|
|
|
initWorkbenchDefaultParam(req); |
|
|
|
LambdaQueryWrapper<Project> projectQuery = Wrappers.lambdaQuery(Project.class) |
|
|
|
.select(Project::getReviewAmount, Project::getApprovalAmount, Project::getId, |
|
|
|
Project::getApprovalGovOwnFinanceAmount,Project::getApprovalGovSuperiorFinanceAmount) |
|
|
|
Project::getApprovalGovOwnFinanceAmount, Project::getApprovalGovSuperiorFinanceAmount) |
|
|
|
.eq(Project::getProjectYear, req.getProjectYear()) |
|
|
|
.eq(req.getUnitStrip() != null, Project::getUnitStrip, req.getUnitStrip()) |
|
|
|
.eq(Project::getNewest, Boolean.TRUE); |
|
|
@@ -520,23 +524,7 @@ public class WorkbenchManage { |
|
|
|
} |
|
|
|
|
|
|
|
public PageVo<ProjectLibListItemVO> pageProjectLib(WorkbenchProjectLibReq req) { |
|
|
|
Assert.notNull(req.getProcessNode(), "节点不能为空"); |
|
|
|
Long unitId = Optional.ofNullable(req.getUnitId()).orElseGet(LoginUserUtil::getMhUnitId); |
|
|
|
List<Long> viewUnitIds = mhUnitCache.getViewChildIdsRecursion(unitId); |
|
|
|
LambdaQueryWrapper<Project> query = Wrappers.lambdaQuery(Project.class) |
|
|
|
.eq(req.getProjectYear() != null, Project::getProjectYear, req.getProjectYear()) |
|
|
|
.like(StrUtil.isNotBlank(req.getBuildOrg()), Project::getBuildOrgName, req.getBuildOrg()) |
|
|
|
.like(StrUtil.isNotBlank(req.getProjectName()), Project::getProjectName, req.getProjectName()) |
|
|
|
.in(Project::getBuildOrgCode, CollUtils.convert(viewUnitIds, String::valueOf)) |
|
|
|
// 评审金额 |
|
|
|
.ge(req.getReviewAmountMin() != null, Project::getReviewAmount, req.getReviewAmountMin()) |
|
|
|
.le(req.getReviewAmountMax() != null, Project::getReviewAmount, req.getReviewAmountMax()) |
|
|
|
// 下达金额 |
|
|
|
.ge(req.getApproveAmountMin() != null, Project::getApprovalAmount, req.getApproveAmountMin()) |
|
|
|
.le(req.getApproveAmountMax() != null, Project::getApprovalAmount, req.getApproveAmountMax()) |
|
|
|
.eq(req.getUnitStrip() != null, Project::getUnitStrip, req.getUnitStrip()) |
|
|
|
.eq(Project::getNewest, Boolean.TRUE) |
|
|
|
.orderByDesc(Project::getUpdateOn); |
|
|
|
LambdaQueryWrapper<Project> query = workbenchProjectLibQuery(req); |
|
|
|
ProjectManageUtil.projectBaseQuery(query); |
|
|
|
projectQueryByProjectStatusChange(query, ProjectStateChangeEvent.PROJECT_APPLICATION_SUBMIT); |
|
|
|
switch (req.getProcessNode()) { |
|
|
@@ -590,4 +578,123 @@ public class WorkbenchManage { |
|
|
|
return PageVo.of(records, page.getTotal()); |
|
|
|
} |
|
|
|
|
|
|
|
public SystemReplaceInfoVO listSystemReplaceInfos(WorkbenchProjectLibReq req) { |
|
|
|
LambdaQueryWrapper<Project> query = workbenchProjectLibQuery(req) |
|
|
|
.select(Project::getProjectCode, Project::getProjectName, |
|
|
|
Project::getBuildOrgCode, Project::getBuildOrgName); |
|
|
|
projectQueryByProjectStatusChange(query, ProjectStateChangeEvent.PROJECT_APPLICATION_SUBMIT); |
|
|
|
switch (req.getProcessNode()) { |
|
|
|
case PROJECT_DECLARED: |
|
|
|
break; |
|
|
|
case PROJECT_REVIEW: |
|
|
|
projectQueryByProjectStatusChange(query, ProjectStateChangeEvent.PROJECT_REVIEW_PASS); |
|
|
|
break; |
|
|
|
case APPROVAL_AMOUNT: |
|
|
|
query.isNotNull(Project::getApprovalAmount).gt(Project::getApprovalAmount, BigDecimal.ZERO); |
|
|
|
break; |
|
|
|
case PROJECT_APPROVAL: |
|
|
|
projectQueryByProjectStatusChange(query, ProjectStateChangeEvent.DECLARED_RECORD_SUBMIT); |
|
|
|
break; |
|
|
|
case PROJECT_PURCHASE: |
|
|
|
projectQueryByProjectStatusChange(query, ProjectStateChangeEvent.SUBMIT_PURCHASE_CONTRACT_RECORD); |
|
|
|
break; |
|
|
|
case FIRST_INSPECTED: |
|
|
|
projectQueryByProjectStatusChange(query, ProjectStateChangeEvent.SUBMIT_FIRST_INSPECTED_FILES); |
|
|
|
break; |
|
|
|
case PROJECT_ADAPTION: |
|
|
|
projectQueryByProjectStatusChange(query, ProjectStateChangeEvent.SUBMIT_PURCHASE_ORG_CONFIRM); |
|
|
|
break; |
|
|
|
case FINAL_INSPECTED: |
|
|
|
projectQueryByProjectStatusChange(query, ProjectStateChangeEvent.FINAL_ACCEPTANCE_PASS); |
|
|
|
break; |
|
|
|
default: |
|
|
|
return null; |
|
|
|
} |
|
|
|
List<Project> projects = projectService.list(query); |
|
|
|
return buildSystemReplaceInfos(projects); |
|
|
|
} |
|
|
|
|
|
|
|
private LambdaQueryWrapper<Project> workbenchProjectLibQuery(WorkbenchProjectLibReq req) { |
|
|
|
Assert.notNull(req.getProcessNode(), "节点不能为空"); |
|
|
|
Long unitId = Optional.ofNullable(req.getUnitId()).orElseGet(LoginUserUtil::getMhUnitId); |
|
|
|
List<Long> viewUnitIds = mhUnitCache.getViewChildIdsRecursion(unitId); |
|
|
|
return Wrappers.lambdaQuery(Project.class) |
|
|
|
.eq(req.getProjectYear() != null, Project::getProjectYear, req.getProjectYear()) |
|
|
|
.like(StrUtil.isNotBlank(req.getBuildOrg()), Project::getBuildOrgName, req.getBuildOrg()) |
|
|
|
.like(StrUtil.isNotBlank(req.getProjectName()), Project::getProjectName, req.getProjectName()) |
|
|
|
.in(Project::getBuildOrgCode, CollUtils.convert(viewUnitIds, String::valueOf)) |
|
|
|
.ge(req.getReviewAmountMin() != null, Project::getReviewAmount, req.getReviewAmountMin()) |
|
|
|
.le(req.getReviewAmountMax() != null, Project::getReviewAmount, req.getReviewAmountMax()) |
|
|
|
.ge(req.getApproveAmountMin() != null, Project::getApprovalAmount, req.getApproveAmountMin()) |
|
|
|
.le(req.getApproveAmountMax() != null, Project::getApprovalAmount, req.getApproveAmountMax()) |
|
|
|
.eq(req.getUnitStrip() != null, Project::getUnitStrip, req.getUnitStrip()) |
|
|
|
.eq(Project::getNewest, Boolean.TRUE) |
|
|
|
.orderByDesc(Project::getUpdateOn); |
|
|
|
} |
|
|
|
|
|
|
|
private SystemReplaceInfoVO buildSystemReplaceInfos(List<Project> projects) { |
|
|
|
if (projects.isEmpty()) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
List<String> projectCodes = CollUtils.fieldList(projects, Project::getProjectCode); |
|
|
|
Wrapper<ProjectGovSystemReplaceInfos> query = Wrappers.lambdaQuery(ProjectGovSystemReplaceInfos.class) |
|
|
|
.in(ProjectGovSystemReplaceInfos::getProjectCode, projectCodes); |
|
|
|
List<ProjectGovSystemReplaceInfos> systemReplaceInfos = systemReplaceInfosService.list(query); |
|
|
|
if (systemReplaceInfos.isEmpty()) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
SystemReplaceInfoVO retDetail = new SystemReplaceInfoVO(); |
|
|
|
Map<String, List<ProjectGovSystemReplaceInfos>> projectSystemMap = CollUtils.group(systemReplaceInfos, |
|
|
|
ProjectGovSystemReplaceInfos::getProjectCode); |
|
|
|
Map<String, List<Project>> unitProjectMap = CollUtils.group(projects, Project::getBuildOrgCode); |
|
|
|
List<UnitProjectGovSystemReplaceVO> retList = new ArrayList<>(); |
|
|
|
AtomicInteger sourceCount = new AtomicInteger(0); |
|
|
|
AtomicInteger targetCount = new AtomicInteger(0); |
|
|
|
for (Map.Entry<String, List<Project>> entry : unitProjectMap.entrySet()) { |
|
|
|
List<Project> tmpProjects = entry.getValue(); |
|
|
|
List<ProjectGovSystemReplaceVO> currOrgReplaceInfos = new ArrayList<>(); |
|
|
|
for (Project proj : tmpProjects) { |
|
|
|
List<ProjectGovSystemReplaceInfos> replaceInfos = projectSystemMap.get(proj.getProjectCode()); |
|
|
|
if (replaceInfos != null) { |
|
|
|
ProjectGovSystemReplaceVO projectSystem = new ProjectGovSystemReplaceVO(); |
|
|
|
projectSystem.setProjectName(proj.getProjectName()); |
|
|
|
currOrgReplaceInfos.add(projectSystem); |
|
|
|
Map<Integer, List<ProjectGovSystemReplaceInfos>> replaceInfoGroup = CollUtils.group(replaceInfos, |
|
|
|
ProjectGovSystemReplaceInfos::getBatchNo); |
|
|
|
List<GovSystemReplaceInfoDTO> replaceInfoList = replaceInfoGroup.entrySet().stream() |
|
|
|
.sorted(Comparator.comparingInt(Map.Entry::getKey)) |
|
|
|
.map(w -> { |
|
|
|
List<ProjectGovSystemReplaceInfos> currBatchValues = w.getValue(); |
|
|
|
ProjectGovSystemReplaceInfos firstReplaceInfo = currBatchValues.get(0); |
|
|
|
GovSystemReplaceInfoDTO replaceInfo = new GovSystemReplaceInfoDTO(); |
|
|
|
replaceInfo.setReplaceType(firstReplaceInfo.getReplaceType()); |
|
|
|
replaceInfo.setTargetSystemName(firstReplaceInfo.getTargetSystem()); |
|
|
|
List<String> sourceSystemNames = CollUtils.fieldList(currBatchValues, val -> { |
|
|
|
String sourceSystem = val.getSourceSystem(); |
|
|
|
if (isValidSystem.test(sourceSystem)) { |
|
|
|
sourceCount.incrementAndGet(); |
|
|
|
} |
|
|
|
return sourceSystem; |
|
|
|
}); |
|
|
|
replaceInfo.setSourceSystemNames(sourceSystemNames); |
|
|
|
if (isValidSystem.test(replaceInfo.getTargetSystemName())) { |
|
|
|
targetCount.incrementAndGet(); |
|
|
|
} |
|
|
|
return replaceInfo; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
projectSystem.setReplaceSystems(replaceInfoList); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!currOrgReplaceInfos.isEmpty()) { |
|
|
|
UnitProjectGovSystemReplaceVO item = new UnitProjectGovSystemReplaceVO(); |
|
|
|
item.setUnitName(tmpProjects.get(0).getBuildOrgName()); |
|
|
|
item.setProjectSystemReplaces(currOrgReplaceInfos); |
|
|
|
retList.add(item); |
|
|
|
} |
|
|
|
} |
|
|
|
retDetail.setBeforeReplace(sourceCount.get()); |
|
|
|
retDetail.setAfterReplace(targetCount.get()); |
|
|
|
retDetail.setReplaceDetail(retList); |
|
|
|
return retDetail; |
|
|
|
} |
|
|
|
} |