From 3add1f8ab325dff968d5c2b94985700419ea1ccb Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期三, 19 二月 2025 09:46:32 +0800
Subject: [PATCH] 运维监控报表接口统计sql重新编写
---
ycl-server/src/main/java/com/ycl/task/HKTask.java | 285 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 250 insertions(+), 35 deletions(-)
diff --git a/ycl-server/src/main/java/com/ycl/task/HKTask.java b/ycl-server/src/main/java/com/ycl/task/HKTask.java
index 993e794..c6cad22 100644
--- a/ycl-server/src/main/java/com/ycl/task/HKTask.java
+++ b/ycl-server/src/main/java/com/ycl/task/HKTask.java
@@ -1,14 +1,29 @@
package com.ycl.task;
import com.alibaba.fastjson2.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mongodb.client.result.DeleteResult;
+import com.ycl.feign.HKClient;
import com.ycl.feign.HkApiUtil;
+import com.ycl.feign.UYClient;
+import com.ycl.platform.domain.entity.CheckIndexCar;
+import com.ycl.platform.domain.entity.CheckIndexFace;
+import com.ycl.platform.domain.entity.TMonitor;
import com.ycl.platform.domain.param.HK.*;
import com.ycl.platform.domain.result.HK.*;
+import com.ycl.platform.domain.result.UY.MonitorQualifyResult;
+import com.ycl.platform.domain.result.UY.VideoOnlineResult;
+import com.ycl.platform.domain.vo.UpdateOnlineVO;
+import com.ycl.platform.mapper.CheckIndexCarMapper;
+import com.ycl.platform.mapper.CheckIndexFaceMapper;
+import com.ycl.platform.mapper.TMonitorMapper;
+import com.ycl.platform.mapper.WorkOrderMapper;
import com.ycl.platform.service.*;
import com.ycl.utils.DateUtils;
import constant.ApiConstants;
import constant.CheckConstants;
+import enumeration.general.AreaDeptEnum;
+import enumeration.general.PublishType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -18,9 +33,11 @@
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
-import java.util.Date;
-import java.util.List;
-import java.util.Objects;
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
//娴峰悍瀵规帴鏁版嵁浠诲姟
@Slf4j
@@ -33,12 +50,34 @@
public String appKey;
@Value("${HK.appSecret}")
public String appSecret;
+ @Value("${HK.carCode}")
+ public String carCode;
+ @Value("${HK.faceCode}")
+ public String faceCode;
+ @Value("${HK.carProvinceCode}")
+ public String carProvinceCode;
+ @Value("${HK.faceProvinceCode}")
+ public String faceProvinceCode;
@Autowired
private MongoTemplate mongoTemplate;
@Autowired
private IYwThresholdService ywThresholdService;
@Autowired
private YwPointService pointService;
+ @Autowired
+ private TMonitorMapper monitorMapper;
+ @Autowired
+ private UYErrorTypeCheckService uyErrorTypeCheckService;
+ @Autowired
+ private HKClient hkClient;
+ @Autowired
+ private ICheckIndexCarService carService;
+ @Autowired
+ private CheckIndexCarMapper carMapper;
+ @Autowired
+ private ICheckIndexFaceService faceService;
+ @Autowired
+ private CheckIndexFaceMapper faceMapper;
//杞﹁締璁惧鍏ㄦ鎸囨爣鐩戞祴缁撴灉
public void vehicleDeviceInspectionTask() {
@@ -48,7 +87,7 @@
param.setPageSize(ApiConstants.HKPageSize);
param.setDate(DateUtils.getDate());
param.setDataType(ApiConstants.HK_DataType_CAR);
- List<VehicleDeviceInspectionResult> list = HkApiUtil.sendAPI(host,appKey,appSecret,"/api/dqd/service/rs/v2/data/vehFullAmount/query", param, VehicleDeviceInspectionResult.class);
+ List<VehicleDeviceInspectionResult> list = HkApiUtil.sendAPI(host, appKey, appSecret, "/api/dqd/service/rs/v2/data/vehFullAmount/query", param, VehicleDeviceInspectionResult.class);
if (!CollectionUtils.isEmpty(list)) {
//濡傛灉瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎
Query query = new Query(Criteria.where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())));
@@ -77,7 +116,7 @@
param.setPageNo(ApiConstants.PageNo);
param.setPageSize(ApiConstants.HKPageSize);
param.setDate(DateUtils.getDate());
- List<FaceDeviceInspectionResult> list = HkApiUtil.sendAPI(host,appKey,appSecret,"/api/dqd/service/rs/v2/data/faceFullAmount/query", param, FaceDeviceInspectionResult.class);
+ List<FaceDeviceInspectionResult> list = HkApiUtil.sendAPI(host, appKey, appSecret, "/api/dqd/service/rs/v2/data/faceFullAmount/query", param, FaceDeviceInspectionResult.class);
if (!CollectionUtils.isEmpty(list)) {
//濡傛灉瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎
Query query = new Query(Criteria.where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())));
@@ -87,7 +126,7 @@
item.setNo(item.getExternalIndexCode());
}
});
- pointService.setDeviceTagByGB(list,CheckConstants.Rule_Category_Face);
+ pointService.setDeviceTagByGB(list, CheckConstants.Rule_Category_Face);
//瀛樻斁鍦╩ongo涓�
mongoTemplate.insertAll(list);
//鍚屾鐨勬暟鎹繘琛屽伐鍗曢槇鍊煎鐞�
@@ -108,7 +147,7 @@
carParam.setPageSize(ApiConstants.HKPageSize);
carParam.setDate(DateUtils.getDate());
carParam.setDataType(ApiConstants.HK_DataType_CAR);
- List<SnapshotDataMonitorResult> carList = HkApiUtil.sendAPI(host,appKey,appSecret,"/api/dqd/service/rs/v1/data/snapCountDetail/query", carParam, SnapshotDataMonitorResult.class);
+ List<SnapshotDataMonitorResult> carList = HkApiUtil.sendAPI(host, appKey, appSecret, "/api/dqd/service/rs/v1/data/snapCountDetail/query", carParam, SnapshotDataMonitorResult.class);
if (!CollectionUtils.isEmpty(carList)) {
//濡傛灉浠婂ぉ瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎
Query query = new Query(Criteria
@@ -120,12 +159,10 @@
item.setNo(item.getExternalIndexCode());
}
});
- pointService.setDeviceTagByGB(carList,CheckConstants.Rule_Category_Car);
+ pointService.setDeviceTagByGB(carList, CheckConstants.Rule_Category_Car);
//瀛樻斁鍦╩ongo涓�
carList.forEach(item -> item.setDataType(ApiConstants.HK_DataType_CAR));
mongoTemplate.insertAll(carList);
- //TODO锛氭洿鏂皃oint琛ㄥ湪绾跨姸鎬侊紙鏈夋姄鎷嶉噺瑙嗕綔鍦ㄧ嚎锛�
- //宸ュ崟
}
/** 浜鸿劯鏁版嵁 */
@@ -134,9 +171,8 @@
faceParam.setPageSize(ApiConstants.HKPageSize);
faceParam.setDate(DateUtils.getDate());
faceParam.setDataType(ApiConstants.HK_DataType_FACE);
- List<SnapshotDataMonitorResult> faceList = HkApiUtil.sendAPI(host,appKey,appSecret,"/api/dqd/service/rs/v1/data/snapCountDetail/query", faceParam, SnapshotDataMonitorResult.class);
+ List<SnapshotDataMonitorResult> faceList = HkApiUtil.sendAPI(host, appKey, appSecret, "/api/dqd/service/rs/v1/data/snapCountDetail/query", faceParam, SnapshotDataMonitorResult.class);
if (!CollectionUtils.isEmpty(faceList)) {
- log.info("缁撴灉鏁版嵁澶у皬锛歿}",faceList.size());
//濡傛灉浠婂ぉ瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎
Query query = new Query(Criteria
.where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))
@@ -147,14 +183,62 @@
item.setNo(item.getExternalIndexCode());
}
});
- pointService.setDeviceTagByGB(faceList,CheckConstants.Rule_Category_Face);
+ pointService.setDeviceTagByGB(faceList, CheckConstants.Rule_Category_Face);
//瀛樻斁鍦╩ongo涓�
faceList.forEach(item -> item.setDataType(ApiConstants.HK_DataType_FACE));
mongoTemplate.insertAll(faceList);
- //TODO:鏇存柊point琛ㄥ湪绾跨姸鎬侊紙鏈夋姄鎷嶉噺瑙嗕綔鍦ㄧ嚎锛�
- //宸ュ崟
}
-
+ //淇敼online鐘舵��
+ List<SnapshotDataMonitorResult> totalResult = new ArrayList<>();
+ totalResult.addAll(carList);
+ totalResult.addAll(faceList);
+ if (!CollectionUtils.isEmpty(totalResult)) {
+ //鍏堟嬁浼樹簯鐨勫湪绾匡紝杩囨护鎺変紭浜戝凡鏈夌殑鍥芥爣鐮�
+ Query query = new Query();
+ query.addCriteria(Criteria
+ .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())));
+ List<VideoOnlineResult> results = mongoTemplate.find(query, VideoOnlineResult.class);
+ if (!CollectionUtils.isEmpty(results)) {
+ Date now = new Date();
+ List<String> uyNoList = results.stream().map(VideoOnlineResult::getNo).collect(Collectors.toList());
+ List<String> numbers = totalResult.stream().filter(result->!uyNoList.contains(result.getExternalIndexCode()))
+ .map(SnapshotDataMonitorResult::getExternalIndexCode).collect(Collectors.toList());
+ //鎺掗櫎鎺変紭浜戜笖涓嶅寘鍚棰戣澶囩殑鍥芥爣
+ Map<String, TMonitor> map = monitorMapper.selectList(new QueryWrapper<TMonitor>()
+ .in("serial_number", numbers))
+ .stream().filter(monitor -> monitor.getCameraFunType()!=null && !monitor.getCameraFunType().contains("1"))
+ .collect(Collectors.toMap(TMonitor::getSerialNumber, Function.identity()));
+ List<UpdateOnlineVO> willUpdateList = new ArrayList<>();
+ totalResult.forEach(item -> {
+ TMonitor monitor = map.get(item.getExternalIndexCode());
+ if(monitor!=null) {
+ UpdateOnlineVO vo = new UpdateOnlineVO();
+ vo.setOnline(item.getDataCount() > 0 ? 1 : -1);
+ vo.setSerialNumber(monitor.getSerialNumber());
+ vo.setUpdateTime(now);
+ willUpdateList.add(vo);
+ }
+ });
+ if(!CollectionUtils.isEmpty(willUpdateList)) monitorMapper.updateOnlineFromHk(willUpdateList);
+// List<UpdateOnlineVO> willUpdateList = totalResult.stream().map(item -> {
+// UpdateOnlineVO vo = new UpdateOnlineVO();
+// vo.setOnline(item.getDataCount() > 0 ? 1 : -1);
+// vo.setIp(map.get(item.getExternalIndexCode()).getIp());
+// vo.setUpdateTime(now);
+// return vo;
+// }).collect(Collectors.toList());
+// monitorMapper.updateOnlineFromUyOrHk(willUpdateList);
+// //绂荤嚎鐢熸垚宸ュ崟,涓�涓猧p鍙敓鎴愪竴涓伐鍗�
+// List<SnapshotDataMonitorResult> workOrders = new ArrayList<>(totalResult.stream()
+// .filter(item -> ApiConstants.UY_OnlineSite_Offline.equals(item.getDataCount() > 0 ? 1 : -1))
+// .collect(Collectors.toMap(
+// SnapshotDataMonitorResult::getIp,
+// Function.identity(),
+// (existing, replacement) -> existing // 濡傛灉閬囧埌鐩稿悓鐨� IP锛屼繚鐣欑涓�涓紙existing锛�
+// )).values());
+// uyErrorTypeCheckService.hkOnlineCheck(workOrders);
+ }
+ }
log.info("缁撴潫鎶撴媿鏁版嵁閲忔娴嬬粨鏋滄暟鎹悓姝�");
}
@@ -166,7 +250,7 @@
param.setPageNo(ApiConstants.PageNo);
param.setPageSize(ApiConstants.HKPageSize);
param.setDate(DateUtils.getDate());
- List<MonitoringDetailResult> faceList = HkApiUtil.sendAPI(host,appKey,appSecret,"/api/dqd/service/rs/v1/device/cameraExpDetailInfo/query", param, MonitoringDetailResult.class);
+ List<MonitoringDetailResult> faceList = HkApiUtil.sendAPI(host, appKey, appSecret, "/api/dqd/service/rs/v1/device/cameraExpDetailInfo/query", param, MonitoringDetailResult.class);
if (!CollectionUtils.isEmpty(faceList)) {
//濡傛灉浠婂ぉ瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎
Query query = new Query(Criteria
@@ -177,7 +261,7 @@
item.setNo(item.getExternalIndexCode());
}
});
- pointService.setDeviceTagByGB(faceList,CheckConstants.Rule_Category_Face);
+ pointService.setDeviceTagByGB(faceList, CheckConstants.Rule_Category_Face);
//瀛樻斁鍦╩ongo涓�
mongoTemplate.insertAll(faceList);
}
@@ -192,7 +276,7 @@
param.setPageNo(ApiConstants.PageNo);
param.setPageSize(ApiConstants.HKPageSize);
param.setDate(DateUtils.getDate());
- List<CrossDetailResult> carList = HkApiUtil.sendAPI(host,appKey,appSecret,"/api/dqd/service/rs/v1/device/crossExpDetailInfo/query", param, CrossDetailResult.class);
+ List<CrossDetailResult> carList = HkApiUtil.sendAPI(host, appKey, appSecret, "/api/dqd/service/rs/v1/device/crossExpDetailInfo/query", param, CrossDetailResult.class);
if (!CollectionUtils.isEmpty(carList)) {
//濡傛灉浠婂ぉ瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎
Query query = new Query(Criteria
@@ -203,7 +287,7 @@
item.setNo(item.getExternalIndexCode());
}
});
- pointService.setDeviceTagByGB(carList,CheckConstants.Rule_Category_Car);
+ pointService.setDeviceTagByGB(carList, CheckConstants.Rule_Category_Car);
//瀛樻斁鍦╩ongo涓�
mongoTemplate.insertAll(carList);
}
@@ -219,7 +303,7 @@
param.setPageSize(ApiConstants.HKPageSize);
param.setDate(DateUtils.getDate());
param.setDataType(ApiConstants.HK_DataType_CAR);
- List<DataIntegrityMonitoringResult> carList = HkApiUtil.sendAPI(host,appKey,appSecret,"/api/dqd/service/rs/v1/data/attributeIntegrity/query", param, DataIntegrityMonitoringResult.class);
+ List<DataIntegrityMonitoringResult> carList = HkApiUtil.sendAPI(host, appKey, appSecret, "/api/dqd/service/rs/v1/data/attributeIntegrity/query", param, DataIntegrityMonitoringResult.class);
if (!CollectionUtils.isEmpty(carList)) {
//濡傛灉浠婂ぉ瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎
@@ -231,7 +315,7 @@
item.setNo(item.getExternalIndexCode());
}
});
- pointService.setDeviceTagByGB(carList,CheckConstants.Rule_Category_Car);
+ pointService.setDeviceTagByGB(carList, CheckConstants.Rule_Category_Car);
//瀛樻斁鍦╩ongo涓�
mongoTemplate.insertAll(carList);
}
@@ -247,7 +331,7 @@
param.setPageSize(ApiConstants.HKPageSize);
param.setDate(DateUtils.getDate());
param.setDataType(ApiConstants.HK_DataType_CAR);
- List<AttrRecognitionMonitorResult> carList = HkApiUtil.sendAPI(host,appKey,appSecret,"/api/dqd/service/rs/v1/data/attributeRecognition/query", param, AttrRecognitionMonitorResult.class);
+ List<AttrRecognitionMonitorResult> carList = HkApiUtil.sendAPI(host, appKey, appSecret, "/api/dqd/service/rs/v1/data/attributeRecognition/query", param, AttrRecognitionMonitorResult.class);
if (!CollectionUtils.isEmpty(carList)) {
//濡傛灉浠婂ぉ瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎
@@ -259,7 +343,7 @@
item.setNo(item.getExternalIndexCode());
}
});
- pointService.setDeviceTagByGB(carList,CheckConstants.Rule_Category_Car);
+ pointService.setDeviceTagByGB(carList, CheckConstants.Rule_Category_Car);
//瀛樻斁鍦╩ongo涓�
mongoTemplate.insertAll(carList);
}
@@ -277,7 +361,7 @@
carParam.setPageSize(ApiConstants.HKPageSize);
carParam.setDate(DateUtils.getDate());
carParam.setDataType(ApiConstants.HK_DataType_CAR);
- List<SnapshotDelayMonitorResult> carList = HkApiUtil.sendAPI(host,appKey,appSecret,"/api/dqd/service/rs/v1/data/snapAgingDetail/query", carParam, SnapshotDelayMonitorResult.class);
+ List<SnapshotDelayMonitorResult> carList = HkApiUtil.sendAPI(host, appKey, appSecret, "/api/dqd/service/rs/v1/data/snapAgingDetail/query", carParam, SnapshotDelayMonitorResult.class);
if (!CollectionUtils.isEmpty(carList)) {
//濡傛灉浠婂ぉ瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎
@@ -292,7 +376,7 @@
item.setNo(item.getExternalIndexCode());
}
});
- pointService.setDeviceTagByGB(carList,CheckConstants.Rule_Category_Car);
+ pointService.setDeviceTagByGB(carList, CheckConstants.Rule_Category_Car);
mongoTemplate.insertAll(carList);
}
@@ -302,7 +386,7 @@
faceParam.setPageSize(ApiConstants.HKPageSize);
faceParam.setDate(DateUtils.getDate());
faceParam.setDataType(ApiConstants.HK_DataType_FACE);
- List<SnapshotDelayMonitorResult> faceList = HkApiUtil.sendAPI(host,appKey,appSecret,"/api/dqd/service/rs/v1/data/snapAgingDetail/query", faceParam, SnapshotDelayMonitorResult.class);
+ List<SnapshotDelayMonitorResult> faceList = HkApiUtil.sendAPI(host, appKey, appSecret, "/api/dqd/service/rs/v1/data/snapAgingDetail/query", faceParam, SnapshotDelayMonitorResult.class);
if (!CollectionUtils.isEmpty(faceList)) {
//濡傛灉浠婂ぉ瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎
@@ -317,7 +401,7 @@
item.setNo(item.getExternalIndexCode());
}
});
- pointService.setDeviceTagByGB(faceList,CheckConstants.Rule_Category_Face);
+ pointService.setDeviceTagByGB(faceList, CheckConstants.Rule_Category_Face);
mongoTemplate.insertAll(faceList);
}
log.info("缁撴潫鎶撴媿鏁版嵁鏃跺欢鐩戞祴缁撴灉鏁版嵁鍚屾");
@@ -332,7 +416,7 @@
param.setPageSize(ApiConstants.HKPageSize);
param.setDate(DateUtils.getDate());
param.setDataType(ApiConstants.HK_DataType_CAR);
- List<PicAccessResult> carList = HkApiUtil.sendAPI(host,appKey,appSecret,"/api/dqd/service/rs/v1/data/picAccessDetail/query", param, PicAccessResult.class);
+ List<PicAccessResult> carList = HkApiUtil.sendAPI(host, appKey, appSecret, "/api/dqd/service/rs/v1/data/picAccessDetail/query", param, PicAccessResult.class);
if (!CollectionUtils.isEmpty(carList)) {
//濡傛灉浠婂ぉ瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎
@@ -344,7 +428,7 @@
item.setNo(item.getExternalIndexCode());
}
});
- pointService.setDeviceTagByGB(carList,CheckConstants.Rule_Category_Car);
+ pointService.setDeviceTagByGB(carList, CheckConstants.Rule_Category_Car);
//瀛樻斁鍦╩ongo涓�
mongoTemplate.insertAll(carList);
}
@@ -360,7 +444,7 @@
param.setPageSize(ApiConstants.HKPageSize);
param.setDate(DateUtils.getDate());
param.setDataType(ApiConstants.HK_DataType_CAR);
- List<VehicleDeviceSamplingResult> carList = HkApiUtil.sendAPI(host,appKey,appSecret,"/api/dqd/service/rs/v2/data/vehSampleAmount/query", param, VehicleDeviceSamplingResult.class);
+ List<VehicleDeviceSamplingResult> carList = HkApiUtil.sendAPI(host, appKey, appSecret, "/api/dqd/service/rs/v2/data/vehSampleAmount/query", param, VehicleDeviceSamplingResult.class);
if (!CollectionUtils.isEmpty(carList)) {
//濡傛灉浠婂ぉ瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎
@@ -372,7 +456,7 @@
item.setNo(item.getExternalIndexCode());
}
});
- pointService.setDeviceTagByGB(carList,CheckConstants.Rule_Category_Car);
+ pointService.setDeviceTagByGB(carList, CheckConstants.Rule_Category_Car);
//瀛樻斁鍦╩ongo涓�
mongoTemplate.insertAll(carList);
}
@@ -387,7 +471,7 @@
param.setPageNo(ApiConstants.PageNo);
param.setPageSize(ApiConstants.HKPageSize);
param.setDate(DateUtils.getDate());
- List<FaceDeviceSamplingResult> faceList = HkApiUtil.sendAPI(host,appKey,appSecret,"/api/dqd/service/rs/v2/data/faceSampleAmount/query", param, FaceDeviceSamplingResult.class);
+ List<FaceDeviceSamplingResult> faceList = HkApiUtil.sendAPI(host, appKey, appSecret, "/api/dqd/service/rs/v2/data/faceSampleAmount/query", param, FaceDeviceSamplingResult.class);
if (!CollectionUtils.isEmpty(faceList)) {
//濡傛灉浠婂ぉ瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎
@@ -399,17 +483,148 @@
item.setNo(item.getExternalIndexCode());
}
});
- pointService.setDeviceTagByGB(faceList,CheckConstants.Rule_Category_Face);
+ pointService.setDeviceTagByGB(faceList, CheckConstants.Rule_Category_Face);
//瀛樻斁鍦╩ongo涓�
mongoTemplate.insertAll(faceList);
}
log.info("缁撴潫浜鸿劯璁惧鎶芥鎸囨爣鐩戞祴缁撴灉鏁版嵁鍚屾");
}
+ //鑰冩牳鎴愮哗
+ public void HkScoreTask() {
+ log.info("寮�濮嬫墽琛屾捣搴疯�冩牳鎴愮哗鏁版嵁");
+ //鍑嗗鏂板鎴栦慨鏀圭殑鏁版嵁
+ List<CheckIndexCar> cars = new ArrayList<>();
+ List<CheckIndexFace> faces = new ArrayList<>();
+ // 鏌ヨ鏄惁index琛ㄥ凡缁忓瓨鍦ㄤ粖鏃ユ暟鎹�
+ List<CheckIndexFace> checkIndexFaceList = faceMapper.selectToday(utils.DateUtils.getDate());
+ List<CheckIndexCar> checkIndexCarList = carMapper.selectToday(utils.DateUtils.getDate());
+
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+ // 鑾峰彇褰撳墠鏃堕棿鐨凜alendar瀹炰緥
+ Calendar calendar = Calendar.getInstance();
+ // 璁剧疆鏃堕棿涓哄墠涓�澶�
+ calendar.add(Calendar.DATE, -1);
+ // 鑾峰彇鍓嶄竴澶╃殑Date瀵硅薄
+ Date yesterday = calendar.getTime();
+ //鍏堣姹傚叏閲忔暟鎹�
+ ScoreParam param = new ScoreParam();
+ param.setStartDate(format.format(yesterday));
+ param.setEndDate(format.format(yesterday));
+ param.setFocusFlag(ApiConstants.HK_FOCUS_FLAG_ALL);
+ param.setCarTree(carCode);
+ param.setFaceTree(faceCode);
+ JSONObject scoreJson = hkClient.getScore(param);
+ if (scoreJson != null) {
+ String code = scoreJson.getString("code");
+ if (ApiConstants.HKSuccessCode.equals(code)) {
+ List<HKScoreResult> data = scoreJson.getList("data", HKScoreResult.class);
+ //鏍规嵁鏁版嵁杞崲涓篿ndex瀵硅薄
+ data.forEach(score -> {
+ CheckIndexCar car = new CheckIndexCar();
+ CheckIndexFace face = new CheckIndexFace();
+ score2Index(score, car, face);
+ car.setExamineTag(CheckConstants.Examine_Tag_County);
+ face.setExamineTag(CheckConstants.Examine_Tag_County);
+ Optional<CheckIndexCar> carFirst = checkIndexCarList.stream()
+ .filter(index -> CheckConstants.Examine_Tag_County.equals(index.getExamineTag()) && car.getDeptId().equals(index.getDeptId()))
+ .findFirst();
+ Optional<CheckIndexFace> faceFirst = checkIndexFaceList.stream()
+ .filter(index -> CheckConstants.Examine_Tag_County.equals(index.getExamineTag()) && face.getDeptId().equals(index.getDeptId()))
+ .findFirst();
+ if (carFirst.isPresent()) {
+ car.setId(carFirst.get().getId());
+ }
+ if (faceFirst.isPresent()) {
+ face.setId(faceFirst.get().getId());
+ }
+ cars.add(car);
+ faces.add(face);
+ });
+ }
+ }
+
+ //鍏堣姹傜渷鍘呮暟鎹�
+ ScoreParam provinceParam = new ScoreParam();
+ provinceParam.setStartDate(format.format(yesterday));
+ provinceParam.setEndDate(format.format(yesterday));
+ provinceParam.setFocusFlag(ApiConstants.HK_FOCUS_FLAG_ALL);
+ provinceParam.setCarTree(carProvinceCode);
+ provinceParam.setFaceTree(faceProvinceCode);
+ JSONObject scoreProvinceJson = hkClient.getScore(provinceParam);
+ if (scoreProvinceJson != null) {
+ String code = scoreProvinceJson.getString("code");
+ if (ApiConstants.HKSuccessCode.equals(code)) {
+ List<HKScoreResult> data = scoreProvinceJson.getList("data", HKScoreResult.class);
+
+ //鏍规嵁鏁版嵁杞崲涓篿ndex瀵硅薄
+ data.forEach(score -> {
+ CheckIndexCar car = new CheckIndexCar();
+ CheckIndexFace face = new CheckIndexFace();
+ score2Index(score, car, face);
+ car.setExamineTag(CheckConstants.Examine_Tag_Province);
+ face.setExamineTag(CheckConstants.Examine_Tag_Province);
+ Optional<CheckIndexCar> carFirst = checkIndexCarList.stream()
+ .filter(index -> CheckConstants.Examine_Tag_Province.equals(index.getExamineTag()) && car.getDeptId().equals(index.getDeptId()))
+ .findFirst();
+ Optional<CheckIndexFace> faceFirst = checkIndexFaceList.stream()
+ .filter(index -> CheckConstants.Examine_Tag_Province.equals(index.getExamineTag()) && face.getDeptId().equals(index.getDeptId()))
+ .findFirst();
+ if (carFirst.isPresent()) {
+ car.setId(carFirst.get().getId());
+ }
+ if (faceFirst.isPresent()) {
+ face.setId(faceFirst.get().getId());
+ }
+ cars.add(car);
+ faces.add(face);
+ });
+ }
+ }
+ //瀛樻斁鎴愮哗鍒癿ysql锛屽鏋滃瓨鍦ㄥ垯鏇挎崲涓嶅瓨鍦ㄥ氨鏂板銆�
+ if (!CollectionUtils.isEmpty(cars)) carService.saveOrUpdateBatch(cars);
+ if (!CollectionUtils.isEmpty(faces)) faceService.saveOrUpdateBatch(faces);
+ log.info("缁撴潫娴峰悍鑰冩牳鎴愮哗鏁版嵁");
+ }
+
+ private void score2Index(HKScoreResult score, CheckIndexCar car, CheckIndexFace face) {
+ car.setDeptId(Long.parseLong(AreaDeptEnum.fromCode(score.getAreaCode()).getDeptId() + ""));
+ car.setCreateTime(new Date());
+ car.setPublish(PublishType.PUBLISHED.getCode());
+ face.setDeptId(Long.parseLong(AreaDeptEnum.fromCode(score.getAreaCode()).getDeptId() + ""));
+ face.setCreateTime(new Date());
+ face.setPublish(PublishType.PUBLISHED.getCode());
+
+ car.setViewConnectStability(new BigDecimal(score.getDownCarDataUploadScoreString() == null ? "1" : score.getDownCarDataUploadScoreString()));
+ car.setSiteOnline(new BigDecimal(score.getDownCrossQualityCarScoreString() == null ? "1" : score.getDownCrossQualityCarScoreString()));
+ car.setDeviceDirectoryConsistent(new BigDecimal(score.getDownCrossNumPushCarScoreString() == null ? "1" : score.getDownCrossNumPushCarScoreString()));
+ //TODO:娌℃壘鍒拌�冩牳椤�
+ car.setVehicleInformationCollectionAccuracy(new BigDecimal("1"));
+ car.setVehicleCaptureIntegrity(new BigDecimal(score.getDownCrossAllCarDataIntegrityScoreString() == null ? "1" : score.getDownCrossAllCarDataIntegrityScoreString()));
+ //娴峰悍鏄涓�1鐨勶紝浣嗘槸鎺ュ彛鎺ㄧ殑鍘熷鏁版嵁
+ car.setVehicleCaptureAccuracy(new BigDecimal("1"));
+ car.setVehicleTimingAccuracy(new BigDecimal(score.getDownCrossCarInvertScoreString() == null ? "1" : score.getDownCrossCarInvertScoreString()));
+ car.setVehicleUploadTimeliness(new BigDecimal(score.getDownCrossAllCarDelayScoreString() == null ? "1" : score.getDownCrossAllCarDelayScoreString()));
+ //TODO:娌℃壘鍒拌�冩牳椤�
+ car.setVehicleUrlAvailability(new BigDecimal("1"));
+ car.setVehiclePictureAvailability(new BigDecimal(score.getDownCrossPictureQualityCarScoreString() == null ? "1" : score.getDownCrossPictureQualityCarScoreString()));
+
+ face.setViewConnectStability(new BigDecimal(score.getDownFaceDataUploadScoreString() == null ? "1" : score.getDownFaceDataUploadScoreString()));
+ face.setSiteOnline(new BigDecimal(score.getDownFaceDataUploadScoreString() == null ? "1" : score.getDownFaceDataUploadScoreString()));
+ face.setDeviceDirectoryConsistent(new BigDecimal(score.getDownCrossNumPushFaceScoreString() == null ? "1" : score.getDownCrossNumPushFaceScoreString()));
+ //TODO:娌℃壘鍒拌�冩牳椤�
+ face.setFaceInformationCollectionAccuracy(new BigDecimal("1"));
+ //TODO:娌℃壘鍒拌�冩牳椤�
+ face.setFacePictureQualification(new BigDecimal("1"));
+ face.setFaceTimingAccuracy(new BigDecimal(score.getDownCrossFaceInvertScoreString() == null ? "1" : score.getDownCrossFaceInvertScoreString()));
+ face.setFaceUploadTimeliness(new BigDecimal(score.getDownCrossAllFaceDelayScoreString() == null ? "1" : score.getDownCrossAllFaceDelayScoreString()));
+ face.setFacePictureAvailability(new BigDecimal(score.getDownCrossPictureQualityFaceScoreString() == null ? "1" : score.getDownCrossPictureQualityFaceScoreString()));
+ }
+
//瑙f瀽鏁版嵁
private <T> List<T> getDataList(JSONObject jsonObject, Class<T> resultClass, String message) {
if (jsonObject != null && ApiConstants.HKSuccessCode.equals(jsonObject.getString("code"))) {
- log.info("鏁版嵁鏍煎紡"+jsonObject);
+ log.info("鏁版嵁鏍煎紡" + jsonObject);
JSONObject data = jsonObject.getJSONObject("data");
if (data == null) {
log.error(message, jsonObject);
--
Gitblit v1.8.0