diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/NumUtil.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/NumUtil.java new file mode 100644 index 00000000..00ebfb09 --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/NumUtil.java @@ -0,0 +1,20 @@ +package org.jeecg.common.util; + +import cn.hutool.core.util.ObjectUtil; +import java.math.BigDecimal; +import java.math.RoundingMode; + +public class NumUtil { + + public static Double fixedMax(int bit, Double value){ + if (ObjectUtil.isNull(value)) + return value; + // 获取整数位数 + int length = String.valueOf(value).split("\\.")[0].length(); + if (length >= bit) + return value; + int scale = bit - length; + BigDecimal decimal = new BigDecimal(value); + return decimal.setScale(scale, RoundingMode.HALF_UP).doubleValue(); + } +} diff --git a/jeecg-boot-base-core/src/main/resources/excelTemplate/QcResult-B.xls b/jeecg-boot-base-core/src/main/resources/excelTemplate/QcResult-B.xls index 0576a78f..98a27e6f 100644 Binary files a/jeecg-boot-base-core/src/main/resources/excelTemplate/QcResult-B.xls and b/jeecg-boot-base-core/src/main/resources/excelTemplate/QcResult-B.xls differ diff --git a/jeecg-boot-base-core/src/main/resources/excelTemplate/SampleInformation-B.xls b/jeecg-boot-base-core/src/main/resources/excelTemplate/SampleInformation-B.xls index f9c83821..4e38979c 100644 Binary files a/jeecg-boot-base-core/src/main/resources/excelTemplate/SampleInformation-B.xls and b/jeecg-boot-base-core/src/main/resources/excelTemplate/SampleInformation-B.xls differ diff --git a/jeecg-boot-base-core/src/main/resources/excelTemplate/SampleInformation-G.xls b/jeecg-boot-base-core/src/main/resources/excelTemplate/SampleInformation-G.xls index 21694ff3..5e1f1497 100644 Binary files a/jeecg-boot-base-core/src/main/resources/excelTemplate/SampleInformation-G.xls and b/jeecg-boot-base-core/src/main/resources/excelTemplate/SampleInformation-G.xls differ diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java index d705a233..161032b8 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java @@ -5,6 +5,7 @@ import cn.hutool.core.collection.ListUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.io.FileUtil; import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ReUtil; import cn.hutool.core.util.StrUtil; @@ -47,6 +48,7 @@ import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; +import java.text.DecimalFormat; import java.text.ParseException; import java.time.LocalDateTime; import java.util.*; @@ -1865,7 +1867,7 @@ public class GammaServiceImpl implements IGammaService { } item.setName(name); item.setFlag(iter.getValue().isBPass() ? "PASS" : "FAIL"); - item.setValue(iter.getValue().getValue()); + item.setValue(NumUtil.fixedMax(6 ,iter.getValue().getValue())); String standard=""; List strList = Arrays.asList(iter.getValue().getStandard().split(StringPool.COMMA)); for (String str : strList) { @@ -1890,6 +1892,8 @@ public class GammaServiceImpl implements IGammaService { } } item.setStandard(standard); + if(StrUtil.equals(name, "Xe133-MDC (uBq/m3)")) + qcResultList.add(0, item); qcResultList.add(item); } result.setSuccess(true); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java index d9a84ff1..33360c50 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SpectrumAnalysisServiceImpl.java @@ -1183,6 +1183,8 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { QCResult qcResult = result.getResult(); if (ObjectUtil.isNull(qcResult)) return; Map dataMap = BeanUtil.beanToMap(qcResult); + // 将Null值替换为"",避免空指针异常(或者在模板中进行判断) + dataMap.replaceAll((key, value) -> ObjectUtil.isNull(value) ? "" : value); String export = "QCResult-Beta.xls"; String template = QcResult_B.getName(); ExportUtil.exportXls(response,template,dataMap,export);