| | |
| | | import constant.ApiConstants; |
| | | import constant.CheckConstants; |
| | | import constant.CheckSnapCountConstants; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.CollectionUtils; |
| | |
| | | * 更新或新增 |
| | | */ |
| | | @Component |
| | | @Slf4j |
| | | public class CarSnapshotDelayCalculation extends IndexCalculationServe implements CalculationStrategy<SnapshotDelayMonitorResult> { |
| | | @Autowired |
| | | private CheckIndexCarMapper checkIndexCarMapper; |
| | |
| | | //区域车辆点位在线指标的内部类 |
| | | private static class AreaStats { |
| | | int totalCount = 0; |
| | | int delayCount = 0; |
| | | //0-180s |
| | | int delayCount1 = 0; |
| | | //180-300s |
| | |
| | | @Override |
| | | public void calculate(List<SnapshotDelayMonitorResult> list) { |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | log.info("数据为空"); |
| | | return; |
| | | } |
| | | |
| | |
| | | //返回对象的引用,如果不存在会放入新的key,value |
| | | AreaStats stats = areaStatsMap.computeIfAbsent(key, k -> new AreaStats()); |
| | | stats.totalCount += result.getDataCount(); |
| | | stats.delayCount += result.getDelayCount(); |
| | | stats.delayCount1 += result.getDataDelayCount1(); |
| | | stats.delayCount2 += result.getDataDelayCount2(); |
| | | stats.delayCount3 += result.getDataDelayCount3(); |
| | |
| | | //调用抓拍上传及时性计算方法 |
| | | Map<String, Object> param = new HashMap<>(); |
| | | param.put("totalCount", stats.totalCount); |
| | | param.put("delayCount", stats.delayCount); |
| | | param.put("delayCount1", stats.delayCount1); |
| | | param.put("delayCount2", stats.delayCount2); |
| | | param.put("delayCount3", stats.delayCount3); |
| | | BigDecimal index = snapshopDelay(param); |
| | | checkIndexCar.setSiteOnline(index); |
| | | checkIndexCar.setVehicleUploadTimeliness(index); |
| | | return checkIndexCar; |
| | | } |
| | | } |