| | |
| | | * 更新或新增 |
| | | */ |
| | | @Component |
| | | public class CarSiteOnlineCalculation implements CalculationStrategy<SnapshotDataMonitorResult> { |
| | | public class CarSiteOnlineCalculation extends IndexCalculationServe implements CalculationStrategy<SnapshotDataMonitorResult> { |
| | | @Autowired |
| | | private CheckIndexCarMapper checkIndexCarMapper; |
| | | @Autowired |
| | |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | return; |
| | | } |
| | | Map<String, AreaStats> areaStatsMap = new HashMap<>(); |
| | | |
| | | //获得国标码为key的设备map |
| | | Map<String, TMonitor> monitorMap = monitorService.list(new QueryWrapper<TMonitor>() |
| | | .in("serial_number", list.stream().map(SnapshotDataMonitorResult::getExternalIndexCode).collect(Collectors.toList()))) |
| | | .stream().collect(Collectors.toMap(TMonitor::getSerialNumber, Function.identity())); |
| | | //获取省厅国标码集合 |
| | | List<String> provinceIds = getProvince(); |
| | | |
| | | // TODO: 分省厅市局 需要补充集合数据 |
| | | List<String> provinceIds = new ArrayList<>(); // 这里需要根据点位补充 |
| | | |
| | | Map<String, AreaStats> areaStatsMap = new HashMap<>(); |
| | | for (SnapshotDataMonitorResult result : list) { |
| | | TMonitor monitor = monitorMap.get(result.getExternalIndexCode()); |
| | | if (monitor == null) continue; |
| | |
| | | |
| | | /** 车辆点位在线率和视图库对接稳定性 */ |
| | | private CheckIndexCar createOrUpdateCheckIndexCar(String key, AreaStats stats, BigDecimal cityCountAvg, BigDecimal countyCountAvg, List<CheckIndexCar> checkIndexCarList) { |
| | | CheckIndexCar checkIndexCar; |
| | | |
| | | // 检查是否已存在今日数据 |
| | | Optional<CheckIndexCar> existingCar = checkIndexCarList.stream() |
| | | .filter(car -> key.equals(car.getDeptId().toString()) && |
| | | (key.startsWith("Province_") ? CheckConstants.Examine_Tag_City.equals(car.getExamineTag()) |
| | | : CheckConstants.Examine_Tag_County.equals(car.getExamineTag()))) |
| | | .findFirst(); |
| | | |
| | | if (existingCar.isPresent()) { |
| | | checkIndexCar = existingCar.get(); |
| | | } else { |
| | | checkIndexCar = new CheckIndexCar(); |
| | | checkIndexCar.setDeptId(key.startsWith("Province_") ? Long.parseLong(key.split("_")[1]) : Long.parseLong(key)); |
| | | checkIndexCar.setExamineTag(key.startsWith("Province_") ? CheckConstants.Examine_Tag_City : CheckConstants.Examine_Tag_County); |
| | | checkIndexCar.setCreateTime(new Date()); |
| | | } |
| | | CheckIndexCar checkIndexCar = getCheckIndex(key, checkIndexCarList); |
| | | //调用点位在线计算方法 |
| | | Map<String, Object> siteOnlineParam = new HashMap<>(); |
| | | siteOnlineParam.put("totalSites", stats.totalSites); |
| | | siteOnlineParam.put("offlineSites", stats.offlineSites); |
| | | BigDecimal siteOnline = IndexCalculationUtils.siteOnline(siteOnlineParam); |
| | | BigDecimal siteOnline = siteOnline(siteOnlineParam); |
| | | checkIndexCar.setSiteOnline(siteOnline); |
| | | //视图库对接稳定性 |
| | | BigDecimal avgCount = key.startsWith("Province_") ? cityCountAvg : countyCountAvg; |
| | | Map<String, Object> viewConnectParam = new HashMap<>(); |
| | | viewConnectParam.put("totalDataSum", stats.totalDataSum); |
| | | viewConnectParam.put("avgCount", avgCount); |
| | | BigDecimal viewConnectStability = IndexCalculationUtils.viewConnectStability(viewConnectParam); |
| | | BigDecimal viewConnectStability = viewConnectStability(viewConnectParam); |
| | | checkIndexCar.setViewConnectStability(viewConnectStability); |
| | | return checkIndexCar; |
| | | } |