From 492795c4452e315ccd29f22dee0a19bfd2f44fa8 Mon Sep 17 00:00:00 2001 From: nieziyan Date: Wed, 13 Sep 2023 15:33:09 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9AGamma=20RLR?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/jeecg/common/util/NumUtil.java | 53 ++++++++++++++++++ .../jeecg/modules/base/bizVo/GammaRLR.java | 4 ++ .../org/jeecg/modules/entity/vo/Nuclides.java | 11 ++++ .../org/jeecg/modules/entity/vo/Ratios.java | 7 +++ .../modules/entity/vo/TableAssociation.java | 2 + .../jeecg/modules/entity/vo/TablePeakFit.java | 2 + .../main/resources/excelTemplate/RLR-B.xls | Bin 35840 -> 34816 bytes .../service/impl/GammaServiceImpl.java | 26 +++++---- .../impl/SpectrumAnalysisServiceImpl.java | 9 +-- 9 files changed, 96 insertions(+), 18 deletions(-) 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 index 00ebfb09..8ffbff22 100644 --- 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 @@ -1,11 +1,17 @@ package org.jeecg.common.util; +import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; + 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; @@ -17,4 +23,51 @@ public class NumUtil { BigDecimal decimal = new BigDecimal(value); return decimal.setScale(scale, RoundingMode.HALF_UP).doubleValue(); } + + public static Double keep2(Double value){ + if (ObjectUtil.isNull(value)) + return null; + BigDecimal decimal = new BigDecimal(String.valueOf(value)); + return decimal.setScale(2, RoundingMode.HALF_UP).doubleValue(); + } + + public static String keep2Str(Double value){ + if (ObjectUtil.isNull(value)) + return null; + BigDecimal decimal = new BigDecimal(String.valueOf(value)); + return String.valueOf(decimal.setScale(2, RoundingMode.HALF_UP) + .doubleValue()); + } + + public static Double keep3(Double value){ + if (ObjectUtil.isNull(value)) + return null; + BigDecimal decimal = new BigDecimal(String.valueOf(value)); + return decimal.setScale(3, RoundingMode.HALF_UP).doubleValue(); + } + + public static String keep3Str(Double value){ + if (ObjectUtil.isNull(value)) + return null; + BigDecimal decimal = new BigDecimal(String.valueOf(value)); + return String.valueOf(decimal.setScale(3, RoundingMode.HALF_UP) + .doubleValue()); + } + + public static String keep4ScienceStr(Double value){ + if (ObjectUtil.isNull(value)) + return null; + String result = NumberUtil.decimalFormat("0.####E00", value); + if (!StrUtil.contains(result, "E-")) + return StrUtil.replace(result, "E", "E+"); + return result; + } + + public static String keepStr(Double value, int scale){ + if (ObjectUtil.isNull(value)) + return null; + BigDecimal decimal = new BigDecimal(String.valueOf(value)); + return String.valueOf(decimal.setScale(scale, RoundingMode.HALF_UP) + .doubleValue()); + } } diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/bizVo/GammaRLR.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/bizVo/GammaRLR.java index d3bf11ca..c0bde2d3 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/bizVo/GammaRLR.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/bizVo/GammaRLR.java @@ -1,9 +1,13 @@ package org.jeecg.modules.base.bizVo; +import cn.hutool.core.util.ObjectUtil; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; import org.jeecg.modules.entity.vo.*; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.text.DecimalFormat; import java.util.List; @Data diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/Nuclides.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/Nuclides.java index 4265bcfe..1d77b697 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/Nuclides.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/Nuclides.java @@ -21,4 +21,15 @@ public class Nuclides implements Serializable { private String mdc; private String lc; + + public Nuclides() { + this.name = ""; + this.activity = ""; + this.uncertActivity = ""; + this.mda = ""; + this.concentration = ""; + this.uncertConcentration = ""; + this.mdc = ""; + this.lc = ""; + } } diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/Ratios.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/Ratios.java index 0fe16df8..e9d5350d 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/Ratios.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/Ratios.java @@ -13,4 +13,11 @@ public class Ratios implements Serializable { private String isotopeRatio; private String uncertRatio; + + public Ratios() { + this.nuclide1 = ""; + this.nuclide2 = ""; + this.isotopeRatio = ""; + this.uncertRatio = ""; + } } diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/TableAssociation.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/TableAssociation.java index 7b46a3ef..0c922569 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/TableAssociation.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/TableAssociation.java @@ -7,6 +7,8 @@ import java.io.Serializable; @Data public class TableAssociation implements Serializable { + private Integer index; + private String exLevel; private String identified; diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/TablePeakFit.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/TablePeakFit.java index 0198391c..89dc7f3b 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/TablePeakFit.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/TablePeakFit.java @@ -7,6 +7,8 @@ import java.io.Serializable; @Data public class TablePeakFit implements Serializable { + private Integer index; + private String energy; private String energyErr; diff --git a/jeecg-boot-base-core/src/main/resources/excelTemplate/RLR-B.xls b/jeecg-boot-base-core/src/main/resources/excelTemplate/RLR-B.xls index a596f589a3db875e710333118926164e643560cb..90f30c037485c8ccf358148eba1f95cd8c790e7f 100644 GIT binary patch delta 2103 zcmZuyO-x)>6#m|O^Ct^va0ZHoMxzoJSX+JsMuq`~8DM}iKrPi;DAIzh!;c8G!;dp+ zwTY|N8xxJjRX6U`Nn9BgZrr-7#-wqfYnLV_ir+c!%`i}M^XBF|_d9?0o^z(~nO(SR z-|e<~zK#84S$)QD{}uUfe}7-TUI6|46yKZp`x9UGvEDB}3O)SuS1WEdd>`1q+${d% z`@G8z&zetrQvMvtw~D{_JX4pigSCxqJc|WfLljS885@{K7T0l=l6NRs$7xFEutZ!1 zOW+(S>!fV*TSpEjT=52Z^JJ}2*ms2DcPUFWJBJz<%)^{doeW1F)lQff`x@#ibmkFo zSy{}RndzPU$)ka<(XPa_QW11zDrZZ|)LWs26|6Fa$+9&s*2>&?SmpWJ z#cuJB>H46#H`8RAW`FZ{!wFbL>q;PC-7=wt7iur?vY!hAH{JwJzYTo3SsYy0vaAcm z9~a|Q_HC!=tfigBe;M9cSQtQ(3NEsVQf1^24VICQXsC?*M8jniAWD}}kZ6Qx4|QlU z%}WjWR-zO}RTf4oy{2>}>04G%{kQQvfieC{G;L%haITDO`Wr7JhbTj|$J=a!&$Cmq z)XtLxCOmd~x0;$PK}ecYWh7~yClXWbhfGNVFG&J59XwCt6=j9dVKU40`A(t)lR^JfnL*w61ezFHTK5*n5(#(HnY&ciY|$EE)gWY_;B5gR zT(r&CxsQ(=NnPmC@K)6R#%DgOu=mu)fHEYlQH~1NOHvs( zJVsI&5$U=F-trhJWn|4)JFSn)+ezQ`a~_J#FoxuHYoz;XZ|A2=STdPW_OALCdWKFO)+I?kx$bxMYuV$sXsj z;AiPbVf$HNQob^}rAYl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qiN!=MJl!tcd-!qme~kdu AqW}N^ 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 a05ebb09..2f30040b 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 @@ -44,6 +44,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; import java.math.BigDecimal; +import java.math.RoundingMode; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; @@ -1957,7 +1958,7 @@ public class GammaServiceImpl implements IGammaService { String col_stop = phd.getCollect().getCollection_stop_date() + StringPool.SPACE + phd.getCollect().getCollection_stop_time(); map.put("collect_start", col_start); map.put("collect_stop", col_stop); - map.put("collect_airVolume", phd.getCollect().getAir_volume()); + map.put("collect_airVolume", NumUtil.keep3(phd.getCollect().getAir_volume())); // Init #SampleReceipt if(StringUtils.isNotBlank(phd.getHeader().getSample_ref_id())){ map.put("Receipt_srid", phd.getHeader().getSample_ref_id()); @@ -1981,17 +1982,18 @@ public class GammaServiceImpl implements IGammaService { double live_time = phd.getAcq().getAcquisition_live_time(); for(int i=0; i 0 ? String.valueOf(peak.areaErr/peak.area*100) : "0"; + tablePeak.setNetArea(NumUtil.keep4ScienceStr(peak.area)); + String area_err = peak.area > 0 ? NumUtil.keep2Str(peak.areaErr/peak.area*100) : "0"; tablePeak.setAreaErr(area_err); - String rate = live_time > 0 ? String.valueOf(peak.area/live_time) : "0"; + String rate = live_time > 0 ? NumUtil.keep4ScienceStr(peak.area/live_time) : "0"; tablePeak.setNetCountRate(rate); tablePeak.setNcRateErr(area_err); - tablePeak.setLc(String.valueOf(peak.lc)); - tablePeak.setSignificance(String.valueOf(peak.significance)); + tablePeak.setLc(NumUtil.keep4ScienceStr(peak.lc)); + tablePeak.setSignificance(NumUtil.keep2Str(peak.significance)); peakFitList.add(tablePeak); } map.put("peakFit", peakFitList); @@ -2006,6 +2008,7 @@ public class GammaServiceImpl implements IGammaService { List associationList = new LinkedList<>(); for(int i=0; i nuclides = phd.getVPeak().get(i).nuclides; String iden = ""; @@ -2035,12 +2038,12 @@ public class GammaServiceImpl implements IGammaService { TableResult tableResult = new TableResult(); NuclideActMda nuc = it.getValue(); tableResult.setNuclide(it.getKey()); - tableResult.setActivity(String.valueOf(nuc.getActivity())); - String act_err = nuc.getActivity() > 0 ? String.valueOf(nuc.getAct_err()/nuc.getActivity()*100) : "0"; + tableResult.setActivity(NumUtil.keepStr(nuc.getActivity(), 6)); + String act_err = nuc.getActivity() > 0 ? NumUtil.keepStr(nuc.getAct_err()/nuc.getActivity()*100, 4) : "0"; tableResult.setActErr(act_err); tableResult.setFactor1(coverage_factor); tableResult.setConfidence1(level_confidence); - tableResult.setConc(String.valueOf(nuc.getConcentration()/1000)); + tableResult.setConc(NumUtil.keepStr(nuc.getConcentration()/1000, 5)); tableResult.setConcErr(act_err); tableResult.setFactor2(coverage_factor); tableResult.setConfidence2(level_confidence); @@ -2069,8 +2072,10 @@ public class GammaServiceImpl implements IGammaService { result.setResult(map); return result; } + @Override public void exportRLR(GammaRLR gammaRLR, HttpServletResponse response) { + if (ObjectUtil.isNull(gammaRLR)) return; String pathPrefix = "excelTemplate/"; String path = pathPrefix + RLR_G.getName(); String template = ClassUtil.classPath(path); @@ -2143,6 +2148,7 @@ public class GammaServiceImpl implements IGammaService { writer.close(); } } + @Override public void viewAutomaticAnalysisLog(Integer sampleId, HttpServletResponse response) { if (Objects.isNull(sampleId)){ 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 957db613..b6dcd54b 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 @@ -1319,14 +1319,7 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { dataMap.replaceAll((key, value) -> ObjectUtil.isNull(value) ? "" : value); String export = "RLR-Beta.xls"; String template = RLR_B.getName(); - ExportUtil.exportXls(response, template, dataMap,export); - } - - public static void main(String[] args) { - BetaRLR betaRLR = new BetaRLR(); - Map dataMap = BeanUtil.beanToMap(betaRLR); - dataMap.replaceAll((key, value) -> ObjectUtil.isNull(value) ? "" : value); - dataMap.forEach((key, value) -> System.out.println(key + "---" + value)); + ExportUtil.exportXls(response, template, dataMap, export); } @Override