From db50acb5ecdd9a5aeb20a77f2d053ae2e14e888b Mon Sep 17 00:00:00 2001 From: fengyuan_yang <1976974459@qq.com> Date: Tue, 20 Oct 2026 16:34:45 +0800 Subject: [PATCH] =?UTF-8?q?2026-10-20=20=E5=AF=BC=E5=87=BA=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProductionReportController.java | 10 ++ .../Impl/ProductionReportServiceImpl.java | 125 ++++++++++++++++++ .../service/ProductionReportService.java | 2 + 3 files changed, 137 insertions(+) diff --git a/src/main/java/com/gaotao/modules/shopOrder/controller/ProductionReportController.java b/src/main/java/com/gaotao/modules/shopOrder/controller/ProductionReportController.java index 12d1ab2..1f41d84 100644 --- a/src/main/java/com/gaotao/modules/shopOrder/controller/ProductionReportController.java +++ b/src/main/java/com/gaotao/modules/shopOrder/controller/ProductionReportController.java @@ -13,6 +13,8 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -202,6 +204,14 @@ public class ProductionReportController { return map; } + /** + * 订单产出标签报表--导出(流式生成真实 xlsx) + */ + @PostMapping(value="/exportSfdcRollsReport") + public void exportSfdcRollsReport(@RequestBody SFDCRollsOutData indata, HttpServletResponse response) throws IOException { + productionReportService.exportSfdcRollsReport(indata, response); + } + /** * 订单产出标签报表--保存属性变更 * @param diff --git a/src/main/java/com/gaotao/modules/shopOrder/service/Impl/ProductionReportServiceImpl.java b/src/main/java/com/gaotao/modules/shopOrder/service/Impl/ProductionReportServiceImpl.java index 68f2224..1842f23 100644 --- a/src/main/java/com/gaotao/modules/shopOrder/service/Impl/ProductionReportServiceImpl.java +++ b/src/main/java/com/gaotao/modules/shopOrder/service/Impl/ProductionReportServiceImpl.java @@ -15,11 +15,20 @@ import com.gaotao.modules.shopOrder.entity.*; import com.gaotao.modules.shopOrder.entity.SfdcRollsReportExecuteData; import com.gaotao.modules.shopOrder.service.ProductionReportService; import com.gaotao.modules.sys.service.SysMsgService; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.xssf.streaming.SXSSFSheet; +import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.Map; @@ -244,4 +253,120 @@ public class ProductionReportServiceImpl implements ProductionReportService { return responseData; } + + @Override + public void exportSfdcRollsReport(SFDCRollsOutData indata, HttpServletResponse response) throws IOException { + if (indata == null) { + indata = new SFDCRollsOutData(); + } + indata.setPage(null); + indata.setLimit(null); + + String fileName = URLEncoder.encode( + "订单产出标签统计_" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()), + "UTF-8" + ).replace("+", "%20"); + + response.setCharacterEncoding(StandardCharsets.UTF_8.name()); + response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + fileName + ".xlsx"); + + SXSSFWorkbook workbook = new SXSSFWorkbook(500); + workbook.setCompressTempFiles(true); + SimpleDateFormat dateTimeFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + try { + SXSSFSheet sheet = workbook.createSheet("订单产出标签统计"); + int rowIndex = 0; + Row headerRow = sheet.createRow(rowIndex++); + fillSfdcRollsExportHeader(headerRow); + + List records = productionReportMapper.searchSfdcRollsReport(indata); + if (records != null) { + for (SFDCRollsOutData item : records) { + Row row = sheet.createRow(rowIndex++); + fillSfdcRollsExportRow(row, item, dateTimeFormatter); + } + } + sheet.flushRows(500); + workbook.write(response.getOutputStream()); + response.flushBuffer(); + } finally { + try { + workbook.close(); + } finally { + workbook.dispose(); + } + } + } + + private void fillSfdcRollsExportHeader(Row headerRow) { + String[] headers = new String[]{ + "卷标签", "卷数量", "良品数", "面损", "性能不良", "不良数", "良率", "总数", "Packing List", + "物料编码", "物料名称", "规格型号", "上级卷标签号", "上机卷标签类型", + "来源工单号", "来源派工单号", "来源工序号", "生产机台", "创建人", "创建时间", + "消耗工单号", "消耗派工单号", "消耗工序号", "消耗机台", "上机时间", "下机时间", + "标签类型", "状态", "标签备注" + }; + for (int i = 0; i < headers.length; i++) { + headerRow.createCell(i).setCellValue(headers[i]); + } + } + + private void fillSfdcRollsExportRow(Row row, SFDCRollsOutData item, SimpleDateFormat dateTimeFormatter) { + String[] values = new String[]{ + safeValue(item.getRollNo()), + safeValue(item.getRollQty()), + safeValue(item.getGoodQty()), + safeValue(item.getSurfaceLossQty()), + safeValue(item.getPoorPerformanceQty()), + safeValue(item.getDefectQty()), + safeValue(item.getYieldRate()), + safeValue(item.getTotalQty()), + safeValue(item.getPackingList()), + safeValue(item.getPartNo()), + safeValue(item.getPartDesc()), + safeValue(item.getSpec()), + safeValue(item.getParentRollNo()), + safeValue(item.getParentRollType()), + safeValue(item.getOrderNo()), + formatWholeNumber(item.getCreatedOpsSeqNo()), + formatWholeNumber(item.getCreatedOpsItemNo()), + safeValue(item.getProductionResourceID()), + safeValue(item.getCreatedby()), + formatDate(item.getCreatedDate(), dateTimeFormatter), + safeValue(item.getConsumeOrderNo()), + safeValue(item.getConsumeSeqNo()), + safeValue(item.getConsumeItemNo()), + safeValue(item.getConsumptionResourceID()), + formatDate(item.getDate1(), dateTimeFormatter), + formatDate(item.getDate2(), dateTimeFormatter), + safeValue(item.getRollType()), + safeValue(item.getFinalStatus()), + safeValue(item.getRemark()) + }; + for (int i = 0; i < values.length; i++) { + row.createCell(i).setCellValue(values[i]); + } + } + + private String formatWholeNumber(double value) { + if (value == (long) value) { + return String.valueOf((long) value); + } + return String.valueOf(value); + } + + private String formatDate(Date value, SimpleDateFormat formatter) { + if (value == null) { + return ""; + } + return formatter.format(value); + } + + private String safeValue(Object value) { + if (value == null) { + return ""; + } + return String.valueOf(value); + } } diff --git a/src/main/java/com/gaotao/modules/shopOrder/service/ProductionReportService.java b/src/main/java/com/gaotao/modules/shopOrder/service/ProductionReportService.java index d09368a..67206b9 100644 --- a/src/main/java/com/gaotao/modules/shopOrder/service/ProductionReportService.java +++ b/src/main/java/com/gaotao/modules/shopOrder/service/ProductionReportService.java @@ -120,6 +120,8 @@ public interface ProductionReportService { SFDCRollsOutData searchSfdcRollsReportSummary(SFDCRollsOutData indata); + void exportSfdcRollsReport(SFDCRollsOutData indata, javax.servlet.http.HttpServletResponse response) throws java.io.IOException; + void updateSfdcRollsAttribute(List indata); /**