From 492795c4452e315ccd29f22dee0a19bfd2f44fa8 Mon Sep 17 00:00:00 2001 From: nieziyan Date: Wed, 13 Sep 2023 15:33:09 +0800 Subject: [PATCH 1/3] =?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^}rAYl6nd~x*Wgpg&?r67)-4Pw*4vXL%leGC(6S_}wUJ{$}_lCZE Sf8Fmde1AFgu$a4Z$M-)45m(y) delta 3096 zcmZ`*-EUMy6hHUwS81RnwYyCoR{GG!8eq}}eejL5NXEC$!bozZ+67)~c+^U2N`bEy!iL zDeqxk$4FIUDCpxQxh;1j$X-{CJum&@5Y3f+)y_w~Qwdm?uC$I@L3JVPJcbur=Z4Jl z_M6ho)h8L0o#Zn%hEdA@{CTdn=);+SC!YsUzgA}h z+%S){d_5tud`;x9+xTBB4J;KcYrgc|mEKyr#VXmih9mBl>_uu?NFk1h{42Gfqxhc# zfJenZ4fs?X)M=kefEqMZ8&*e#FcY;cgxaQ2hkah6j<`Na*ioM%Y~E05td5+)OxSb? zHmzaDd|twi`xH?pe2S=N4b_g-k%@Cy2-_ZlZP&2peP+T=`V?WOe2TEs8Yd+k>Qb?} z=@_U1nbCWVatzo59O~1;ORgicM)ElJ9hvhf8@{{XQxQ;aYJ@sD4r_8|By?0dapFL) z7o$#%L>F0hTspW_;zt&YjlDqcmqmTtfct}fXXSV!A{0D22Va>& z!f?DS2Z5;5LC>I7VdX;VqX!+gwPf6p~mGnH#3_$5qepV9C!t;_cq z?vvPapPmGf$xCjlkua>%Q6c1#B^0?)ExEpgLG3|EyH(Gu?)i4iSv%Seof z?c(#i!8G-hu=9@M!Qm+x)gm7lkD4s-KOB9SmzCwb|XM3VXb+y<~&xUO#q5o9&t>z@;{oNxY65EVdhFI1gy)}U-)e1Wc zX-hYzb1?D@_V;5yQpWE&gf*0tVha{3I1iyQyyU!apVy+hDhQvFNp)+rd4WZ>t7HnC z<66m76(uaToU9og(^|*6(J`$h!#ZZvrM2W`ehdq6SI?}kXSRwS)@4ra8$EMc4{u)9 z)?8IR7oev(!#d5$hURRfxd=U z1^!uT-+GIC3|FGS&Rz@)>q!i*eHdKX9W9CB0%U>2P^?V*7z&ih97CouLt{D-xQ^=^ zKZ2W{=@LOYFd-rc>?FRnyHU(CXXuLG|aOYftXqiN!=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 From a06fbed52add64a82fc02d1fc7c538b895bb9e8b Mon Sep 17 00:00:00 2001 From: orgin Date: Wed, 13 Sep 2023 16:34:28 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=20redis=20?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96GardsNuclLinesLib=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/IGardsNuclLinesLibService.java | 3 ++ .../impl/GardsNuclLinesLibServiceImpl.java | 44 ++++++++++++++++--- .../impl/SysDefaultNuclideServiceImpl.java | 14 +++--- 3 files changed, 50 insertions(+), 11 deletions(-) diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/IGardsNuclLinesLibService.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/IGardsNuclLinesLibService.java index b9e50971..61f51df1 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/IGardsNuclLinesLibService.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/IGardsNuclLinesLibService.java @@ -3,6 +3,7 @@ package org.jeecg.modules.system.service; import com.baomidou.mybatisplus.extension.service.IService; import com.google.common.collect.Multimap; import org.jeecg.modules.base.entity.configuration.GardsNuclLinesLib; +import org.jeecg.modules.entity.vo.NuclideLines; import java.util.List; import java.util.Map; @@ -10,4 +11,6 @@ import java.util.Map; public interface IGardsNuclLinesLibService extends IService { Map> mapLines(List nuclideNames); + + Map defaultLines(List nuclideNames); } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/GardsNuclLinesLibServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/GardsNuclLinesLibServiceImpl.java index 20df66c1..45c3e3eb 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/GardsNuclLinesLibServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/GardsNuclLinesLibServiceImpl.java @@ -2,17 +2,12 @@ package org.jeecg.modules.system.service.impl; import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.collection.ListUtil; import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.ObjectUtil; import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.Multimap; -import com.google.common.collect.Multimaps; -import org.apache.commons.collections.MultiHashMap; -import org.jeecg.common.util.ListUtils; import org.jeecg.modules.base.entity.configuration.GardsNuclLinesLib; +import org.jeecg.modules.entity.vo.NuclideLines; import org.jeecg.modules.system.mapper.GardsNuclLinesLibMapper; import org.jeecg.modules.system.service.IGardsNuclLibService; import org.jeecg.modules.system.service.IGardsNuclLinesLibService; @@ -21,6 +16,7 @@ import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -64,4 +60,40 @@ public class GardsNuclLinesLibServiceImpl extends ServiceImpl defaultLines(List nuclideNames) { + Map result = new HashMap<>(); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(GardsNuclLinesLib::getName, nuclideNames); + // 获取GardsNuclLinesLib核素数据 + List allNuclide = list(wrapper); + Map halfLife = nuclLibService.halfLife(nuclideNames); + + // 按照 QT源代码 处理数据 + for (int i = 0; i < allNuclide.size(); i++) { + NuclideLines nuclideLines; + GardsNuclLinesLib lib = allNuclide.get(i); + nuclideLines = result.containsKey(lib.getName()) ? result.get(lib.getName()) : new NuclideLines(); + + nuclideLines.getFullNames().add(lib.getFullName()); + nuclideLines.getVEnergy().add(lib.getEnergy()); + nuclideLines.getVUncertE().add(lib.getEnergyUncert()); + nuclideLines.getVYield().add(lib.getYield() / 100); + nuclideLines.getVUncertY().add(lib.getYieldUncert()); + + int keyFlag = lib.getKeyFlag(); + if (keyFlag > 0){ + nuclideLines.setKey_flag(i); + nuclideLines.setMaxYeildIdx(i); + } + + String name = lib.getName(); + Double day = halfLife.get(name); + if (ObjectUtil.isNotNull(day)) + lib.setHalflife(day * 86400); + + result.put(lib.getName(), nuclideLines); + } + return result; + } } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysDefaultNuclideServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysDefaultNuclideServiceImpl.java index d90f723f..cabc5c91 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysDefaultNuclideServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysDefaultNuclideServiceImpl.java @@ -16,6 +16,7 @@ import org.jeecg.common.constant.RedisConstant; import org.jeecg.common.util.RedisUtil; import org.jeecg.modules.base.entity.configuration.GardsNuclLinesLib; import org.jeecg.modules.base.entity.postgre.SysDefaultNuclide; +import org.jeecg.modules.entity.vo.NuclideLines; import org.jeecg.modules.monitor.domain.RedisInfo; import org.jeecg.modules.system.mapper.SysDefaultNuclideMapper; import org.jeecg.modules.system.service.IGardsNuclLinesLibService; @@ -24,10 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.PostConstruct; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; @@ -108,21 +106,27 @@ public class SysDefaultNuclideServiceImpl extends ServiceImpl linesHashMap = new HashMap<>(); + List nuclideTypes = ListUtil.toList("G","P"); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(SysDefaultNuclide::getUseType,1); wrapper.in(SysDefaultNuclide::getNuclideType,nuclideTypes); + // 获取自动处理需要的默认核素参数 List nuclides = list(wrapper); + // 根据核素类型分组 Map> nuclideMap = nuclides.stream() .filter(nuclide -> StrUtil.isNotBlank(nuclide.getNuclideName())) .collect(Collectors.groupingBy(SysDefaultNuclide::getNuclideType)); + // 获取GardsNuclLinesLib核素数据 for (Map.Entry> entry : nuclideMap.entrySet()) { List nuclideNames = entry.getValue().stream() .map(SysDefaultNuclide::getNuclideName) .collect(Collectors.toList()); + String nuclideType = entry.getKey(); String key = RedisConstant.NUCLIDE_LINES_LIB + nuclideType; - Map> mapLines = nuclLinesLibService.mapLines(nuclideNames); + Map mapLines = nuclLinesLibService.defaultLines(nuclideNames); redisUtil.set(key,mapLines); } } From 1b16ceca8f77ed37b3c119fbdc3f6c086230e331 Mon Sep 17 00:00:00 2001 From: nieziyan Date: Wed, 13 Sep 2023 17:08:37 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat=EF=BC=9Aformat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jeecg/common/constant/DateConstant.java | 4 +++ .../java/org/jeecg/common/util/NumUtil.java | 21 ++++-------- .../service/impl/GammaServiceImpl.java | 33 +++++++++++-------- 3 files changed, 31 insertions(+), 27 deletions(-) diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/DateConstant.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/DateConstant.java index 2c66253b..21ad4bae 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/DateConstant.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/DateConstant.java @@ -8,6 +8,10 @@ public interface DateConstant { String DATE_TIME = "yyyy-MM-dd HH:mm:ss"; + String DATE_BIAS = "yyyy/MM/dd"; + + String DATE_BIAS_TIME = "yyyy/MM/dd HH:mm:ss"; + String TIME_START = " 00:00:00"; String TIME_END = " 23:59:59"; 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 8ffbff22..8d6554a8 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 @@ -24,13 +24,6 @@ public class NumUtil { 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; @@ -39,13 +32,6 @@ public class NumUtil { .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; @@ -63,6 +49,13 @@ public class NumUtil { return result; } + public static Double keep(Double value, int scale){ + if (ObjectUtil.isNull(value)) + return null; + BigDecimal decimal = new BigDecimal(String.valueOf(value)); + return decimal.setScale(scale, RoundingMode.HALF_UP).doubleValue(); + } + public static String keepStr(Double value, int scale){ if (ObjectUtil.isNull(value)) return null; 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 613d9e3b..c2679c9c 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 @@ -39,12 +39,10 @@ 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; import java.sql.Statement; -import java.text.DecimalFormat; import java.text.ParseException; import java.time.LocalDateTime; import java.util.*; @@ -1929,7 +1927,8 @@ public class GammaServiceImpl implements IGammaService { return result; } Map map = new HashMap<>(); - Date curTime = new Date(); + String dateTime = DateUtil.format(new Date(), DateConstant.DATE_BIAS_TIME); + String date = DateUtil.format(new Date(), DateConstant.DATE_BIAS); String responsible_person = "wang shilian"; String software = "GammaAnalyser,GammaAnalyALG"; int num = phd.getVPeak().size(); @@ -1954,29 +1953,29 @@ public class GammaServiceImpl implements IGammaService { map.put("header_report_type", "FIN"); // 8: Report Type map.put("header_report_number", "1"); // 9: Report Number map.put("header_sample_category", "Category C"); // 10:Sample Category - map.put("header_transmission", curTime); // 11:Message Transmission Time + map.put("header_transmission", dateTime); // 11:Message Transmission Time // Init #Objective map.put("Obj_purpose", "The purpose of this analysis is proficiency test."); map.put("Obj_authorized", "High-resolution non-destructive gamma spectroscopy."); - map.put("Obj_instruction", "`0"); + map.put("Obj_instruction", "0"); // Init #Collection String col_start = phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time(); 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", NumUtil.keep3(phd.getCollect().getAir_volume())); + map.put("collect_airVolume", NumUtil.keep(phd.getCollect().getAir_volume(), 4)); // Init #SampleReceipt if(StringUtils.isNotBlank(phd.getHeader().getSample_ref_id())){ map.put("Receipt_srid", phd.getHeader().getSample_ref_id()); } map.put("Receipt_sealNum", "0"); - map.put("Receipt_sample_dateTime", curTime); + map.put("Receipt_sample_dateTime", dateTime); map.put("Receipt_package", "Parcel."); map.put("Receipt_seal", "Good."); map.put("Receipt_sample", "Good."); // Init #Test map.put("Test_type", "Analysis of a reference sample."); - map.put("Test_completion", curTime); + map.put("Test_completion", date); map.put("Test_person", responsible_person); map.put("Test_purpose", "The purpose of this analysis is proficiency test exercise."); // Init #PeaksMethod @@ -2036,20 +2035,28 @@ public class GammaServiceImpl implements IGammaService { String coverage_factor = "2.00"; String level_confidence = "95.00"; - map.put("Result_act_ref", phd.getUsedSetting().getRefTime_act()); - map.put("Result_conc_ref", phd.getUsedSetting().getRefTime_conc()); + Date refTimeAct = phd.getUsedSetting().getRefTime_act(); + Date refTimeConc = phd.getUsedSetting().getRefTime_conc(); + String timeAct = ""; + String timeConc = ""; + if (ObjectUtil.isNotNull(refTimeAct)) + timeAct = DateUtil.format(refTimeAct, DateConstant.DATE_BIAS_TIME); + if (ObjectUtil.isNotNull(refTimeConc)) + timeConc = DateUtil.format(refTimeConc, DateConstant.DATE_BIAS_TIME); + map.put("Result_act_ref", timeAct); + map.put("Result_conc_ref", timeConc); List tableResultList = new LinkedList<>(); for(Map.Entry it : phd.getMapNucActMda().entrySet()){ if(it.getValue().isBCalculateMDA()) { TableResult tableResult = new TableResult(); NuclideActMda nuc = it.getValue(); tableResult.setNuclide(it.getKey()); - tableResult.setActivity(NumUtil.keepStr(nuc.getActivity(), 6)); - String act_err = nuc.getActivity() > 0 ? NumUtil.keepStr(nuc.getAct_err()/nuc.getActivity()*100, 4) : "0"; + tableResult.setActivity(NumUtil.keep4ScienceStr(nuc.getActivity())); + String act_err = nuc.getActivity() > 0 ? NumUtil.keepStr(nuc.getAct_err()/nuc.getActivity()*100, 2) : "0"; tableResult.setActErr(act_err); tableResult.setFactor1(coverage_factor); tableResult.setConfidence1(level_confidence); - tableResult.setConc(NumUtil.keepStr(nuc.getConcentration()/1000, 5)); + tableResult.setConc(NumUtil.keep4ScienceStr(nuc.getConcentration()/1000)); tableResult.setConcErr(act_err); tableResult.setFactor2(coverage_factor); tableResult.setConfidence2(level_confidence);