diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/AbstractS_D_Q_G_SpectrumHandler.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/AbstractS_D_Q_G_SpectrumHandler.java index cf071b36..ddc71105 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/AbstractS_D_Q_G_SpectrumHandler.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/AbstractS_D_Q_G_SpectrumHandler.java @@ -9,8 +9,7 @@ import org.apache.logging.log4j.util.Strings; import org.jeecg.common.constant.StringConstant; import org.jeecg.common.properties.SpectrumPathProperties; import org.jeecg.common.util.DateUtils; -import org.jeecg.common.util.SelfStationUtil; -import org.jeecg.common.util.SelfUtil; +import org.jeecg.common.util.SelfBaseUtil; import org.jeecg.modules.ErrorLogManager; import org.jeecg.modules.base.entity.original.GardsSampleData; import org.jeecg.modules.base.enums.SampleStatus; @@ -29,7 +28,6 @@ import java.io.*; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.text.ParseException; import java.util.Date; import java.util.List; import java.util.Objects; @@ -93,7 +91,7 @@ public abstract class AbstractS_D_Q_G_SpectrumHandler extends AbstractSpectrumHa // 如果是自建台站能谱,需要单独处理Histogram数据,避免性能问题 EnergySpectrumStruct sourceData = null; if (super.spectrumFile.length() > (1024 * 1024 * 4L)) { - sourceData = SelfStationUtil.getSourceDataNotHis(super.spectrumFile.getAbsolutePath()); + sourceData = SelfBaseUtil.getSourceDataNotHis(super.spectrumFile.getAbsolutePath()); } else { sourceData = EnergySpectrumHandler.getSourceData(super.spectrumFile.getAbsolutePath()); } diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_C_Analysis.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_C_Analysis.java index 929fb92e..96695ad7 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_C_Analysis.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_C_Analysis.java @@ -242,7 +242,7 @@ public class Sample_C_Analysis { analyseResult.setS_g_fitting_e_c(s_g_fitting_e_c); // 执行beta分析 - List selfXeResults = SelfStationUtil.betaAnalyse(selfParameter, sampleStruct.POI_G_y1, + List selfXeResults = SelfBaseUtil.betaAnalyse(selfParameter, sampleStruct.POI_G_y1, sampleStruct.POI_G_y2, sampleFilePathName, phdFile1, phdFile2, phdFile3, phdFile4); analyseResult.setXeResults(selfXeResults); @@ -327,24 +327,24 @@ public class Sample_C_Analysis { // 根据ROI生成四个Gamma谱文件 文件命名格式为: 样品谱原名_ROI_x.PHD String saveFullPath = this.saveFullPath(); String gammaOneName = StrUtil.subBefore(sampleFilename, ".PHD", true) + "_ROI_1.PHD"; - SelfStationUtil.createGammaFile(saveFullPath, gammaOneName, this.sampleStruct, roiOneCounts); + SelfBaseUtil.createGammaFile(saveFullPath, gammaOneName, this.sampleStruct, roiOneCounts); String gammaTwoName = StrUtil.subBefore(sampleFilename, ".PHD", true) + "_ROI_2.PHD"; - SelfStationUtil.createGammaFile(saveFullPath, gammaTwoName, this.sampleStruct, roiTwoCounts); + SelfBaseUtil.createGammaFile(saveFullPath, gammaTwoName, this.sampleStruct, roiTwoCounts); String gammaThreeName = StrUtil.subBefore(sampleFilename, ".PHD", true) + "_ROI_3.PHD"; - SelfStationUtil.createGammaFile(saveFullPath, gammaThreeName, this.sampleStruct, roiThreeCounts); + SelfBaseUtil.createGammaFile(saveFullPath, gammaThreeName, this.sampleStruct, roiThreeCounts); String gammaFourName = StrUtil.subBefore(sampleFilename, ".PHD", true) + "_ROI_4.PHD"; - SelfStationUtil.createGammaFile(saveFullPath, gammaFourName, this.sampleStruct, roiFourCounts); + SelfBaseUtil.createGammaFile(saveFullPath, gammaFourName, this.sampleStruct, roiFourCounts); // 将生成的GammaPHD文件转换为PHDFile对象 - this.phdFile1 = SelfStationUtil.createGammaPHD(this.sampleStruct, gammaOneName, saveFullPath, roiOneCounts); + this.phdFile1 = SelfBaseUtil.createGammaPHD(this.sampleStruct, gammaOneName, saveFullPath, roiOneCounts); this.phdFile1.setRoiSuffix("_ROI_1"); - this.phdFile2 = SelfStationUtil.createGammaPHD(this.sampleStruct, gammaTwoName, saveFullPath, roiTwoCounts); + this.phdFile2 = SelfBaseUtil.createGammaPHD(this.sampleStruct, gammaTwoName, saveFullPath, roiTwoCounts); this.phdFile2.setRoiSuffix("_ROI_2"); - this.phdFile3 = SelfStationUtil.createGammaPHD(this.sampleStruct, gammaThreeName, saveFullPath, roiThreeCounts); + this.phdFile3 = SelfBaseUtil.createGammaPHD(this.sampleStruct, gammaThreeName, saveFullPath, roiThreeCounts); this.phdFile3.setRoiSuffix("_ROI_3"); - this.phdFile4 = SelfStationUtil.createGammaPHD(this.sampleStruct, gammaFourName, saveFullPath, roiFourCounts); + this.phdFile4 = SelfBaseUtil.createGammaPHD(this.sampleStruct, gammaFourName, saveFullPath, roiFourCounts); this.phdFile4.setRoiSuffix("_ROI_4"); // 生成PHD的inputFileName // String saveRelativePath = this.spectrumHandler.getFileSaveRelativePath(); @@ -431,7 +431,7 @@ public class Sample_C_Analysis { throw new FileNotExistException("gas or det file is no exist or is error.."); } // this.detStruct = EnergySpectrumHandler.getSourceData(this.detFileFinalPath); - this.detStruct = SelfStationUtil.getSourceDataNotHis(this.detFileFinalPath); + this.detStruct = SelfBaseUtil.getSourceDataNotHis(this.detFileFinalPath); } /** diff --git a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/SelfStationUtil.java b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/SelfBaseUtil.java similarity index 95% rename from jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/SelfStationUtil.java rename to jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/SelfBaseUtil.java index b1c67581..9164fab0 100644 --- a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/SelfStationUtil.java +++ b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/SelfBaseUtil.java @@ -9,21 +9,16 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.StringPool; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.fasterxml.jackson.core.JsonProcessingException; -import com.google.common.cache.Cache; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import lombok.extern.slf4j.Slf4j; -import org.jeecg.common.constant.RedisConstant; import org.jeecg.modules.base.abstracts.AbstractLogOrReport; import org.jeecg.modules.base.enums.CalName; -import org.jeecg.modules.base.enums.DataTypeAbbr; import org.jeecg.modules.base.enums.SampleFileHeader; import org.jeecg.modules.entity.vo.*; import org.jeecg.modules.native_jni.CalValuesHandler; import org.jeecg.modules.native_jni.EnergySpectrumHandler; -import org.jeecg.modules.native_jni.struct.BgBoundary; import org.jeecg.modules.native_jni.struct.CalValuesOut; -import org.jeecg.modules.native_jni.struct.CalcBgBoundaryParam; import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -33,11 +28,10 @@ import java.io.*; import java.text.DecimalFormat; import java.text.ParseException; import java.util.*; -import java.util.stream.Collectors; @Component @Slf4j -public class SelfStationUtil extends AbstractLogOrReport { +public class SelfBaseUtil extends AbstractLogOrReport { @Autowired private FTPUtil ftpUtil; @@ -49,10 +43,10 @@ public class SelfStationUtil extends AbstractLogOrReport { * @return */ public static HashMap readPHDFile(String phdPath) { + File file = new File(phdPath); + HashMap result = Maps.newHashMap(); + BufferedReader reader = FileUtil.getReader(file, "utf8"); try { - File file = new File(phdPath); - HashMap result = Maps.newHashMap(); - BufferedReader reader = FileUtil.getReader(file, "utf8"); List hCounts = Lists.newLinkedList(); String currentName = ""; long [][] hCountArr = null; @@ -67,10 +61,9 @@ public class SelfStationUtil extends AbstractLogOrReport { String s = reader.readLine(); String[] split = s.split(" "); long[] array = Arrays.stream(split).filter(StrUtil::isNotEmpty).mapToLong(Long::parseLong).toArray(); - // todo 暂时反着写,邮件中是错误的,正确的为 0 1 - hCountArr = new long[(int)array[1]][(int)array[0]]; - result.put("g_channels", array[1]); - result.put("b_channels", array[0]); + hCountArr = new long[(int)array[0]][(int)array[1]]; + result.put("g_channels", array[0]); + result.put("b_channels", array[1]); result.put("g_energy_span", array[2]); result.put("b_energy_span", array[3]); Console.log(s); @@ -98,8 +91,15 @@ public class SelfStationUtil extends AbstractLogOrReport { throw new RuntimeException(e); } catch (NumberFormatException e) { throw new RuntimeException(e); + } finally { + try { + reader.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } } } + /** * 统计道值范围内数量 * @param startChannel 起始道值 @@ -144,6 +144,36 @@ public class SelfStationUtil extends AbstractLogOrReport { return map; } + /** + * 根据文件路径,类型获取对应的解析文件内容并返回进行存储 + * @param filePathName + * @param type + * @param selfStationData + * @return + */ +// public EnergySpectrumStruct getSourceData(String filePathName, String type, SelfStationData selfStationData) { +// EnergySpectrumStruct struct = null; +// File file = null; +// try { +// //根据完整的文件路径 获取临时文件 +// file = ftpUtil.downloadFile(filePathName); +// if (Objects.nonNull(file)) { +// if (type.equalsIgnoreCase("sample")) { +// selfStationData.setSampleTmpPath(file.getAbsolutePath()); +// } else if (type.equalsIgnoreCase("det")) { +// selfStationData.setDetTmpPath(file.getAbsolutePath()); +// } else if (type.equalsIgnoreCase("qc")) { +// selfStationData.setQcTmpPath(file.getAbsolutePath()); +// } +// //解析文件内容 +// struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath()); +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// return struct; +// } + /** * 调用dll解析phd文件,dll不解析histogram块数据 * @param filePathName 文件地址 @@ -152,7 +182,7 @@ public class SelfStationUtil extends AbstractLogOrReport { public static EnergySpectrumStruct getSourceDataNotHis(String filePathName) { EnergySpectrumStruct struct = null; try { - if (Objects.nonNull(filePathName)) { + if (StrUtil.isNotEmpty(filePathName) && new File(filePathName).exists()) { //解析文件内容 long start = System.currentTimeMillis(); struct = EnergySpectrumHandler.getSourceDataNotHis(filePathName); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/SelfStationUtil.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/SelfStationUtil.java index 10229309..e39c8019 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/SelfStationUtil.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/SelfStationUtil.java @@ -46,7 +46,7 @@ import java.util.stream.Collectors; @Component @Slf4j -public class SelfStationUtil extends AbstractLogOrReport { +public class SelfStationUtil extends SelfBaseUtil { @Autowired private FTPUtil ftpUtil; @@ -265,174 +265,6 @@ public class SelfStationUtil extends AbstractLogOrReport { } } - /** - * 根据文件路径,类型获取对应的解析文件内容并返回进行存储 - * @param filePathName - * @param type - * @param selfStationData - * @return - */ - public EnergySpectrumStruct getSourceData(String filePathName, String type, SelfStationData selfStationData) { - EnergySpectrumStruct struct = null; - File file = null; - try { - //根据完整的文件路径 获取临时文件 - file = ftpUtil.downloadFile(filePathName); - if (Objects.nonNull(file)) { - if (type.equalsIgnoreCase("sample")) { - selfStationData.setSampleTmpPath(file.getAbsolutePath()); - } else if (type.equalsIgnoreCase("det")) { - selfStationData.setDetTmpPath(file.getAbsolutePath()); - } else if (type.equalsIgnoreCase("qc")) { - selfStationData.setQcTmpPath(file.getAbsolutePath()); - } - //解析文件内容 - struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath()); - } - } catch (Exception e) { - e.printStackTrace(); - } - return struct; - } - - /** - * 调用dll解析phd文件,dll不解析histogram块数据 - * @param filePathName 文件地址 - * @param sampleType 谱类型 - * @param selfStationData - * @return - */ - public void getSourceDataNotHis(String filePathName, String sampleType, SelfStationData selfStationData) { - EnergySpectrumStruct struct = null; - File file = null; - try { - //根据完整的文件路径 获取临时文件 - file = ftpUtil.downloadFile(filePathName); - if (Objects.nonNull(file)) { - //解析文件内容 - struct = EnergySpectrumHandler.getSourceDataNotHis(file.getAbsolutePath()); - HashMap hisMap = this.readPHDFile(file.getAbsolutePath()); - struct.setH_count_arr((long[][]) hisMap.get("h_count")); - struct.setG_channels((long) hisMap.get("g_channels")); - struct.setB_channels((long) hisMap.get("b_channels")); - struct.setG_energy_span((long) hisMap.get("g_energy_span")); - struct.setB_energy_span((long) hisMap.get("b_energy_span")); - - if (sampleType.equalsIgnoreCase("sample")) { - selfStationData.setSampleStruct(struct); - selfStationData.setSampleTmpPath(file.getAbsolutePath()); - } else if (sampleType.equalsIgnoreCase("det")) { - selfStationData.setDetStruct(struct); - selfStationData.setDetTmpPath(file.getAbsolutePath()); - } else if (sampleType.equalsIgnoreCase("qc")) { - selfStationData.setQcStruct(struct); - selfStationData.setQcTmpPath(file.getAbsolutePath()); - } - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - /** - * 解析 #histogram块数据 - * @param phdPath 文件地址 - * @return - */ - public HashMap readPHDFile(String phdPath) { - try { - File file = new File(phdPath); - HashMap result = Maps.newHashMap(); - BufferedReader reader = FileUtil.getReader(file, "utf8"); - List hCounts = Lists.newLinkedList(); - String currentName = ""; - long [][] hCountArr = null; - int row = 0; - String blockHis = SampleFileHeader.HISTOGRAM.getMessage(); - while (reader.ready()) { - // 当前行 - String line = reader.readLine(); - if (line.equals(blockHis)) { - currentName = line; - // 首行 - String s = reader.readLine(); - String[] split = s.split(" "); - hCountArr = new long[Integer.parseInt(split[0])][Integer.parseInt(split[1])]; - result.put("g_channels", Long.parseLong(split[0])); - result.put("b_channels", Long.parseLong(split[1])); - result.put("g_energy_span", Long.parseLong(split[2])); - result.put("b_energy_span", Long.parseLong(split[3])); - Console.log(s); - continue; - } - if (!line.equals(blockHis) && !currentName.equals(blockHis)) { - continue; - } - if (line.equals("STOP")) { - break; - } - String[] split = line.split(" "); - for (int i = 0; i < split.length; i++) { - hCountArr[row][i] = Long.parseLong(split[i]); - hCounts.add(Long.parseLong(split[i])); - } - row++; - } - result.put("h_count", hCountArr); - Console.log("Size:{}",hCounts.size()); - return result; - } catch (IORuntimeException e) { - throw new RuntimeException(e); - } catch (IOException e) { - throw new RuntimeException(e); - } catch (NumberFormatException e) { - throw new RuntimeException(e); - } - } - /** - * 统计道值范围内数量 - * @param startChannel 起始道值 - * @param endChannel 结束道值 - * @param betaChannels 行数 - * @param gammaChannels 列数 - * @param h_counts 计数数组 - */ - public Map statisticsROIList(Integer startChannel, Integer endChannel, long betaChannels, long gammaChannels, List h_counts) { - Map map = new HashMap<>(); - // g_counts - List counts = new LinkedList<>(); - //存储同一列不同行加和后的数量 - List sumList = new LinkedList<>(); - List seriseDataList = new LinkedList<>(); - //遍历所有列 - for (int i=0; i 0 && index < h_counts.size()) { - count = h_counts.get(index); - } - sum+=count; - } - seriseData.setY(sum); - sumList.add(sum); - counts.add((long) sum); - seriseDataList.add(seriseData); - } - map.put("startChannel", startChannel); - map.put("endChannel", endChannel); - map.put("dataList", seriseDataList); - map.put("counts", counts); - Console.log(counts.toString()); - return map; - } - public Map getGammaByROI(String systemType, List roiBBoundaryStart, List roiBBoundaryStop, SelfStationData selfStationData) { @@ -545,30 +377,6 @@ public class SelfStationUtil extends AbstractLogOrReport { return map; } - public List roiList(Integer startChannel, Integer endChannel, long betaChannels, long gammaChannels, List h_counts) { - // g_counts - List counts = new LinkedList<>(); - //存储同一列不同行加和后的数量 - List sumList = new LinkedList<>(); - //遍历所有列 - for (int i=0; i 0 && index < h_counts.size()) { - count = h_counts.get(index); - } - sum+=count; - } - counts.add(sum); - } - return counts; - } - public String UpdateEquationEnergy(ParameterInfo m_curParam) { String equation =""; int p_size = m_curParam.getP().size()-1; @@ -837,82 +645,6 @@ public class SelfStationUtil extends AbstractLogOrReport { map.put("AllData", datalist); } - /** - * 根据ROI卡出来的Gamma数据生成新的GammaPHD文件 - * @param pathName 文件存储路径 - * @param fileName GammaPHD名称 - * @param struct BetaPHD内容 - * @param g_counts ROI卡出来的Gamma数据 - */ - public void createGammaFile(String pathName,String fileName, EnergySpectrumStruct struct, List g_counts) { - File file = new File(pathName + "\\" + fileName); - // 创建PrintWriter对象 - PrintWriter out = null; - DecimalFormat decimalFormat = new DecimalFormat("0.000000"); - try { - out = new PrintWriter(file); - out.println("BEGIN IMS2.0"); - out.println("MSG_TYPE DATA"); - // todo msg_type用的不对,dll没解析出这个字段 - out.println("MSG_ID " + struct.msg_id + " " + struct.msg_type + "\n" + "DATA_TYPE " + struct.data_type); - out.println("#Header 3"); - // 解析出的Gamma谱 系统类型暂时使用G - out.println(struct.site_code + " " + struct.detector_code + " G " + - struct.sample_geometry + " " + struct.spectrum_quantity); - out.println(struct.sample_ref_id); - out.println(struct.measurement_id + " " + struct.detector_bk_measurement_id + " 0"); - out.println(struct.transmit_date + " " + struct.transmit_time); - out.println("#Collection"); - out.println(struct.collection_start_date + " " + struct.collection_start_time + " " + - struct.collection_stop_date + " " + struct.collection_stop_time + " " - + decimalFormat.format(struct.air_volume)); - out.println("#Acquisition"); - out.println(struct.acquisition_start_date + " " + struct.acquisition_start_time + " " + - decimalFormat.format(struct.acquisition_real_time) + " " + - decimalFormat.format(struct.acquisition_live_time)); - out.println("#g_Energy"); - - - format(struct.g_energy, struct.g_centroid_channel, struct.g_uncertainty, out); - out.println("#g_Resolution"); - format(struct.g_r_energy, struct.g_r_FWHM, struct.g_r_uncertainty, out); - out.println("#g_Efficiency"); - format(struct.g_e_energy, struct.g_e_efficiency, struct.g_e_uncertainty, out); - out.println("#g_Spectrum"); - // num_g_channel 根据g_counts数量得来和PHD写的数字没有关系;g_energy_span是PHD写的值 - out.println(struct.num_g_channel + " " + struct.g_energy_span); - // 存储前一个数字 - String beforeStr = ""; - for (int i = 0; i < g_counts.size(); i++) { - String str = g_counts.get(i).toString(); - if(i % 5 == 0) { - if (i == 0) { - out.printf((i+1)+""); - } else { - out.printf("\n" + (i+1) ); - } - beforeStr = i+""; - } - - if(StrUtil.isEmpty(beforeStr)){ - beforeStr = str; - } - // 根据前一个字符长度计算需要的空格 - out.printf("%" + (str.length() + (6 - beforeStr.length()))+ "s" , g_counts.get(i)); - if(i == g_counts.size() - 1) { - out.println(); - } - beforeStr = str; - } - out.print("STOP"); - } catch (FileNotFoundException e) { - throw new RuntimeException(e); - } finally { - if (null != out) { - out.close(); - } - } - } /** * 创建Gamma PHD文件并转换为数据存入SelfStationVueData * @param path PHD保存地址 @@ -946,230 +678,6 @@ public class SelfStationUtil extends AbstractLogOrReport { sampleVueData.setROIFourPHDFile(this.createGammaPHD(struct, gammaFourName, path, sampleVueData.getROIFourCounts())); } - /** - * 根据DLL解析GammaPHD内容 得到PHDFile实体 - * @param struct dll解析后的实体 - * @param fileName 文件名称 - * @param pathName 路径 - * @param g_counts beta卡出来的gamma数据 - * @return PHDFile 实体 - */ - public PHDFile createGammaPHD(EnergySpectrumStruct struct, String fileName, String pathName, List g_counts) { - PHDFile phd = new PHDFile(); - phd.setFilepath(pathName); - phd.setFilename(fileName); - File file = new File(pathName + StringPool.SLASH + fileName); - phd.setTmpFilePath(file.getAbsolutePath()); - try { - //MsgInfo - phd.getMsgInfo().setMsg_id(struct.msg_id); - phd.getMsgInfo().setMsg_type(struct.msg_type); - phd.getMsgInfo().setData_type(struct.data_type); - //Header - phd.getHeader().setDesignator(struct.designator); - phd.getHeader().setSite_code(struct.site_code); - phd.getHeader().setDetector_code(struct.detector_code); - phd.getHeader().setSystem_type(struct.system_type); - phd.getHeader().setSample_geometry(struct.sample_geometry); - phd.getHeader().setSpectrum_quantity(struct.spectrum_quantity); - phd.getHeader().setSample_ref_id(struct.sample_ref_id); - phd.getHeader().setMeasurement_id(struct.measurement_id); - phd.getHeader().setDetector_bk_measurement_id(struct.detector_bk_measurement_id); - phd.getHeader().setGas_bk_measurement_id(struct.gas_bk_measurement_id); - phd.getHeader().setTransmit_date(struct.transmit_date); - phd.getHeader().setTransmit_time(struct.transmit_time); - //Comment - phd.setOriTotalCmt(struct.comment); - //Collection - if (StrUtil.isNotBlank(struct.collection_start_date) && StrUtil.isNotBlank(struct.collection_start_time) - && StrUtil.isNotBlank(struct.collection_stop_date) && StrUtil.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); - phd.getCollect().setCollection_stop_time(struct.collection_stop_time); - phd.getCollect().setAir_volume(struct.air_volume); - if (phd.getCollect().getCollection_start_time().indexOf('.') < 0) { - phd.getCollect().setCollection_start_time(phd.getCollect().getCollection_start_time() + ".0"); - } - if (phd.getCollect().getCollection_stop_time().indexOf('.') < 0) { - phd.getCollect().setCollection_stop_time(phd.getCollect().getCollection_stop_time() + ".0"); - } - } else { - phd.getCollect().setAir_volume(0.0); - } - //Acquisition - if (StrUtil.isNotBlank(struct.acquisition_start_date) && StrUtil.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); - phd.getAcq().setAcquisition_live_time(struct.acquisition_live_time); - if (phd.getAcq().getAcquisition_start_time().indexOf('.') < 0) { - phd.getAcq().setAcquisition_start_time(phd.getAcq().getAcquisition_start_time() + ".0"); - } - } else { - phd.getAcq().setAcquisition_live_time(0.0); - 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) - && StrUtil.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); - phd.getProcess().setUncertainty_2(struct.uncertainty_2); - phd.getProcess().setArchive_bottle_id(struct.archive_bottle_id); - } else { - phd.getProcess().setSample_volume_of_Xe(0.0); - phd.getProcess().setXe_collection_yield(0.0); - phd.getProcess().setUncertainty_1(0.0); - phd.getProcess().setUncertainty_2(0.0); - } - //Sample - 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 { - phd.getSampleBlock().setDimension_1(0.0); - phd.getSampleBlock().setDimension_2(0.0); - } - //Calibration - if (StrUtil.isNotBlank(struct.date_calibration) && StrUtil.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) && StrUtil.isNotBlank(struct.assay_date) - && StrUtil.isNotBlank(struct.assay_time) && StrUtil.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); - phd.getCertificate().setUnits_activity(struct.units_activity); - phd.getCertificate().setNuclide_name(struct.nuclide_name); - phd.getCertificate().setHalf_life_time(struct.half_life_time); - phd.getCertificate().setTime_unit(struct.time_unit); - phd.getCertificate().setActivity_nuclide_time_assay(struct.activity_nuclide_time_assay); - phd.getCertificate().setUncertainty(struct.uncertainty); - phd.getCertificate().setG_energy(struct.cer_g_energy); - phd.getCertificate().setG_intensity(struct.g_intensity); - phd.getCertificate().setElectron_decay_mode(struct.electron_decay_mode); - phd.getCertificate().setMaximum_energy(struct.maximum_energy); - phd.getCertificate().setIntensity_b_particle(struct.intensity_b_particle); - 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)) { - phd.getSpec().setNum_g_channel(struct.g_counts.size()); // todo 原Num_g_channel有误 - phd.getSpec().setG_energy_span(struct.g_energy_span); - phd.getSpec().setBegin_channel(struct.g_begin_channel); - // 从 struct.g_counts 换成 beta 卡出来的gamma数据 - phd.getSpec().setCounts(g_counts); - int i = 0; - for (; i < phd.getSpec().getNum_g_channel(); i++) { - if (phd.getSpec().getCounts().get(i) > 0) { - break; - } - } - if (i == phd.getSpec().getNum_g_channel()) { - phd.setValid(false); - } - } - //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)) { - GEnergyBlock gEnergyBlock = new GEnergyBlock(); - gEnergyBlock.setG_energy(struct.g_energy); - gEnergyBlock.setCentroid_channel(struct.g_centroid_channel); - gEnergyBlock.setUncertainty(struct.g_uncertainty); - gEnergyBlock.setRecord_count(struct.g_record_count); - 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)) { - GResolutionBlock gResolutionBlock = new GResolutionBlock(); - gResolutionBlock.setG_energy(struct.g_r_energy); - gResolutionBlock.setFWHM(struct.g_r_FWHM); - gResolutionBlock.setUncertainty(struct.g_r_uncertainty); - gResolutionBlock.setRecord_count(struct.g_r_record_count); - 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)) { - GEfficiencyBlock gEfficiencyBlock = new GEfficiencyBlock(); - gEfficiencyBlock.setG_energy(struct.g_e_energy); - gEfficiencyBlock.setEfficiency(struct.g_e_efficiency); - gEfficiencyBlock.setUncertainty(struct.g_e_uncertainty); - gEfficiencyBlock.setRecord_count(struct.g_e_record_count); - 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)) { - TotaleffBlock totaleffBlock = new TotaleffBlock(); - totaleffBlock.setG_energy(struct.t_g_energy); - totaleffBlock.setTotal_efficiency(struct.total_efficiency); - totaleffBlock.setUncertainty(struct.t_uncertainty); - totaleffBlock.setRecord_count(struct.t_record_count); - phd.getMapTotEKD().put(CalName.CalPHD.getType(), totaleffBlock); - } - - // 初始化默认分析设置 - if(phd.getHeader().getSystem_type().equalsIgnoreCase("P")) { - phd.getSetting().setECutAnalysis_Low(35.0); - phd.getSetting().setBUpdateCal(true); - } - if (StrUtil.isNotBlank(phd.getCollect().getCollection_start_date()) - && StrUtil.isNotBlank(phd.getCollect().getCollection_start_time())) { - phd.getSetting().setRefTime_conc(DateUtils.parseDate(phd.getCollect().getCollection_start_date() - + StringPool.SPACE + phd.getCollect().getCollection_start_time())); - } - if (StrUtil.isNotBlank(phd.getAcq().getAcquisition_start_date()) && StrUtil.isNotBlank(phd.getAcq().getAcquisition_start_time())) { - phd.getSetting().setRefTime_act(DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() - + StringPool.SPACE + phd.getAcq().getAcquisition_start_time())); - } - SpecSetup usedSetting = new SpecSetup(); - BeanUtils.copyProperties(phd.getSetting(), usedSetting); - phd.setUsedSetting(usedSetting); - - phd.setBAnalyed(false); - phd.setAnaly_start_time(DateUtils.formatDate(new Date(), "yyyy/MM/dd HH:mm:ss")); - - } catch (Exception e) { - throw new RuntimeException(e); - } - return phd; - } - - /** - * 数据格式化 - * @param aList 第一列数据 - * @param bList 第二列数据 - * @param cList 第三列数据 - * @param out - */ - private static void format(List aList, List bList,List cList,PrintWriter out) { - for (int i = 0; i < aList.size(); i++) { - DecimalFormat decimalFormat = new DecimalFormat("0.000000"); - String a = decimalFormat.format(aList.get(i)); - String b = decimalFormat.format(bList.get(i)); - String c = decimalFormat.format(cList.get(i)); - out.print(a); - out.printf("%" + ( b.length() + (17 - a.length())) + "s", b); - out.printf("%" + ( c.length() + (17 - b.length())) + "s", c+"\n"); - } - } - /** * 根据ROI从selfStationData 获取对应的gamma数据 * @param gammaROINum diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SelfStationServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SelfStationServiceImpl.java index 6dd7cbe8..02a96286 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SelfStationServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SelfStationServiceImpl.java @@ -245,8 +245,7 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf //返回结果map Map map = new HashMap<>(); //获取sample分析后的对象 - selfStationUtil.getSourceDataNotHis(sampleFilePath, "sample", selfStationData); - EnergySpectrumStruct struct = selfStationData.getSampleStruct(); + EnergySpectrumStruct struct = selfStationUtil.getSourceDataNotHis(sampleFilePath); if (Objects.nonNull(struct)) { selfStationData.setSampleStruct(struct); selfStationData.setSampleTmpPath(sampleFilePath); @@ -328,8 +327,7 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf //返回结果map Map map = new HashMap<>(); //获取sample分析后的对象 - selfStationUtil.getSourceDataNotHis(detFilePath, "det", selfStationData); - EnergySpectrumStruct struct = selfStationData.getDetStruct(); + EnergySpectrumStruct struct = selfStationUtil.getSourceDataNotHis(detFilePath); if (Objects.nonNull(struct)) { selfStationData.setDetStruct(struct); selfStationData.setDetTmpPath(detFilePath); @@ -348,8 +346,7 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf //返回结果map Map map = new HashMap<>(); //获取sample分析后的对象 - selfStationUtil.getSourceDataNotHis(qcFilePath, "qc", selfStationData); - EnergySpectrumStruct struct = selfStationData.getQcStruct(); + EnergySpectrumStruct struct = selfStationUtil.getSourceDataNotHis(qcFilePath); if (Objects.nonNull(struct)) { selfStationData.setQcStruct(struct); selfStationData.setQcTmpPath(qcFilePath); @@ -476,9 +473,10 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf Map map = new HashMap<>(); //获取sample分析后的对象 // 获取PHD数据 - selfStationUtil.getSourceDataNotHis(sampleFilePath, "sample", selfStationData); - EnergySpectrumStruct sampleStruct = selfStationData.getSampleStruct(); + EnergySpectrumStruct sampleStruct = selfStationUtil.getSourceDataNotHis(sampleFilePath); if (Objects.nonNull(sampleStruct)) { + selfStationData.setSampleStruct(sampleStruct); + selfStationData.setSampleTmpPath(sampleFilePath); selfStationData.setSampleFileName(sampleFileName); selfStationData.setSampleFilePathName(sampleFilePath); selfStationUtil.loadFile(selfStationData, null, null, "sample", map); @@ -501,8 +499,10 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf //返回结果map Map map = new HashMap<>(); //获取det分析后的对象 - selfStationUtil.getSourceDataNotHis(detFilePath, "det", selfStationData); - if (Objects.nonNull(selfStationData.getDetStruct())) { + EnergySpectrumStruct struct = selfStationUtil.getSourceDataNotHis(detFilePath); + if (Objects.nonNull(struct)) { + selfStationData.setDetStruct(struct); + selfStationData.setDetTmpPath(detFilePath); selfStationData.setDetFilePathName(detFilePath); selfStationData.setDetFileName(detFileName); selfStationUtil.loadFile(selfStationData, null, null, "det", map); @@ -519,8 +519,10 @@ public class SelfStationServiceImpl extends AbstractLogOrReport implements ISelf //返回结果map Map map = new HashMap<>(); //获取QC分析后的对象 - selfStationUtil.getSourceDataNotHis(qcFilePath, "qc", selfStationData); - if (Objects.nonNull(selfStationData.getQcStruct())) { + EnergySpectrumStruct struct = selfStationUtil.getSourceDataNotHis(qcFilePath); + if (Objects.nonNull(struct)) { + selfStationData.setQcStruct(struct); + selfStationData.setQcTmpPath(qcFilePath); selfStationData.setQcFilePathName(qcFilePath); selfStationData.setQcFileName(qcFileName); selfStationUtil.loadFile(selfStationData, null, null, "qc", map);