From 5126a5c163b8c7b60a1ea3adff9e1758be50ea3f Mon Sep 17 00:00:00 2001 From: caojia <1301869380@qq.com> Date: Thu, 15 Oct 2026 18:45:09 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=E5=BA=94=E6=94=B6?= =?UTF-8?q?=E8=B4=A6=E5=8D=95=E5=BA=8F=E5=8F=B7=E6=A0=BC=E5=BC=8F=E5=B9=B6?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E7=99=BB=E5=BD=95=E9=BB=98=E8=AE=A4=E8=B4=A6?= =?UTF-8?q?=E5=8F=B7=E5=AF=86=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ar/service/impl/ArBillServiceImpl.java | 30 ++++++++++++++----- bms-front/src/views/login.vue | 4 +-- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/bms-back/bms-system/src/main/java/com/bms/ar/service/impl/ArBillServiceImpl.java b/bms-back/bms-system/src/main/java/com/bms/ar/service/impl/ArBillServiceImpl.java index 268d332f..f108455e 100644 --- a/bms-back/bms-system/src/main/java/com/bms/ar/service/impl/ArBillServiceImpl.java +++ b/bms-back/bms-system/src/main/java/com/bms/ar/service/impl/ArBillServiceImpl.java @@ -28,6 +28,7 @@ import java.util.zip.ZipInputStream; import java.util.zip.ZipOutputStream; import jakarta.servlet.http.HttpServletResponse; +import org.apache.poi.ss.usermodel.BuiltinFormats; import org.apache.poi.ss.usermodel.FillPatternType; import org.apache.poi.ss.usermodel.IndexedColors; import org.apache.poi.xssf.model.StylesTable; @@ -1281,11 +1282,19 @@ public class ArBillServiceImpl implements IArBillService { private void writeOoxmlWorkbook(ArBill bill, ArExportTemplate template, Path target) throws IOException { // 样式表单独读取;不加载整张工作簿,且不依赖 styles.xml 和 sheet1.xml 在 ZIP 中的先后顺序。 StylesTable styles = readExportStyles(template); + XSSFCellStyle detailNoStyle = styles.createCellStyle(); + detailNoStyle.cloneStyleFrom(styles.getStyleAt(TEMPLATE_DETAIL_STYLE_INDEX)); + detailNoStyle.setDataFormat(BuiltinFormats.getBuiltinFormat("0")); + int detailNoStyleIndex = Short.toUnsignedInt(detailNoStyle.getIndex()); XSSFCellStyle failedDetailStyle = styles.createCellStyle(); failedDetailStyle.cloneStyleFrom(styles.getStyleAt(TEMPLATE_DETAIL_STYLE_INDEX)); failedDetailStyle.setFillForegroundColor(IndexedColors.YELLOW.getIndex()); failedDetailStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); int failedDetailStyleIndex = Short.toUnsignedInt(failedDetailStyle.getIndex()); + XSSFCellStyle failedDetailNoStyle = styles.createCellStyle(); + failedDetailNoStyle.cloneStyleFrom(failedDetailStyle); + failedDetailNoStyle.setDataFormat(BuiltinFormats.getBuiltinFormat("0")); + int failedDetailNoStyleIndex = Short.toUnsignedInt(failedDetailNoStyle.getIndex()); try (InputStream input = openTemplateStream(template); ZipInputStream templateZip = new ZipInputStream(input); OutputStream fileOutput = Files.newOutputStream(target); ZipOutputStream output = new ZipOutputStream(fileOutput)) { boolean replaced = false; @@ -1293,7 +1302,8 @@ public class ArBillServiceImpl implements IArBillService { ZipEntry outputEntry = new ZipEntry(entry.getName()); output.putNextEntry(outputEntry); if (TEMPLATE_SHEET_XML.equals(entry.getName())) { - writeOoxmlSheet(readUtf8(templateZip), bill, output, failedDetailStyleIndex); + writeOoxmlSheet(readUtf8(templateZip), bill, output, failedDetailStyleIndex, + detailNoStyleIndex, failedDetailNoStyleIndex); replaced = true; } else if (TEMPLATE_STYLES_XML.equals(entry.getName())) { styles.writeTo(output); @@ -1352,8 +1362,8 @@ public class ArBillServiceImpl implements IArBillService { /** * 以 XML 流方式写入表头、分页明细和银行信息,避免 POI 在大数据量下移动行。 */ - private void writeOoxmlSheet(String templateXml, ArBill bill, OutputStream output, int failedDetailStyleIndex) - throws IOException { + private void writeOoxmlSheet(String templateXml, ArBill bill, OutputStream output, int failedDetailStyleIndex, + int detailNoStyleIndex, int failedDetailNoStyleIndex) throws IOException { int sheetDataStart = templateXml.indexOf("', sheetDataStart); int sheetDataEnd = templateXml.indexOf("", sheetDataOpenEnd); @@ -1386,7 +1396,8 @@ public class ArBillServiceImpl implements IArBillService { } attachFees(details); for (ArBillDetail detail : details) { - writeOoxmlDetailRow(output, rowIndex++, detail, failedDetailStyleIndex); + writeOoxmlDetailRow(output, rowIndex++, detail, failedDetailStyleIndex, + detailNoStyleIndex, failedDetailNoStyleIndex); } lastDetailNo = details.get(details.size() - 1).getDetailNo(); } @@ -1530,10 +1541,12 @@ public class ArBillServiceImpl implements IArBillService { } } - private void writeOoxmlDetailRow(OutputStream output, int rowNumber, ArBillDetail detail, int failedDetailStyleIndex) - throws IOException { + private void writeOoxmlDetailRow(OutputStream output, int rowNumber, ArBillDetail detail, int failedDetailStyleIndex, + int detailNoStyleIndex, int failedDetailNoStyleIndex) throws IOException { String failureDescription = exportBillingFailDescription(detail.getBillingFailStatus()); - int styleIndex = failureDescription.isEmpty() ? TEMPLATE_DETAIL_STYLE_INDEX : failedDetailStyleIndex; + boolean failedDetail = !failureDescription.isEmpty(); + int styleIndex = failedDetail ? failedDetailStyleIndex : TEMPLATE_DETAIL_STYLE_INDEX; + int sequenceStyleIndex = failedDetail ? failedDetailNoStyleIndex : detailNoStyleIndex; Object[] values = { detail.getDetailNo(), detail.getReceiveTime() == null ? "" : new SimpleDateFormat("yyyy-MM-dd").format(detail.getReceiveTime()), @@ -1549,7 +1562,8 @@ public class ArBillServiceImpl implements IArBillService { StringBuilder row = new StringBuilder(2048); row.append(""); for (int index = 0; index < TEMPLATE_COLUMN_COUNT; index++) { - appendOoxmlCell(row, (char) ('A' + index) + String.valueOf(rowNumber), values[index], styleIndex); + int cellStyleIndex = index == 0 ? sequenceStyleIndex : styleIndex; + appendOoxmlCell(row, (char) ('A' + index) + String.valueOf(rowNumber), values[index], cellStyleIndex); } row.append(""); writeUtf8(output, row.toString()); diff --git a/bms-front/src/views/login.vue b/bms-front/src/views/login.vue index f4b6398d..5ad1e8db 100644 --- a/bms-front/src/views/login.vue +++ b/bms-front/src/views/login.vue @@ -79,8 +79,8 @@ const router = useRouter() const { proxy } = getCurrentInstance() const loginForm = ref({ - username: "admin", - password: "admin123", + username: "", + password: "", rememberMe: false, code: "", uuid: ""