| | |
| | | BigDecimal nationalProvincial = vehicle.get(HolidayConstants.ROAD_NATIONAL_PROVINCIAL); |
| | | BigDecimal comparisonBase = comparisonBaseByDate.get(day.getHolidayDate()); |
| | | BigDecimal nationalProvincialRingRatio = nationalProvincialRingRatio( |
| | | year, nationalProvincial, previousNationalProvincial, comparisonBase); |
| | | nationalProvincial, previousNationalProvincial); |
| | | BigDecimal nonBusinessPersonFlow = null; |
| | | if (coefficient != null && (expressway != null || nationalProvincial != null)) { |
| | | nonBusinessPersonFlow = HolidayNumberUtils.multiply( |
| | |
| | | } |
| | | } |
| | | if (target == null) return null; |
| | | return dailyMetrics(year, holidayType, dayIndex, target.getHolidayDate()); |
| | | } |
| | | |
| | | public DailyMetrics dailyMetricsByDate(LocalDate date) { |
| | | if (date == null) return null; |
| | | return dailyMetrics(date.getYear(), null, 0, date); |
| | | } |
| | | |
| | | private DailyMetrics dailyMetrics(int year, String holidayType, int dayIndex, LocalDate date) { |
| | | Map<LocalDate, Map<String, BigDecimal>> passengerByDate = loadPassengerByDate(year); |
| | | Map<LocalDate, Map<String, BigDecimal>> vehicleByDate = loadVehicleByDate(year); |
| | | Map<LocalDate, BigDecimal> comparisonBaseByDate = loadComparisonBaseByDate(year); |
| | | Map<String, BigDecimal> passenger = passengerByDate.getOrDefault(target.getHolidayDate(), Collections.emptyMap()); |
| | | Map<String, BigDecimal> vehicle = vehicleByDate.getOrDefault(target.getHolidayDate(), Collections.emptyMap()); |
| | | Map<String, BigDecimal> passenger = passengerByDate.getOrDefault(date, Collections.emptyMap()); |
| | | Map<String, BigDecimal> vehicle = vehicleByDate.getOrDefault(date, Collections.emptyMap()); |
| | | BigDecimal coefficient = configService.coefficientOf(year, HolidayConstants.CATEGORY_HOLIDAY); |
| | | BigDecimal expressway = vehicle.get(HolidayConstants.ROAD_EXPRESSWAY); |
| | | BigDecimal nationalProvincial = vehicle.get(HolidayConstants.ROAD_NATIONAL_PROVINCIAL); |
| | | BigDecimal comparisonBase = comparisonBaseByDate.get(target.getHolidayDate()); |
| | | BigDecimal comparisonBase = comparisonBaseByDate.get(date); |
| | | BigDecimal nonBusiness = null; |
| | | if (coefficient != null && (expressway != null || nationalProvincial != null)) { |
| | | nonBusiness = HolidayNumberUtils.multiply( |
| | |
| | | metrics.setYear(year); |
| | | metrics.setHolidayType(holidayType); |
| | | metrics.setDayIndex(dayIndex); |
| | | metrics.setDate(target.getHolidayDate()); |
| | | metrics.setDate(date); |
| | | metrics.setRail(passenger.get(HolidayConstants.MODE_RAIL)); |
| | | metrics.setCivilAviation(passenger.get(HolidayConstants.MODE_CIVIL_AVIATION)); |
| | | metrics.setRoad(passenger.get(HolidayConstants.MODE_ROAD)); |
| | |
| | | return total; |
| | | } |
| | | |
| | | private BigDecimal nationalProvincialRingRatio(int year, BigDecimal current, |
| | | BigDecimal previous, BigDecimal comparisonBase) { |
| | | // The national/provincial ring ratio always compares the current day with the previous day of |
| | | // the same year. The stored comparison base (Excel column C) is kept as an operator backup |
| | | // value only and never feeds this calculation. |
| | | private BigDecimal nationalProvincialRingRatio(BigDecimal current, BigDecimal previous) { |
| | | if (current == null) return null; |
| | | if (HolidayConstants.supportsComparisonBase(year) && comparisonBase != null) { |
| | | return ratio(current, comparisonBase); |
| | | } |
| | | return previous == null ? null : ratio(current, previous); |
| | | } |
| | | |