From 9b55891e6dd57bc244e6c5654434b32e05c83496 Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期三, 25 九月 2024 15:10:25 +0800
Subject: [PATCH] 异常监控排除已经审核过的工单作为状态
---
ycl-server/src/main/java/com/ycl/calculate/CarDataIntegrityCalculation.java | 58 ++++++++++++++++++----------------------------------------
1 files changed, 18 insertions(+), 40 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 42c1c5d..8c510a8 100644
--- a/ycl-server/src/main/java/com/ycl/calculate/CarDataIntegrityCalculation.java
+++ b/ycl-server/src/main/java/com/ycl/calculate/CarDataIntegrityCalculation.java
@@ -1,25 +1,23 @@
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;
@@ -30,16 +28,17 @@
* 鏇存柊鎴栨柊澧�
*/
@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;
@@ -48,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);
+ if (areaStatsMap == null) return;
// 鏌ヨ鏄惁index琛ㄥ凡缁忓瓨鍦ㄤ粖鏃ユ暟鎹�
List<CheckIndexCar> checkIndexCarList = checkIndexCarMapper.selectToday(DateUtils.getDate());
@@ -92,7 +69,8 @@
/**
* 绱鎶撴媿鏁版嵁瀹屾暣璁惧鏁板拰璁惧鎬绘暟锛屽尯鍒嗛噸鐐圭偣浣�
*/
- 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++;
@@ -100,8 +78,8 @@
if (result.getMainNoIntegrityPercent() <= 0.1) {
stats.integritySites++;
}
- //閲嶇偣鐐逛綅涓哄叚椤瑰睘鎬�
- if (importantIds.contains(key)) {
+ //閲嶇偣鐐逛綅涓哄叚椤瑰睘鎬у畬鏁�
+ if (result.getImportantTag()!=null && result.getImportantTag()) {
stats.importantTotalSites++;
if (result.getNoIntegrityPercent() <= 0.1) {
stats.importantIntegritySites++;
@@ -110,7 +88,7 @@
}
/**
- * 杞﹁締淇℃伅閲囬泦姝g‘鐜�
+ * 杞﹁締鏁版嵁瀹屾暣
*/
private CheckIndexCar createOrUpdateCheckIndexCar(String key, AreaStats stats, List<CheckIndexCar> checkIndexCarList) {
CheckIndexCar checkIndexCar = getCheckIndex(key, checkIndexCarList, CheckIndexCar.class);
--
Gitblit v1.8.0