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 bf33643a..e652eef7 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 @@ -295,8 +295,11 @@ public class GammaFileUtil { File file = File.createTempFile("tmp", null); //将ftp文件的输入流复制给临时文件 FileUtils.copyInputStreamToFile(inputStream, file); + //调用FileUtils的readLines方法获取文件的所有行数据 List readLines = FileUtils.readLines(file, "UTF-8"); + //得到行数据处理后的数据结果 List vData = ReadLcScacInfo(readLines); + //将数据结果赋值给 phdFile的vLc phd.setVLc(vData); } } catch (IOException e) { @@ -336,8 +339,11 @@ public class GammaFileUtil { File file = File.createTempFile("tmp", null); //将ftp文件的输入流复制给临时文件 FileUtils.copyInputStreamToFile(inputStream, file); + //调用FileUtils的readLines方法获取文件的所有行数据 List readLines = FileUtils.readLines(file, "UTF-8"); + //得到行数据处理后的数据结果 List vData = ReadLcScacInfo(readLines); + //将数据结果赋值给 phdFile的vScac phd.setVScac(vData); } } catch (IOException e) { @@ -371,9 +377,12 @@ public class GammaFileUtil { ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); ftpClient.changeWorkingDirectory(pathName); String baselineFileName = "RNAUTO_"+subFileName + ".baseline"; + //获取ftp的文件流数据 inputStream = ftpClient.retrieveFileStream(baselineFileName); if (Objects.nonNull(inputStream)){ + //调用处理BaseCtrl的方法 ReadBaseCtrlInfo(phd, inputStream); + //将phdFile的BaseCtrls的BaseLine部分数据 赋值给 phdFile的vBase phd.setVBase(phd.getBaseCtrls().getBaseline()); } } catch (IOException e) { @@ -394,32 +403,52 @@ public class GammaFileUtil { } public List ReadLcScacInfo(List readLines) { + //声明一个结果集合 List vData = new LinkedList<>(); + //遍历行数据 for (int i=0; i< readLines.size(); i++){ + //读取当前行数据 String line = readLines.get(i); + //判断当前行是否包含# 如果包含则进入 if (line.contains("#")){ + //声明下一行的下标 int j=i+1; + //读取当前行的下一行的数据 line = readLines.get(j); + //将下一行的数据赋给一个 新的行数据 String line1 = line; + //遍历判断 下标不是行数据的最后一行 且 行数据不为空 while (j != readLines.size()-1 && StringUtils.isNotBlank(line) ){ + //行下标+1 j++; + //读取下一行数据 line = readLines.get(j); + //判断下一行数据是否包含# if (!line.contains("#")){ + //不包含#则将当前行数据 拼接到 行数据 line1 += StringPool.SPACE + line; - }else { + }else {//否则结束循环 break; } } + //所有行数据 去掉首位空位符 line1 = line1.trim(); + //行数据根据任意形式空格切割成数组 List strList = Arrays.asList(line1.split("\\s+")); + //如果数据量小于2 跳过本次循环 继续下一行读取 if(strList.size() < 2){ continue; } + //遍历行数据数组 for(int k=1; k> map = new HashMap<>(); + //判断当前行数据是否为空 while (null != (line = reader.readLine())) { + //如果当前行包含# if (line.contains("#")) { + //将当前行数据去掉前后空字符并赋值给标题名称对象 block_name = line.trim(); + //向map中加入当前标题名称 初始化集合信息 map.put(block_name, new LinkedList<>()); continue; } + //根据当前标题名称读取集合数据 List data = map.get(block_name); + //对当前行数据使用任意空格符切割数据 String[] split = line.split("\\s+"); + //遍历数组 for(String str : split) { + //如果当前当前数据不为空 且 数据不匹配任意大小写的nan if (StringUtils.isNotBlank(str) && !str.equalsIgnoreCase("nan")){ + //当前数据转为double 并 存入到集合中 double d = Double.parseDouble(str); data.add(d); } else if (StringUtils.isNotBlank(str) && str.equalsIgnoreCase("nan")) { + //如果当前数据不为空 但 数据匹配任意大小写的nan + //将0.0填充到 double中 data.add(0.0); } } } + //判断map是否含有#AnalyseRange if(map.containsKey("#AnalyseRange")) { + //根据#AnalyseRange获取对应的集合信息 List vTemp = map.get("#AnalyseRange"); + //如果集合大小等于2 if(vTemp.size() == 2) { + //集合中第一个赋值给 phdFile的baseCtrls的rg_low phd.getBaseCtrls().setRg_low(vTemp.get(0).intValue()); + //集合中第二个赋值给 phdFile的baseCtrls的rg_high phd.getBaseCtrls().setRg_high(vTemp.get(1).intValue()); } } + //判断map是否含有#XCtrl if(map.containsKey("#XCtrl")) { + //根据#XCtrl获取对应的集合信息 List vTemp = map.get("#XCtrl"); + //将集合数据 赋值给 phdFile的BaseCtrls的xCtrl phd.getBaseCtrls().setXCtrl(vTemp); } + //判断map是否含有#YCtrl if(map.containsKey("#YCtrl")) { + //根据#YCtrl获取集合信息 List vTemp = map.get("#YCtrl"); + //将集合信息赋值给 phdFile的BaseCtrls的yCtrl phd.getBaseCtrls().setYCtrl(vTemp); } + //判断map是否含有#YSlope if(map.containsKey("#YSlope")) { + //根据#YSlope获取集合信息 List vTemp = map.get("#YSlope"); + //将集合信息赋值给 phdFile的BaseCtrls的ySlope phd.getBaseCtrls().setYSlope(vTemp); } + //判断map是否含有#Baseline if(map.containsKey("#Baseline")) { + //根据#Baseline获取集合数据 List vTemp = map.get("#Baseline"); + //截取集合 下标1到末尾的数据 List list = vTemp.subList(1, vTemp.size()); + //将截取后的数据 赋值给 phdFile的BaseCtrls的Baseline phd.getBaseCtrls().setBaseline(list); } + //判断map是否含有#StepCounts if(map.containsKey("#StepCounts")) { + //根据#StepCounts获取集合数据 List vTemp = map.get("#StepCounts"); + //截取集合 下标1到末尾的数据 List list = vTemp.subList(1, vTemp.size()); + //将截取后的数据 赋值给 phdFile的BaseCtrls phd.getBaseCtrls().setStepCounts(list); } } catch (IOException e) { @@ -783,26 +849,40 @@ public class GammaFileUtil { public List Qcstate(PHDFile phd) { // Collection Time、 Acq Time、 Decay Time、 SampVol、 Be7-FWHM、 Ba140-MDC、 Xe133-MDC List qcState = new LinkedList<>(); + //初始化七个状态颜色为 灰色 for (int i=0;i<7; i++){ qcState.add("GRAY"); } + //判断 phdFile下QcItems大小是否小于等于5 if(phd.getQcItems().size() <= 5) { - this.RunQC(phd); + //执行判断QC状态方法 + RunQC(phd); } + //判断 QcItems的col_time的BPass状态 如果是true 则颜色赋值为BLUE 如果是false 则颜色赋值为 RED qcState.set(0, phd.getQcItems().get("col_time").isBPass()?"BLUE":"RED"); + //判断 QcItems的acq_time的BPass状态 如果是true 则颜色赋值为BLUE 如果是false 则颜色赋值为 RED qcState.set(1, phd.getQcItems().get("acq_time").isBPass()?"BLUE":"RED"); + //判断 QcItems的decay_time的BPass状态 如果是true 则颜色赋值为BLUE 如果是false 则颜色赋值为 RED qcState.set(2, phd.getQcItems().get("decay_time").isBPass()?"BLUE":"RED"); + //判断 QcItems的samp_vol的BPass状态 如果是true 则颜色赋值为BLUE 如果是false 则颜色赋值为 RED qcState.set(3, phd.getQcItems().get("samp_vol").isBPass()?"BLUE":"RED"); - + //判断当前文件系统类型是否匹配 P if(phd.getHeader().getSystem_type().equalsIgnoreCase("P")) { + //如果匹配P 判断 QcItems的Be7-FWHM数据是否为空 if(Objects.nonNull(phd.getQcItems().get("Be7-FWHM"))) { + //不为空 判断 QcItems的Be7-FWHM的BPass状态 如果是true 则颜色赋值为BLUE 如果是false则颜色赋值为RED qcState.set(4, phd.getQcItems().get("Be7-FWHM").isBPass()?"BLUE":"RED"); } + //如果匹配P 判断 QcItems的Ba140-MDC数据是否为空 if(Objects.nonNull(phd.getQcItems().get("Ba140-MDC"))) { + //不为空 判断 QcItems的Ba140-MDC的BPass状态 如果是true 则颜色赋值为BLUE 如果是false则颜色赋值为RED qcState.set(5, phd.getQcItems().get("Ba140-MDC").isBPass()?"BLUE":"RED"); } } else if(phd.getHeader().getSystem_type().equalsIgnoreCase("G")) { + //判断当前文件系统类型是否匹配 G + //如果匹配G 判断 QcItems的Xe133-MDC数据是否为空 if(Objects.nonNull(phd.getQcItems().get("Xe133-MDC"))) { + //不为空 判断 QcItems的Xe133-MDC的BPass状态 如果是true 则颜色赋值为BLUE 如果是false则颜色赋值为RED qcState.set(6, phd.getQcItems().get("Xe133-MDC").isBPass()?"BLUE":"RED"); } } @@ -810,64 +890,99 @@ public class GammaFileUtil { } public void RunQC(PHDFile phd) { + //调用dll库 System.loadLibrary("GammaAnaly"); try { + //获取phdFile的 采集开始时间 Date start = DateUtils.parseDate(phd.getCollect().getCollection_start_date() + StringPool.SPACE + phd.getCollect().getCollection_start_time()); + //获取phdFile的 采集结束时间 Date end = DateUtils.parseDate(phd.getCollect().getCollection_stop_date() + StringPool.SPACE + phd.getCollect().getCollection_stop_time()); + //获取phdFile的 分析开始时间 Date acq = DateUtils.parseDate(phd.getAcq().getAcquisition_start_date() + StringPool.SPACE + phd.getAcq().getAcquisition_start_time()); - + //计算得到采集耗时 double collect_hour = (end.getTime()/1000 - start.getTime()/1000) / 3600.0; + //获取 实际分析时长 double acq_hour = phd.getAcq().getAcquisition_real_time() / 3600.0; + //计算得到衰减耗时 double Decay_hour = (acq.getTime()/1000 - end.getTime()/1000) / 3600.0; - + //声明一个double数据 Double ener_Be7 = 0.0; + //声明一个map用于存储计算数据 Map vMdcInfoMap = new HashMap<>(); + //声明一个数组存储计算数据 List vMdcInfo = new LinkedList<>(); + //声明一个数组存储QcItems数据 Map qcItems = new LinkedHashMap<>(); - if(!this.ReadQCLimit(qcItems, vMdcInfoMap, ener_Be7, phd.getHeader().getSystem_type().toUpperCase())) { + //调用方法 读取文件信息 判断QC数据 + if(!ReadQCLimit(qcItems, vMdcInfoMap, ener_Be7, phd.getHeader().getSystem_type().toUpperCase())) { String WARNING = "Read QC Flags from SystemManager.xml Failed!"; } + //判断map是否为空 if (CollectionUtils.isNotEmpty(vMdcInfoMap)) { + //根据键值按顺序向数组中插入数据 vMdcInfo.add(vMdcInfoMap.get("0")); vMdcInfo.add(vMdcInfoMap.get("1")); vMdcInfo.add(vMdcInfoMap.get("2")); } - + //获取QcItem中col_time数据 QcCheckItem colTime = qcItems.get("col_time"); + //将采集耗时 赋值给 colTime colTime.setValue(collect_hour); + //将数据存入QcItems的map中 qcItems.put("col_time", colTime); - + //获取QcItem中acq_time数据 QcCheckItem acqTime = qcItems.get("acq_time"); + //将实际分析时长 赋值给 acqTime acqTime.setValue(acq_hour); + //将数据存入QcItems的map中 qcItems.put("acq_time", acqTime); - + //获取QcItem中decay_time数据 QcCheckItem decayTime = qcItems.get("decay_time"); + //将衰减耗时 赋值给 decayTime decayTime.setValue(Decay_hour); + //将数据存入QcItems的map中 qcItems.put("decay_time", decayTime); - + //获取QcItem中samp_vol数据 QcCheckItem sampVol = qcItems.get("samp_vol"); + //将phdFile的Collect的air_volume赋值给 sampVol.setValue(phd.getCollect().getAir_volume()); + //将数据存入QcItems的map中 qcItems.put("samp_vol", sampVol); - + //获取QcItem中decay_time数据 QcCheckItem airFlow = qcItems.get("airFlow"); airFlow.setValue(phd.getCollect().getAir_volume() / collect_hour); + //将数据存入QcItems的map中 qcItems.put("airFlow", airFlow); - + //判断phdFile的valid参数是否为true phdFile的vBase集合大小是否等于phdFile的Spec的num_g_channel数据 if(phd.isValid() && phd.getVBase().size() == phd.getSpec().getNum_g_channel()) { + //判断system_type是否匹配P if(phd.getHeader().getSystem_type().equalsIgnoreCase("P")) { + //声明一个energy集合 List energy = new LinkedList<>(); + //集合增加数据 energy.add(ener_Be7); + //调用算法计算 CalValuesOut calValuesOut = CalValuesHandler.calFcnEval(energy, phd.getUsedResoPara().getP()); + //获取计算结果的counts赋值给 fwhm集合 List fwhm = calValuesOut.counts; + //获取QcItems中Be7-FWHM数据 QcCheckItem be7 = qcItems.get("Be7-FWHM"); + //将计算结果的第一个数据赋值给 be7 be7.setValue(fwhm.get(0)); + //将数据存入QcItems的map中 qcItems.put("Be7-FWHM", be7); + //获取QcItems中Ba140-MDC数据 QcCheckItem Ba140 = qcItems.get("Ba140-MDC"); + //调用CalculateMDC得到Ba140的数据 Ba140.setValue(CalculateMDC(phd, vMdcInfo, 1.0)); + //将数据存入QcItems的map中 qcItems.put("Ba140-MDC", Ba140); } else { + //获取QcItems中Xe133-MDC数据 QcCheckItem Xe133 = qcItems.get("Xe133-MDC"); + //调用CalculateMDC得到Xe133的数据 Xe133.setValue(CalculateMDC(phd, vMdcInfo, 1.0)); + //将数据存入QcItems的map中 qcItems.put("Xe133-MDC", Xe133); } } @@ -1191,8 +1306,8 @@ public class GammaFileUtil { if(m_nSChan == 0) { m_vCount.add(0L); } - ChartData shadowEnergyChart = this.Energy_Count(phd, m_vCount, m_nCount, colorMap.get("Color_Spec")); - ChartData shadowChannelChart = this.Channel_Count(m_vCount, m_nCount, colorMap.get("Color_Spec")); + ChartData shadowEnergyChart = Energy_Count(phd, m_vCount, m_nCount, colorMap.get("Color_Spec")); + ChartData shadowChannelChart = Channel_Count(m_vCount, m_nCount, colorMap.get("Color_Spec")); map.put("shadowEnergyChart", shadowEnergyChart); map.put("shadowChannelChart", shadowChannelChart); List allData = AllData(false, phd, m_vCount, m_nCount, colorMap); @@ -1502,12 +1617,135 @@ public class GammaFileUtil { String phdStr = mapper.writeValueAsString(phd); String nuclideLinesMap = mapper.writeValueAsString(mapLines); String strValue = CalValuesHandler.analyseSpectrum(phdStr, nuclideLinesMap, tmpFile.getAbsolutePath()); - PHDFile phdFile = JSON.parseObject(strValue, PHDFile.class); - phd.setVLc(phdFile.getVLc()); - phd.setVScac(phdFile.getVScac()); - phd.setVBase(phdFile.getVBase()); - phd.setVEnergy(phdFile.getVEnergy()); - phd.setVPeak(phdFile.getVPeak()); + Map parseMap = JSON.parseObject(strValue, Map.class); + for (Map.Entry entry:parseMap.entrySet()) { + if (entry.getKey().equalsIgnoreCase("bAnalyed")) { + boolean value = (boolean) entry.getValue(); + phd.setBAnalyed(value); + } + if (entry.getKey().equalsIgnoreCase("mapEnerPara")) { + Map value = (Map) entry.getValue(); + phd.setMapEnerPara(value); + } + if (entry.getKey().equalsIgnoreCase("mapResoPara")) { + Map value = (Map) entry.getValue(); + phd.setMapResoPara(value); + } + if (entry.getKey().equalsIgnoreCase("mapEffiPara")) { + Map value = (Map) entry.getValue(); + phd.setMapEffiPara(value); + } + if (entry.getKey().equalsIgnoreCase("mapTotEPara")) { + Map value = (Map) entry.getValue(); + 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 = (String) entry.getValue(); + phd.setNewEner(value); + } + if (entry.getKey().equalsIgnoreCase("mapEnerKD")) { + Map value = (Map) entry.getValue(); + phd.setMapEnerKD(value); + } + if (entry.getKey().equalsIgnoreCase("mapResoKD")) { + Map value = (Map) entry.getValue(); + phd.setMapResoKD(value); + } + if (entry.getKey().equalsIgnoreCase("vEnergy")) { + List value = (List) entry.getValue(); + phd.setVEnergy(value); + } + if (entry.getKey().equalsIgnoreCase("vBase")) { + List value = (List) entry.getValue(); + phd.setVBase(value); + } + if (entry.getKey().equalsIgnoreCase("vLc")) { + List value = (List) entry.getValue(); + phd.setVLc(value); + } + if (entry.getKey().equalsIgnoreCase("vScac")) { + List value = (List) entry.getValue(); + phd.setVScac(value); + } + if (entry.getKey().equalsIgnoreCase("vPeak")) { + List value = (List) entry.getValue(); + 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 = (String) entry.getValue(); + 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 = (String) entry.getValue(); + 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 = (String) entry.getValue(); + 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 = (String) entry.getValue(); + 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 (StringUtils.isBlank(peak.recoilBetaChan)) { peak.recoilBetaChan = "1"; @@ -1545,7 +1783,9 @@ public class GammaFileUtil { List old_ener = phd.getUsedEnerPara().getP(); List new_ener = phd.getMapEnerPara().get(phd.getNewEner()).getP(); - if(old_ener.size() != new_ener.size()) return 1; + if(old_ener.size() != new_ener.size()) { + return 1; + } for(int i=0; i 1E-6){ return 1; @@ -1554,7 +1794,9 @@ public class GammaFileUtil { List old_reso = phd.getUsedResoPara().getP(); List new_reso = phd.getMapResoPara().get(phd.getNewReso()).getP(); - if(old_reso.size() != new_reso.size()) return 1; + if(old_reso.size() != new_reso.size()) { + return 1; + } for(int i=0; i 1E-6){ return 1; @@ -1563,7 +1805,9 @@ public class GammaFileUtil { List old_effi = phd.getUsedEffiPara().getP(); List new_effi = phd.getMapEffiPara().get(phd.getNewEffi()).getP(); - if(old_effi.size() != new_effi.size()) return -1; + if(old_effi.size() != new_effi.size()) { + return -1; + } for(int i=0; i 1E-6){ return -1; @@ -2384,11 +2628,11 @@ public class GammaFileUtil { public String GetReportContent(PHDFile phd, boolean bLog) { GStoreMiddleProcessData middleData = new GStoreMiddleProcessData(); - this.GetInterMiddlData(phd, "", middleData); + GetInterMiddlData(phd, "", middleData); if(bLog) { - return this.GetLogContent(middleData); + return GetLogContent(middleData); } else { - return this.GetReportContent(middleData); + return GetReportContent(middleData); } } 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 82b23b0d..c7086096 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 @@ -53,6 +53,11 @@ public class GammaController { redisTemplate.convertAndSend(GlobalConstants.REDIS_TOPIC_NAME, params);; } + @GetMapping("testFun") + public Result testFun(String fileName,HttpServletRequest request){ + return gammaService.testFun(fileName, request); + } + @GetMapping("gammaByDB") public Result gammaByDB(Integer sampleId, String dbName, HttpServletRequest request){ return gammaService.gammaByDB(dbName, sampleId, request); @@ -243,6 +248,12 @@ public class GammaController { return gammaService.callDataEnergy(file, sampleFileName, width, currentText); } + @PutMapping("setCurrentEnergy") + @ApiOperation(value = "Energy Calibration页面set to current按钮", notes = "Energy Calibration页面set to current按钮") + public Result setCurrentEnergy(String fileName, String currentName) { + return gammaService.setCurrentEnergy(fileName, currentName); + } + @GetMapping("resolutionCalibration") @ApiOperation(value = "查看Resolution Calibration数据", notes = "查看Resolution Calibration数据") public Result resolutionCalibration(Integer sampleId, String fileName, String currentText, Double width) { @@ -273,6 +284,12 @@ public class GammaController { return gammaService.callDataResolution(file, sampleFileName, width, currentText); } + @PutMapping("setCurrentResolution") + @ApiOperation(value = "Resolution Calibration页面set to current按钮", notes = "Resolution Calibration页面set to current按钮") + public Result setCurrentResolution(String fileName, String currentName) { + return gammaService.setCurrentResolution(fileName, currentName); + } + @GetMapping("EfficiencyCalibration") @ApiOperation(value = "查看Efficiency Calibration数据", notes = "查看Efficiency Calibration数据") public Result EfficiencyCalibration(Integer sampleId, String fileName, String currentText, Double width) { @@ -303,6 +320,12 @@ public class GammaController { return gammaService.callDataEfficiency(file, sampleFileName, width, currentText); } + @PutMapping("setCurrentEfficiency") + @ApiOperation(value = "Efficiency Calibration页面set to current按钮", notes = "Efficiency Calibration页面set to current按钮") + public Result setCurrentEfficiency(String fileName, String currentName) { + return gammaService.setCurrentEfficiency(fileName, currentName); + } + @GetMapping("NuclideLibrary") @ApiOperation(value = "查看Nuclide Library页面数据", notes = "查看Nuclide Library页面数据") public Result NuclideLibrary(Integer sampleId, String fileName, String editEnergy, double err, String libraryName, String nuclideName, HttpServletRequest request) { 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 be498b4b..89058d3a 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 @@ -14,6 +14,8 @@ public interface IGammaService{ Result initValue(Integer sampleId, String dbName, HttpServletRequest request); + Result testFun(String fileName, HttpServletRequest request); + Result gammaByDB(String dbName, Integer sampleId, HttpServletRequest request); Result gammaByFile(String fileName, HttpServletRequest request); @@ -80,6 +82,8 @@ public interface IGammaService{ Result callDataEnergy(MultipartFile file, String sampleFileName, Double width, String currentText); + Result setCurrentEnergy(String fileName, String currentName); + Result resolutionCalibration(Integer sampleId, String fileName, String currentText, Double width); Result changeDataResolution(List m_vCurReso, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer sampleId, String fileName, Double width); @@ -90,6 +94,8 @@ public interface IGammaService{ Result callDataResolution(MultipartFile file, String sampleFileName, Double width, String currentText); + Result setCurrentResolution(String fileName, String currentName); + Result EfficiencyCalibration(Integer sampleId, String fileName, String currentText, Double width); Result changeDataEfficiency(List m_vCurEffi, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer funcId, Integer sampleId, String fileName, Double width); @@ -100,6 +106,8 @@ public interface IGammaService{ Result callDataEfficiency(MultipartFile file, String sampleFileName, Double width, String currentText); + Result setCurrentEfficiency(String fileName, String currentName); + Result NuclideLibrary(Integer sampleId, String fileName, String editEnergy, double err, String libraryName, String nuclideName, HttpServletRequest request); Result configUserLibrary(Integer sampleId, String fileName, HttpServletRequest request); diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java index 21cf147e..2f6cb178 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 @@ -153,12 +153,189 @@ public class GammaServiceImpl implements IGammaService { return result; } + @Override + public Result testFun(String fileName, HttpServletRequest request) { + Result result = new Result(); + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(fileName); + phd.setUserId("1"); + phd.setXmlFilePath(parameterFilePath); + if (Objects.isNull(phd)){ + result.error500("请先选择解析文件!"); + return result; + } + String userName = JwtUtil.getUserNameByToken(request); + //查询当前用户关联的核素信息 + List nuclides = new LinkedList<>(); + //从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的 + nuclides = defaultNuclideSpectrumService.findNuclidesByUserName(userName, phd.getHeader().getSystem_type().toUpperCase()); + if (CollectionUtils.isEmpty(nuclides)){ + nuclides = defaultNuclideSpectrumService.findNuclidesByUserName("admin", phd.getHeader().getSystem_type().toUpperCase()); + } + Map nuclideLinesMap = gammaFileUtil.GetNuclideLines(nuclides); + //解析获取临时文件信息 + + File tmpFile = gammaFileUtil.analyzeFile(StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName, fileName); + ObjectMapper mapper = new ObjectMapper(); + try { + String phdStr = mapper.writeValueAsString(phd); + String mapLines = mapper.writeValueAsString(nuclideLinesMap); + String strValue = CalValuesHandler.analyseSpectrum(phdStr, mapLines, tmpFile.getAbsolutePath()); + Map parseMap = JSON.parseObject(strValue, Map.class); + for (Map.Entry entry:parseMap.entrySet()) { + if (entry.getKey().equalsIgnoreCase("bAnalyed")) { + boolean value = (boolean) entry.getValue(); + phd.setBAnalyed(value); + } + if (entry.getKey().equalsIgnoreCase("mapEnerPara")) { + Map value = (Map) entry.getValue(); + phd.setMapEnerPara(value); + } + if (entry.getKey().equalsIgnoreCase("mapResoPara")) { + Map value = (Map) entry.getValue(); + phd.setMapResoPara(value); + } + if (entry.getKey().equalsIgnoreCase("mapEffiPara")) { + Map value = (Map) entry.getValue(); + phd.setMapEffiPara(value); + } + if (entry.getKey().equalsIgnoreCase("mapTotEPara")) { + Map value = (Map) entry.getValue(); + 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 = (String) entry.getValue(); + phd.setNewEner(value); + } + if (entry.getKey().equalsIgnoreCase("mapEnerKD")) { + Map value = (Map) entry.getValue(); + phd.setMapEnerKD(value); + } + if (entry.getKey().equalsIgnoreCase("mapResoKD")) { + Map value = (Map) entry.getValue(); + phd.setMapResoKD(value); + } + if (entry.getKey().equalsIgnoreCase("vEnergy")) { + List value = (List) entry.getValue(); + phd.setVEnergy(value); + } + if (entry.getKey().equalsIgnoreCase("vBase")) { + List value = (List) entry.getValue(); + phd.setVBase(value); + } + if (entry.getKey().equalsIgnoreCase("vLc")) { + List value = (List) entry.getValue(); + phd.setVLc(value); + } + if (entry.getKey().equalsIgnoreCase("vScac")) { + List value = (List) entry.getValue(); + phd.setVScac(value); + } + if (entry.getKey().equalsIgnoreCase("vPeak")) { + List value = (List) entry.getValue(); + 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 = (String) entry.getValue(); + 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 = (String) entry.getValue(); + 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 = (String) entry.getValue(); + 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 = (String) entry.getValue(); + 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 (StringUtils.isBlank(peak.recoilBetaChan)) { + peak.recoilBetaChan = "1"; + } + if (StringUtils.isBlank(peak.recoilDeltaChan)) { + peak.recoilDeltaChan = "1"; + } + } + result.setResult(phd); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + result.setSuccess(true); + return result; + } + @Override public Result gammaByDB(String dbName, Integer sampleId, HttpServletRequest request) { Result result = new Result(); + //通过token获取用户名 String userName = JwtUtil.getUserNameByToken(request); + //声明一个接收最后返回结果的map Map map = new HashMap<>(); + //加载本地缓存信息 Cache phdCache = localCache.getPHDCache(); + //声明phd实体类 PHDFile phd = new PHDFile(); //读取文件内容 //根据sampleId获取sample文件路径 @@ -167,16 +344,21 @@ public class GammaServiceImpl implements IGammaService { 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); + //调用加载文件的方法 传入文件路径,文件名称,全局变量phd,响应结果result boolean flag = gammaFileUtil.loadFile(pathName, fileName, phd, result); + //如果文件加载失败 返回失败原因 if (!flag){ return result; } - //声明基础数组信息 + //加载phd数据所需的lc,scac,baseline数据 gammaFileUtil.SetBaseInfo(phd); - //从数据库中读取相关信息 + //从数据库中读取phd其他相关信息 boolean bRet = gammaFileUtil.getResultFromDB(dbName, userName, sampleId, phd, result); + //判断数据库信息是否读取正常 if (!bRet){ return result; } @@ -194,7 +376,9 @@ public class GammaServiceImpl implements IGammaService { map.put("live_time", String.format("%.2f", phd.getAcq().getAcquisition_live_time())); double deadTime = (phd.getAcq().getAcquisition_real_time() - phd.getAcq().getAcquisition_live_time()) / phd.getAcq().getAcquisition_real_time(); map.put("dead_time", String.format("%.2f", deadTime*100)); + // 更新页面折线图信息 gammaFileUtil.UpdateChart(phd, map, colorMap); + //将当前加载的phd信息加入到缓存中 文件名称作为缓存信息的key phdCache.put(fileName, phd); localCache.setPHDCache(phdCache); result.setSuccess(true); @@ -352,8 +536,6 @@ public class GammaServiceImpl implements IGammaService { phdSetting.setRiskLevelK(configureData.getRiskLevelK()); phdSetting.setRefTime_act(configureData.getRefTime_act()); phdSetting.setRefTime_conc(configureData.getRefTime_conc()); - phdCache.put(fileName, phd); - localCache.setPHDCache(phdCache); result.success("保存成功"); return result; } @@ -406,8 +588,6 @@ public class GammaServiceImpl implements IGammaService { result.setSuccess(true); result.setResult(map); } - phdCache.put(fileName, phd); - localCache.setPHDCache(phdCache); return result; } @@ -1486,6 +1666,24 @@ public class GammaServiceImpl implements IGammaService { return result; } + @Override + public Result setCurrentEnergy(String fileName, String currentName) { + Result result = new Result(); + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(fileName); + if (Objects.isNull(phd)){ + result.error500("请先选择解析文件!"); + return result; + } + if (StringUtils.isNotBlank(currentName)) { + phd.setNewEner(currentName); + } + phdCache.put(fileName, phd); + localCache.setPHDCache(phdCache); + result.success("修改成功"); + return result; + } + @Override public Result resolutionCalibration(Integer sampleId, String fileName, String currentText, Double width) { Result result = new Result(); @@ -1720,6 +1918,24 @@ public class GammaServiceImpl implements IGammaService { return result; } + @Override + public Result setCurrentResolution(String fileName, String currentName) { + Result result = new Result(); + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(fileName); + if (Objects.isNull(phd)){ + result.error500("请先选择解析文件!"); + return result; + } + if (StringUtils.isNotBlank(currentName)) { + phd.setNewReso(currentName); + } + phdCache.put(fileName, phd); + localCache.setPHDCache(phdCache); + result.success("修改成功"); + return result; + } + @Override public Result EfficiencyCalibration(Integer sampleId, String fileName, String currentText, Double width) { Result result = new Result(); @@ -1976,6 +2192,24 @@ public class GammaServiceImpl implements IGammaService { return result; } + @Override + public Result setCurrentEfficiency(String fileName, String currentName) { + Result result = new Result(); + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(fileName); + if (Objects.isNull(phd)){ + result.error500("请先选择解析文件!"); + return result; + } + if (StringUtils.isNotBlank(currentName)) { + phd.setNewEffi(currentName); + } + phdCache.put(fileName, phd); + localCache.setPHDCache(phdCache); + result.success("修改成功"); + return result; + } + @Override public Result NuclideLibrary(Integer sampleId, String fileName, String editEnergy, double err, String libraryName, String nuclideName, HttpServletRequest request) { Result result = new Result();