From 34981c30a78e8bbd7791131059a9210f9928b62c Mon Sep 17 00:00:00 2001
From: 刘光辉 <347230014@qq.com>
Date: 星期四, 17 九月 2026 09:24:09 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master' into master
---
jnpf-lims/jnpf-lims-controller/src/test/java/jnpf/limsController/export/LimsWendingxingFenxiWorkbookBuilderTest.java | 67 +++++++++++++++++++++++++++++++++
1 files changed, 67 insertions(+), 0 deletions(-)
diff --git a/jnpf-lims/jnpf-lims-controller/src/test/java/jnpf/limsController/export/LimsWendingxingFenxiWorkbookBuilderTest.java b/jnpf-lims/jnpf-lims-controller/src/test/java/jnpf/limsController/export/LimsWendingxingFenxiWorkbookBuilderTest.java
new file mode 100644
index 0000000..5efeceb
--- /dev/null
+++ b/jnpf-lims/jnpf-lims-controller/src/test/java/jnpf/limsController/export/LimsWendingxingFenxiWorkbookBuilderTest.java
@@ -0,0 +1,67 @@
+package jnpf.limsController.export;
+
+import jnpf.base.entity.DictionaryDataEntity;
+import jnpf.limsEntity.LimsWendingxingFenxiRowVo;
+import org.apache.poi.ss.usermodel.CellType;
+import org.apache.poi.ss.usermodel.DataFormatter;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.junit.Test;
+
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Collections;
+
+import static org.junit.Assert.assertEquals;
+
+public class LimsWendingxingFenxiWorkbookBuilderTest {
+
+ private final DataFormatter formatter = new DataFormatter();
+
+ @Test
+ public void formatsPeriodDateAndDictionaryUnit() throws Exception {
+ LimsWendingxingFenxiRowVo source = row("18.000000000000000", "month");
+ DictionaryDataEntity month = new DictionaryDataEntity();
+ month.setEnCode("month");
+ month.setFullName("鏈�");
+
+ try (Workbook workbook = new LimsWendingxingFenxiWorkbookBuilder()
+ .build(Collections.singletonList(source), Collections.singletonList(month))) {
+ Row exported = workbook.getSheetAt(0).getRow(1);
+ assertEquals(CellType.NUMERIC, exported.getCell(0).getCellType());
+ assertEquals("0", formatter.formatCellValue(exported.getCell(0)));
+ assertEquals("2026-07-30", formatter.formatCellValue(exported.getCell(4)));
+ assertEquals(CellType.NUMERIC, exported.getCell(5).getCellType());
+ assertEquals("18", formatter.formatCellValue(exported.getCell(5)));
+ assertEquals("鏈�", exported.getCell(6).getStringCellValue());
+ assertEquals("6.70", exported.getCell(8).getStringCellValue());
+ assertEquals("7.0", exported.getCell(9).getStringCellValue());
+ }
+ }
+
+ @Test
+ public void usesSlashForBaselineAndPreservesUnknownUnit() throws Exception {
+ try (Workbook workbook = new LimsWendingxingFenxiWorkbookBuilder().build(
+ Arrays.asList(row("0.000", "month"), row("3", "custom_unit")),
+ Collections.<DictionaryDataEntity>emptyList())) {
+ assertEquals("/", workbook.getSheetAt(0).getRow(1).getCell(6).getStringCellValue());
+ assertEquals("custom_unit", workbook.getSheetAt(0).getRow(2).getCell(6).getStringCellValue());
+ }
+ }
+
+ private LimsWendingxingFenxiRowVo row(String period, String periodUnit) throws Exception {
+ LimsWendingxingFenxiRowVo row = new LimsWendingxingFenxiRowVo();
+ row.setYangpinMingcheng("闃胯帿瑗挎灄鑳跺泭");
+ row.setJihuaBianhao("AMXLJN-001");
+ row.setPihao("AMXLJN-001-01");
+ row.setJieguoLuruRiqi(new SimpleDateFormat("yyyy-MM-dd").parse("2026-07-30"));
+ row.setZhouqi(period);
+ row.setZhouqiDanwei(periodUnit);
+ row.setXiangmuMingcheng("pH鍊�");
+ row.setRawResult("6.70");
+ row.setShangxian("7.0");
+ row.setXiaxian("5.0");
+ row.setUnit("/");
+ return row;
+ }
+}
--
Gitblit v1.8.0