From c83101eb62f5d4906b9c01ceea6b21a37f9e84d8 Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期二, 18 十一月 2025 09:24:53 +0800
Subject: [PATCH] bug修复
---
ycl-server/src/main/java/com/ycl/task/HKTask.java | 730 +++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 647 insertions(+), 83 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 bdcda0d..f43b1e2 100644
--- a/ycl-server/src/main/java/com/ycl/task/HKTask.java
+++ b/ycl-server/src/main/java/com/ycl/task/HKTask.java
@@ -1,46 +1,83 @@
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.HkApiUtil;
-import com.ycl.feign.HkApiUtil;
+import com.ycl.feign.*;
+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.service.ICheckIndexCarService;
-import com.ycl.platform.service.ICheckIndexFaceService;
-import com.ycl.platform.service.ICheckIndexVideoService;
-import com.ycl.platform.service.IYwThresholdService;
+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.service.*;
import com.ycl.utils.DateUtils;
import constant.ApiConstants;
-import com.ycl.feign.HKClient;
+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;
+import org.springframework.cloud.client.loadbalancer.LoadBalancerRequestFactory;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
+import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
-import java.util.Date;
-import java.util.List;
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
//娴峰悍瀵规帴鏁版嵁浠诲姟
@Slf4j
@Component("HKTask")
public class HKTask {
+ @Value("${HK.host}")
+ public String host;
+ @Value("${HK.appKey}")
+ 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 ICheckIndexFaceService checkIndexFaceService;
+ private YwPointService pointService;
@Autowired
- private ICheckIndexCarService checkIndexCarService;
+ private TMonitorMapper monitorMapper;
@Autowired
- private ICheckIndexVideoService checkIndexVideoService;
+ private UYErrorTypeCheckService uyErrorTypeCheckService;
+ @Autowired
+ private HKClient hkClient;
+ @Autowired
+ private ICheckIndexCarService carService;
+ @Autowired
+ private CheckIndexCarMapper carMapper;
+ @Autowired
+ private ICheckIndexFaceService faceService;
+ @Autowired
+ private CheckIndexFaceMapper faceMapper;
- //杞﹁締璁惧鍏ㄦ鎸囨爣鐩戞祴缁撴灉
+ //杞﹁締璁惧鍏ㄦ鎸囨爣鐩戞祴缁撴灉 杞﹁締锛堣溅杈嗗崱鍙h澶囨椂閽熷噯纭�с�侊級
public void vehicleDeviceInspectionTask() {
log.info("寮�濮嬫墽琛岃溅杈嗚澶囧叏妫�鎸囨爣鐩戞祴缁撴灉鏁版嵁鍚屾");
VehicleDeviceInspectionParam param = new VehicleDeviceInspectionParam();
@@ -48,42 +85,58 @@
param.setPageSize(ApiConstants.HKPageSize);
param.setDate(DateUtils.getDate());
param.setDataType(ApiConstants.HK_DataType_CAR);
- List<VehicleDeviceInspectionResult> list = HkApiUtil.sendAPI("/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())));
DeleteResult result = mongoTemplate.remove(query, VehicleDeviceInspectionResult.class);
+ list.stream().forEach(item -> {
+ if (Objects.nonNull(item.getExternalIndexCode())) {
+ item.setNo(item.getExternalIndexCode());
+ }
+ });
+ pointService.setDeviceTagByGB(list, CheckConstants.Rule_Category_Car);
//瀛樻斁鍦╩ongo涓�
mongoTemplate.insertAll(list);
//鍚屾鐨勬暟鎹繘琛屽伐鍗曢槇鍊煎鐞�
ywThresholdService.carCheck(list);
}
+ // 鏈湴娴嬭瘯
+// Query query = new Query(Criteria.where("mongoCreateTime").lt(DateUtils.getDayEnd(new Date())));
+// ywThresholdService.carCheck(mongoTemplate.find(query, VehicleDeviceInspectionResult.class));
log.info("缁撴潫杞﹁締璁惧鍏ㄦ鎸囨爣鐩戞祴缁撴灉鏁版嵁鍚屾");
}
- //浜鸿劯璁惧鍏ㄦ鎸囨爣鐩戞祴缁撴灉
+ //浜鸿劯璁惧鍏ㄦ鎸囨爣鐩戞祴缁撴灉 浜鸿劯锛堣澶囨姄鎷嶅浘鐗囨椂閽熷噯纭�э級
public void faceDeviceInspectionTask() {
log.info("寮�濮嬫墽琛屼汉鑴歌澶囧叏妫�鎸囨爣鐩戞祴缁撴灉鏁版嵁鍚屾");
FaceDeviceInspectionParam param = new FaceDeviceInspectionParam();
param.setPageNo(ApiConstants.PageNo);
param.setPageSize(ApiConstants.HKPageSize);
param.setDate(DateUtils.getDate());
- List<FaceDeviceInspectionResult> list = HkApiUtil.sendAPI("/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())));
DeleteResult result = mongoTemplate.remove(query, FaceDeviceInspectionResult.class);
+ list.stream().forEach(item -> {
+ if (Objects.nonNull(item.getExternalIndexCode())) {
+ item.setNo(item.getExternalIndexCode());
+ }
+ });
+ pointService.setDeviceTagByGB(list, CheckConstants.Rule_Category_Face);
//瀛樻斁鍦╩ongo涓�
mongoTemplate.insertAll(list);
//鍚屾鐨勬暟鎹繘琛屽伐鍗曢槇鍊煎鐞�
- //TODO:鍙兘鏈夐噸澶嶅伐鍗�
ywThresholdService.faceCheck(list);
}
+// Query query = new Query(Criteria.where("mongoCreateTime").lt(DateUtils.getDayEnd(new Date())));
+// ywThresholdService.faceCheck(mongoTemplate.find(query, FaceDeviceInspectionResult.class));
log.info("缁撴潫浜鸿劯璁惧鍏ㄦ鎸囨爣鐩戞祴缁撴灉鏁版嵁鍚屾");
}
- //鎶撴媿鏁版嵁閲忕洃娴嬬粨鏋�
+ // 鎶撴媿鏁版嵁閲忕洃娴嬬粨鏋� 杞﹁締浜鸿劯锛堣鍥惧簱瀵规帴绋冲畾鎬с�佺偣浣嶅湪绾跨巼锛�
public void snapshotDataMonitorTask() {
log.info("寮�濮嬫墽琛屾姄鎷嶆暟鎹噺妫�娴嬬粨鏋滄暟鎹悓姝�");
/** 杞﹁締鏁版嵁 */
@@ -92,13 +145,19 @@
carParam.setPageSize(ApiConstants.HKPageSize);
carParam.setDate(DateUtils.getDate());
carParam.setDataType(ApiConstants.HK_DataType_CAR);
- List<SnapshotDataMonitorResult> carList = HkApiUtil.sendAPI("/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
.where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))
.and("dataType").is(ApiConstants.HK_DataType_CAR));
DeleteResult result = mongoTemplate.remove(query, SnapshotDataMonitorResult.class);
+ carList.stream().forEach(item -> {
+ if (Objects.nonNull(item.getExternalIndexCode())) {
+ item.setNo(item.getExternalIndexCode());
+ }
+ });
+ pointService.setDeviceTagByGB(carList, CheckConstants.Rule_Category_Car);
//瀛樻斁鍦╩ongo涓�
carList.forEach(item -> item.setDataType(ApiConstants.HK_DataType_CAR));
mongoTemplate.insertAll(carList);
@@ -110,22 +169,82 @@
faceParam.setPageSize(ApiConstants.HKPageSize);
faceParam.setDate(DateUtils.getDate());
faceParam.setDataType(ApiConstants.HK_DataType_FACE);
- List<SnapshotDataMonitorResult> faceList = HkApiUtil.sendAPI("/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);
+ log.info("鎵撳嵃浜鸿劯锛堣鍥惧簱瀵规帴绋冲畾鎬с�佺偣浣嶅湪绾跨巼锛塇K鎺ュ彛鑾峰緱浠诲姟淇℃伅:{}",faceList);
if (!CollectionUtils.isEmpty(faceList)) {
+
//濡傛灉浠婂ぉ瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎
Query query = new Query(Criteria
.where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))
.and("dataType").is(ApiConstants.HK_DataType_FACE));
DeleteResult result = mongoTemplate.remove(query, SnapshotDataMonitorResult.class);
+ faceList.stream().forEach(item -> {
+ if (Objects.nonNull(item.getExternalIndexCode())) {
+ item.setNo(item.getExternalIndexCode());
+ }
+ });
+ pointService.setDeviceTagByGB(faceList, CheckConstants.Rule_Category_Face);
//瀛樻斁鍦╩ongo涓�
- carList.forEach(item -> item.setDataType(ApiConstants.HK_DataType_FACE));
+ faceList.forEach(item -> item.setDataType(ApiConstants.HK_DataType_FACE));
+ log.info("鎵撳嵃浜鸿劯锛堣鍥惧簱瀵规帴绋冲畾鎬с�佺偣浣嶅湪绾跨巼锛夎缃畉ag骞舵彃鍏ongodb鏁版嵁:{}",faceList);
mongoTemplate.insertAll(faceList);
}
- //TODO:宸ュ崟
+ //淇敼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);
+ }
+ });
+ log.info("淇敼璁惧灏嗚鏇存柊鍏ql涓暟鎹細{}",willUpdateList);
+ 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("缁撴潫鎶撴媿鏁版嵁閲忔娴嬬粨鏋滄暟鎹悓姝�");
}
- //閲囬泦璁惧灞炴�х洃娴嬬粨鏋�(浜鸿劯)
+ //閲囬泦璁惧灞炴�х洃娴嬬粨鏋�(浜鸿劯) 浜鸿劯锛堜汉鑴稿崱鍙d俊鎭噰闆嗗噯纭巼锛�
public void monitorDetailTask() {
log.info("寮�濮嬫墽琛岄噰闆嗚澶囧睘鎬х洃娴嬬粨鏋滄暟鎹悓姝�");
//浜鸿劯鍗″彛淇℃伅閲囬泦鍑嗙‘鐜�
@@ -133,20 +252,25 @@
param.setPageNo(ApiConstants.PageNo);
param.setPageSize(ApiConstants.HKPageSize);
param.setDate(DateUtils.getDate());
- List<MonitoringDetailResult> faceList = HkApiUtil.sendAPI("/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
.where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())));
DeleteResult result = mongoTemplate.remove(query, MonitoringDetailResult.class);
+ faceList.stream().forEach(item -> {
+ if (Objects.nonNull(item.getExternalIndexCode())) {
+ item.setNo(item.getExternalIndexCode());
+ }
+ });
+ pointService.setDeviceTagByGB(faceList, CheckConstants.Rule_Category_Face);
//瀛樻斁鍦╩ongo涓�
mongoTemplate.insertAll(faceList);
}
- //TODO:宸ュ崟澶勭悊
log.info("缁撴潫閲囬泦璁惧灞炴�х洃娴嬬粨鏋滄暟鎹悓姝�");
}
- //鍗″彛灞炴�х洃娴嬬粨鏋�
+ //鍗″彛灞炴�х洃娴嬬粨鏋� 杞﹁締锛堣溅杈嗗崱鍙d俊鎭噰闆嗗噯纭巼銆侊級
public void crossDetailTask() {
log.info("寮�濮嬫墽琛屽崱鍙e睘鎬х洃娴嬬粨鏋滄暟鎹悓姝�");
//杞﹁締鍗″彛淇℃伅閲囬泦鍑嗙‘鐜�
@@ -154,20 +278,25 @@
param.setPageNo(ApiConstants.PageNo);
param.setPageSize(ApiConstants.HKPageSize);
param.setDate(DateUtils.getDate());
- List<CrossDetailResult> faceList = HkApiUtil.sendAPI("/api/dqd/service/rs/v1/device/crossExpDetailInfo/query", param, CrossDetailResult.class);
- if (!CollectionUtils.isEmpty(faceList)) {
+ 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
.where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())));
DeleteResult result = mongoTemplate.remove(query, CrossDetailResult.class);
+ carList.stream().forEach(item -> {
+ if (Objects.nonNull(item.getExternalIndexCode())) {
+ item.setNo(item.getExternalIndexCode());
+ }
+ });
+ pointService.setDeviceTagByGB(carList, CheckConstants.Rule_Category_Car);
//瀛樻斁鍦╩ongo涓�
- mongoTemplate.insertAll(faceList);
+ mongoTemplate.insertAll(carList);
}
- //TODO:宸ュ崟澶勭悊
log.info("缁撴潫鍗″彛灞炴�х洃娴嬬粨鏋滄暟鎹悓姝�");
}
- //鏁版嵁瀹屾暣鎬х洃娴嬬粨鏋�
+ //鏁版嵁瀹屾暣鎬х洃娴嬬粨鏋� 杞﹂噺锛堣溅杈嗗崱鍙h澶囨姄鎷嶆暟鎹畬鏁存�с�侊級
public void dataIntegrityMonitoringTask() {
log.info("寮�濮嬫墽琛屾暟鎹畬鏁存�х洃娴嬬粨鏋滄暟鎹悓姝�");
//杞﹁締鍗″彛璁惧鎶撴媿鏁版嵁瀹屾暣鎬�
@@ -176,21 +305,26 @@
param.setPageSize(ApiConstants.HKPageSize);
param.setDate(DateUtils.getDate());
param.setDataType(ApiConstants.HK_DataType_CAR);
- List<DataIntegrityMonitoringResult> faceList = HkApiUtil.sendAPI("/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(faceList)) {
+ if (!CollectionUtils.isEmpty(carList)) {
//濡傛灉浠婂ぉ瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎
Query query = new Query(Criteria
.where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())));
DeleteResult result = mongoTemplate.remove(query, DataIntegrityMonitoringResult.class);
+ carList.stream().forEach(item -> {
+ if (Objects.nonNull(item.getExternalIndexCode())) {
+ item.setNo(item.getExternalIndexCode());
+ }
+ });
+ pointService.setDeviceTagByGB(carList, CheckConstants.Rule_Category_Car);
//瀛樻斁鍦╩ongo涓�
- mongoTemplate.insertAll(faceList);
+ mongoTemplate.insertAll(carList);
}
- //TODO:宸ュ崟澶勭悊
log.info("缁撴潫鏁版嵁瀹屾暣鎬х洃娴嬬粨鏋滄暟鎹悓姝�");
}
- //灞炴�ц瘑鍒噯纭洃娴嬬粨鏋�
+ //灞炴�ц瘑鍒噯纭洃娴嬬粨鏋� 杞﹁締锛堣溅杈嗗崱鍙h澶囨姄鎷嶆暟鎹噯纭�с�侊級
public void attrRecognitionMonitorTask() {
log.info("寮�濮嬫墽琛屽睘鎬ц瘑鍒噯纭洃娴嬬粨鏋滄暟鎹悓姝�");
//杞﹁締鍗″彛璁惧鎶撴媿鏁版嵁鍑嗙‘鎬�
@@ -199,22 +333,27 @@
param.setPageSize(ApiConstants.HKPageSize);
param.setDate(DateUtils.getDate());
param.setDataType(ApiConstants.HK_DataType_CAR);
- List<AttrRecognitionMonitorResult> faceList = HkApiUtil.sendAPI("/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(faceList)) {
+ if (!CollectionUtils.isEmpty(carList)) {
//濡傛灉浠婂ぉ瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎
Query query = new Query(Criteria
.where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())));
DeleteResult result = mongoTemplate.remove(query, AttrRecognitionMonitorResult.class);
+ carList.stream().forEach(item -> {
+ if (Objects.nonNull(item.getExternalIndexCode())) {
+ item.setNo(item.getExternalIndexCode());
+ }
+ });
+ pointService.setDeviceTagByGB(carList, CheckConstants.Rule_Category_Car);
//瀛樻斁鍦╩ongo涓�
- mongoTemplate.insertAll(faceList);
+ mongoTemplate.insertAll(carList);
}
- //TODO:宸ュ崟澶勭悊
log.info("缁撴潫灞炴�ц瘑鍒噯纭洃娴嬬粨鏋滄暟鎹悓姝�");
}
- //鎶撴媿鏁版嵁鏃跺欢鐩戞祴缁撴灉
+ //鎶撴媿鏁版嵁鏃跺欢鐩戞祴缁撴灉鍖呭惈 杞﹁締浜鸿劯锛堟姄鎷嶆暟鎹笂浼犲強鏃舵�э級
public void snapshopDelayMonitorTask() {
log.info("寮�濮嬫墽琛屾姄鎷嶆暟鎹椂寤剁洃娴嬬粨鏋滄暟鎹悓姝�");
//杞﹁締鍗″彛璁惧鎶撴媿鏁版嵁涓婁紶鍙婃椂鎬�
@@ -224,16 +363,22 @@
carParam.setPageSize(ApiConstants.HKPageSize);
carParam.setDate(DateUtils.getDate());
carParam.setDataType(ApiConstants.HK_DataType_CAR);
- List<SnapshotDelayMonitorResult> carList = HkApiUtil.sendAPI("/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)) {
//濡傛灉浠婂ぉ瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎
Query query = new Query(Criteria
.where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))
.and("dataType").is(ApiConstants.HK_DataType_CAR));
- DeleteResult result = mongoTemplate.remove(query, SnapshotDelayMonitorParam.class);
+ DeleteResult result = mongoTemplate.remove(query, SnapshotDelayMonitorResult.class);
//瀛樻斁鍦╩ongo涓�
- carList.forEach(item -> item.setDataType(ApiConstants.HK_DataType_CAR));
+ carList.stream().forEach(item -> {
+ item.setDataType(ApiConstants.HK_DataType_CAR);
+ if (Objects.nonNull(item.getExternalIndexCode())) {
+ item.setNo(item.getExternalIndexCode());
+ }
+ });
+ pointService.setDeviceTagByGB(carList, CheckConstants.Rule_Category_Car);
mongoTemplate.insertAll(carList);
}
@@ -243,23 +388,28 @@
faceParam.setPageSize(ApiConstants.HKPageSize);
faceParam.setDate(DateUtils.getDate());
faceParam.setDataType(ApiConstants.HK_DataType_FACE);
- List<SnapshotDelayMonitorParam> faceList = HkApiUtil.sendAPI("/api/dqd/service/rs/v1/data/snapAgingDetail/query", faceParam, SnapshotDelayMonitorParam.class);
+ List<SnapshotDelayMonitorResult> faceList = HkApiUtil.sendAPI(host, appKey, appSecret, "/api/dqd/service/rs/v1/data/snapAgingDetail/query", faceParam, SnapshotDelayMonitorResult.class);
if (!CollectionUtils.isEmpty(faceList)) {
//濡傛灉浠婂ぉ瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎
Query query = new Query(Criteria
.where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))
.and("dataType").is(ApiConstants.HK_DataType_FACE));
- DeleteResult result = mongoTemplate.remove(query, SnapshotDelayMonitorParam.class);
+ DeleteResult result = mongoTemplate.remove(query, SnapshotDelayMonitorResult.class);
//瀛樻斁鍦╩ongo涓�
- carList.forEach(item -> item.setDataType(ApiConstants.HK_DataType_FACE));
+ faceList.forEach(item -> {
+ item.setDataType(ApiConstants.HK_DataType_FACE);
+ if (Objects.nonNull(item.getExternalIndexCode())) {
+ item.setNo(item.getExternalIndexCode());
+ }
+ });
+ pointService.setDeviceTagByGB(faceList, CheckConstants.Rule_Category_Face);
mongoTemplate.insertAll(faceList);
}
- //TODO:宸ュ崟
log.info("缁撴潫鎶撴媿鏁版嵁鏃跺欢鐩戞祴缁撴灉鏁版嵁鍚屾");
}
- //鍥剧墖璁块棶鐩戞祴缁撴灉
+ //鍥剧墖璁块棶鐩戞祴缁撴灉 杞﹁締锛堣溅杈嗗崱鍙d俊鎭噰闆嗗噯纭巼銆佽溅杈嗗崱鍙h澶噓rl鍙敤鎬э級
public void picAccessTask() {
log.info("寮�濮嬫墽琛屽浘鐗囪闂洃娴嬬粨鏋滄暟鎹悓姝�");
//杞﹁締鍗″彛淇℃伅閲囬泦鍑嗙‘鐜囥�佽溅杈嗗崱鍙h澶噓rl鍙敤鎬�
@@ -268,20 +418,26 @@
param.setPageSize(ApiConstants.HKPageSize);
param.setDate(DateUtils.getDate());
param.setDataType(ApiConstants.HK_DataType_CAR);
- List<PicAccessResult> faceList = HkApiUtil.sendAPI("/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(faceList)) {
+ if (!CollectionUtils.isEmpty(carList)) {
//濡傛灉浠婂ぉ瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎
Query query = new Query(Criteria
.where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())));
DeleteResult result = mongoTemplate.remove(query, PicAccessResult.class);
+ carList.stream().forEach(item -> {
+ if (Objects.nonNull(item.getExternalIndexCode())) {
+ item.setNo(item.getExternalIndexCode());
+ }
+ });
+ pointService.setDeviceTagByGB(carList, CheckConstants.Rule_Category_Car);
//瀛樻斁鍦╩ongo涓�
- mongoTemplate.insertAll(faceList);
+ mongoTemplate.insertAll(carList);
}
- //TODO:宸ュ崟澶勭悊
log.info("缁撴潫鍥剧墖璁块棶鐩戞祴缁撴灉鏁版嵁鍚屾");
}
- //杞﹁締璁惧鎶芥鎸囨爣鐩戞祴缁撴灉
+
+ //杞﹁締璁惧鎶芥鎸囨爣鐩戞祴缁撴灉 杞﹁締锛堣溅杈嗗崱鍙d俊鎭噰闆嗗噯纭巼銆佽溅杈嗗崱鍙h澶噓rl鍙敤鎬э級
public void vehicleDeviceSamplingTask() {
log.info("寮�濮嬫墽琛岃溅杈嗚澶囨娊妫�鎸囨爣鐩戞祴缁撴灉鏁版嵁鍚屾");
//杞﹁締鍗″彛淇℃伅閲囬泦鍑嗙‘鐜囥�佽溅杈嗗崱鍙h澶噓rl鍙敤鎬�
@@ -290,74 +446,482 @@
param.setPageSize(ApiConstants.HKPageSize);
param.setDate(DateUtils.getDate());
param.setDataType(ApiConstants.HK_DataType_CAR);
- List<VehicleDeviceSamplingResult> faceList = HkApiUtil.sendAPI("/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(faceList)) {
+ if (!CollectionUtils.isEmpty(carList)) {
//濡傛灉浠婂ぉ瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎
Query query = new Query(Criteria
.where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())));
DeleteResult result = mongoTemplate.remove(query, VehicleDeviceSamplingResult.class);
+ carList.stream().forEach(item -> {
+ if (Objects.nonNull(item.getExternalIndexCode())) {
+ item.setNo(item.getExternalIndexCode());
+ }
+ });
+ pointService.setDeviceTagByGB(carList, CheckConstants.Rule_Category_Car);
//瀛樻斁鍦╩ongo涓�
- mongoTemplate.insertAll(faceList);
+ mongoTemplate.insertAll(carList);
}
- //TODO:宸ュ崟澶勭悊
log.info("缁撴潫杞﹁締璁惧鎶芥鎸囨爣鐩戞祴缁撴灉鏁版嵁鍚屾");
}
- //浜鸿劯璁惧鎶芥鎸囨爣鐩戞祴缁撴灉
+ //浜鸿劯璁惧鎶芥鎸囨爣鐩戞祴缁撴灉 浜鸿劯锛堟姄鎷嶆暟鎹ぇ鍥惧彲鐢ㄦ��,淇℃伅閲囬泦姝g‘鐜囷級
public void faceDeviceSamplingTask() {
log.info("寮�濮嬫墽琛屼汉鑴歌澶囨娊妫�鎸囨爣鐩戞祴缁撴灉鏁版嵁鍚屾");
FaceDeviceSamplingParam param = new FaceDeviceSamplingParam();
param.setPageNo(ApiConstants.PageNo);
param.setPageSize(ApiConstants.HKPageSize);
param.setDate(DateUtils.getDate());
- List<FaceDeviceSamplingResult> faceList = HkApiUtil.sendAPI("/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)) {
//濡傛灉浠婂ぉ瀛樺湪涔嬪墠鐨勬暟鎹厛鍒犻櫎
Query query = new Query(Criteria
.where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())));
DeleteResult result = mongoTemplate.remove(query, FaceDeviceSamplingResult.class);
+ faceList.stream().forEach(item -> {
+ if (Objects.nonNull(item.getExternalIndexCode())) {
+ item.setNo(item.getExternalIndexCode());
+ }
+ });
+ pointService.setDeviceTagByGB(faceList, CheckConstants.Rule_Category_Face);
//瀛樻斁鍦╩ongo涓�
mongoTemplate.insertAll(faceList);
}
- //TODO:宸ュ崟澶勭悊
log.info("缁撴潫浜鸿劯璁惧鎶芥鎸囨爣鐩戞祴缁撴灉鏁版嵁鍚屾");
}
- //娴嬭瘯
- public void test() {
- log.info("娴嬭瘯娴峰悍鎺ュ彛");
- HkApiUtil.sendAPI("/api/dqd/service/rs/v2/data/faceDetect/query", new FaceDeviceSamplingParam(), Object.class);
- 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("缁撴潫娴峰悍鑰冩牳鎴愮哗鏁版嵁");
+// }
+
+ public void HkScoreTask(){
+ log.info("寮�濮嬫墽琛屾捣搴疯�冩牳鎴愮哗鏁版嵁");
+ //鍏堟墽琛岃幏寰楁爣绛� 鍥犱负鍏ㄩ噺榛樿浼犲弬涓簄ull锛屼絾鏄渷鍘呮暟鎹渶瑕佽幏寰楁爣绛�
+ JSONObject labelJson = hkClient.getGetLabel();
+ Integer faceLabelId = null;
+ Integer carLabelId = null;
+ Integer allLabelId = null;
+ if (labelJson != null) {
+ String code = labelJson.getString("code");
+ if (ApiConstants.HKSuccessCode.equals(code)){
+ //鑾峰緱label鑰冩牳鏍囩瀵硅薄
+ log.error("labelJson鐨刣ata:{}",labelJson.get("data"));
+ List<HKResultLabel> hkResultLabels = labelJson.getList("data",HKResultLabel.class);
+ for (HKResultLabel label : hkResultLabels) {
+ if ("鐪佸巺浜鸿劯".equals(label.getLabelName())){
+ faceLabelId = label.getId();
+ }else if ("鐪佸巺杞﹁締".equals(label.getLabelName())){
+ carLabelId = label.getId();
+ }else if ("鍏ㄩ噺".equals(label.getLabelName())){
+ allLabelId = label.getId();
+ }
+ }
+ log.error("鎵撳嵃hkResultLabels锛歿}",hkResultLabels);
+ }
+ }
+ if (faceLabelId == null || carLabelId == null){
+ log.error("娴峰悍鑾峰彇鐪佸巺鑰冩牳鏍囩涓簄ull");
+ }
+
+ //鍑嗗鏂板鎴栦慨鏀圭殑鏁版嵁
+ 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.setLabelId();
+
+ //------------榛樿鍙傛暟涓簄ull璇锋眰鍏ㄩ噺鏁版嵁
+ if (allLabelId == null){
+ allLabelId = -1;
+ }
+ param.setLabelId(allLabelId);
+ JSONObject scoreJson = hkClient.getScoreNew(param);
+ log.error("鍏ㄩ噺鏁版嵁");
+ if (scoreJson != null) {
+ List<HkResultInfo> allInfo = new ArrayList<>();
+ String code = scoreJson.getString("code");
+ if (ApiConstants.HKSuccessCode.equals(code)){
+ JSONObject data = scoreJson.getJSONObject("data");
+
+ Map<Integer,JSONObject> map = new HashMap<>();
+ //鑾峰緱data 涓� batchId 鐨勬壒娆d瀵硅薄 鏀惧叆map涓�
+ for (String batchIdKey :data.keySet() ) {
+ JSONObject batch = data.getJSONObject(batchIdKey);
+ //浠ユ壒娆d涓簁ey 鏀惧叆 JSONObject瀵硅薄
+ map.put(Integer.valueOf(batchIdKey),batch);
+ //鎵规id 涓� 鍚勫尯淇℃伅闆嗗悎
+ }
+ //鑾峰緱鏈�澶х殑閿��
+ Optional<Integer> maxKey = map.keySet().stream()
+ .max(Integer::compareTo);
+ if (maxKey.isPresent()) {
+ //鑾峰彇鏈�澶х殑key 鎺ュ彛杩斿洖鍐呭涓渶鏂扮殑鎵规
+ Integer id = maxKey.get();
+ //杩欎竴灞備负鑾峰緱 data -> 涓� 鎵规鏁扮粍涓� -> 鍖哄煙code鏁扮粍鐨刱ey
+ for (String areaCodeKey : map.get(id).keySet()) {
+ //瀛樻斁鏈�鏂版壒娆$殑鍐呭鍒癮llInfo闆嗗悎涓�
+ log.error("鎵撳嵃鍖轰俊鎭�:{}",map.get(id).get(areaCodeKey));
+ allInfo.addAll(map.get(id).getList(areaCodeKey,HkResultInfo.class));
+ }
+ }
+ //瀵筧llInfo杩涜鍒嗙粍 鍒嗙粍鎸夊尯鍩焛d
+ Map<String, List<HkResultInfo>> groupedByAreaName = allInfo.stream()
+ .collect(Collectors.groupingBy(HkResultInfo::getAreaCode));
+ for (Map.Entry<String, List<HkResultInfo>> entry : groupedByAreaName.entrySet()) {
+ log.error("鏈�鏂版壒娆″唴size:{}",groupedByAreaName.get(entry.getKey()).size());
+ log.error("鏈�鏂版壒娆″唴鏁版嵁:{}",groupedByAreaName.get(entry.getKey()));
+ CheckIndexCar car = new CheckIndexCar();
+ CheckIndexFace face = new CheckIndexFace();
+ score3Index(groupedByAreaName.get(entry.getKey()), car, face,entry.getKey());
+ 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);
+ }
+ }else {
+ log.error("璋冪敤娴峰悍鍏ㄩ噺鏁版嵁api澶辫触");
+ }
+
+ }
+ //------------鑾峰彇鐪佸巺鏁版嵁
+ List<HkResultInfo> provincialList = new ArrayList<>();
+ //鑾峰彇鐪佸巺浜鸿劯鏁版嵁
+ if (faceLabelId != null){
+ ScoreParam faceParam = new ScoreParam();
+ log.error("faceLabelId:{}",faceLabelId);
+ faceParam.setLabelId(faceLabelId);
+ JSONObject faceJson = hkClient.getScoreNew(faceParam);
+ log.error("鐪佸巺浜鸿劯鏁版嵁");
+ if (faceJson != null) {
+ String code = faceJson.getString("code");
+ if (ApiConstants.HKSuccessCode.equals(code)){
+ JSONObject data = faceJson.getJSONObject("data");
+
+ Map<Integer,JSONObject> map = new HashMap<>();
+ //鑾峰緱data 涓� batchId 鐨勬壒娆d瀵硅薄 鏀惧叆map涓�
+ for (String batchIdKey :data.keySet() ) {
+ JSONObject batch = data.getJSONObject(batchIdKey);
+ //浠ユ壒娆d涓簁ey 鏀惧叆 JSONObject瀵硅薄
+ map.put(Integer.valueOf(batchIdKey),batch);
+ //鎵规id 涓� 鍚勫尯淇℃伅闆嗗悎
+ log.error("鎵撳嵃鍑虹渷鍘呬汉鑴竏ata鍐呭涓壒娆d锛歿}锛屼互鍙婂搴旂殑缁撴灉info:{}",batchIdKey,batch);
+ }
+ //鑾峰緱鏈�澶х殑閿��
+ Optional<Integer> maxKey = map.keySet().stream()
+ .max(Integer::compareTo);
+ if (maxKey.isPresent()) {
+ //鑾峰彇鏈�澶х殑key 鎺ュ彛杩斿洖鍐呭涓渶鏂扮殑鎵规
+ Integer id = maxKey.get();
+ //杩欎竴灞備负鑾峰緱 data -> 涓� 鎵规鏁扮粍涓� -> 鍖哄煙code鏁扮粍鐨刱ey
+ for (String areaCodeKey : map.get(id).keySet()) {
+ //瀛樻斁鏈�鏂版壒娆$殑鍐呭鍒癮llInfo闆嗗悎涓�
+ provincialList.addAll(map.get(id).getList(areaCodeKey,HkResultInfo.class));
+ }
+ }
+
+ }else {
+ log.error("璋冪敤娴峰悍鐪佸巺浜鸿劯鏁版嵁api澶辫触");
+ }
+
+ }
+ }else {
+ log.error("faceLabelId:涓虹┖涓嶆墽琛岃幏寰楃渷鍘呮暟鎹�");
+ }
+ //鑾峰彇鐪佸巺杞﹁締鏁版嵁v.
+ if (carLabelId != null){
+ ScoreParam carParam = new ScoreParam();
+ log.error("carLabelId:{}",carLabelId);
+ carParam.setLabelId(carLabelId);
+ JSONObject carJson = hkClient.getScoreNew(carParam);
+ log.error("鐪佸巺杞﹁締鏁版嵁");
+ if (carJson != null) {
+ String code = carJson.getString("code");
+ if (ApiConstants.HKSuccessCode.equals(code)){
+ JSONObject data = carJson.getJSONObject("data");
+
+ Map<Integer,JSONObject> map = new HashMap<>();
+ //鑾峰緱data 涓� batchId 鐨勬壒娆d瀵硅薄 鏀惧叆map涓�
+ for (String batchIdKey :data.keySet() ) {
+ JSONObject batch = data.getJSONObject(batchIdKey);
+ //浠ユ壒娆d涓簁ey 鏀惧叆 JSONObject瀵硅薄
+ map.put(Integer.valueOf(batchIdKey),batch);
+ //鎵规id 涓� 鍚勫尯淇℃伅闆嗗悎
+ log.error("鎵撳嵃鍑虹渷鍘呮垚杈哾ata鍐呭涓壒娆d锛歿}锛屼互鍙婂搴旂殑缁撴灉info:{}",batchIdKey,batch);
+ }
+ //鑾峰緱鏈�澶х殑閿��
+ Optional<Integer> maxKey = map.keySet().stream()
+ .max(Integer::compareTo);
+ if (maxKey.isPresent()) {
+ //鑾峰彇鏈�澶х殑key 鎺ュ彛杩斿洖鍐呭涓渶鏂扮殑鎵规
+ Integer id = maxKey.get();
+ //杩欎竴灞備负鑾峰緱 data -> 涓� 鎵规鏁扮粍涓� -> 鍖哄煙code鏁扮粍鐨刱ey
+ for (String areaCodeKey : map.get(id).keySet()) {
+ //瀛樻斁鏈�鏂版壒娆$殑鍐呭鍒癮llInfo闆嗗悎涓�
+ provincialList.addAll(map.get(id).getList(areaCodeKey,HkResultInfo.class));
+ }
+ }
+ }else {
+ log.error("璋冪敤娴峰悍鐪佸巺杞﹁締鏁版嵁api澶辫触");
+ }
+ }
+ }else {
+ log.error("carLabelId:涓虹┖涓嶆墽琛岃幏寰楃渷鍘呮暟鎹�");
+ }
+ //鑾峰彇瀹屾暟鎹紑濮嬪垎缁�
+ Map<String,List<HkResultInfo>> provincialGroupedByAreaName = provincialList.stream()
+ .collect(Collectors.groupingBy(HkResultInfo::getAreaCode));
+ for (Map.Entry<String, List<HkResultInfo>> entry : provincialGroupedByAreaName.entrySet()) {
+ CheckIndexCar car = new CheckIndexCar();
+ CheckIndexFace face = new CheckIndexFace();
+ score3Index(provincialGroupedByAreaName.get(entry.getKey()), car, face,entry.getKey());
+ 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);
+ }
+ log.error("鎵撳嵃鎻掑叆鏁版嵁cars:{}",cars);
+ log.error("鎵撳嵃鎻掑叆鏁版嵁faces:{}",faces);
+ //瀛樻斁鎴愮哗鍒癿ysql锛屽鏋滃瓨鍦ㄥ垯鏇挎崲涓嶅瓨鍦ㄥ氨鏂板銆�
+ if (!CollectionUtils.isEmpty(cars)) carService.saveOrUpdateBatch(cars);
+ if (!CollectionUtils.isEmpty(faces)) faceService.saveOrUpdateBatch(faces);
+ log.info("缁撴潫娴峰悍鑰冩牳鎴愮哗鏁版嵁");
}
- //娴嬭瘯
- public void test1() {
- log.info("娴嬭瘯娴峰悍鎺ュ彛");
- HkApiUtil.sendAPI("/api/dqd/service/rs/v1/device/coordinateExpInfo/query", new FaceDeviceSamplingParam(), Object.class);
- 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()));
}
- //娴嬭瘯
- public void test2() {
- log.info("娴嬭瘯娴峰悍鎺ュ彛");
- HkApiUtil.sendAPI("/api/dqd/service/rs/v1/device/gbCodeExpInfo/query", new FaceDeviceSamplingParam(), Object.class);
- log.info("缁撴潫->{}锛岃皟鐢ㄦ垚鍔�");
- }
+ private void score3Index(List<HkResultInfo> score, CheckIndexCar car, CheckIndexFace face,String areaCode){
+ car.setCreateTime(new Date());
+ car.setPublish(PublishType.PUBLISHED.getCode());
+ face.setCreateTime(new Date());
+ face.setPublish(PublishType.PUBLISHED.getCode());
+ car.setDeptId(Long.parseLong(AreaDeptEnum.fromCode(areaCode).getDeptId() + ""));
+ face.setDeptId(Long.parseLong(AreaDeptEnum.fromCode(areaCode).getDeptId() + ""));
- //娴嬭瘯
- public void test3() {
- log.info("娴嬭瘯娴峰悍鎺ュ彛");
- HkApiUtil.sendAPI("/api/dqd/service/rs/v2/data/passDetect/query", new FaceDeviceSamplingParam(), Object.class);
- log.info("缁撴潫->{}锛岃皟鐢ㄦ垚鍔�");
+ for(HkResultInfo hkResultInfo : score){
+ if (HKLabelName.carDelay.getCode().equals(hkResultInfo.getIndexCode())){
+ //杞﹁締鍗″彛璁惧鎶撴媿鏁版嵁涓婁紶鍙婃椂鎬�
+ car.setVehicleUploadTimeliness(new BigDecimal(hkResultInfo.getScore() == null ? "1" : String.valueOf(hkResultInfo.getScore())));
+ }else if (HKLabelName.carOnlineRate2023.getCode().equals(hkResultInfo.getIndexCode())){
+ //杞﹁締鐐逛綅鍦ㄧ嚎鐜�
+ car.setSiteOnline(new BigDecimal(hkResultInfo.getScore() == null ? "1" : String.valueOf(hkResultInfo.getScore())));
+ }else if (HKLabelName.carButtStability2023.getCode().equals(hkResultInfo.getIndexCode())){
+ //杞﹁締瑙嗗浘搴撳鎺ョǔ瀹氭��
+ car.setViewConnectStability(new BigDecimal(hkResultInfo.getScore() == null ? "1" : String.valueOf(hkResultInfo.getScore())));
+ }else if (HKLabelName.carQualifiedRate.getCode().equals(hkResultInfo.getIndexCode())){
+ //杞﹁締鍗″彛璁惧鎶撴媿鏁版嵁瀹屾暣鎬�
+ car.setVehicleCaptureIntegrity(new BigDecimal(hkResultInfo.getScore() == null ? "1" : String.valueOf(hkResultInfo.getScore())));
+ }else if (HKLabelName.carCorrectRate.getCode().equals(hkResultInfo.getIndexCode())){
+ //杞﹁締鍗″彛璁惧鎶撴媿鏁版嵁鍑嗙‘鎬�
+ car.setVehicleCaptureAccuracy(new BigDecimal(hkResultInfo.getScore() == null ? "1" : String.valueOf(hkResultInfo.getScore())));
+ }else if (HKLabelName.carClockAccuracy.getCode().equals(hkResultInfo.getIndexCode())){
+ //杞﹁締鍗″彛璁惧鏃堕挓鍑嗙‘鎬�
+ car.setVehicleTimingAccuracy(new BigDecimal(hkResultInfo.getScore() == null ? "1" : String.valueOf(hkResultInfo.getScore())));
+ }else if (HKLabelName.carBigPictureAccess.getCode().equals(hkResultInfo.getIndexCode())){
+ //杞﹁締鍗″彛璁惧鎶撴媿鏁版嵁澶у浘鍙敤鎬�
+ car.setVehiclePictureAvailability(new BigDecimal(hkResultInfo.getScore() == null ? "1" : String.valueOf(hkResultInfo.getScore())));
+ }else if (HKLabelName.carUrlOkRate.getCode().equals(hkResultInfo.getIndexCode())){
+ //杞﹁締鍗″彛璁惧url鍙敤鎬�
+ car.setVehicleUrlAvailability(new BigDecimal(hkResultInfo.getScore() == null ? "1" : String.valueOf(hkResultInfo.getScore())));
+ }else if(HKLabelName.faceButtStability2023.getCode().equals(hkResultInfo.getIndexCode())){
+ //浜鸿劯瑙嗗浘搴撳鎺ョǔ瀹氭��
+ face.setViewConnectStability(new BigDecimal(hkResultInfo.getScore() == null ? "1" : String.valueOf(hkResultInfo.getScore())));
+ }else if (HKLabelName.faceOnlineRate.getCode().equals(hkResultInfo.getIndexCode())){
+ //浜鸿劯鐐逛綅鍦ㄧ嚎鐜�
+ face.setSiteOnline(new BigDecimal(hkResultInfo.getScore() == null ? "1" : String.valueOf(hkResultInfo.getScore())));
+ }else if (HKLabelName.faceCapturedPicturesEligibility.getCode().equals(hkResultInfo.getIndexCode())){
+ //浜鸿劯璁惧鎶撴媿鍥剧墖鍚堟牸鎬�
+ face.setFacePictureQualification(new BigDecimal(hkResultInfo.getScore() == null ? "1" : String.valueOf(hkResultInfo.getScore())));
+ }else if (HKLabelName.faceClockAccuracy.getCode().equals(hkResultInfo.getIndexCode())){
+ //浜鸿劯璁惧鎶撴媿鍥剧墖鏃堕挓鍑嗙‘鎬�
+ face.setFaceTimingAccuracy(new BigDecimal(hkResultInfo.getScore() == null ? "1" : String.valueOf(hkResultInfo.getScore())));
+ }else if (HKLabelName.faceDelay.getCode().equals(hkResultInfo.getIndexCode())){
+ //璁惧鎶撴媿浜鸿劯鏁版嵁涓婁紶鍙婃椂鎬�
+ face.setFaceUploadTimeliness(new BigDecimal(hkResultInfo.getScore() == null ? "1" : String.valueOf(hkResultInfo.getScore())));
+ }else if (HKLabelName.faceBigPictureAccess.getCode().equals(hkResultInfo.getIndexCode())){
+ //浜鸿劯鍗″彛璁惧鎶撴媿鏁版嵁澶у浘鍙敤鎬�
+ face.setFacePictureAvailability(new BigDecimal(hkResultInfo.getScore() == null ? "1" : String.valueOf(hkResultInfo.getScore())));
+ }
+ }
+ //TODO:娌℃壘鍒拌�冩牳椤� 浜鸿劯鍗″彛淇℃伅閲囬泦鍑嗙‘鐜�
+ face.setFaceInformationCollectionAccuracy(new BigDecimal("1"));
+ //TODO:娌℃壘鍒拌�冩牳椤� 璁惧鐩綍涓�鑷寸巼
+ face.setDeviceDirectoryConsistent(new BigDecimal("1"));
+
+
+ //TODO:娌℃壘鍒拌�冩牳椤� 杞﹁締鍗″彛淇℃伅閲囬泦鍑嗙‘鐜�
+ car.setVehicleInformationCollectionAccuracy(new BigDecimal("1"));
+ //TODO:娌℃壘鍒拌�冩牳椤� 鑱旂綉鍗″彛璁惧鐩綍涓�鑷寸巼
+ car.setDeviceDirectoryConsistent(new BigDecimal("1"));
}
//瑙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