Browse Source

优化统计报表

tags/24080901
PoffyZhang 1 year ago
parent
commit
8ff36b0987
4 changed files with 175 additions and 15 deletions
  1. +20
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/common/util/BizUtils.java
  2. +11
    -5
      pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/FundStatisticsManage.java
  3. +53
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/gov/enumeration/GovProjectClassifiedEnum.java
  4. +91
    -10
      pmapi/src/main/java/com/ningdatech/pmapi/gov/utils/ProjectConvertUtil.java

+ 20
- 0
pmapi/src/main/java/com/ningdatech/pmapi/common/util/BizUtils.java View File

@@ -153,4 +153,24 @@ public class BizUtils {
jsonArray.add(resultVo);
return JSON.toJSONString(jsonArray);
}

public static LocalDateTime convertLocalDateTime(String time) {
if(StringUtils.isBlank(time)){
return null;
}
String[] timeSplit = time.split(StrPool.DASH);
String year = timeSplit[0];
String month = "01";
String dayOfMonth = "01";
if(timeSplit.length > 1){
month = timeSplit[1];
}
if(timeSplit.length > 2){
dayOfMonth = timeSplit[2];
}
return LocalDateTime.of(Integer.parseInt(year),
Integer.parseInt(month),
Integer.parseInt(dayOfMonth)
,0,0,0);
}
}

+ 11
- 5
pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/FundStatisticsManage.java View File

