| | |
| | | } |
| | | break; |
| | | } |
| | | case "investPassengerDetail": |
| | | case "investLogisticsDetail": { |
| | | boolean paxDetail = "investPassengerDetail".equals(t); |
| | | String catName = paxDetail ? "客运站场" : "物流园区"; |
| | | String catLabel = paxDetail ? "客运站场投资月报" : "物流园区投资月报"; |
| | | List<InvestmentProject> catProjects = investProjectMapper.selectList( |
| | | new LambdaQueryWrapper<InvestmentProject>().eq(InvestmentProject::getCategory, catName)); |
| | | final List<Long> catIds = new ArrayList<>(); |
| | | for (InvestmentProject cp : catProjects) catIds.add(cp.getId()); |
| | | if (catIds.isEmpty()) { |
| | | rows = 0; |
| | | notes.add("缺数据:" + catLabel); |
| | | } else { |
| | | rows = addReadyCount(() -> investMonthlyMapper.selectCount( |
| | | periodQw(period, mode, InvestmentMonthly::getReportPeriod) |
| | | .in(InvestmentMonthly::getProjectId, catIds)), catLabel, notes); |
| | | } |
| | | String detTpl = paxDetail ? "模板_X月客运站投资明细表.xlsx" : "模板_X月物流站场投资明细.xls"; |
| | | try { |
| | | if (resolveAnyTemplate(investTemplateDir, detTpl) == null) { |
| | | rows = 0; |
| | | notes.add("docs/投资/模板 下缺少《" + detTpl + "》"); |
| | | } |
| | | } catch (Exception ex) { |
| | | rows = 0; |
| | | notes.add("母版定位失败:" + ex.getMessage()); |
| | | } |
| | | auditTypes.add("INVEST"); |
| | | break; |
| | | } |
| | | default: |
| | | rows = 0; |
| | | notes.add("未知报表类型:" + t); |
| | |
| | | coverage.addAll(investCover); |
| | | // 投资为当月报表(无 1..N 累计口径),只提示当月缺失 |
| | | if (!investCover.contains(month)) missing.add(month); |
| | | investPreview(period, mode, summary, problems); |
| | | if ("investPassengerDetail".equals(t)) investPreview(period, mode, "客运站场", summary, problems); |
| | | else if ("investLogisticsDetail".equals(t)) investPreview(period, mode, "物流园区", summary, problems); |
| | | else investPreview(period, mode, summary, problems); |
| | | } else if ("energySummary".equals(t)) { |
| | | Long ec = energyMapper.selectCount(periodQw(period, mode, EnergyVehicleQuarterly::getReportPeriod)); |
| | | if (ec != null && ec > 0) coverage.add(month); |
| | |
| | | } |
| | | |
| | | private boolean isInvestType(String t) { |
| | | return "investPlan".equals(t) || "investFiveYearLogistics".equals(t) || "investBillion".equals(t) || "investCounty".equals(t); |
| | | return "investPlan".equals(t) || "investFiveYearLogistics".equals(t) || "investBillion".equals(t) || "investCounty".equals(t) |
| | | || "investPassengerDetail".equals(t) || "investLogisticsDetail".equals(t); |
| | | } |
| | | |
| | | private boolean isEnergyType(String t) { |
| | |
| | | if (allZero) problems.add("全省累计值全为 0(公交/出租月报可能未导入)"); |
| | | } |
| | | |
| | | /** 投资摘要:项目数 + 本月完成/自年初/自开始累计 */ |
| | | /** 投资摘要:项目数 + 本月完成/自年初/自开始累计(全投资月报合计,不分类别) */ |
| | | private void investPreview(String period, String mode, List<Map<String, Object>> summary, List<String> problems) { |
| | | List<InvestmentMonthly> list = investMonthlyMapper.selectList(periodQw(period, mode, InvestmentMonthly::getReportPeriod)); |
| | | investPreview(period, mode, null, summary, problems); |
| | | } |
| | | |
| | | /** 投资摘要(category 非空时只统计该类别,如客运站场/物流园区投资明细表) */ |
| | | private void investPreview(String period, String mode, String category, List<Map<String, Object>> summary, List<String> problems) { |
| | | LambdaQueryWrapper<InvestmentMonthly> qw = periodQw(period, mode, InvestmentMonthly::getReportPeriod); |
| | | if (category != null) { |
| | | List<InvestmentProject> ps = investProjectMapper.selectList( |
| | | new LambdaQueryWrapper<InvestmentProject>().eq(InvestmentProject::getCategory, category)); |
| | | List<Long> ids = new ArrayList<>(); |
| | | for (InvestmentProject p : ps) ids.add(p.getId()); |
| | | if (ids.isEmpty()) { problems.add("缺数据:库内没有「" + category + "」项目主档"); return; } |
| | | qw.in(InvestmentMonthly::getProjectId, ids); |
| | | } |
| | | List<InvestmentMonthly> list = investMonthlyMapper.selectList(qw); |
| | | Set<Long> proj = new HashSet<>(); |
| | | double monthDone = 0.0, yearCum = 0.0, startCum = 0.0; |
| | | for (InvestmentMonthly m : list) { |
| | |
| | | int dbFilled = summaryWorkbookFiller.fillMonthlyLedger(wb, effPeriod, year, effMonth, dbProblems); |
| | | int yoyFilled = summaryWorkbookFiller.ensureMonthYoyFormulas(wb, year, effMonth); |
| | | int monthFormulaFilled = summaryWorkbookFiller.ensureMonthFormulas(wb, year, effMonth); |
| | | // 累计同比分母修正:母版把「去年各月」与「去年1-M月累计」辅助列同时计入(重复计/漏当月) |
| | | int cumYoyFixed = summaryWorkbookFiller.repairCumulativeYoyFormulas(wb, year, effMonth); |
| | | int rankRefreshed = refreshSummaryRankSheets(wb, effPeriod, "month"); |
| | | int cumulativeRefreshed = refreshSummaryCumulativeSheets(wb, year, effMonth); // 四张跨页合成页随报表期刷新 |
| | | int widthApplied = applySummaryReferenceLayout(wb); |
| | | log.info("汇总工作簿数据驱动回填完成:写入当月值格数={},补写当月同比公式格数={},补写当月合计公式格数={}," |
| | | + "刷新排名页数值格数={},刷新四页(城市汇总/城市分市州/中口径分析/道路运输周转量)数值格数={}," |
| | | + "修正累计同比分母格数={},刷新排名页数值格数={},刷新四页(城市汇总/城市分市州/中口径分析/道路运输周转量)数值格数={}," |
| | | + "按《生成_道路运输量汇总表》对齐列宽列数={},缺数提示={}", |
| | | dbFilled, yoyFilled, monthFormulaFilled, rankRefreshed, cumulativeRefreshed, widthApplied, dbProblems); |
| | | dbFilled, yoyFilled, monthFormulaFilled, cumYoyFixed, rankRefreshed, cumulativeRefreshed, widthApplied, dbProblems); |
| | | applyTwoDecimalFormat(wb); // 数值显示两位小数(保留全精度);% / 日期等既有样式不改变 |
| | | int inlineFixed = normalizeStaleInlineStrings(wb); // 清掉「非 inlineStr 却残留 <is>」的非法格,否则 Excel 拒绝打开 |
| | | if (inlineFixed > 0) log.warn("汇总工作簿清掉残留 inlineStr 非法格 {} 个(母版由 openpyxl 写出时的典型问题)", inlineFixed); |
| | |
| | | hssfText(row, 0, "合计"); |
| | | InvestAgg prov = new InvestAgg(); |
| | | for (InvestmentMonthly m : monthlies) prov.add(m, pmap.get(m.getProjectId())); |
| | | addProjectsWithoutMonthly(prov, projects, mByProject, null, null); |
| | | writeInvestAggHssf(row, prov); |
| | | continue; |
| | | } |
| | |
| | | InvestmentProject p = pmap.get(m.getProjectId()); |
| | | if (p != null && blockCategory.equals(p.getCategory())) agg.add(m, p); |
| | | } |
| | | addProjectsWithoutMonthly(agg, projects, mByProject, blockCategory, null); |
| | | writeInvestAggHssf(row, agg); |
| | | seq = 0; |
| | | continue; |
| | |
| | | if (p != null && city.equals(p.getCity()) |
| | | && (blockCategory == null || blockCategory.equals(p.getCategory()))) agg.add(m, p); |
| | | } |
| | | addProjectsWithoutMonthly(agg, projects, mByProject, blockCategory, city); |
| | | writeInvestAggHssf(row, agg); |
| | | continue; |
| | | } |
| | |
| | | if (agg.yearPlan > 0) hssfNum(row, 23, agg.yearCum / agg.yearPlan); |
| | | } |
| | | |
| | | /** |
| | | * 补计「本期没有月度记录、但项目主档有总投资」的项目(只计总投资这一列)。 |
| | | * 场景:某市州本月未报送单表(如武汉 8 月物流),主档里项目仍在,若不补计,该市州小计/合计会整块为空。 |
| | | * |
| | | * @param category 块类别(客运站场/物流园区);null 表示不限 |
| | | * @param city 市州全称(如 武汉市);null 表示不限 |
| | | */ |
| | | private void addProjectsWithoutMonthly(InvestAgg agg, List<InvestmentProject> projects, |
| | | Map<Long, InvestmentMonthly> mByProject, |
| | | String category, String city) { |
| | | for (InvestmentProject p : projects) { |
| | | if (p == null || mByProject.containsKey(p.getId())) continue; |
| | | if (category != null && !category.equals(p.getCategory())) continue; |
| | | if (city != null && !city.equals(p.getCity())) continue; |
| | | if (p.getTotalInvestment() != null) agg.total += p.getTotalInvestment(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | // ==================== 投资模块:客运站投资明细表 / 物流站场投资明细(模板底稿原位替换) ==================== |