| | |
| | | import com.ycl.platform.domain.result.UY.OneMachineFileResult; |
| | | import com.ycl.platform.domain.vo.TMonitorVO; |
| | | import com.ycl.platform.mapper.TMonitorMapper; |
| | | import com.ycl.platform.mapper.YwPointMapper; |
| | | import com.ycl.platform.service.ITMonitorService; |
| | | import com.ycl.platform.service.YwPointService; |
| | | import com.ycl.system.entity.SysDictData; |
| | |
| | | @Autowired |
| | | private YwPointService ywPointService; |
| | | @Autowired |
| | | private YwPointMapper ywPointMapper; |
| | | @Autowired |
| | | private RedisTemplate redisTemplate; |
| | | |
| | | //同步mongodb一机一档到数据库 |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void synchronize() { |
| | | // 获取Calendar实例,默认使用当前时区和语言环境 |
| | | Calendar calendar = Calendar.getInstance(); |
| | | // 清除Calendar中的所有字段值,以避免它们对当前日期时间有影响 |
| | | calendar.clear(); |
| | | // 设置年份、月份(注意:月份是从0开始的,所以8月是7)、日期 |
| | | calendar.set(Calendar.YEAR, 2024); |
| | | calendar.set(Calendar.MONTH, Calendar.AUGUST); |
| | | calendar.set(Calendar.DAY_OF_MONTH, 13); |
| | | // Calendar.getTime()方法返回一个表示此Calendar时间值的Date对象 |
| | | Date date = calendar.getTime(); |
| | | log.info("开始同步mongodb一机一档到数据库"); |
| | | Date date = DateUtils.getDay(2024,7,13); |
| | | Query query = new Query(Criteria.where("mongoCreateTime").gte(DateUtils.getDayStart(date)).lt(DateUtils.getDayEnd(date))); |
| | | // Query query = new Query(Criteria.where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | List<MonitorQualifyResult> oneMachineFileResults = mongoTemplate.find(query, MonitorQualifyResult.class); |
| | |
| | | SysDictData sysDictData = new SysDictData(); |
| | | sysDictData.setDictType("platform_important_site"); |
| | | List<SysDictData> DictDataList = dictDataService.selectDictDataList(sysDictData); |
| | | //采集区域为重点点位的集合 |
| | | List<String> importantSite = DictDataList.stream().map(SysDictData::getDictValue).collect(Collectors.toList()); |
| | | |
| | | //全年留存 |
| | |
| | | log.info("result集合{},设备集合{},点位集合{}", oneMachineFileResults.size(), monitorList.size(), ywPointList.size()); |
| | | //插入数据库 |
| | | if (!CollectionUtils.isEmpty(monitorList)) { |
| | | monitorService.saveOrUpdateBatch(monitorList); |
| | | monitorMapper.deleteAll(); |
| | | monitorService.saveBatch(monitorList); |
| | | } |
| | | if (!CollectionUtils.isEmpty(ywPointList)) { |
| | | ywPointService.saveOrUpdateBatch(ywPointList); |
| | | ywPointMapper.deleteAll(); |
| | | ywPointService.saveBatch(ywPointList); |
| | | } |
| | | //新的数据放入Redis中等待考核指标任务使用 |
| | | redisTemplate.opsForValue().set(RedisConstant.New_Monitor_Set, JSONArray.toJSONString(newMonitorList)); |
| | | log.info("结束同步mongodb一机一档到数据库"); |
| | | } |
| | | |
| | | private YwPoint getPoint(MonitorQualifyResult result, Map<String, YwPoint> pointMap, List<String> importantSite) { |
| | |
| | | ywPoint.setSerialNumber(result.getSerialNumber().getValue()); |
| | | ywPoint.setImportantTag(Boolean.FALSE); |
| | | ywPoint.setProvinceTag(Boolean.FALSE); |
| | | ywPoint.setImportantCommandImageTag(Boolean.FALSE); |
| | | ywPoint.setCreateTime(new Date()); |
| | | ywPoint.setUpdateTime(new Date()); |
| | | } |
| | | //比对是否是重点点位 |
| | | if (importantSite.contains(result.getSerialNumber().getValue())) { |
| | | if (importantSite.contains(result.getSxjcjqy().getValue())) { |
| | | ywPoint.setImportantTag(Boolean.TRUE); |
| | | } |
| | | //解析deptId |