@@ -247,6 +247,10 @@ | |||||
<groupId>cn.afterturn</groupId> | <groupId>cn.afterturn</groupId> | ||||
<artifactId>easypoi-base</artifactId> | <artifactId>easypoi-base</artifactId> | ||||
</dependency> | </dependency> | ||||
<dependency> | |||||
<groupId>com.github.oshi</groupId> | |||||
<artifactId>oshi-core</artifactId> | |||||
</dependency> | |||||
</dependencies> | </dependencies> | ||||
<!-- 打包 --> | <!-- 打包 --> | ||||
<!--配置环境的profile--> | <!--配置环境的profile--> | ||||
@@ -1,7 +1,7 @@ | |||||
package com.hz.pm.api; | package com.hz.pm.api; | ||||
import com.ningdatech.basic.util.SpringUtils; | |||||
import com.hz.pm.api.common.util.SpringContextHolder; | import com.hz.pm.api.common.util.SpringContextHolder; | ||||
import com.ningdatech.basic.util.SpringUtils; | |||||
import org.mybatis.spring.annotation.MapperScan; | import org.mybatis.spring.annotation.MapperScan; | ||||
import org.springframework.boot.SpringApplication; | import org.springframework.boot.SpringApplication; | ||||
import org.springframework.boot.autoconfigure.SpringBootApplication; | import org.springframework.boot.autoconfigure.SpringBootApplication; | ||||
@@ -397,25 +397,31 @@ public class DeclaredRecordManage { | |||||
ImportProjectFinanceInfosDTO financeInfo = new ImportProjectFinanceInfosDTO(); | ImportProjectFinanceInfosDTO financeInfo = new ImportProjectFinanceInfosDTO(); | ||||
financeInfo.setProjectName(projectName); | financeInfo.setProjectName(projectName); | ||||
financeInfo.setUnitName(MapUtil.getStr(w, "单位名称")); | financeInfo.setUnitName(MapUtil.getStr(w, "单位名称")); | ||||
Assert.notBlank(financeInfo.getUnitName(), "单位名称不能为空"); | |||||
financeInfo.setDeclareAmount(MapUtil.get(w, "合计", BigDecimal.class)); | financeInfo.setDeclareAmount(MapUtil.get(w, "合计", BigDecimal.class)); | ||||
financeInfo.setDeclareHaveAmount(MapUtil.get(w, "其他资金", BigDecimal.class)); | financeInfo.setDeclareHaveAmount(MapUtil.get(w, "其他资金", BigDecimal.class)); | ||||
financeInfo.setDeclareGovOwnFinanceAmount(MapUtil.get(w, "市本级信息化专项资金", BigDecimal.class)); | financeInfo.setDeclareGovOwnFinanceAmount(MapUtil.get(w, "市本级信息化专项资金", BigDecimal.class)); | ||||
financeInfo.setDeclareGovSuperiorFinanceAmount(MapUtil.get(w, "上级补助资金", BigDecimal.class)); | financeInfo.setDeclareGovSuperiorFinanceAmount(MapUtil.get(w, "上级补助资金", BigDecimal.class)); | ||||
return financeInfo; | return financeInfo; | ||||
}); | }); | ||||
Map<String, List<ImportProjectFinanceInfosDTO>> groupByUnit = CollUtils.group(importDataList, ImportProjectFinanceInfosDTO::getUnitName); | |||||
List<Project> projects = new ArrayList<>(); | List<Project> 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<String, List<ImportProjectFinanceInfosDTO>> entry : groupByUnit.entrySet()) { | |||||
if (entry.getValue().size() != 1) { | |||||
log.warn("单位存在多个项目:{}", entry.getKey()); | |||||
continue; | continue; | ||||
} | } | ||||
log.info("项目存在:{}", projectName); | |||||
project.setDeclareAmount(importData.getDeclareAmount()); | |||||
project.setDeclareGovOwnFinanceAmount(importData.getDeclareGovOwnFinanceAmount()); | |||||
project.setDeclareGovSuperiorFinanceAmount(importData.getDeclareGovSuperiorFinanceAmount()); | |||||
project.setDeclareHaveAmount(importData.getDeclareHaveAmount()); | |||||
Collection<Project> 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); | projects.add(project); | ||||
} | } | ||||
if (projects.isEmpty()) { | if (projects.isEmpty()) { | ||||
@@ -428,6 +434,13 @@ public class DeclaredRecordManage { | |||||
} | } | ||||
} | } | ||||
private Collection<Project> listProjectsByUnitName(String unitName) { | |||||
List<Project> 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) | @Transactional(rollbackFor = Exception.class) | ||||
public void importReplaceSystemInfos(MultipartFile file) { | public void importReplaceSystemInfos(MultipartFile file) { | ||||
try (InputStream is = file.getInputStream()) { | try (InputStream is = file.getInputStream()) { | ||||
@@ -444,6 +457,7 @@ public class DeclaredRecordManage { | |||||
importData.setSourceName(MapUtil.getStr(w, "替代前系统")); | importData.setSourceName(MapUtil.getStr(w, "替代前系统")); | ||||
importData.setTargetName(MapUtil.getStr(w, "替代后系统")); | importData.setTargetName(MapUtil.getStr(w, "替代后系统")); | ||||
importData.setUnitName(MapUtil.getStr(w, "单位")); | importData.setUnitName(MapUtil.getStr(w, "单位")); | ||||
Assert.notBlank(importData.getUnitName(), "单位名称不能为空"); | |||||
if (StrUtil.equals(importData.getReplaceType(), "/") | if (StrUtil.equals(importData.getReplaceType(), "/") | ||||
|| StrUtil.isBlank(importData.getReplaceType())) { | || StrUtil.isBlank(importData.getReplaceType())) { | ||||
importData.setReplaceType(null); | importData.setReplaceType(null); | ||||
@@ -455,15 +469,16 @@ public class DeclaredRecordManage { | |||||
return importData; | return importData; | ||||
}); | }); | ||||
Map<String, List<ImportReplaceSystemInfosDTO>> groupByProject = CollUtils.group(importDataList, | Map<String, List<ImportReplaceSystemInfosDTO>> groupByProject = CollUtils.group(importDataList, | ||||
ImportReplaceSystemInfosDTO::getProjectName); | |||||
ImportReplaceSystemInfosDTO::getUnitName); | |||||
List<Long> projectIds = new ArrayList<>(); | List<Long> projectIds = new ArrayList<>(); | ||||
List<ProjectGovSystemReplaceInfos> replaceInfos = new ArrayList<>(); | List<ProjectGovSystemReplaceInfos> replaceInfos = new ArrayList<>(); | ||||
for (Map.Entry<String, List<ImportReplaceSystemInfosDTO>> entry : groupByProject.entrySet()) { | for (Map.Entry<String, List<ImportReplaceSystemInfosDTO>> entry : groupByProject.entrySet()) { | ||||
Project project = projectService.getByProjectName(entry.getKey()); | |||||
if (project == null) { | |||||
log.warn("项目不存在:{}", entry.getKey()); | |||||
Collection<Project> projects = listProjectsByUnitName(entry.getKey()); | |||||
if (projects.size() != 1) { | |||||
log.warn("单位存在多个项目:{}", entry.getKey()); | |||||
continue; | continue; | ||||
} | } | ||||
Project project = new ArrayList<>(projects).get(0); | |||||
projectIds.add(project.getId()); | projectIds.add(project.getId()); | ||||
Map<String, Integer> batchNoMap = new HashMap<>(); | Map<String, Integer> batchNoMap = new HashMap<>(); | ||||
AtomicInteger integer = new AtomicInteger(1); | AtomicInteger integer = new AtomicInteger(1); | ||||
@@ -180,6 +180,18 @@ public class ProjectDTO { | |||||
@ApiModelProperty("立项批复资金(万元)") | @ApiModelProperty("立项批复资金(万元)") | ||||
private BigDecimal approvalAmount; | 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") | @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") | ||||
private LocalDateTime annualPlanAddTime; | private LocalDateTime annualPlanAddTime; | ||||
@@ -209,6 +209,20 @@ public class Project implements Serializable { | |||||
@Compare("资金分配情况-第三方服务") | @Compare("资金分配情况-第三方服务") | ||||
private BigDecimal thirdPartyAmount; | private BigDecimal thirdPartyAmount; | ||||
//================================================================================================================== | |||||
@ApiModelProperty("批复-自有金额(万元)") | |||||
@Compare("批复-自有金额") | |||||
private BigDecimal approvalHaveAmount; | |||||
@ApiModelProperty("批复-政府投资-本级财政资金(万元)") | |||||
@Compare("批复-政府投资-本级财政资金") | |||||
private BigDecimal approvalGovOwnFinanceAmount; | |||||
@ApiModelProperty("批复-政府投资-上级补助资金(万元)") | |||||
@Compare("批复-政府投资-上级补助资金") | |||||
private BigDecimal approvalGovSuperiorFinanceAmount; | |||||
@ApiModelProperty("立项批复总投资(万元)") | @ApiModelProperty("立项批复总投资(万元)") | ||||
@Compare("立项批复总投资") | @Compare("立项批复总投资") | ||||
private BigDecimal approvalAmount; | private BigDecimal approvalAmount; | ||||
@@ -558,4 +558,16 @@ public class ProjectDetailVO { | |||||
@ApiModelProperty("政务信息系统改造情况") | @ApiModelProperty("政务信息系统改造情况") | ||||
private List<GovSystemReplaceInfoDTO> systemReplaceInfos; | private List<GovSystemReplaceInfoDTO> systemReplaceInfos; | ||||
@ApiModelProperty("批复-自有金额(万元)") | |||||
@Compare("批复-自有金额") | |||||
private BigDecimal approvalHaveAmount; | |||||
@ApiModelProperty("批复-政府投资-本级财政资金(万元)") | |||||
@Compare("批复-政府投资-本级财政资金") | |||||
private BigDecimal approvalGovOwnFinanceAmount; | |||||
@ApiModelProperty("批复-政府投资-上级补助资金(万元)") | |||||
@Compare("批复-政府投资-上级补助资金") | |||||
private BigDecimal approvalGovSuperiorFinanceAmount; | |||||
} | } |
@@ -1,6 +1,9 @@ | |||||
package com.hz.pm.api.user.manage; | package com.hz.pm.api.user.manage; | ||||
import cn.hutool.core.collection.CollUtil; | 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.conditions.query.LambdaQueryWrapper; | ||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils; | import com.baomidou.mybatisplus.core.toolkit.StringUtils; | ||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||||
@@ -37,7 +40,12 @@ import org.springframework.transaction.annotation.Transactional; | |||||
import java.time.LocalDateTime; | import java.time.LocalDateTime; | ||||
import java.util.*; | 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.Collectors; | ||||
import java.util.stream.LongStream; | |||||
import java.util.stream.Stream; | |||||
/** | /** | ||||
* @author liuxinxin | * @author liuxinxin | ||||
@@ -411,4 +419,30 @@ public class UserInfoManage { | |||||
return userInfoHelper.getUserFullInfo(userInfo); | 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)); | |||||
}); | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | } |
@@ -158,6 +158,11 @@ | |||||
<artifactId>easypoi-base</artifactId> | <artifactId>easypoi-base</artifactId> | ||||
<version>4.4.0</version> | <version>4.4.0</version> | ||||
</dependency> | </dependency> | ||||
<dependency> | |||||
<groupId>com.github.oshi</groupId> | |||||
<artifactId>oshi-core</artifactId> | |||||
<version>6.4.0</version> | |||||
</dependency> | |||||
</dependencies> | </dependencies> | ||||
</dependencyManagement> | </dependencyManagement> | ||||