From a0c1a335ee93b56351416e9ce221bd25a2629635 Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Tue, 26 Sep 2023 10:16:45 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E8=BF=94=E5=9B=9E=E5=86=85=E5=AE=B9=E7=9A=84?= =?UTF-8?q?=E8=A7=A3=E6=9E=90=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jeecg/common/util/GammaFileUtil.java | 144 +++++++++++++----- 1 file changed, 105 insertions(+), 39 deletions(-) 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 e652eef7..4fb8c475 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,7 +1,6 @@ package org.jeecg.common.util; import com.alibaba.fastjson.JSON; -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; @@ -43,7 +42,6 @@ import java.text.DecimalFormat; import java.text.NumberFormat; import java.text.ParseException; import java.util.*; -import java.util.stream.Collectors; @Component public class GammaFileUtil { @@ -986,32 +984,41 @@ public class GammaFileUtil { qcItems.put("Xe133-MDC", Xe133); } } - + //遍历QcItems for(Map.Entry iter:qcItems.entrySet()){ + //判断 QcItems的Standard是否为空 if(iter.getValue().getStandard().isEmpty()){ continue; } + //根据英文,分割standard数据 String[] lists = iter.getValue().getStandard().split(StringPool.COMMA); + //声明一个boolean类型 记录是否符合要求 boolean bSatisfy = true; + //遍历标准数据 for(String str : lists) { + //判断标准数据是否含有 / 如果含有跳过本次循环 if(str.contains(StringPool.DASH)){ continue; - } else if(str.contains(StringPool.LEFT_BRACKET)) { + } else if(str.contains(StringPool.LEFT_BRACKET)) {//判断标准数据是否包含( + //判断当前QcItem的值 是否 小于等于 去掉(后的标准值 if(iter.getValue().getValue() <= Double.valueOf(str.replace(StringPool.LEFT_BRACKET,""))) { bSatisfy = false; break; } - } else if(str.contains(StringPool.RIGHT_BRACKET)) { + } else if(str.contains(StringPool.RIGHT_BRACKET)) {//判断标准数据是否包含) + //判断当前QcItem的值 是否 大于等于 去掉)后的标准值 if(iter.getValue().getValue() >= Double.valueOf(str.replace(StringPool.RIGHT_BRACKET,""))) { bSatisfy = false; break; } - } else if(str.contains(StringPool.LEFT_SQ_BRACKET)) { + } else if(str.contains(StringPool.LEFT_SQ_BRACKET)) {//判断标准数据是否包含[ + //判断当前QcItem的值 是否 小于 去掉[后的标准值 if(iter.getValue().getValue() < Double.valueOf(str.replace(StringPool.LEFT_SQ_BRACKET,""))) { bSatisfy = false; break; } - } else if(str.contains(StringPool.RIGHT_SQ_BRACKET)) { + } else if(str.contains(StringPool.RIGHT_SQ_BRACKET)) {//判断标准数据是否包含] + //判断当前QcItem的值 是否 大于 去掉]后的标准值 if(iter.getValue().getValue() > Double.valueOf(str.replace(StringPool.RIGHT_SQ_BRACKET,""))) { bSatisfy = false; break; @@ -1029,29 +1036,47 @@ public class GammaFileUtil { public Double CalculateMDC(PHDFile phd, List vMdcInfo, Double CCF) { try { System.loadLibrary("GammaAnaly"); + //判断用于计算的数据大小是否小于3 判断集合中最后一个数值是否等于0 if(vMdcInfo.size() < 3 || vMdcInfo.get(2) == 0) { return 0.0; } + //获取采集开始时间 Date collectStart = DateUtils.parseDate(phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time().substring(0,phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); + //获取采样结束时间 Date collectStop = DateUtils.parseDate(phd.getCollect().getCollection_stop_date() + StringPool.SPACE + phd.getCollect().getCollection_stop_time().substring(0,phd.getCollect().getCollection_stop_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); + //获取能谱获取时间 Date acqStart = DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + StringPool.SPACE + phd.getAcq().getAcquisition_start_time().substring(0,phd.getAcq().getAcquisition_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); - double Ts = (collectStart.getTime()/1000 - collectStop.getTime()/1000); // 采样时间 - double Td = (collectStop.getTime()/1000 - acqStart.getTime()/1000); // 衰变时间 - double Ta = phd.getAcq().getAcquisition_real_time(); // 能谱获取实时间 - double Tl = phd.getAcq().getAcquisition_live_time(); // 能谱获取活时间 - double Svol = phd.getCollect().getAir_volume(); // 样品采样体积 + //计算采样时间 + double Ts = (collectStart.getTime()/1000 - collectStop.getTime()/1000); + //计算衰变时间 + double Td = (collectStop.getTime()/1000 - acqStart.getTime()/1000); + //获取能谱获取实时间 + double Ta = phd.getAcq().getAcquisition_real_time(); + //获取能谱获取活时间 + double Tl = phd.getAcq().getAcquisition_live_time(); + //获取样品采样体积 + double Svol = phd.getCollect().getAir_volume(); double DCF1, DCF2, DCF3; - + //计算得到lamda计算值 double lambda = Math.log(2.0) / (vMdcInfo.get(2) * 86400); - if ( Ts == 0 ) DCF1 = 1; - else DCF1 = lambda * Ts / (1-Math.exp(-lambda*Ts)); - if ( Td == 0 ) DCF2 = 1; - else DCF2 = Math.exp(lambda*Td); - if ( Ta == 0 ) DCF3 = 1; - else DCF3 = lambda * Ta / (1-Math.exp(-lambda*Ta)); - + if ( Ts == 0 ) { + DCF1 = 1; + } else { + DCF1 = lambda * Ts / (1-Math.exp(-lambda*Ts)); + } + if ( Td == 0 ) { + DCF2 = 1; + } else { + DCF2 = Math.exp(lambda*Td); + } + if ( Ta == 0 ) { + DCF3 = 1; + } else { + DCF3 = lambda * Ta / (1-Math.exp(-lambda*Ta)); + } + //计算得到DCF_conc double DCF_conc = Math.exp(lambda * (phd.getUsedSetting().getRefTime_conc().getTime()/1000 - collectStart.getTime()/1000)); - + //声明一个集合 List energy = new LinkedList<>(); energy.add(vMdcInfo.get(0)); //使用energyToChannel方法计算 @@ -1255,9 +1280,11 @@ public class GammaFileUtil { // SRID, Sample_Status, Collect_Start, Sampling_Time, Quantity, Flow_Rate, // Acq_Start, Acq_Real, Acq_Live, Decay_Time, Auto_Cat, Category List detailInfo = new LinkedList<>(); + //Detail Info的所有数据初始化为“” for (int i=0; i<18; i++){ detailInfo.add(""); } + //读取phdFile的数据 修改detailInfo的数据 detailInfo.set(0, Objects.nonNull(sampleId)?sampleId.toString():""); // Sample_Id detailInfo.set(1, phd.getHeader().getSite_code()); // Station_Code detailInfo.set(2, phd.getHeader().getDetector_code()); // Detector_Code @@ -1291,10 +1318,11 @@ public class GammaFileUtil { } public void UpdateChart(PHDFile phd, Map map, Map colorMap) { + //声明一个数组 List m_vCount = new LinkedList<>(); + //获取 phdFile的Spec的num_g_channel long m_nCount = phd.getSpec().getNum_g_channel(); long m_nSChan = phd.getSpec().getBegin_channel(); - // 确保绘制曲线时所有谱都是从1道开始 int i = 0; if(m_nSChan == 0){ @@ -1590,7 +1618,9 @@ public class GammaFileUtil { } public int AnalyseData(PHDFile phd, List nuclides) { + //判断phdFile内容是否有进行改变 int change = SettingChanged(phd); + //change == 0 且 vPeak的集合大小大于0 说明内容没有变化 if(change == 0 && phd.getVPeak().size() > 0) { return change; } else if(change == -1) { @@ -1620,23 +1650,47 @@ public class GammaFileUtil { Map parseMap = JSON.parseObject(strValue, Map.class); for (Map.Entry entry:parseMap.entrySet()) { if (entry.getKey().equalsIgnoreCase("bAnalyed")) { - boolean value = (boolean) entry.getValue(); + boolean value = JSON.parseObject(JSON.toJSONString(entry.getValue()), Boolean.class); phd.setBAnalyed(value); } if (entry.getKey().equalsIgnoreCase("mapEnerPara")) { - Map value = (Map) entry.getValue(); + 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")) { - Map value = (Map) entry.getValue(); + 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")) { - Map value = (Map) entry.getValue(); + 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")) { - Map value = (Map) entry.getValue(); + 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")) { @@ -1660,35 +1714,47 @@ public class GammaFileUtil { phd.setPara_tailRightAlpha(value); } if (entry.getKey().equalsIgnoreCase("newEner")) { - String value = (String) entry.getValue(); + String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class); phd.setNewEner(value); } if (entry.getKey().equalsIgnoreCase("mapEnerKD")) { - Map value = (Map) entry.getValue(); + 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")) { - Map value = (Map) entry.getValue(); + 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 = (List) entry.getValue(); + List value = JSON.parseArray(JSON.toJSONString(entry.getValue()), Double.class); phd.setVEnergy(value); } if (entry.getKey().equalsIgnoreCase("vBase")) { - List value = (List) entry.getValue(); + List value = JSON.parseArray(JSON.toJSONString(entry.getValue()), Double.class); phd.setVBase(value); } if (entry.getKey().equalsIgnoreCase("vLc")) { - List value = (List) entry.getValue(); + List value = JSON.parseArray(JSON.toJSONString(entry.getValue()), Double.class); phd.setVLc(value); } if (entry.getKey().equalsIgnoreCase("vScac")) { - List value = (List) entry.getValue(); + List value = JSON.parseArray(JSON.toJSONString(entry.getValue()), Double.class); phd.setVScac(value); } if (entry.getKey().equalsIgnoreCase("vPeak")) { - List value = (List) entry.getValue(); + List value = JSON.parseArray(JSON.toJSONString(entry.getValue()), PeakInfo.class); phd.setVPeak(value); } if (entry.getKey().equalsIgnoreCase("baseCtrls")) { @@ -1696,7 +1762,7 @@ public class GammaFileUtil { phd.setBaseCtrls(value); } if (entry.getKey().equalsIgnoreCase("usedEner")) { - String value = (String) entry.getValue(); + String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class); phd.setUsedEner(value); } if (entry.getKey().equalsIgnoreCase("usedEnerKD")) { @@ -1708,7 +1774,7 @@ public class GammaFileUtil { phd.setUsedEnerPara(value); } if (entry.getKey().equalsIgnoreCase("usedReso")) { - String value = (String) entry.getValue(); + String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class); phd.setUsedReso(value); } if (entry.getKey().equalsIgnoreCase("usedResoKD")) { @@ -1720,7 +1786,7 @@ public class GammaFileUtil { phd.setUsedResoPara(value); } if (entry.getKey().equalsIgnoreCase("usedEffi")) { - String value = (String) entry.getValue(); + String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class); phd.setUsedEffi(value); } if (entry.getKey().equalsIgnoreCase("usedEffiKD")) { @@ -1732,7 +1798,7 @@ public class GammaFileUtil { phd.setUsedEffiPara(value); } if (entry.getKey().equalsIgnoreCase("usedTotE")) { - String value = (String) entry.getValue(); + String value = JSON.parseObject(JSON.toJSONString(entry.getValue()), String.class); phd.setUsedTotE(value); } if (entry.getKey().equalsIgnoreCase("usedTotEKD")) { From 18d205e21bf41477c0a00eca9ae2a58ef0736e31 Mon Sep 17 00:00:00 2001 From: xiaoguangbin Date: Tue, 26 Sep 2023 11:01:53 +0800 Subject: [PATCH 2/5] =?UTF-8?q?fix=EF=BC=9Agamma=20=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jeecg/common/constant/CommonConstant.java | 2 +- .../jeecg/common/util/GammaReportUtil.java | 63 ++- .../java/org/jeecg/common/GammaFileUtil.java | 508 +++++++++++++----- .../modules/native_jni/CalValuesHandler.java | 20 +- .../struct/EnergySpectrumStruct.java | 3 + .../GardsGammaDefaultParamsServiceImpl.java | 4 +- .../modules/spectrum/Sample_G_Analysis.java | 180 +++++-- 7 files changed, 547 insertions(+), 233 deletions(-) diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/CommonConstant.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/CommonConstant.java index 7c8c8423..dd411a72 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/CommonConstant.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/CommonConstant.java @@ -514,7 +514,7 @@ public interface CommonConstant { /** * 自动处理Gamma报告前缀 */ - String REPORT_PREFIX_AUTO = "RNAUTO_"; + String REPORT_PREFIX_AUTO = "RNAUTO"; /** * 自动处理报告后缀 diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/GammaReportUtil.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/GammaReportUtil.java index 5b384d97..e13840ad 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/GammaReportUtil.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/GammaReportUtil.java @@ -1,20 +1,28 @@ package org.jeecg.common.util; +import cn.hutool.core.io.FileUtil; +import com.baomidou.mybatisplus.core.toolkit.StringPool; +import org.apache.commons.lang3.StringUtils; import org.jeecg.modules.entity.vo.BaseControls; +import org.jeecgframework.core.util.ApplicationContextUtil; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.PrintWriter; +import java.io.*; +import java.math.BigDecimal; +import java.math.MathContext; import java.util.List; import java.util.Objects; public class GammaReportUtil { + private static FTPUtil ftpUtil = ApplicationContextUtil.getContext().getBean(FTPUtil.class); public static void writeFile(BaseControls baseCtrl, String path){ + // 获取系统的临时目录 + String tempDir = System.getProperty("java.io.tmpdir"); // 创建文件 - File file = new File(path); + File file = new File(tempDir += System.currentTimeMillis()); + // 创建PrintWriter对象 + PrintWriter out = null; try { - // 创建PrintWriter对象 - PrintWriter out = new PrintWriter(file); + out = new PrintWriter(file); out.println("#AnalyseRange"); String low = String.valueOf(baseCtrl.getRg_low()); String high = String.valueOf(baseCtrl.getRg_high()); @@ -35,22 +43,41 @@ public class GammaReportUtil { out.println("#StepCounts"); format(baseCtrl.getStepCounts(), out); + + String targetPath = StringUtils.substringBeforeLast(path, StringPool.SLASH); + String targetName = StringUtils.substringAfterLast(path, StringPool.SLASH); + ftpUtil.saveFile(targetPath, targetName, new FileInputStream(file)); } catch (FileNotFoundException e) { e.printStackTrace(); + } finally { + if (null != out) { + out.close(); + } } } public static void writeFile(List data, String fileType, String path){ + // 获取系统的临时目录 + String tempDir = System.getProperty("java.io.tmpdir"); // 创建文件 - File file = new File(path); + File file = new File(tempDir + System.currentTimeMillis()); + // 创建PrintWriter对象 + PrintWriter out = null; try { - // 创建PrintWriter对象 - PrintWriter out = new PrintWriter(file); + out = new PrintWriter(file); out.println("#" + fileType); out.printf("%" + (String.valueOf(data.size()).length() + 15) + "s", data.size() + "\n"); format(data, out); + String targetPath = StringUtils.substringBeforeLast(path, StringPool.SLASH); + String targetName = StringUtils.substringAfterLast(path, StringPool.SLASH); + ftpUtil.saveFile(targetPath, targetName, new FileInputStream(file)); + } catch (FileNotFoundException e) { e.printStackTrace(); + } finally { + if (null != out) { + out.close(); + } } } @@ -69,8 +96,8 @@ public class GammaReportUtil { for(i = 0; i < nGroupBL; i++) { - String col = Objects.isNull(data.get(i)) ? "nan" : String.valueOf(data.get(i)); - out.printf("%" + (columnWidths[i] + 15) + "s", col); + System.out.print(i+">>>>"+data.get(i)); + out.printf("%" + (columnWidths[i] + 15) + "s", getValue(data.get(i))); if((i+1) % numPerLine == 0) { out.println(""); } @@ -78,10 +105,20 @@ public class GammaReportUtil { if(i < n) { for(; i ftpFiles = Arrays.asList(ftpClient.listFiles()); - ftpFiles = ftpFiles.stream().filter(item -> item.getName().equals(fileName)).collect(Collectors.toList()); - if (ftpFiles.size() == 0) { - result.error500("ftp获取文件数据失败"); - return false; - } - FTPFile ftpFile = ftpFiles.get(0); - if (Objects.nonNull(ftpFile)) { - InputStream inputStream = ftpClient.retrieveFileStream(ftpFile.getName()); + inputStream = ftpClient.retrieveFileStream(fileName); + if (Objects.nonNull(inputStream)) { //声明一个临时文件 File file = File.createTempFile("tmp", null); //将ftp文件的输入流复制给临时文件 @@ -115,7 +121,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 (org.apache.commons.lang3.StringUtils.isNotBlank(struct.collection_start_date) && org.apache.commons.lang3.StringUtils.isNotBlank(struct.collection_start_time) && org.apache.commons.lang3.StringUtils.isNotBlank(struct.collection_stop_date) && org.apache.commons.lang3.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); @@ -131,7 +137,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 (org.apache.commons.lang3.StringUtils.isNotBlank(struct.acquisition_start_date) && org.apache.commons.lang3.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); @@ -144,7 +150,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) && org.apache.commons.lang3.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); @@ -157,7 +163,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 { @@ -165,14 +171,14 @@ public class GammaFileUtil { phd.getSampleBlock().setDimension_2(0.0); } //Calibration - if (StringUtils.isNotBlank(struct.date_calibration) || StringUtils.isNotBlank(struct.time_calibration)) { + if (org.apache.commons.lang3.StringUtils.isNotBlank(struct.date_calibration) && org.apache.commons.lang3.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) && org.apache.commons.lang3.StringUtils.isNotBlank(struct.assay_date) && org.apache.commons.lang3.StringUtils.isNotBlank(struct.assay_time) && org.apache.commons.lang3.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); @@ -190,7 +196,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); @@ -206,7 +212,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); @@ -215,7 +221,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); @@ -224,7 +230,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); @@ -233,7 +239,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); @@ -247,9 +253,11 @@ public class GammaFileUtil { phd.getSetting().setECutAnalysis_Low(35.0); phd.getSetting().setBUpdateCal(true); } - phd.getSetting().setRefTime_conc(DateUtils.parseDate(phd.getCollect().getCollection_start_date() + " " + phd.getCollect().getCollection_start_time().substring(0, phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss")); - phd.getSetting().setRefTime_act(DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + " " + phd.getAcq().getAcquisition_start_time().substring(0, phd.getAcq().getAcquisition_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss")); - phd.setUsedSetting(phd.getSetting()); + phd.getSetting().setRefTime_conc(DateUtils.parseDate(phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time().substring(0, phd.getCollect().getCollection_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss")); + phd.getSetting().setRefTime_act(DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + StringPool.SPACE + phd.getAcq().getAcquisition_start_time().substring(0, phd.getAcq().getAcquisition_start_time().indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss")); + 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")); @@ -264,6 +272,9 @@ public class GammaFileUtil { if (Objects.nonNull(ftpClient)){ ftpClient.disconnect(); } + if (Objects.nonNull(inputStream)){ + inputStream.close(); + } } catch (IOException e) { throw new RuntimeException(e); } @@ -1517,8 +1528,194 @@ public class GammaFileUtil { return true; } - public boolean AnalyseSpectrum(PHDFile phd, Map map){ - return false; + public boolean AnalyseSpectrum(PHDFile phd, Map mapLines){ + System.loadLibrary("GammaAnaly"); + //解析获取临时文件信息 + File tmpFile = analyzeFile(phd.getFilepath(), phd.getFilename()); + ObjectMapper mapper = new ObjectMapper(); + try { + String phdStr = mapper.writeValueAsString(phd); + String nuclideLinesMap = mapper.writeValueAsString(mapLines); + String strValue = CalValuesHandler.analyseSpectrum(phdStr, nuclideLinesMap, 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 (org.apache.commons.lang3.StringUtils.isBlank(peak.recoilBetaChan)) { + peak.recoilBetaChan = "1"; + } + if (org.apache.commons.lang3.StringUtils.isBlank(peak.recoilDeltaChan)) { + peak.recoilDeltaChan = "1"; + } + } + //重新分析各峰值对应的核素信息 + NuclidesIdent(phd, mapLines); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + return true; } public int SettingChanged(PHDFile phd) { @@ -1705,7 +1902,7 @@ public class GammaFileUtil { private void ReadSpecialNuclides(Map mapHalflife, List vNuclides) { try { - String fileName = parameterFilePath+"/setup/nuclide_ActMdc.txt"; + String fileName = parameterFilePath+"/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++){ @@ -2783,7 +2980,6 @@ public class GammaFileUtil { public boolean GetMiddleData(PHDFile fileAnlyse, String userName,Map nucline,GStoreMiddleProcessData middleData, String type) throws ParseException { boolean bRet=true; - //标准名称规范化 String dataType = fileAnlyse.getMsgInfo().getData_type(); String subDirSavePath = ""; @@ -2834,9 +3030,11 @@ public class GammaFileUtil { String qsSaveBaseLine = StringPool.SLASH+spectrumPathProperties.getRootPath()+StringPool.SLASH+qsBaseLinePath; String qsSaveLc = StringPool.SLASH+spectrumPathProperties.getRootPath()+StringPool.SLASH+qsLcPath; String qsSaveScac = StringPool.SLASH+spectrumPathProperties.getRootPath()+StringPool.SLASH+qsScacPath; - middleData.analyses_baseline_filePath = qsSaveBaseLine; - middleData.analyses_lc_filePath = qsSaveLc; - middleData.analyses_scac_filePath = qsSaveScac; + + GammaReportUtil.writeFile(fileAnlyse.getBaseCtrls(), qsSaveBaseLine); + GammaReportUtil.writeFile(fileAnlyse.getVLc(), "LC", qsSaveLc); + GammaReportUtil.writeFile(fileAnlyse.getVScac(), "SCSC", qsSaveScac); +// ftpUtil.saveFile(org.apache.commons.lang3.StringUtils.substringBeforeLast(qsSaveBaseLine, StringPool.SLASH), baselineName, new FileInputStream(fileAnlyse.getBaseCtrls())); // WriteBaseInfo(fileAnlyse.getBaseCtrls(),qsSaveBaseLine); // WriteLcScac(fileAnlyse.getVLc(),"Lc",qsSaveLc); // WriteLcScac(fileAnlyse.getVScac(),"Scac",qsSaveScac); @@ -2855,6 +3053,16 @@ public class GammaFileUtil { middleData.analyses_searchThreshold = fileAnlyse.getUsedSetting().getEnergyTolerance(); middleData.analyses_numberOfPeaks = fileAnlyse.getVPeak().size(); middleData.analyses_totalCounts = totalNumber; + middleData.analyses_baseline_filePath = qsBaseLinePath; + middleData.analyses_lc_filePath = qsLcPath; + middleData.analyses_scac_filePath = qsScacPath; + + middleData.analyses_baseline_absolute_filePath =qsSaveLc; + middleData.analyses_lc_absolute_filePath=qsSaveLc; + middleData.analyses_scac_absolute_filePath=qsSaveScac; + middleData.analyses_save_absolute_filePath=spectrumPathProperties.getRootPath()+StringPool.SLASH+qsSaveFile; + middleData.analyses_absolute_LogPath=spectrumPathProperties.getLogPath()+StringPool.SLASH+qsLogPath; + middleData.analyses_absolute_ReportPath=spectrumPathProperties.getRootPath()+StringPool.SLASH+qsReportPath; if(fileAnlyse.getUsedEnerKD() != null && fileAnlyse.getUsedEnerKD().getG_energy().size() != 0) { middleData.calibration_pairs_E_Caltype = CalType.ENERGY_CAL.getType(); @@ -2865,13 +3073,13 @@ public class GammaFileUtil { for(int pos=0;pos0) { - coeffEnergy+=numberFormat.format(fileAnlyse.getUsedEnerPara().getP().get(coeffNumber-1)); + coeffEnergy+=String.format("%e", fileAnlyse.getUsedEnerPara().getP().get(coeffNumber-1)); } uncerNumber = fileAnlyse.getUsedEnerPara().getPerr().size(); for(int m=0;m0) { - uncerEnergy+=numberFormat.format(fileAnlyse.getUsedEnerPara().getPerr().get(uncerNumber-1)); + uncerEnergy+=String.format("%e", fileAnlyse.getUsedEnerPara().getPerr().get(uncerNumber-1)); } funcDefEnergy = EquationDescription(funcType); funcTypeDefEnergy = EquationName(funcType); @@ -3000,18 +3207,18 @@ public class GammaFileUtil { funcType = fileAnlyse.getUsedEffiPara().getP().get(0).intValue(); } for(int m=1;m0) { - coeffEffi+=numberFormat.format(fileAnlyse.getUsedEffiPara().getP().get(coeffNumber-1)); + coeffEffi+=String.format("%e", fileAnlyse.getUsedEffiPara().getP().get(coeffNumber-1)); } uncerNumber = fileAnlyse.getUsedEffiPara().getPerr().size(); for(int m=0;m0) { - uncerEffi+= numberFormat.format(fileAnlyse.getUsedEffiPara().getPerr().get(uncerNumber-1)); + uncerEffi+= String.format("%e", fileAnlyse.getUsedEffiPara().getPerr().get(uncerNumber-1)); } funcDefEffi = EquationDescription(funcType); funcTypeDefEffi = EquationName(funcType); @@ -3032,18 +3239,18 @@ public class GammaFileUtil { funcType = fileAnlyse.getUsedResoPara().getP().get(0).intValue(); } for(int m=1;m0) { - coeffReso+= numberFormat.format(fileAnlyse.getUsedResoPara().getP().get(coeffNumber-1)); + coeffReso+= String.format("%e", fileAnlyse.getUsedResoPara().getP().get(coeffNumber-1)); } uncerNumber = fileAnlyse.getUsedResoPara().getPerr().size(); for(int m=0;m0) { - uncerReso+= numberFormat.format(fileAnlyse.getUsedResoPara().getPerr().get(uncerNumber-1)); + uncerReso+= String.format("%e", fileAnlyse.getUsedResoPara().getPerr().get(uncerNumber-1)); } funcDefReso = EquationDescription(funcType); funcTypeDefReso = EquationName(funcType); @@ -3064,18 +3271,18 @@ public class GammaFileUtil { funcType = fileAnlyse.getUsedTotEPara().getP().get(0).intValue(); } for(int m=1;m0) { - coeffTotE+= numberFormat.format(fileAnlyse.getUsedTotEPara().getP().get(coeffNumber-1)); + coeffTotE+= String.format("%e", fileAnlyse.getUsedTotEPara().getP().get(coeffNumber-1)); } uncerNumber = fileAnlyse.getUsedTotEPara().getPerr().size(); for(int m=0;m0) { - uncerTotE+= numberFormat.format(fileAnlyse.getUsedTotEPara().getPerr().get(uncerNumber-1)); + uncerTotE+= String.format("%e", fileAnlyse.getUsedTotEPara().getPerr().get(uncerNumber-1)); } funcDefTotE = EquationDescription(funcType); funcTypeDefTotE = EquationName(funcType); @@ -3090,7 +3297,7 @@ public class GammaFileUtil { //gards_ peaks数据表 if(fileAnlyse.getVPeak().size() != 0) { - List dvctIDPEAK = new LinkedList<>(); + List dvctIDPEAK = new LinkedList<>(); List dvctCENTROIDCHANNEL = new LinkedList<>(); List dvctUNCCENTROIDCHANNEL = new LinkedList<>(); List dvctENERGY = new LinkedList<>(); @@ -3122,8 +3329,8 @@ public class GammaFileUtil { List dvctLD = new LinkedList<>(); List dvctNuclide_name = new LinkedList<>(); List dvctComments = new LinkedList<>(); - for(int m=0;m 1024){ t_comment = t_comment.substring(0, 1025); } dvctComments.add(t_comment); - - String qsName = ""; - for(int n=0;n svctNUCLIDEFULLNAME = new LinkedList<>(); - List dvctIDPEAK = new LinkedList<>(); - List dvctENERGY = new LinkedList<>(); - List dvctUNCENERGY = new LinkedList<>(); - List dvctABUNDANCE = new LinkedList<>(); - List dvctUNCABUNDANCE = new LinkedList<>(); - List dvctACTIVITY = new LinkedList<>(); - List dvctUNCACTIVITY = new LinkedList<>(); - List dvctEFFIC = new LinkedList<>(); - List dvctUNEFFIC = new LinkedList<>(); - List dvctMDA = new LinkedList<>(); - List dvctKEY_FLAG = new LinkedList<>(); - List dvctCSC_RATIO = new LinkedList<>(); - List dvctCSC_RATIO_ERR = new LinkedList<>(); - List dvctCSC_MOD_FLAG = new LinkedList<>(); - List dvctMDC = new LinkedList<>(); - List dvctCONCENTRATION = new LinkedList<>(); for(Map.Entry itor:fileAnlyse.getMapNucActMda().entrySet()) { + List svctNUCLIDEFULLNAME = new LinkedList<>(); + List dvctIDPEAK = new LinkedList<>(); + List dvctENERGY = new LinkedList<>(); + List dvctUNCENERGY = new LinkedList<>(); + List dvctABUNDANCE = new LinkedList<>(); + List dvctUNCABUNDANCE = new LinkedList<>(); + List dvctACTIVITY = new LinkedList<>(); + List dvctUNCACTIVITY = new LinkedList<>(); + List dvctEFFIC = new LinkedList<>(); + List dvctUNEFFIC = new LinkedList<>(); + List dvctMDA = new LinkedList<>(); + List dvctKEY_FLAG = new LinkedList<>(); + List dvctCSC_RATIO = new LinkedList<>(); + List dvctCSC_RATIO_ERR = new LinkedList<>(); + List dvctCSC_MOD_FLAG = new LinkedList<>(); + List dvctMDC = new LinkedList<>(); + List dvctCONCENTRATION = new LinkedList<>(); int first=itor.getValue().getFullNames().size(); int second=itor.getValue().getVPeakIdx().size(); first = first0?String.format("%e", itor.getValue().getMda()):"0.0"); // dvctKEY_FLAG.add(itor.value().vYield.get(m)); dvctCSC_RATIO.add(1.0); dvctCSC_RATIO_ERR.add(0.0); @@ -3249,11 +3447,11 @@ public class GammaFileUtil { } else { dvctKEY_FLAG.add(0.0); } - dvctMDC.add(numberFormat.format(itor.getValue().getMdc())); - dvctCONCENTRATION.add(numberFormat.format(itor.getValue().getConcentration())); + dvctMDC.add(String.format("%e", itor.getValue().getMdc())); + dvctCONCENTRATION.add(String.format("%e", itor.getValue().getConcentration())); } nucl_lines_ided_data.nuclideFullname = svctNUCLIDEFULLNAME; - nucl_lines_ided_data.idPeak =DoubleLimit_G(dvctIDPEAK); + nucl_lines_ided_data.idPeak =dvctIDPEAK; nucl_lines_ided_data.Energy =DoubleLimit_G(dvctENERGY); nucl_lines_ided_data.uncEnergy =DoubleLimit_G(dvctUNCENERGY); nucl_lines_ided_data.Abundance =DoubleLimit_G(dvctABUNDANCE); @@ -3272,36 +3470,35 @@ public class GammaFileUtil { middleData.getNucl_lines_ided_data().put(itor.getKey(), nucl_lines_ided_data); } // gards_ nucl_ided数据表 - List svctNUCLIDEFULLNAME1 = new LinkedList<>(); - List svctTYPE = new LinkedList<>(); - List dvctHALFLIFE = new LinkedList<>(); - List dvctAVE_ACTIV = new LinkedList<>(); - List dvctAVE_ACTIV_ERR = new LinkedList<>(); - List dvctACTIV_KEY = new LinkedList<>(); - List dvctACTIV_KEY_ERR = new LinkedList<>(); - List dvctMDA1 = new LinkedList<>(); - List dvctMDA_ERR = new LinkedList<>(); - List dvctNID_FLAG = new LinkedList<>(); - List dvctCSC_RATIO1 = new LinkedList<>(); - List dvctCSC_RATIO_ERR1 = new LinkedList<>(); - List dvctCSC_MOD_FLAG1 = new LinkedList<>(); - List dvctMDC1 = new LinkedList<>(); - List dvctCONCENTRATION1 = new LinkedList<>(); - List dvctKey_Energy = new LinkedList<>(); - List dvctKey_Yield = new LinkedList<>(); - if( fileAnlyse.getMapNucActMda().size() != 0) { + List svctNUCLIDEFULLNAME = new LinkedList<>(); + List svctTYPE = new LinkedList<>(); + List dvctHALFLIFE = new LinkedList<>(); + List dvctAVE_ACTIV = new LinkedList<>(); + List dvctAVE_ACTIV_ERR = new LinkedList<>(); + List dvctACTIV_KEY = new LinkedList<>(); + List dvctACTIV_KEY_ERR = new LinkedList<>(); + List dvctMDA = new LinkedList<>(); + List dvctMDA_ERR = new LinkedList<>(); + List dvctNID_FLAG = new LinkedList<>(); + List dvctCSC_RATIO = new LinkedList<>(); + List dvctCSC_RATIO_ERR = new LinkedList<>(); + List dvctCSC_MOD_FLAG = new LinkedList<>(); + List dvctMDC = new LinkedList<>(); + List dvctCONCENTRATION = new LinkedList<>(); + List dvctKey_Energy = new LinkedList<>(); + List dvctKey_Yield = new LinkedList<>(); for(Map.Entry itor_v: fileAnlyse.getMapNucActMda().entrySet()) { String nuclideName = itor_v.getKey(); - svctNUCLIDEFULLNAME1.add(nuclideName); + svctNUCLIDEFULLNAME.add(nuclideName); dvctHALFLIFE.add(itor_v.getValue().getHalflife()); dvctACTIV_KEY.add(itor_v.getValue().getActivity()); dvctACTIV_KEY_ERR.add(itor_v.getValue().getAct_err()); - dvctMDA1.add(numberFormat.format(itor_v.getValue().getMda())); - dvctMDC1.add(numberFormat.format(itor_v.getValue().getMdc())); - dvctCONCENTRATION1.add(numberFormat.format(itor_v.getValue().getConcentration())); - dvctCSC_RATIO1.add(1.0); - dvctCSC_RATIO_ERR1.add(0.0); + dvctMDA.add(String.format("%e", itor_v.getValue().getMda())); + dvctMDC.add(itor_v.getValue().getMdc()>0?String.format("%e", itor_v.getValue().getMdc()):"0.0"); + dvctCONCENTRATION.add(String.format("%e", itor_v.getValue().getConcentration())); + dvctCSC_RATIO.add(1.0); + dvctCSC_RATIO_ERR.add(0.0); if(itor_v.getValue().getCalculateIdx() >= 0 && itor_v.getValue().getCalculateIdx() qvctQC_NAME = new LinkedList<>(); - List dvctQC_VALUE = new LinkedList<>(); - List qvctQC_STANDARD = new LinkedList<>(); - List dvctQC_RESULT = new LinkedList<>(); if( fileAnlyse.getQcItems().size() != 0) { + List qvctQC_NAME = new LinkedList<>(); + List dvctQC_VALUE = new LinkedList<>(); + List qvctQC_STANDARD = new LinkedList<>(); + List dvctQC_RESULT = new LinkedList<>(); for(Map.Entry itor_q:fileAnlyse.getQcItems().entrySet()) { String nuclideName = itor_q.getKey(); qvctQC_NAME.add(nuclideName); @@ -3347,11 +3542,9 @@ public class GammaFileUtil { middleData.QC_CHECK_QC_STANDARD=qvctQC_STANDARD; middleData.QC_CHECK_QC_VALUE=DoubleLimit_G(dvctQC_VALUE); } - //sample info - middleData.sample_collection_start = fileAnlyse.getCollect().getCollection_start_date()+" "+fileAnlyse.getCollect().getCollection_start_time(); - middleData.sample_collection_stop = fileAnlyse.getCollect().getCollection_stop_date()+" "+fileAnlyse.getCollect().getCollection_stop_time(); - + middleData.sample_collection_start = fileAnlyse.getCollect().getCollection_start_date()+StringPool.SPACE+fileAnlyse.getCollect().getCollection_start_time(); + middleData.sample_collection_stop = fileAnlyse.getCollect().getCollection_stop_date()+StringPool.SPACE+fileAnlyse.getCollect().getCollection_stop_time(); if(Objects.nonNull(fileAnlyse.getQcItems().get("col_time"))) { middleData.sample_time = String.format("%.4f", fileAnlyse.getQcItems().get("col_time").getValue()); if(fileAnlyse.getQcItems().get("col_time").getValue()!=0) { @@ -3365,18 +3558,16 @@ public class GammaFileUtil { middleData.sample_acquistion_time = String.format("%.5f", fileAnlyse.getQcItems().get("acq_time").getValue()); } middleData.sample_quantity = String.format("%.4f", fileAnlyse.getCollect().getAir_volume()); - middleData.sample_acquisiton_start = fileAnlyse.getAcq().getAcquisition_start_date()+" "+fileAnlyse.getAcq().getAcquisition_start_time(); + middleData.sample_acquisiton_start = fileAnlyse.getAcq().getAcquisition_start_date()+StringPool.SPACE+fileAnlyse.getAcq().getAcquisition_start_time(); String acquisition_start = middleData.sample_acquisiton_start; - Date dataTime = DateUtils.parseDate(acquisition_start.substring(0, acquisition_start.indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); - acquisition_start = DateUtils.formatDate(dataTime, "yyyy/MM/dd HH:mm:ss"); - middleData.sample_acquistion_stop = DateUtils.formatDate(new Date((long) (dataTime.getTime()/1000 + fileAnlyse.getAcq().getAcquisition_live_time())), "yyyy/MM/dd HH:mm:ss"); + Date dataTime = DateUtils.parseDate(acquisition_start); + middleData.sample_acquistion_stop = DateUtils.formatDate(new Date((long) (dataTime.getTime()/1000 + fileAnlyse.getAcq().getAcquisition_live_time())) , "yyyy/MM/dd HH:mm:ss"); middleData.sample_acquistion_time = String.format("%.2f", fileAnlyse.getAcq().getAcquisition_real_time()) ; 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.setting_specSetup = fileAnlyse.getUsedSetting(); - middleData.Collection_Station_Comments = fileAnlyse.getOriTotalCmt(); middleData.NDC_Analysis_General_Comments = fileAnlyse.getTotalCmt(); return bRet; @@ -4027,4 +4218,41 @@ public class GammaFileUtil { } } + 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-auto-process/src/main/java/org/jeecg/modules/native_jni/CalValuesHandler.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/native_jni/CalValuesHandler.java index aeb4a67e..c74161b8 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/native_jni/CalValuesHandler.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/native_jni/CalValuesHandler.java @@ -1,8 +1,8 @@ package org.jeecg.modules.native_jni; -import org.jeecg.modules.entity.vo.PeakInfo; import org.jeecg.modules.eneity.vo.StructInsertInput; import org.jeecg.modules.eneity.vo.StructInsertOutput; +import org.jeecg.modules.entity.vo.PeakInfo; import org.jeecg.modules.native_jni.struct.CalValuesOut; import java.util.List; @@ -25,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); - - public static native String baseImprove(double BaseImprovePSS, double k_back, double k_alpha, double k_beta); - - public static native String fitPeakFull(); + public static native String analyseSpectrum(String phd, String mapLines, String phdFilePath); } diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/native_jni/struct/EnergySpectrumStruct.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/native_jni/struct/EnergySpectrumStruct.java index 63eb8f90..c58a5f44 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/native_jni/struct/EnergySpectrumStruct.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/native_jni/struct/EnergySpectrumStruct.java @@ -1,11 +1,14 @@ package org.jeecg.modules.native_jni.struct; +import lombok.Data; + import java.util.List; import java.util.Objects; /** * 能谱结构体字段信息 */ +@Data public class EnergySpectrumStruct { /************************* Infomations ******************/ diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsGammaDefaultParamsServiceImpl.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsGammaDefaultParamsServiceImpl.java index b0ea3e52..4a909897 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsGammaDefaultParamsServiceImpl.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsGammaDefaultParamsServiceImpl.java @@ -18,8 +18,8 @@ public class GardsGammaDefaultParamsServiceImpl extends ServiceImpl mapSetting() { Map paramsMap = list().stream() - .collect(Collectors.toMap(GardsGammaDefaultParams::getName, - v->v.getValue() == null ? "" : v.getValue())); + .collect(Collectors.toMap(v-> v.getName().trim(), + v->v.getValue() == null ? "-9999" : v.getValue())); return paramsMap; } } 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 7be44e7d..30be1904 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 @@ -7,10 +7,14 @@ import cn.hutool.core.io.FileUtil; import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.toolkit.StringPool; +import com.google.common.collect.Lists; import com.google.common.collect.Maps; import lombok.Data; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.jeecg.common.GammaFileUtil; +import org.jeecg.common.api.vo.Result; import org.jeecg.common.constant.*; import org.jeecg.common.constant.enums.SpectrumSystemType; import org.jeecg.common.properties.SpectrumPathProperties; @@ -20,13 +24,22 @@ import org.jeecg.common.util.MyLogFormatUtil; import org.jeecg.modules.base.dto.*; import org.jeecg.modules.base.entity.original.GardsSampleData; import org.jeecg.modules.base.entity.rnauto.*; +import org.jeecg.modules.base.enums.MiddleDataType; +import org.jeecg.modules.config.datasource.DataSourceSwitcher; 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.transaction.TransactionStatus; +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; import java.lang.reflect.Field; import java.util.*; @Data +@Slf4j public class Sample_G_Analysis { private final Map fieldMap = fieldMap(); @@ -82,8 +95,10 @@ public class Sample_G_Analysis { */ private String arrFileName; + private FTPUtils ftpUtil; + public Sample_G_Analysis(EnergySpectrumStruct energySpectrumStruct,SpectrumServiceQuotes serviceQuotes, - GardsSampleData sampleData) { + GardsSampleData sampleData, FTPUtils ftpUtil) { this.sampleData = sampleData; this.serviceQuotes = serviceQuotes; this.energySpectrumStruct = energySpectrumStruct; @@ -92,6 +107,7 @@ public class Sample_G_Analysis { this.sampleInputFilename = sampleData.getInputFileName(); this.sampleFilename = StringUtils.substring(sampleData.getInputFileName(), sampleData.getInputFileName().lastIndexOf((StringConstant.SLASH)+1)); + this.ftpUtil = ftpUtil; } public void analysis(){ @@ -100,11 +116,17 @@ public class Sample_G_Analysis { GStoreMiddleProcessData middleData = new GStoreMiddleProcessData(); Integer sampleId = sampleData.getSampleId(); - GammaFileUtil gammaFileUtil = new GammaFileUtil(); + GammaFileUtil gammaFileUtil = ApplicationContextUtil.getContext().getBean(GammaFileUtil.class); PHDFile phdFile = new PHDFile(); + // 解析PHD文件 + spectrumPathProperties = ApplicationContextUtil.getContext().getBean(SpectrumPathProperties.class); + String sampleFilePath = sampleData.getInputFileName(); + String pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); + String fileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH)+1); + boolean flag = gammaFileUtil.loadFile(pathName, fileName, phdFile, new Result()); // 获取数据库 Gamma 默认参数 - getSettingFromDB(phdFile); +// getSettingFromDB(phdFile); // 文件路径 middleData.setAnalyses_save_filePath(this.sampleInputFilename); // 读取文件内容并附值 @@ -117,26 +139,11 @@ public class Sample_G_Analysis { if (this.systemType.equals(SpectrumSystemType.G.name())) { nuclideLibs = this.getNuclideLinesG(); } - gammaFileUtil.GetMiddleData(phdFile, CommonConstant.REPORT_PREFIX_AUTO, nuclideLibs, middleData, "1"); + gammaFileUtil.GetMiddleData(phdFile, CommonConstant.REPORT_PREFIX_AUTO, nuclideLibs, middleData, MiddleDataType.Auto.getType()); + + // 数据插入数据库 + this.storageDataToDatabase(middleData, phdFile.getQcItems()); - // 保存分析结果 ==> INSERT INTO RNAUTO.GARDS_ANALYSES - saveAnalysis(middleData,sampleId); - // 获取分析结果ID ==> SELECT IDANALYSIS - Integer IdAnalysis = getIdAnalysis(sampleId); - // 修改保存结果状态 ==> UPDATE ORIGINAL.GARDS_SAMPLE_DATA - serviceQuotes.getSampleDataService().updateStatus(null,null); - /* GARDS_CALIBRATION_PAIRS 数据表保存 */ - saveCalibrationPairs(middleData, sampleId, IdAnalysis); - /* GARDS_CALIBRATION 数据表保存 */ - saveCalibration(middleData, sampleId, IdAnalysis); - /* Gards_Peaks 数据表保存 */ - savePeaks(middleData); - /* Gards_Nucl_Lines_Ided 数据表保存 */ - saveNuclLinesIded(middleData, sampleId, IdAnalysis); - /* Gards_Nucl_Ided 数据表保存 */ - saveNuclIded(middleData, sampleId, IdAnalysis); - /* Gards_Qc_Check 数据表保存 */ - saveQcCheck(middleData, sampleId, IdAnalysis, phdFile.getQcItems()); // 生成日志文件 writeLog(middleData.getAnalyses_LogPath(), middleData); // todo 报告文件 @@ -148,6 +155,47 @@ public class Sample_G_Analysis { } } + private void storageDataToDatabase(GStoreMiddleProcessData middleData, Map qcItems){ + //如果数据已经存储,不在重复存储 + final Integer idAnalysis = serviceQuotes.getAnalysesService().getIdAnalysis(this.sampleData.getSampleId()); + if(Objects.nonNull(idAnalysis)){ +// log.warn("{} file analysis data has been stored",new File(this.sampleTempFilePath).getName()); + return; + } + DataSourceSwitcher.switchToOracle(); + final TransactionStatus transactionStatus = serviceQuotes.getTransactionManager().getTransaction(serviceQuotes.getTransactionDefinition()); + try { + Integer sampleId = this.sampleData.getSampleId(); + // 保存分析结果 ==> INSERT INTO RNAUTO.GARDS_ANALYSES + saveAnalysis(middleData, sampleId); + // 获取分析结果ID ==> SELECT IDANALYSIS + Integer IdAnalysis = getIdAnalysis(sampleId); + // 修改保存结果状态 ==> UPDATE ORIGINAL.GARDS_SAMPLE_DATA +// serviceQuotes.getSampleDataService().updateStatus(null,null); + /* GARDS_CALIBRATION_PAIRS 数据表保存 */ + saveCalibrationPairs(middleData, sampleId, IdAnalysis); + /* GARDS_CALIBRATION 数据表保存 */ + saveCalibration(middleData, sampleId, IdAnalysis); + /* Gards_Peaks 数据表保存 */ + savePeaks(middleData); + /* Gards_Nucl_Lines_Ided 数据表保存 */ + saveNuclLinesIded(middleData, sampleId, IdAnalysis); + /* Gards_Nucl_Ided 数据表保存 */ + saveNuclIded(middleData, sampleId, IdAnalysis); + /* Gards_Qc_Check 数据表保存 */ + saveQcCheck(middleData, sampleId, IdAnalysis, qcItems); + //提交事务 + serviceQuotes.getTransactionManager().commit(transactionStatus); + } catch (Exception e) { + //设置分析数据存储失败标记 +// this.parsingProcessLog.setAnalysisDataStoreFlag(false); + //回滚事务 + serviceQuotes.getTransactionManager().rollback(transactionStatus); + throw e; + } finally { + DataSourceSwitcher.clearDataSource(); + } + } /** * 生成日志文件 * @param logFilePath @@ -434,57 +482,69 @@ public class Sample_G_Analysis { String base_E_Paris = "calibration_pairs_E_idCalPoint"; PairsEDto pairsEDto = new PairsEDto(); BeanUtil.copyProperties(middleData,pairsEDto); - List pairsE = mapFields(pairsEDto, pairs, base_E_Paris, fieldMap); - String pairsECaltype = middleData.getCalibration_pairs_E_Caltype(); - String pairsEInput = middleData.getCalibration_pairs_E_Input(); - for (GardsCalibrationPairs onePairs : pairsE) { - onePairs.setSampleId(sampleId); - onePairs.setIdAnalysis(IdAnalysis); - onePairs.setSampleType(pairsSampleType); - onePairs.setCaltype(pairsECaltype); - onePairs.setInput(pairsEInput); + List pairsE = Lists.newArrayList(); + if (pairsEDto.getCalibration_pairs_E_idCalPoint().size() > 0) { + pairsE = mapFields(pairsEDto, pairs, base_E_Paris, fieldMap); + String pairsECaltype = middleData.getCalibration_pairs_E_Caltype(); + String pairsEInput = middleData.getCalibration_pairs_E_Input(); + for (GardsCalibrationPairs onePairs : pairsE) { + onePairs.setSampleId(sampleId); + onePairs.setIdAnalysis(IdAnalysis); + onePairs.setSampleType(pairsSampleType); + onePairs.setCaltype(pairsECaltype); + onePairs.setInput(pairsEInput); + } } // GARDS_CALIBRATION_PAIRS (Efficiency) ==> INSERT INTO RNAUTO.GARDS_CALIBRATION_PAIRS String base_EF_Paris = "calibration_pairs_EF_idCalPoint"; PairsEFDto pairsEFDto = new PairsEFDto(); BeanUtil.copyProperties(middleData,pairsEFDto); - List pairsEF = mapFields(pairsEFDto, pairs, base_EF_Paris, fieldMap); - String pairsEFCaltype = middleData.getCalibration_pairs_EF_Caltype(); - String pairsEFInput = middleData.getCalibration_pairs_EF_Input(); - for (GardsCalibrationPairs onePairs : pairsEF) { - onePairs.setSampleId(sampleId); - onePairs.setIdAnalysis(IdAnalysis); - onePairs.setSampleType(pairsSampleType); - onePairs.setCaltype(pairsEFCaltype); - onePairs.setInput(pairsEFInput); + List pairsEF = Lists.newArrayList(); + if (pairsEFDto.getCalibration_pairs_EF_idCalPoint().size() > 0) { + pairsEF = mapFields(pairsEFDto, pairs, base_EF_Paris, fieldMap); + String pairsEFCaltype = middleData.getCalibration_pairs_EF_Caltype(); + String pairsEFInput = middleData.getCalibration_pairs_EF_Input(); + for (GardsCalibrationPairs onePairs : pairsEF) { + onePairs.setSampleId(sampleId); + onePairs.setIdAnalysis(IdAnalysis); + onePairs.setSampleType(pairsSampleType); + onePairs.setCaltype(pairsEFCaltype); + onePairs.setInput(pairsEFInput); + } } // GARDS_CALIBRATION_PAIRS (Resolution) ==> INSERT INTO RNAUTO.GARDS_CALIBRATION_PAIRS String base_R_Paris = "calibration_pairs_R_idCalPoint"; PairsRDto pairsRDto = new PairsRDto(); BeanUtil.copyProperties(middleData,pairsRDto); - List pairsR = mapFields(pairsRDto, pairs, base_R_Paris, fieldMap); - String pairsRCaltype = middleData.getCalibration_pairs_R_Caltype(); - String pairsRInput = middleData.getCalibration_pairs_R_Input(); - for (GardsCalibrationPairs onePairs : pairsR) { - onePairs.setSampleId(sampleId); - onePairs.setIdAnalysis(IdAnalysis); - onePairs.setSampleType(pairsSampleType); - onePairs.setCaltype(pairsRCaltype); - onePairs.setInput(pairsRInput); + List pairsR = Lists.newArrayList(); + if (pairsRDto.getCalibration_pairs_R_idCalPoint().size() > 0) { + pairsR = mapFields(pairsRDto, pairs, base_R_Paris, fieldMap); + String pairsRCaltype = middleData.getCalibration_pairs_R_Caltype(); + String pairsRInput = middleData.getCalibration_pairs_R_Input(); + for (GardsCalibrationPairs onePairs : pairsR) { + onePairs.setSampleId(sampleId); + onePairs.setIdAnalysis(IdAnalysis); + onePairs.setSampleType(pairsSampleType); + onePairs.setCaltype(pairsRCaltype); + onePairs.setInput(pairsRInput); + } } // GARDS_CALIBRATION_PAIRS (TotalEfficiency) ==> INSERT INTO RNAUTO.GARDS_CALIBRATION_PAIRS String base_T_Paris = "calibration_pairs_T_idCalPoint"; PairsTDto pairsTDto = new PairsTDto(); BeanUtil.copyProperties(middleData,pairsTDto); - List pairsT = mapFields(pairsTDto, pairs, base_T_Paris, fieldMap); - String pairsTCaltype = middleData.getCalibration_pairs_T_Caltype(); - String pairsTInput = middleData.getCalibration_pairs_T_Input(); - for (GardsCalibrationPairs onePairs : pairsT) { - onePairs.setSampleId(sampleId); - onePairs.setIdAnalysis(IdAnalysis); - onePairs.setSampleType(pairsSampleType); - onePairs.setCaltype(pairsTCaltype); - onePairs.setInput(pairsTInput); + List pairsT = Lists.newArrayList(); + if (pairsTDto.getCalibration_pairs_T_idCalPoint().size() > 0) { + pairsT = mapFields(pairsTDto, pairs, base_T_Paris, fieldMap); + String pairsTCaltype = middleData.getCalibration_pairs_T_Caltype(); + String pairsTInput = middleData.getCalibration_pairs_T_Input(); + for (GardsCalibrationPairs onePairs : pairsT) { + onePairs.setSampleId(sampleId); + onePairs.setIdAnalysis(IdAnalysis); + onePairs.setSampleType(pairsSampleType); + onePairs.setCaltype(pairsTCaltype); + onePairs.setInput(pairsTInput); + } } // GARDS_CALIBRATION_PAIRS 汇总保存 List allPairs = new ArrayList<>(); @@ -646,11 +706,13 @@ public class Sample_G_Analysis { } public Map getNuclideLinesG() { + redisUtil = ApplicationContextUtil.getContext().getBean(RedisUtil.class); Object nuclideLibs = redisUtil.get(RedisConstant.NUCLIDE_LINES_LIB + "G"); return Objects.isNull(nuclideLibs) ? Maps.newHashMap() : (Map) nuclideLibs; } public Map getNuclideLinesP(){ + redisUtil = ApplicationContextUtil.getContext().getBean(RedisUtil.class); Object nuclideLibs = redisUtil.get(RedisConstant.NUCLIDE_LINES_LIB + "P"); return Objects.isNull(nuclideLibs) ? Maps.newHashMap() : (Map) nuclideLibs; } @@ -788,7 +850,7 @@ public class Sample_G_Analysis { private GardsAnalyses toAnalysis(GStoreMiddleProcessData middleData){ GardsAnalyses gardsAnalyses = new GardsAnalyses(); - String dateTime = DateConstant.DATE_TIME; + String dateTime = DateConstant.DATE_BIAS_TIME; String analysisBegin = middleData.getAnalyses_analysisBegin(); Date analysis_Begin = DateUtil.parse(analysisBegin, dateTime) .toJdkDate(); From f41b378856c9c2bfb9f875d731a7395c0ea28410 Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Tue, 26 Sep 2023 15:23:47 +0800 Subject: [PATCH 3/5] =?UTF-8?q?GammaController=E6=96=B0=E5=A2=9EaddComment?= =?UTF-8?q?=E6=96=B9=E6=B3=95=20=E4=BF=AE=E6=94=B9=E5=88=86=E6=9E=90?= =?UTF-8?q?=E5=90=8E=E7=BB=93=E6=9E=9C=E8=B5=8B=E5=80=BC=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jeecg/common/util/GammaFileUtil.java | 88 +++++++++++++++---- .../modules/controller/GammaController.java | 10 ++- .../jeecg/modules/service/IGammaService.java | 4 +- .../service/impl/GammaServiceImpl.java | 73 ++++++++++----- 4 files changed, 134 insertions(+), 41 deletions(-) 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 4fb8c475..3696217d 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 @@ -37,6 +37,7 @@ import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import java.io.*; import java.math.BigDecimal; +import java.math.MathContext; import java.math.RoundingMode; import java.text.DecimalFormat; import java.text.NumberFormat; @@ -1088,26 +1089,28 @@ public class GammaFileUtil { double[] array = dE.stream().mapToDouble(Double::doubleValue).toArray(); SimpleMatrix dEMatrix = new SimpleMatrix(calDerivEval.rowNum, calDerivEval.colNum, true, array); //calFcnEval计算得到矩阵数据 - CalValuesOut calFcnEval = CalValuesHandler.calFcnEval(energy, phd.getUsedEnerPara().getP()); - List counts = calFcnEval.counts; + CalValuesOut fwhmcCalFcnEval = CalValuesHandler.calFcnEval(energy, phd.getUsedResoPara().getP()); + List fwhmcCounts = fwhmcCalFcnEval.counts; //计算后的矩阵的集合转换成数组 - double[] array2 = counts.stream().mapToDouble(Double::doubleValue).toArray(); + double[] array2 = fwhmcCounts.stream().mapToDouble(Double::doubleValue).toArray(); //按照行数 列数 实际数据 生成矩阵 - SimpleMatrix calMatrix = new SimpleMatrix(calFcnEval.rowNum, calFcnEval.colNum, true, array2); + SimpleMatrix calMatrix = new SimpleMatrix(fwhmcCalFcnEval.rowNum, fwhmcCalFcnEval.colNum, true, array2); //计算后的矩阵 / dE矩阵 得到除后的矩阵 SimpleMatrix matrixC = calMatrix.elementDiv(dEMatrix); //声明一个集合接收除后的矩阵数据 - List values = new LinkedList<>(); +// List values = new LinkedList<>(); //遍历相除后的矩阵 行数 - for (int i=0; i counts = calFcnEval.counts; double effi = counts.get(0); int index = 0; for(int i=1; i old_ener = phd.getUsedEnerPara().getP(); - List new_ener = phd.getMapEnerPara().get(phd.getNewEner()).getP(); + List new_ener = CollectionUtils.isNotEmpty(phd.getMapEnerPara())?phd.getMapEnerPara().get(phd.getNewEner()).getP():new LinkedList<>(); if(old_ener.size() != new_ener.size()) { return 1; } @@ -1859,7 +1914,7 @@ public class GammaFileUtil { } List old_reso = phd.getUsedResoPara().getP(); - List new_reso = phd.getMapResoPara().get(phd.getNewReso()).getP(); + List new_reso = CollectionUtils.isNotEmpty(phd.getMapResoPara())?phd.getMapResoPara().get(phd.getNewReso()).getP():new LinkedList<>(); if(old_reso.size() != new_reso.size()) { return 1; } @@ -1870,7 +1925,7 @@ public class GammaFileUtil { } List old_effi = phd.getUsedEffiPara().getP(); - List new_effi = phd.getMapEffiPara().get(phd.getNewEffi()).getP(); + List new_effi = CollectionUtils.isNotEmpty(phd.getMapEffiPara())?phd.getMapEffiPara().get(phd.getNewEffi()).getP():new LinkedList<>(); if(old_effi.size() != new_effi.size()) { return -1; } @@ -1879,7 +1934,8 @@ public class GammaFileUtil { return -1; } } - return 0; + //return 0; + return 1; } public void UpdateEfficiency(PHDFile phd) { 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 c7086096..ccddd548 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 @@ -36,8 +36,8 @@ public class GammaController { @GetMapping("initValue") @ApiOperation(value = "初始化gamma数据", notes = "初始化gamma数据") - public Result initValue(Integer sampleId, String dbName, HttpServletRequest request) { - return gammaService.initValue(sampleId, dbName, request); + public Result initValue(Integer sampleId, String dbName, String fileName, HttpServletRequest request) { + return gammaService.initValue(sampleId, dbName, fileName, request); } @GetMapping("analysisProcess") @@ -350,6 +350,12 @@ public class GammaController { return gammaService.viewComment(sampleId, fileName); } + @PutMapping("addComment") + @ApiOperation(value = "修改Comment数据", notes = "修改Comment数据") + public Result addComment(String fileName, String comment) { + return gammaService.addComment(fileName, comment); + } + @GetMapping("peakInformation") @ApiOperation(value = "查看Peak Information页面数据", notes = "查看Peak Information页面数据") public Result peakInformation(Integer sampleId, String fileName){ 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 89058d3a..dde8a850 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 @@ -12,7 +12,7 @@ import java.util.List; public interface IGammaService{ - Result initValue(Integer sampleId, String dbName, HttpServletRequest request); + Result initValue(Integer sampleId, String dbName, String fileName, HttpServletRequest request); Result testFun(String fileName, HttpServletRequest request); @@ -116,6 +116,8 @@ public interface IGammaService{ Result viewComment(Integer sampleId, String fileName); + Result addComment(String fileName, String comment); + Result peakInformation(Integer sampleId, String fileName); void exportPeakInformation(Integer sampleId, String fileName, HttpServletResponse response); 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 2f6cb178..ab7c8b16 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 @@ -120,33 +120,45 @@ public class GammaServiceImpl implements IGammaService { private IGardsAnalySettingSpectrumService analySettingSpectrumService; @Override - public Result initValue(Integer sampleId, String dbName, HttpServletRequest request) { + public Result initValue(Integer sampleId, String dbName, String samfileName, HttpServletRequest request) { Result result = new Result(); // String userName = JwtUtil.getUserNameByToken(request); Cache phdCache = localCache.getPHDCache(); PHDFile phd = new PHDFile(); //读取文件内容 - //根据sampleId获取sample文件路径 - String sampleFilePath = spectrumAnalysisMapper.getSampleFilePath(sampleId); - if (StringUtils.isBlank(sampleFilePath)){ - result.error500("样品文件不存在!"); - return result; + String lastName = ""; + if (Objects.nonNull(sampleId) && StringUtils.isNotBlank(dbName)) { + //根据sampleId获取sample文件路径 + String sampleFilePath = spectrumAnalysisMapper.getSampleFilePath(sampleId); + if (StringUtils.isBlank(sampleFilePath)){ + result.error500("样品文件不存在!"); + return result; + } + String pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); + String fileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH)+1); + boolean flag = gammaFileUtil.loadFile(pathName, fileName, phd, result); + if (!flag){ + return result; + } + //声明基础数组信息 + gammaFileUtil.SetBaseInfo(phd); + //从数据库中读取相关信息 + boolean bRet = gammaFileUtil.getResultFromDB(dbName, userName, sampleId, phd, result); + if (!bRet){ + return result; + } + lastName = fileName; + } else { + String pathName = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; + String fileName = samfileName; + boolean flag = gammaFileUtil.loadFile(pathName, fileName, phd, result); + if (!flag){ + return result; + } + lastName = fileName; } - String pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); - String fileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH)+1); - boolean flag = gammaFileUtil.loadFile(pathName, fileName, phd, result); - if (!flag){ - return result; - } - //声明基础数组信息 - gammaFileUtil.SetBaseInfo(phd); - //从数据库中读取相关信息 - boolean bRet = gammaFileUtil.getResultFromDB(dbName, userName, sampleId, phd, result); - if (!bRet){ - return result; - } - phdCache.put(fileName, phd); + phdCache.put(lastName, phd); localCache.setPHDCache(phdCache); result.setSuccess(true); result.setResult(phd); @@ -174,7 +186,6 @@ public class GammaServiceImpl implements IGammaService { } Map nuclideLinesMap = gammaFileUtil.GetNuclideLines(nuclides); //解析获取临时文件信息 - File tmpFile = gammaFileUtil.analyzeFile(StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName, fileName); ObjectMapper mapper = new ObjectMapper(); try { @@ -1057,7 +1068,9 @@ public class GammaServiceImpl implements IGammaService { result.error500("请先选择解析文件!"); return result; } - phd.setTotalCmt(comments); + if (StringUtils.isNotBlank(comments)) { + phd.setTotalCmt(comments); + } return Result.ok(); } @@ -2342,6 +2355,22 @@ public class GammaServiceImpl implements IGammaService { return result; } + @Override + public Result addComment(String fileName, String comment) { + Result result = new Result(); + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(fileName); + if (Objects.isNull(phd)){ + result.error500("请先选择解析文件!"); + return result; + } + if(StringUtils.isNotBlank(comment)) { + phd.setTotalCmt(comment); + } + result.success("修改成功"); + return result; + } + public Result> peakInformation(Integer sampleId, String fileName){ Result> result = new Result(); Cache phdCache = localCache.getPHDCache(); From 07e872718a926aa27ba31e097631f700ff600e13 Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Tue, 26 Sep 2023 16:54:05 +0800 Subject: [PATCH 4/5] =?UTF-8?q?GardsNuclLinesIded=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E4=B8=8E=E6=95=B0=E6=8D=AE=E5=BA=93=E5=AF=B9=E5=BA=94=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E4=BF=AE=E6=94=B9=20Gamma=E9=A1=B5=E9=9D=A2save=20To?= =?UTF-8?q?=20DB=E6=8E=A5=E5=8F=A3=E9=83=A8=E5=88=86=E5=AD=98=E5=82=A8?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E4=BF=AE=E6=94=B9=20GammaFileUtil=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E6=98=AF=E5=90=A6=E5=8F=91=E7=94=9F=E6=94=B9=E5=8F=98?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E8=BF=98=E5=8E=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/entity/rnman/GardsNuclLinesIded.java | 2 +- .../org/jeecg/common/util/GammaFileUtil.java | 3 +- ...librationPairsOrigSpectrumServiceImpl.java | 96 ++++++++++--------- .../GardsNuclIdedSpectrumServiceImpl.java | 13 ++- .../impl/GardsPeaksSpectrumServiceImpl.java | 8 +- ...talEfficiencyPairsSpectrumServiceImpl.java | 28 +++--- 6 files changed, 78 insertions(+), 72 deletions(-) diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/rnman/GardsNuclLinesIded.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/rnman/GardsNuclLinesIded.java index 036063cb..65ac9d67 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/rnman/GardsNuclLinesIded.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/rnman/GardsNuclLinesIded.java @@ -35,7 +35,7 @@ public class GardsNuclLinesIded implements Serializable { /** * 核素名称 */ - @TableField(value = "NUCLIDE_NAME") + @TableField(value = "NUCLIDENAME") private String nuclideName; @TableField(value = "MODDATE") 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 3696217d..a8a8d7b6 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 @@ -1934,8 +1934,7 @@ public class GammaFileUtil { return -1; } } - //return 0; - return 1; + return 0; } public void UpdateEfficiency(PHDFile phd) { diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsCalibrationPairsOrigSpectrumServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsCalibrationPairsOrigSpectrumServiceImpl.java index e1a61e64..41f335e4 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsCalibrationPairsOrigSpectrumServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GardsCalibrationPairsOrigSpectrumServiceImpl.java @@ -112,57 +112,63 @@ public class GardsCalibrationPairsOrigSpectrumServiceImpl extends ServiceImpl calibrationPairsOrigList = new LinkedList<>(); - if (Objects.nonNull(phd.getMapEnerKD().get(CalName.CalPHD.getType()).getG_energy())) { - int t_size = phd.getMapEnerKD().get(CalName.CalPHD.getType()).getG_energy().size(); - if(t_size > 0) { - GEnergyBlock g_ener = phd.getMapEnerKD().get(CalName.CalPHD.getType()); - for (int i=0; i 0) { + GEnergyBlock g_ener = phd.getMapEnerKD().get(CalName.CalPHD.getType()); + for (int i=0; i 0) { - GResolutionBlock g_reso = phd.getMapResoKD().get(CalName.CalPHD.getType()); - for (int i=0; i 0) { + GResolutionBlock g_reso = phd.getMapResoKD().get(CalName.CalPHD.getType()); + for (int i=0; i 0) { - GEfficiencyBlock g_effi = phd.getMapEffiKD().get(CalName.CalPHD.getType()); - for (int i=0; i 0) { + GEfficiencyBlock g_effi = phd.getMapEffiKD().get(CalName.CalPHD.getType()); + for (int i=0; i totalEfficiencyPairsList = new LinkedList<>(); - int t_size = Objects.nonNull(phd.getMapTotEKD().get(CalName.CalPHD.getType()).getG_energy())?phd.getMapTotEKD().get(CalName.CalPHD.getType()).getG_energy().size():0; - if(t_size > 0) { - TotaleffBlock g_tote = phd.getMapTotEKD().get(CalName.CalPHD.getType()); - for (int i=0; i 0) { + TotaleffBlock g_tote = phd.getMapTotEKD().get(CalName.CalPHD.getType()); + for (int i=0; i Date: Tue, 26 Sep 2023 18:43:43 +0800 Subject: [PATCH 5/5] =?UTF-8?q?fix=EF=BC=9Agamma=20=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=A4=84=E7=90=86=E8=A7=A3=E5=86=B3calibration=E6=8F=92?= =?UTF-8?q?=E5=85=A5=E9=97=AE=E9=A2=98=EF=BC=9B=E5=89=8D=E7=AB=AF=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E6=B8=B2=E6=9F=93=E6=95=B0=E6=8D=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/jeecg/common/GammaFileUtil.java | 52 ++++++++++++++++ .../mapper/GardsCalibrationMapper.java | 4 ++ .../mapper/xml/GardsCalibrationMapper.xml | 29 +++++++++ .../service/GardsCalibrationService.java | 4 +- .../impl/GardsCalibrationServiceImpl.java | 6 ++ .../modules/spectrum/Sample_G_Analysis.java | 62 ++++++++++++------- .../spectrum/SpectrumServiceQuotes.java | 1 + 7 files changed, 133 insertions(+), 25 deletions(-) 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 a6282aea..d257c5c3 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 @@ -1701,6 +1701,58 @@ 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 (org.apache.commons.lang3.StringUtils.isBlank(peak.recoilBetaChan)) { diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/mapper/GardsCalibrationMapper.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/mapper/GardsCalibrationMapper.java index 1025782a..0707374e 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/mapper/GardsCalibrationMapper.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/mapper/GardsCalibrationMapper.java @@ -5,8 +5,12 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Param; import org.jeecg.modules.base.entity.rnauto.GardsCalibration; +import java.util.List; + public interface GardsCalibrationMapper extends BaseMapper { @InterceptorIgnore(tenantLine = "true") public int create(@Param("calibration") GardsCalibration calibration); + @InterceptorIgnore(tenantLine = "true") + public int createBatch(@Param("calibrations") List calibration); } diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/mapper/xml/GardsCalibrationMapper.xml b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/mapper/xml/GardsCalibrationMapper.xml index f63942f5..47a10641 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/mapper/xml/GardsCalibrationMapper.xml +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/mapper/xml/GardsCalibrationMapper.xml @@ -31,5 +31,34 @@ #{calibration.moddate}) + + begin + + insert into RNAUTO.GARDS_CALIBRATION( + SAMPLE_ID, + IDANALYSIS, + SAMPLE_TYPE, + CALTYPE, + FUNCTION, + FUNCTIONDEF, + STARTOFRANGE, + ENDOFRANGE, + COEFF_STRING, + moddate) + values + (#{calibration.sampleId}, + #{calibration.idAnalysis}, + #{calibration.sampleType}, + #{calibration.calType}, + #{calibration.function}, + #{calibration.functionDef}, + #{calibration.startOfRange}, + #{calibration.endOfRange}, + #{calibration.coeffString}, + #{calibration.moddate}) + + end; + + \ No newline at end of file diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsCalibrationService.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsCalibrationService.java index b3ecfec6..5a0085a9 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsCalibrationService.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsCalibrationService.java @@ -3,7 +3,8 @@ package org.jeecg.modules.service; import com.baomidou.mybatisplus.extension.service.IService; import org.jeecg.modules.base.entity.rnauto.GardsCalibration; import org.jeecg.modules.native_jni.struct.BgAnalyseResult; -import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct; + +import java.util.List; /** * 存储数据分析过程中能量、分辨率和效率刻度的拟合结果。 @@ -20,4 +21,5 @@ public interface GardsCalibrationService extends IService { * @param anayId */ public void create(BgAnalyseResult analyseResult,Integer sampleId,Integer gasSampleId,Integer detSampleId,Integer anayId); + public void createBatch( List calibrations); } diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsCalibrationServiceImpl.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsCalibrationServiceImpl.java index 876267f0..715c2060 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsCalibrationServiceImpl.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsCalibrationServiceImpl.java @@ -9,6 +9,7 @@ import org.jeecg.modules.service.BlockConstant; import org.jeecg.modules.service.GardsCalibrationService; import org.springframework.stereotype.Service; import java.util.Date; +import java.util.List; @Service @DS("ora") @@ -37,6 +38,11 @@ public class GardsCalibrationServiceImpl extends ServiceImpl calibrations) { + this.baseMapper.createBatch(calibrations); + } + /** * 保存 B_Energy 块信息 * @param analyseResult 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 30be1904..8616658e 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 @@ -32,9 +32,6 @@ import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct; import org.jeecgframework.core.util.ApplicationContextUtil; import org.springframework.transaction.TransactionStatus; -import java.io.File; -import java.io.IOException; -import java.io.PrintWriter; import java.lang.reflect.Field; import java.util.*; @@ -145,7 +142,7 @@ public class Sample_G_Analysis { this.storageDataToDatabase(middleData, phdFile.getQcItems()); // 生成日志文件 - writeLog(middleData.getAnalyses_LogPath(), middleData); +// writeLog(middleData.getAnalyses_LogPath(), middleData); // todo 报告文件 }catch (Exception e){ e.printStackTrace(); @@ -177,7 +174,7 @@ public class Sample_G_Analysis { /* GARDS_CALIBRATION 数据表保存 */ saveCalibration(middleData, sampleId, IdAnalysis); /* Gards_Peaks 数据表保存 */ - savePeaks(middleData); + savePeaks(middleData, sampleId, IdAnalysis); /* Gards_Nucl_Lines_Ided 数据表保存 */ saveNuclLinesIded(middleData, sampleId, IdAnalysis); /* Gards_Nucl_Ided 数据表保存 */ @@ -552,7 +549,6 @@ public class Sample_G_Analysis { allPairs.addAll(pairsR);allPairs.addAll(pairsT); serviceQuotes.getGardsCalibrationPairsService().saveBatch(allPairs); } - public void saveCalibration(GStoreMiddleProcessData middleData, Integer sampleId, Integer IdAnalysis){ String calibrationSampleType = middleData.getCalibration_sample_type(); @@ -573,6 +569,7 @@ public class Sample_G_Analysis { calibration.setStartOfRange((int)middleData.getCalibration_E_startOfRange()); calibration.setEndOfRange((int)middleData.getCalibration_E_endOfRange()); calibration.setCoeffString(middleData.getCalibration_E_coeff_string()); + calibration.setModdate(new Date()); calibrations.add(calibration); } // GARDS_CALIBRATION (EF) ==> INSERT INTO RNAUTO.GARDS_CALIBRATION @@ -592,7 +589,9 @@ public class Sample_G_Analysis { calibration.setFunctionDef(efFunctionDef); calibration.setStartOfRange((int)efStartOfRange); calibration.setEndOfRange((int)efEndOfRange); - calibration.setCoeffString(efCoeffString); + // todo 暂时固定 + calibration.setCoeffString("1,2,3"); + calibration.setModdate(new Date()); calibrations.add(calibration); } // GARDS_CALIBRATION (R) ==> INSERT INTO RNAUTO.GARDS_CALIBRATION @@ -613,6 +612,7 @@ public class Sample_G_Analysis { calibration.setStartOfRange((int)rStartOfRange); calibration.setEndOfRange((int)rEndOfRange); calibration.setCoeffString(rCoeffString); + calibration.setModdate(new Date()); calibrations.add(calibration); } // GARDS_CALIBRATION (T) ==> INSERT INTO RNAUTO.GARDS_CALIBRATION @@ -633,19 +633,26 @@ public class Sample_G_Analysis { calibration.setStartOfRange((int)tStartOfRange); calibration.setEndOfRange((int)tEndOfRange); calibration.setCoeffString(tCoeffString); + calibration.setModdate(new Date()); calibrations.add(calibration); } - serviceQuotes.getGardsCalibrationService().saveBatch(calibrations); + serviceQuotes.getGardsCalibrationService().createBatch(calibrations); } - public void savePeaks(GStoreMiddleProcessData middleData){ + public void savePeaks(GStoreMiddleProcessData middleData,Integer sampleId, Integer IdAnalysis){ // Gards_Peaks数据表 ==> INSERT INTO RNAUTO.GARDS_PEAKS String base_P_IdPeak = "peaks_idPeak"; GardsPeaksDto gardsPeaksDto = new GardsPeaksDto(); BeanUtil.copyProperties(middleData,gardsPeaksDto); GardsPeaks gardsPeaks = new GardsPeaks(); - List peaks = mapFields(gardsPeaksDto, gardsPeaks, base_P_IdPeak, fieldMap); - serviceQuotes.getGardsPeaksAutoService().saveBatch(peaks); + if (gardsPeaksDto.getPeaks_idPeak().size() > 0) { + List peaks = mapFields(gardsPeaksDto, gardsPeaks, base_P_IdPeak, fieldMap); + peaks.forEach(ided -> { + ided.setSampleId(sampleId); + ided.setIdAnalysis(IdAnalysis); + }); + serviceQuotes.getGardsPeaksAutoService().saveBatch(peaks); + } } public void saveNuclLinesIded(GStoreMiddleProcessData middleData, @@ -678,12 +685,15 @@ public class Sample_G_Analysis { GardsNuclIdedDto gardsNuclIdedDto = new GardsNuclIdedDto(); GardsNuclIded gardsNuclIded = new GardsNuclIded(); BeanUtil.copyProperties(middleData,gardsNuclIdedDto); - String base_NuclideName = "nucl_ided_Nuclidename"; - List gardsNuclIdeds = - mapFields(gardsNuclIdedDto, gardsNuclIded, base_NuclideName, fieldMap); - for (GardsNuclIded ided : gardsNuclIdeds) { - ided.setSampleId(sampleId); - ided.setIdAnalysis(IdAnalysis); + if (gardsNuclIdedDto.getNucl_ided_Nuclidename().size() > 0) { + String base_NuclideName = "nucl_ided_Nuclidename"; + List gardsNuclIdeds = + mapFields(gardsNuclIdedDto, gardsNuclIded, base_NuclideName, fieldMap); + for (GardsNuclIded ided : gardsNuclIdeds) { + ided.setSampleId(sampleId); + ided.setIdAnalysis(IdAnalysis); + } + serviceQuotes.getGardsNuclIdedAutoService().saveBatch(gardsNuclIdeds); } // serviceQuotes.get } @@ -695,13 +705,15 @@ public class Sample_G_Analysis { String base_QC = String.valueOf(qcItems.size()); QcCheckDto qcCheckDto = new QcCheckDto(); BeanUtil.copyProperties(middleData,qcCheckDto); - GardsQcCheck gardsQcCheck = new GardsQcCheck(); - List gardsQcChecks = mapFields(qcCheckDto, gardsQcCheck,base_QC,fieldMap); - for (GardsQcCheck qcCheck : gardsQcChecks) { - qcCheck.setSampleId(sampleId); - qcCheck.setIdanalysis(IdAnalysis); + if (qcItems.size() > 0) { + GardsQcCheck gardsQcCheck = new GardsQcCheck(); + List gardsQcChecks = mapFields(qcCheckDto, gardsQcCheck,base_QC,fieldMap); + for (GardsQcCheck qcCheck : gardsQcChecks) { + qcCheck.setSampleId(sampleId); + qcCheck.setIdanalysis(IdAnalysis); + } + serviceQuotes.getGardsQcCheckAutoService().saveBatch(gardsQcChecks); } - serviceQuotes.getGardsQcCheckAutoService().saveBatch(gardsQcChecks); } } @@ -886,7 +898,9 @@ public class Sample_G_Analysis { if (isNumber){ total = Integer.parseInt(baseLine); }else { - List baseList = (List) sourceClass.getDeclaredField(baseLine).get(source); + Field declaredField = sourceClass.getDeclaredField(baseLine); + declaredField.setAccessible(true); + List baseList = (List) declaredField.get(source); if (CollUtil.isEmpty(baseList)) return result; total = baseList.size(); 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 872d5b44..621d6a67 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 @@ -58,6 +58,7 @@ public class SpectrumServiceQuotes { private final GardsPeaksAutoService gardsPeaksAutoService; private final GardsNuclLinesIdedAutoService gardsNuclLinesIdedAutoService; + private final GardsNuclIdedAutoService gardsNuclIdedAutoService; private final GardsQcCheckAutoService gardsQcCheckAutoService;