| | |
| | | package com.ycl.task; |
| | | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.ycl.platform.domain.param.HK.FaceDeviceInspectionParam; |
| | | import com.ycl.platform.domain.param.HK.SnapshotDataMonitorParam; |
| | | import com.ycl.platform.domain.param.HK.VehicleDeviceInspectionParam; |
| | | import com.ycl.platform.domain.result.HK.BaseResult; |
| | | import com.ycl.platform.domain.result.HK.FaceDeviceInspectionResult; |
| | | import com.ycl.platform.domain.result.HK.SnapshotDataMonitorResult; |
| | | import com.ycl.platform.domain.result.HK.VehicleDeviceInspectionResult; |
| | | import com.mongodb.client.result.DeleteResult; |
| | | import com.ycl.platform.domain.param.HK.*; |
| | | import com.ycl.platform.domain.result.BaseResult; |
| | | 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.utils.DateUtils; |
| | | import constant.ApiConstants; |
| | | import com.ycl.feign.HKClient; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | 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.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | |
| | | //海康对接数据任务 |
| | | @Slf4j |
| | | @Component("HKTask") |
| | | public class HKTask { |
| | |
| | | private ICheckIndexVideoService checkIndexVideoService; |
| | | |
| | | //车辆设备全检指标监测结果 |
| | | public void VehicleDeviceInspectionTask() { |
| | | public void vehicleDeviceInspectionTask() { |
| | | log.info("开始执行车辆设备全检指标监测结果数据同步"); |
| | | VehicleDeviceInspectionParam param = new VehicleDeviceInspectionParam(); |
| | | param.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(getToday()); |
| | | param.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(DateUtils.getDate()); |
| | | JSONObject jsonObject = hkClient.VehicleDeviceInspection(param); |
| | | List<VehicleDeviceInspectionResult> list = getDataList(jsonObject, 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); |
| | | //存放在mongo中 |
| | | mongoTemplate.insert(list); |
| | | //同步的数据进行工单阈值处理 |
| | |
| | | } |
| | | |
| | | //人脸设备全检指标监测结果 |
| | | public void FaceDeviceInspectionTask() { |
| | | public void faceDeviceInspectionTask() { |
| | | log.info("开始执行人脸设备全检指标监测结果数据同步"); |
| | | FaceDeviceInspectionParam param = new FaceDeviceInspectionParam(); |
| | | param.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(getToday()); |
| | | param.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(DateUtils.getDate()); |
| | | JSONObject jsonObject = hkClient.FaceDeviceInspection(param); |
| | | List<FaceDeviceInspectionResult> list = getDataList(jsonObject, 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); |
| | | //存放在mongo中 |
| | | mongoTemplate.insert(list); |
| | | //同步的数据进行工单阈值处理 |
| | | //TODO:可能有重复工单 |
| | | ywThresholdService.faceCheck(list); |
| | | } |
| | | log.info("结束人脸设备全检指标监测结果数据同步"); |
| | |
| | | |
| | | |
| | | //抓拍数据量监测结果 |
| | | public void SnapshotDataMonitorTask() { |
| | | public void snapshotDataMonitorTask() { |
| | | log.info("开始执行抓拍数据量检测结果数据同步"); |
| | | /** 车辆数据 */ |
| | | SnapshotDataMonitorParam carParam = new SnapshotDataMonitorParam(); |
| | | carParam.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(getToday()).setDataType(ApiConstants.HK_DATATYPE_CAR); |
| | | carParam.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(DateUtils.getDate()).setDataType(ApiConstants.HK_DATATYPE_CAR); |
| | | JSONObject carJsonObject = hkClient.SnapshotDataMonitor(carParam); |
| | | List<SnapshotDataMonitorResult> carList = getDataList(carJsonObject, 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); |
| | | //存放在mongo中 |
| | | carList.forEach(item -> item.setDataType(ApiConstants.HK_DATATYPE_CAR)); |
| | | mongoTemplate.insert(carList); |
| | | //TODO:车辆点位在线率 |
| | | checkIndexCarService.siteOnline(carList); |
| | | } |
| | | |
| | | /** 人脸数据 */ |
| | | SnapshotDataMonitorParam faceParam = new SnapshotDataMonitorParam(); |
| | | faceParam.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(getToday()).setDataType(ApiConstants.HK_DATATYPE_FACE); |
| | | faceParam.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(DateUtils.getDate()).setDataType(ApiConstants.HK_DATATYPE_FACE); |
| | | JSONObject faceJsonObject = hkClient.SnapshotDataMonitor(carParam); |
| | | List list = getDataList(faceJsonObject, SnapshotDataMonitorResult.class, "人脸抓拍数据量检测结果数据为空"); |
| | | if (!CollectionUtils.isEmpty(list)) { |
| | | List<SnapshotDataMonitorResult> faceList = getDataList(faceJsonObject, SnapshotDataMonitorResult.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, SnapshotDataMonitorResult.class); |
| | | //存放在mongo中 |
| | | mongoTemplate.insert(list); |
| | | //TODO:人脸点位在线率 |
| | | checkIndexFaceService.siteOnline(list); |
| | | carList.forEach(item -> item.setDataType(ApiConstants.HK_DATATYPE_FACE)); |
| | | mongoTemplate.insert(faceList); |
| | | } |
| | | |
| | | //TODO:工单 |
| | | log.info("结束抓拍数据量检测结果数据同步"); |
| | | } |
| | | |
| | | |
| | | //一机一档 |
| | | public void task2() { |
| | | //联网卡口设备目录一致率 |
| | | //采集设备属性监测结果(人脸) |
| | | public void monitorDetailTask() { |
| | | log.info("开始执行采集设备属性监测结果数据同步"); |
| | | //人脸卡口信息采集准确率 |
| | | MonitoringDetailParam param = new MonitoringDetailParam(); |
| | | param.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(DateUtils.getDate()); |
| | | JSONObject jsonObject = hkClient.monitorDetail(param); |
| | | List<MonitoringDetailResult> faceList = getDataList(jsonObject, 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); |
| | | //存放在mongo中 |
| | | mongoTemplate.insert(faceList); |
| | | } |
| | | //TODO:工单处理 |
| | | log.info("结束采集设备属性监测结果数据同步"); |
| | | } |
| | | |
| | | //卡口属性监测结果 |
| | | public void task3() { |
| | | public void crossDetailTask() { |
| | | log.info("开始执行卡口属性监测结果数据同步"); |
| | | //车辆卡口信息采集准确率 |
| | | CrossDetailParam param = new CrossDetailParam(); |
| | | param.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(DateUtils.getDate()); |
| | | JSONObject jsonObject = hkClient.crossDetail(param); |
| | | List<CrossDetailResult> faceList = getDataList(jsonObject, CrossDetailResult.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, CrossDetailResult.class); |
| | | //存放在mongo中 |
| | | mongoTemplate.insert(faceList); |
| | | } |
| | | //TODO:工单处理 |
| | | log.info("结束卡口属性监测结果数据同步"); |
| | | } |
| | | |
| | | //数据完整性监测结果 |
| | | public void task4() { |
| | | public void dataIntegrityMonitoringTask() { |
| | | log.info("开始执行数据完整性监测结果数据同步"); |
| | | //车辆卡口设备抓拍数据完整性 |
| | | DataIntegrityMonitoringParam param = new DataIntegrityMonitoringParam(); |
| | | param.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(DateUtils.getDate()).setDataType(ApiConstants.HK_DATATYPE_CAR); |
| | | JSONObject jsonObject = hkClient.DataIntegrityMonitoring(param); |
| | | List<DataIntegrityMonitoringResult> faceList = getDataList(jsonObject, DataIntegrityMonitoringResult.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, DataIntegrityMonitoringResult.class); |
| | | //存放在mongo中 |
| | | mongoTemplate.insert(faceList); |
| | | } |
| | | //TODO:工单处理 |
| | | log.info("结束数据完整性监测结果数据同步"); |
| | | } |
| | | |
| | | //属性识别准确监测结果 |
| | | public void task5() { |
| | | //车辆卡口设备抓拍数据完整性 |
| | | } |
| | | public void attrRecognitionMonitorTask() { |
| | | log.info("开始执行属性识别准确监测结果数据同步"); |
| | | //车辆卡口设备抓拍数据准确性 |
| | | AttrRecognitionParam param = new AttrRecognitionParam(); |
| | | param.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(DateUtils.getDate()).setDataType(ApiConstants.HK_DATATYPE_CAR); |
| | | JSONObject jsonObject = hkClient.AttrRecognitionMonitor(param); |
| | | List<AttrRecognitionMonitorResult> faceList = getDataList(jsonObject, AttrRecognitionMonitorResult.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, AttrRecognitionMonitorResult.class); |
| | | //存放在mongo中 |
| | | mongoTemplate.insert(faceList); |
| | | } |
| | | //TODO:工单处理 |
| | | log.info("结束属性识别准确监测结果数据同步"); |
| | | |
| | | //车辆设备全检指标监测结果 |
| | | public void task6() { |
| | | //车辆卡口设备时钟准确性 |
| | | } |
| | | |
| | | //抓拍数据时延监测结果 |
| | | public void task7() { |
| | | public void snapshopDelayMonitorTask() { |
| | | log.info("开始执行抓拍数据时延监测结果数据同步"); |
| | | //车辆卡口设备抓拍数据上传及时性 |
| | | /** 车辆数据 */ |
| | | SnapshotDelayMonitorParam carParam = new SnapshotDelayMonitorParam(); |
| | | carParam.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(DateUtils.getDate()).setDataType(ApiConstants.HK_DATATYPE_CAR); |
| | | JSONObject carJsonObject = hkClient.SnapshotDelayMonitor(carParam); |
| | | List<SnapshotDelayMonitorResult> carList = getDataList(carJsonObject, 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); |
| | | //存放在mongo中 |
| | | carList.forEach(item -> item.setDataType(ApiConstants.HK_DATATYPE_CAR)); |
| | | mongoTemplate.insert(carList); |
| | | } |
| | | |
| | | /** 人脸数据 */ |
| | | SnapshotDelayMonitorParam faceParam = new SnapshotDelayMonitorParam(); |
| | | faceParam.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(DateUtils.getDate()).setDataType(ApiConstants.HK_DATATYPE_FACE); |
| | | JSONObject faceJsonObject = hkClient.SnapshotDelayMonitor(faceParam); |
| | | List<SnapshotDelayMonitorParam> faceList = getDataList(faceJsonObject, SnapshotDelayMonitorParam.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); |
| | | //存放在mongo中 |
| | | carList.forEach(item -> item.setDataType(ApiConstants.HK_DATATYPE_FACE)); |
| | | mongoTemplate.insert(faceList); |
| | | } |
| | | //TODO:工单 |
| | | log.info("结束抓拍数据时延监测结果数据同步"); |
| | | } |
| | | |
| | | //图片访问监测结果 |
| | | public void task8() { |
| | | //车辆卡口信息采集准确率 |
| | | |
| | | //车辆卡口设备url可用性 |
| | | public void PicAccessTask() { |
| | | log.info("开始执行图片访问监测结果数据同步"); |
| | | //车辆卡口信息采集准确率、车辆卡口设备url可用性 |
| | | PicAccessParam param = new PicAccessParam(); |
| | | param.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(DateUtils.getDate()).setDataType(ApiConstants.HK_DATATYPE_CAR); |
| | | JSONObject jsonObject = hkClient.PicAccessMonitor(param); |
| | | List<PicAccessResult> faceList = getDataList(jsonObject, PicAccessResult.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, PicAccessResult.class); |
| | | //存放在mongo中 |
| | | mongoTemplate.insert(faceList); |
| | | } |
| | | //TODO:工单处理 |
| | | log.info("结束图片访问监测结果数据同步"); |
| | | } |
| | | |
| | | //获取当前日期 |
| | | private String getToday() { |
| | | Date date = new Date(); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String today = sdf.format(date); |
| | | return today; |
| | | //人脸设备抽检指标监测结果 |
| | | public void Face() { |
| | | log.info("开始执行人脸设备抽检指标监测结果数据同步"); |
| | | //车辆卡口信息采集准确率、车辆卡口设备url可用性 |
| | | FaceDeviceSamplingParam param = new FaceDeviceSamplingParam(); |
| | | param.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(DateUtils.getDate()); |
| | | JSONObject jsonObject = hkClient.FaceDeviceSampling(param); |
| | | List<FaceDeviceSamplingResult> faceList = getDataList(jsonObject, 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); |
| | | //存放在mongo中 |
| | | mongoTemplate.insert(faceList); |
| | | } |
| | | //TODO:工单处理 |
| | | log.info("结束人脸设备抽检指标监测结果数据同步"); |
| | | } |
| | | |
| | | //车辆设备抽检指标监测结果 |
| | | public void FaceDeviceSamplingTask() { |
| | | log.info("开始执行车辆设备抽检指标监测结果数据同步"); |
| | | //车辆卡口信息采集准确率、车辆卡口设备url可用性 |
| | | FaceDeviceSamplingParam param = new FaceDeviceSamplingParam(); |
| | | param.setPageNO(ApiConstants.pageNo).setPageSize(ApiConstants.pageSize).setDate(DateUtils.getDate()); |
| | | JSONObject jsonObject = hkClient.FaceDeviceSampling(param); |
| | | List<FaceDeviceSamplingResult> faceList = getDataList(jsonObject, 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); |
| | | //存放在mongo中 |
| | | mongoTemplate.insert(faceList); |
| | | } |
| | | //TODO:工单处理 |
| | | log.info("结束人脸设备抽检指标监测结果数据同步"); |
| | | } |
| | | |
| | | //解析数据 |
| | | private <T> List<T> getDataList(JSONObject faceJsonObject, Class<T> resultClass, String message) { |
| | | if (faceJsonObject != null && ApiConstants.successCode.equals(faceJsonObject.getString("code"))) { |
| | | if (faceJsonObject != null && ApiConstants.HKSuccessCode.equals(faceJsonObject.getString("code"))) { |
| | | JSONObject data = faceJsonObject.getJSONObject("data"); |
| | | if (data == null) { |
| | | log.error(message, faceJsonObject); |
| | |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | log.error(message, data); |
| | | return null; |
| | | } |
| | | for (T t : list) { |
| | | if (t instanceof BaseResult) { |
| | | ((BaseResult) t).setCreateTime(new Date()); |
| | | } |
| | | } |
| | | return list; |
| | | } else { |