Переглянути джерело

驾驶舱 项目画像接口

tags/24080901
PoffyZhang 1 рік тому
джерело
коміт
ac6c13f623
1 змінених файлів з 70 додано та 9 видалено
  1. +70
    -9
      pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/DashboardProjectManage.java

+ 70
- 9
pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/DashboardProjectManage.java Переглянути файл

@@ -1,6 +1,9 @@
package com.ningdatech.pmapi.dashboard.manage;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
@@ -24,11 +27,18 @@ import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.projectlib.model.entity.ProjectDelayApply;
import com.ningdatech.pmapi.projectlib.service.INdProjectDelayApplyService;
import com.ningdatech.pmapi.projectlib.service.IProjectService;
import com.ningdatech.pmapi.sys.model.req.NoticeListReq;
import com.ningdatech.pmapi.todocenter.model.req.ToBeProcessedReq;
import com.ningdatech.pmapi.todocenter.model.vo.TodoCenterStatisticsVO;
import com.ningdatech.pmapi.workbench.converter.WorkbenchConverter;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ForkJoinPool;
import java.util.stream.Collectors;

/**
@@ -341,8 +351,9 @@ public class DashboardProjectManage {

//2.转换项目信息
ProtraitProjectInfoVO projectInfo = BeanUtil.copyProperties(project,ProtraitProjectInfoVO.class);
//todo: 超期逻辑
projectInfo.setOverdueSituation("即将超期");
projectInfo.setSafetyInputRate("3%");
projectInfo.setSafetyInputRate(convertSafetyInputRate(project));
//3.项目状态情况
projectInfo.setStatusSituation(generateProjectStatus(project));
res.setProjectInfo(projectInfo);
@@ -357,29 +368,79 @@ public class DashboardProjectManage {
}

/**
* 计算安全投入
* @param project
* @return
*/
private String convertSafetyInputRate(Project project) {
String safetyInputDescribe = project.getSafetyInputDescribe();
if(org.apache.commons.lang3.StringUtils.isNotBlank(safetyInputDescribe)){
JSONArray array = JSON.parseArray(safetyInputDescribe);
final Integer[] total = {0};
array.forEach(j -> {
JSONObject json = JSON.parseObject(JSON.toJSONString(j));
Integer safetyInputAmount = json.getInteger("safetyInputAmount");
total[0] += safetyInputAmount;
});
Integer totalAmount = total[0];
//申报金额
BigDecimal declareAmount = project.getDeclareAmount();
if(Objects.isNull(declareAmount) || declareAmount.compareTo(BigDecimal.ZERO) == 0){
return "0%";
}
BigDecimal rate = BigDecimal.valueOf(totalAmount).multiply(BigDecimal.valueOf(100))
.divide(declareAmount,BigDecimal.ROUND_CEILING, RoundingMode.HALF_UP)
.stripTrailingZeros();
return rate.toPlainString() + "%";
}
return "0%";
}

/**
* 生成项目 状态流转信息
* @param project
* @return
*/
private List<ProtraitProjectStatusSituationVO> generateProjectStatus(Project project) {
List<ProtraitProjectStatusSituationVO> res = Lists.newArrayList();
final List<ProtraitProjectStatusSituationVO> res = Lists.newArrayList();
//1.计划(单位内部审核)
res.add(statusHandler.generateApproveStatus(project,DashboardConstant.Protrait.PLAN,InstTypeEnum.UNIT_INNER_AUDIT.getCode()));
res.add(new ProtraitProjectStatusSituationVO());
//2.申报(项目预审)
res.add(statusHandler.generateApproveStatus(project,DashboardConstant.Protrait.DECLARED,InstTypeEnum.PRELIMINARY_PREVIEW.getCode()));
res.add(new ProtraitProjectStatusSituationVO());
//3.审批(建设方案审批)
res.add(statusHandler.generateApproveStatus(project,DashboardConstant.Protrait.APPROVE,InstTypeEnum.CONSTRUCTION_PLAN_REVIEW.getCode()));
res.add(new ProtraitProjectStatusSituationVO());
//4.建设(立项后的建设中)
res.add(statusHandler.generateStatus(project,DashboardConstant.Protrait.CONSTRUCTION,
ProjectStatusEnum.UNDER_CONSTRUCTION.getCode(),ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode()));
res.add(new ProtraitProjectStatusSituationVO());
//5.验收(终验)
res.add(statusHandler.generateApproveStatus(project,DashboardConstant.Protrait.ACCEPT,InstTypeEnum.PROJECT_FINAL_INSPECTION.getCode()));
res.add(new ProtraitProjectStatusSituationVO());
//6.运维(todo: 运维时间还没有)
res.add(ProtraitProjectStatusSituationVO.builder().statusName(DashboardConstant.Protrait.OPERATION).build());
//7.绩效
res.add(statusHandler.generatePerformanceStatus(project));
res.add(new ProtraitProjectStatusSituationVO());
//8.注销(todo: 还没有注销功能)
res.add(ProtraitProjectStatusSituationVO.builder().statusName(DashboardConstant.Protrait.LOG_OFF).build());

CompletableFuture.allOf(
CompletableFuture.runAsync(() -> {
res.set(0,statusHandler.generateApproveStatus(project,DashboardConstant.Protrait.PLAN,InstTypeEnum.UNIT_INNER_AUDIT.getCode()));
}, ForkJoinPool.commonPool()),
CompletableFuture.runAsync(() -> {
res.set(1,statusHandler.generateApproveStatus(project,DashboardConstant.Protrait.DECLARED,InstTypeEnum.PRELIMINARY_PREVIEW.getCode()));
}, ForkJoinPool.commonPool()),
CompletableFuture.runAsync(() -> {
res.set(2,statusHandler.generateApproveStatus(project,DashboardConstant.Protrait.APPROVE,InstTypeEnum.CONSTRUCTION_PLAN_REVIEW.getCode()));
}, ForkJoinPool.commonPool()),
CompletableFuture.runAsync(() -> {
res.set(3,statusHandler.generateStatus(project,DashboardConstant.Protrait.CONSTRUCTION,
ProjectStatusEnum.UNDER_CONSTRUCTION.getCode(),ProjectStatusEnum.TO_BE_FINALLY_INSPECTED.getCode()));
}, ForkJoinPool.commonPool()),
CompletableFuture.runAsync(() -> {
res.set(4,statusHandler.generateApproveStatus(project,DashboardConstant.Protrait.ACCEPT,InstTypeEnum.PROJECT_FINAL_INSPECTION.getCode()));
}, ForkJoinPool.commonPool()),
CompletableFuture.runAsync(() -> {
res.set(6, statusHandler.generatePerformanceStatus(project));
}, ForkJoinPool.commonPool())
).join();
return res;
}
}

Завантаження…
Відмінити
Зберегти