@@ -17,12 +17,14 @@ import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.projectlib.service.IProjectService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ForkJoinPool;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@@ -414,6 +416,7 @@ public class FundStatisticsManage {
List<GovBizProjectProcure> procures) {
//申报项目颗粒度
Map<String, List<Project>> groupProjectMap = projects.stream()
.filter(p -> StringUtils.isNotBlank(p.getBuildOrgCode()))
.collect(Collectors.groupingBy(Project::getBuildOrgCode));
List<FundStatisticsVO.AmountData> projectAmounts = Lists.newArrayList();
for(Map.Entry<String, List<Project>> entry : groupProjectMap.entrySet()){
@@ -430,6 +433,7 @@ public class FundStatisticsManage {

//项目归集颗粒度
Map<String, List<GovBizProjectBaseinfo>> groupGovMap = baseInfos.stream()
.filter(b -> StringUtils.isNotBlank(b.getBaseBuildDeprtDing()))
.collect(Collectors.groupingBy(GovBizProjectBaseinfo::getBaseBuildDeprtDing));
List<FundStatisticsVO.AmountData> govAmounts = Lists.newArrayList();
for(Map.Entry<String, List<GovBizProjectBaseinfo>> entry : groupGovMap.entrySet()){
@@ -455,11 +459,13 @@ public class FundStatisticsManage {
}

//求出TOP10
List<FundStatisticsVO.AmountData> res = Stream.concat(projectAmounts.stream(),
govAmounts.stream())
.sorted(Comparator.comparing(FundStatisticsVO.AmountData::getAmount).reversed())
return Stream.concat(projectAmounts.stream(), govAmounts.stream())
.collect(Collectors.toMap(FundStatisticsVO.AmountData::getName, Function.identity(),
(v1, v2) -> {
v1.setAmount(v1.getAmount().add(v2.getAmount()));
return v1;
})).values().stream()
.sorted(Comparator.comparing(FundStatisticsVO.AmountData::getAmount))
.limit(10).collect(Collectors.toList());

return res;
}
}

+ 53
- 0
pmapi/src/main/java/com/ningdatech/pmapi/gov/enumeration/GovProjectClassifiedEnum.java View File

@@ -0,0 +1,53 @@
package com.ningdatech.pmapi.gov.enumeration;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
* GovProjectClassifiedEnum
*
* @return
* @author ZPF
* @since 2023/10/24 16:27
*/
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum GovProjectClassifiedEnum {
/**
* 是否涉密
*/
NOT_CLASSIFIED("01", "非涉密"),
CLASSIFIED("02", "涉密"),;

private String code;
private String desc;

public static String getDescByCode(Integer code) {
if (Objects.isNull(code)) {
return StringUtils.EMPTY;
}
for (GovProjectClassifiedEnum t : GovProjectClassifiedEnum.values()) {
if (code.equals(t.getCode())) {
return t.desc;
}
}
return StringUtils.EMPTY;
}

public static GovProjectClassifiedEnum match(String code) {
if (StringUtils.isBlank(code)) {
return null;
}
for (GovProjectClassifiedEnum t : GovProjectClassifiedEnum.values()) {
if (code.equals(t.getCode())) {
return t;
}
}
return null;
}
}

+ 91
- 10
pmapi/src/main/java/com/ningdatech/pmapi/gov/utils/ProjectConvertUtil.java View File

@@ -1,12 +1,29 @@
package com.ningdatech.pmapi.gov.utils;

import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.xiaoymin.knife4j.core.util.CommonUtils;
import com.google.common.collect.Lists;
import com.ningdatech.basic.util.StrPool;
import com.ningdatech.pmapi.common.constant.RegionConst;
import com.ningdatech.pmapi.common.enumeration.CommonEnum;
import com.ningdatech.pmapi.common.util.BizUtils;
import com.ningdatech.pmapi.gov.enumeration.GovProjectClassifiedEnum;
import com.ningdatech.pmapi.gov.manage.GovProjectCollectionManage;
import com.ningdatech.pmapi.gov.model.vo.*;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.projectlib.model.vo.ProjectApplicationVO;
import com.ningdatech.pmapi.projectlib.model.vo.ProjectDetailVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
* @Classname ProjectCollectionUtil
@@ -14,14 +31,19 @@ import java.util.Objects;
* @Date 2023/9/14 9:07
* @Author PoffyZhang
*/
@Slf4j
@Component
@RequiredArgsConstructor
public class ProjectConvertUtil {

private final GovProjectCollectionManage collectionManage;

/**
* 申报项目 转为 项目归集
* @param project
* @return
*/
public static GovBizProjectDetailVO declaredToCollection(Project project){
public GovBizProjectDetailVO declaredToCollection(ProjectDetailVO project){
GovBizProjectDetailVO projectCollection = new GovBizProjectDetailVO();
if(Objects.isNull(project)){
return projectCollection;
@@ -40,7 +62,7 @@ public class ProjectConvertUtil {
}

//转化基本信息
private static GovBizProjectBaseinfoVO buildBaseinfo(Project project) {
private GovBizProjectBaseinfoVO buildBaseinfo(ProjectDetailVO project) {
GovBizProjectBaseinfoVO baseinfo = new GovBizProjectBaseinfoVO();
baseinfo.setBaseProjId(project.getProjectCode());
baseinfo.setBaseProjName(project.getProjectName());
@@ -56,40 +78,99 @@ public class ProjectConvertUtil {
baseinfo.setBaseManDepartUsci(project.getSuperOrgCreditCode());
baseinfo.setBaseProjContacts(project.getContactName());
baseinfo.setBaseProjContactsCall(project.getContactPhone());
// baseinfo.setBaseProjIsConfidentiality(CommonEnum.NO.getCode());
baseinfo.setBaseProjIsConfidentiality(GovProjectClassifiedEnum.NOT_CLASSIFIED.getCode());
baseinfo.setBaseProjPrincipal(project.getResponsibleMan());
baseinfo.setBaseProjPrincipalCall(project.getResponsibleManMobile());
baseinfo.setBaseProvManDeprt(project.getHigherSuperOrg());
baseinfo.setBaseProvManDepartDing(project.getHigherSuperOrgCode());
baseinfo.setBaseProvManDeprtType(project.getBaseProvManDeprtType());
// TODO 缺少状态映射
// baseinfo.setBaseProjSetProg();
baseinfo.setBaseProjType(project.getProjectType());
return baseinfo;
}

//转化申报信息
private static GovBizProjectApplyVO buildApply(Project project) {
private GovBizProjectApplyVO buildApply(ProjectDetailVO project) {
GovBizProjectApplyVO apply = new GovBizProjectApplyVO();

apply.setBaseProjId(project.getProjectCode());
apply.setBaseProjName(project.getProjectName());
apply.setAreaCode(RegionConst.RC_LS);
apply.setBaseHistorProjId(project.getBaseHistorProjId());
apply.setBaseBasisEstablish(project.getBaseBasisEstablish());
List<ProjectApplicationVO> projectApplications = project.getProjectApplications();
if(CollUtil.isNotEmpty(projectApplications)){
String appName = projectApplications.stream().map(app -> {
if (StringUtils.isNotBlank(app.getRelatedExistsApplication())) {
return app.getRelatedExistsApplication();
}
return app.getApplicationName();
}).collect(Collectors.joining(StrPool.SEMICOLON_CHINA));
apply.setBaseAccountAppName(appName);
}
apply.setBaseBasisAmountOri(project.getBaseBasisAmountOri());
String coreBusiness = project.getCoreBusiness();
if(StringUtils.isNotBlank(coreBusiness)){
try{
JSONArray coreJson = JSON.parseArray(coreBusiness);
String matters = coreJson.stream().map(j -> {
JSONObject matterJson = JSON.parseObject(JSON.toJSONString(j));
return matterJson.getString("matterName");
}).filter(Objects::nonNull)
.collect(Collectors.joining(StrPool.SEMICOLON_CHINA));
String matterCodes = coreJson.stream().map(j -> {
JSONObject matterJson = JSON.parseObject(JSON.toJSONString(j));
return matterJson.getString("oid");
}).filter(Objects::nonNull)
.collect(Collectors.joining(StrPool.SEMICOLON_CHINA));
apply.setBaseCoreBusiness(matters);
apply.setBaseCoreBusinessCode(matterCodes);
}catch (Exception e){
log.error("项目转化失败",e);
}
}
apply.setBaseDevelopCode(project.getDevelopCode());
apply.setBaseLowestLevel(project.getLowestLevel());
apply.setBaseHistorProjName(project.getBaseHistorProjName());
apply.setBaseHistorProjYear(project.getBaseHistorProjYear());
apply.setBaseProjApplyFile(project.getProjectApplicationForm());
apply.setBaseProjApplyFilePdf(collectionManage.convertAndUpload(project
.getProjectApplicationForm()).toString());
String beginTime = project.getBeginTime();
String endTime = project.getEndTime();
if(StringUtils.isNotBlank(beginTime)){
apply.setBaseProjStartTime(BizUtils.convertLocalDateTime(beginTime));
}
if(StringUtils.isNotBlank(endTime)){
apply.setBaseProjEndTime(BizUtils.convertLocalDateTime(endTime));
}
apply.setBaseProjDuration(project.getBuildCycle());
return apply;
}

//转化审批信息
private static GovBizProjectApproveVO buildApprove(Project project) {
private GovBizProjectApproveVO buildApprove(ProjectDetailVO project) {
GovBizProjectApproveVO approve = new GovBizProjectApproveVO();

return approve;
}

//转化建设 实施
private static GovBizProjectCimplementVO buildCim(Project project) {
private GovBizProjectCimplementVO buildCim(ProjectDetailVO project) {
GovBizProjectCimplementVO cim = new GovBizProjectCimplementVO();

return cim;
}

//转化运维实施
private static GovBizProjectMimplementVO buildMim(Project project) {
private GovBizProjectMimplementVO buildMim(ProjectDetailVO project) {
GovBizProjectMimplementVO mim = new GovBizProjectMimplementVO();

return mim;
}

//转化采购信息
private static List<GovBizProjectProcureVO> buildProcure(Project project) {
private List<GovBizProjectProcureVO> buildProcure(ProjectDetailVO project) {
List<GovBizProjectProcureVO> procures = Lists.newArrayList();

return procures;


Loading…
Cancel
Save