From f74a2a83586dc7a58b9d5c9b518c07c323404795 Mon Sep 17 00:00:00 2001 From: nieziyan Date: Mon, 11 Sep 2023 22:11:13 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9ABug=20Fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/jeecg/common/util/NumUtil.java | 20 ++++++++++++++++++ .../resources/excelTemplate/QcResult-B.xls | Bin 20480 -> 19456 bytes .../excelTemplate/SampleInformation-B.xls | Bin 19968 -> 19968 bytes .../excelTemplate/SampleInformation-G.xls | Bin 19456 -> 19456 bytes .../service/impl/GammaServiceImpl.java | 6 +++++- .../impl/SpectrumAnalysisServiceImpl.java | 2 ++ 6 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 jeecg-boot-base-core/src/main/java/org/jeecg/common/util/NumUtil.java 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 0576a78f7e127ff02db4d5e672b4ea378253bac3..98a27e6f3230bee201dddbc17faf6d03b16f934d 100644 GIT binary patch delta 1029 zcmb7CO=uHQ5T4m=_9soUo1}I(+S;_Xf*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/main/resources/excelTemplate/SampleInformation-B.xls index f9c838214eca1542c4300b66ac32cf9b4f671a72..4e38979cc68d4149709e439db64b112e126544d1 100644 GIT binary patch delta 1411 zcmbVLOK1~e5S~BX&F(h3k0vIYn3_bX^kq{m_93)QwWbw8M0-(D+Dk?8RZ%ZRQ#>d| z5n-xDC`I&G6m`9bV2gsFP!C!Zw1)`Q9uyCv2MZGC-(>B}P;kTUF!O!iJpRnzH^lme z*u5iyyIStPJ~D+Tg$wMi^-HL52>_WCo{;>mS#wjW!ef#TH_KtNCO(l(947mU-Yc>X zizt48>@7Kjr|5l4coq5Q37?U|SgYuGPLgqzV&XT#K1;flR4T=w8vuT0bbyBdiD)7U zf)Y)G4+`;;+V&6BZ==iciyFt*s>u|r(c<`2Gj-X?G-MclkKcnYjVNx=%-}Ky_>n6C zV|Ee=KWOn%pMy>Sl~0(EL$w8QJgkO-mA243AM%p~$Bp8BMNWLcFh(Pz5oZ>4PJGZa z=yBpyD?9r@cXyUwXXjshCgpfk4Wu^OsK-%FKqoaEavBcI#=8>H>c4|fdkapu+|ILN zQM@8g^@tr8@v&iaRp;TX%oERQ7f%$*!;kYxSsnjIYVvS$THIokNwrxH-ZsjZ$yLFI zJSsnqtHt=fs8l%nytBu0d;3e+PP|&bRXQld=qzG5S)UGwz;?qf*aoez31ncs& ztcK$SEQV_u*C~8sN+f{q)}BTWGsa>XxPUH=i~r96K0MvDp9%P;$zm#AY~C))E*-r1 ztT`1Y7HB|P_zi`mVdU|>Ud@1|t33?i(}>D4(F5yzG-j zs0Q(Pm%M9!Js9YqTlJgIum`QCOXy$i%V0QpSxFN%mVx1Eyq^pNa~?RBWcHKBkI9HK zopm6M>yv9S-e#n7Je{8vWpQ-FoM~sBZynsRj?Uzr&e1#gQg-iBg#X7e*gh#f`g(0- K%9?3+i+=zqfKF2Y delta 1387 zcmbVMPe>GD6o213f8E?~X4iISH*=Oqi`5!M@(-krma8Cj=oC^>7f%x6A?UQ8g3Ka# zg&1ZMl-FvcL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_b_y;czj3-=1noyl{(f@wZ+CNTQrlh3&M;>Ss(0xkrqw9$+Kg2J&=XI{)9#j$Fr-!NYh^cIDTgWIB8sEZx@;&HxpQ*al6qtv++;5< zGICKkD-LoY2QJPE7YDpMv+pX~lzD4r`aS>u^HuNqE?M6tN6Vsgpx-B--4*dz7`EYi zZHoYVHbjBsW@o0-5P?Vd561L>>K~3v zMl722s+SA-7MA}KuW8F{Ew^k_dJ(^f^Z8g#e{RO}dS2(ey3Dg#Uq9&OuiR4tmyO1? zelJS7>kcxk;TUhY=9kYqcB(u`Bj+c4>j^K9Qo*|ds>eMp;~Ay%sQ^t=0QbF>6U74b zJ;h1MVDTOA4bYUlI6^y>0bhgrw3ApxS9B=AW#YBbf)C*iak8-Z;mY;X-G%@%+X4ZB c9a(m>&T*AEVP#(3=FxjW0=amJKF4I~2fH`SSO5S3 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);