package com.ycl.task; import com.ycl.calculate.CalculationStrategy; import com.ycl.factory.IndexCalculationFactory; import com.ycl.platform.domain.result.HK.*; import com.ycl.platform.domain.vo.TMonitorVO; import com.ycl.platform.mapper.TMonitorMapper; import com.ycl.utils.DateUtils; import com.ycl.utils.StringUtils; import constant.ApiConstants; import constant.CalculationStrategyConstants; import constant.CheckConstants; 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 java.util.Date; import java.util.List; import java.util.stream.Collectors; /** * 人脸计算考核指标任务 * 凌晨执行计算昨天数据 * */ @Slf4j @Component("faceTask") public class FaceTask { @Autowired private MongoTemplate mongoTemplate; @Autowired private TMonitorMapper monitorMapper; public void siteOnlineTask() { log.info("开始计算人脸点位在线率和视图库对接稳定性"); Date yesterday = DateUtils.addDays(new Date(), -1); //点位在线率和视图库对接稳定性 Query query = new Query(); query.addCriteria(Criteria .where("mongoCreateTime").gte(DateUtils.getDayStart(yesterday)).lt(DateUtils.getDayEnd(yesterday)) .and("dataType").is(ApiConstants.HK_DataType_FACE)); List results = mongoTemplate.find(query, SnapshotDataMonitorResult.class); CalculationStrategy calculator = IndexCalculationFactory.getCalculator(CalculationStrategyConstants.Face_SiteOnline_ViewStability); calculator.calculate(results); log.info("结束计算人脸点位在线率和视图库对接稳定性"); } public void deviceSampleTask() { log.info("开始计算人脸图片合格率、大图可用性"); Date yesterday = DateUtils.addDays(new Date(), -1); //计算人脸图片合格率、大图可用性 Query query = new Query(); query.addCriteria(Criteria .where("mongoCreateTime").gte(DateUtils.getDayStart(yesterday)).lt(DateUtils.getDayEnd(yesterday))); List results = mongoTemplate.find(query, FaceDeviceSamplingResult.class); CalculationStrategy calculator = IndexCalculationFactory.getCalculator(CalculationStrategyConstants.Face_DataAccuracy_PicUsability); calculator.calculate(results); log.info("结束计算人脸图片合格率、大图可用性"); } public void infoAccuracyTask(){ log.info("开始计算人脸卡口信息采集准确率"); Date yesterday = DateUtils.addDays(new Date(), -1); //计算人脸卡口信息采集准确率 Query query = new Query(); query.addCriteria(Criteria .where("mongoCreateTime").gte(DateUtils.getDayStart(yesterday)).lt(DateUtils.getDayEnd(yesterday))); List results = mongoTemplate.find(query, MonitoringDetailResult.class); CalculationStrategy calculator = IndexCalculationFactory.getCalculator(CalculationStrategyConstants.Face_InfoAccuracy); calculator.calculate(results); log.info("结束计算人脸卡口信息采集准确率"); } public void snapShopDelay(){ log.info("开始计算人脸抓拍数据上传及时性"); Date yesterday = DateUtils.addDays(new Date(), -1); //计算人脸抓拍数据上传及时性 Query query = new Query(); query.addCriteria(Criteria .where("mongoCreateTime").gte(DateUtils.getDayStart(yesterday)).lt(DateUtils.getDayEnd(yesterday)) .and("dataType").is(ApiConstants.HK_DataType_FACE)); List results = mongoTemplate.find(query, SnapshotDelayMonitorResult.class); CalculationStrategy calculator = IndexCalculationFactory.getCalculator(CalculationStrategyConstants.Face_SnapshotDelay); calculator.calculate(results); log.info("结束计算人脸抓拍数据上传及时性"); } public void clockAccuracyTask() { log.info("开始计算人脸设备时钟准确性"); Date yesterday = DateUtils.addDays(new Date(), -1); //计算人脸设备时钟准确性 Query query = new Query(); query.addCriteria(Criteria .where("mongoCreateTime").gte(DateUtils.getDayStart(yesterday)).lt(DateUtils.getDayEnd(yesterday))); List results = mongoTemplate.find(query, FaceDeviceInspectionResult.class); CalculationStrategy calculator = IndexCalculationFactory.getCalculator(CalculationStrategyConstants.Face_ClockAccuracy); calculator.calculate(results); log.info("结束计算人脸设备时钟准确性"); } public void directConsistentTask() { log.info("开始计算人脸目录一致率"); //人脸目录一致率 List tMonitorVOS = monitorMapper.selectMonitorVOList(); List list = tMonitorVOS.stream().filter(tMonitorVO ->!StringUtils.isEmpty(tMonitorVO.getCameraFunType()) && tMonitorVO.getCameraFunType().contains(CheckConstants.Rule_Category_Face + "")).collect(Collectors.toList()); CalculationStrategy calculator = IndexCalculationFactory.getCalculator(CalculationStrategyConstants.Face_DirectConsistent); calculator.calculate(list); log.info("结束计算人脸目录一致率"); } }