| | |
| | | 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; |
| | | |
| | |
| | | private String email; |
| | | @Value("${youYun.passwd}") |
| | | private String passwd; |
| | | |
| | | //一机一档 |
| | | public void monitorTask() { |
| | | //一机一档合格率 |
| | |
| | | OneMachineFileParam param = new OneMachineFileParam(); |
| | | JSONObject jsonObject = uyClient.oneMachineFile(param); |
| | | if (jsonObject != null) { |
| | | log.info("数据格式"+jsonObject); |
| | | log.info("数据格式" + jsonObject); |
| | | JSONObject cameraList = jsonObject.getJSONObject("CameraList"); |
| | | if (cameraList != null) { |
| | | List<OneMachineFileResult> data = cameraList.getList("data", OneMachineFileResult.class); |
| | |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | DeleteResult result = mongoTemplate.remove(query, OneMachineFileResult.class); |
| | | //存放在mongo中 |
| | | mongoTemplate.insert(data); |
| | | mongoTemplate.insertAll(data); |
| | | } else { |
| | | log.error("一机一档数据为空{}", cameraList); |
| | | } |
| | |
| | | param.setTenantId(tenantId); |
| | | JSONObject jsonObject = uyClient.queryVqdResult(param); |
| | | if (jsonObject != null) { |
| | | log.info("数据格式"+jsonObject); |
| | | log.info("数据格式" + jsonObject); |
| | | Integer statusCode = jsonObject.getInteger("statusCode"); |
| | | if (ApiConstants.UYSuccessCode.equals(statusCode)) { |
| | | JSONObject data = jsonObject.getJSONObject("data"); |
| | |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | DeleteResult result = mongoTemplate.remove(query, QueryVqdResult.class); |
| | | //存放在mongo中 |
| | | mongoTemplate.insert(records); |
| | | mongoTemplate.insertAll(records); |
| | | } else { |
| | | log.error("图像监测诊断结果数据为空{}", data); |
| | | } |
| | |
| | | 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) { |
| | | log.info("数据格式"+jsonObject); |
| | | if (jsonObject.getBoolean("success")) { |
| | | JSONObject data = jsonObject.getJSONObject("data"); |
| | | if (data != null) { |
| | | List<RecordMetaDSumResult> records = data.getList("records", 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.insert(records); |
| | | } else { |
| | | log.error("录像可用数据为空{}", data); |
| | | } |
| | | } else { |
| | | log.error("录像可用数据为空{}", jsonObject); |
| | | 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); |
| | | } |
| | | } else { |
| | | log.error("录像可用数据为空{}", jsonObject); |
| | | } |
| | | } else { |
| | | log.error("录像可用数据为空"); |
| | | } |
| | | log.info("结束执行录像可用数据同步"); |
| | | } |
| | | |
| | | |
| | | //视频标注 |
| | | public void OsdMonitorTask() { |
| | | //视频标注 |
| | | log.info("开始执行视频标注数据同步"); |
| | | OsdMonitorParam param = new OsdMonitorParam(); |
| | | JSONObject jsonObject = uyClient.osdMonitorList(param,tenantId); |
| | | JSONObject jsonObject = uyClient.osdMonitorList(param, tenantId); |
| | | if (jsonObject != null) { |
| | | log.info("数据格式"+jsonObject); |
| | | if (jsonObject.getBoolean("success")) { |
| | | log.info("数据格式" + jsonObject); |
| | | if (ApiConstants.UYSuccessCodeStr.equals(jsonObject.getString("code"))) { |
| | | JSONObject data = jsonObject.getJSONObject("data"); |
| | | if (data != null) { |
| | | List<OsdMonitorResult> records = data.getList("records", OsdMonitorResult.class); |
| | |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | DeleteResult result = mongoTemplate.remove(query, OsdMonitorResult.class); |
| | | //存放在mongo中 |
| | | mongoTemplate.insert(records); |
| | | mongoTemplate.insertAll(records); |
| | | } else { |
| | | log.error("视频标注数据为空{}", data); |
| | | } |