From 2a12d6d43b6f7abc0ef594ee9b992f34ee00b7a1 Mon Sep 17 00:00:00 2001 From: fuliqi <fuliqi@qq.com> Date: 星期五, 16 八月 2024 10:28:59 +0800 Subject: [PATCH] python接口 --- ycl-server/src/main/java/com/ycl/calculate/FaceSnapshotDelayCalculation.java | 57 ++++++++++++++++++++++----------------------------------- 1 files changed, 22 insertions(+), 35 deletions(-) diff --git a/ycl-server/src/main/java/com/ycl/calculate/FaceSnapshotDelayCalculation.java b/ycl-server/src/main/java/com/ycl/calculate/FaceSnapshotDelayCalculation.java index 8013800..04d781a 100644 --- a/ycl-server/src/main/java/com/ycl/calculate/FaceSnapshotDelayCalculation.java +++ b/ycl-server/src/main/java/com/ycl/calculate/FaceSnapshotDelayCalculation.java @@ -1,13 +1,12 @@ package com.ycl.calculate; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.ycl.platform.domain.entity.CheckIndexFace; -import com.ycl.platform.domain.entity.TMonitor; import com.ycl.platform.domain.result.HK.SnapshotDelayMonitorResult; +import com.ycl.platform.domain.vo.TMonitorVO; import com.ycl.platform.mapper.CheckIndexFaceMapper; +import com.ycl.platform.mapper.TMonitorMapper; import com.ycl.platform.service.ICheckIndexFaceService; -import com.ycl.platform.service.ITMonitorService; -import com.ycl.system.mapper.SysConfigMapper; +import constant.ApiConstants; import constant.CheckConstants; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -15,12 +14,16 @@ 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 * 寰幆map璁$畻鏁版嵁涓婁紶鍙婃椂鎬� * 鏇存柊鎴栨柊澧� @@ -30,13 +33,11 @@ @Autowired private CheckIndexFaceMapper checkIndexFaceMapper; @Autowired - private SysConfigMapper sysConfigMapper; - @Autowired - private ITMonitorService monitorService; + private TMonitorMapper monitorMapper; @Autowired private ICheckIndexFaceService checkIndexFaceService; - //鍖哄煙杞﹁締鐐逛綅鍦ㄧ嚎鎸囨爣鐨勫唴閮ㄧ被 + //鍖哄煙浜鸿劯鏁版嵁涓婁紶寤惰繜鎸囨爣鐨勫唴閮ㄧ被 private static class AreaStats { int totalCount = 0; //0-180s @@ -54,15 +55,14 @@ } //鑾峰緱鍥芥爣鐮佷负key鐨勮澶噈ap - Map<String, TMonitor> monitorMap = monitorService.list(new QueryWrapper<TMonitor>() - .in("serial_number", list.stream().map(SnapshotDelayMonitorResult::getExternalIndexCode).collect(Collectors.toList()))) - .stream().collect(Collectors.toMap(TMonitor::getSerialNumber, Function.identity())); + Map<String, TMonitorVO> monitorMap = monitorMapper.selectListByIds(list.stream().map(SnapshotDelayMonitorResult::getExternalIndexCode).collect(Collectors.toList())) + .stream().collect(Collectors.toMap(TMonitorVO::getSerialNumber, Function.identity())); //鑾峰彇鐪佸巺鍥芥爣鐮侀泦鍚� List<String> provinceIds = getProvince(); Map<String, AreaStats> areaStatsMap = new HashMap<>(); for (SnapshotDelayMonitorResult result : list) { - TMonitor monitor = monitorMap.get(result.getExternalIndexCode()); + TMonitorVO monitor = monitorMap.get(result.getExternalIndexCode()); if (monitor == null) continue; String deptId = monitor.getDeptId().toString(); @@ -70,7 +70,7 @@ // 澶勭悊鐪佸巺鏁版嵁 if (!CollectionUtils.isEmpty(provinceIds) && provinceIds.contains(monitor.getSerialNumber())) { - String provinceKey = "Province_" + deptId; + String provinceKey = ApiConstants.Province + deptId; updateAreaStats(areaStatsMap, provinceKey, result); } } @@ -81,7 +81,9 @@ areaStatsMap.forEach((deptId, stats) -> { if (stats.totalCount > 0) { CheckIndexFace checkIndexFace = createOrUpdateCheckIndexFace(deptId, stats, checkIndexFaceList); - checkIndexFaces.add(checkIndexFace); + if (checkIndexFace != null) { + checkIndexFaces.add(checkIndexFace); + } } }); @@ -89,7 +91,7 @@ } /** - * 绱鎬荤偣浣嶆暟銆佺绾挎暟銆佹�绘姄鎷嶉噺 + * 绱鎬绘暟鎹噺銆佸欢杩熸暟鎹噺 */ private void updateAreaStats(Map<String, AreaStats> areaStatsMap, String key, SnapshotDelayMonitorResult result) { //杩斿洖瀵硅薄鐨勫紩鐢紝濡傛灉涓嶅瓨鍦ㄤ細鏀惧叆鏂扮殑key,value @@ -100,29 +102,14 @@ stats.delayCount3 += result.getDataDelayCount3(); } - /** - * 杞﹁締鐐逛綅鍦ㄧ嚎鐜囧拰瑙嗗浘搴撳鎺ョǔ瀹氭�� + * 浜鸿劯鏁版嵁涓婁紶鍙婃椂鎬� */ private CheckIndexFace createOrUpdateCheckIndexFace(String key, AreaStats stats, List<CheckIndexFace> checkIndexFaceList) { - CheckIndexFace checkIndexFace; - - // 妫�鏌ユ槸鍚﹀凡瀛樺湪浠婃棩鏁版嵁 - Optional<CheckIndexFace> existingFace = checkIndexFaceList.stream() - .filter(face -> key.equals(face.getDeptId().toString()) && - (key.startsWith("Province_") ? CheckConstants.Examine_Tag_City.equals(face.getExamineTag()) - : CheckConstants.Examine_Tag_County.equals(face.getExamineTag()))) - .findFirst(); - - if (existingFace.isPresent()) { - checkIndexFace = existingFace.get(); - } else { - checkIndexFace = new CheckIndexFace(); - checkIndexFace.setDeptId(key.startsWith("Province_") ? Long.parseLong(key.split("_")[1]) : Long.parseLong(key)); - checkIndexFace.setExamineTag(key.startsWith("Province_") ? CheckConstants.Examine_Tag_City : CheckConstants.Examine_Tag_County); - checkIndexFace.setCreateTime(new Date()); + CheckIndexFace checkIndexFace = getCheckIndex(key, checkIndexFaceList, CheckIndexFace.class); + if (checkIndexFace == null) { + return null; } - //璋冪敤鎶撴媿涓婁紶鍙婃椂鎬ц绠楁柟娉� Map<String, Object> param = new HashMap<>(); param.put("totalCount", stats.totalCount); -- Gitblit v1.8.0