From 8ff36b0987d557a62b979f2084216ae3baee58ce Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Wed, 29 Nov 2023 14:39:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BB=9F=E8=AE=A1=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ningdatech/pmapi/common/util/BizUtils.java | 20 ++++ .../dashboard/manage/FundStatisticsManage.java | 16 +++- .../gov/enumeration/GovProjectClassifiedEnum.java | 53 +++++++++++ .../pmapi/gov/utils/ProjectConvertUtil.java | 101 +++++++++++++++++++-- 4 files changed, 175 insertions(+), 15 deletions(-) create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/gov/enumeration/GovProjectClassifiedEnum.java diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/util/BizUtils.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/util/BizUtils.java index 4a504ae..9037deb 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/util/BizUtils.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/util/BizUtils.java @@ -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); + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/FundStatisticsManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/FundStatisticsManage.java index 3649986..85dfde5 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/FundStatisticsManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/manage/FundStatisticsManage.java @@ -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 procures) { //申报项目颗粒度 Map> groupProjectMap = projects.stream() + .filter(p -> StringUtils.isNotBlank(p.getBuildOrgCode())) .collect(Collectors.groupingBy(Project::getBuildOrgCode)); List projectAmounts = Lists.newArrayList(); for(Map.Entry> entry : groupProjectMap.entrySet()){ @@ -430,6 +433,7 @@ public class FundStatisticsManage { //项目归集颗粒度 Map> groupGovMap = baseInfos.stream() + .filter(b -> StringUtils.isNotBlank(b.getBaseBuildDeprtDing())) .collect(Collectors.groupingBy(GovBizProjectBaseinfo::getBaseBuildDeprtDing)); List govAmounts = Lists.newArrayList(); for(Map.Entry> entry : groupGovMap.entrySet()){ @@ -455,11 +459,13 @@ public class FundStatisticsManage { } //求出TOP10 - List 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; } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/enumeration/GovProjectClassifiedEnum.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/enumeration/GovProjectClassifiedEnum.java new file mode 100644 index 0000000..c75a918 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/enumeration/GovProjectClassifiedEnum.java @@ -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; + } +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/utils/ProjectConvertUtil.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/utils/ProjectConvertUtil.java index 9fc25e0..e63969a 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/utils/ProjectConvertUtil.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/utils/ProjectConvertUtil.java @@ -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 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 buildProcure(Project project) { + private List buildProcure(ProjectDetailVO project) { List procures = Lists.newArrayList(); return procures;