| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.trafficaudit.common.Result; |
| | | import com.trafficaudit.dataimport.entity.FreightTurnoverImport; |
| | | import com.trafficaudit.dataimport.entity.H202FreightVehicleOwnership; |
| | | import com.trafficaudit.dataimport.entity.H2032EnterpriseMonthly; |
| | | import com.trafficaudit.dataimport.entity.PassengerAuthVehicle; |
| | | import com.trafficaudit.dataimport.entity.CityBusMonthly; |
| | |
| | | import com.trafficaudit.dataimport.service.CityRollupService; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import com.trafficaudit.dataimport.mapper.FreightTurnoverImportMapper; |
| | | import com.trafficaudit.dataimport.mapper.H202FreightVehicleOwnershipMapper; |
| | | import com.trafficaudit.dataimport.mapper.H2032EnterpriseMonthlyMapper; |
| | | import com.trafficaudit.dataimport.mapper.PassengerAuthVehicleMapper; |
| | | import com.trafficaudit.dataimport.mapper.CityBusMonthlyMapper; |
| | |
| | | |
| | | @Resource |
| | | private H2032EnterpriseMonthlyMapper h2032Mapper; |
| | | @Resource |
| | | private H202FreightVehicleOwnershipMapper h202Mapper; |
| | | @Resource |
| | | private TransportAuthVehicleMapper transportAuthMapper; |
| | | @Resource |
| | |
| | | @RequestParam(value = "period", required = false) String period, |
| | | @RequestParam(value = "keyword", required = false) String keyword, |
| | | @RequestParam(value = "periodType", required = false) String periodType, |
| | | @RequestParam(value = "enterpriseCategory", required = false) String enterpriseCategory, |
| | | @RequestParam(value = "page", defaultValue = "1") long page, |
| | | @RequestParam(value = "size", defaultValue = "20") long size) { |
| | | String kw = keyword == null ? "" : keyword.trim(); |
| | | String trackCategory = enterpriseCategory == null ? "" : enterpriseCategory.trim(); |
| | | long safePage = Math.max(page, 1); |
| | | long safeSize = Math.min(Math.max(size, 1), 200); |
| | | |
| | |
| | | result.put("columns", columnsOf(type)); |
| | | |
| | | switch (type) { |
| | | case "h202": { |
| | | LambdaQueryWrapper<H202FreightVehicleOwnership> w = new LambdaQueryWrapper<H202FreightVehicleOwnership>() |
| | | .eq(notEmpty(period), H202FreightVehicleOwnership::getReportPeriod, period) |
| | | .and(!kw.isEmpty(), q -> q.like(H202FreightVehicleOwnership::getRegionName, kw) |
| | | .or().like(H202FreightVehicleOwnership::getItemName, kw) |
| | | .or().like(H202FreightVehicleOwnership::getItemCode, kw)) |
| | | .orderByAsc(H202FreightVehicleOwnership::getRegionName) |
| | | .orderByAsc(H202FreightVehicleOwnership::getItemCode); |
| | | Page<H202FreightVehicleOwnership> p = new Page<>(safePage, safeSize); |
| | | Page<H202FreightVehicleOwnership> r = h202Mapper.selectPage(p, w); |
| | | List<Map<String, Object>> rows = toMaps(r.getRecords(), propsOf(H202_COLUMNS)); |
| | | stringifyH202Decimals(rows); |
| | | result.put("records", rows); |
| | | fillPage(result, r); |
| | | break; |
| | | } |
| | | case "h2032": { |
| | | LambdaQueryWrapper<H2032EnterpriseMonthly> w = new LambdaQueryWrapper<H2032EnterpriseMonthly>() |
| | | .eq(notEmpty(period), H2032EnterpriseMonthly::getReportPeriod, period) |
| | |
| | | case "trackMileage": { |
| | | LambdaQueryWrapper<VehicleTrackMileage> w = new LambdaQueryWrapper<VehicleTrackMileage>() |
| | | .eq(notEmpty(period), VehicleTrackMileage::getReportPeriod, period) |
| | | .eq(isTrackCategory(trackCategory), VehicleTrackMileage::getEnterpriseCategory, trackCategory) |
| | | .like(!kw.isEmpty(), VehicleTrackMileage::getEnterpriseName, kw) |
| | | .orderByAsc(VehicleTrackMileage::getEnterpriseCategory) |
| | | .orderByDesc(VehicleTrackMileage::getId); |
| | | Page<VehicleTrackMileage> p = new Page<>(safePage, safeSize); |
| | | Page<VehicleTrackMileage> r = trackMileageMapper.selectPage(p, w); |
| | | result.put("records", toMaps(r.getRecords(), propsOf(TRACK_COLUMNS))); |
| | | List<Map<String, Object>> rows = toMaps(r.getRecords(), propsOf(TRACK_COLUMNS)); |
| | | translateTrackCategory(rows); |
| | | result.put("records", rows); |
| | | fillPage(result, r); |
| | | break; |
| | | } |
| | |
| | | return Result.ok(result); |
| | | } |
| | | |
| | | /** 区划代码 -> 市州名(无法识别返回空串) */ |
| | | /** Keep H202 decimal values as exact JSON strings instead of routing through JavaScript Number. */ |
| | | private void stringifyH202Decimals(List<Map<String, Object>> rows) { |
| | | String[] props = {"totalValue", "individualValue", "largeValue", "largeHeavyValue", |
| | | "largeHeavyIndividualValue", "largeIndividualValue", "mediumValue", |
| | | "mediumIndividualValue", "smallValue", "smallIndividualValue"}; |
| | | for (Map<String, Object> row : rows) { |
| | | for (String prop : props) { |
| | | Object value = row.get(prop); |
| | | if (value instanceof java.math.BigDecimal) { |
| | | String plain = ((java.math.BigDecimal) value).stripTrailingZeros().toPlainString(); |
| | | row.put(prop, "0".equals(plain) ? "0" : plain); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** \u533a\u5212\u4ee3\u7801 -> \u5e02\u5dde\u540d\uff08\u65e0\u6cd5\u8bc6\u522b\u8fd4\u56de\u7a7a\u4e32\uff09 */ |
| | | private String cityOf(String regionCode) { |
| | | if (regionCode == null || regionCode.trim().isEmpty()) return ""; |
| | | String city = RegionUtil.cityByCode(regionCode.trim()); |
| | |
| | | |
| | | private static double nz(Double v) { |
| | | return v == null ? 0.0 : v; |
| | | } |
| | | |
| | | private void translateTrackCategory(List<Map<String, Object>> rows) { |
| | | for (Map<String, Object> row : rows) { |
| | | Object value = row.get("enterpriseCategory"); |
| | | if (VehicleTrackMileage.CATEGORY_PASSENGER.equals(value)) { |
| | | row.put("enterpriseCategory", "两客企业"); |
| | | } else if (VehicleTrackMileage.CATEGORY_ABOVE_SCALE.equals(value)) { |
| | | row.put("enterpriseCategory", "规上企业"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** 网约车订单台账 -> 按市州竖排:全省 + 17 市州 × 指标(客运量/周转量由 WycSplitCalc 拆分口径计算) */ |
| | |
| | | return s != null && !s.trim().isEmpty(); |
| | | } |
| | | |
| | | private boolean isTrackCategory(String category) { |
| | | return VehicleTrackMileage.CATEGORY_ABOVE_SCALE.equals(category) |
| | | || VehicleTrackMileage.CATEGORY_PASSENGER.equals(category); |
| | | } |
| | | |
| | | private void fillPage(Map<String, Object> result, Page<?> r) { |
| | | result.put("total", r.getTotal()); |
| | | result.put("current", r.getCurrent()); |
| | |
| | | private List<Map<String, Object>> columnsOf(String type) { |
| | | switch (type) { |
| | | case "h2032": return H2032_COLUMNS; |
| | | case "h202": return H202_COLUMNS; |
| | | case "transportAuth": return AUTH_COLUMNS; |
| | | case "trackMileage": return TRACK_COLUMNS; |
| | | case "scaleSplit": return SPLIT_COLUMNS; |
| | |
| | | } |
| | | |
| | | private static final List<Map<String, Object>> H2032_COLUMNS = new ArrayList<>(); |
| | | private static final List<Map<String, Object>> H202_COLUMNS = new ArrayList<>(); |
| | | private static final List<Map<String, Object>> AUTH_COLUMNS = new ArrayList<>(); |
| | | private static final List<Map<String, Object>> TRACK_COLUMNS = new ArrayList<>(); |
| | | private static final List<Map<String, Object>> SPLIT_COLUMNS = new ArrayList<>(); |
| | |
| | | private static final List<Map<String, Object>> WYC_ORDER_COLUMNS = new ArrayList<>(); |
| | | |
| | | static { |
| | | H2032_COLUMNS.add(col("reportPeriod", "报表期", 100)); |
| | | H202_COLUMNS.add(col("reportPeriod", "\u62a5\u8868\u671f", 100)); |
| | | H202_COLUMNS.add(col("regionName", "\u5730\u533a", 120)); |
| | | H202_COLUMNS.add(col("reportDate", "\u62a5\u8868\u65e5\u671f", 110)); |
| | | H202_COLUMNS.add(col("itemCode", "\u6307\u6807\u4ee3\u7801", 90)); |
| | | H202_COLUMNS.add(col("itemName", "\u6307\u6807\u540d\u79f0", 240)); |
| | | H202_COLUMNS.add(col("unit", "\u8ba1\u91cf\u5355\u4f4d", 90)); |
| | | H202_COLUMNS.add(col("totalValue", "\u603b\u8ba1", 130)); |
| | | H202_COLUMNS.add(col("individualValue", "\u4e2a\u4f53", 130)); |
| | | H202_COLUMNS.add(col("largeValue", "\u5927\u578b", 120)); |
| | | H202_COLUMNS.add(col("largeHeavyValue", "\u5927\u578b-\u91cd\u578b", 130)); |
| | | H202_COLUMNS.add(col("largeHeavyIndividualValue", "\u5927\u578b-\u91cd\u578b-\u4e2a\u4f53", 160)); |
| | | H202_COLUMNS.add(col("largeIndividualValue", "\u5927\u578b-\u4e2a\u4f53", 130)); |
| | | H202_COLUMNS.add(col("mediumValue", "\u4e2d\u578b", 120)); |
| | | H202_COLUMNS.add(col("mediumIndividualValue", "\u4e2d\u578b-\u4e2a\u4f53", 130)); |
| | | H202_COLUMNS.add(col("smallValue", "\u5c0f\u578b", 120)); |
| | | H202_COLUMNS.add(col("smallIndividualValue", "\u5c0f\u578b-\u4e2a\u4f53", 130)); |
| | | H2032_COLUMNS.add(col("reportPeriod", "\u62a5\u8868\u671f", 100)); |
| | | H2032_COLUMNS.add(col("regionCode", "所属地区", 100)); |
| | | H2032_COLUMNS.add(col("city", "市州", 110)); |
| | | H2032_COLUMNS.add(col("enterpriseCode", "企业代码", 130)); |
| | |
| | | AUTH_COLUMNS.add(col("otherTons", "其他吨位(吨)", 120)); |
| | | |
| | | TRACK_COLUMNS.add(col("reportPeriod", "报表期", 100)); |
| | | TRACK_COLUMNS.add(col("enterpriseCategory", "企业类别", 110)); |
| | | TRACK_COLUMNS.add(col("enterpriseName", "企业名称", 240)); |
| | | TRACK_COLUMNS.add(col("monthlyMileage", "月度里程(公里)", 130)); |
| | | TRACK_COLUMNS.add(col("trackedVehicles", "轨迹车辆数(辆)", 130)); |
| | | TRACK_COLUMNS.add(col("anomalyMileage", "异常里程(公里)", 130)); |
| | | |
| | | SPLIT_COLUMNS.add(col("reportPeriod", "报表期", 100)); |
| | | SPLIT_COLUMNS.add(col("periodType", "口径", 90)); |
| | |
| | | WYC_ORDER_COLUMNS.add(col("note", "说明", 200)); |
| | | |
| | | } |
| | | } |
| | | } |