package com.ycl.task; import com.alibaba.fastjson2.JSONObject; import com.mongodb.client.result.DeleteResult; import com.ycl.platform.domain.param.UY.OnlineParam; import com.ycl.platform.domain.param.UY.QueryVqdParam; import com.ycl.platform.domain.result.HK.PicAccessResult; import com.ycl.platform.domain.result.UY.QueryVqdResult; import com.ycl.platform.service.IYwThresholdService; import com.ycl.feign.UYClient; import com.ycl.utils.DateUtils; 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.stereotype.Component; import org.springframework.util.CollectionUtils; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; @Slf4j @Component("UYTask") public class UYTask { @Autowired private MongoTemplate mongoTemplate; @Autowired private UYClient uyClient; @Autowired private IYwThresholdService ywThresholdService; @Value("${youYun.tenantId}") private String tenantId; //一机一档 public void monitorTask() { log.info("开始执行一机一档数据同步"); //一机一档合格率 // 一机一档注册率 // 档案考核比 log.info("结束执行一机一档数据同步"); } //图像监测诊断结果 public void queryVqdResultTask() { //点位在线率 log.info("开始执行图像监测诊断结果数据同步"); QueryVqdParam param = new QueryVqdParam(); param.setTenantId(tenantId); JSONObject jsonObject = uyClient.queryVqdResult(param); if (jsonObject != null) { JSONObject cameraList = jsonObject.getJSONObject("CameraList"); if (cameraList != null) { List data = cameraList.getList("data", QueryVqdResult.class); if (!CollectionUtils.isEmpty(data)) { //如果今天存在之前的数据先删除 Query query = new Query(Criteria .where("createTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); DeleteResult result = mongoTemplate.remove(query, PicAccessResult.class); //存放在mongo中 mongoTemplate.insert(data); } else { log.error("图像监测诊断结果数据为空{}", cameraList); } } else { log.error("图像监测诊断结果数据为空{}", jsonObject); } } else { log.error("图像监测诊断结果数据为空"); } log.info("结束执行图像监测诊断结果数据同步"); } //录像可用 public void task3() { //录像可用率 } //视频图像质量 public void task4() { //录像可用率 } }