| | |
| | | import com.trafficaudit.reportexport.calc.MidCalc; |
| | | import com.trafficaudit.reportexport.calc.PaxCalc; |
| | | import com.trafficaudit.reportexport.calc.SummaryWorkbookFiller; |
| | | import com.trafficaudit.reportexport.calc.FreightReadinessCheck; |
| | | import com.trafficaudit.reportexport.layout.SummaryLayoutExpander; |
| | | import com.trafficaudit.reportexport.calc.WycSplitCalc; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | private SummaryWorkbookFiller summaryWorkbookFiller; |
| | | @Resource |
| | | private SummaryLayoutExpander summaryLayoutExpander; |
| | | @Resource |
| | | private FreightReadinessCheck freightReadinessCheck; |
| | | @Resource |
| | | private WycSplitCalc wycSplitCalc; |
| | | @Resource |
| | |
| | | } |
| | | } |
| | | |
| | | /** 只修正当期母版里 7 个标题页的标题文字(按母版期次重写,用于修复滞后标题)。 */ |
| | | public byte[] fixSummaryTitles(String period) throws Exception { |
| | | if (period == null || !period.contains("-")) { |
| | | throw new RuntimeException("标题修正仅支持按月,请指定 period=YYYY-MM"); |
| | | } |
| | | int year = Integer.parseInt(period.split("-")[0]); |
| | | int month = monthOf(period, "month"); |
| | | File mother = resolveSummaryMother(period, "month"); |
| | | if (mother == null) { |
| | | throw new RuntimeException("未找到汇总表母版(docs/生成汇总大表):" + year + "年" + month + "月道路运输量汇总表.xlsx"); |
| | | } |
| | | try (InputStream in = new FileInputStream(mother)) { |
| | | return summaryLayoutExpander.fixTitles(org.apache.poi.util.IOUtils.toByteArray(in), year, month); |
| | | } |
| | | } |
| | | |
| | | /** 生成_道路运输量汇总表.xlsx(P0-P1 骨架,支持 toMonth 裁剪): |
| | | * 以《YYYY年M月道路运输量汇总表.xlsx》(M 由 period 决定)为母版,按同期备份母版还原月度块; |
| | | * toMonth 非空且小于 M 时,把 8 个台账/合成页裁到 toMonth 月(toMonth+1..M 的当月值/同比列清空、保留表头, |
| | |
| | | int effMonth = (toMonth != null && toMonth > 0 && toMonth < month) ? toMonth : month; |
| | | List<String> dbProblems = new ArrayList<>(); |
| | | String effPeriod = String.format("%04d-%02d", year, effMonth); |
| | | dbProblems.addAll(freightReadinessCheck.check(effPeriod)); // B4:货运口径导出前体检(6 条规则) |
| | | reportProgress(progress, 22, "回填当月数据"); |
| | | int dbFilled = summaryWorkbookFiller.fillMonthlyLedger(wb, effPeriod, year, effMonth, dbProblems); |
| | | int yoyFilled = summaryWorkbookFiller.ensureMonthYoyFormulas(wb, year, effMonth); |