| | |
| | | public R exportDetail(@PathVariable("id") Long id) { |
| | | // 获取月结统计信息 |
| | | MonthlySettleStatisticsVO statistics = monthlySettleService.getSettleStatistics(id); |
| | | if (statistics == null || statistics.getDetails() == null) { |
| | | if (statistics == null) { |
| | | return R.error("月结明细不存在"); |
| | | } |
| | | |
| | | List<MonthlySettleDetail> details = statistics.getDetails(); |
| | | List<MonthlySettleDetail> details = statistics.getDetails() != null ? statistics.getDetails() : new ArrayList<>(); |
| | | List<com.zy.asrs.entity.result.MonthlySettleDetailFlowVO> detailFlows = statistics.getDetailFlows() != null ? statistics.getDetailFlows() : new ArrayList<>(); |
| | | |
| | | // 定义导出字段 |
| | | List<String> fields = new ArrayList<>(); |
| | | fields.add("matnr"); |
| | | fields.add("maktx"); |
| | | fields.add("batch"); |
| | | fields.add("brand"); |
| | | fields.add("beginningQty"); |
| | | fields.add("endingQty"); |
| | | fields.add("diffQty"); |
| | | fields.add("inQty"); |
| | | fields.add("outQty"); |
| | | // 定义明细流水导出字段 |
| | | List<String> flowFields = new ArrayList<>(); |
| | | flowFields.add("orderNo"); |
| | | flowFields.add("orderTime"); |
| | | flowFields.add("pakinPakoutStatusName"); |
| | | flowFields.add("matnr"); |
| | | flowFields.add("maktx"); |
| | | flowFields.add("batch"); |
| | | flowFields.add("brand"); |
| | | flowFields.add("specs"); |
| | | flowFields.add("qty"); |
| | | flowFields.add("unit"); |
| | | |
| | | return R.ok(exportSupport(details, fields)); |
| | | // 定义汇总导出字段 |
| | | List<String> summaryFields = new ArrayList<>(); |
| | | summaryFields.add("matnr"); |
| | | summaryFields.add("maktx"); |
| | | summaryFields.add("batch"); |
| | | summaryFields.add("brand"); |
| | | summaryFields.add("beginningQty"); |
| | | summaryFields.add("endingQty"); |
| | | summaryFields.add("diffQty"); |
| | | summaryFields.add("inQty"); |
| | | summaryFields.add("outQty"); |
| | | |
| | | // 构建返回数据结构:第一页是明细流水,第二页是汇总 |
| | | java.util.Map<String, Object> result = new java.util.HashMap<>(); |
| | | result.put("detailFlows", exportSupport(detailFlows, flowFields)); |
| | | result.put("details", exportSupport(details, summaryFields)); |
| | | result.put("flowTitles", new String[]{"订单编号", "业务时间", "类型", "物料编码", "物料名称", "批次", "品牌", "规格", "数量", "单位"}); |
| | | result.put("summaryTitles", new String[]{"物料编码", "物料名称", "批次", "品牌", "期初库存", "期末库存", "差异数量", "本期入库", "本期出库"}); |
| | | |
| | | return R.ok(result); |
| | | } |
| | | |
| | | } |