| | |
| | | package com.ycl.task; |
| | | |
| | | import com.ycl.platform.domain.param.UY.OnlineParam; |
| | | import com.ycl.platform.service.IYwThresholdService; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.mongodb.client.result.DeleteResult; |
| | | import com.ycl.feign.UYClient; |
| | | import com.ycl.platform.domain.param.UY.*; |
| | | import com.ycl.platform.domain.result.HK.FaceDeviceInspectionResult; |
| | | import com.ycl.platform.domain.result.UY.OneMachineFileResult; |
| | | import com.ycl.platform.domain.result.UY.OsdMonitorResult; |
| | | import com.ycl.platform.domain.result.UY.RecordMetaDSumResult; |
| | | import com.ycl.platform.domain.result.UY.*; |
| | | import com.ycl.platform.service.ITMonitorService; |
| | | import com.ycl.platform.service.IYwThresholdService; |
| | | import com.ycl.platform.service.UYErrorTypeCheckService; |
| | | import com.ycl.utils.DateUtils; |
| | | import constant.ApiConstants; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | 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.format.annotation.DateTimeFormat; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | |
| | | //优云对接数据任务 |
| | | @Slf4j |
| | | @Component("UYTask") |
| | | public class UYTask { |
| | |
| | | private UYClient uyClient; |
| | | @Autowired |
| | | private IYwThresholdService ywThresholdService; |
| | | @Autowired |
| | | private ITMonitorService monitorService; |
| | | @Autowired |
| | | private UYErrorTypeCheckService uyErrorTypeCheckService; |
| | | |
| | | private final static Integer pageNo = 1; |
| | | private final static Integer pageSize = 5000; |
| | | //成功状态码 |
| | | private final static String successCode = "0"; |
| | | @Value("${youYun.tenantId}") |
| | | private String tenantId; |
| | | @Value("${youYun.apikey}") |
| | | private String apikey; |
| | | @Value("${youYun.accesskey}") |
| | | private String accesskey; |
| | | @Value("${youYun.email}") |
| | | private String email; |
| | | @Value("${youYun.passwd}") |
| | | private String passwd; |
| | | |
| | | //车辆设备全检指标监测结果 |
| | | public void VehicleDeviceInspectionTask() { |
| | | log.info("开始执行车辆设备全检指标监测结果数据同步"); |
| | | |
| | | log.info("结束车辆设备全检指标监测结果数据同步"); |
| | | } |
| | | |
| | | |
| | | public void FaceDeviceInspectionTask() { |
| | | log.info("开始执行人脸设备全检指标监测结果数据同步"); |
| | | |
| | | log.info("结束人脸设备全检指标监测结果数据同步"); |
| | | // 图像检测 |
| | | public void imageDetection() { |
| | | log.info("开始执行图像检测数据同步"); |
| | | ImageDetectionParam param = new ImageDetectionParam(); |
| | | param.setPageNum(ApiConstants.PageNo); |
| | | param.setPageSize(ApiConstants.PageSize); |
| | | param.setArealayerno(ApiConstants.AreaNo); |
| | | JSONObject jsonObject = uyClient.imageDetection(param); |
| | | if (jsonObject != null) { |
| | | log.info("数据格式" + jsonObject); |
| | | Integer statusCode = jsonObject.getInteger("statusCode"); |
| | | if (ApiConstants.UYSuccessCode.equals(statusCode)) { |
| | | JSONObject data = jsonObject.getJSONObject("data"); |
| | | if (data != null) { |
| | | List<ImageDetectionResult> records = data.getList("records", ImageDetectionResult.class); |
| | | if (!CollectionUtils.isEmpty(records)) { |
| | | //如果今天存在之前的数据先删除 |
| | | Query query = new Query(Criteria |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | DeleteResult result = mongoTemplate.remove(query, ImageDetectionResult.class); |
| | | //存放在mongo中 |
| | | mongoTemplate.insertAll(records); |
| | | // 工单生成 |
| | | uyErrorTypeCheckService.imageDetectionCheck(records); |
| | | } else { |
| | | log.error("图像监测数据为空{}", data); |
| | | } |
| | | } else { |
| | | log.error("图像监测数据为空{}", jsonObject); |
| | | } |
| | | } else { |
| | | log.error("图像监测请求失败{}", jsonObject); |
| | | } |
| | | } else { |
| | | log.error("图像监测数据为空"); |
| | | } |
| | | // 本地测试 |
| | | // Query query = new Query(Criteria.where("mongoCreateTime").lt(DateUtils.getDayEnd(new Date()))); |
| | | // uyErrorTypeCheckService.imageDetectionCheck(mongoTemplate.find(query, ImageDetectionResult.class)); |
| | | log.info("结束执行图像监测数据同步"); |
| | | } |
| | | |
| | | //一机一档 |
| | | public void task1() { |
| | | public void monitorQualifyTask() { |
| | | //一机一档合格率 |
| | | // 一机一档注册率 |
| | | // 档案考核比 |
| | | log.info("开始执行一机一档合格率数据同步"); |
| | | MonitorQualifyParam param = new MonitorQualifyParam(); |
| | | param.setPageNum(ApiConstants.PageNo); |
| | | param.setPageSize(ApiConstants.PageSize); |
| | | JSONObject jsonObject = uyClient.monitorQualify(param); |
| | | if (jsonObject != null) { |
| | | String code = jsonObject.getString("code"); |
| | | if (ApiConstants.UYSuccessCodeStr.equals(code)) { |
| | | JSONObject data = jsonObject.getJSONObject("data"); |
| | | if (data != null) { |
| | | List<MonitorQualifyResult> records = data.getList("records", MonitorQualifyResult.class); |
| | | if (!CollectionUtils.isEmpty(records)) { |
| | | //如果今天存在之前的数据先删除 |
| | | Query query = new Query(Criteria |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | DeleteResult result = mongoTemplate.remove(query, MonitorQualifyResult.class); |
| | | //存放在mongo中 |
| | | mongoTemplate.insertAll(records); |
| | | // 工单生成 |
| | | uyErrorTypeCheckService.monitorQualifyCheck(records); |
| | | } else { |
| | | log.error("一机一档合格率数据为空{}", data); |
| | | } |
| | | } |
| | | } else { |
| | | log.error("一机一档合格率数据为空{}", jsonObject); |
| | | } |
| | | } else { |
| | | log.error("一机一档合格率数据为空"); |
| | | } |
| | | // 本地测试 |
| | | // Query query = new Query(Criteria.where("mongoCreateTime").lt(DateUtils.getDayEnd(new Date()))); |
| | | // uyErrorTypeCheckService.monitorQualifyCheck(mongoTemplate.find(query, MonitorQualifyResult.class)); |
| | | log.info("结束一机一档合格率数据同步"); |
| | | } |
| | | |
| | | //图像监测诊断结果 |
| | | public void queryVqdResultTask() { |
| | | //点位在线率 |
| | | log.info("开始执行图像监测诊断结果数据同步"); |
| | | |
| | | |
| | | log.info("结束执行图像监测诊断结果数据同步"); |
| | | //点位在线率 |
| | | public void videoOnlineTask() { |
| | | //视频图像质量 |
| | | log.info("开始执行点位在线数据同步"); |
| | | VideoOnlineParam param = new VideoOnlineParam(); |
| | | param.setPageNum(ApiConstants.PageNo); |
| | | param.setPageSize(ApiConstants.PageSize); |
| | | param.setArealayerno(ApiConstants.AreaNo); |
| | | param.setStatus(ApiConstants.UY_OnlineStatus_All); |
| | | param.setIcmpStatus(ApiConstants.UY_OnlineStatus_All); |
| | | JSONObject jsonObject = uyClient.videoOnline(param); |
| | | if (jsonObject != null) { |
| | | Integer statusCode = jsonObject.getInteger("statusCode"); |
| | | if (ApiConstants.UYSuccessCode.equals(statusCode)) { |
| | | JSONObject data = jsonObject.getJSONObject("data"); |
| | | if (data != null) { |
| | | List<VideoOnlineResult> records = data.getList("records", VideoOnlineResult.class); |
| | | if (!CollectionUtils.isEmpty(records)) { |
| | | //如果今天存在之前的数据先删除 |
| | | Query query = new Query(Criteria |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | DeleteResult result = mongoTemplate.remove(query, VideoOnlineResult.class); |
| | | //存放在mongo中 |
| | | mongoTemplate.insertAll(records); |
| | | // 工单生成 |
| | | uyErrorTypeCheckService.videoOnlineCheck(records); |
| | | } else { |
| | | log.error("点位在线结果数据为空{}", data); |
| | | } |
| | | } else { |
| | | log.error("点位在线结果数据为空{}", jsonObject); |
| | | } |
| | | } else { |
| | | log.error("点位在线结果请求失败{}", jsonObject); |
| | | } |
| | | } else { |
| | | log.error("点位在线结果数据为空"); |
| | | } |
| | | // 本地测试 |
| | | // Query query = new Query(Criteria.where("mongoCreateTime").lt(DateUtils.getDayEnd(new Date()))); |
| | | // uyErrorTypeCheckService.videoOnlineCheck(mongoTemplate.find(query, VideoOnlineResult.class)); |
| | | log.info("结束执行点位在线数据同步"); |
| | | } |
| | | |
| | | //录像可用 |
| | | public void task3() { |
| | | public void recordMetaDSumTask() { |
| | | //录像可用率 |
| | | log.info("开始执行录像可用数据同步"); |
| | | RecordMetaDSumParam param = new RecordMetaDSumParam(); |
| | | param.setTenantId(tenantId); |
| | | Calendar instance = Calendar.getInstance(); |
| | | instance.setTime(new Date()); |
| | | instance.add(Calendar.DAY_OF_MONTH, -1); |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String yesterday = format.format(instance.getTime()); |
| | | param.setStatTime(yesterday); |
| | | JSONObject jsonObject = uyClient.recordMetaDSumList(param); |
| | | if (jsonObject != null) { |
| | | if (ApiConstants.UYSuccessCodeStr.equals(jsonObject.getString("code"))) { |
| | | List<RecordMetaDSumResult> records = jsonObject.getList("data", RecordMetaDSumResult.class); |
| | | if (!CollectionUtils.isEmpty(records)) { |
| | | //如果今天存在之前的数据先删除 |
| | | Query query = new Query(Criteria |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | DeleteResult result = mongoTemplate.remove(query, RecordMetaDSumResult.class); |
| | | //存放在mongo中 |
| | | mongoTemplate.insertAll(records); |
| | | // 工单生成 |
| | | uyErrorTypeCheckService.recordMetaDSumCheck(records); |
| | | } |
| | | } else { |
| | | log.error("录像可用数据为空{}", jsonObject); |
| | | } |
| | | } |
| | | // 本地测试 |
| | | // Query query = new Query(Criteria.where("mongoCreateTime").lt(DateUtils.getDayEnd(new Date()))); |
| | | // uyErrorTypeCheckService.recordMetaDSumCheck(mongoTemplate.find(query, RecordMetaDSumResult.class)); |
| | | log.info("结束执行录像可用数据同步"); |
| | | } |
| | | |
| | | |
| | | |
| | | } |