diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/AcquisitionBlock.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/AcquisitionBlock.java index ad551e00..6808c1ee 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/AcquisitionBlock.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/AcquisitionBlock.java @@ -12,9 +12,9 @@ public class AcquisitionBlock implements Serializable { private String acquisition_start_time; // acquisition start time (hh : mm : ss . s) - private Double acquisition_real_time; // acquisition real time (s) + private double acquisition_real_time; // acquisition real time (s) - private Double acquisition_live_time; // acquisition live time (s) + private double acquisition_live_time; // acquisition live time (s) public AcquisitionBlock(){ acquisition_start_date=""; diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/BaseControls.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/BaseControls.java index f78b3977..aaec4cf0 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/BaseControls.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/BaseControls.java @@ -17,17 +17,19 @@ public class BaseControls implements Serializable { private List YSlope; private List Baseline; private List StepCounts; + private List BaseStack; public BaseControls(){ rg_low = 1; rg_high = 1; ReplotUsed = false; ReplotNeeded = false; - XCtrl=new LinkedList<>(); - YCtrl=new LinkedList<>(); - YSlope=new LinkedList<>(); - Baseline=new LinkedList<>(); - StepCounts=new LinkedList<>(); + XCtrl = new LinkedList<>(); + YCtrl = new LinkedList<>(); + YSlope = new LinkedList<>(); + Baseline = new LinkedList<>(); + StepCounts = new LinkedList<>(); + BaseStack = new LinkedList<>(); } } diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/BaseCtrlStack.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/BaseCtrlStack.java new file mode 100644 index 00000000..fef35815 --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/BaseCtrlStack.java @@ -0,0 +1,24 @@ +package org.jeecg.modules.entity.vo; + +import lombok.Data; + +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; + +@Data +public class BaseCtrlStack implements Serializable { + + private List cx; + + private List cy; + + private List cdy; + + public BaseCtrlStack(){ + cx = new LinkedList<>(); + cy = new LinkedList<>(); + cdy = new LinkedList<>(); + } + +} diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/GEfficiencyBlock.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/GEfficiencyBlock.java index 002936c2..b016d7dc 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/GEfficiencyBlock.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/GEfficiencyBlock.java @@ -15,7 +15,7 @@ public class GEfficiencyBlock implements Serializable { private List uncertainty; // uncertainty (counts in peak/photon emitted) - private Integer record_count; + private int record_count; public GEfficiencyBlock(){ g_energy = new LinkedList<>(); diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/GEnergyBlock.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/GEnergyBlock.java index b1c30949..a13d3f71 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/GEnergyBlock.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/GEnergyBlock.java @@ -15,7 +15,7 @@ public class GEnergyBlock implements Serializable { private List uncertainty; // uncertainty (channels) - private Integer record_count; + private int record_count; public GEnergyBlock(){ g_energy = new LinkedList<>(); diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/GResolutionBlock.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/GResolutionBlock.java index 90363fce..a1c9da7d 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/GResolutionBlock.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/GResolutionBlock.java @@ -15,7 +15,7 @@ public class GResolutionBlock implements Serializable { private List uncertainty; // uncertainty (keV) - private Integer record_count; + private int record_count; public GResolutionBlock(){ g_energy = new LinkedList<>(); diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/NuclideLines.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/NuclideLines.java index b5917aa8..994bbed0 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/NuclideLines.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/NuclideLines.java @@ -9,10 +9,10 @@ import java.util.List; @Data public class NuclideLines implements Serializable { public List fullNames; // 核素全名 - public List vEnergy; // 核素的所有γ射线能量 - public List vUncertE; - public List vYield; // 核素γ射线分支比 - public List vUncertY; + public List venergy; // 核素的所有γ射线能量 + public List vuncertE; + public List vyield; // 核素γ射线分支比 + public List vuncertY; public double halflife;// 单位:秒 public int key_flag; // 记录主射线下标 public int maxYeildIdx; @@ -22,10 +22,10 @@ public class NuclideLines implements Serializable { key_flag = -1; halflife = 0; fullNames=new LinkedList<>(); - vEnergy=new LinkedList<>(); - vUncertE=new LinkedList<>(); - vYield=new LinkedList<>(); - vUncertY=new LinkedList<>(); + venergy=new LinkedList<>(); + vuncertE=new LinkedList<>(); + vyield=new LinkedList<>(); + vuncertY=new LinkedList<>(); } } diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/PHDFile.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/PHDFile.java index 29b4fd5f..0739895b 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/PHDFile.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/PHDFile.java @@ -13,6 +13,10 @@ import java.util.Map; @JsonIgnoreProperties(ignoreUnknown = true) public class PHDFile implements Serializable { + private String userId; + + private String xmlFilePath; + private boolean isValid; // 是否有效谱 private boolean bAnalyed; // 记录是否被分析 diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/SpecSetup.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/SpecSetup.java index 3a86e209..60999248 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/SpecSetup.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/entity/vo/SpecSetup.java @@ -46,7 +46,7 @@ public class SpecSetup implements Serializable { public SpecSetup(){ eCutAnalysis_Low = 12.0; - eCutAnalysis_High = 12.0; + eCutAnalysis_High = -9999.0; energyTolerance = 0.5; calibrationPSS_high = 10.0; calibrationPSS_low = 5.0; diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/common/GammaFileUtil.java b/jeecg-module-auto-process/src/main/java/org/jeecg/common/GammaFileUtil.java index ca7b2c77..74796de3 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/common/GammaFileUtil.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/common/GammaFileUtil.java @@ -1603,8 +1603,8 @@ public class GammaFileUtil { } FilterNuclideLine(iter.getValue(), phd.getUsedSetting().getECutAnalysis_Low()); // 过滤核素能量小于ECutAnalysis_Low的射线 - List vEnergy = iter.getValue().vEnergy; // 该核素的所有γ射线能量 - List vYield = iter.getValue().vYield; + List vEnergy = iter.getValue().venergy; // 该核素的所有γ射线能量 + List vYield = iter.getValue().vyield; List vEffi = CalValuesHandler.calFcnEval(vEnergy, phd.getUsedEffiPara().getP()).counts; // 该核素所有γ射线能量处的探测效率 List vFit = new LinkedList<>(); // γ射线能量与峰中心道能量匹配标识 for (int i=0; i vE = lines.vEnergy; + List vE = lines.venergy; for(int i=0, j=0; i 0) { - List vY = lines.vYield; + if(lines.key_flag < 0 && lines.venergy.size() > 0) { + List vY = lines.vyield; lines.maxYeildIdx = 0; double maxYield = vY.get(0); for(int ii=1; ii nuclideLineList = spectrumAnalysisMapper.getNuclideLines(name); for(int j=0;j 0) { nlines.key_flag = j; nlines.maxYeildIdx = j; @@ -3932,7 +3932,7 @@ public class GammaFileUtil { ReadSpecialNuclides(mapHalflife, vNuclides); double energyWidth = phd.getUsedSetting().getEnergyTolerance(); - List vEnergy = lines.vEnergy; // 该核素的所有γ射线能量 + List vEnergy = lines.venergy; // 该核素的所有γ射线能量 double maxYield = 0; int mainPeakIdx = -1; // 记录核素主γ峰的索引下标 @@ -3945,9 +3945,9 @@ public class GammaFileUtil { break; } else if(vEnergy.get(i) <= energy + energyWidth) { ActMda.getVEnergy().add(vEnergy.get(i)); - ActMda.getVUncertE().add(lines.vUncertE.get(i)); - ActMda.getVYield().add(lines.vYield.get(i)); - ActMda.getVUncertY().add(lines.vUncertY.get(i)); + ActMda.getVUncertE().add(lines.vuncertE.get(i)); + ActMda.getVYield().add(lines.vyield.get(i)); + ActMda.getVUncertY().add(lines.vuncertY.get(i)); ActMda.getFullNames().add(lines.fullNames.get(i)); ActMda.getVPeakIdx().add(vPeakIdx.get(j)+1); if(lines.key_flag == i) { diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java index a315cfcc..58e7573a 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java @@ -1,9 +1,13 @@ package org.jeecg.common.util; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.StringPool; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.commons.lang3.StringUtils; import org.apache.commons.io.FileUtils; +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; @@ -101,7 +105,7 @@ public class GammaFileUtil { //Comment phd.setOriTotalCmt(struct.comment); //Collection - if (StringUtils.isNotBlank(struct.collection_start_date) || StringUtils.isNotBlank(struct.collection_start_time) || StringUtils.isNotBlank(struct.collection_stop_date) || StringUtils.isNotBlank(struct.collection_stop_time) || Objects.nonNull(struct.air_volume)) { + if (StringUtils.isNotBlank(struct.collection_start_date) && StringUtils.isNotBlank(struct.collection_start_time) && StringUtils.isNotBlank(struct.collection_stop_date) && StringUtils.isNotBlank(struct.collection_stop_time) && Objects.nonNull(struct.air_volume)) { phd.getCollect().setCollection_start_date(struct.collection_start_date); phd.getCollect().setCollection_start_time(struct.collection_start_time); phd.getCollect().setCollection_stop_date(struct.collection_stop_date); @@ -117,7 +121,7 @@ public class GammaFileUtil { phd.getCollect().setAir_volume(0.0); } //Acquisition - if (StringUtils.isNotBlank(struct.acquisition_start_date) || StringUtils.isNotBlank(struct.acquisition_start_time) || Objects.nonNull(struct.acquisition_real_time) || Objects.nonNull(struct.acquisition_live_time)) { + if (StringUtils.isNotBlank(struct.acquisition_start_date) && StringUtils.isNotBlank(struct.acquisition_start_time) && Objects.nonNull(struct.acquisition_real_time) && Objects.nonNull(struct.acquisition_live_time)) { phd.getAcq().setAcquisition_start_date(struct.acquisition_start_date); phd.getAcq().setAcquisition_start_time(struct.acquisition_start_time); phd.getAcq().setAcquisition_real_time(struct.acquisition_real_time); @@ -130,7 +134,7 @@ public class GammaFileUtil { phd.getAcq().setAcquisition_real_time(0.0); } //Processing - if (Objects.nonNull(struct.sample_volume_of_Xe) || Objects.nonNull(struct.uncertainty_1) || Objects.nonNull(struct.Xe_collection_yield) || Objects.nonNull(struct.uncertainty_2) || StringUtils.isNotBlank(struct.archive_bottle_id)) { + if (Objects.nonNull(struct.sample_volume_of_Xe) && Objects.nonNull(struct.uncertainty_1) && Objects.nonNull(struct.Xe_collection_yield) && Objects.nonNull(struct.uncertainty_2) && StringUtils.isNotBlank(struct.archive_bottle_id)) { phd.getProcess().setSample_volume_of_Xe(struct.sample_volume_of_Xe); phd.getProcess().setUncertainty_1(struct.uncertainty_1); phd.getProcess().setXe_collection_yield(struct.Xe_collection_yield); @@ -143,7 +147,7 @@ public class GammaFileUtil { phd.getProcess().setUncertainty_2(0.0); } //Sample - if (Objects.nonNull(struct.dimension_1) || Objects.nonNull(struct.dimension_2)) { + if (Objects.nonNull(struct.dimension_1) && Objects.nonNull(struct.dimension_2)) { phd.getSampleBlock().setDimension_1(struct.dimension_1); phd.getSampleBlock().setDimension_2(struct.dimension_2); } else { @@ -151,14 +155,14 @@ public class GammaFileUtil { phd.getSampleBlock().setDimension_2(0.0); } //Calibration - if (StringUtils.isNotBlank(struct.date_calibration) || StringUtils.isNotBlank(struct.time_calibration)) { + if (StringUtils.isNotBlank(struct.date_calibration) && StringUtils.isNotBlank(struct.time_calibration)) { phd.getCalibration().setDate_calibration(struct.date_calibration); phd.getCalibration().setTime_calibration(struct.time_calibration); } //Certificate - if (Objects.nonNull(struct.total_source_activity) || StringUtils.isNotBlank(struct.assay_date) || StringUtils.isNotBlank(struct.assay_time) || StringUtils.isNotBlank(struct.units_activity) || CollectionUtils.isNotEmpty(struct.nuclide_name) - || CollectionUtils.isNotEmpty(struct.half_life_time) || CollectionUtils.isNotEmpty(struct.time_unit) || CollectionUtils.isNotEmpty(struct.activity_nuclide_time_assay) || CollectionUtils.isNotEmpty(struct.uncertainty) - || CollectionUtils.isNotEmpty(struct.cer_g_energy) || CollectionUtils.isNotEmpty(struct.g_intensity) || CollectionUtils.isNotEmpty(struct.electron_decay_mode) || CollectionUtils.isNotEmpty(struct.maximum_energy) || CollectionUtils.isNotEmpty(struct.intensity_b_particle) || Objects.nonNull(struct.record_count)) { + if (Objects.nonNull(struct.total_source_activity) && StringUtils.isNotBlank(struct.assay_date) && StringUtils.isNotBlank(struct.assay_time) && StringUtils.isNotBlank(struct.units_activity) && CollectionUtils.isNotEmpty(struct.nuclide_name) + && CollectionUtils.isNotEmpty(struct.half_life_time) && CollectionUtils.isNotEmpty(struct.time_unit) && CollectionUtils.isNotEmpty(struct.activity_nuclide_time_assay) && CollectionUtils.isNotEmpty(struct.uncertainty) + && CollectionUtils.isNotEmpty(struct.cer_g_energy) && CollectionUtils.isNotEmpty(struct.g_intensity) && CollectionUtils.isNotEmpty(struct.electron_decay_mode) && CollectionUtils.isNotEmpty(struct.maximum_energy) && CollectionUtils.isNotEmpty(struct.intensity_b_particle) && Objects.nonNull(struct.record_count)) { phd.getCertificate().setTotal_source_activity(struct.total_source_activity); phd.getCertificate().setAssay_date(struct.assay_date); phd.getCertificate().setAssay_time(struct.assay_time); @@ -176,7 +180,7 @@ public class GammaFileUtil { phd.getCertificate().setRecord_count(struct.record_count); } //g_Spectrum - if (Objects.nonNull(struct.num_g_channel) || Objects.nonNull(struct.g_energy_span) || Objects.nonNull(struct.g_begin_channel) || CollectionUtils.isNotEmpty(struct.g_counts)) { + if (Objects.nonNull(struct.num_g_channel) && Objects.nonNull(struct.g_energy_span) && Objects.nonNull(struct.g_begin_channel) && CollectionUtils.isNotEmpty(struct.g_counts)) { phd.getSpec().setNum_g_channel(struct.num_g_channel); phd.getSpec().setG_energy_span(struct.g_energy_span); phd.getSpec().setBegin_channel(struct.g_begin_channel); @@ -192,7 +196,7 @@ public class GammaFileUtil { } } //g_Energy - if (CollectionUtils.isNotEmpty(struct.g_energy) || CollectionUtils.isNotEmpty(struct.g_centroid_channel) || CollectionUtils.isNotEmpty(struct.g_uncertainty) || Objects.nonNull(struct.g_record_count)) { + if (CollectionUtils.isNotEmpty(struct.g_energy) && CollectionUtils.isNotEmpty(struct.g_centroid_channel) && CollectionUtils.isNotEmpty(struct.g_uncertainty) && Objects.nonNull(struct.g_record_count)) { GEnergyBlock gEnergyBlock = new GEnergyBlock(); gEnergyBlock.setG_energy(struct.g_energy); gEnergyBlock.setCentroid_channel(struct.g_centroid_channel); @@ -201,7 +205,7 @@ public class GammaFileUtil { phd.getMapEnerKD().put(CalName.CalPHD.getType(), gEnergyBlock); } //g_Resolution - if (CollectionUtils.isNotEmpty(struct.g_r_energy) || CollectionUtils.isNotEmpty(struct.g_r_FWHM) || CollectionUtils.isNotEmpty(struct.g_r_uncertainty) || Objects.nonNull(struct.g_r_record_count)) { + if (CollectionUtils.isNotEmpty(struct.g_r_energy) && CollectionUtils.isNotEmpty(struct.g_r_FWHM) && CollectionUtils.isNotEmpty(struct.g_r_uncertainty) && Objects.nonNull(struct.g_r_record_count)) { GResolutionBlock gResolutionBlock = new GResolutionBlock(); gResolutionBlock.setG_energy(struct.g_r_energy); gResolutionBlock.setFWHM(struct.g_r_FWHM); @@ -210,7 +214,7 @@ public class GammaFileUtil { phd.getMapResoKD().put(CalName.CalPHD.getType(), gResolutionBlock); } //g_Efficiency - if (CollectionUtils.isNotEmpty(struct.g_e_energy) || CollectionUtils.isNotEmpty(struct.g_e_efficiency) || CollectionUtils.isNotEmpty(struct.g_e_uncertainty) || Objects.nonNull(struct.g_e_record_count)) { + if (CollectionUtils.isNotEmpty(struct.g_e_energy) && CollectionUtils.isNotEmpty(struct.g_e_efficiency) && CollectionUtils.isNotEmpty(struct.g_e_uncertainty) && Objects.nonNull(struct.g_e_record_count)) { GEfficiencyBlock gEfficiencyBlock = new GEfficiencyBlock(); gEfficiencyBlock.setG_energy(struct.g_e_energy); gEfficiencyBlock.setEfficiency(struct.g_e_efficiency); @@ -219,7 +223,7 @@ public class GammaFileUtil { phd.getMapEffiKD().put(CalName.CalPHD.getType(), gEfficiencyBlock); } //TotalEff - if (CollectionUtils.isNotEmpty(struct.t_g_energy) || CollectionUtils.isNotEmpty(struct.total_efficiency) || CollectionUtils.isNotEmpty(struct.t_uncertainty) || Objects.nonNull(struct.t_record_count)) { + if (CollectionUtils.isNotEmpty(struct.t_g_energy) && CollectionUtils.isNotEmpty(struct.total_efficiency) && CollectionUtils.isNotEmpty(struct.t_uncertainty) && Objects.nonNull(struct.t_record_count)) { TotaleffBlock totaleffBlock = new TotaleffBlock(); totaleffBlock.setG_energy(struct.t_g_energy); totaleffBlock.setTotal_efficiency(struct.total_efficiency); @@ -365,10 +369,7 @@ public class GammaFileUtil { String baselineFileName = "RNAUTO_"+subFileName + ".baseline"; inputStream = ftpClient.retrieveFileStream(baselineFileName); if (Objects.nonNull(inputStream)){ - long start = System.currentTimeMillis(); ReadBaseCtrlInfo(phd, inputStream); - long end = System.currentTimeMillis(); - System.out.println(end-start); phd.setVBase(phd.getBaseCtrls().getBaseline()); } } catch (IOException e) { @@ -1469,7 +1470,7 @@ public class GammaFileUtil { return datalist; } - public boolean AnalyseData(PHDFile phd, ConfigureData configureData, List nuclides, boolean bSingle) { + public int AnalyseData(PHDFile phd, ConfigureData configureData, List nuclides, Result result) { //调用方法判断是否修改了参数 if (Objects.nonNull(configureData)){ SpecSetup phdSetting = phd.getSetting(); @@ -1487,8 +1488,9 @@ public class GammaFileUtil { } int change = SettingChanged(phd); - if(change == 0 && phd.getVPeak().size() > 0) return false; - else if(change == -1) { + if(change == 0 && phd.getVPeak().size() > 0) { + return change; + } else if(change == -1) { phd.setUsedEffi(phd.getNewEffi()); phd.setUsedEffiKD(phd.getMapEffiKD().get(phd.getNewEffi())); phd.setUsedEffiPara(phd.getMapEffiPara().get(phd.getNewEffi())); @@ -1496,24 +1498,31 @@ public class GammaFileUtil { Map nuclideLinesMap = GetNuclideLines(nuclides); NuclidesIdent(phd, nuclideLinesMap); RunQC(phd); - String Warning = "Finish three tasks:\n"+ + result.error500("Finish three tasks:\n"+ "\t1.Update efficiencies of all peaks;\n"+ "\t2.Identify nuclides again;\n"+ - "\t3.Test QC again."; + "\t3.Test QC again."); } else { - if(bSingle) { -// AnalyseFlowChart flow_dlg(this); -// flow_dlg.exec(); - } else { - Map nuclideLinesMap = GetNuclideLines(nuclides); -// AnalyseSpectrum(phd, nuclideLinesMap); - } + Map nuclideLinesMap = GetNuclideLines(nuclides); + AnalyseSpectrum(phd, nuclideLinesMap); } - return true; + return change; } - public boolean AnalyseSpectrum(PHDFile phd, Map map){ - return false; + public boolean AnalyseSpectrum(PHDFile phd, Map mapLines){ + System.loadLibrary("GammaAnaly"); + ObjectMapper mapper = new ObjectMapper(); + try { + String phdStr = mapper.writeValueAsString(phd); + String mapLinesStr = mapper.writeValueAsString(mapLines); + String analyseSpectrum = CalValuesHandler.analyseSpectrum(phdStr, mapLinesStr, ""); + JSONObject jsonObject = JSONObject.parseObject(analyseSpectrum); + String jsonString = jsonObject.toJSONString(); + + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + return true; } public int SettingChanged(PHDFile phd) { @@ -1598,8 +1607,8 @@ public class GammaFileUtil { } FilterNuclideLine(iter.getValue(), phd.getUsedSetting().getECutAnalysis_Low()); // 过滤核素能量小于ECutAnalysis_Low的射线 - List vEnergy = iter.getValue().vEnergy; // 该核素的所有γ射线能量 - List vYield = iter.getValue().vYield; + List vEnergy = iter.getValue().venergy; // 该核素的所有γ射线能量 + List vYield = iter.getValue().vyield; List vEffi = CalValuesHandler.calFcnEval(vEnergy, phd.getUsedEffiPara().getP()).counts; // 该核素所有γ射线能量处的探测效率 List vFit = new LinkedList<>(); // γ射线能量与峰中心道能量匹配标识 for (int i=0; i vE = lines.vEnergy; + List vE = lines.venergy; for(int i=0, j=0; i 0) { - List vY = lines.vYield; + if(lines.key_flag < 0 && lines.venergy.size() > 0) { + List vY = lines.vyield; lines.maxYeildIdx = 0; double maxYield = vY.get(0); for(int ii=1; ii nuclideLineList = spectrumAnalysisMapper.getNuclideLines(name); for(int j=0;j 0) { nlines.key_flag = j; nlines.maxYeildIdx = j; @@ -3941,7 +3950,7 @@ public class GammaFileUtil { ReadSpecialNuclides(mapHalflife, vNuclides); double energyWidth = phd.getUsedSetting().getEnergyTolerance(); - List vEnergy = lines.vEnergy; // 该核素的所有γ射线能量 + List vEnergy = lines.venergy; // 该核素的所有γ射线能量 double maxYield = 0; int mainPeakIdx = -1; // 记录核素主γ峰的索引下标 @@ -3954,9 +3963,9 @@ public class GammaFileUtil { break; } else if(vEnergy.get(i) <= energy + energyWidth) { ActMda.getVEnergy().add(vEnergy.get(i)); - ActMda.getVUncertE().add(lines.vUncertE.get(i)); - ActMda.getVYield().add(lines.vYield.get(i)); - ActMda.getVUncertY().add(lines.vUncertY.get(i)); + ActMda.getVUncertE().add(lines.vuncertE.get(i)); + ActMda.getVYield().add(lines.vyield.get(i)); + ActMda.getVUncertY().add(lines.vuncertY.get(i)); ActMda.getFullNames().add(lines.fullNames.get(i)); ActMda.getVPeakIdx().add(vPeakIdx.get(j)+1); if(lines.key_flag == i) { @@ -4160,4 +4169,42 @@ public class GammaFileUtil { return datalist; } + public File analyzeFile(String path, String fileName) { + //连接ftp + FTPClient ftpClient = ftpUtil.LoginFTP(); + InputStream inputStream = null; + File file = null; + try { + //被动模式 + ftpClient.enterLocalPassiveMode(); + //设置文件类型--二进制文件 + ftpClient.setFileType(FTP.BINARY_FILE_TYPE); + // + ftpClient.setControlEncoding("UTF-8"); + ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); + //切换文件路径 + ftpClient.changeWorkingDirectory(path); + inputStream = ftpClient.retrieveFileStream(fileName); + if (Objects.nonNull(inputStream)){ + file = File.createTempFile("tmp", null); + //将ftp文件的输入流复制给临时文件 + FileUtils.copyInputStreamToFile(inputStream, file); + } + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + try { + if (Objects.nonNull(ftpClient)){ + ftpClient.disconnect(); + } + if (Objects.nonNull(inputStream)){ + inputStream.close(); + } + } catch (IOException e) { + throw new RuntimeException(e); + } + } + return file; + } + } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java index b4d947b1..b45f634c 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/controller/GammaController.java @@ -43,18 +43,19 @@ public class GammaController { @GetMapping("analysisProcess") @ApiOperation(value = "分析进度", notes = "分析进度") public void message(String message) { - Result user = systemClient.getUserData(); +// Result user = systemClient.getUserData(); BaseMap params = new BaseMap(); params.put(GlobalConstants.HANDLER_NAME, WebSocketHandlerConst.GAMMA_ANALYSIS_HANDLER); - params.put("userId", user.getResult().getId()); + params.put("userId", "message.userId"); + // userId, fileName, process params.put("message", message); // 通过 redis 订阅发送 websocket 消息 redisTemplate.convertAndSend(GlobalConstants.REDIS_TOPIC_NAME, params);; } @GetMapping("testFun") - public Result testFun(String fileName){ - return gammaService.testFun(fileName); + public Result testFun(String fileName,HttpServletRequest request){ + return gammaService.testFun(fileName, request); } @GetMapping("gammaByDB") diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/PeakInfo.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/PeakInfo.java index 459421d3..77134382 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/PeakInfo.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/PeakInfo.java @@ -64,6 +64,8 @@ public class PeakInfo implements Serializable { public PeakInfo(){ nuclides = new LinkedList<>(); comments = ""; + recoilBetaChan = "1"; + recoilDeltaChan = "1"; } } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/native_jni/CalValuesHandler.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/native_jni/CalValuesHandler.java index 93b40793..d08cf789 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/native_jni/CalValuesHandler.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/native_jni/CalValuesHandler.java @@ -1,13 +1,11 @@ package org.jeecg.modules.native_jni; -import com.alibaba.fastjson.JSON; import org.jeecg.modules.entity.vo.PeakInfo; import org.jeecg.modules.entity.vo.StructInsertInput; import org.jeecg.modules.entity.vo.StructInsertOutput; import org.jeecg.modules.native_jni.struct.CalValuesOut; import java.util.List; -import java.util.Map; public class CalValuesHandler { @@ -27,22 +25,6 @@ public class CalValuesHandler { public static native StructInsertOutput ComputePeakRange(int peakSize, int m_nCount, List vCentroid, List vFwhmCh, List vTail, List vUpperTail); - public static native List calValues(int cal, int m_nChans); - - public static native List GetFwhmcAll(int m_nChans); - - public static native List calculateLC(List BaseLine, List FwhmcAll, double RiskLevelK); - - public static native List calculateSCAC(List Spectrum, List BaseLine, List FwhmcAll); - - public static native boolean armaAny(List Spectrum); - - public static native String calUpdate(String dataType, List certEne, boolean E1, boolean R, boolean E2, boolean KeepCalPeakSearchPeaks, double k_back, double k_alpha, double k_beta); - - public static native String peakSearch(double ECutLow, double ECutHigh, double deltaE, double pssLow, double k_back, double k_alpha, double k_beta, List Peaks); - - public static native String baseImprove(double BaseImprovePSS, double k_back, double k_alpha, double k_beta, double ECutLow, double ECutHigh, double deltaE, double pssLow); - - public static native String fitPeakFull(); + public static native String analyseSpectrum(String phd, String mapLines, String phdFilePath); } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java index b9bf8285..2bd327e6 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/IGammaService.java @@ -13,7 +13,7 @@ public interface IGammaService{ Result initValue(Integer sampleId, String dbName, HttpServletRequest request); - Result testFun(String fileName); + Result testFun(String fileName, HttpServletRequest request); Result gammaByDB(String dbName, Integer sampleId, HttpServletRequest request); 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 e6b0055e..25042ab3 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 @@ -8,13 +8,18 @@ import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ReUtil; import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.StringPool; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; import com.google.common.cache.Cache; import org.apache.commons.net.ftp.FTPClient; +import org.codehaus.jettison.json.JSONString; import org.jeecg.common.api.vo.Result; import org.jeecg.common.cache.LocalCache; import org.jeecg.common.constant.DateConstant; @@ -30,6 +35,7 @@ import org.jeecg.modules.entity.*; import org.jeecg.modules.mapper.SpectrumAnalysisMapper; import org.jeecg.modules.native_jni.CalValuesHandler; 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; @@ -77,6 +83,8 @@ public class GammaServiceImpl implements IGammaService { private FTPUtil ftpUtil; @Value("${ZeroTime}") private String ZeroTimeStr; + @Value("${parameter.filePath}") + private String parameterFilePath; @Autowired private IGardsAnalysesSpectrumService analysesSpectrumService; @Autowired @@ -144,31 +152,62 @@ public class GammaServiceImpl implements IGammaService { } @Override - public Result testFun(String fileName) { + public Result testFun(String fileName, HttpServletRequest request) { Result result = new Result(); + Map map = new HashMap<>(); Cache phdCache = localCache.getPHDCache(); PHDFile phd = phdCache.getIfPresent(fileName); - Map map = new HashMap<>(); - System.loadLibrary("GammaAnaly"); -// List baseInfo_s_Energy = CalValuesHandler.calValues(0, phd.getSpec().getCounts().size()); -// map.put("baseInfo_s_Energy", baseInfo_s_Energy); -// List baseInfo_s_fwhmcAll = CalValuesHandler.GetFwhmcAll(phd.getSpec().getCounts().size()); -// map.put("baseInfo_s_fwhmcAll", baseInfo_s_fwhmcAll); -// List baseInfo_s_Lc = CalValuesHandler.calculateLC(phd.getBaseCtrls().getBaseline(), baseInfo_s_fwhmcAll, phd.getSetting().getRiskLevelK()); -// map.put("baseInfo_s_Lc", baseInfo_s_Lc); -// List values = gammaFileUtil.DoubleLimit_L(phd.getSpec().getCounts()); -// List baseInfo_s_Scac = CalValuesHandler.calculateSCAC(values, phd.getBaseCtrls().getBaseline(), baseInfo_s_fwhmcAll); -// map.put("baseInfo_s_Scac", baseInfo_s_Scac); -// boolean armaAny = CalValuesHandler.armaAny(values); -// map.put("armaAny", armaAny); - String dataType = phd.getMsgInfo().getData_type().substring(0, 1); - List gEnergy = phd.getCertificate().getG_energy(); - String calUpdateStr = CalValuesHandler.calUpdate(dataType, gEnergy, true, true, true, phd.getSetting().isKeepCalPeakSearchPeaks(), phd.getSetting().getK_back(), phd.getSetting().getK_alpha(), phd.getSetting().getK_beta()); - map.put("calUpdateStr", calUpdateStr); -// CalValuesHandler.peakSearch(phd.getSetting().getECutAnalysis_Low(), phd.getSetting().getECutAnalysis_High(), -// phd.getSetting().getEnergyTolerance(), phd.getSetting().getPSS_low(), phd.getSetting().getK_back(), phd.getSetting().getK_alpha(), phd.getSetting().getK_beta(), phd.getVPeak()); + if (Objects.isNull(phd)){ + result.error500("请先选择解析文件!"); + return result; + } + phd.setUserId("1"); + phd.setXmlFilePath(parameterFilePath); + String userName = JwtUtil.getUserNameByToken(request); + //获取当前角色的颜色配置 + Map colorMap = sysUserColorService.initColor(userName); + //查询当前用户关联的核素信息 + List nuclides = new LinkedList<>(); + //从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的 + nuclides = defaultNuclideSpectrumService.findNuclidesByUserName(userName, phd.getHeader().getSystem_type().toUpperCase()); + if (CollectionUtils.isEmpty(nuclides)){ + nuclides = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase()); + } + Map nuclideLinesMap = gammaFileUtil.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()); + PHDFile phdFile = JSON.parseObject(strValue, PHDFile.class); + phd.setVLc(phdFile.getVLc()); + phd.setVScac(phdFile.getVScac()); + phd.setVBase(phdFile.getVBase()); + phd.setVEnergy(phdFile.getVEnergy()); + phd.setVPeak(phdFile.getVPeak()); + for (PeakInfo peak:phd.getVPeak()) { + if (StringUtils.isBlank(peak.recoilBetaChan)) { + peak.recoilBetaChan = "1"; + } + if (StringUtils.isBlank(peak.recoilDeltaChan)) { + peak.recoilDeltaChan = "1"; + } + } + gammaFileUtil.UpdateChart(phd, map, colorMap); + // + gammaFileUtil.NuclidesIdent(phd, nuclideLinesMap); + // 更新 ‘QC Flags’ 状态 + List qcstate = gammaFileUtil.Qcstate(phd); + map.put("QCFlag", qcstate); + phdCache.put(fileName, phd); + localCache.setPHDCache(phdCache); + result.setResult(map); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } result.setSuccess(true); - result.setResult(map); return result; } @@ -369,8 +408,19 @@ public class GammaServiceImpl implements IGammaService { if (CollectionUtils.isEmpty(nuclides)){ nuclides = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase()); } - boolean flag = gammaFileUtil.AnalyseData(phd, configureData, nuclides, true); - if (flag){ + int flag = gammaFileUtil.AnalyseData(phd, configureData, nuclides, result); + if (flag == 0){ + String warning = "The spectrum needn't Analyed. Maybe:\n"+ + "1. It has already Analyed.\n"+ + "2. You didn't change any setting or calibration."; + result.error500(warning); + } else if (flag == -1){ + String warning = "Finish three tasks:\n"+ + "\t1.Update efficiencies of all peaks;\n"+ + "\t2.Identify nuclides again;\n"+ + "\t3.Test QC again."; + result.error500(warning); + } else { Map map = new HashMap<>(); phd.getUsedSetting().setECutAnalysis_Low(configureData.getECutAnalysis_Low()); phd.getUsedSetting().setECutAnalysis_High(configureData.getECutAnalysis_High()); @@ -386,11 +436,6 @@ public class GammaServiceImpl implements IGammaService { gammaFileUtil.UpdateChart(phd, map, colorMap); result.setSuccess(true); result.setResult(map); - }else { - String warning = "The spectrum needn't Analyed. Maybe:\n"+ - "1. It has already Analyed.\n"+ - "2. You didn't change any setting or calibration."; - result.error500(warning); } return result; } @@ -440,6 +485,8 @@ public class GammaServiceImpl implements IGammaService { map.put("energy", phd.getVEnergy()); //赋值BaseCtrls map.put("BaseCtrls", phd.getBaseCtrls()); + //FitBaseLine颜色 + map.put("FitBaseLine", colorMap.get("Color_Fitbase")); result.setSuccess(true); result.setResult(map); return result; 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 45c3e3eb..2c411174 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 @@ -76,10 +76,10 @@ public class GardsNuclLinesLibServiceImpl extends ServiceImpl 0){ diff --git a/jeecg-server-cloud/jeecg-auto-process-start/src/main/resources/application.yml b/jeecg-server-cloud/jeecg-auto-process-start/src/main/resources/application.yml index a5d0fe92..c74f45bc 100644 --- a/jeecg-server-cloud/jeecg-auto-process-start/src/main/resources/application.yml +++ b/jeecg-server-cloud/jeecg-auto-process-start/src/main/resources/application.yml @@ -15,5 +15,5 @@ spring: config: import: - optional:nacos:jeecg.yaml - - optional:nacos:jeecg-@profile.name@-pbl.yaml + - optional:nacos:jeecg-@profile.name@.yaml