| | |
| | | // 图像检测 |
| | | 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("图像监测数据为空"); |
| | | } |
| | | // 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)); |
| | | Query query = new Query(Criteria.where("mongoCreateTime").lt(DateUtils.getDayEnd(new Date()))); |
| | | uyErrorTypeCheckService.imageDetectionCheck(mongoTemplate.find(query, ImageDetectionResult.class)); |
| | | log.info("结束执行图像监测数据同步"); |
| | | } |
| | | |
| | |
| | | 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); |
| | | } |
| | | } |
| | | // 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)); |
| | | Query query = new Query(Criteria.where("mongoCreateTime").lt(DateUtils.getDayEnd(new Date()))); |
| | | uyErrorTypeCheckService.recordMetaDSumCheck(mongoTemplate.find(query, RecordMetaDSumResult.class)); |
| | | log.info("结束执行录像可用数据同步"); |
| | | } |
| | | |