From 0d243e7f5dc593cdc6e0608bb52cd635f8fc6982 Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期五, 19 九月 2025 11:59:44 +0800
Subject: [PATCH] 新需求
---
ycl-server/src/main/java/com/ycl/calculate/CarDataIntegrityCalculation.java | 74 ++++++++++++++----------------------
1 files changed, 29 insertions(+), 45 deletions(-)
diff --git a/ycl-server/src/main/java/com/ycl/calculate/CarDataIntegrityCalculation.java b/ycl-server/src/main/java/com/ycl/calculate/CarDataIntegrityCalculation.java
index 64e8cd4..ad8ecef 100644
--- a/ycl-server/src/main/java/com/ycl/calculate/CarDataIntegrityCalculation.java
+++ b/ycl-server/src/main/java/com/ycl/calculate/CarDataIntegrityCalculation.java
@@ -1,44 +1,44 @@
package com.ycl.calculate;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.ycl.platform.base.CheckIndex;
import com.ycl.platform.domain.entity.CheckIndexCar;
-import com.ycl.platform.domain.entity.TMonitor;
-import com.ycl.platform.domain.result.HK.CrossDetailResult;
import com.ycl.platform.domain.result.HK.DataIntegrityMonitoringResult;
+import com.ycl.platform.domain.vo.TMonitorVO;
import com.ycl.platform.mapper.CheckIndexCarMapper;
import com.ycl.platform.mapper.TMonitorMapper;
import com.ycl.platform.service.ICheckIndexCarService;
-import com.ycl.platform.service.ITMonitorService;
-import com.ycl.system.mapper.SysConfigMapper;
import constant.ApiConstants;
-import constant.CheckConstants;
+import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import utils.DateUtils;
import java.math.BigDecimal;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
- * 璁$畻杞﹁締鏁版嵁瀹屾暣鎬�
+ * 璁$畻杞﹁締鏁版嵁瀹屾暣鎬э紙妫�娴嬭溅鐗屽彿銆佽溅鐗岄鑹插暐鐨勫悎涓嶅悎鏍囧噯
+ * 閲囩敤鏁版嵁瀹屾暣鎬х洃娴嬫帴鍙�
* 鑾峰彇鍒嗙渷鍘呫�佸尯鍩熺殑map<k,v> k涓篸eptId鎴栬�匬rovince_deptId
* 鏇存柊鎴栨柊澧�
*/
@Component
-public class CarDataIntegrityCalculation extends IndexCalculationServe implements CalculationStrategy<DataIntegrityMonitoringResult> {
+@Slf4j
+public class CarDataIntegrityCalculation extends IndexCalculationServe<DataIntegrityMonitoringResult, CarDataIntegrityCalculation.AreaStats> implements CalculationStrategy<DataIntegrityMonitoringResult> {
@Autowired
private CheckIndexCarMapper checkIndexCarMapper;
@Autowired
- private ITMonitorService monitorService;
+ private TMonitorMapper monitorMapper;
@Autowired
private ICheckIndexCarService checkIndexCarService;
//鍖哄煙杞﹁締淇℃伅閲囬泦鍑嗙‘鐜囩殑鍐呴儴绫�
- private static class AreaStats {
+ protected static class AreaStats {
int totalSites = 0;
int importantTotalSites = 0;
int integritySites = 0;
@@ -47,31 +47,9 @@
@Override
public void calculate(List<DataIntegrityMonitoringResult> list) {
- if (CollectionUtils.isEmpty(list)) {
- return;
- }
- //杩斿洖浠ュ浗鏍囩爜涓簁ey鐨勮澶噈ap
- //TODO锛歮onitor鍘绘帀浜哾eptId
- Map<String, TMonitor> monitorMap = monitorService.list(new QueryWrapper<TMonitor>()
- .in("serial_number", list.stream().map(DataIntegrityMonitoringResult::getExternalIndexCode).collect(Collectors.toList())))
- .stream().collect(Collectors.toMap(TMonitor::getSerialNumber, Function.identity()));
- //鑾峰彇鐪佸巺鍥芥爣鐮侀泦鍚�
- List<String> provinceIds = getProvince();
- //鑾峰彇閲嶇偣鐐逛綅闆嗗悎
- List<String> importantIds = getImportant();
- Map<String, AreaStats> areaStatsMap = new HashMap<>();
- for (DataIntegrityMonitoringResult result : list) {
- TMonitor monitor = monitorMap.get(result.getExternalIndexCode());
- if (monitor == null) continue;
- String deptId = monitor.getDeptId().toString();
- updateAreaStats(areaStatsMap, deptId, result, importantIds);
-
- // 澶勭悊鐪佸巺鏁版嵁
- if (!CollectionUtils.isEmpty(provinceIds) && provinceIds.contains(monitor.getSerialNumber())) {
- String provinceKey = "Province_" + deptId;
- updateAreaStats(areaStatsMap, provinceKey, result, importantIds);
- }
- }
+ //鑾峰彇鍒嗗尯鍩熺殑鎸囨爣鏁伴噺
+ Map<String, CarDataIntegrityCalculation.AreaStats> areaStatsMap = getAreaStatsMap(list, Boolean.FALSE);
+ if (areaStatsMap == null) return;
// 鏌ヨ鏄惁index琛ㄥ凡缁忓瓨鍦ㄤ粖鏃ユ暟鎹�
List<CheckIndexCar> checkIndexCarList = checkIndexCarMapper.selectToday(DateUtils.getDate());
@@ -79,7 +57,9 @@
areaStatsMap.forEach((deptId, stats) -> {
if (stats.totalSites > 0) {
CheckIndexCar checkIndexCar = createOrUpdateCheckIndexCar(deptId, stats, checkIndexCarList);
- checkIndexCars.add(checkIndexCar);
+ if (checkIndexCar != null) {
+ checkIndexCars.add(checkIndexCar);
+ }
}
});
@@ -89,28 +69,32 @@
/**
* 绱鎶撴媿鏁版嵁瀹屾暣璁惧鏁板拰璁惧鎬绘暟锛屽尯鍒嗛噸鐐圭偣浣�
*/
- private void updateAreaStats(Map<String, AreaStats> areaStatsMap, String key, DataIntegrityMonitoringResult result, List<String> importantIds) {
+ @Override
+ public void updateAreaStats(Map<String, AreaStats> areaStatsMap, String key, DataIntegrityMonitoringResult result) {
//杩斿洖瀵硅薄鐨勫紩鐢紝濡傛灉涓嶅瓨鍦ㄤ細鏀惧叆鏂扮殑key,value
AreaStats stats = areaStatsMap.computeIfAbsent(key, k -> new AreaStats());
stats.totalSites++;
//90%鍙婁互涓婃暟鎹悎鏍煎垯姝よ溅杈嗗崱鍙h澶囪瑙嗕负鎶撴媿鏁版嵁瀹屾暣
- if(result.getMainNoIntegrityPercent() <= 0.1){
+ if (result.getMainNoIntegrityPercent() != null && result.getMainNoIntegrityPercent() <= 0.1) {
stats.integritySites++;
}
- //閲嶇偣鐐逛綅涓哄叚椤瑰睘鎬�
- if(importantIds.contains(key)){
+ //閲嶇偣鐐逛綅涓哄叚椤瑰睘鎬у畬鏁�
+ if (result.getImportantTag() != null && result.getImportantTag()) {
stats.importantTotalSites++;
- if(result.getNoIntegrityPercent() <= 0.1){
+ if (result.getNoIntegrityPercent()!=null && result.getNoIntegrityPercent() <= 0.1) {
stats.importantIntegritySites++;
}
}
}
/**
- * 杞﹁締淇℃伅閲囬泦姝g‘鐜�
+ * 杞﹁締鏁版嵁瀹屾暣
*/
private CheckIndexCar createOrUpdateCheckIndexCar(String key, AreaStats stats, List<CheckIndexCar> checkIndexCarList) {
- CheckIndexCar checkIndexCar = getCheckIndex(key, checkIndexCarList);
+ CheckIndexCar checkIndexCar = getCheckIndex(key, checkIndexCarList, CheckIndexCar.class);
+ if (checkIndexCar == null) {
+ return null;
+ }
//璋冪敤璁$畻鏂规硶
Map<String, Object> param = new HashMap<>();
param.put("totalSites", stats.totalSites);
--
Gitblit v1.8.0