From d4d5653d026997377feaaf561b3d2c9e33fa7aaa Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Mon, 9 Oct 2023 09:39:05 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=97=E6=B3=95=E6=89=80=E9=9C=80=E5=AE=9E?= =?UTF-8?q?=E4=BD=93=E7=B1=BB=E5=8F=8A=E8=B0=83=E7=94=A8=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E6=8F=90=E5=87=BA=E5=88=B0=E5=85=AC=E7=94=A8=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E4=B8=8B=20=E4=BF=AE=E6=94=B9=E8=87=AA=E5=8A=A8=E5=A4=84?= =?UTF-8?q?=E7=90=86=E7=A8=8B=E5=BA=8F=E5=AD=98=E5=82=A8=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=9C=89=E8=AF=AF=E9=97=AE=E9=A2=98=20=E6=96=B0=E5=A2=9EParame?= =?UTF-8?q?terProperties=E7=B1=BB=20=E6=96=B0=E5=A2=9ENumberFormatUtil?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../properties/ParameterProperties.java | 24 ++ .../jeecg/common/util/NumberFormatUtil.java | 57 +++++ .../jeecg/modules/entity/vo/AnalyseData.java | 26 +- jeecg-module-auto-process/pom.xml | 2 +- .../modules/spectrum/Sample_G_Analysis.java | 9 +- .../spectrum/SpectrumServiceQuotes.java | 3 + .../pom.xml | 2 +- .../org/jeecg/common/util/GammaFileUtil.java | 82 ++----- .../org/jeecg/modules/entity/vo/PeakInfo.java | 0 .../modules/entity/vo/StructInsertInput.java | 0 .../modules/entity/vo/StructInsertOutput.java | 0 .../modules/native_jni/CalValuesHandler.java | 0 .../native_jni/EnergySpectrumHandler.java | 0 .../native_jni/struct/AllGenerate.java | 0 .../native_jni/struct/BgAnalyseResult.java | 0 .../modules/native_jni/struct/BgBoundary.java | 0 .../native_jni/struct/CalValuesOut.java | 0 .../struct/CalcBgBoundaryParam.java | 0 .../struct/EnergySpectrumStruct.java | 0 jeecg-module-spectrum-analysis/pom.xml | 2 +- .../modules/entity/vo/BgCalibratePara.java | 0 .../modules/entity/vo/SpectrumGroup.java | 2 - .../native_jni/EnergySpectrumHandler.java | 11 + .../service/impl/GammaServiceImpl.java | 232 ++++++++++++++++-- .../impl/SpectrumAnalysisServiceImpl.java | 218 +++++++++------- .../jeecg/common/CalculateStationData.java | 8 +- .../jeecg/JeecgAutoProcessApplication.java | 4 +- pom.xml | 6 +- 28 files changed, 491 insertions(+), 197 deletions(-) create mode 100644 jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/ParameterProperties.java create mode 100644 jeecg-boot-base-core/src/main/java/org/jeecg/common/util/NumberFormatUtil.java rename {jeecg-module-BetaGammaAnalyser => jeecg-module-beta-gamma-analyser}/pom.xml (95%) rename {jeecg-module-BetaGammaAnalyser => jeecg-module-beta-gamma-analyser}/src/main/java/org/jeecg/common/util/GammaFileUtil.java (98%) rename {jeecg-module-BetaGammaAnalyser => jeecg-module-beta-gamma-analyser}/src/main/java/org/jeecg/modules/entity/vo/PeakInfo.java (100%) rename {jeecg-module-BetaGammaAnalyser => jeecg-module-beta-gamma-analyser}/src/main/java/org/jeecg/modules/entity/vo/StructInsertInput.java (100%) rename {jeecg-module-BetaGammaAnalyser => jeecg-module-beta-gamma-analyser}/src/main/java/org/jeecg/modules/entity/vo/StructInsertOutput.java (100%) rename {jeecg-module-BetaGammaAnalyser => jeecg-module-beta-gamma-analyser}/src/main/java/org/jeecg/modules/native_jni/CalValuesHandler.java (100%) rename {jeecg-module-BetaGammaAnalyser => jeecg-module-beta-gamma-analyser}/src/main/java/org/jeecg/modules/native_jni/EnergySpectrumHandler.java (100%) rename {jeecg-module-BetaGammaAnalyser => jeecg-module-beta-gamma-analyser}/src/main/java/org/jeecg/modules/native_jni/struct/AllGenerate.java (100%) rename {jeecg-module-BetaGammaAnalyser => jeecg-module-beta-gamma-analyser}/src/main/java/org/jeecg/modules/native_jni/struct/BgAnalyseResult.java (100%) rename {jeecg-module-BetaGammaAnalyser => jeecg-module-beta-gamma-analyser}/src/main/java/org/jeecg/modules/native_jni/struct/BgBoundary.java (100%) rename {jeecg-module-BetaGammaAnalyser => jeecg-module-beta-gamma-analyser}/src/main/java/org/jeecg/modules/native_jni/struct/CalValuesOut.java (100%) rename {jeecg-module-BetaGammaAnalyser => jeecg-module-beta-gamma-analyser}/src/main/java/org/jeecg/modules/native_jni/struct/CalcBgBoundaryParam.java (100%) rename {jeecg-module-BetaGammaAnalyser => jeecg-module-beta-gamma-analyser}/src/main/java/org/jeecg/modules/native_jni/struct/EnergySpectrumStruct.java (100%) rename {jeecg-boot-base-core => jeecg-module-spectrum-analysis}/src/main/java/org/jeecg/modules/entity/vo/BgCalibratePara.java (100%) rename {jeecg-boot-base-core => jeecg-module-spectrum-analysis}/src/main/java/org/jeecg/modules/entity/vo/SpectrumGroup.java (94%) diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/ParameterProperties.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/ParameterProperties.java new file mode 100644 index 00000000..a54db57d --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/ParameterProperties.java @@ -0,0 +1,24 @@ +package org.jeecg.common.properties; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import java.io.Serializable; + +@Data +@Component +@ConfigurationProperties(prefix = "parameter") +public class ParameterProperties implements Serializable { + + /** + * 算法计算需要用到的文件存储路径 + */ + private String filePath; + + /** + * db文件存储路径 + */ + private String dbPath; + +} diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/NumberFormatUtil.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/NumberFormatUtil.java new file mode 100644 index 00000000..2909cbec --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/NumberFormatUtil.java @@ -0,0 +1,57 @@ +package org.jeecg.common.util; + +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Component; + +import java.math.BigDecimal; +import java.math.MathContext; + +@Component +public class NumberFormatUtil { + + public static void main(String[] args) { + double value = 8823 * 12 * 30 + 79.2 * 10000; + value = value - 2640000; + System.out.println(value); + } + + //接收参数判断是否是科学计数法 + public static String numberFormat(String number) { + String value = ""; + //判断传入的字符串是否包含e + if (StringUtils.isNotBlank(number)) { + if (number.contains("e") || number.contains("E")) { + value = scienceCal(number); + } else { + value = numberCal(number); + } + } + return value; + } + + public static String scienceCal(String number) { + String value = ""; + if (number.indexOf("e")>0) { + String calNumber = number.substring(0, number.indexOf("e")); + String numberCal = numberCal(calNumber); + value = numberCal + number.substring(number.indexOf("e")); + } else if (number.indexOf("E")>0) { + String calNumber = number.substring(0, number.indexOf("E")); + String numberCal = numberCal(calNumber); + value = numberCal + number.substring(number.indexOf("E")); + } + return value; + } + + //正常小数进行固定长度的保留小数 + public static String numberCal(String number) { + //将当前字符串的数字 + BigDecimal b = new BigDecimal(number); + BigDecimal divisor = BigDecimal.ONE; + //需要保留的长度 + MathContext mc = new MathContext(6); + return String.valueOf(b.divide(divisor, mc)); + } + + +} diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/AnalyseData.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/AnalyseData.java index 09e203b7..6712cb36 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/AnalyseData.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/AnalyseData.java @@ -12,26 +12,16 @@ public class AnalyseData implements Serializable { private boolean sampleData; - private boolean GasBgData; + private boolean gasBgData; - private boolean DetBgData; + private boolean detBgData; - private boolean QCData; - - private boolean gFitting; - - private boolean bFitting; + private boolean qcData; private boolean bGammaEnergyValid; private boolean bBetaEnergyValid; - private List fittingChannelEnergy; - - private CalibrationParam g_calibration_param; - - private CalibrationParam b_calibration_param; - private List dbNames; private List sampleIds; @@ -42,15 +32,15 @@ public class AnalyseData implements Serializable { private List detFileNames; + private List qcFileNames; + public AnalyseData(){ sampleData = false; - GasBgData = false; - DetBgData = false; - QCData = false; + gasBgData = false; + detBgData = false; + qcData = false; bGammaEnergyValid = false; bBetaEnergyValid = false; - g_calibration_param = new CalibrationParam(); - b_calibration_param = new CalibrationParam(); } } diff --git a/jeecg-module-auto-process/pom.xml b/jeecg-module-auto-process/pom.xml index 2d2dbd37..6724d41d 100644 --- a/jeecg-module-auto-process/pom.xml +++ b/jeecg-module-auto-process/pom.xml @@ -18,7 +18,7 @@ org.jeecgframework.boot - jeecg-module-BetaGammaAnalyser + jeecg-module-beta-gamma-analyser diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_G_Analysis.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_G_Analysis.java index 9dad3679..fe6a6756 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_G_Analysis.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_G_Analysis.java @@ -16,6 +16,7 @@ import org.apache.commons.lang3.StringUtils; import org.jeecg.common.api.vo.Result; import org.jeecg.common.constant.*; import org.jeecg.common.constant.enums.SpectrumSystemType; +import org.jeecg.common.properties.ParameterProperties; import org.jeecg.common.properties.SpectrumPathProperties; import org.jeecg.common.util.GammaFileUtil; import org.jeecg.common.util.RedisUtil; @@ -30,6 +31,7 @@ import org.jeecg.modules.entity.vo.*; import org.jeecg.modules.ftp.FTPUtils; import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct; import org.jeecgframework.core.util.ApplicationContextUtil; +import org.springframework.beans.factory.annotation.Value; import org.springframework.transaction.TransactionStatus; import java.io.File; @@ -56,6 +58,8 @@ public class Sample_G_Analysis { // 能谱文件存储路径属性 private SpectrumPathProperties spectrumPathProperties; + private ParameterProperties parameterProperties; + private RedisUtil redisUtil; /** @@ -117,8 +121,9 @@ public class Sample_G_Analysis { Integer sampleId = sampleData.getSampleId(); GammaFileUtil gammaFileUtil = ApplicationContextUtil.getContext().getBean(GammaFileUtil.class); + parameterProperties = ApplicationContextUtil.getContext().getBean(ParameterProperties.class); PHDFile phdFile = new PHDFile(); - + phdFile.setXmlFilePath(parameterProperties.getFilePath()); // 解析PHD文件 spectrumPathProperties = ApplicationContextUtil.getContext().getBean(SpectrumPathProperties.class); String sampleFilePath = sampleData.getInputFileName(); @@ -126,7 +131,7 @@ public class Sample_G_Analysis { String fileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH)+1); boolean flag = gammaFileUtil.loadFile(pathName, fileName, phdFile, new Result()); // todo 测试阶段暂时注释掉,获取数据库 Gamma 默认参数 -// getSettingFromDB(phdFile); + getSettingFromDB(phdFile); // 文件路径 middleData.setAnalyses_save_filePath(this.sampleInputFilename); // 读取文件内容并附值 diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SpectrumServiceQuotes.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SpectrumServiceQuotes.java index e4961f44..ef7140be 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SpectrumServiceQuotes.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SpectrumServiceQuotes.java @@ -2,6 +2,7 @@ package org.jeecg.modules.spectrum; import lombok.Getter; import lombok.RequiredArgsConstructor; +import org.jeecg.common.properties.ParameterProperties; import org.jeecg.common.properties.SoftwareProperties; import org.jeecg.common.properties.SpectrumPathProperties; import org.jeecg.common.properties.TaskProperties; @@ -36,6 +37,8 @@ public class SpectrumServiceQuotes { private final SpectrumPathProperties spectrumPathProperties; + private final ParameterProperties parameterProperties; + private final ISOHSpectrumService sohSpectrumService; private final IAlertSpectrumService alertSpectrumService; diff --git a/jeecg-module-BetaGammaAnalyser/pom.xml b/jeecg-module-beta-gamma-analyser/pom.xml similarity index 95% rename from jeecg-module-BetaGammaAnalyser/pom.xml rename to jeecg-module-beta-gamma-analyser/pom.xml index 442068a5..30e75419 100644 --- a/jeecg-module-BetaGammaAnalyser/pom.xml +++ b/jeecg-module-beta-gamma-analyser/pom.xml @@ -9,7 +9,7 @@ 3.5.1 - jeecg-module-BetaGammaAnalyser + jeecg-module-beta-gamma-analyser 8 diff --git a/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java similarity index 98% rename from jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java rename to jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java index 622a2274..14d3f76f 100644 --- a/jeecg-module-BetaGammaAnalyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java +++ b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java @@ -11,6 +11,7 @@ import org.apache.commons.net.ftp.FTP; import org.apache.commons.net.ftp.FTPClient; import org.ejml.simple.SimpleMatrix; import org.jeecg.common.api.vo.Result; +import org.jeecg.common.properties.ParameterProperties; import org.jeecg.common.properties.SpectrumPathProperties; import org.jeecg.modules.base.entity.configuration.GardsNuclLib; import org.jeecg.modules.base.entity.configuration.GardsNuclLinesLib; @@ -44,8 +45,8 @@ import java.util.*; @Component public class GammaFileUtil { - @Value("${parameter.filePath}") - private String parameterFilePath; + @Autowired + private ParameterProperties parameterProperties; @Autowired private FTPUtil ftpUtil; @Autowired @@ -845,7 +846,7 @@ public class GammaFileUtil { public boolean ReadQCLimit(Map qcItems, Map vMdcInfoMap, Double ener_Be7, String systemType) { try { - String filePath = parameterFilePath+ File.separator +"SystemManager.xml"; + String filePath = parameterProperties.getFilePath()+ File.separator +"SystemManager.xml"; //创建一个文档解析器工厂 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); //创建文档解析器 @@ -1383,7 +1384,6 @@ public class GammaFileUtil { String strValue = CalValuesHandler.analyseSpectrum(phdStr, nuclideLinesMap, tmpFile.getAbsolutePath()); Map parseMap = JSON.parseObject(strValue, Map.class); for (Map.Entry entry:parseMap.entrySet()) { - System.out.println(entry.getKey()); if (entry.getKey().equalsIgnoreCase("bAnalyed")) { boolean value = JSON.parseObject(JSON.toJSONString(entry.getValue()), Boolean.class); phd.setBAnalyed(value); @@ -1546,58 +1546,6 @@ public class GammaFileUtil { } } BeanUtils.copyProperties(phd.getSetting(), phd.getUsedSetting()); - if(CollectionUtils.isNotEmpty(phd.getMapEnerKD())) { - String key = ""; - key = phd.getNewEner(); - phd.setUsedEner(key); - GEnergyBlock source = new GEnergyBlock(); - GEnergyBlock gEnergyBlock = phd.getMapEnerKD().get(phd.getNewEner()); - BeanUtils.copyProperties(gEnergyBlock, source); - phd.setUsedEnerKD(source); - ParameterInfo info = new ParameterInfo(); - ParameterInfo parameterInfo = phd.getMapEnerPara().get(phd.getNewEner()); - BeanUtils.copyProperties(parameterInfo, info); - phd.setUsedEnerPara(info); - } - if(CollectionUtils.isNotEmpty(phd.getMapResoKD())) { - String key = ""; - key = phd.getNewReso(); - phd.setUsedReso(key); - GResolutionBlock source = new GResolutionBlock(); - GResolutionBlock gResolutionBlock = phd.getMapResoKD().get(phd.getNewReso()); - BeanUtils.copyProperties(gResolutionBlock, source); - phd.setUsedResoKD(source); - ParameterInfo info = new ParameterInfo(); - ParameterInfo parameterInfo = phd.getMapResoPara().get(phd.getNewReso()); - BeanUtils.copyProperties(parameterInfo, info); - phd.setUsedResoPara(info); - } - if(CollectionUtils.isNotEmpty(phd.getMapEffiKD())) { - String key = ""; - key = phd.getNewEffi(); - phd.setUsedEffi(key); - GEfficiencyBlock source = new GEfficiencyBlock(); - GEfficiencyBlock gEfficiencyBlock = phd.getMapEffiKD().get(phd.getNewEffi()); - BeanUtils.copyProperties(gEfficiencyBlock, source); - phd.setUsedEffiKD(source); - ParameterInfo info = new ParameterInfo(); - ParameterInfo parameterInfo = Objects.nonNull(phd.getMapEffiPara().get(phd.getNewEffi()))?phd.getMapEffiPara().get(phd.getNewEffi()):new ParameterInfo(); - BeanUtils.copyProperties(parameterInfo, info); - phd.setUsedEffiPara(info); - } - if(CollectionUtils.isNotEmpty(phd.getMapTotEKD())) { - String key = ""; - key = phd.getNewTotE(); - phd.setUsedTotE(key); - TotaleffBlock source = new TotaleffBlock(); - TotaleffBlock totaleffBlock = phd.getMapTotEKD().get(phd.getNewTotE()); - BeanUtils.copyProperties(totaleffBlock, source); - phd.setUsedTotEKD(source); - ParameterInfo info = new ParameterInfo(); - ParameterInfo parameterInfo = Objects.nonNull(phd.getMapTotEPara().get(phd.getNewTotE()))?phd.getMapTotEPara().get(phd.getNewTotE()):new ParameterInfo(); - BeanUtils.copyProperties(parameterInfo, info); - phd.setUsedTotEPara(info); - } for (PeakInfo peak:phd.getVPeak()) { if (StringUtils.isBlank(peak.recoilBetaChan)) { @@ -1810,7 +1758,7 @@ public class GammaFileUtil { private void ReadSpecialNuclides(Map mapHalflife, List vNuclides) { try { - String fileName = parameterFilePath+"/setup/nuclide_ActMdc.txt"; + String fileName = parameterProperties.getFilePath() + StringPool.SLASH +"nuclide_ActMdc.txt"; File t_file = new File(fileName); List readLines = FileUtils.readLines(t_file, "UTF-8"); for (int i=0;i< readLines.size();i++){ @@ -2061,7 +2009,7 @@ public class GammaFileUtil { public void ReadData(List m_vEnergy, List m_vNuclide) { try { - String filePath = parameterFilePath+File.separator+"Energy_Nuclide.txt"; + String filePath = parameterProperties.getFilePath() +File.separator+"Energy_Nuclide.txt"; File file = new File(filePath); List readLines = FileUtils.readLines(file, "UTF-8"); for (int i=0; i m_vCurEnergy, ParameterInfo m_curParam) { + public String UpdateEquationEfficiency(List m_vCurEnergy, ParameterInfo m_curParam, Integer funId) { String equation = ""; if(m_curParam.getP().size() > 2) { int p_size = m_curParam.getP().size()-1; int e_size = m_vCurEnergy.size(); - int funId = m_curParam.getP().get(0).intValue(); + if (Objects.isNull(funId)) { + funId = m_curParam.getP().get(0).intValue(); + } switch(funId) { case 1: // Interpolation: y=yi+(y(i+1)-yi)*(x-xi)/(x(i+1)-xi) for xi<=x= 4) { @@ -2698,7 +2648,11 @@ public class GammaFileUtil { public List DoubleLimit(List data) { List rData = new LinkedList<>(); for(int pos=0;pos org.jeecgframework.boot - jeecg-module-BetaGammaAnalyser + jeecg-module-beta-gamma-analyser diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/BgCalibratePara.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/BgCalibratePara.java similarity index 100% rename from jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/BgCalibratePara.java rename to jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/BgCalibratePara.java diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/SpectrumGroup.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/SpectrumGroup.java similarity index 94% rename from jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/SpectrumGroup.java rename to jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/SpectrumGroup.java index fbcd0dc2..4de7726c 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/SpectrumGroup.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/SpectrumGroup.java @@ -13,8 +13,6 @@ public class SpectrumGroup implements Serializable { public List b_c2e; public List g_c2e; - public Integer sampleId; - public SpectrumGroup(){ BgCalPara = new BgCalibratePara(); b_c2e = new LinkedList<>(); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/native_jni/EnergySpectrumHandler.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/native_jni/EnergySpectrumHandler.java index acf974c2..60364614 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/native_jni/EnergySpectrumHandler.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/native_jni/EnergySpectrumHandler.java @@ -1,5 +1,6 @@ package org.jeecg.modules.native_jni; +import org.jeecg.modules.entity.vo.BgCalibratePara; import org.jeecg.modules.native_jni.struct.BgAnalyseResult; import org.jeecg.modules.native_jni.struct.BgBoundary; import org.jeecg.modules.native_jni.struct.CalcBgBoundaryParam; @@ -51,4 +52,14 @@ public class EnergySpectrumHandler { */ public static native BgAnalyseResult bgAnalyse(String sampleFile, String gasFile, String detFile); + /** + * BetaGamma 重新分析算法 + * @param sampleFile + * @param gasFile + * @param detFile + * @param BgCalPara + * @return + */ + public static native BgAnalyseResult bgReAnalyse(String sampleFile, String gasFile, String detFile, BgCalibratePara BgCalPara); + } 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 6823300e..b7e2d5a9 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 @@ -21,6 +21,7 @@ import org.apache.commons.net.ftp.FTPClient; import org.jeecg.common.api.vo.Result; import org.jeecg.common.cache.LocalCache; import org.jeecg.common.constant.DateConstant; +import org.jeecg.common.properties.ParameterProperties; import org.jeecg.common.properties.SpectrumPathProperties; import org.jeecg.common.system.util.JwtUtil; import org.jeecg.common.util.*; @@ -39,6 +40,7 @@ import org.jeecg.modules.mapper.SpectrumAnalysisMapper; import org.jeecg.modules.native_jni.CalValuesHandler; import org.jeecg.modules.native_jni.struct.CalValuesOut; import org.jeecg.modules.service.*; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -89,8 +91,8 @@ public class GammaServiceImpl implements IGammaService { private FTPUtil ftpUtil; @Value("${ZeroTime}") private String ZeroTimeStr; - @Value("${parameter.filePath}") - private String parameterFilePath; + @Autowired + private ParameterProperties parameterProperties; @Autowired private IGardsAnalysesSpectrumService analysesSpectrumService; @Autowired @@ -173,7 +175,16 @@ public class GammaServiceImpl implements IGammaService { @Override public Result testFun(String fileName, HttpServletRequest request) { Result result = new Result(); + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(fileName); + phd.getSetting().setBUpdateCal(false); + phd.setUserId("1"); + phd.setXmlFilePath(parameterProperties.getFilePath()); String systemType = fileName.substring(2, 3); + if (Objects.isNull(phd)){ + result.error500("请先选择解析文件!"); + return result; + } String userName = JwtUtil.getUserNameByToken(request); //查询当前用户关联的核素信息 List nuclides = new LinkedList<>(); @@ -183,8 +194,197 @@ public class GammaServiceImpl implements IGammaService { nuclides = defaultNuclideSpectrumService.findNuclidesByUserName("admin", systemType); } Map nuclideLinesMap = GetNuclideLines(nuclides); + //解析获取临时文件信息 + File tmpFile = gammaFileUtil.analyzeFile(StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName, fileName); + ObjectMapper mapper = new ObjectMapper(); + try { + String phdStr = mapper.writeValueAsString(phd); + String mapLines = mapper.writeValueAsString(nuclideLinesMap); + String strValue = CalValuesHandler.analyseSpectrum(phdStr, mapLines, tmpFile.getAbsolutePath()); + Map parseMap = JSON.parseObject(strValue, Map.class); + for (Map.Entry entry:parseMap.entrySet()) { + if (entry.getKey().equalsIgnoreCase("bAnalyed")) { + boolean value = JSON.parseObject(JSON.toJSONString(entry.getValue()), Boolean.class); + phd.setBAnalyed(value); + } + if (entry.getKey().equalsIgnoreCase("mapEnerPara")) { + HashMap jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class); + Map value = new HashMap<>(); + for (Map.Entry objectEntry:jsonMap.entrySet()) { + String key = objectEntry.getKey(); + ParameterInfo entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), ParameterInfo.class); + value.put(key, entryValue); + } + phd.setMapEnerPara(value); + } + if (entry.getKey().equalsIgnoreCase("mapResoPara")) { + HashMap jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class); + Map value = new HashMap<>(); + for (Map.Entry objectEntry:jsonMap.entrySet()) { + String key = objectEntry.getKey(); + ParameterInfo entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), ParameterInfo.class); + value.put(key, entryValue); + } + phd.setMapResoPara(value); + } + if (entry.getKey().equalsIgnoreCase("mapEffiPara")) { + HashMap jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class); + Map value = new HashMap<>(); + for (Map.Entry objectEntry:jsonMap.entrySet()) { + String key = objectEntry.getKey(); + ParameterInfo entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), ParameterInfo.class); + value.put(key, entryValue); + } + phd.setMapEffiPara(value); + } + if (entry.getKey().equalsIgnoreCase("mapTotEPara")) { + HashMap jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class); + Map value = new HashMap<>(); + for (Map.Entry objectEntry:jsonMap.entrySet()) { + String key = objectEntry.getKey(); + ParameterInfo entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), ParameterInfo.class); + value.put(key, entryValue); + } + phd.setMapTotEPara(value); + } + if (entry.getKey().equalsIgnoreCase("para_stepRatio")) { + ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); + phd.setPara_stepRatio(value); + } + if (entry.getKey().equalsIgnoreCase("para_tail")) { + ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); + phd.setPara_tail(value); + } + if (entry.getKey().equalsIgnoreCase("para_tailAlpha")) { + ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); + phd.setPara_tailAlpha(value); + } + if (entry.getKey().equalsIgnoreCase("para_tailRight")) { + ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); + phd.setPara_tailRight(value); + } + if (entry.getKey().equalsIgnoreCase("para_tailRightAlpha")) { + ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); + phd.setPara_tailRightAlpha(value); + } + if (entry.getKey().equalsIgnoreCase("newEner")) { + String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class); + phd.setNewEner(value); + } + if (entry.getKey().equalsIgnoreCase("mapEnerKD")) { + HashMap jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class); + Map value = new HashMap<>(); + for (Map.Entry objectEntry:jsonMap.entrySet()) { + String key = objectEntry.getKey(); + GEnergyBlock entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), GEnergyBlock.class); + value.put(key, entryValue); + } + phd.setMapEnerKD(value); + } + if (entry.getKey().equalsIgnoreCase("mapResoKD")) { + HashMap jsonMap = JSON.parseObject(JSON.toJSONString(entry.getValue()), HashMap.class); + Map value = new HashMap<>(); + for (Map.Entry objectEntry:jsonMap.entrySet()) { + String key = objectEntry.getKey(); + GResolutionBlock entryValue = JSON.parseObject(JSON.toJSONString(objectEntry.getValue()), GResolutionBlock.class); + value.put(key, entryValue); + } + phd.setMapResoKD(value); + } + if (entry.getKey().equalsIgnoreCase("vEnergy")) { + List value = JSON.parseArray(JSON.toJSONString(entry.getValue()), Double.class); + phd.setVEnergy(value); + } + if (entry.getKey().equalsIgnoreCase("vBase")) { + List value = JSON.parseArray(JSON.toJSONString(entry.getValue()), Double.class); + phd.setVBase(value); + } + if (entry.getKey().equalsIgnoreCase("vLc")) { + List value = JSON.parseArray(JSON.toJSONString(entry.getValue()), Double.class); + phd.setVLc(value); + } + if (entry.getKey().equalsIgnoreCase("vScac")) { + List value = JSON.parseArray(JSON.toJSONString(entry.getValue()), Double.class); + phd.setVScac(value); + } + if (entry.getKey().equalsIgnoreCase("vPeak")) { + List value = JSON.parseArray(JSON.toJSONString(entry.getValue()), PeakInfo.class); + phd.setVPeak(value); + } + if (entry.getKey().equalsIgnoreCase("baseCtrls")) { + BaseControls value = JSON.parseObject(JSON.toJSONString(entry.getValue()), BaseControls.class); + phd.setBaseCtrls(value); + } + if (entry.getKey().equalsIgnoreCase("usedEner")) { + String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class); + phd.setUsedEner(value); + } + if (entry.getKey().equalsIgnoreCase("usedEnerKD")) { + GEnergyBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), GEnergyBlock.class); + phd.setUsedEnerKD(value); + } + if (entry.getKey().equalsIgnoreCase("usedEnerPara")) { + ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); + phd.setUsedEnerPara(value); + } + if (entry.getKey().equalsIgnoreCase("usedReso")) { + String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class); + phd.setUsedReso(value); + } + if (entry.getKey().equalsIgnoreCase("usedResoKD")) { + GResolutionBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), GResolutionBlock.class); + phd.setUsedResoKD(value); + } + if (entry.getKey().equalsIgnoreCase("usedResoPara")) { + ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); + phd.setUsedResoPara(value); + } + if (entry.getKey().equalsIgnoreCase("usedEffi")) { + String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class); + phd.setUsedEffi(value); + } + if (entry.getKey().equalsIgnoreCase("usedEffiKD")) { + GEfficiencyBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), GEfficiencyBlock.class); + phd.setUsedEffiKD(value); + } + if (entry.getKey().equalsIgnoreCase("usedEffiPara")) { + ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); + phd.setUsedEffiPara(value); + } + if (entry.getKey().equalsIgnoreCase("usedTotE")) { + String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class); + phd.setUsedTotE(value); + } + if (entry.getKey().equalsIgnoreCase("usedTotEKD")) { + TotaleffBlock value = JSON.parseObject(JSON.toJSONString(entry.getValue()), TotaleffBlock.class); + phd.setUsedTotEKD(value); + } + if (entry.getKey().equalsIgnoreCase("usedTotEPara")) { + ParameterInfo value = JSON.parseObject(JSON.toJSONString(entry.getValue()), ParameterInfo.class); + phd.setUsedTotEPara(value); + } + } + BeanUtils.copyProperties(phd.getSetting(), phd.getUsedSetting()); + + for (PeakInfo peak:phd.getVPeak()) { + if (StringUtils.isBlank(peak.recoilBetaChan)) { + peak.recoilBetaChan = "1"; + } + if (StringUtils.isBlank(peak.recoilDeltaChan)) { + peak.recoilDeltaChan = "1"; + } + } + gammaFileUtil.NuclidesIdent(phd, nuclideLinesMap); + gammaFileUtil.RunQC(phd); + result.setResult(phd); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } finally { + if (Objects.nonNull(tmpFile)) { + tmpFile.delete(); + } + } result.setSuccess(true); - result.setResult(nuclideLinesMap); return result; } @@ -461,8 +661,8 @@ public class GammaServiceImpl implements IGammaService { phd.getMapNucActMda().get(str_key).setEfficiency(nuclLinesIdedSpectrum.getEffic()); phd.getMapNucActMda().get(str_key).setEffi_err(nuclLinesIdedSpectrum.getUnEffic()); phd.getMapNucActMda().get(str_key).setMda(nuclLinesIdedSpectrum.getMda()); - phd.getMapNucActMda().get(str_key).setMdc(Double.valueOf(nuclLinesIdedSpectrum.getMdc())); - phd.getMapNucActMda().get(str_key).setConcentration(Double.valueOf(nuclLinesIdedSpectrum.getConcentration())); + phd.getMapNucActMda().get(str_key).setMdc(nuclLinesIdedSpectrum.getMdc().equalsIgnoreCase("inf")?0.0:Double.valueOf(nuclLinesIdedSpectrum.getMdc())); + phd.getMapNucActMda().get(str_key).setConcentration(nuclLinesIdedSpectrum.getConcentration().equalsIgnoreCase("inf")?0.0:Double.valueOf(nuclLinesIdedSpectrum.getConcentration())); if(phd.getMapNucActMda().get(str_key).getActivity() > 0){ phd.getMapNucActMda().get(str_key).setBCalculateMDA(true); } @@ -729,7 +929,7 @@ public class GammaServiceImpl implements IGammaService { phd.setUserId(user.getId()); } //赋值xml文件存放路径 - phd.setXmlFilePath(parameterFilePath); + phd.setXmlFilePath(parameterProperties.getFilePath()); //获取当前角色的颜色配置 Map colorMap = sysUserColorService.initColor(userName); //查询当前用户关联的核素信息 @@ -2312,7 +2512,7 @@ public class GammaServiceImpl implements IGammaService { efficiencyDataList.add(efficiencyData); } map.put("table", efficiencyDataList); - String equation = gammaFileUtil.UpdateEquationEfficiency(m_vCurEnergy, m_curParam); + String equation = gammaFileUtil.UpdateEquationEfficiency(m_vCurEnergy, m_curParam, null); map.put("equation", equation); gammaFileUtil.UpdateChartEfficiency(m_vCurEnergy, m_curParam, m_vCurEffi, phd, width, map); map.put("ECutAnalysis_Low", phd.getSetting().getECutAnalysis_Low()); @@ -2370,7 +2570,7 @@ public class GammaServiceImpl implements IGammaService { String Warning = "Fit failed. Maybe:\n1. data's number are too little;\n2. %1 isn't suitable for the data."; } map.put("table", efficiencyDataList); - String equation = gammaFileUtil.UpdateEquationEfficiency(m_vCurEnergy, m_curParam); + String equation = gammaFileUtil.UpdateEquationEfficiency(m_vCurEnergy, m_curParam, funcId); map.put("equation", equation); gammaFileUtil.UpdateChartEfficiency(m_vCurEnergy, m_curParam, m_vCurEffi, phd, width, map); } @@ -2505,7 +2705,7 @@ public class GammaServiceImpl implements IGammaService { efficiencyDataList.add(efficiencyData); } map.put("table", efficiencyDataList); - String equation = gammaFileUtil.UpdateEquationEfficiency(m_vCurEnergy, m_curParam); + String equation = gammaFileUtil.UpdateEquationEfficiency(m_vCurEnergy, m_curParam, null); map.put("equation", equation); gammaFileUtil.UpdateChartEfficiency(m_vCurEnergy, m_curParam, m_vCurEffi, phd, width, map); map.put("ECutAnalysis_Low", phd.getSetting().getECutAnalysis_Low()); @@ -3141,7 +3341,7 @@ public class GammaServiceImpl implements IGammaService { } item.setName(name); item.setFlag(iter.getValue().isBPass() ? "PASS" : "FAIL"); - item.setValue(NumUtil.fixedMax(6 ,iter.getValue().getValue())); + item.setValue( Double.parseDouble(NumberFormatUtil.numberCal(String.valueOf(iter.getValue().getValue()))) ); String standard=""; List strList = Arrays.asList(iter.getValue().getStandard().split(StringPool.COMMA)); for (String str : strList) { @@ -3258,16 +3458,16 @@ public class GammaServiceImpl implements IGammaService { TablePeakFit tablePeak = new TablePeakFit(); tablePeak.setIndex(i + 1); PeakInfo peak = phd.getVPeak().get(i); - tablePeak.setEnergy(NumUtil.keep3Str(peak.energy)); + tablePeak.setEnergy( NumberFormatUtil.numberCal(String.valueOf(peak.energy)) ); tablePeak.setEnergyErr(energy_uncert); - tablePeak.setNetArea(NumUtil.keep4ScienceStr(peak.area)); - String area_err = peak.area > 0 ? NumUtil.keep2Str(peak.areaErr/peak.area*100) : "0"; + tablePeak.setNetArea( NumberFormatUtil.numberCal(String.valueOf(peak.area)) ); + String area_err = peak.area > 0 ? NumberFormatUtil.numberCal(String.valueOf(peak.areaErr/peak.area*100)) : "0"; tablePeak.setAreaErr(area_err); - String rate = live_time > 0 ? NumUtil.keep4ScienceStr(peak.area/live_time) : "0"; + String rate = live_time > 0 ? NumberFormatUtil.numberCal(String.valueOf(peak.area/live_time)) : "0"; tablePeak.setNetCountRate(rate); tablePeak.setNcRateErr(area_err); - tablePeak.setLc(NumUtil.keep4ScienceStr(peak.lc)); - tablePeak.setSignificance(NumUtil.keep2Str(peak.significance)); + tablePeak.setLc( NumberFormatUtil.numberCal(String.valueOf(peak.lc)) ); + tablePeak.setSignificance( NumberFormatUtil.numberCal(String.valueOf(peak.significance)) ); peakFitList.add(tablePeak); } map.put("peakFit", peakFitList); 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 e966705b..7c784b04 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 @@ -385,7 +385,8 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { @Override public Result getFileSpectrumChart(String sampleFileName, String gasFileName, String detFileName, String qcFileName, HttpServletRequest request) { Result result = new Result(); - String path = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + JwtUtil.getUserNameByToken(request); + String userName = JwtUtil.getUserNameByToken(request); + String path = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; Map resultMap = new HashMap<>(); List filePath = new LinkedList<>(); Map sampleMap = new HashMap<>(); @@ -2362,30 +2363,49 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { @Override public Result ReAnalyse(AnalyseData analyseData, HttpServletRequest request) { + Result result = new Result(); String userName = JwtUtil.getUserNameByToken(request); if ("CurrentSpectrum".equals(analyseData.getApplyType())) { List sampleIds = analyseData.getSampleIds(); if (CollectionUtils.isNotEmpty(sampleIds)){ String dbName = analyseData.getDbNames().get(0); Integer sampleId = sampleIds.get(0); - Integer analysisID = spectrumAnalysisMapper.getAnalysisID(dbName, sampleId, userName); + Integer analysisID = null; + if (dbName.equalsIgnoreCase("auto")){ + dbName = "RNAUTO"; + analysisID = spectrumAnalysisMapper.getAnalysisID(dbName, sampleId, "RNAUTO"); + }else if (dbName.equalsIgnoreCase("man")){ + dbName = "RNMAN"; + analysisID = spectrumAnalysisMapper.getAnalysisID(dbName, sampleId, userName); + } SpectrumFileRecord dbSpectrumFilePath = spectrumAnalysisMapper.getDBSpectrumFilePath(dbName, sampleId,analysisID); if (Objects.nonNull(dbSpectrumFilePath)) { - BetaGammaAnalyzeCurrentProcess(analyseData, dbSpectrumFilePath, userName); + BgAnalyseResult analyseResult = BetaGammaAnalyzeCurrentProcess(analyseData, dbSpectrumFilePath, userName); + result.setSuccess(true); + result.setResult(analyseResult); } + } else { + String path = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; + SpectrumFileRecord dbSpectrumFilePath = new SpectrumFileRecord(); + dbSpectrumFilePath.setSampleFilePath(path); + dbSpectrumFilePath.setGasBgFilePath(path); + dbSpectrumFilePath.setDetBgFilePath(path); + BgAnalyseResult analyseResult = BetaGammaAnalyzeCurrentProcess(analyseData, dbSpectrumFilePath, userName); + result.setSuccess(true); + result.setResult(analyseResult); } - } else if ("AllSpectrum".equals(analyseData.getApplyType())) { - Map m_loadData = new HashMap<>(); - for (int i=0; i m_loadData = new HashMap<>(); +// for (int i=0; iBetaOriginalChartView->SetFittingParam(fit_analy_param.b_calibration_param.param_a_c2e_new, // fit_analy_param.b_calibration_param.param_b_c2e_new, @@ -2402,96 +2422,126 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService { // fit_analy_param.g_calibration_param.param_b_c2e_new, // fit_analy_param.g_calibration_param.param_c_c2e_new); // } - - return null; + return result; } - private void BetaGammaAnalyzeCurrentProcess(AnalyseData analyseData, SpectrumFileRecord dbSpectrumFilePath, String userName){ + private BgAnalyseResult BetaGammaAnalyzeCurrentProcess(AnalyseData analyseData, SpectrumFileRecord dbSpectrumFilePath, String userName){ SpectrumGroup spectrum_group = new SpectrumGroup(); - spectrum_group.sampleId = dbSpectrumFilePath.getSampleId(); - spectrum_group.SampleSpectrumFile = dbSpectrumFilePath.getSampleFilePath(); - spectrum_group.GasBgSpectrumFile = dbSpectrumFilePath.getGasBgFilePath(); - spectrum_group.DetBgSpectrumFile = dbSpectrumFilePath.getDetBgFilePath(); - + String sampleFilePath = dbSpectrumFilePath.getSampleFilePath().substring(0, dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH)); + String sampleFileName = dbSpectrumFilePath.getSampleFilePath().substring(dbSpectrumFilePath.getSampleFilePath().lastIndexOf(StringPool.SLASH)+1); + String gasFilePath = dbSpectrumFilePath.getGasBgFilePath().substring(0, dbSpectrumFilePath.getGasBgFilePath().lastIndexOf(StringPool.SLASH)); + String gasFileName = dbSpectrumFilePath.getGasBgFilePath().substring(dbSpectrumFilePath.getGasBgFilePath().lastIndexOf(StringPool.SLASH)+1); + String detFilePath = dbSpectrumFilePath.getDetBgFilePath().substring(0, dbSpectrumFilePath.getDetBgFilePath().lastIndexOf(StringPool.SLASH)); + String detFileName = dbSpectrumFilePath.getDetBgFilePath().substring(dbSpectrumFilePath.getDetBgFilePath().lastIndexOf(StringPool.SLASH)+1); + List qcFileNames = analyseData.getQcFileNames(); + String qcFileName = qcFileNames.get(0); + //从本地缓存获取beta gamma的数组 + Cache> cache = betaCache.getBetaCache(); + //根据qc文件名称-用户名-beta的方式获取beta的内容 + Map betaMap = cache.getIfPresent(qcFileName + "-" + userName + "-beta"); + List betaList = new LinkedList<>(); + List betaFittingPara = new LinkedList<>(); + List betaFittingParaToUi = new LinkedList<>(); + if (CollectionUtils.isNotEmpty(betaMap)) { + betaList = (List)betaMap.get("Series"); + betaFittingPara = (List) betaMap.get("fittingPara"); + betaFittingParaToUi = (List) betaMap.get("fittingParaToUi"); + } + //根据qc文件名称-用户名-gamma的方式获取gamma的内容 + Map gammaMap = cache.getIfPresent(qcFileName + "-" + userName + "-gamma"); + List gammaList = new LinkedList<>(); + List gammaFittingPara = new LinkedList<>(); + List gammaFittingParaToUi = new LinkedList<>(); + if (CollectionUtils.isNotEmpty(gammaMap)) { + gammaList = (List)gammaMap.get("Series"); + gammaFittingPara = (List) gammaMap.get("fittingPara"); + gammaFittingParaToUi = (List) gammaMap.get("fittingParaToUi"); + } if (analyseData.isBBetaEnergyValid()) { List beCal = new LinkedList<>(); - beCal.add(analyseData.getB_calibration_param().param_c_e2c_new); - beCal.add(analyseData.getB_calibration_param().param_b_e2c_new); - beCal.add(analyseData.getB_calibration_param().param_a_e2c_new); + beCal.add(Double.valueOf(betaFittingParaToUi.get(0))); + beCal.add(Double.valueOf(betaFittingParaToUi.get(1))); + beCal.add(Double.valueOf(betaFittingParaToUi.get(2))); spectrum_group.BgCalPara.b_e_cal = beCal; List bc2e = new LinkedList<>(); - bc2e.add(analyseData.getB_calibration_param().param_c_c2e_new); - bc2e.add(analyseData.getB_calibration_param().param_b_c2e_new); - bc2e.add(analyseData.getB_calibration_param().param_a_c2e_new); + bc2e.add(Double.valueOf(betaFittingPara.get(0))); + bc2e.add(Double.valueOf(betaFittingPara.get(1))); + bc2e.add(Double.valueOf(betaFittingPara.get(2))); spectrum_group.b_c2e = bc2e; } if (analyseData.isBGammaEnergyValid()) { List geCal = new LinkedList<>(); - geCal.add(analyseData.getG_calibration_param().param_c_e2c_new); - geCal.add(analyseData.getG_calibration_param().param_b_e2c_new); - geCal.add(analyseData.getG_calibration_param().param_a_e2c_new); + geCal.add(Double.valueOf(gammaFittingParaToUi.get(0))); + geCal.add(Double.valueOf(gammaFittingParaToUi.get(1))); + geCal.add(Double.valueOf(gammaFittingParaToUi.get(2))); spectrum_group.BgCalPara.g_e_cal = geCal; List gc2e = new LinkedList<>(); - gc2e.add(analyseData.getG_calibration_param().param_c_c2e_new); - gc2e.add(analyseData.getG_calibration_param().param_b_c2e_new); - gc2e.add(analyseData.getG_calibration_param().param_a_c2e_new); + gc2e.add(Double.valueOf(gammaFittingPara.get(0))); + gc2e.add(Double.valueOf(gammaFittingPara.get(1))); + gc2e.add(Double.valueOf(gammaFittingPara.get(2))); spectrum_group.g_c2e = gc2e; } spectrum_group.BgCalPara.bApplyNewCalicSample = analyseData.isSampleData(); spectrum_group.BgCalPara.bApplyNewCalicGasBg = analyseData.isGasBgData(); spectrum_group.BgCalPara.bApplyNewCalicDetBg = analyseData.isDetBgData(); - spectrum_group.BgCalPara.bApplyNewCalicQc = analyseData.isQCData(); - + spectrum_group.BgCalPara.bApplyNewCalicQc = analyseData.isQcData(); + System.loadLibrary("ReadPHDFile"); + //根据文件路径 文件名称获取对应的临时文件 + File sampleTmp = phdFileUtil.analyzeFile(sampleFilePath, sampleFileName); + File gasTmp = phdFileUtil.analyzeFile(gasFilePath, gasFileName); + File detTmp = phdFileUtil.analyzeFile(detFilePath, detFileName); + BgAnalyseResult analyseResult = EnergySpectrumHandler.bgReAnalyse(sampleTmp.getAbsolutePath(), gasTmp.getAbsolutePath(), detTmp.getAbsolutePath(), spectrum_group.BgCalPara); + return analyseResult; } - private void BetaGammaAnalyzeAllProcess(Map m_loadData, AnalyseData analyseData){ - List spectrum_group_list = new LinkedList<>(); - for (Map.Entry entry: m_loadData.entrySet()){ - SpectrumGroup spectrum_group = new SpectrumGroup(); - SpectrumFileRecord spectrumFileRecord = entry.getValue(); - spectrum_group.SampleSpectrumFile = spectrumFileRecord.getSampleFilePath(); - spectrum_group.GasBgSpectrumFile = spectrumFileRecord.getGasBgFilePath(); - spectrum_group.DetBgSpectrumFile = spectrumFileRecord.getDetBgFilePath(); - - if (analyseData.isBBetaEnergyValid()) { - List beCal = new LinkedList<>(); - beCal.add(analyseData.getB_calibration_param().param_c_e2c_new); - beCal.add(analyseData.getB_calibration_param().param_b_e2c_new); - beCal.add(analyseData.getB_calibration_param().param_a_e2c_new); - spectrum_group.BgCalPara.b_e_cal = beCal; - List bc2e = new LinkedList<>(); - bc2e.add(analyseData.getB_calibration_param().param_c_c2e_new); - bc2e.add(analyseData.getB_calibration_param().param_b_c2e_new); - bc2e.add(analyseData.getB_calibration_param().param_a_c2e_new); - spectrum_group.b_c2e = bc2e; - } - if (analyseData.isBGammaEnergyValid()) { - List geCal = new LinkedList<>(); - geCal.add(analyseData.getG_calibration_param().param_c_e2c_new); - geCal.add(analyseData.getG_calibration_param().param_b_e2c_new); - geCal.add(analyseData.getG_calibration_param().param_a_e2c_new); - spectrum_group.BgCalPara.g_e_cal = geCal; - List gc2e = new LinkedList<>(); - gc2e.add(analyseData.getG_calibration_param().param_c_c2e_new); - gc2e.add(analyseData.getG_calibration_param().param_b_c2e_new); - gc2e.add(analyseData.getG_calibration_param().param_a_c2e_new); - spectrum_group.g_c2e = gc2e; - } - spectrum_group.BgCalPara.bApplyNewCalicSample = analyseData.isSampleData(); - spectrum_group.BgCalPara.bApplyNewCalicGasBg = analyseData.isGasBgData(); - spectrum_group.BgCalPara.bApplyNewCalicDetBg = analyseData.isDetBgData(); - spectrum_group.BgCalPara.bApplyNewCalicQc = analyseData.isQCData(); - - spectrum_group_list.add(spectrum_group); - } - - if (CollectionUtils.isNotEmpty(spectrum_group_list)) { -// beta_gamma_analy.SetSpectrumGroupList(spectrum_group_list); -// AnalyProcessDlg analy_dlg(beta_gamma_analy); -// analy_dlg.SetProgressRange(0, spectrum_group_list.count()); -// analy_dlg.exec(); - } - } +// private void BetaGammaAnalyzeAllProcess(Map m_loadData, AnalyseData analyseData){ +// List spectrum_group_list = new LinkedList<>(); +// for (Map.Entry entry: m_loadData.entrySet()){ +// SpectrumGroup spectrum_group = new SpectrumGroup(); +// SpectrumFileRecord spectrumFileRecord = entry.getValue(); +// spectrum_group.SampleSpectrumFile = spectrumFileRecord.getSampleFilePath(); +// spectrum_group.GasBgSpectrumFile = spectrumFileRecord.getGasBgFilePath(); +// spectrum_group.DetBgSpectrumFile = spectrumFileRecord.getDetBgFilePath(); +// +// if (analyseData.isBBetaEnergyValid()) { +// List beCal = new LinkedList<>(); +// beCal.add(analyseData.getB_calibration_param().param_c_e2c_new); +// beCal.add(analyseData.getB_calibration_param().param_b_e2c_new); +// beCal.add(analyseData.getB_calibration_param().param_a_e2c_new); +// spectrum_group.BgCalPara.b_e_cal = beCal; +// List bc2e = new LinkedList<>(); +// bc2e.add(analyseData.getB_calibration_param().param_c_c2e_new); +// bc2e.add(analyseData.getB_calibration_param().param_b_c2e_new); +// bc2e.add(analyseData.getB_calibration_param().param_a_c2e_new); +// spectrum_group.b_c2e = bc2e; +// } +// if (analyseData.isBGammaEnergyValid()) { +// List geCal = new LinkedList<>(); +// geCal.add(analyseData.getG_calibration_param().param_c_e2c_new); +// geCal.add(analyseData.getG_calibration_param().param_b_e2c_new); +// geCal.add(analyseData.getG_calibration_param().param_a_e2c_new); +// spectrum_group.BgCalPara.g_e_cal = geCal; +// List gc2e = new LinkedList<>(); +// gc2e.add(analyseData.getG_calibration_param().param_c_c2e_new); +// gc2e.add(analyseData.getG_calibration_param().param_b_c2e_new); +// gc2e.add(analyseData.getG_calibration_param().param_a_c2e_new); +// spectrum_group.g_c2e = gc2e; +// } +// spectrum_group.BgCalPara.bApplyNewCalicSample = analyseData.isSampleData(); +// spectrum_group.BgCalPara.bApplyNewCalicGasBg = analyseData.isGasBgData(); +// spectrum_group.BgCalPara.bApplyNewCalicDetBg = analyseData.isDetBgData(); +// spectrum_group.BgCalPara.bApplyNewCalicQc = analyseData.isQcData(); +// +// spectrum_group_list.add(spectrum_group); +// } +// +// if (CollectionUtils.isNotEmpty(spectrum_group_list)) { +//// beta_gamma_analy.SetSpectrumGroupList(spectrum_group_list); +//// AnalyProcessDlg analy_dlg(beta_gamma_analy); +//// analy_dlg.SetProgressRange(0, spectrum_group_list.count()); +//// analy_dlg.exec(); +// } +// } @Override public Result analyseCurrentSpectrum(String dbName, Integer sampleId, String sampleFileName, String gasFileName, String detFileName, HttpServletRequest request) { diff --git a/jeecg-module-station-operation/src/main/java/org/jeecg/common/CalculateStationData.java b/jeecg-module-station-operation/src/main/java/org/jeecg/common/CalculateStationData.java index 90caa72a..9903f738 100644 --- a/jeecg-module-station-operation/src/main/java/org/jeecg/common/CalculateStationData.java +++ b/jeecg-module-station-operation/src/main/java/org/jeecg/common/CalculateStationData.java @@ -1,7 +1,9 @@ package org.jeecg.common; import lombok.extern.slf4j.Slf4j; +import org.jeecg.common.properties.ParameterProperties; import org.jeecg.modules.entity.data.*; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import org.w3c.dom.*; @@ -22,8 +24,8 @@ import java.util.concurrent.TimeUnit; @Component public class CalculateStationData { - @Value("${parameter.filePath}") - private String parameterFilePath; + @Autowired + private ParameterProperties parameterProperties; /** * 初始化配置信息 @@ -31,7 +33,7 @@ public class CalculateStationData { public RateParam initParameter() { try { //文件路径 - String filePath = parameterFilePath+ File.separator +"parameter.xml"; + String filePath = parameterProperties.getFilePath()+ File.separator +"parameter.xml"; //声明一个实体类存储参数信息 RateParam mRateParam = new RateParam(); //创建一个文档解析器工厂 diff --git a/jeecg-server-cloud/jeecg-auto-process-start/src/main/java/org/jeecg/JeecgAutoProcessApplication.java b/jeecg-server-cloud/jeecg-auto-process-start/src/main/java/org/jeecg/JeecgAutoProcessApplication.java index 4f477f36..2b62faeb 100644 --- a/jeecg-server-cloud/jeecg-auto-process-start/src/main/java/org/jeecg/JeecgAutoProcessApplication.java +++ b/jeecg-server-cloud/jeecg-auto-process-start/src/main/java/org/jeecg/JeecgAutoProcessApplication.java @@ -65,8 +65,8 @@ public class JeecgAutoProcessApplication extends SpringBootServletInitializer im if(EmailReceivePolicy.CURR_DATE_ORDER_RECEIVE.getPolicy().equals(taskProperties.getReceivePolicy())){ systemStartupTime = new Date(); } - autoProcessManager.start(systemStartupTime); - undealHandleManager.start(); +// autoProcessManager.start(systemStartupTime); +// undealHandleManager.start(); fileSourceHandleManager.start(); } } \ No newline at end of file diff --git a/pom.xml b/pom.xml index 371400cc..ca65834a 100644 --- a/pom.xml +++ b/pom.xml @@ -84,7 +84,7 @@ jeecg-module-abnormal-alarm jeecg-module-auto-process jeecg-module-spectrum-analysis - jeecg-module-BetaGammaAnalyser + jeecg-module-beta-gamma-analyser @@ -202,10 +202,10 @@ jeecg-module-spectrum-analysis ${jeecgboot.version} - + org.jeecgframework.boot - jeecg-module-BetaGammaAnalyser + jeecg-module-beta-gamma-analyser ${jeecgboot.version}