|
|
@@ -9,15 +9,23 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.hz.pm.api.common.helper.UserInfoHelper; |
|
|
|
import com.hz.pm.api.common.model.constant.BizConst; |
|
|
|
import com.hz.pm.api.common.model.entity.KeyValDTO; |
|
|
|
import com.hz.pm.api.common.statemachine.event.*; |
|
|
|
import com.hz.pm.api.common.util.DecimalUtil; |
|
|
|
import com.hz.pm.api.projectdeclared.model.entity.Purchase; |
|
|
|
import com.hz.pm.api.projectdeclared.service.IPurchaseService; |
|
|
|
import com.hz.pm.api.projectlib.entity.ProjectGovSystemReplaceInfos; |
|
|
|
import com.hz.pm.api.projectlib.entity.PurchaseStatusChange; |
|
|
|
import com.hz.pm.api.projectlib.handle.AbstractProcessHandle.ProcessNode; |
|
|
|
import com.hz.pm.api.projectlib.manage.ProjectLibManage; |
|
|
|
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.req.ProjectListReq; |
|
|
|
import com.hz.pm.api.projectlib.model.vo.ProjectLibListItemVO; |
|
|
|
import com.hz.pm.api.projectlib.service.IProjectGovSystemReplaceInfosService; |
|
|
|
import com.hz.pm.api.projectlib.service.IProjectService; |
|
|
|
import com.hz.pm.api.projectlib.service.IProjectStatusChangeService; |
|
|
|
import com.hz.pm.api.projectlib.service.IPurchaseStatusChangeService; |
|
|
|
import com.hz.pm.api.sys.manage.EarlyWarningManage; |
|
|
|
import com.hz.pm.api.sys.model.entity.WflowEarlyWarningRecords; |
|
|
|
import com.hz.pm.api.sys.service.IEarlyWarningRecordsService; |
|
|
@@ -30,6 +38,8 @@ import com.hz.pm.api.user.helper.MhUnitCache; |
|
|
|
import com.hz.pm.api.user.security.model.UserFullInfoDTO; |
|
|
|
import com.hz.pm.api.user.util.LoginUserUtil; |
|
|
|
import com.hz.pm.api.workbench.converter.WorkbenchConverter; |
|
|
|
import com.hz.pm.api.workbench.model.WorkbenchReq; |
|
|
|
import com.hz.pm.api.workbench.model.vo.ProjectProcessStageStatisticsVO; |
|
|
|
import com.hz.pm.api.workbench.model.vo.ProjectTotalViewVO; |
|
|
|
import com.hz.pm.api.workbench.model.vo.WorkbenchVO; |
|
|
|
import com.ningdatech.basic.model.PageVo; |
|
|
@@ -47,6 +57,7 @@ import java.time.LocalDate; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.temporal.ChronoUnit; |
|
|
|
import java.util.*; |
|
|
|
import java.util.function.ToLongFunction; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
@@ -69,8 +80,11 @@ public class WorkbenchManage { |
|
|
|
private final ProjectLibManage projectLibManage; |
|
|
|
private final EarlyWarningManage earlyWarningManage; |
|
|
|
private final IProjectService projectService; |
|
|
|
private final IProjectStatusChangeService projectStatusChangeService; |
|
|
|
private final IPurchaseService purchaseService; |
|
|
|
private final MhUnitCache mhUnitCache; |
|
|
|
private final IProjectGovSystemReplaceInfosService systemReplaceInfosService; |
|
|
|
private final IPurchaseStatusChangeService purchaseStatusChangeService; |
|
|
|
|
|
|
|
public WorkbenchVO getWorkbenchData(Integer year) { |
|
|
|
WorkbenchVO res = new WorkbenchVO(); |
|
|
@@ -145,20 +159,23 @@ public class WorkbenchManage { |
|
|
|
return "催办成功了" + employees.length + "个人"; |
|
|
|
} |
|
|
|
|
|
|
|
public ProjectTotalViewVO projectTotalView(Long unitId, Integer projectYear) { |
|
|
|
ProjectTotalViewVO retDetail = new ProjectTotalViewVO(); |
|
|
|
if (unitId == null) { |
|
|
|
unitId = LoginUserUtil.loginUserDetail().getMhUnitId(); |
|
|
|
private void initWorkbenchDefaultParam(WorkbenchReq req) { |
|
|
|
if (req.getUnitId() == null) { |
|
|
|
req.setUnitId(LoginUserUtil.loginUserDetail().getMhUnitId()); |
|
|
|
} |
|
|
|
if (projectYear == null) { |
|
|
|
projectYear = LocalDate.now().getYear(); |
|
|
|
if (req.getProjectYear() == null) { |
|
|
|
req.setProjectYear(LocalDate.now().getYear()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public ProjectTotalViewVO projectTotalView(WorkbenchReq req) { |
|
|
|
ProjectTotalViewVO retDetail = new ProjectTotalViewVO(); |
|
|
|
initWorkbenchDefaultParam(req); |
|
|
|
LambdaQueryWrapper<Project> query = Wrappers.lambdaQuery(Project.class) |
|
|
|
.select(Project::getReviewAmount, Project::getApprovalGovOwnFinanceAmount, Project::getId) |
|
|
|
.eq(Project::getProjectYear, projectYear) |
|
|
|
.eq(Project::getProjectYear, req.getProjectYear()) |
|
|
|
.eq(Project::getNewest, Boolean.TRUE); |
|
|
|
List<Long> viewUnitIds = mhUnitCache.getChildIdsRecursion(unitId); |
|
|
|
viewUnitIds.add(unitId); |
|
|
|
List<Long> viewUnitIds = mhUnitCache.getViewChildIdsRecursion(req.getUnitId()); |
|
|
|
query.in(Project::getBuildOrgCode, CollUtils.convert(viewUnitIds, String::valueOf)); |
|
|
|
List<Project> projects = projectService.list(query); |
|
|
|
if (projects.isEmpty()) { |
|
|
@@ -192,4 +209,93 @@ public class WorkbenchManage { |
|
|
|
return retDetail; |
|
|
|
} |
|
|
|
|
|
|
|
public List<ProjectProcessStageStatisticsVO> projectProcessStageStatistics(WorkbenchReq req) { |
|
|
|
initWorkbenchDefaultParam(req); |
|
|
|
List<ProjectProcessStageStatisticsVO> retData = new ArrayList<>(); |
|
|
|
List<Long> projectIds = new ArrayList<>(); |
|
|
|
Map<String, Long> purchaseEventMap = new HashMap<>(); |
|
|
|
ToLongFunction<AbstractStateChangeEvent> getPurchaseCount = event -> purchaseEventMap.getOrDefault(event.name(), 0L); |
|
|
|
long firstInspectedCount = 0; |
|
|
|
for (ProcessNode node : ProcessNode.ALL) { |
|
|
|
long count; |
|
|
|
switch (node) { |
|
|
|
case PROJECT_DECLARED: |
|
|
|
List<Long> viewUnitIds = mhUnitCache.getViewChildIdsRecursion(req.getUnitId()); |
|
|
|
Wrapper<Project> query = Wrappers.lambdaQuery(Project.class) |
|
|
|
.select(Project::getId) |
|
|
|
.eq(Project::getProjectYear, req.getProjectYear()) |
|
|
|
.eq(Project::getNewest, Boolean.TRUE) |
|
|
|
.in(Project::getBuildOrgCode, CollUtils.convert(viewUnitIds, String::valueOf)); |
|
|
|
List<Project> projects = projectService.list(query); |
|
|
|
if (projects.isEmpty()) { |
|
|
|
return retData; |
|
|
|
} |
|
|
|
count = projects.size(); |
|
|
|
projectIds.addAll(CollUtils.fieldList(projects, Project::getId)); |
|
|
|
break; |
|
|
|
case PROJECT_REVIEW: |
|
|
|
count = 0; |
|
|
|
break; |
|
|
|
case APPROVAL_AMOUNT: |
|
|
|
count = projectService.count(Wrappers.lambdaQuery(Project.class) |
|
|
|
.in(Project::getId, projectIds) |
|
|
|
.isNotNull(Project::getApprovalAmount)); |
|
|
|
break; |
|
|
|
case PROJECT_APPROVAL: |
|
|
|
count = projectStatusChangeService.count(Wrappers.lambdaQuery(ProjectStatusChange.class) |
|
|
|
.in(ProjectStatusChange::getProjectId, projectIds) |
|
|
|
.eq(ProjectStatusChange::getEvent, ProjectStateChangeEvent.DECLARED_RECORD_PASS)); |
|
|
|
break; |
|
|
|
case PROJECT_PURCHASE: |
|
|
|
count = purchaseService.count(Wrappers.lambdaQuery(Purchase.class) |
|
|
|
.in(Purchase::getProjectId, projectIds)); |
|
|
|
if (count > 0) { |
|
|
|
Wrapper<PurchaseStatusChange> pQuery = Wrappers.lambdaQuery(PurchaseStatusChange.class) |
|
|
|
.select(PurchaseStatusChange::getEvent) |
|
|
|
.in(PurchaseStatusChange::getProjectId, projectIds) |
|
|
|
.in(PurchaseStatusChange::getEvent, AdaptStateChangeEvent.ADAPT_INFO_PASSED, |
|
|
|
SelfTestStateChangeEvent.SELF_TEST_PASSED, |
|
|
|
TestValidStateChangeEvent.TEST_VALID_INFO_PASSED, |
|
|
|
TenderStateChangeEvent.SUBMIT_FIRST_INSPECTED_FILES, |
|
|
|
XcfhxStateChangeEvent.XCFHX_APPLY_PASSED, |
|
|
|
TenderStateChangeEvent.FINALLY_INSPECTED_PASSED); |
|
|
|
List<PurchaseStatusChange> changes = purchaseStatusChangeService.list(pQuery); |
|
|
|
changes.forEach(change -> purchaseEventMap.merge(change.getEvent(), 1L, Long::sum)); |
|
|
|
} |
|
|
|
break; |
|
|
|
case PROJECT_ADAPTION: |
|
|
|
count = getPurchaseCount.applyAsLong(AdaptStateChangeEvent.ADAPT_INFO_PASSED); |
|
|
|
break; |
|
|
|
case SYSTEM_SELF_TEST: |
|
|
|
count = getPurchaseCount.applyAsLong(SelfTestStateChangeEvent.SELF_TEST_PASSED); |
|
|
|
break; |
|
|
|
case SYSTEM_TEST_VALID: |
|
|
|
count = getPurchaseCount.applyAsLong(TestValidStateChangeEvent.TEST_VALID_INFO_PASSED); |
|
|
|
break; |
|
|
|
case FIRST_INSPECTED: |
|
|
|
count = getPurchaseCount.applyAsLong(TenderStateChangeEvent.SUBMIT_FIRST_INSPECTED_FILES); |
|
|
|
firstInspectedCount = count; |
|
|
|
break; |
|
|
|
case PILOT_RUNNING: |
|
|
|
count = firstInspectedCount; |
|
|
|
break; |
|
|
|
case XCFHX_REVIEW: |
|
|
|
count = getPurchaseCount.applyAsLong(XcfhxStateChangeEvent.XCFHX_APPLY_PASSED); |
|
|
|
break; |
|
|
|
case FINAL_INSPECTED: |
|
|
|
count = getPurchaseCount.applyAsLong(TenderStateChangeEvent.FINALLY_INSPECTED_PASSED); |
|
|
|
break; |
|
|
|
default: |
|
|
|
count = 0; |
|
|
|
break; |
|
|
|
} |
|
|
|
retData.add(ProjectProcessStageStatisticsVO.builder() |
|
|
|
.stage(node) |
|
|
|
.stageName(node.getName()) |
|
|
|
.count((int) count) |
|
|
|
.build()); |
|
|
|
} |
|
|
|
return retData; |
|
|
|
} |
|
|
|
|
|
|
|
} |