From b2514bed17055c18b0623121cae2291d62abf190 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Mon, 4 Mar 2024 18:15:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B5=84=E9=87=91=E4=B8=8B?= =?UTF-8?q?=E8=BE=BE=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hz-pm-api/pom.xml | 4 ++ hz-pm-api/src/main/java/com/hz/pm/api/App.java | 2 +- .../projectlib/manage/DeclaredRecordManage.java | 43 +++++++++++++++------- .../hz/pm/api/projectlib/model/dto/ProjectDTO.java | 12 ++++++ .../hz/pm/api/projectlib/model/entity/Project.java | 14 +++++++ .../api/projectlib/model/vo/ProjectDetailVO.java | 12 ++++++ .../com/hz/pm/api/user/manage/UserInfoManage.java | 34 +++++++++++++++++ pom.xml | 5 +++ 8 files changed, 111 insertions(+), 15 deletions(-) diff --git a/hz-pm-api/pom.xml b/hz-pm-api/pom.xml index df2e4fc..4a792aa 100644 --- a/hz-pm-api/pom.xml +++ b/hz-pm-api/pom.xml @@ -247,6 +247,10 @@ cn.afterturn easypoi-base + + com.github.oshi + oshi-core + diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/App.java b/hz-pm-api/src/main/java/com/hz/pm/api/App.java index 9de6501..a9ff222 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/App.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/App.java @@ -1,7 +1,7 @@ package com.hz.pm.api; -import com.ningdatech.basic.util.SpringUtils; import com.hz.pm.api.common.util.SpringContextHolder; +import com.ningdatech.basic.util.SpringUtils; import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/DeclaredRecordManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/DeclaredRecordManage.java index f09bb06..847d62a 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/DeclaredRecordManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/manage/DeclaredRecordManage.java @@ -397,25 +397,31 @@ public class DeclaredRecordManage { ImportProjectFinanceInfosDTO financeInfo = new ImportProjectFinanceInfosDTO(); financeInfo.setProjectName(projectName); financeInfo.setUnitName(MapUtil.getStr(w, "单位名称")); + Assert.notBlank(financeInfo.getUnitName(), "单位名称不能为空"); financeInfo.setDeclareAmount(MapUtil.get(w, "合计", BigDecimal.class)); financeInfo.setDeclareHaveAmount(MapUtil.get(w, "其他资金", BigDecimal.class)); financeInfo.setDeclareGovOwnFinanceAmount(MapUtil.get(w, "市本级信息化专项资金", BigDecimal.class)); financeInfo.setDeclareGovSuperiorFinanceAmount(MapUtil.get(w, "上级补助资金", BigDecimal.class)); return financeInfo; }); + Map> groupByUnit = CollUtils.group(importDataList, ImportProjectFinanceInfosDTO::getUnitName); List projects = new ArrayList<>(); - for (ImportProjectFinanceInfosDTO importData : importDataList) { - String projectName = importData.getProjectName(); - Project project = projectService.getByProjectName(projectName); - if (project == null) { - log.warn("项目不存在:{}", projectName); + for (Map.Entry> entry : groupByUnit.entrySet()) { + if (entry.getValue().size() != 1) { + log.warn("单位存在多个项目:{}", entry.getKey()); continue; } - log.info("项目存在:{}", projectName); - project.setDeclareAmount(importData.getDeclareAmount()); - project.setDeclareGovOwnFinanceAmount(importData.getDeclareGovOwnFinanceAmount()); - project.setDeclareGovSuperiorFinanceAmount(importData.getDeclareGovSuperiorFinanceAmount()); - project.setDeclareHaveAmount(importData.getDeclareHaveAmount()); + Collection projectsTmp = listProjectsByUnitName(entry.getKey()); + if (projectsTmp.size() != 1) { + log.warn("单位存在多个项目:{}", entry.getKey()); + continue; + } + Project project = new ArrayList<>(projects).get(0); + ImportProjectFinanceInfosDTO importData = entry.getValue().get(0); + project.setApprovalAmount(importData.getDeclareAmount()); + project.setApprovalGovOwnFinanceAmount(importData.getDeclareGovOwnFinanceAmount()); + project.setApprovalGovSuperiorFinanceAmount(importData.getDeclareGovSuperiorFinanceAmount()); + project.setApprovalHaveAmount(importData.getDeclareHaveAmount()); projects.add(project); } if (projects.isEmpty()) { @@ -428,6 +434,13 @@ public class DeclaredRecordManage { } } + private Collection listProjectsByUnitName(String unitName) { + List projects = projectService.list(Wrappers.lambdaQuery(Project.class) + .eq(Project::getBuildOrgName, unitName)); + return BizUtils.groupFirst(projects, Project::getProjectCode, + Comparator.comparing(Project::getCreateOn).reversed()); + } + @Transactional(rollbackFor = Exception.class) public void importReplaceSystemInfos(MultipartFile file) { try (InputStream is = file.getInputStream()) { @@ -444,6 +457,7 @@ public class DeclaredRecordManage { importData.setSourceName(MapUtil.getStr(w, "替代前系统")); importData.setTargetName(MapUtil.getStr(w, "替代后系统")); importData.setUnitName(MapUtil.getStr(w, "单位")); + Assert.notBlank(importData.getUnitName(), "单位名称不能为空"); if (StrUtil.equals(importData.getReplaceType(), "/") || StrUtil.isBlank(importData.getReplaceType())) { importData.setReplaceType(null); @@ -455,15 +469,16 @@ public class DeclaredRecordManage { return importData; }); Map> groupByProject = CollUtils.group(importDataList, - ImportReplaceSystemInfosDTO::getProjectName); + ImportReplaceSystemInfosDTO::getUnitName); List projectIds = new ArrayList<>(); List replaceInfos = new ArrayList<>(); for (Map.Entry> entry : groupByProject.entrySet()) { - Project project = projectService.getByProjectName(entry.getKey()); - if (project == null) { - log.warn("项目不存在:{}", entry.getKey()); + Collection projects = listProjectsByUnitName(entry.getKey()); + if (projects.size() != 1) { + log.warn("单位存在多个项目:{}", entry.getKey()); continue; } + Project project = new ArrayList<>(projects).get(0); projectIds.add(project.getId()); Map batchNoMap = new HashMap<>(); AtomicInteger integer = new AtomicInteger(1); diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/dto/ProjectDTO.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/dto/ProjectDTO.java index 8e14e81..7c30e5d 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/dto/ProjectDTO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/dto/ProjectDTO.java @@ -180,6 +180,18 @@ public class ProjectDTO { @ApiModelProperty("立项批复资金(万元)") private BigDecimal approvalAmount; + @ApiModelProperty("批复-自有金额(万元)") + @Compare("批复-自有金额") + private BigDecimal approvalHaveAmount; + + @ApiModelProperty("批复-政府投资-本级财政资金(万元)") + @Compare("批复-政府投资-本级财政资金") + private BigDecimal approvalGovOwnFinanceAmount; + + @ApiModelProperty("批复-政府投资-上级补助资金(万元)") + @Compare("批复-政府投资-上级补助资金") + private BigDecimal approvalGovSuperiorFinanceAmount; + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") private LocalDateTime annualPlanAddTime; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/Project.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/Project.java index 59a9fb3..27fc4b0 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/Project.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/entity/Project.java @@ -209,6 +209,20 @@ public class Project implements Serializable { @Compare("资金分配情况-第三方服务") private BigDecimal thirdPartyAmount; + //================================================================================================================== + + @ApiModelProperty("批复-自有金额(万元)") + @Compare("批复-自有金额") + private BigDecimal approvalHaveAmount; + + @ApiModelProperty("批复-政府投资-本级财政资金(万元)") + @Compare("批复-政府投资-本级财政资金") + private BigDecimal approvalGovOwnFinanceAmount; + + @ApiModelProperty("批复-政府投资-上级补助资金(万元)") + @Compare("批复-政府投资-上级补助资金") + private BigDecimal approvalGovSuperiorFinanceAmount; + @ApiModelProperty("立项批复总投资(万元)") @Compare("立项批复总投资") private BigDecimal approvalAmount; diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/vo/ProjectDetailVO.java b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/vo/ProjectDetailVO.java index ddfd1d7..cb8ac22 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/vo/ProjectDetailVO.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/projectlib/model/vo/ProjectDetailVO.java @@ -558,4 +558,16 @@ public class ProjectDetailVO { @ApiModelProperty("政务信息系统改造情况") private List systemReplaceInfos; + @ApiModelProperty("批复-自有金额(万元)") + @Compare("批复-自有金额") + private BigDecimal approvalHaveAmount; + + @ApiModelProperty("批复-政府投资-本级财政资金(万元)") + @Compare("批复-政府投资-本级财政资金") + private BigDecimal approvalGovOwnFinanceAmount; + + @ApiModelProperty("批复-政府投资-上级补助资金(万元)") + @Compare("批复-政府投资-上级补助资金") + private BigDecimal approvalGovSuperiorFinanceAmount; + } diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/UserInfoManage.java b/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/UserInfoManage.java index 2bbac27..ce7a970 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/UserInfoManage.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/user/manage/UserInfoManage.java @@ -1,6 +1,9 @@ package com.hz.pm.api.user.manage; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.StopWatch; +import cn.hutool.core.util.RandomUtil; +import cn.hutool.system.oshi.OshiUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -37,7 +40,12 @@ import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; import java.util.*; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; +import java.util.stream.LongStream; +import java.util.stream.Stream; /** * @author liuxinxin @@ -411,4 +419,30 @@ public class UserInfoManage { return userInfoHelper.getUserFullInfo(userInfo); } + public static void main(String[] args) { + int logicalProcessorCount = OshiUtil.getProcessor().getLogicalProcessorCount(); + int max = (int) Math.max(logicalProcessorCount * 0.25, 1); + ExecutorService fixedThreadPool = Executors.newFixedThreadPool(max); + final int limitCount = 1000000000; + while (true) { + if (System.currentTimeMillis() % 5000 == 0) { + double cpuUsage = OshiUtil.getCpuInfo().getUsed(); + System.out.println(cpuUsage); + if (cpuUsage < 40) { + fixedThreadPool.execute(() -> { + StopWatch watch = new StopWatch(); + watch.start(); + Long sum = Stream.generate(() -> RandomUtil.randomLong(1, limitCount)) + .map(w -> w + limitCount / w) + .limit(limitCount) + .collect(Collectors.summingLong(Long::longValue)); + watch.stop(); + System.out.println("总计:" + sum + " 耗时:" + watch.getTotal(TimeUnit.SECONDS)); + }); + } + } + } + + } + } diff --git a/pom.xml b/pom.xml index 7dc74bf..2ad2e4f 100644 --- a/pom.xml +++ b/pom.xml @@ -158,6 +158,11 @@ easypoi-base 4.4.0 + + com.github.oshi + oshi-core + 6.4.0 +