From 970d4f30276a8c1f61d13900d2e95aa22aaf7a56 Mon Sep 17 00:00:00 2001 From: nieziyan Date: Tue, 23 Jul 2024 16:49:11 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E8=87=AA=E5=BB=BA=E5=8F=B0?= =?UTF-8?q?=E7=AB=99=E8=B0=B1=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/exception/CAnalyseException.java | 24 +++++++++++++ .../modules/spectrum/Sample_C_Analysis.java | 36 ++++++++++++------- .../org/jeecg/common/util/GammaFileUtil.java | 13 ++++--- .../java/org/jeecg/common/util/SelfUtil.java | 15 +++++--- 4 files changed, 67 insertions(+), 21 deletions(-) create mode 100644 jeecg-module-auto-process/src/main/java/org/jeecg/modules/exception/CAnalyseException.java diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/exception/CAnalyseException.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/exception/CAnalyseException.java new file mode 100644 index 00000000..d0ad8190 --- /dev/null +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/exception/CAnalyseException.java @@ -0,0 +1,24 @@ +package org.jeecg.modules.exception; + +/** + * C谱分析异常 + */ +public class CAnalyseException extends AnalyseException{ + + /** + * Constructs a new exception with the specified detail message. The + * cause is not initialized, and may subsequently be initialized by + * a call to {@link #initCause}. + * + * @param message the detail message. The detail message is saved for + * later retrieval by the {@link #getMessage()} method. + */ + public CAnalyseException(String message) { + super(message); + } + + public CAnalyseException(String message, boolean isDuplicateKeyException) { + super(message,isDuplicateKeyException); + } + +} 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 80ef7d5a..1bae27d2 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 @@ -28,6 +28,7 @@ import org.jeecg.modules.base.enums.SpectrumType; import org.jeecg.modules.config.datasource.DataSourceSwitcher; import org.jeecg.modules.entity.vo.*; import org.jeecg.modules.exception.AnalySpectrumException; +import org.jeecg.modules.exception.CAnalyseException; import org.jeecg.modules.exception.GAnalyseException; import org.jeecg.modules.file.FileOperation; import org.jeecg.modules.native_jni.EnergySpectrumHandler; @@ -139,7 +140,7 @@ public class Sample_C_Analysis { sampleData.getInputFileName().lastIndexOf((StringConstant.SLASH))+1); } - public void analysis() throws GAnalyseException, AnalySpectrumException{ + public void analysis() throws CAnalyseException, AnalySpectrumException{ log.info("SelfStaion自动处理分析--Start"); try { //获取PHD文件的路径以及文件名称信息 @@ -225,11 +226,11 @@ public class Sample_C_Analysis { e.printStackTrace(); log.error("Sample_C_Analysis", e); if (e instanceof DuplicateKeyException) { - throw new GAnalyseException("Sample Analyse Error at "+DateUtils.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss"), true); + throw new CAnalyseException("Sample Analyse Error at "+DateUtils.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss"), true); } else if (e instanceof AnalySpectrumException) { throw new AnalySpectrumException(e.getMessage()); } else { - throw new GAnalyseException("Sample Analyse Error at "+DateUtils.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss")); + throw new CAnalyseException("Sample Analyse Error at "+DateUtils.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss")); } } log.info("SelfStaion自动处理分析--End"); @@ -238,7 +239,7 @@ public class Sample_C_Analysis { /* * 根据自建台站样品谱生成4个Gamma谱 * */ - private void create4PHD(){ + public void create4PHD(){ // 计算边界值 List gEnergy = sampleStruct.g_energy; List gCentroidChannel = sampleStruct.g_centroid_channel; @@ -280,27 +281,38 @@ public class Sample_C_Analysis { // 根据ROI生成四个Gamma谱文件 文件命名格式为: 样品谱原名_ROI_x.PHD String gammaOneName = StrUtil.subBefore(sampleFilename, ".PHD", true) + "_ROI_1.PHD"; - selfStationUtil.createGammaFile(sampleFilePath, gammaOneName, this.sampleStruct, roiOneCounts); + selfStationUtil.createGammaFile(this.savePath(), gammaOneName, this.sampleStruct, roiOneCounts); String gammaTwoName = StrUtil.subBefore(sampleFilename, ".PHD", true) + "_ROI_2.PHD"; - selfStationUtil.createGammaFile(sampleFilePath, gammaTwoName, this.sampleStruct, roiTwoCounts); + selfStationUtil.createGammaFile(this.savePath(), gammaTwoName, this.sampleStruct, roiTwoCounts); String gammaThreeName = StrUtil.subBefore(sampleFilename, ".PHD", true) + "_ROI_3.PHD"; - selfStationUtil.createGammaFile(sampleFilePath, gammaThreeName, this.sampleStruct, roiThreeCounts); + selfStationUtil.createGammaFile(this.savePath(), gammaThreeName, this.sampleStruct, roiThreeCounts); String gammaFourName = StrUtil.subBefore(sampleFilename, ".PHD", true) + "_ROI_4.PHD"; - selfStationUtil.createGammaFile(sampleFilePath, gammaFourName, this.sampleStruct, roiFourCounts); + selfStationUtil.createGammaFile(this.savePath(), gammaFourName, this.sampleStruct, roiFourCounts); // 将生成的GammaPHD文件转换为PHDFile对象 - this.phdFile1 = selfStationUtil.getGammaPHD(gammaOneName, sampleFilePath); + this.phdFile1 = selfStationUtil.getGammaPHD(gammaOneName, this.savePath()); this.phdFile1.setRoiSuffix("_ROI_1"); - this.phdFile2 = selfStationUtil.getGammaPHD(gammaTwoName, sampleFilePath); + this.phdFile2 = selfStationUtil.getGammaPHD(gammaTwoName, this.savePath()); this.phdFile2.setRoiSuffix("_ROI_2"); - this.phdFile3 = selfStationUtil.getGammaPHD(gammaThreeName, sampleFilePath); + this.phdFile3 = selfStationUtil.getGammaPHD(gammaThreeName, this.savePath()); this.phdFile3.setRoiSuffix("_ROI_3"); - this.phdFile4 = selfStationUtil.getGammaPHD(gammaFourName, sampleFilePath); + this.phdFile4 = selfStationUtil.getGammaPHD(gammaFourName, this.savePath()); this.phdFile4.setRoiSuffix("_ROI_4"); } + /* + * 获取savefile全路径 不包含文件名 + * */ + public String savePath(){ + spectrumPathProperties = SpringContextUtils.getBean(SpectrumPathProperties.class); + String rootPath = spectrumPathProperties.getRootPath(); + String saveFilePath = spectrumPathProperties.getSaveFilePath(); + String saveRelativePath = this.spectrumHandler.getFileSaveRelativePath(); + return rootPath + saveFilePath + File.separator + saveRelativePath; + } + /** * 读取计算MDC参数文件方法 */ diff --git a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java index 97b7889c..83f8747e 100644 --- a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java +++ b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/GammaFileUtil.java @@ -2,6 +2,7 @@ package org.jeecg.common.util; import cn.hutool.core.io.FileUtil; import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.StringPool; @@ -3178,8 +3179,9 @@ public class GammaFileUtil extends AbstractLogOrReport { boolean bRet=true; //标准名称规范化 String dataType = fileAnlyse.getMsgInfo().getData_type(); + String systemType = fileAnlyse.getHeader().getSystem_type(); String subDirSavePath = ""; - subDirSavePath+=nameStandUtil.GetSysTemSubdir(fileAnlyse.getHeader().getSystem_type()); + subDirSavePath+=nameStandUtil.GetSysTemSubdir(systemType); subDirSavePath+=nameStandUtil.GetDateTypeSubdir(dataType); Map fileNames = nameStandUtil.NameStandard(fileAnlyse); String lcName = fileNames.get("lc"); @@ -3212,7 +3214,8 @@ public class GammaFileUtil extends AbstractLogOrReport { anylseBegin = DateUtils.formatDate(new Date(), "yyyy/MM/dd HH:mm:ss"); bRet = AnalyseSpectrum(fileAnlyse,nucline); if (bRet) { - RunQC(fileAnlyse); + if (!StrUtil.equals(systemType, SystemType.SELFSTATION.getType())) + RunQC(fileAnlyse); fileAnlyse.setEfficiencyParam(fileAnlyse.getUsedEffiPara().getP()); fileAnlyse.setEfficiencyEnergy(fileAnlyse.getUsedEffiKD().getG_energy()); fileAnlyse.setEfficiencyCurRow(0); @@ -3316,7 +3319,7 @@ public class GammaFileUtil extends AbstractLogOrReport { } //gards_ calibration_pairs Efficiency - middleData.calibration_pairs_sample_type = fileAnlyse.getHeader().getSystem_type(); + middleData.calibration_pairs_sample_type = systemType; if(fileAnlyse.getUsedEffiKD() != null && fileAnlyse.getUsedEffiKD().getG_energy().size() != 0) { middleData.calibration_pairs_EF_Caltype = CalType.EFFICIENCY_CAL.getType(); middleData.calibration_pairs_EF_Input = fileAnlyse.getUsedEffi(); @@ -3390,7 +3393,7 @@ public class GammaFileUtil extends AbstractLogOrReport { // gards_ calibration 数据表 //拼写刻度字符串 //获取刻度描述字符串 - middleData.calibration_sample_type = fileAnlyse.getHeader().getSystem_type(); + middleData.calibration_sample_type = systemType; String coeffEnergy = ""; String uncerEnergy = ""; String funcDefEnergy = ""; @@ -3805,7 +3808,7 @@ public class GammaFileUtil extends AbstractLogOrReport { middleData.sample_stationID = fileAnlyse.getHeader().getSite_code(); middleData.sample_detectID = fileAnlyse.getHeader().getDetector_code(); middleData.sample_Geometry = fileAnlyse.getHeader().getSample_geometry(); - middleData.sample_Type = fileAnlyse.getHeader().getSystem_type(); + middleData.sample_Type = systemType; middleData.setting_specSetup = fileAnlyse.getUsedSetting(); middleData.Collection_Station_Comments = StringUtils.isNotBlank(fileAnlyse.getOriTotalCmt())?fileAnlyse.getOriTotalCmt():""; middleData.NDC_Analysis_General_Comments = StringUtils.isNotBlank(fileAnlyse.getTotalCmt())?fileAnlyse.getTotalCmt():""; diff --git a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/SelfUtil.java b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/SelfUtil.java index 3bb52c58..c261c8e5 100644 --- a/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/SelfUtil.java +++ b/jeecg-module-beta-gamma-analyser/src/main/java/org/jeecg/common/util/SelfUtil.java @@ -46,7 +46,14 @@ public class SelfUtil { return counts; } - public void createGammaFile(String pathName, String fileName, EnergySpectrumStruct struct, List g_counts) { + /** + * 根据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; @@ -59,7 +66,7 @@ public class SelfUtil { 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 " + + out.println(struct.site_code + " " + struct.detector_code + " C " + struct.sample_geometry + " " + struct.spectrum_quantity); out.println(struct.sample_ref_id); out.println(struct.measurement_id + " " + struct.detector_bk_measurement_id + " 0"); @@ -89,9 +96,9 @@ public class SelfUtil { String str = g_counts.get(i).toString(); if(i % 5 == 0) { if (i == 0) { - out.printf(i+""); + out.printf((i+1)+""); } else { - out.printf("\n" + i ); + out.printf("\n" + (i+1) ); } beforeStr = i+""; }