New file |
| | |
| | | package constant; |
| | | |
| | | /** |
| | | * 考核计算策略常量 |
| | | */ |
| | | public class CalculationStrategyConstants { |
| | | |
| | | /** |
| | | * 车辆点位在线率和视图库对接稳定性 |
| | | */ |
| | | public static final String CAR_SiteOnline_ViewStability = "carSiteOnlineViewStability"; |
| | | /** |
| | | * 人脸点位在线率和视图库对接稳定性 |
| | | */ |
| | | public static final String Face_SiteOnline_ViewStability = "faceSiteOnlineViewStability"; |
| | | } |
| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.time.LocalDate; |
| | | import java.util.*; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | |
| | | BigDecimal cityCountAvg = getAverageCount(CheckSnapCountConstants.City); |
| | | BigDecimal countyCountAvg = getAverageCount(CheckSnapCountConstants.County); |
| | | |
| | | // 查询今日数据 |
| | | // 查询是否index表已经存在今日数据 |
| | | List<CheckIndexCar> checkIndexCarList = checkIndexCarMapper.selectToday(DateUtils.getDate()); |
| | | List<CheckIndexCar> checkIndexCars = new ArrayList<>(); |
| | | areaStatsMap.forEach((deptId, stats) -> { |
| | |
| | | checkIndexCarService.saveOrUpdateBatch(checkIndexCars); |
| | | } |
| | | |
| | | //累计总点位数、离线数、总抓拍量 |
| | | /** 累计总点位数、离线数、总抓拍量 */ |
| | | private void updateAreaStats(Map<String, AreaStats> areaStatsMap, String key, SnapshotDataMonitorResult result) { |
| | | //返回对象的引用,如果不存在会放入新的key,value |
| | | AreaStats stats = areaStatsMap.computeIfAbsent(key, k -> new AreaStats()); |
| | |
| | | } |
| | | } |
| | | |
| | | //获取2022同期抓拍平均值 |
| | | /** 获取2022同期抓拍平均值 */ |
| | | private BigDecimal getAverageCount(String configKey) { |
| | | String count = sysConfigMapper.checkConfigKeyUnique(configKey).getConfigValue(); |
| | | return new BigDecimal(count).multiply(new BigDecimal(CheckSnapCountConstants.Multiply)) |
| | | .divide(new BigDecimal(CheckSnapCountConstants.CountyNum), 0, RoundingMode.HALF_UP); |
| | | return new BigDecimal(count) |
| | | .multiply(new BigDecimal(CheckSnapCountConstants.Multiply)) |
| | | .divide(new BigDecimal(CheckSnapCountConstants.CountyNum), 10, RoundingMode.HALF_UP) |
| | | .divide(new BigDecimal(LocalDate.now().getDayOfMonth()), 0, RoundingMode.HALF_UP); |
| | | } |
| | | |
| | | //车辆点位在线率和视图库对接稳定性 |
| | | /** 车辆点位在线率和视图库对接稳定性 */ |
| | | private CheckIndexCar createOrUpdateCheckIndexCar(String key, AreaStats stats, BigDecimal cityCountAvg, BigDecimal countyCountAvg, List<CheckIndexCar> checkIndexCarList) { |
| | | CheckIndexCar checkIndexCar; |
| | | |
New file |
| | |
| | | package com.ycl.task; |
| | | |
| | | |
| | | import com.ycl.calculate.CalculationStrategy; |
| | | import com.ycl.factory.IndexCalculationFactory; |
| | | import com.ycl.platform.domain.result.HK.SnapshotDataMonitorResult; |
| | | import com.ycl.utils.DateUtils; |
| | | import constant.ApiConstants; |
| | | import constant.CalculationStrategyConstants; |
| | | 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; |
| | | |
| | | /** |
| | | * 车辆计算考核指标任务 |
| | | * 凌晨执行计算昨天数据 |
| | | */ |
| | | @Slf4j |
| | | @Component("carTask") |
| | | public class CarTask { |
| | | @Autowired |
| | | private MongoTemplate mongoTemplate; |
| | | |
| | | public void siteOnlineTask() { |
| | | 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_CAR)); |
| | | List<SnapshotDataMonitorResult> snapshotDataMonitorResults = mongoTemplate.find(query, SnapshotDataMonitorResult.class); |
| | | CalculationStrategy<SnapshotDataMonitorResult> siteOnlineCalculator = IndexCalculationFactory.getCalculator(CalculationStrategyConstants.CAR_SiteOnline_ViewStability); |
| | | siteOnlineCalculator.calculate(snapshotDataMonitorResults); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | @Autowired |
| | | private CheckScoreMapper scoreMapper; |
| | | @Autowired |
| | | private MongoTemplate mongoTemplate; |
| | | @Autowired |
| | | private ICheckIndexVideoService videoService; |
| | | @Autowired |
| | | private ICheckIndexFaceService faceService; |
| | | @Autowired |
| | | private ICheckIndexCarService carService; |
| | | |
| | | //TODO:统一任务时间 |
| | | public void executeTemplate(Integer templateId) { |
| | | CheckTemplate checkTemplate = templateMapper.selectCheckTemplateById(templateId); |
| | | if (checkTemplate != null) { |
| | |
| | | //根据模板的考核标签查各区县对应省厅或市局视频数据 |
| | | List<CheckIndexVideo> checkIndexVideos = videoService.selectCheckIndexVideoList(checkIndexVideo); |
| | | for (CheckIndexVideo indexVideo : checkIndexVideos) { |
| | | addToList(templateId, checkTemplate, examineTag, templateRuleList, scoreList, indexVideo,CheckConstants.Rule_Category_Video); |
| | | addToList(templateId, checkTemplate, examineTag, templateRuleList, scoreList, indexVideo, CheckConstants.Rule_Category_Video); |
| | | } |
| | | } else if (CheckConstants.Rule_Category_Car.equals(examineCategory)) { |
| | | CheckIndexCar checkIndexCar = new CheckIndexCar(); |
| | |
| | | //根据模板的考核标签查各区县对应省厅或市局车辆数据 |
| | | List<CheckIndexCar> checkIndexCars = carService.selectCheckIndexCarList(checkIndexCar); |
| | | for (CheckIndexCar indexCar : checkIndexCars) { |
| | | addToList(templateId, checkTemplate, examineTag, templateRuleList, scoreList, indexCar,CheckConstants.Rule_Category_Car); |
| | | addToList(templateId, checkTemplate, examineTag, templateRuleList, scoreList, indexCar, CheckConstants.Rule_Category_Car); |
| | | } |
| | | } else if (CheckConstants.Rule_Category_Face.equals(examineCategory)) { |
| | | CheckIndexFace checkIndexFace = new CheckIndexFace(); |
| | |
| | | //根据模板的考核标签查各区县对应省厅或市局人脸数据 |
| | | List<CheckIndexFace> checkIndexFaces = faceService.selectCheckIndexFaceList(checkIndexFace); |
| | | for (CheckIndexFace indexFace : checkIndexFaces) { |
| | | addToList(templateId, checkTemplate, examineTag, templateRuleList, scoreList, indexFace,CheckConstants.Rule_Category_Face); |
| | | addToList(templateId, checkTemplate, examineTag, templateRuleList, scoreList, indexFace, CheckConstants.Rule_Category_Face); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | private <T extends CheckIndex>void addToList(Integer templateId, CheckTemplate checkTemplate, Short examineTag, List<CheckTemplateRule> templateRuleList, List<CheckScore> scoreList, T indexObject,Short checkCategory) { |
| | | private <T extends CheckIndex> void addToList(Integer templateId, CheckTemplate checkTemplate, Short examineTag, List<CheckTemplateRule> templateRuleList, List<CheckScore> scoreList, T indexObject, Short checkCategory) { |
| | | CheckScore checkScore = new CheckScore(); |
| | | BigDecimal scoreFinal = BigDecimal.ZERO; |
| | | for (CheckTemplateRule templateRule : templateRuleList) { |
| | |
| | | scoreFinal = getScoreFinal(indexObject, scoreFinal, templateRule); |
| | | } |
| | | //补充checkScore |
| | | fillCheckScore(templateId, checkTemplate, examineTag, indexObject, checkScore, scoreFinal,checkCategory); |
| | | fillCheckScore(templateId, checkTemplate, examineTag, indexObject, checkScore, scoreFinal, checkCategory); |
| | | scoreList.add(checkScore); |
| | | } |
| | | |
| | | //通用方法计算分数 |
| | | private <T>BigDecimal getScoreFinal(T object, BigDecimal scoreFinal, CheckTemplateRule templateRule) { |
| | | private <T> BigDecimal getScoreFinal(T object, BigDecimal scoreFinal, CheckTemplateRule templateRule) { |
| | | String ruleIndex = templateRule.getRuleIndex(); |
| | | //将a_b_c转换为aBC |
| | | String camelRuleIndex = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, ruleIndex); |
| | |
| | | BigDecimal score = index.multiply(templateRule.getWeight()); |
| | | scoreFinal = scoreFinal.add(score); |
| | | } catch (Exception e) { |
| | | log.info("反射异常",e); |
| | | log.info("反射异常", e); |
| | | } |
| | | return scoreFinal; |
| | | } |
| | | |
| | | //设置checkScore对象 |
| | | private void fillCheckScore(Integer templateId, CheckTemplate checkTemplate, Short examineTag, CheckIndex checkIndex, CheckScore checkScore, BigDecimal scoreFinal,Short checkCategory) { |
| | | private void fillCheckScore(Integer templateId, CheckTemplate checkTemplate, Short examineTag, CheckIndex checkIndex, CheckScore checkScore, BigDecimal scoreFinal, Short checkCategory) { |
| | | //根据调整系数调整最终分数大小 |
| | | String adjustWay = checkTemplate.getAdjustWay(); |
| | | BigDecimal adjustCoefficient = checkTemplate.getAdjustCoefficient(); |
| | | if(CheckConstants.Multiply.equals(adjustWay)){ |
| | | if (CheckConstants.Multiply.equals(adjustWay)) { |
| | | scoreFinal = adjustCoefficient.multiply(scoreFinal).multiply(new BigDecimal(100)); |
| | | }else if(CheckConstants.Divided.equals(adjustWay)){ |
| | | } else if (CheckConstants.Divided.equals(adjustWay)) { |
| | | //四舍五入保留小数后四位 |
| | | scoreFinal = scoreFinal.divide(adjustCoefficient,4, RoundingMode.HALF_UP).multiply(new BigDecimal(100)); |
| | | scoreFinal = scoreFinal.divide(adjustCoefficient, 4, RoundingMode.HALF_UP).multiply(new BigDecimal(100)); |
| | | } |
| | | checkScore.setCreateTime(new Date()); |
| | | checkScore.setExamineTag(Integer.parseInt(examineTag +"")); |
| | | checkScore.setExamineTag(Integer.parseInt(examineTag + "")); |
| | | checkScore.setExamineCategory(checkCategory); |
| | | checkScore.setDeptId(checkIndex.getDeptId()); |
| | | checkScore.setTemplateId(templateId); |
| | | checkScore.setScore(scoreFinal); |
| | | } |
| | | |
| | | //查mongo数据归档到mysql |
| | | public void dataArchiving() { |
| | | //TODO:归档check_index_car,区分省厅市局,每个区县一条数据 |
| | | CheckIndexCar checkIndexCar = new CheckIndexCar(); |
| | | //TODO:归档check_index_face |
| | | CheckIndexFace checkIndexFace = new CheckIndexFace(); |
| | | //TODO:归档check_index_video |
| | | CheckIndexVideo checkIndexVideo = new CheckIndexVideo(); |
| | | |
| | | } |
| | | } |
New file |
| | |
| | | package com.ycl.task; |
| | | |
| | | |
| | | import com.ycl.calculate.CalculationStrategy; |
| | | import com.ycl.factory.IndexCalculationFactory; |
| | | import com.ycl.platform.domain.result.HK.SnapshotDataMonitorResult; |
| | | import com.ycl.utils.DateUtils; |
| | | import constant.ApiConstants; |
| | | import constant.CalculationStrategyConstants; |
| | | 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; |
| | | |
| | | /** |
| | | * 人脸计算考核指标任务 |
| | | * 凌晨执行计算昨天数据 |
| | | * */ |
| | | @Slf4j |
| | | @Component("faceTask") |
| | | public class FaceTask { |
| | | @Autowired |
| | | private MongoTemplate mongoTemplate; |
| | | |
| | | public void siteOnlineTask() { |
| | | 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<SnapshotDataMonitorResult> snapshotDataMonitorResults = mongoTemplate.find(query, SnapshotDataMonitorResult.class); |
| | | CalculationStrategy<SnapshotDataMonitorResult> siteOnlineCalculator = IndexCalculationFactory.getCalculator(CalculationStrategyConstants.Face_SiteOnline_ViewStability); |
| | | siteOnlineCalculator.calculate(snapshotDataMonitorResults); |
| | | } |
| | | |
| | | } |
| | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | |
| | | //海康对接数据任务 |
| | | @Slf4j |
| | | @Component("HKTask") |
| | | public class HKTask { |
| | |
| | | List<VehicleDeviceInspectionResult> list = getDataList(jsonObject, VehicleDeviceInspectionResult.class, "车辆设备全检指标监测结果数据为空"); |
| | | if (!CollectionUtils.isEmpty(list)) { |
| | | //如果存在之前的数据先删除 |
| | | Query query = new Query(Criteria.where("createTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | Query query = new Query(Criteria.where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | DeleteResult result = mongoTemplate.remove(query, VehicleDeviceInspectionResult.class); |
| | | //存放在mongo中 |
| | | mongoTemplate.insert(list); |
| | |
| | | List<FaceDeviceInspectionResult> list = getDataList(jsonObject, FaceDeviceInspectionResult.class, "人脸设备全检指标监测结果数据为空"); |
| | | if (!CollectionUtils.isEmpty(list)) { |
| | | //如果存在之前的数据先删除 |
| | | Query query = new Query(Criteria.where("createTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | Query query = new Query(Criteria.where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | DeleteResult result = mongoTemplate.remove(query, FaceDeviceInspectionResult.class); |
| | | //存放在mongo中 |
| | | mongoTemplate.insert(list); |
| | |
| | | if (!CollectionUtils.isEmpty(carList)) { |
| | | //如果今天存在之前的数据先删除 |
| | | Query query = new Query(Criteria |
| | | .where("createTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())) |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())) |
| | | .and("dataType").is(ApiConstants.HK_DATATYPE_CAR)); |
| | | DeleteResult result = mongoTemplate.remove(query, SnapshotDataMonitorResult.class); |
| | | //存放在mongo中 |
| | |
| | | if (!CollectionUtils.isEmpty(faceList)) { |
| | | //如果今天存在之前的数据先删除 |
| | | Query query = new Query(Criteria |
| | | .where("createTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())) |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())) |
| | | .and("dataType").is(ApiConstants.HK_DATATYPE_FACE)); |
| | | DeleteResult result = mongoTemplate.remove(query, SnapshotDataMonitorResult.class); |
| | | //存放在mongo中 |
| | |
| | | if (!CollectionUtils.isEmpty(faceList)) { |
| | | //如果今天存在之前的数据先删除 |
| | | Query query = new Query(Criteria |
| | | .where("createTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | DeleteResult result = mongoTemplate.remove(query, MonitoringDetailResult.class); |
| | | //存放在mongo中 |
| | | mongoTemplate.insert(faceList); |
| | |
| | | if (!CollectionUtils.isEmpty(faceList)) { |
| | | //如果今天存在之前的数据先删除 |
| | | Query query = new Query(Criteria |
| | | .where("createTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | DeleteResult result = mongoTemplate.remove(query, CrossDetailResult.class); |
| | | //存放在mongo中 |
| | | mongoTemplate.insert(faceList); |
| | |
| | | if (!CollectionUtils.isEmpty(faceList)) { |
| | | //如果今天存在之前的数据先删除 |
| | | Query query = new Query(Criteria |
| | | .where("createTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | DeleteResult result = mongoTemplate.remove(query, DataIntegrityMonitoringResult.class); |
| | | //存放在mongo中 |
| | | mongoTemplate.insert(faceList); |
| | |
| | | if (!CollectionUtils.isEmpty(faceList)) { |
| | | //如果今天存在之前的数据先删除 |
| | | Query query = new Query(Criteria |
| | | .where("createTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | DeleteResult result = mongoTemplate.remove(query, AttrRecognitionMonitorResult.class); |
| | | //存放在mongo中 |
| | | mongoTemplate.insert(faceList); |
| | |
| | | if (!CollectionUtils.isEmpty(carList)) { |
| | | //如果今天存在之前的数据先删除 |
| | | Query query = new Query(Criteria |
| | | .where("createTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())) |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())) |
| | | .and("dataType").is(ApiConstants.HK_DATATYPE_CAR)); |
| | | DeleteResult result = mongoTemplate.remove(query, SnapshotDataMonitorResult.class); |
| | | DeleteResult result = mongoTemplate.remove(query, SnapshotDelayMonitorParam.class); |
| | | //存放在mongo中 |
| | | carList.forEach(item -> item.setDataType(ApiConstants.HK_DATATYPE_CAR)); |
| | | mongoTemplate.insert(carList); |
| | |
| | | if (!CollectionUtils.isEmpty(faceList)) { |
| | | //如果今天存在之前的数据先删除 |
| | | Query query = new Query(Criteria |
| | | .where("createTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())) |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date())) |
| | | .and("dataType").is(ApiConstants.HK_DATATYPE_FACE)); |
| | | DeleteResult result = mongoTemplate.remove(query, SnapshotDataMonitorResult.class); |
| | | DeleteResult result = mongoTemplate.remove(query, SnapshotDelayMonitorParam.class); |
| | | //存放在mongo中 |
| | | carList.forEach(item -> item.setDataType(ApiConstants.HK_DATATYPE_FACE)); |
| | | mongoTemplate.insert(faceList); |
| | |
| | | if (!CollectionUtils.isEmpty(faceList)) { |
| | | //如果今天存在之前的数据先删除 |
| | | Query query = new Query(Criteria |
| | | .where("createTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | DeleteResult result = mongoTemplate.remove(query, PicAccessResult.class); |
| | | //存放在mongo中 |
| | | mongoTemplate.insert(faceList); |
| | |
| | | if (!CollectionUtils.isEmpty(faceList)) { |
| | | //如果今天存在之前的数据先删除 |
| | | Query query = new Query(Criteria |
| | | .where("createTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | DeleteResult result = mongoTemplate.remove(query, PicAccessResult.class); |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | DeleteResult result = mongoTemplate.remove(query, FaceDeviceSamplingResult.class); |
| | | //存放在mongo中 |
| | | mongoTemplate.insert(faceList); |
| | | } |
| | |
| | | if (!CollectionUtils.isEmpty(faceList)) { |
| | | //如果今天存在之前的数据先删除 |
| | | Query query = new Query(Criteria |
| | | .where("createTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | DeleteResult result = mongoTemplate.remove(query, PicAccessResult.class); |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | DeleteResult result = mongoTemplate.remove(query, FaceDeviceSamplingResult.class); |
| | | //存放在mongo中 |
| | | mongoTemplate.insert(faceList); |
| | | } |
| | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | |
| | | //优云对接数据任务 |
| | | @Slf4j |
| | | @Component("UYTask") |
| | | public class UYTask { |
| | |
| | | if (!CollectionUtils.isEmpty(data)) { |
| | | //如果今天存在之前的数据先删除 |
| | | Query query = new Query(Criteria |
| | | .where("createTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | DeleteResult result = mongoTemplate.remove(query, OneMachineFileResult.class); |
| | | //存放在mongo中 |
| | | mongoTemplate.insert(data); |
| | |
| | | if (!CollectionUtils.isEmpty(records)) { |
| | | //如果今天存在之前的数据先删除 |
| | | Query query = new Query(Criteria |
| | | .where("createTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | DeleteResult result = mongoTemplate.remove(query, QueryVqdResult.class); |
| | | //存放在mongo中 |
| | | mongoTemplate.insert(records); |
| | |
| | | if (!CollectionUtils.isEmpty(records)) { |
| | | //如果今天存在之前的数据先删除 |
| | | Query query = new Query(Criteria |
| | | .where("createTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | .where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | DeleteResult result = mongoTemplate.remove(query, RecordMetaDSumResult.class); |
| | | //存放在mongo中 |
| | | mongoTemplate.insert(records); |
New file |
| | |
| | | package com.ycl.task; |
| | | |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.mongodb.core.MongoTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * 视频计算考核指标任务 |
| | | * 凌晨执行计算昨天数据 |
| | | * */ |
| | | @Slf4j |
| | | @Component("videoTask") |
| | | public class VideoTask { |
| | | @Autowired |
| | | private MongoTemplate mongoTemplate; |
| | | } |