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 a596f589..90f30c03 100644 Binary files a/jeecg-boot-base-core/src/main/resources/excelTemplate/RLR-B.xls and b/jeecg-boot-base-core/src/main/resources/excelTemplate/RLR-B.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 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