| | |
| | | import com.ycl.platform.domain.entity.YwPoint; |
| | | import com.ycl.platform.domain.result.UY.MonitorQualifyResult; |
| | | import com.ycl.platform.domain.result.UY.OneMachineFileResult; |
| | | import com.ycl.platform.domain.result.UY.OsdCheckResult; |
| | | import com.ycl.platform.domain.vo.TMonitorVO; |
| | | import com.ycl.platform.mapper.TMonitorMapper; |
| | | import com.ycl.platform.mapper.YwPointMapper; |
| | |
| | | //同步mongodb一机一档到数据库 |
| | | public void synchronize() { |
| | | log.info("开始同步mongodb一机一档到数据库"); |
| | | Query query = new Query(Criteria.where("mongoCreateTime").gte(DateUtils.getDayStart(new Date())).lt(DateUtils.getDayEnd(new Date()))); |
| | | Date yesterday = DateUtils.addDays(new Date(), -1); |
| | | Query query = new Query(Criteria.where("mongoCreateTime").gte(DateUtils.getDayStart(yesterday)).lt(DateUtils.getDayEnd(yesterday))); |
| | | List<MonitorQualifyResult> oneMachineFileResults = mongoTemplate.find(query, MonitorQualifyResult.class); |
| | | //mongo品牌数据 |
| | | Query OSDQuery = new Query(Criteria.where("mongoCreateTime").gte(DateUtils.getDayStart(yesterday)).lt(DateUtils.getDayEnd(yesterday))); |
| | | Map<String, OsdCheckResult> osdMap = mongoTemplate.find(query, OsdCheckResult.class).stream().collect(Collectors.toMap(OsdCheckResult::getDeviceNo, Function.identity())); |
| | | //数据库monitor表数据 |
| | | Map<String, TMonitorVO> monitorVOMap = monitorMapper.selectMonitorVOList().stream().collect(Collectors.toMap(TMonitorVO::getSerialNumber, Function.identity())); |
| | | //点位数据 |
| | |
| | | |
| | | //全年留存 |
| | | for (MonitorQualifyResult result : oneMachineFileResults) { |
| | | TMonitor monitor = getMonitor(result, monitorVOMap); |
| | | TMonitor monitor = getMonitor(result, monitorVOMap,osdMap); |
| | | YwPoint point = getPoint(result, pointMap, importantSite); |
| | | monitorList.add(monitor); |
| | | ywPointList.add(point); |
| | |
| | | if (!numbers.contains(key)){ |
| | | TMonitor monitor = new TMonitor(); |
| | | BeanUtils.copyProperties(value,monitor); |
| | | //填补品牌 |
| | | OsdCheckResult osdCheckResult = osdMap.get(key); |
| | | if(osdCheckResult!=null) { |
| | | monitor.setDeviceType(osdCheckResult.getDeviceBrand()); |
| | | } |
| | | monitorList.add(monitor); |
| | | } |
| | | }); |
| | |
| | | return ywPoint; |
| | | } |
| | | |
| | | private TMonitor getMonitor(MonitorQualifyResult result, Map<String, TMonitorVO> monitorVOMap) { |
| | | private TMonitor getMonitor(MonitorQualifyResult result, Map<String, TMonitorVO> monitorVOMap, Map<String, OsdCheckResult> osdMap) { |
| | | TMonitor monitor = new TMonitor(); |
| | | if (monitorVOMap.containsKey(result.getSerialNumber().getValue())) { |
| | | monitor.setId(monitorVOMap.get(result.getSerialNumber().getValue()).getId()); |
| | | monitor.setDeviceType(monitorVOMap.get(result.getSerialNumber().getValue()).getDeviceType()); |
| | | //更新品牌 |
| | | OsdCheckResult osdCheckResult = osdMap.get(result.getSerialNumber().getValue()); |
| | | if(osdCheckResult!=null) { |
| | | monitor.setDeviceType(osdCheckResult.getDeviceBrand()); |
| | | } |
| | | } |
| | | |
| | | monitor.setSerialNumber(result.getSerialNumber().getValue()); |