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")) {