| | |
| | | import com.trafficaudit.dataimport.entity.WycTotalMonthly; |
| | | import com.trafficaudit.common.util.RegionUtil; |
| | | import com.trafficaudit.reportexport.calc.WycSplitCalc; |
| | | import com.trafficaudit.dataimport.service.CityRollupService; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import com.trafficaudit.dataimport.mapper.FreightTurnoverImportMapper; |
| | | import com.trafficaudit.dataimport.mapper.H2032EnterpriseMonthlyMapper; |
| | | import com.trafficaudit.dataimport.mapper.PassengerAuthVehicleMapper; |
| | |
| | | private WycTotalMonthlyMapper wycTotalMapper; |
| | | @Resource |
| | | private WycSplitCalc wycSplitCalc; |
| | | @Resource |
| | | private CityRollupService cityRollupService; |
| | | |
| | | @GetMapping("/list") |
| | | public Result<Map<String, Object>> list(@RequestParam("type") String type, |
| | |
| | | LambdaQueryWrapper<VehicleTrackMileage> w = new LambdaQueryWrapper<VehicleTrackMileage>() |
| | | .eq(notEmpty(period), VehicleTrackMileage::getReportPeriod, period) |
| | | .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 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 拆分口径计算) */ |
| | | private List<Map<String, Object>> wycOrderCityRows(WycOrderMonthly o) { |
| | | List<Map<String, Object>> rows = new ArrayList<>(); |
| | |
| | | rows.add(row); |
| | | } |
| | | return rows; |
| | | } |
| | | |
| | | /** 支持按市州汇总的数据类型 */ |
| | | @GetMapping("/rollupTypes") |
| | | public Result<List<Map<String, Object>>> rollupTypes() { |
| | | return Result.ok(cityRollupService.supportedTypes()); |
| | | } |
| | | |
| | | /** 按市州汇总(任意起止月) */ |
| | | @GetMapping("/summary") |
| | | public Result<Map<String, Object>> summary(@RequestParam("type") String type, |
| | | @RequestParam("from") String from, |
| | | @RequestParam("to") String to, |
| | | @RequestParam(value = "rankMode", defaultValue = "blank") String rankMode) { |
| | | return Result.ok(cityRollupService.summary(type, from, to, "recompute".equalsIgnoreCase(rankMode))); |
| | | } |
| | | |
| | | /** 按市州汇总导出 Excel(数值全精度,显示 2 位小数 / 百分比) */ |
| | | @GetMapping("/export") |
| | | public void export(@RequestParam("type") String type, |
| | | @RequestParam("from") String from, |
| | | @RequestParam("to") String to, |
| | | @RequestParam(value = "rankMode", defaultValue = "blank") String rankMode, |
| | | HttpServletResponse response) throws Exception { |
| | | byte[] bytes = cityRollupService.exportExcel(type, from, to, "recompute".equalsIgnoreCase(rankMode)); |
| | | String fileName = "按市州汇总_" + type + "_" + from + "_" + to + ".xlsx"; |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
| | | response.setCharacterEncoding("UTF-8"); |
| | | response.setHeader("Content-Disposition", |
| | | "attachment; filename=\"" + java.net.URLEncoder.encode(fileName, "UTF-8") + "\""); |
| | | response.setContentLength(bytes.length); |
| | | response.getOutputStream().write(bytes); |
| | | response.getOutputStream().flush(); |
| | | } |
| | | |
| | | private boolean notEmpty(String s) { |
| | |
| | | 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)); |