diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/SpectrumPathProperties.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/SpectrumPathProperties.java index d2e6d78d..04e15e75 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/SpectrumPathProperties.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/SpectrumPathProperties.java @@ -26,6 +26,11 @@ public class SpectrumPathProperties implements Serializable { */ private String rootPath; + /** + * 日志文件存储路径 + */ + private String logPath; + /** * 能谱文件存储路径以能谱系统类型/能谱类型为key,以存储路径为value */ diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/configuration/GardsNuclLinesLib.java b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/configuration/GardsNuclLinesLib.java new file mode 100644 index 00000000..ec730402 --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/modules/base/entity/configuration/GardsNuclLinesLib.java @@ -0,0 +1,44 @@ +package org.jeecg.modules.base.entity.configuration; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.io.Serializable; +import java.util.Date; + +@Data +@TableName(value = "CONFIGURATION.GARDS_NUCL_LINES_LIB") +public class GardsNuclLinesLib implements Serializable { + @TableField(value = "NAME") + private String name; + + @TableField(value = "ENERGY") + private Integer energy; + + @TableField(value = "ENERGY_UNCERT") + private Integer energyUncert; + + @TableField(value = "YIELD") + private Integer yield; + + @TableField(value = "YIELD_UNCERT") + private Integer yieldUncert; + + @TableField(value = "KEY_FLAG") + private Integer keyFlag; + + @TableField(value = "NUCLIDE_ID") + private Integer nuclideId; + + @TableField(value = "FULLNAME") + private String fullName; + + @TableField(value = "MODDATE") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date MODDATE; + +} diff --git a/jeecg-module-spectrum-analysis/pom.xml b/jeecg-module-spectrum-analysis/pom.xml index 2803eafa..77a9993c 100644 --- a/jeecg-module-spectrum-analysis/pom.xml +++ b/jeecg-module-spectrum-analysis/pom.xml @@ -29,6 +29,12 @@ ejml-simple 0.39 + + + com.google.guava + guava + 23.0 + \ No newline at end of file diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/cache/LocalCache.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/cache/LocalCache.java new file mode 100644 index 00000000..fe49f1a7 --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/cache/LocalCache.java @@ -0,0 +1,33 @@ +package org.jeecg.common.cache; + +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import org.jeecg.modules.entity.vo.PHDFile; +import org.springframework.stereotype.Component; + +import java.util.concurrent.TimeUnit; + +@Component +public class LocalCache { + private Cache phdCache = CacheBuilder.newBuilder() + //设置缓存初始大小,应该合理设置,后续会扩容 + .initialCapacity(10) + //最大值 + .maximumSize(100) + //并发数设置 + .concurrencyLevel(5) + //缓存过期时间,写入后5秒钟过期 + .expireAfterWrite(5, TimeUnit.HOURS) + //统计缓存命中率 + .recordStats() + .build(); + + public Cache getPHDCache() { + return phdCache; + } + + public void setPHDCache(Cache phdCache) { + this.phdCache = phdCache; + } + +} 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 a9f8454f..2c910c91 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 @@ -9,6 +9,8 @@ import org.apache.commons.net.ftp.FTPFile; import org.ejml.simple.SimpleMatrix; import org.jeecg.common.api.vo.Result; import org.jeecg.common.properties.SpectrumPathProperties; +import org.jeecg.modules.base.entity.configuration.GardsNuclLib; +import org.jeecg.modules.base.entity.configuration.GardsNuclLinesLib; import org.jeecg.modules.base.entity.rnman.GardsAnalySetting; import org.jeecg.modules.entity.*; import org.jeecg.modules.entity.vo.*; @@ -27,13 +29,16 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.text.DecimalFormat; +import java.text.NumberFormat; import java.text.ParseException; import java.util.*; import java.util.stream.Collectors; +import static sun.misc.DoubleConsts.NaN; + @Component public class GammaFileUtil { @@ -74,7 +79,7 @@ public class GammaFileUtil { ftpClient.changeWorkingDirectory(pathName); List ftpFiles = Arrays.asList(ftpClient.listFiles()); ftpFiles = ftpFiles.stream().filter(item-> item.getName().equals(fileName)).collect(Collectors.toList()); - if (CollectionUtils.isEmpty(ftpFiles)){ + if (ftpFiles.size() == 0){ result.error500("ftp获取文件数据失败"); } FTPFile ftpFile = ftpFiles.get(0); @@ -260,6 +265,214 @@ public class GammaFileUtil { } } + public void SetBaseInfo(PHDFile phd, Integer sampleId){ + //根据sampleId获取sample文件路径 + String sampleFilePath = spectrumAnalysisMapper.getSampleFilePath(sampleId); + String pathName = sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH)); + String fileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH)+1); + //文件名称需要加上自动处理的前缀以及修改不同的文件后缀名 + String subFileName = fileName.substring(0, fileName.lastIndexOf(StringPool.DOT)); + try { + pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + pathName; + if(StringUtils.isNotBlank(subFileName)){ + //连接ftp + FTPClient ftpClient = ftpUtil.LoginFTP(); + if (Objects.isNull(ftpClient)){ + String warning = "ftp连接失败"; + } + //切换被动模式 + ftpClient.enterLocalPassiveMode(); + ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); + // 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项 + ftpClient.setControlEncoding("UTF-8"); + ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); + ftpClient.changeWorkingDirectory(pathName); + List ftpFiles = Arrays.asList(ftpClient.listFiles()); + String lcFileName = "RNAUTO_"+subFileName + ".lc"; + List lcFiles = ftpFiles.stream().filter(item -> item.getName().equals(lcFileName)).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(lcFiles)){ + FTPFile lcFile = lcFiles.get(0); + if (Objects.nonNull(lcFile)){ + InputStream inputStream = ftpClient.retrieveFileStream(lcFile.getName()); + //声明一个临时文件 + File file = File.createTempFile("tmp", null); + //将ftp文件的输入流复制给临时文件 + FileUtils.copyInputStreamToFile(inputStream, file); + List readLines = FileUtils.readLines(file, "UTF-8"); + List vData = ReadLcScacInfo(readLines); + phd.setVLc(vData); + } + } + try { + ftpClient.disconnect(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + if(StringUtils.isNotBlank(subFileName)){ + //连接ftp + FTPClient ftpClient = ftpUtil.LoginFTP(); + if (Objects.isNull(ftpClient)){ + String warning = "ftp连接失败"; + } + //切换被动模式 + ftpClient.enterLocalPassiveMode(); + ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); + // 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项 + ftpClient.setControlEncoding("UTF-8"); + ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); + ftpClient.changeWorkingDirectory(pathName); + List ftpFiles = Arrays.asList(ftpClient.listFiles()); + String scacFileName = "RNAUTO_"+subFileName + ".scac"; + List scacFiles = ftpFiles.stream().filter(item -> item.getName().equals(scacFileName)).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(scacFiles)){ + FTPFile scacFile = scacFiles.get(0); + if (Objects.nonNull(scacFile)){ + InputStream inputStream = ftpClient.retrieveFileStream(scacFile.getName()); + //声明一个临时文件 + File file = File.createTempFile("tmp", null); + //将ftp文件的输入流复制给临时文件 + FileUtils.copyInputStreamToFile(inputStream, file); + List readLines = FileUtils.readLines(file, "UTF-8"); + List vData = ReadLcScacInfo(readLines); + phd.setVScac(vData); + } + } + try { + ftpClient.disconnect(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + if(StringUtils.isNotBlank(subFileName)){ + //连接ftp + FTPClient ftpClient = ftpUtil.LoginFTP(); + if (Objects.isNull(ftpClient)){ + String warning = "ftp连接失败"; + } + //切换被动模式 + ftpClient.enterLocalPassiveMode(); + ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); + // 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项 + ftpClient.setControlEncoding("UTF-8"); + ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); + ftpClient.changeWorkingDirectory(pathName); + List ftpFiles = Arrays.asList(ftpClient.listFiles()); + String baselineFileName = "RNAUTO_"+subFileName + ".baseline"; + List baselineFiles = ftpFiles.stream().filter(item -> item.getName().equals(baselineFileName)).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(baselineFiles)){ + FTPFile baselineFile = baselineFiles.get(0); + if (Objects.nonNull(baselineFile)){ + InputStream inputStream = ftpClient.retrieveFileStream(baselineFile.getName()); + //声明一个临时文件 + File file = File.createTempFile("tmp", null); + //将ftp文件的输入流复制给临时文件 + FileUtils.copyInputStreamToFile(inputStream, file); + List readLines = FileUtils.readLines(file, "UTF-8"); + ReadBaseCtrlInfo(phd,readLines); + phd.setVBase(phd.getBaseCtrls().getBaseline()); + } + } + try { + ftpClient.disconnect(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + 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) ){ + j++; + line = readLines.get(j); + if (!line.contains("#")){ + line1 += " " + line; + }else { + break; + } + } + line1 = line1.trim(); + List strList = Arrays.asList(line1.split("\\s+")); + if(strList.size() < 2){ + continue; + } + for(int k=1; k readLines){ + for (int i=0; i< readLines.size(); i++){ + String line = readLines.get(i); + if (line.contains("#")){ + String block_name = line.trim(); + int j=i+1; + line = readLines.get(j); + String block_data = line; + while(j!= readLines.size()-1 && StringUtils.isNotBlank(line)) { + j++; + line = readLines.get(j); + if (!line.contains("#")){ + block_data += " " + line; + }else { + break; + } + } + i=j-1; + block_data = block_data.trim(); + List str_list = Arrays.asList(block_data.split("\\s+")); + if(str_list.size() < 1){ + continue; + } + List vTemp = new LinkedList<>(); + for(String str:str_list) { + if (StringUtils.isNotBlank(str) && !str.equalsIgnoreCase("nan")){ + double d = Double.valueOf(str); + vTemp.add(d); + } else if (StringUtils.isNotBlank(str) && str.equalsIgnoreCase("nan")) { + vTemp.add(0.0); + } + } + if(block_name.contains("#AnalyseRange")) { + if(vTemp.size() == 2) { + phd.getBaseCtrls().setRg_low(vTemp.get(0).intValue()); + phd.getBaseCtrls().setRg_high(vTemp.get(1).intValue()); + } + } else if(block_name.contains("#XCtrl")) { + phd.getBaseCtrls().setXCtrl(vTemp); + } else if(block_name.contains("#YCtrl")) { + phd.getBaseCtrls().setYCtrl(vTemp); + } else if(block_name.contains("#YSlope")) { + phd.getBaseCtrls().setYSlope(vTemp); + } else if(block_name.contains("#Baseline")) { + List list = vTemp.subList(1, vTemp.size()); + phd.getBaseCtrls().setBaseline(list); + } else if(block_name.contains("#StepCounts")) { + List list = vTemp.subList(1, vTemp.size()); + phd.getBaseCtrls().setStepCounts(list); + } + } + } + } + public boolean getResultFromDB(String dbName, Integer sampleId, PHDFile phd, Result result){ //判断连接的数据库 String T_analy, T_calib, T_peaks, T_param, T_nuc_line, T_nuc_act, T_qc, T_setting; @@ -338,7 +551,8 @@ public class GammaFileUtil { peakInfo.upperTail = peaksSpectrum.getUpperTail()==null?0:peaksSpectrum.getUpperTail(); peakInfo.upperTailAlpha = peaksSpectrum.getUpperTailAlpha()==null?0:peaksSpectrum.getUpperTailAlpha(); peakInfo.BWWidthChan = peaksSpectrum.getBwwidthchan()==null?0:peaksSpectrum.getBwwidthchan(); - peakInfo.recoilDeltaChan = peaksSpectrum.getRecoildeltachan()==null?0:peaksSpectrum.getRecoildeltachan(); + peakInfo.recoilBetaChan = "1"; + peakInfo.recoilDeltaChan = peaksSpectrum.getRecoildeltachan()==null?"1":peaksSpectrum.getRecoildeltachan().toString(); peakInfo.comments = peaksSpectrum.getPeakcomments(); phd.getVPeak().add(peakInfo); } @@ -360,22 +574,22 @@ public class GammaFileUtil { phd.setUsedEner(pairsSpectrum.getInput()); gEnergyBlock.getCentroid_channel().add(pairsSpectrum.getXValue()); gEnergyBlock.getG_energy().add(pairsSpectrum.getYValue()); - gEnergyBlock.getUncertainty().add(pairsSpectrum.getUncYValue().isEmpty()? null:Double.valueOf(pairsSpectrum.getUncYValue())); + gEnergyBlock.getUncertainty().add(pairsSpectrum.getUncYValue().isEmpty()? 0:Double.valueOf(pairsSpectrum.getUncYValue())); } else if(calType.equals("Resolution")) { phd.setUsedReso(pairsSpectrum.getInput()); gResolutionBlock.getG_energy().add(pairsSpectrum.getXValue()); gResolutionBlock.getFWHM().add(pairsSpectrum.getYValue()); - gResolutionBlock.getUncertainty().add(pairsSpectrum.getUncYValue().isEmpty()? null: Double.valueOf(pairsSpectrum.getUncYValue())); + gResolutionBlock.getUncertainty().add(pairsSpectrum.getUncYValue().isEmpty()? 0: Double.valueOf(pairsSpectrum.getUncYValue())); } else if(calType.equals("efficiency")) { phd.setUsedEffi(pairsSpectrum.getInput()); gEfficiencyBlock.getG_energy().add(pairsSpectrum.getXValue()); gEfficiencyBlock.getEfficiency().add(pairsSpectrum.getYValue()); - gEfficiencyBlock.getUncertainty().add(pairsSpectrum.getUncYValue().isEmpty()? null: Double.valueOf(pairsSpectrum.getUncYValue())); + gEfficiencyBlock.getUncertainty().add(pairsSpectrum.getUncYValue().isEmpty()? 0: Double.valueOf(pairsSpectrum.getUncYValue())); } else if(calType.equals("TotalEfficiency")) { phd.setUsedTotE(pairsSpectrum.getInput()); totaleffBlock.getG_energy().add(pairsSpectrum.getXValue()); totaleffBlock.getTotal_efficiency().add(pairsSpectrum.getYValue()); - totaleffBlock.getUncertainty().add(pairsSpectrum.getUncYValue().isEmpty()? null: Double.valueOf(pairsSpectrum.getUncYValue())); + totaleffBlock.getUncertainty().add(pairsSpectrum.getUncYValue().isEmpty()? 0: Double.valueOf(pairsSpectrum.getUncYValue())); } } if (phd.getUsedEner().isEmpty()){ @@ -432,7 +646,7 @@ public class GammaFileUtil { String[] list_coeff = calibrationSpectrum.getCoeffString().split(StringPool.COMMA); for (String str:list_coeff) { para.getP().add(Double.valueOf(str)); - para.getPerr().add(null); + para.getPerr().add(NaN); } if(calType.equals("energy")) { phd.setUsedEnerPara(para); @@ -463,7 +677,7 @@ public class GammaFileUtil { phd.getMapNucActMda().get(str_key).setActivity(Double.valueOf(nuclLinesIdedSpectrum.getActivity())); phd.getMapNucActMda().get(str_key).setAct_err(nuclLinesIdedSpectrum.getUncActivity()); phd.getMapNucActMda().get(str_key).setEfficiency(nuclLinesIdedSpectrum.getEffic()); - phd.getMapNucActMda().get(str_key).setEffi_err(nuclLinesIdedSpectrum.getUncEffic()); + phd.getMapNucActMda().get(str_key).setEffi_err(nuclLinesIdedSpectrum.getUnEffic()); phd.getMapNucActMda().get(str_key).setMda(nuclLinesIdedSpectrum.getMda()); phd.getMapNucActMda().get(str_key).setMdc(Double.valueOf(nuclLinesIdedSpectrum.getMdc())); phd.getMapNucActMda().get(str_key).setConcentration(Double.valueOf(nuclLinesIdedSpectrum.getConcentration())); @@ -525,7 +739,7 @@ public class GammaFileUtil { if (Objects.nonNull(analySetting)){ phd.getUsedSetting().setECutAnalysis_Low(analySetting.getEcutanalysisLow()); double t_d = analySetting.getEcutanalysisHigh(); - phd.getUsedSetting().setECutAnalysis_High((t_d <= phd.getUsedSetting().getECutAnalysis_Low() ? null : t_d)); + phd.getUsedSetting().setECutAnalysis_High((t_d <= phd.getUsedSetting().getECutAnalysis_Low() ? 0 : t_d)); phd.getUsedSetting().setEnergyTolerance(analySetting.getEnergytolerance()); phd.getUsedSetting().setCalibrationPSS_high(analySetting.getCalibrationpssHigh()); phd.getUsedSetting().setCalibrationPSS_low(analySetting.getCalibrationpssLow()); @@ -1170,7 +1384,7 @@ public class GammaFileUtil { regChan.add(d); d += 0.25; } - List t_base = new LinkedList<>(vBase.subList(peak.left-1, peak.right)); + List t_base = vBase.subList(peak.left, peak.right + 1); List regPeak = CalValuesHandler.interp1(peak, t_base, regChan); if(bEnergy) { @@ -1634,4 +1848,1693 @@ public class GammaFileUtil { return mapLines; } + public ChartData Channel_BaseLine(PHDFile phd, List m_vCount, long m_nCount) { + ChartData cData = new ChartData(); + int start =0; + long end = 0; + if(m_nCount > 1 && phd.getVBase().size() == m_nCount) { + if(start < 1){ + start = 1; + } + if(end > m_nCount || end < 1){ + end = m_nCount; + } + + for(int i=start-1; i Differance(PHDFile phd, List vecPeak, List m_vCount, long m_nCount){ + System.loadLibrary("GammaAnaly"); + List pointlist = new LinkedList<>(); + int start =0; + long end = 0; + int peakNum = vecPeak.size(); + if(peakNum < 1 || phd.getVBase().size() != m_nCount){ + return pointlist; + } + + if(start < 1){ + start = 1; + } + if(end > m_nCount || end < 1){ + end = m_nCount; + } + + // 找出在所给范围的第一道拟合峰和最后一道拟合峰的索引下标 + int index = 0; + int startPeak = -1; + int endPeak = peakNum-1; + while(index < peakNum && start > vecPeak.get(index).right){ + ++index; + } + if(index < peakNum) { + startPeak = index; + while(index < peakNum && vecPeak.get(index).left < end){ + ++index; + } + endPeak = index-1; + } + if(startPeak < 0 || startPeak > endPeak){ + return pointlist; + } + + List regPeak = new LinkedList<>(); + int channel = 1; + for(int i=start-1; i= peak.left && channel <= peak.right) { + if(CollectionUtils.isEmpty(regPeak)) { + List regChan = new LinkedList<>(); + for(double d=peak.left; d<=peak.right; d+=1.0){ + regChan.add(d); + } + List vBase = phd.getVBase(); + List t_base = vBase.subList(peak.left-1, peak.right); + regPeak = CalValuesHandler.interp1(peak, t_base, regChan); + } + // 差值 = 原谱值 - 峰面积 + SeriseData seriseData = new SeriseData(); + seriseData.setX(channel); + seriseData.setY(m_vCount.get(i) - regPeak.get(channel-peak.left)); + pointlist.add(seriseData); + } else if(m_vCount.get(i) > 0 && phd.getVBase().get(i) > 0) { + SeriseData seriseData = new SeriseData(); + seriseData.setX(channel); + seriseData.setY(m_vCount.get(i) - phd.getVBase().get(i)); + pointlist.add(seriseData); + } else{ + SeriseData seriseData = new SeriseData(); + seriseData.setX(channel); + seriseData.setY(0); + pointlist.add(seriseData); + } + + if(vecPeak.get(startPeak).right < channel) { + ++startPeak; regPeak.clear(); + } + if(startPeak > endPeak){ + break; + } + } + for(int i=channel; i 0 && phd.getVBase().get(i) > 0) { + SeriseData seriseData = new SeriseData(); + seriseData.setX(i+1); + seriseData.setY(m_vCount.get(i) - phd.getVBase().get(i)); + pointlist.add(seriseData); + } else { + SeriseData seriseData = new SeriseData(); + seriseData.setX(i+1); + seriseData.setY(0); + pointlist.add(seriseData); + } + } + + return pointlist; + } + + public void ReadData(List m_vEnergy, List m_vNuclide){ + try { + String filePath = parameterFilePath+File.separator+"Energy_Nuclide.txt"; + File file = new File(filePath); + List readLines = FileUtils.readLines(file, "UTF-8"); + for (int i=0; i= 2 && m_curParam.getP().get(2) > 0) { + // Polynomial: y=a0+a1*x+a2*x^2+a3*x^3 + equation +="Energy = "+m_curParam.getP().get(1)+" + C * "+m_curParam.getP().get(2); + for(int i=3; i<=p_size; ++i) { + equation += " + C" + (i-1) +" * "+m_curParam.getP().get(i)+""; + } + } else if(p_size == 1) { + equation = "Energy = "+m_curParam.getP().get(1)+" * C"; + } + return equation; + } + + public void UpdateChartEnergy(List m_vCurEnergy, ParameterInfo m_curParam, List m_vCurCentroid, PHDFile phd, Map map) { + System.loadLibrary("GammaAnaly"); + int num = m_vCurEnergy.size(); + if(num < 1){ + return; + } + List datalist = new LinkedList<>(); + if(CollectionUtils.isNotEmpty(m_curParam.getP())) { + // 拟合曲线 + ChartData lData = new ChartData(); + lData.setColor("255, 255, 0"); + lData.setType("Line"); + + List vChan = new LinkedList<>(); + double MaxChan = Double.valueOf(phd.getSpec().getNum_g_channel()); + double d = 1; + double dStep = MaxChan / 30 * 2; + while(d < MaxChan) { + vChan.add(d); + d+= dStep; + } + vChan.add(MaxChan); + + List vFit = CalValuesHandler.calFcnEval(vChan, m_curParam.getP()).counts; + for(int i=0; i 0){ + SeriseData seriseData = new SeriseData(); + seriseData.setX(vChan.get(i)); + seriseData.setY(vFit.get(i)); + lData.getPointlist().add(seriseData); + } + } + if(lData.getPointlist().size() > 1){ + datalist.add(lData); + } + } + + // Channel——Energy 点集 + ChartData pData = new ChartData(); + pData.setColor("red"); + pData.setType("Scatter"); + for(int i=0; i= 2 && m_curParam.getP().get(1) > 0 && m_curParam.getP().get(2) > 0) { + // Square root of polynomial: y = sqrt(a0+a1*x+a2*x^2+a3*x^3 ) + equation += "FWHM = ("+m_curParam.getP().get(1)+" + E * "+m_curParam.getP().get(2); + for(int i=3; i<=p_size; ++i) { + equation += " + E"+(i-1)+" * "+m_curParam.getP().get(i); + } + equation += ")"+1+"/"+2+""; + } + return equation; + } + + public void UpdateChartResolution(List m_vCurEnergy, ParameterInfo m_curParam, List m_vCurReso, PHDFile phd, Map map) { + System.loadLibrary("GammaAnaly"); + int num = m_vCurEnergy.size(); + if(num < 1) return; + + List datalist = new LinkedList<>(); + if(CollectionUtils.isNotEmpty(m_curParam.getP())) { + // 拟合曲线 + ChartData lData = new ChartData(); + lData.setColor("255, 255, 0"); + lData.setType("Line"); + + List vChan = new LinkedList<>(); + vChan.add(1.0); + vChan.add(Double.valueOf(phd.getSpec().getNum_g_channel())); + + List vEner = CalValuesHandler.calFcnEval(vChan, phd.getUsedEnerPara().getP()).counts; + double d = vEner.get(0), maxE = vEner.get(1); + double dStep = maxE / 30 * 2; + + vEner.remove(vEner.size()-1); + while(d < maxE) { + vEner.add(d); + d += dStep; + } + vEner.add(maxE); + + List vFit = CalValuesHandler.calFcnEval(vEner, m_curParam.getP()).counts; + for(int i=0; i 0){ + SeriseData seriseData = new SeriseData(); + seriseData.setX(vEner.get(i)); + seriseData.setY(vFit.get(i)); + lData.getPointlist().add(seriseData); + } + } + if(lData.getPointlist().size() > 1){ + datalist.add(lData); + } + } + + // Channel——Energy 点集 + ChartData pData = new ChartData(); + pData.setColor("red"); + pData.setType("Scatter"); + for(int i=0; i m_vCurEnergy, ParameterInfo m_curParam) { + String equation = ""; + if(m_curParam.getP().size() > 2) { + int p_size = m_curParam.getP().size()-1; + int e_size = m_vCurEnergy.size(); + int funId = m_curParam.getP().get(0).intValue(); + switch(funId) { + case 1: // Interpolation: y=yi+(y(i+1)-yi)*(x-xi)/(x(i+1)-xi) for xi<=x= 4) { + int i = 0; + if(i < 0 || i >= e_size) break; + + double y1, y0, x1, x0; + if(i < e_size - 1) + { + y1 = m_curParam.getP().get(i*2+3); + y0 = m_curParam.getP().get(i*2+1); + x1 = m_curParam.getP().get(i*2+2); + x0 = m_curParam.getP().get(i*2); + } + else { + y1 = m_curParam.getP().get(i*2+1); + y0 = m_curParam.getP().get(i*2-1); + x1 = m_curParam.getP().get(i*2); + x0 = m_curParam.getP().get(i*2-2); + } + equation += "Efficiency = "+y0+" + ("+y1+"-"+y0+") * (E - "+x0+") / ("+x1+" - "+x0+")"; + } + break; + case 5: // HT Efficiency: y = A*exp(-(E1/x)^k)*(1-exp(-(E2/x)^n)) + if(p_size == 5) { + for(int i=1; i<=p_size; ++i) { + if(m_curParam.getP().get(i) <= 0) break; + } + equation += "Efficiency = "+m_curParam.getP().get(1)+" * exp(-("+m_curParam.getP().get(2)+" / E)"+m_curParam.getP().get(3)+") * "+ + "(1-exp(-("+m_curParam.getP().get(4)+" / E)"+m_curParam.getP().get(5)+"))"; + } + break; + case 6: // Polynomial in log(y) against log(x): log(y) = a0 + a1*log(x) +a2*log(x)^2+ a3*log(x)^3 + if(p_size >= 2) { + equation += "log(Efficiency) = "+m_curParam.getP().get(1)+" + "+m_curParam.getP().get(2)+" * log(E)"; + for(int i=3; i<=p_size; ++i) { + equation += " + "+m_curParam.getP().get(i)+" * log(E)"+(i-1)+""; + } + } + break; + case 8: // Polynomial in log(y) against log(1/x): log(y) = a0 + a1*log(c/x) + a2*log(c/x)^2 + a3*log(c/x)^3 + a4*log(c/x)^4 + if(p_size >= 3) { + equation += "log(Efficiency) = "+m_curParam.getP().get(1)+" + "+m_curParam.getP().get(2)+" * log(C/E)"; + for(int i=3; i<=p_size; ++i) { + equation += " + "+m_curParam.getP().get(i)+" * log(C/E)"+(i-1)+""; + } + } + break; + case 93: // HAE Efficiency (1-3): y=S*exp(-(E1/x)^k)*(1- exp(-(2*E3/(x-E3))^n)) + if(p_size == 5) { + equation += "Efficiency = "+m_curParam.getP().get(1)+" * exp(-("+m_curParam.getP().get(2)+" / E)"+m_curParam.getP().get(3)+") * "+ + "(1 - exp(-(2 * "+m_curParam.getP().get(4)+" / (E - "+m_curParam.getP().get(4)+"))"+m_curParam.getP().get(5)+"))"; + } + break; + case 94: // HAE Efficiency (1-2): y=S*exp(-(E1/x)^k)*(1- exp(-b*(1/(x-E2))^m)) + if(p_size == 6) { + equation += "Efficiency = "+m_curParam.getP().get(1)+" * exp(-("+m_curParam.getP().get(2)+" / E)"+m_curParam.getP().get(3)+") * "+ + "(1 - exp(-"+m_curParam.getP().get(4)+" * (1 / (E - "+m_curParam.getP().get(5)+"))"+m_curParam.getP().get(6)+"))"; + } + break; + case 95: // HAE Efficiency (1-2-3): y = S * exp(-(E1/x)^k) * (1- exp(-b*(1/(x-E2))^m)) *(1 - exp(-(2*E3/(E-E3))^n)) + if(p_size == 8) { + equation += "Efficiency = "+m_curParam.getP().get(1)+" * exp(-("+m_curParam.getP().get(2)+" / E)"+m_curParam.getP().get(3)+") * "+ + "(1 - exp(-"+m_curParam.getP().get(4)+" * (1 / (E - "+m_curParam.getP().get(5)+"))"+m_curParam.getP().get(6)+")) * "+ + "(1 - exp(-(2 * "+m_curParam.getP().get(7)+" / (E - "+m_curParam.getP().get(7)+"))"+m_curParam.getP().get(8)+"))"; + } + break; + } + } + return equation; + } + + public void UpdateChartEfficiency(List m_vCurEnergy, ParameterInfo m_curParam, List m_vCurEffi, PHDFile phd, Map map) { + System.loadLibrary("GammaAnaly"); + int num = m_vCurEnergy.size(); + if(num < 1) return; + + List datalist = new LinkedList<>(); + if(CollectionUtils.isNotEmpty(m_curParam.getP())) { + // 拟合曲线 + ChartData lData = new ChartData(); + lData.setColor("255, 255, 0"); + lData.setType("Line"); + + List vChan = new LinkedList<>(); + vChan.add(1.0); + vChan.add(Double.valueOf(phd.getSpec().getNum_g_channel())); + + List vEner = CalValuesHandler.calFcnEval(vChan, phd.getUsedEnerPara().getP()).counts; + double d = vEner.get(0); + double maxE = vEner.get(1); + double dStep = maxE / 30 * 2; + + vEner.remove(vEner.size()-1); + while(d < maxE) { + vEner.add(d); + d += dStep; + } + vEner.add(maxE); + + List vFit = CalValuesHandler.calFcnEval(vEner, m_curParam.getP()).counts; + for(int i=0; i 0){ + SeriseData seriseData = new SeriseData(); + seriseData.setX(vEner.get(i)); + seriseData.setY(vFit.get(i)); + lData.getPointlist().add(seriseData); + } + } + if(lData.getPointlist().size() > 1){ + datalist.add(lData); + } + } + + // Channel——Energy 点集 + ChartData pData = new ChartData(); + pData.setColor("red"); + pData.setType("Scatter"); + for(int i=0; i InitNuclideLine(String editEnergy, double err, String name) { + Double min = null; + Double max = null; + if (StringUtils.isNotBlank(editEnergy) && Objects.nonNull(err)){ + double editEnergyDou = Double.valueOf(editEnergy); + min = editEnergyDou - err; + max = editEnergyDou + err; + } + List nuclideLines = spectrumAnalysisMapper.getNuclideLine(min, max, name); + return nuclideLines; + } + + public Map InitNuclideInfo(String name) { + Map map = new HashMap<>(); + GardsNuclLib nuclideInfo = spectrumAnalysisMapper.getNuclideInfo(name); + if(Objects.nonNull(nuclideInfo)) { + Long numLines = nuclideInfo.getNumLines(); + map.put("lab_lines", numLines.toString()); + if(Objects.isNull(nuclideInfo.getHalflife())) { + map.put("lab_halfLife", ""); + } else { + String units = "D"; + double halflife = nuclideInfo.getHalflife().doubleValue(); + if(halflife >= 1000) { + halflife = halflife / 365.25; + units = "A"; + } else if(halflife < 0.1 && halflife >= 1.0 / 1440.0) { + halflife = halflife * 1440.0; + units = "M"; + } else if(halflife <= 1.0 / 1440.0 && halflife > 0.0) { + halflife = halflife * 86400.0; + units = "S"; + } + char flag = 'f'; + if(halflife >= 1000){ + flag = 'e'; + } + if (flag == 'f'){ + map.put("lab_halfLife", String.format("%.3f", halflife)+units); + } else if (flag == 'e') { + NumberFormat numberFormat = new DecimalFormat("0.###E0"); + String formatNum = numberFormat.format(halflife); + map.put("lab_halfLife", formatNum+units); + } + } + if(Objects.isNull(nuclideInfo.getHalflifeErr())) { + map.put("lab_halfLifeErr", ""); + } else { + map.put("lab_halfLifeErr", String.format("%.3f", nuclideInfo.getHalflifeErr().doubleValue())+"%"); + } + } + return map; + } + + public Map InitParentAndDaughter(String name) { + Map map = new HashMap<>(); + GardsNuclLib parentAndDaughter = spectrumAnalysisMapper.getParentAndDaughter(name); + List parentList = new LinkedList<>(); + if(Objects.nonNull(parentAndDaughter)) { + parentList.add(parentAndDaughter.getDaughters1()); + parentList.add(parentAndDaughter.getDaughters2()); + parentList.add(parentAndDaughter.getDaughters3()); + parentList.add(parentAndDaughter.getDaughters4()); + parentList.add(parentAndDaughter.getDaughters5()); + map.put("list_parent", parentList); + List daughterList = new LinkedList<>(); + TableDaughter tableDaughter1 = new TableDaughter(); + tableDaughter1.setDaughters(parentAndDaughter.getDaughters1()); + tableDaughter1.setBranchingratios(String.format("%.2f", parentAndDaughter.getBranchingratios1().doubleValue())+"%"); + tableDaughter1.setDaughtersstable(parentAndDaughter.getDaughtersstable1().intValue() == 1? "Stable" : "Unstable"); + daughterList.add(tableDaughter1); + TableDaughter tableDaughter2 = new TableDaughter(); + tableDaughter2.setDaughters(parentAndDaughter.getDaughters2()); + tableDaughter2.setBranchingratios(String.format("%.2f", parentAndDaughter.getBranchingratios2().doubleValue())+"%"); + tableDaughter2.setDaughtersstable(parentAndDaughter.getDaughtersstable2().intValue() == 1? "Stable" : "Unstable"); + daughterList.add(tableDaughter2); + TableDaughter tableDaughter3 = new TableDaughter(); + tableDaughter3.setDaughters(parentAndDaughter.getDaughters3()); + tableDaughter3.setBranchingratios(String.format("%.2f", parentAndDaughter.getBranchingratios3().doubleValue())+"%"); + tableDaughter3.setDaughtersstable(parentAndDaughter.getDaughtersstable3().intValue() == 1? "Stable" : "Unstable"); + daughterList.add(tableDaughter3); + TableDaughter tableDaughter4 = new TableDaughter(); + tableDaughter4.setDaughters(parentAndDaughter.getDaughters4()); + tableDaughter4.setBranchingratios(String.format("%.2f", parentAndDaughter.getBranchingratios4().doubleValue())+"%"); + tableDaughter4.setDaughtersstable(parentAndDaughter.getDaughtersstable4().intValue() == 1? "Stable" : "Unstable"); + daughterList.add(tableDaughter4); + TableDaughter tableDaughter5 = new TableDaughter(); + tableDaughter5.setDaughters(parentAndDaughter.getDaughters5()); + tableDaughter5.setBranchingratios(String.format("%.2f", parentAndDaughter.getBranchingratios5().doubleValue())+"%"); + tableDaughter5.setDaughtersstable(parentAndDaughter.getDaughtersstable5().intValue() == 1? "Stable" : "Unstable"); + daughterList.add(tableDaughter5); + map.put("table_daughter", daughterList); + } + return map; + } + + public String GetReportContent(PHDFile phd, boolean bLog) { + GStoreMiddleProcessData middleData = new GStoreMiddleProcessData(); + this.GetInterMiddlData(phd, middleData); + if(bLog) { + return this.GetLogContent(middleData); + } else { + return this.GetReportContent(middleData); + } + } + + public boolean GetInterMiddlData(PHDFile phd, GStoreMiddleProcessData middleData){ + boolean bRet = true; + Map temp = new HashMap<>(); + try { + bRet = GetMiddleData(phd,temp,middleData); + middleData.analyses_type ="Interactive"; + } catch (ParseException e) { + throw new RuntimeException(e); + } + return bRet; + } + + public String GetLogContent(GStoreMiddleProcessData middleData){ + StringBuffer strBuffer = new StringBuffer(); + strBuffer.append("-------------------------- Sample Analyse Beginning at "+DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss")+" ---------------------------\n"); + strBuffer.append("\n"); + strBuffer.append("....................................... Read calibration data ........................................\n"); + strBuffer.append("\n"); + strBuffer.append("Reading gamma energy pairs(sampleID: "+middleData.sample_id+").....\n"); + strBuffer.append("\n"); + for (int i=0;i0) { + strBuffer.append("Energy Calibration ["+middleData.calibration_pairs_E_Input+" ]\n"); + strBuffer.append("Function: "+middleData.calibration_E_functionTypeDef+"\n"); + strBuffer.append("E: "+middleData.calibration_E_functionDef+"\n"); + strBuffer.append("P: "+middleData.calibration_E_coeff_string+"\n"); + strBuffer.append("Err: "+middleData.calibration_E_uncoeff_string+"\n"); + strBuffer.append("Data: "+middleData.calibration_pairs_E_Input+"\n"); + } + if(middleData.calibration_pairs_R_idCalPoint.size()>0) { + strBuffer.append("Resolution Calibration ["+middleData.calibration_pairs_R_Input+" ]\n"); + strBuffer.append("Function: "+middleData.calibration_R_functionTypeDef+"\n"); + strBuffer.append("E: "+middleData.calibration_R_functionDef+"\n"); + strBuffer.append("P: "+middleData.calibration_R_coeff_string+"\n"); + strBuffer.append("Err: "+middleData.calibration_R_uncoeff_string+"\n"); + strBuffer.append("Data: "+middleData.calibration_pairs_R_Input+"\n"); + } + if(middleData.calibration_pairs_EF_idCalPoint.size()>0) { + strBuffer.append("Efficiency Calibration ["+middleData.calibration_pairs_EF_Input+" ]\n"); + strBuffer.append("Function: "+middleData.calibration_EF_functionTypeDef+"\n"); + strBuffer.append("E: "+middleData.calibration_EF_functionDef+"\n"); + strBuffer.append("P: "+middleData.calibration_EF_coeff_string+"\n"); + strBuffer.append("Err: "+middleData.calibration_EF_uncoeff_string+"\n"); + strBuffer.append("Data: "+middleData.calibration_pairs_EF_Input+"\n"); + } + if(middleData.calibration_pairs_T_idCalPoint.size()>0) { + strBuffer.append("Tot_efficiency Calibration ["+middleData.calibration_pairs_T_Input+" ]\n"); + strBuffer.append("Function: "+middleData.calibration_T_functionTypeDef+"\n"); + strBuffer.append("E: "+middleData.calibration_T_functionDef+"\n"); + strBuffer.append("P: "+middleData.calibration_T_coeff_string+"\n"); + strBuffer.append("Err: "+middleData.calibration_T_uncoeff_string+"\n"); + strBuffer.append("Data: "+middleData.calibration_pairs_T_Input+"\n"); + } + strBuffer.append("\n"); + strBuffer.append("........................................ Calibration Finished ........................................"); + strBuffer.append("\n"); + strBuffer.append("..................................... Starting Spectrum Analysis ....................................."); + strBuffer.append("\n"); + strBuffer.append("PROCESSING PARAMETERS.....\n"); + strBuffer.append("ECutAnalysis_Low : "+middleData.setting_specSetup.getECutAnalysis_Low()+"\n"); + strBuffer.append("ECutAnalysis_High : "+middleData.setting_specSetup.getECutAnalysis_High()+"\n"); + strBuffer.append("EnergyTolerance : "+middleData.setting_specSetup.getEnergyTolerance()+"\n"); + strBuffer.append("BaseImprovePSS : "+middleData.setting_specSetup.getBaseImprovePSS()+"\n"); + strBuffer.append("PSS_low : "+middleData.setting_specSetup.getPSS_low()+"\n"); + strBuffer.append("k_back : "+middleData.setting_specSetup.getK_back()+"\n"); + strBuffer.append("k_alpha : "+middleData.setting_specSetup.getK_alpha()+"\n"); + strBuffer.append("k_beta : "+middleData.setting_specSetup.getK_beta()+"\n"); + strBuffer.append("RiskLevelK : "+middleData.setting_specSetup.getRiskLevelK()+"\n"); + strBuffer.append("refTime_act : "+middleData.setting_specSetup.getRefTime_act()+"\n"); + strBuffer.append("refTime_conc : "+middleData.setting_specSetup.getRefTime_conc()+"\n"); + strBuffer.append("\n"); + strBuffer.append("CALIBRATION PARAMETERS.....\n"); + strBuffer.append("\n"); + strBuffer.append("CalibrationPSS_low : "+middleData.setting_specSetup.getCalibrationPSS_low()+"\n"); + strBuffer.append("CalibrationPSS_high : "+middleData.setting_specSetup.getCalibrationPSS_high()+"\n"); + strBuffer.append("bUpdateCal : "+(middleData.setting_specSetup.isBUpdateCal()?"1":"0")+"\n"); + strBuffer.append("KeepCalPeakSearchPeaks : "+(middleData.setting_specSetup.isKeepCalPeakSearchPeaks()?"1":"0")+"\n"); + strBuffer.append("\n"); + double peaksUsed = 0; + for(int m=0;m1) + { + qsNuclidesName = qsNuclidesName+middleData.nucl_ided_Nuclidename.get(middleData.nucl_ided_Nuclidename.size()-1); + } + strBuffer.append("Nuclide Identified.....\n"); + strBuffer.append("\n"); + strBuffer.append("Nuclides Identified : "+qsNuclidesName+"\n"); + strBuffer.append("Keyline Activities for Nuclides with defined Reference Line : \n"); + strBuffer.append("Activity Reference Time : "+middleData.sample_acquisiton_start+"\n"); + strBuffer.append("Concentration Reference Time : "+middleData.sample_collection_start+"\n"); + strBuffer.append("\n"); + for (int i=0;i1) { + qsNuclidesName = qsNuclidesName+middleData.nucl_ided_Nuclidename.get(middleData.nucl_ided_Nuclidename.size()-1); + } + strBuffer.append("#ACTIVITY SUMMARY\n"); + strBuffer.append(" Nuclides Identified: "+qsNuclidesName+"\n"); + strBuffer.append(" Keyline Activities for Nuclides: \n"); + strBuffer.append(" with defined Reference Line: \n"); + strBuffer.append(" Activity Reference Time: "+middleData.sample_acquisiton_start+"\n"); + strBuffer.append(" Concentration Reference Time: "+middleData.sample_collection_start+"\n"); + strBuffer.append(" \n"); + strBuffer.append(" \n"); + strBuffer.append(" \n"); + strBuffer.append(" Nuclide Halflife(s) Activity(Bq) RelErr% MDA(Bq) Conc(uBq/m^3) MDC\n"); + for (int i=0; i0) { + strBuffer.append("#Calibration\n"); + strBuffer.append(" Energy Calibration ["+middleData.calibration_pairs_E_Input+" ]\n"); + strBuffer.append(" Function: "+middleData.calibration_E_functionTypeDef+"\n"); + strBuffer.append(" E: "+middleData.calibration_E_functionDef+"\n"); + strBuffer.append(" P: "+middleData.calibration_E_coeff_string+"\n"); + strBuffer.append(" Err: "+middleData.calibration_E_uncoeff_string+"\n"); + strBuffer.append(" Data: "+middleData.calibration_pairs_E_Input+"\n"); + strBuffer.append("\n"); + strBuffer.append("\n"); + strBuffer.append("\n"); + } + if(middleData.calibration_pairs_R_idCalPoint.size()>0) { + strBuffer.append(" Resolution Calibration ["+middleData.calibration_pairs_R_Input+" ]\n"); + strBuffer.append(" Function: "+middleData.calibration_R_functionTypeDef+"\n"); + strBuffer.append(" E: "+middleData.calibration_R_functionDef+"\n"); + strBuffer.append(" P: "+middleData.calibration_R_coeff_string+"\n"); + strBuffer.append(" Err: "+middleData.calibration_R_uncoeff_string+"\n"); + strBuffer.append(" Data: "+middleData.calibration_pairs_R_Input+"\n"); + strBuffer.append("\n"); + strBuffer.append("\n"); + strBuffer.append("\n"); + } + if(middleData.calibration_pairs_EF_idCalPoint.size()>0) { + strBuffer.append(" Efficiency Calibration ["+middleData.calibration_pairs_EF_Input+" ]\n"); + strBuffer.append(" Function: "+middleData.calibration_EF_functionTypeDef+"\n"); + strBuffer.append(" E: "+middleData.calibration_EF_functionDef+"\n"); + strBuffer.append(" P: "+middleData.calibration_EF_coeff_string+"\n"); + strBuffer.append(" Err: "+middleData.calibration_EF_uncoeff_string+"\n"); + strBuffer.append(" Data: "+middleData.calibration_pairs_EF_Input+"\n"); + strBuffer.append("\n"); + strBuffer.append("\n"); + strBuffer.append("\n"); + } + if(middleData.calibration_pairs_T_idCalPoint.size()>0) { + strBuffer.append(" Tot_efficiency Calibration ["+middleData.calibration_pairs_T_Input+" ]\n"); + strBuffer.append(" Function: "+middleData.calibration_T_functionTypeDef+"\n"); + strBuffer.append(" E: "+middleData.calibration_T_functionDef+"\n"); + strBuffer.append(" P: "+middleData.calibration_T_coeff_string+"\n"); + strBuffer.append(" Err: "+middleData.calibration_T_uncoeff_string+"\n"); + strBuffer.append(" Data: "+middleData.calibration_pairs_T_Input+"\n"); + strBuffer.append("\n"); + strBuffer.append("\n"); + strBuffer.append("\n"); + } + strBuffer.append("#DATA QUALITY FLAGS\n"); + strBuffer.append(" Name Pass/Fail Value Test\n"); + for (int i=0;i DoubleLimit(List data){ + for(int pos=0;pos DoubleLimit_G(List _data) { + NumberFormat numberFormat = new DecimalFormat("0.##########E0"); + List rdata = new LinkedList<>(); + for(int pos=0;pos<_data.size();pos++) { + if(Objects.isNull(_data.get(pos))) { + rdata.add("NULL"); + } else { + rdata.add(numberFormat.format(_data.get(pos))); + } + } + return rdata; + } + + public String EquationDescription(int funcId) { + String desc = ""; + switch (funcId) + { + case 1: desc = "y=yi+(y(i+1)-yi)*(x-xi)/(x(i+1)-xi) for xi<=x nucline,GStoreMiddleProcessData middleData) throws ParseException { + boolean bRet=true; + double totalNumber = 0.0; + for(int m=0;m temp = new LinkedList<>(); + for(int pos=0;pos temp = new LinkedList<>(); + for(int pos=0;pos temp = new LinkedList<>(); + for(int pos=0;pos temp = new LinkedList<>(); + for(int pos=0;pos0) { + funcType = fileAnlyse.getUsedEnerPara().getP().get(0).intValue(); + } + for(int m=1;m0) { + coeffEnergy+=numberFormat.format(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)); + } + funcDefEnergy = EquationDescription(funcType); + funcTypeDefEnergy = EquationName(funcType); + middleData.calibration_E_Caltype = "energy"; + middleData.calibration_E_function = funcType; + middleData.calibration_E_functionDef = funcDefEnergy; + middleData.calibration_E_functionTypeDef = funcTypeDefEnergy; + middleData.calibration_E_startOfRange = 0; + middleData.calibration_E_endOfRange = 1; + middleData.calibration_E_coeff_string = coeffEnergy; + + + String coeffEffi = ""; + String uncerEffi = ""; + String funcDefEffi = ""; + String funcTypeDefEffi = ""; + coeffNumber = fileAnlyse.getUsedEffiPara().getP().size(); + if(coeffNumber>0) { + funcType = fileAnlyse.getUsedEffiPara().getP().get(0).intValue(); + } + for(int m=1;m0) { + coeffEffi+=numberFormat.format(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)); + } + funcDefEffi = EquationDescription(funcType); + funcTypeDefEffi = EquationName(funcType); + middleData.calibration_EF_Caltype = "efficiency"; + middleData.calibration_EF_function = funcType; + middleData.calibration_EF_functionDef = funcDefEffi; + middleData.calibration_EF_functionTypeDef = funcTypeDefEffi; + middleData.calibration_EF_startOfRange = 0; + middleData.calibration_EF_endOfRange = 1; + middleData.calibration_EF_coeff_string = coeffEffi; + + String coeffReso = ""; + String uncerReso = ""; + String funcDefReso = ""; + String funcTypeDefReso = ""; + coeffNumber = fileAnlyse.getUsedResoPara().getP().size(); + if(coeffNumber>0) { + funcType = fileAnlyse.getUsedResoPara().getP().get(0).intValue(); + } + for(int m=1;m0) { + coeffReso+= numberFormat.format(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)); + } + funcDefReso = EquationDescription(funcType); + funcTypeDefReso = EquationName(funcType); + middleData.calibration_R_Caltype = "Resolution"; + middleData.calibration_R_function = funcType; + middleData.calibration_R_functionDef = funcDefReso; + middleData.calibration_R_functionTypeDef = funcTypeDefReso; + middleData.calibration_R_startOfRange = 0; + middleData.calibration_R_endOfRange = 1; + middleData.calibration_R_coeff_string = coeffReso; + + String coeffTotE = ""; + String uncerTotE = ""; + String funcDefTotE = ""; + String funcTypeDefTotE = ""; + coeffNumber = fileAnlyse.getUsedTotEPara().getP().size(); + if(coeffNumber>0) { + funcType = fileAnlyse.getUsedTotEPara().getP().get(0).intValue(); + } + for(int m=1;m0) { + coeffTotE+= numberFormat.format(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)); + } + funcDefTotE = EquationDescription(funcType); + funcTypeDefTotE = EquationName(funcType); + middleData.calibration_T_Caltype = "TotalEfficiency"; + middleData.calibration_T_function = funcType; + middleData.calibration_T_functionDef = funcDefTotE; + middleData.calibration_T_functionTypeDef = funcTypeDefTotE; + middleData.calibration_T_startOfRange = 0; + middleData.calibration_T_endOfRange = 1; + middleData.calibration_T_coeff_string = coeffTotE; + + //gards_ peaks数据表 + + if(fileAnlyse.getVPeak().size() != 0) { + List dvctIDPEAK = new LinkedList<>(); + List dvctCENTROIDCHANNEL = new LinkedList<>(); + List dvctUNCCENTROIDCHANNEL = new LinkedList<>(); + List dvctENERGY = new LinkedList<>(); + List dvctUNCENERGY = new LinkedList<>(); + List dvctAREA = new LinkedList<>(); + List dvctnetCountRate = new LinkedList<>(); + List dvctuncNetCountRate = new LinkedList<>(); + List dvctUNCAREA = new LinkedList<>(); + List dvctEFFICIENCY = new LinkedList<>(); + List dvctUNCEFFICIENCY = new LinkedList<>(); + List dvctFWHM = new LinkedList<>(); + List dvctFWTM = new LinkedList<>(); + List dvctSIGNIFICANCE = new LinkedList<>(); + List dvctSENSITIVITY = new LinkedList<>(); + List dvctMULTIINDEX = new LinkedList<>(); + List dvctROISTART = new LinkedList<>(); + List dvctROIEND = new LinkedList<>(); + List dvctTAIL = new LinkedList<>(); + List dvctTAILALPHA = new LinkedList<>(); + List dvctUPPERTAIL = new LinkedList<>(); + List dvctUPPERTAILALPHA = new LinkedList<>(); + List dvctBWWIDTHCHAN = new LinkedList<>(); + List dvctRECOILBETACHAN = new LinkedList<>(); + List dvctRECOILDELTACHAN = new LinkedList<>(); + List dvctSTEPRAIO = new LinkedList<>(); + List dvctBACKGROUNDAREA = new LinkedList<>(); + List dvctMEANBACKCOUNT = new LinkedList<>(); + List dvctLC = new LinkedList<>(); + 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()) { + int first=itor.getValue().getFullNames().size(); + int second=itor.getValue().getVPeakIdx().size(); + first = first 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) { + for(Map.Entry itor_v: fileAnlyse.getMapNucActMda().entrySet()) { + String nuclideName = itor_v.getKey(); + svctNUCLIDEFULLNAME1.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); + if(itor_v.getValue().getCalculateIdx() >= 0 && 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) { + for(Map.Entry itor_q:fileAnlyse.getQcItems().entrySet()) { + String nuclideName = itor_q.getKey(); + qvctQC_NAME.add(nuclideName); + dvctQC_VALUE.add(itor_q.getValue().getValue()); + qvctQC_STANDARD.add(itor_q.getValue().getStandard()); + dvctQC_RESULT.add(itor_q.getValue().isBPass()?1.0:0.0); + } + middleData.QC_CHECK_QC_NAME=qvctQC_NAME; + middleData.QC_CHECK_QC_RESULT=DoubleLimit_G(dvctQC_RESULT); + 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(); + + 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) { + middleData.sample_Avg_Flow_Rate = String.format("%.5f", fileAnlyse.getCollect().getAir_volume()/fileAnlyse.getQcItems().get("col_time").getValue()); + } + } + if(Objects.nonNull(fileAnlyse.getQcItems().get("decay_time"))) { + middleData.sample_decay_time = String.format("%.5f", fileAnlyse.getQcItems().get("decay_time").getValue()); + } + if(Objects.nonNull(fileAnlyse.getQcItems().get("acq_time"))) { + 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(); + 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"); + 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; + } + + public Map UpdateDatasNuclideActivity(Map mapNucAct, Date act_ref, Date con_ref) { + Map map = new HashMap<>(); + map.put("dateTime_act_ref", act_ref); + map.put("dateTime_con_ref", con_ref); + + //m_mapAct = mapNucAct; + int size_map = mapNucAct.size(); + if(size_map < 1){ + return map; + } + List nuclideActivityList = new LinkedList<>(); + for(Map.Entry iter:mapNucAct.entrySet()){ + TableNuclideActivity tableNuclideActivity = new TableNuclideActivity(); + NuclideActMda nuc = iter.getValue(); + tableNuclideActivity.setNuclide(iter.getKey()); + char units = 'S'; + double halflife = nuc.getHalflife(); + if(halflife >= 31556736) // 1年 = 365.24 * 24 * 60 * 60 = 31556736s + { + halflife /= 31556736; + units = 'A'; + } + else if(halflife >= 86400) // 1天 = 24 * 60 * 60 = 86400s + { + halflife /= 86400; + units = 'D'; + } + else if(halflife >= 3600) + { + halflife /= 3600; + units = 'H'; + } + tableNuclideActivity.setHalfLife(halflife+" "+units); + tableNuclideActivity.setEnergy(nuc.getVEnergy().get(nuc.getCalculateIdx()).toString()); + tableNuclideActivity.setYield(String.valueOf(nuc.getVYield().get(nuc.getCalculateIdx())*100)); + + String str_effi = (nuc.getEfficiency() <= 0 ? "null" : String.valueOf(nuc.getEfficiency())); + tableNuclideActivity.setEfficiency(str_effi); + + String str_act = (nuc.getActivity() <= 0 ? "null" : String.valueOf(nuc.getActivity())); + tableNuclideActivity.setActivity(str_act); + + String str_act_err = (nuc.getActivity() <= 0 ? "null" : String.valueOf(nuc.getAct_err() / nuc.getActivity() * 100)); + tableNuclideActivity.setActErr(str_act_err); + + String str_mda = (nuc.getMda() <= 0 ? "null" : String.valueOf(nuc.getMda())); + tableNuclideActivity.setMda(str_mda); + + String str_con = (nuc.getConcentration() <= 0 ? "null" : String.valueOf(nuc.getConcentration())); + tableNuclideActivity.setConc(str_con); + + String str_mdc = (nuc.getMdc() <= 0 ? "null" : String.valueOf(nuc.getMdc())); + tableNuclideActivity.setMdc(str_mdc); + nuclideActivityList.add(tableNuclideActivity); + } + map.put("table", nuclideActivityList); + return map; + } + + public String RightFill(String str, int fieldWidth) { + String fillChar = " "; + int fillNum = fieldWidth - str.length(); + while(fillNum > 0) { + str+=fillChar; + --fillNum; + } + return str; + } + + public String MakeUpSpectrum(PHDFile phd) { + StringBuffer spectrum = new StringBuffer(); + + spectrum.append("BEGIN IMS2.0\r\n"); + spectrum.append("MSG_TYPE "+phd.getMsgInfo().getMsg_type()+"\r\n"); + spectrum.append("MSG_ID "+phd.getMsgInfo().getMsg_id()+" "+phd.getMsgInfo().getMsg_src_code()+"\r\n"); + if(phd.getMsgInfo().isVerify_srid()) { + spectrum.append("REF_ID\r\n"); + spectrum.append(phd.getMsgInfo().getRef_id_str()+" "+phd.getMsgInfo().getRef_src_code()+" "+phd.getMsgInfo().getSeq_num()+" "+phd.getMsgInfo().getTot_num()+"\r\n"); + spectrum.append("PROD_ID "+phd.getMsgInfo().getProduct_id()+" "+phd.getMsgInfo().getDelivery_id()+"\r\n"); + } + spectrum.append("DATA_TYPE "+phd.getMsgInfo().getData_type()+"\r\n"); + + List data_types = new LinkedList<>(); + data_types.add("SAMPLEPHD"); + data_types.add("SPHDF"); + data_types.add("SPHDP"); + data_types.add("GASBKPHD"); + data_types.add("BLANKPHD"); + data_types.add("DETBKPHD"); + data_types.add("QCPHD"); + data_types.add("CALIBPHD"); + + if(!data_types.contains(phd.getMsgInfo().getData_type())){ + return spectrum.toString(); + } + + // #Header + spectrum.append("#Header "+phd.getHeader().getDesignator()+"\r\n"); + spectrum.append(RightFill(phd.getHeader().getSite_code(), 5)+ + " "+RightFill(phd.getHeader().getDetector_code(), 9)+ + " "+RightFill(phd.getHeader().getSystem_type(), 1)+ + " "+RightFill(phd.getHeader().getSample_geometry(), 17)+ + " "+RightFill(phd.getHeader().getSpectrum_quantity(), 4)+"\r\n"); + spectrum.append(phd.getHeader().getSample_ref_id() + "\r\n"); + spectrum.append(RightFill(phd.getHeader().getMeasurement_id(), 31)+" "+RightFill(phd.getHeader().getDetector_bk_measurement_id(), 31)+" "+phd.getHeader().getGas_bk_measurement_id()+"\r\n"); + spectrum.append(phd.getHeader().getTransmit_date()+" "+phd.getHeader().getTransmit_time()+"\r\n"); + + // #Comment + if(StringUtils.isNotBlank(phd.getOriTotalCmt())) { + String comment = phd.getOriTotalCmt().replace("\r\n", "\n"); + comment.replace("\n", "\r\n"); + spectrum.append("#Comment\r\n"); + spectrum.append(comment + "\r\n"); + } + + // #Collection + spectrum.append("#Collection\r\n"); + spectrum.append(phd.getCollect().getCollection_start_date()+" "+phd.getCollect().getCollection_start_time()+ + " "+phd.getCollect().getCollection_stop_date()+" "+phd.getCollect().getCollection_stop_time()+" "+phd.getCollect().getAir_volume()+"\r\n"); + + // #Acquisition + spectrum.append("#Acquisition\r\n"); + spectrum.append(phd.getAcq().getAcquisition_start_date()+" "+phd.getAcq().getAcquisition_start_time()+ + " "+RightFill(String.format("%.2f", phd.getAcq().getAcquisition_real_time()), 14)+ + " "+RightFill(String.format("%.2f", phd.getAcq().getAcquisition_live_time()), 14)+"\r\n"); + + // #Processing + if(phd.getProcess().getSample_volume_of_Xe() > 0) { + spectrum.append("#Processing\r\n"); + spectrum.append(RightFill(String.valueOf(phd.getProcess().getSample_volume_of_Xe()), 8)+" "+RightFill(String.valueOf(phd.getProcess().getUncertainty_1()), 8)+"\r\n"+ + " "+RightFill(String.valueOf(phd.getProcess().getXe_collection_yield()), 8)+" "+RightFill(String.valueOf(phd.getProcess().getUncertainty_2()), 8)+"\r\n"+ + " "+phd.getProcess().getArchive_bottle_id()+"\r\n"); + } + + // #Sample + if(phd.getSampleBlock().getDimension_1() > 0) { + spectrum.append("#Sample\r\n"); + spectrum.append(phd.getSampleBlock().getDimension_1()+" "+phd.getSampleBlock().getDimension_2()+"\r\n"); + } + + // Certificate + if(CollectionUtils.isNotEmpty(phd.getCertificate().getG_energy())) { + spectrum.append("#Certificate\r\n"); + spectrum.append(phd.getCertificate().getTotal_source_activity()+""+ phd.getCertificate().getAssay_date()+"" + + phd.getCertificate().getAssay_time()+""+phd.getCertificate().getUnits_activity() + "\r\n"); + + int fieldWidth = 12; + for(int i=0; i 0) { + spectrum.append("#TotalEff\r\n"); + TotaleffBlock g_totE = phd.getUsedTotEKD(); + for(int i=0; i input = gammaService.KorSumInput(coeffData); + result.setSuccess(true); + result.setResult(input); + return result; + } + + @GetMapping("energyCalibration") + public Result energyCalibration(@RequestParam Integer sampleId){ + return gammaService.energyCalibration(sampleId); + } + + @GetMapping("resolutionCalibration") + public Result resolutionCalibration(@RequestParam Integer sampleId){ + return gammaService.resolutionCalibration(sampleId); + } + + @GetMapping("EfficiencyCalibration") + public Result EfficiencyCalibration(@RequestParam Integer sampleId){ + return gammaService.EfficiencyCalibration(sampleId); + } + + @GetMapping("NuclideLibrary") + public Result NuclideLibrary(String editEnergy, double err, String libraryName, String nuclideName, HttpServletRequest request){ + return gammaService.NuclideLibrary(editEnergy, err, libraryName, nuclideName, request); + } + + @GetMapping("configUserLibrary") + public Result configUserLibrary(HttpServletRequest request){ + return gammaService.configUserLibrary(request); + } + + @GetMapping("viewComment") + public Result viewComment(@RequestParam Integer sampleId){ + return gammaService.viewComment(sampleId); + } + + @GetMapping("peakInformation") + public Result peakInformation(@RequestParam Integer sampleId){ + return gammaService.peakInformation(sampleId); + } + + @GetMapping("viewARR") + public Result viewARR(Integer sampleId, HttpServletResponse response){ + return gammaService.viewARR(sampleId, response); + } + + @GetMapping("viewRRR") + public Result viewRRR(Integer sampleId){ + return gammaService.viewRRR(sampleId); + } + + @GetMapping("radionuclideActivity") + public Result radionuclideActivity(Integer sampleId){ + return gammaService.radionuclideActivity(sampleId); + } + + @GetMapping("Spectrum") + public Result Spectrum(Integer sampleId){ + return gammaService.Spectrum(sampleId); + } + + @GetMapping("sampleInformation") + public Result sampleInformation(Integer sampleId){ + return gammaService.sampleInformation(sampleId); + } + + @GetMapping("viewQCResult") + public Result viewQCResult(Integer sampleId){ + return gammaService.viewQCResult(sampleId); + } + + @GetMapping("viewRLR") + public Result viewRLR(Integer sampleId){ + return gammaService.viewRLR(sampleId); + } + + @GetMapping("viewAutomaticAnalysisLog") + public Result viewAutomaticAnalysisLog(Integer sampleId, HttpServletResponse response){ + return gammaService.viewAutomaticAnalysisLog(sampleId, response); + } + + @GetMapping("viewGammaviewerLog") + public Result viewGammaviewerLog(Integer sampleId){ + return gammaService.viewGammaviewerLog(sampleId); + } } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/GardsNuclLinesIdedSpectrum.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/GardsNuclLinesIdedSpectrum.java index 78081493..7ff5d653 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/GardsNuclLinesIdedSpectrum.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/GardsNuclLinesIdedSpectrum.java @@ -73,7 +73,7 @@ public class GardsNuclLinesIdedSpectrum implements Serializable { /** * 该峰处的探测效率不确定度 */ - private Double uncEffic; + private Double unEffic; /** * 利用该峰计算得到的最小可探测活度 diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/CoeffData.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/CoeffData.java new file mode 100644 index 00000000..b7adab90 --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/CoeffData.java @@ -0,0 +1,37 @@ +package org.jeecg.modules.entity.vo; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +@Data +public class CoeffData implements Serializable { + + public Double totalEf1; + + public Double totalEf2; + + public Double totalEf3; + + public Double totalEf4; + + public Double totalEf5; + + public Double totalEf6; + + public Double Effciency1; + + public Double Effciency2; + + public Double Effciency3; + + public Double Effciency4; + + public Double Effciency5; + + public Double Effciency6; + + public List energys; + +} diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/ConfigureData.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/ConfigureData.java new file mode 100644 index 00000000..11b3253e --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/ConfigureData.java @@ -0,0 +1,9 @@ +package org.jeecg.modules.entity.vo; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class ConfigureData implements Serializable { +} diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/EfficiencyData.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/EfficiencyData.java new file mode 100644 index 00000000..587e672f --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/EfficiencyData.java @@ -0,0 +1,18 @@ +package org.jeecg.modules.entity.vo; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class EfficiencyData implements Serializable { + + private String Energy; + + private String Efficiency; + + private String Fit; + + private String Delta; + +} diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/EnergyData.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/EnergyData.java new file mode 100644 index 00000000..47704580 --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/EnergyData.java @@ -0,0 +1,18 @@ +package org.jeecg.modules.entity.vo; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class EnergyData implements Serializable { + + public String channel; + + public String Energy; + + public String Fit; + + public String Delta; + +} diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/GStoreMiddleProcessData.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/GStoreMiddleProcessData.java new file mode 100644 index 00000000..ee5980d9 --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/GStoreMiddleProcessData.java @@ -0,0 +1,423 @@ +package org.jeecg.modules.entity.vo; + +import lombok.Data; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +@Data +public class GStoreMiddleProcessData implements Serializable { + + public boolean dbWriteFlag; //数据库存储标示 例如 + public String dbWriteStatusFlag; //数据写入状态标示 例如 P U F 等 + public String ErrorInfo; //错误信息 + //gards_analyses数据表数据 + public String IdAnalysis; //分析ID号 + public String sample_id; //样品ID号 + public String analyses_analysisBegin; //分析开始时 + public String analyses_analysisEnd; //分析的结束时间 + public String analyses_type; //Reviewed:交互 Auto:自动 + public String analyses_software; //使用的软件 + public String analyses_swVersion; //软件版本号 + public String analyses_analyst; //分析员名称 + public String analyses_baseline_filePath; //基线数据路径 + public String analyses_lc_filePath; //lc数据基线路径 + public String analyses_scac_filePath; //scac数据路径 + public String analyses_save_filePath; //原始文件存储文件名 + public String analyses_baselineMethod; //基线计数方 + public String analyses_peaksMethod; //寻峰方法描 + public String analyses_nuclideMethod; //核素识别方 + public String analyses_uncCalcMethod; //不确定度计 + public String analyses_lcMethod; //Lc计算方法 + public String analyses_LogPath; //日志路径 + public String analyses_ReportPath; //报告路径 + + public String analyses_baseline_absolute_filePath; //基线数据绝对路径 + public String analyses_lc_absolute_filePath; //lc数据基线绝对路径 + public String analyses_scac_absolute_filePath; //scac数据绝对路径 + public String analyses_save_absolute_filePath; //原始文件存储绝对文件名 + public String analyses_absolute_LogPath; //日志绝对路径 + public String analyses_absolute_ReportPath; //报告绝对路径 + + public double analyses_searchStartChannel; //寻峰起始道 + public double analyses_searchEndChannel; //寻峰结束道 + public double analyses_searchThreshold; //寻峰阈值 + public double analyses_numberOfPeaks; //峰数目 + public double analyses_totalCounts; //总计数 未知 + public double analyses_category; //分级结果 + public String analyses_comments; //注释 + + //gards_ calibration_pairs数据表 + public String calibration_pairs_sample_type; //G:gamma探测器的数据,#g_;B:beta探测器的数据,#b_ + + public String calibration_pairs_E_Caltype; //energy:能量刻度 + public String calibration_pairs_E_Input; //PHD:代表数据来自PHD文件;External:代表数据来自外部,如刻度工具、其它文件等 + public List calibration_pairs_E_idCalPoint; //刻度点ID号 + public List calibration_pairs_E_xValue; // + public List calibration_pairs_E_yValue; // + public List calibration_pairs_E_uncYValue; // + + public String calibration_pairs_EF_Caltype; //Efficiency:效率刻度; + public String calibration_pairs_EF_Input; //PHD:代表数据来自PHD文件;External:代表数据来自外部,如刻度工具、其它文件等 + public List calibration_pairs_EF_idCalPoint; //刻度点ID号 + public List calibration_pairs_EF_xValue; // + public List calibration_pairs_EF_yValue; // + public List calibration_pairs_EF_uncYValue; // + + public String calibration_pairs_R_Caltype; //Resolution:分辨率刻度; + public String calibration_pairs_R_Input; //PHD:代表数据来自PHD文件;External:代表数据来自外部,如刻度工具、其它文件等 + public List calibration_pairs_R_idCalPoint; //刻度点ID号 + public List calibration_pairs_R_xValue; // + public List calibration_pairs_R_yValue; // + public List calibration_pairs_R_uncYValue; // + + public String calibration_pairs_T_Caltype; //TotalEfficiency:总效率刻度; + public String calibration_pairs_T_Input; //PHD:代表数据来自PHD文件;External:代表数据来自外部,如刻度工具、其它文件等 + public List calibration_pairs_T_idCalPoint; //刻度点ID号 + public List calibration_pairs_T_xValue; // + public List calibration_pairs_T_yValue; // + public List calibration_pairs_T_uncYValue; // + + //原始谱 数据 + public String calibration_pairs_S_E_Caltype; //energy:能量刻度 + public String calibration_pairs_S_E_Input; //PHD:代表数据来自PHD文件;External:代表数据来自外部,如刻度工具、其它文件等 + public List calibration_pairs_S_E_idCalPoint; //刻度点ID号 + public List calibration_pairs_S_E_xValue; // + public List calibration_pairs_S_E_yValue; // + public List calibration_pairs_S_E_uncYValue; // + + public String calibration_pairs_S_EF_Caltype; //Efficiency:效率刻度; + public String calibration_pairs_S_EF_Input; //PHD:代表数据来自PHD文件;External:代表数据来自外部,如刻度工具、其它文件等 + public List calibration_pairs_S_EF_idCalPoint; //刻度点ID号 + public List calibration_pairs_S_EF_xValue; // + public List calibration_pairs_S_EF_yValue; // + public List calibration_pairs_S_EF_uncYValue; // + + public String calibration_pairs_S_R_Caltype; //Resolution:分辨率刻度; + public String calibration_pairs_S_R_Input; //PHD:代表数据来自PHD文件;External:代表数据来自外部,如刻度工具、其它文件等 + public List calibration_pairs_S_R_idCalPoint; //刻度点ID号 + public List calibration_pairs_S_R_xValue; // + public List calibration_pairs_S_R_yValue; // + public List calibration_pairs_S_R_uncYValue; // + + public String calibration_pairs_S_T_Caltype; //TotalEfficiency:总效率刻度; + public String calibration_pairs_S_T_Input; //PHD:代表数据来自PHD文件;External:代表数据来自外部,如刻度工具、其它文件等 + public List calibration_pairs_S_T_idCalPoint; //刻度点ID号 + public List calibration_pairs_S_T_xValue; // + public List calibration_pairs_S_T_yValue; // + public List calibration_pairs_S_T_uncYValue; // + + //gards_ calibration 数据表 + public String calibration_sample_type; //G:gamma探测器的数据,#g_;B:beta探测器的数据,#b_ + public String calibration_E_Caltype; //energy:能量刻度 + public double calibration_E_function; //拟合方程ID号(统一定义) + public String calibration_E_functionTypeDef; //函数类型描述 + public String calibration_E_functionDef; //拟合方程描述 + public double calibration_E_startOfRange; //拟合的起始值 + public double calibration_E_endOfRange; //拟合的结束值 + public String calibration_E_coeff_string; //拟合系数 + public String calibration_E_uncoeff_string; //拟合系数1不确定度 + + public String calibration_EF_Caltype; //Efficiency:效率刻度; + public double calibration_EF_function; //拟合方程ID号(统一定义) + public String calibration_EF_functionTypeDef; //函数类型描述 + public String calibration_EF_functionDef; //拟合方程描述 + public double calibration_EF_startOfRange; //拟合的起始值 + public double calibration_EF_endOfRange; //拟合的结束值 + public String calibration_EF_coeff_string; //拟合系数 + public String calibration_EF_uncoeff_string; //拟合系数1不确定度 + + public String calibration_R_Caltype; //Resolution:分辨率刻度; + public double calibration_R_function; //拟合方程ID号(统一定义) + public String calibration_R_functionTypeDef; //函数类型描述 + public String calibration_R_functionDef; //拟合方程描述 + public double calibration_R_startOfRange; //拟合的起始值 + public double calibration_R_endOfRange; //拟合的结束值 + public String calibration_R_coeff_string; //拟合系数 + public String calibration_R_uncoeff_string; //拟合系数1不确定度 + + public String calibration_T_Caltype; //TotalEfficiency:总效率刻度; + public double calibration_T_function; //拟合方程ID号(统一定义) + public String calibration_T_functionTypeDef; //函数类型描述 + public String calibration_T_functionDef; //拟合方程描述 + public double calibration_T_startOfRange; //拟合的起始值 + public double calibration_T_endOfRange; //拟合的结束值 + public String calibration_T_coeff_string; //拟合系数 + public String calibration_T_uncoeff_string; //拟合系数1不确定度 + + //gards_ peaks数据表 + public List peaks_idPeak; //峰序号 + public List peaks_peakCentroid; //峰中心道(道址) + public List peaks_uncpeakCentroid; //峰中心道不确定度(道址) + public List peaks_Energy; //峰中心道能量(keV) + public List peaks_uncEnergy; //峰中心道能量不确定度(keV) + public List peaks_Area; //峰面积(计数)。已扣除基线面积,但未扣除空白样品计数和探测器本底计数 + public List peaks_areaErr; //峰面积不确定度(以计数为单位) + public List peaks_netCountRate; //峰的净计数率(1/s)=峰面积/活时间 未知 + public List peaks_uncNetCountRate; //峰的净计数率的不确定度(1/s) 未知 + public List peaks_Efficiency; //测量系统在峰能量处的绝对效率 + public List peaks_Uncefficiency; //测量系统在峰能量处的绝对效率的不确定度 + public List peaks_Fwhm; //峰的半高宽(keV) + public List peaks_Fwhmc; //峰的半高宽(Channel) + public List peaks_Significance; //峰的灵敏度 + public List peaks_Sensitivity; //重峰序号 + public List peaks_multiIndex; //峰的感兴趣区的起始道left + public List peaks_ROIstart; //峰的感兴趣区的结束道right + public List peaks_ROIend; //峰序号 + public List peaks_tail; // + public List peaks_tailAlpha; // + public List peaks_upperTail; // + public List peaks_upperTailAlpha; // + public List peaks_BWWidthChan; // + public List peaks_recoilBetaChan; + public List peaks_recoilDeltaChan; // + public List peaks_stepRatio; // + public List peaks_backgroundArea; //在峰区域下的基线面积(计数) + public List peaks_meanBackCount; //基线面积/道数(计数) + public List peaks_Lc; //峰的可探测线Lc + public List peaks_Ld; //峰的可探测线Ld + public List peaks_Nuclide_name; //文件名称 + public List peaks_comments; + // gards_ nucl_lines_ided数据表 + private Map nucl_lines_ided_data; + //gards_ nucl_ided数据表 + public List nucl_ided_Nuclidename; // 核素名称 + public List nucl_ided_Type; //核素类型 未知 + public List nucl_ided_Halflife; //核素半衰期 + public List nucl_ided_ave_activ; //平均活度值NULL + public List nucl_ided_ave_activ_err; //平均活度值不确定度NULL + public List nucl_ided_activ_key; //主射线活度值 未知 + public List nucl_ided_activ_key_err; //主射线活度值不确定度 + public List nucl_ided_mda; //核素的最小可探测活度 + public List nucl_ided_mda_err; //核素的最小可探测活度不确定度 + public List nucl_ided_nid_flag; //核素识别标志未知 + public List nucl_ided_csc_ratio; //符合相加校正因子(无设为1) + public List nucl_ided_csc_ratio_err; //符合相加校正因子不确定度(无设为0) + public List nucl_ided_csc_mod_flag; //活度是否经过符合相加校正0 + public List nucl_ided_MDC; + public List nucl_ided_Concentration; + public List nucl_ided_Key_Energy; // + public List nucl_ided_Key_Yield; // + + //GARDS_QC_CHECK + public List QC_CHECK_QC_NAME; + public List QC_CHECK_QC_VALUE; + public List QC_CHECK_QC_STANDARD; + public List QC_CHECK_QC_RESULT; + + //sample information + public String sample_collection_start; + public String sample_collection_stop; + public String sample_time; + public String sample_quantity; + public String sample_decay_time; + public String sample_acquisiton_start; + public String sample_acquistion_stop; + + public String sample_acquistion_time; + public String sample_Geometry; + public String sample_Avg_Flow_Rate; + public String sample_stationID; // + public String sample_detectID; // + public String sample_Type; // + + public String Collection_Station_Comments; + public String NDC_Analysis_General_Comments; + + //SpecSetup + public SpecSetup setting_specSetup; + + public GStoreMiddleProcessData(){ + dbWriteFlag = false; + dbWriteStatusFlag = ""; + ErrorInfo = ""; + IdAnalysis = ""; + sample_id = ""; + analyses_analysisBegin = ""; + analyses_analysisEnd = ""; + analyses_type = ""; + analyses_software = ""; + analyses_swVersion = ""; + analyses_analyst = ""; + analyses_baseline_filePath = ""; + analyses_lc_filePath = ""; + analyses_scac_filePath = ""; + analyses_save_filePath = ""; + analyses_baselineMethod = ""; + analyses_peaksMethod = ""; + analyses_nuclideMethod = ""; + analyses_uncCalcMethod = ""; + analyses_lcMethod = ""; + analyses_LogPath = ""; + analyses_ReportPath = ""; + analyses_baseline_absolute_filePath = ""; + analyses_lc_absolute_filePath = ""; + analyses_scac_absolute_filePath = ""; + analyses_save_absolute_filePath = ""; + analyses_absolute_LogPath = ""; + analyses_absolute_ReportPath = ""; + analyses_searchStartChannel = 0; + analyses_searchEndChannel = 0; + analyses_searchThreshold = 0; + analyses_numberOfPeaks = 0; + analyses_totalCounts = 0; + analyses_category = 0; + analyses_comments = ""; + calibration_pairs_sample_type = ""; + calibration_pairs_E_Caltype = ""; + calibration_pairs_E_Input = ""; + calibration_pairs_E_idCalPoint = new LinkedList<>(); + calibration_pairs_E_xValue = new LinkedList<>(); + calibration_pairs_E_yValue = new LinkedList<>(); + calibration_pairs_E_uncYValue = new LinkedList<>(); + calibration_pairs_EF_Caltype = ""; + calibration_pairs_EF_Input = ""; + calibration_pairs_EF_idCalPoint = new LinkedList<>(); + calibration_pairs_EF_xValue = new LinkedList<>(); + calibration_pairs_EF_yValue = new LinkedList<>(); + calibration_pairs_EF_uncYValue = new LinkedList<>(); + calibration_pairs_R_Caltype = ""; + calibration_pairs_R_Input = ""; + calibration_pairs_R_idCalPoint = new LinkedList<>(); + calibration_pairs_R_xValue = new LinkedList<>(); + calibration_pairs_R_yValue = new LinkedList<>(); + calibration_pairs_R_uncYValue = new LinkedList<>(); + calibration_pairs_T_Caltype = ""; + calibration_pairs_T_Input = ""; + calibration_pairs_T_idCalPoint = new LinkedList<>(); + calibration_pairs_T_xValue = new LinkedList<>(); + calibration_pairs_T_yValue = new LinkedList<>(); + calibration_pairs_T_uncYValue = new LinkedList<>(); + calibration_pairs_S_E_Caltype = ""; + calibration_pairs_S_E_Input = ""; + calibration_pairs_S_E_idCalPoint = new LinkedList<>(); + calibration_pairs_S_E_xValue = new LinkedList<>(); + calibration_pairs_S_E_yValue = new LinkedList<>(); + calibration_pairs_S_E_uncYValue = new LinkedList<>(); + calibration_pairs_S_EF_Caltype = ""; + calibration_pairs_S_EF_Input = ""; + calibration_pairs_S_EF_idCalPoint = new LinkedList<>(); + calibration_pairs_S_EF_xValue = new LinkedList<>(); + calibration_pairs_S_EF_yValue = new LinkedList<>(); + calibration_pairs_S_EF_uncYValue = new LinkedList<>(); + calibration_pairs_S_R_Caltype = ""; + calibration_pairs_S_R_Input = ""; + calibration_pairs_S_R_idCalPoint = new LinkedList<>(); + calibration_pairs_S_R_xValue = new LinkedList<>(); + calibration_pairs_S_R_yValue = new LinkedList<>(); + calibration_pairs_S_R_uncYValue = new LinkedList<>(); + calibration_pairs_S_T_Caltype = ""; + calibration_pairs_S_T_Input = ""; + calibration_pairs_S_T_idCalPoint = new LinkedList<>(); + calibration_pairs_S_T_xValue = new LinkedList<>(); + calibration_pairs_S_T_yValue = new LinkedList<>(); + calibration_pairs_S_T_uncYValue = new LinkedList<>(); + calibration_sample_type = ""; + calibration_E_Caltype = ""; + calibration_E_function = 0; + calibration_E_functionTypeDef = ""; + calibration_E_functionDef = ""; + calibration_E_startOfRange = 0; + calibration_E_endOfRange = 0; + calibration_E_coeff_string = ""; + calibration_E_uncoeff_string = ""; + calibration_EF_Caltype = ""; + calibration_EF_function = 0; + calibration_EF_functionTypeDef = ""; + calibration_EF_functionDef = ""; + calibration_EF_startOfRange = 0; + calibration_EF_endOfRange = 0; + calibration_EF_coeff_string = ""; + calibration_EF_uncoeff_string = ""; + calibration_R_Caltype = ""; + calibration_R_function = 0; + calibration_R_functionTypeDef = ""; + calibration_R_functionDef = ""; + calibration_R_startOfRange = 0; + calibration_R_endOfRange = 0; + calibration_R_coeff_string = ""; + calibration_R_uncoeff_string = ""; + calibration_T_Caltype = ""; + calibration_T_function = 0; + calibration_T_functionTypeDef = ""; + calibration_T_functionDef = ""; + calibration_T_startOfRange = 0; + calibration_T_endOfRange = 0; + calibration_T_coeff_string = ""; + calibration_T_uncoeff_string = ""; + peaks_idPeak = new LinkedList<>(); + peaks_peakCentroid = new LinkedList<>(); + peaks_uncpeakCentroid = new LinkedList<>(); + peaks_Energy = new LinkedList<>(); + peaks_uncEnergy = new LinkedList<>(); + peaks_Area = new LinkedList<>(); + peaks_areaErr = new LinkedList<>(); + peaks_netCountRate = new LinkedList<>(); + peaks_uncNetCountRate = new LinkedList<>(); + peaks_Efficiency = new LinkedList<>(); + peaks_Uncefficiency = new LinkedList<>(); + peaks_Fwhm = new LinkedList<>(); + peaks_Fwhmc = new LinkedList<>(); + peaks_Significance = new LinkedList<>(); + peaks_Sensitivity = new LinkedList<>(); + peaks_multiIndex = new LinkedList<>(); + peaks_ROIstart = new LinkedList<>(); + peaks_ROIend = new LinkedList<>(); + peaks_tail = new LinkedList<>(); + peaks_tailAlpha = new LinkedList<>(); + peaks_upperTail = new LinkedList<>(); + peaks_upperTailAlpha = new LinkedList<>(); + peaks_BWWidthChan = new LinkedList<>(); + peaks_recoilBetaChan = new LinkedList<>(); + peaks_recoilDeltaChan = new LinkedList<>(); + peaks_stepRatio = new LinkedList<>(); + peaks_backgroundArea = new LinkedList<>(); + peaks_meanBackCount = new LinkedList<>(); + peaks_Lc = new LinkedList<>(); + peaks_Ld = new LinkedList<>(); + peaks_Nuclide_name = new LinkedList<>(); + peaks_comments = new LinkedList<>(); + nucl_lines_ided_data = new HashMap<>(); + nucl_ided_Nuclidename = new LinkedList<>(); + nucl_ided_Type = new LinkedList<>(); + nucl_ided_Halflife = new LinkedList<>(); + nucl_ided_ave_activ = new LinkedList<>(); + nucl_ided_ave_activ_err = new LinkedList<>(); + nucl_ided_activ_key = new LinkedList<>(); + nucl_ided_activ_key_err = new LinkedList<>(); + nucl_ided_mda = new LinkedList<>(); + nucl_ided_mda_err = new LinkedList<>(); + nucl_ided_nid_flag = new LinkedList<>(); + nucl_ided_csc_ratio = new LinkedList<>(); + nucl_ided_csc_ratio_err = new LinkedList<>(); + nucl_ided_csc_mod_flag = new LinkedList<>(); + nucl_ided_MDC = new LinkedList<>(); + nucl_ided_Concentration = new LinkedList<>(); + nucl_ided_Key_Energy = new LinkedList<>(); + nucl_ided_Key_Yield = new LinkedList<>(); + QC_CHECK_QC_NAME = new LinkedList<>(); + QC_CHECK_QC_VALUE = new LinkedList<>(); + QC_CHECK_QC_STANDARD = new LinkedList<>(); + QC_CHECK_QC_RESULT = new LinkedList<>(); + sample_collection_start = ""; + sample_collection_stop = ""; + sample_time = ""; + sample_quantity = ""; + sample_decay_time = ""; + sample_acquisiton_start = ""; + sample_acquistion_stop = ""; + sample_acquistion_time = ""; + sample_Geometry = ""; + sample_Avg_Flow_Rate = ""; + sample_stationID = ""; + sample_detectID = ""; + sample_Type = ""; + Collection_Station_Comments = ""; + NDC_Analysis_General_Comments = ""; + setting_specSetup = new SpecSetup(); + } + +} diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/GStoreMiddleProcessDataNuclLinesIded.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/GStoreMiddleProcessDataNuclLinesIded.java new file mode 100644 index 00000000..114f1931 --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/GStoreMiddleProcessDataNuclLinesIded.java @@ -0,0 +1,51 @@ +package org.jeecg.modules.entity.vo; + +import lombok.Data; + +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; + +@Data +public class GStoreMiddleProcessDataNuclLinesIded implements Serializable { + + // gards_ nucl_lines_ided数据表 + public List nuclideFullname; //FullName + public List idPeak; //峰序号 + public List Energy; //核素库中核素对应的能量(keV) + public List uncEnergy; //核素库中核素对应峰的能量不确定度(keV) + public List Abundance; //核素库中核素对应峰的发射几率 + public List uncAbundance; //核素库中核素对应峰的发射几率不确定度 + public List Activity; //利用该峰计算得到的活度 + public List uncActivity; //利用该峰计算得到的活度不确定度 + public List Effic; //该峰处的探测效率 + public List uncEffic; //该峰处的探测效率不确定度 + public List Mda; //利用该峰计算得到的最小可探测活度 + public List key_flag; //主射线标识:0-否;1-是 + public List csc_ratio; //符合相加校正因子(无设为1) + public List csc_ratio_err; //符合相加校正因子不确定度(无设为0) + public List csc_mod_flag; //活度是否经过符合相加校正0 未知 + public List MDC; + public List Concentration; + + public GStoreMiddleProcessDataNuclLinesIded(){ + nuclideFullname = new LinkedList<>(); + idPeak = new LinkedList<>(); + Energy = new LinkedList<>(); + uncEnergy = new LinkedList<>(); + Abundance = new LinkedList<>(); + uncAbundance = new LinkedList<>(); + Activity = new LinkedList<>(); + uncActivity = new LinkedList<>(); + Effic = new LinkedList<>(); + uncEffic = new LinkedList<>(); + Mda = new LinkedList<>(); + key_flag = new LinkedList<>(); + csc_ratio = new LinkedList<>(); + csc_ratio_err = new LinkedList<>(); + csc_mod_flag = new LinkedList<>(); + MDC = new LinkedList<>(); + Concentration = new LinkedList<>(); + } + +} diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/InputData.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/InputData.java new file mode 100644 index 00000000..75544e33 --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/InputData.java @@ -0,0 +1,18 @@ +package org.jeecg.modules.entity.vo; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class InputData implements Serializable { + + private Double energy; + + private Double TotalEffi; + + private Double PeakEffi; + + private Double uncertain; + +} diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/NuclideActMda.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/NuclideActMda.java index 71b93797..78ddf098 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/NuclideActMda.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/NuclideActMda.java @@ -9,26 +9,42 @@ import java.util.List; @Data public class NuclideActMda implements Serializable { private boolean bCalculateMDA; + private int calculateIdx; + private int key_flag; // 第 key_flag 条射线是主射线,从 0 开始编号, key_flag < 0 表示无主射线 + private double halflife; + private double activity; + private double act_err; + private double mda; + private double mdc; + private double efficiency; + private double effi_err; + private double concentration; + private List fullNames; + private List vEnergy; // 匹配的γ射线能量 + private List vUncertE; + private List vYield; // 匹配的γ射线分支比 + private List vUncertY; + private List vPeakIdx; // 匹配的峰序号, 从 1 开始 public NuclideActMda() { bCalculateMDA = false; - calculateIdx = -1; + calculateIdx = 0; key_flag = -1; halflife = 0.0; activity = 0.0; diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/PHDFile.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/PHDFile.java index 512618b8..29b4fd5f 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/PHDFile.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/PHDFile.java @@ -1,5 +1,6 @@ package org.jeecg.modules.entity.vo; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.Data; import java.io.Serializable; @@ -9,92 +10,140 @@ import java.util.List; import java.util.Map; @Data +@JsonIgnoreProperties(ignoreUnknown = true) public class PHDFile implements Serializable { private boolean isValid; // 是否有效谱 + private boolean bAnalyed; // 记录是否被分析 + private String analy_start_time; private String filename; // 谱文件名称 + private String filepath; // 谱文件路径 + private String log_path; + private String report_path; + private String baseline_path; + private String lc_path; + private String scac_path; + private String totalCmt; // 谱文件总注释 + private String oriTotalCmt;// 原始谱总注释 - SpecSetup usedSetting; // 当前使用的分析设置 + private SpecSetup usedSetting; // 当前使用的分析设置 - SpecSetup setting; // 新修改的分析设置 + private SpecSetup setting; // 新修改的分析设置 // 分析结果 private List vPeak; + private List vEnergy; + private List vBase; + private List vLc; + private List vScac; - //stdvec vFwhm; - //stdvec vFwhmc; - BaseControls baseCtrls; + + private BaseControls baseCtrls; // 当前修改的刻度名称 private String newEner; + private String newReso; + private String newEffi; + private String newTotE; // 当前寻峰结果所用的刻度名称 private String usedEner; + private String usedReso; + private String usedEffi; + private String usedTotE; // 当前寻峰结果所用的刻度数据 private GEnergyBlock usedEnerKD; + private GResolutionBlock usedResoKD; + private GEfficiencyBlock usedEffiKD; + private TotaleffBlock usedTotEKD; // 存储所有的刻度数据 private Map mapEnerKD; // 能量刻度 + private Map mapResoKD; // 分辨率刻度 + private Map mapEffiKD; // 效率刻度 + private Map mapTotEKD; // 总效率刻度 // 当前寻峰结果所用的刻度参数 private ParameterInfo usedEnerPara; + private ParameterInfo usedResoPara; + private ParameterInfo usedEffiPara; + private ParameterInfo usedTotEPara; // 存储所有的刻度参数 private Map mapEnerPara; + private Map mapResoPara; + private Map mapEffiPara; + private Map mapTotEPara; // 其他参数,目前存储的是默认值 private ParameterInfo para_stepRatio; + private ParameterInfo para_tail; + private ParameterInfo para_tailAlpha; + private ParameterInfo para_tailRight; + private ParameterInfo para_tailRightAlpha; // 谱基本信息 private String id_sample; + private String id_analysis; + private String status; + private String category; + private HeaderBlock header; + private MessageInfo msgInfo; + private GSpectrumBlock Spec; + private AcquisitionBlock acq; + private CollectionBlock collect; + private ProcessingBlock process; + private CalibrationBlock calibration; + private SampleBlock sampleBlock; + private CertificateBlock certificate; // QC Check diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/PeakInfo.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/PeakInfo.java index da44b300..78758e4e 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/PeakInfo.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/PeakInfo.java @@ -53,9 +53,9 @@ public class PeakInfo implements Serializable { public double BWWidthChan; - public double recoilBetaChan; + public String recoilBetaChan; - public double recoilDeltaChan; + public String recoilDeltaChan; public String comments; diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/ResolutionData.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/ResolutionData.java new file mode 100644 index 00000000..621314f3 --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/ResolutionData.java @@ -0,0 +1,18 @@ +package org.jeecg.modules.entity.vo; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class ResolutionData implements Serializable { + + private String Energy; + + private String FWHM; + + private String Fit; + + private String Delta; + +} diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/SpecSetup.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/SpecSetup.java index e95f0bbd..b2974a65 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/SpecSetup.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/SpecSetup.java @@ -1,6 +1,8 @@ package org.jeecg.modules.entity.vo; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; import java.util.Date; @@ -34,8 +36,12 @@ public class SpecSetup implements Serializable { private boolean KeepCalPeakSearchPeaks; + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date refTime_act; //活度参考时间,默认是AcqStartTime + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date refTime_conc; //默认是CollectStartTime public SpecSetup(){ diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/TableAssociation.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/TableAssociation.java new file mode 100644 index 00000000..7b46a3ef --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/TableAssociation.java @@ -0,0 +1,14 @@ +package org.jeecg.modules.entity.vo; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class TableAssociation implements Serializable { + + private String exLevel; + + private String identified; + +} diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/TableDaughter.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/TableDaughter.java new file mode 100644 index 00000000..32b3000b --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/TableDaughter.java @@ -0,0 +1,16 @@ +package org.jeecg.modules.entity.vo; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class TableDaughter implements Serializable { + + private String daughters; + + private String branchingratios; + + private String daughtersstable; + +} diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/TableNuclideActivity.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/TableNuclideActivity.java new file mode 100644 index 00000000..318d827e --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/TableNuclideActivity.java @@ -0,0 +1,30 @@ +package org.jeecg.modules.entity.vo; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class TableNuclideActivity implements Serializable { + + private String nuclide; + + private String halfLife; + + private String energy; + + private String yield; + + private String efficiency; + + private String activity; + + private String actErr; + + private String mda; + + private String conc; + + private String mdc; + +} diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/TablePeak.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/TablePeak.java new file mode 100644 index 00000000..ecf7c0d8 --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/TablePeak.java @@ -0,0 +1,28 @@ +package org.jeecg.modules.entity.vo; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class TablePeak implements Serializable { + + private String energy; + + private String centroid; + + private String multiplet; + + private String FWHM; + + private String netArea; + + private String areaErr; + + private String significant; + + private String sensitivity; + + private String indentify; + +} diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/TablePeakFit.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/TablePeakFit.java new file mode 100644 index 00000000..0198391c --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/TablePeakFit.java @@ -0,0 +1,26 @@ +package org.jeecg.modules.entity.vo; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class TablePeakFit implements Serializable { + + private String energy; + + private String energyErr; + + private String netArea; + + private String areaErr; + + private String netCountRate; + + private String ncRateErr; + + private String lc; + + private String significance; + +} diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/TableQCResult.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/TableQCResult.java new file mode 100644 index 00000000..c67d472a --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/TableQCResult.java @@ -0,0 +1,18 @@ +package org.jeecg.modules.entity.vo; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class TableQCResult implements Serializable { + + private String name; + + private String flag; + + private double value; + + private String standard; + +} diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/TableResult.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/TableResult.java new file mode 100644 index 00000000..74528fd3 --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/entity/vo/TableResult.java @@ -0,0 +1,28 @@ +package org.jeecg.modules.entity.vo; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class TableResult implements Serializable { + + private String nuclide; + + private String activity; + + private String actErr; + + private String factor1; + + private String confidence1; + + private String conc; + + private String concErr; + + private String factor2; + + private String confidence2; + +} diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SpectrumAnalysisMapper.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SpectrumAnalysisMapper.java index ccfb1425..410a331c 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SpectrumAnalysisMapper.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SpectrumAnalysisMapper.java @@ -3,6 +3,8 @@ package org.jeecg.modules.mapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Param; +import org.jeecg.modules.base.entity.configuration.GardsNuclLib; +import org.jeecg.modules.base.entity.configuration.GardsNuclLinesLib; import org.jeecg.modules.base.entity.rnman.GardsAnalySetting; import org.jeecg.modules.entity.*; import org.jeecg.modules.entity.vo.*; @@ -82,4 +84,19 @@ public interface SpectrumAnalysisMapper { List ReadROIResults(@Param(value = "dbName") String dbName, @Param(value = "idAnalysis") Integer idAnalysis, @Param(value = "sampleId") Integer sampleId); List ReadXeResults(@Param(value = "dbName") String dbName, @Param(value = "idAnalysis") Integer idAnalysis, @Param(value = "sampleId") Integer sampleId); + + List getFULLNuclideNames(@Param(value = "min") Double min, @Param(value = "max") Double max); + + List getRelevantNuclideNames(@Param(value = "min") Double min, @Param(value = "max") Double max); + + List getNuclideNames(@Param(value = "dbName") String dbName); + + List getNuclideLine(@Param(value = "min") Double min, @Param(value = "max") Double max, @Param(value = "name") String name); + + GardsNuclLib getNuclideInfo(@Param(value = "name") String name); + + GardsNuclLib getParentAndDaughter(@Param(value = "name") String name); + + String findAutomaticLogPath(@Param(value = "sampleId") Integer sampleId); + } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SysDefaultNuclideSpectrumMapper.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SysDefaultNuclideSpectrumMapper.java new file mode 100644 index 00000000..d8a60926 --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/SysDefaultNuclideSpectrumMapper.java @@ -0,0 +1,13 @@ +package org.jeecg.modules.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; +import org.jeecg.modules.base.entity.postgre.SysDefaultNuclide; + +import java.util.List; + +public interface SysDefaultNuclideSpectrumMapper extends BaseMapper { + + List findNuclidesByUserName(@Param(value = "userName") String userName); + +} diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/xml/SpectrumAnalysisMapper.xml b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/xml/SpectrumAnalysisMapper.xml index bd0e3323..c0664265 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/xml/SpectrumAnalysisMapper.xml +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/xml/SpectrumAnalysisMapper.xml @@ -585,4 +585,82 @@ AND XE_RESULTS.SAMPLE_ID = #{sampleId} + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/xml/SysDefaultNuclideSpectrumMapper.xml b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/xml/SysDefaultNuclideSpectrumMapper.xml new file mode 100644 index 00000000..c3346a4f --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/mapper/xml/SysDefaultNuclideSpectrumMapper.xml @@ -0,0 +1,16 @@ + + + + + + + + \ No newline at end of file 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 d9237fae..eb75e9a2 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 @@ -1,8 +1,12 @@ package org.jeecg.modules.service; import org.jeecg.common.api.vo.Result; +import org.jeecg.modules.entity.vo.CoeffData; +import org.jeecg.modules.entity.vo.InputData; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.List; public interface IGammaService{ @@ -12,4 +16,44 @@ public interface IGammaService{ Result Reprocessing(Integer sampleId); + Result InteractiveTool(Integer sampleId); + + Result ZeroTime(Integer sampleId); + + Result Korsum(); + + List KorSumInput(CoeffData coeffData); + + Result energyCalibration(Integer sampleId); + + Result resolutionCalibration(Integer sampleId); + + Result EfficiencyCalibration(Integer sampleId); + + Result NuclideLibrary(String editEnergy, double err, String libraryName, String nuclideName, HttpServletRequest request); + + Result configUserLibrary(HttpServletRequest request); + + Result viewComment(Integer sampleId); + + Result peakInformation(Integer sampleId); + + Result viewARR(Integer sampleId, HttpServletResponse response); + + Result viewRRR(Integer sampleId); + + Result radionuclideActivity(Integer sampleId); + + Result Spectrum(Integer sampleId); + + Result sampleInformation(Integer sampleId); + + Result viewQCResult(Integer sampleId); + + Result viewRLR(Integer sampleId); + + Result viewAutomaticAnalysisLog(Integer sampleId, HttpServletResponse response); + + Result viewGammaviewerLog(Integer sampleId); + } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISysDefaultNuclideSpectrumService.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISysDefaultNuclideSpectrumService.java new file mode 100644 index 00000000..3716dae7 --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/ISysDefaultNuclideSpectrumService.java @@ -0,0 +1,12 @@ +package org.jeecg.modules.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import org.jeecg.modules.base.entity.postgre.SysDefaultNuclide; + +import java.util.List; + +public interface ISysDefaultNuclideSpectrumService extends IService { + + List findNuclidesByUserName(String userName); + +} 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 c8075123..17fd16e7 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 @@ -1,40 +1,70 @@ package org.jeecg.modules.service.impl; +import cn.hutool.core.util.ObjectUtil; import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.StringPool; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.google.common.cache.Cache; +import org.apache.commons.net.ftp.FTPClient; +import org.apache.commons.net.ftp.FTPFile; import org.jeecg.common.api.vo.Result; +import org.jeecg.common.cache.LocalCache; +import org.jeecg.common.properties.SpectrumPathProperties; import org.jeecg.common.system.util.JwtUtil; +import org.jeecg.common.util.DateUtils; +import org.jeecg.common.util.FTPUtil; import org.jeecg.common.util.GammaFileUtil; import org.jeecg.common.util.RedisUtil; -import org.jeecg.modules.entity.vo.NuclideLines; -import org.jeecg.modules.entity.vo.PHDFile; -import org.jeecg.modules.entity.vo.SpecSetup; +import org.jeecg.modules.base.entity.configuration.GardsNuclLinesLib; +import org.jeecg.modules.entity.vo.*; +import org.jeecg.modules.mapper.SpectrumAnalysisMapper; +import org.jeecg.modules.native_jni.CalValuesHandler; import org.jeecg.modules.service.IGammaService; +import org.jeecg.modules.service.ISysDefaultNuclideSpectrumService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.InputStream; +import java.text.ParseException; +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; @Service(value = "gammaService") @DS("ora") public class GammaServiceImpl implements IGammaService { @Autowired - private RedisUtil redisUtil; + private LocalCache localCache; @Autowired private GammaFileUtil gammaFileUtil; + @Autowired + private ISysDefaultNuclideSpectrumService defaultNuclideSpectrumService; + @Autowired + private SpectrumAnalysisMapper spectrumAnalysisMapper; + @Autowired + private SpectrumPathProperties spectrumPathProperties; + @Autowired + private FTPUtil ftpUtil; + @Value("${ZeroTime}") + private String ZeroTimeStr; @Override public Result gammaByDB(String dbName, Integer sampleId) { Result result = new Result(); Map map = new HashMap<>(); + Cache phdCache = localCache.getPHDCache(); PHDFile phd = new PHDFile(); //读取文件内容 gammaFileUtil.loadFile(sampleId, phd, result); + //声明基础数组信息 + gammaFileUtil.SetBaseInfo(phd, sampleId); //从数据库中读取相关信息 ---- 目前代码未完善 gammaFileUtil.getResultFromDB(dbName, sampleId, phd, result); // 更新 ‘QC Flags’ 状态 @@ -50,7 +80,8 @@ public class GammaServiceImpl implements IGammaService { 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); - redisUtil.set("Gamma : Gamma_"+sampleId, phd); + phdCache.put(sampleId.toString(), phd); + localCache.setPHDCache(phdCache); result.setSuccess(true); result.setResult(map); return result; @@ -59,7 +90,12 @@ public class GammaServiceImpl implements IGammaService { @Override public Result configure(Integer sampleId) { Result result = new Result(); - PHDFile phd = (PHDFile) redisUtil.get("Gamma_" + sampleId); + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(sampleId.toString()); + if (Objects.isNull(phd)){ + result.error500("请先选择解析文件!"); + return result; + } Map map = new HashMap<>(); // 用当前谱使用的设置初始化界面控件 SpecSetup setup = phd.getUsedSetting(); @@ -94,4 +130,877 @@ public class GammaServiceImpl implements IGammaService { return null; } + @Override + public Result InteractiveTool(Integer sampleId) { + Result result = new Result(); + Map map = new HashMap<>(); + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(sampleId.toString()); + if (Objects.isNull(phd)){ + result.error500("请先选择解析文件!"); + return result; + } + //表单 + List vPeak = phd.getVPeak(); + map.put("table", vPeak); + //Chart 折线图 + List m_vCount = new LinkedList<>(); + long m_nCount = phd.getSpec().getNum_g_channel(); + long m_nSChan = phd.getSpec().getBegin_channel(); + // 确保绘制曲线时所有谱都是从1道开始 + int i = 0; + if(m_nSChan == 0){ + i = 1; + } + for(; i channelPeakChart = gammaFileUtil.Channel_Peak(phd, m_nCount); + List channelBaseCPChart = gammaFileUtil.Channel_BaseCP(phd); + map.put("channelCountChart", channelCountChart); + map.put("channelBaseLineChart", channelBaseLineChart); + map.put("channelPeakChart", channelPeakChart); + map.put("channelBaseCPChart", channelBaseCPChart); + //Bar Chart 柱状图 + List differance = gammaFileUtil.Differance(phd, vPeak, m_vCount, m_nCount); + map.put("barChart", differance); + + result.setSuccess(true); + result.setResult(map); + return result; + } + + @Override + public Result ZeroTime(Integer sampleId) { + Result result = new Result(); + Map map = new HashMap<>(); + List zeroTimeList = new LinkedList<>(); + if (StringUtils.isNotBlank(ZeroTimeStr)){ + zeroTimeList = Arrays.asList(ZeroTimeStr.split(StringPool.COMMA)); + } + map.put("list_fission1", zeroTimeList); + map.put("list_fission2", zeroTimeList); + LocalDateTime now = LocalDateTime.now(); + map.put("Date", now.getYear()+"-"+now.getMonthValue()+"-"+now.getDayOfMonth()); + map.put("Time", now.getHour()+":"+now.getMinute()+":"+now.getSecond()); + result.setSuccess(true); + result.setResult(map); + return result; + } + + @Override + public Result Korsum() { + Result result = new Result(); + Map map = new HashMap<>(); + //读取文件获取Energy Nuclide数据 + List m_vEnergy = new LinkedList<>(); + List m_vNuclide = new LinkedList<>(); + gammaFileUtil.ReadData(m_vEnergy, m_vNuclide); + CoeffData coeffData = new CoeffData(); + coeffData.setTotalEf1(-0.024326); + coeffData.setTotalEf2(-1.857587); + coeffData.setTotalEf3(0.111096); + coeffData.setTotalEf4(-0.003896); + coeffData.setTotalEf5(-0.000345); + coeffData.setTotalEf6(0.000017); + coeffData.setEffciency1(-0.329812); + coeffData.setEffciency2(-3.493192); + coeffData.setEffciency3(0.583265); + coeffData.setEffciency4(-0.065884); + coeffData.setEffciency5(0.003255); + coeffData.setEffciency6(-0.000059); + coeffData.setEnergys(m_vEnergy); + List input = this.KorSumInput(coeffData); + map.put("Energy", input); + map.put("Nuclide", m_vNuclide); + result.setSuccess(true); + result.setResult(map); + return result; + } + + @Override + public List KorSumInput(CoeffData coeffData) { + double ener, effi, totE; + List vTotE = new LinkedList<>(); + vTotE.add(0.005); + vTotE.add(0.01); + vTotE.add(0.02); + List vEffi = new LinkedList<>(); + vEffi.add(0.002); + vEffi.add(0.0045); + vEffi.add(0.008); + List energys = coeffData.energys; + List inputDataList = new LinkedList<>(); + for(int i=0; i< energys.size(); ++i) { + InputData data = new InputData(); + // 将 keV 转换成 MeV + ener = energys.get(i)/1000; + // 如果能量小于34keV,则放弃计算 + if(ener < 0.034) { + if(i < 3) { + data.setTotalEffi(vTotE.get(i)); + data.setPeakEffi(vEffi.get(i)); + } else { + data.setTotalEffi(null); + data.setPeakEffi(null); + } + }else { + effi = Math.exp( coeffData.Effciency1*ener + coeffData.Effciency2 + coeffData.Effciency3/ener + coeffData.Effciency4/Math.pow(ener,2) + coeffData.Effciency5/Math.pow(ener, 3) + coeffData.Effciency6/Math.pow(ener, 4) ); + totE = Math.exp( coeffData.totalEf1*ener + coeffData.totalEf2 + coeffData.totalEf3/ener + coeffData.totalEf4/Math.pow(ener,2) + coeffData.totalEf5/Math.pow(ener, 3) + coeffData.totalEf6/Math.pow(ener, 4) ); + data.setTotalEffi(totE); + data.setPeakEffi(effi); + } + data.setEnergy(energys.get(i)); + data.setUncertain(10.0); + inputDataList.add(data); + } + return inputDataList; + } + + @Override + public Result energyCalibration(Integer sampleId) { + Result result = new Result(); + Map map = new HashMap<>(); + System.loadLibrary("GammaAnaly"); + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(sampleId.toString()); + if (Objects.isNull(phd)){ + result.error500("请先选择解析文件!"); + return result; + } + String usedEner = phd.getUsedEner(); + List dataSourceList = phd.getMapEnerKD().keySet().stream().collect(Collectors.toList()); + map.put("list_dataSource", dataSourceList); + List m_vCurCentroid = phd.getMapEnerKD().get(usedEner).getCentroid_channel(); + List m_vCurEnergy = phd.getMapEnerKD().get(usedEner).getG_energy(); + ParameterInfo m_curParam = phd.getMapEnerPara().get(usedEner); + + int num = m_vCurEnergy.size(); + if(num < 1){ + return result; + } + + List vFit = CalValuesHandler.calFcnEval(m_vCurCentroid, m_curParam.getP()).counts; + List energyDataList = new LinkedList<>(); + for(int i=0; i map = new HashMap<>(); + System.loadLibrary("GammaAnaly"); + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(sampleId.toString()); + if (Objects.isNull(phd)){ + result.error500("请先选择解析文件!"); + return result; + } + String usedReso = phd.getUsedReso(); + List dataSourceList = phd.getMapResoKD().keySet().stream().collect(Collectors.toList()); + map.put("list_dataSource", dataSourceList); + List m_vCurReso = phd.getMapResoKD().get(usedReso).getFWHM(); + List m_vCurEnergy = phd.getMapResoKD().get(usedReso).getG_energy(); + ParameterInfo m_curParam = phd.getMapResoPara().get(usedReso); + + int num = m_vCurEnergy.size(); + if(num < 1){ + return result; + } + + List vFit = CalValuesHandler.calFcnEval(m_vCurEnergy, m_curParam.getP()).counts; + List resolutionDataList = new LinkedList<>(); + for(int i=0; i map = new HashMap<>(); + List m_vFuncName = new LinkedList<>(); + m_vFuncName.add("Interpolation"); // 1 + m_vFuncName.add("HT Efficiency"); // 5 + m_vFuncName.add("Log Polynomial"); // 6 + m_vFuncName.add("Invlog Polynomial"); // 8 + m_vFuncName.add("HAE Efficiency(1-3)"); // 93 + m_vFuncName.add("HAE Efficiency(1-2)"); // 94 + m_vFuncName.add("HAE Efficiency(1-2-3)"); // 95 + map.put("function", m_vFuncName); + System.loadLibrary("GammaAnaly"); + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(sampleId.toString()); + if (Objects.isNull(phd)){ + result.error500("请先选择解析文件!"); + return result; + } + String usedEffi = phd.getUsedEffi(); + List dataSourceList = phd.getMapEffiKD().keySet().stream().collect(Collectors.toList()); + map.put("list_dataSource", dataSourceList); + List m_vCurEffi = phd.getMapEffiKD().get(usedEffi).getEfficiency(); + List m_vCurEnergy = phd.getMapEffiKD().get(usedEffi).getG_energy(); + ParameterInfo m_curParam = phd.getMapEffiPara().get(usedEffi); + + int num = m_vCurEnergy.size(); + if(num < 1){ + return result; + } + + List vFit = CalValuesHandler.calFcnEval(m_vCurEnergy, m_curParam.getP()).counts; + List efficiencyDataList = new LinkedList<>(); + for(int i=0; i map = new HashMap<>(); + String userName = JwtUtil.getUserNameByToken(request); + List nuclides = new LinkedList<>(); + //判断传入的数据是否都不为空 + if (StringUtils.isNotBlank(editEnergy) && Objects.nonNull(err)){ + double editEnergyDou = Double.valueOf(editEnergy); + double min = editEnergyDou - err; + double max = editEnergyDou + err; + if (libraryName.equals("UserLibrary")){ + //从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的 + nuclides = defaultNuclideSpectrumService.findNuclidesByUserName(userName); + if (CollectionUtils.isEmpty(nuclides)){ + nuclides = defaultNuclideSpectrumService.findNuclidesByUserName("admin"); + } + }else if (libraryName.equals("FULLLibrary")){ + nuclides = spectrumAnalysisMapper.getFULLNuclideNames(min, max); + }else if (libraryName.equals("RelevantLibrary")){ + nuclides = spectrumAnalysisMapper.getRelevantNuclideNames(min, max); + } + }else { + if(libraryName.equals("UserLibrary")) { + //从postgreSql中获取当前用户关注的核素信息 如果当前用户没有 则返回管理员的 + nuclides = defaultNuclideSpectrumService.findNuclidesByUserName(userName); + if (CollectionUtils.isEmpty(nuclides)){ + nuclides = defaultNuclideSpectrumService.findNuclidesByUserName("admin"); + } + } else if (libraryName.equals("FULLLibrary")){ + nuclides = spectrumAnalysisMapper.getNuclideNames("CONFIGURATION.GARDS_NUCL_LIB"); + } else if (libraryName.equals("RelevantLibrary")){ + nuclides = spectrumAnalysisMapper.getNuclideNames("CONFIGURATION.GARDS_RELEVANT_NUCLIDE"); + } + } + map.put("nuclides", nuclides); + if (StringUtils.isBlank(nuclideName)){ + nuclideName = nuclides.get(0); + } + List nuclLinesLibs = gammaFileUtil.InitNuclideLine(editEnergy, err, nuclideName); + map.put("nuclLinesLibs", nuclLinesLibs); + Map nuclideInfo = gammaFileUtil.InitNuclideInfo(nuclideName); + map.put("nuclideInfo", nuclideInfo); + Map daughter = gammaFileUtil.InitParentAndDaughter(nuclideName); + map.put("daughter", daughter); + result.setSuccess(true); + result.setResult(map); + return result; + } + + @Override + public Result configUserLibrary(HttpServletRequest request) { + Result result = new Result(); + Map> map = new HashMap<>(); + String userName = JwtUtil.getUserNameByToken(request); + List nuclides = spectrumAnalysisMapper.getNuclideNames("CONFIGURATION.GARDS_NUCL_LIB"); + List userNuclides = defaultNuclideSpectrumService.findNuclidesByUserName(userName); + if (CollectionUtils.isEmpty(userNuclides)){ + userNuclides = defaultNuclideSpectrumService.findNuclidesByUserName("admin"); + } + map.put("AllNuclides", nuclides); + map.put("UserNuclides", userNuclides); + result.setSuccess(true); + result.setResult(map); + return result; + } + + @Override + public Result viewComment(Integer sampleId) { + Result result = new Result(); + String comments = ""; + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(sampleId.toString()); + if (Objects.isNull(phd)){ + result.error500("请先选择解析文件!"); + return result; + } + String temp = phd.getOriTotalCmt().trim(); + if(StringUtils.isNotBlank(temp)) { + comments += "Comments From Original Spectrum:\n" + temp; + } + if(Objects.nonNull(sampleId)) { + CommentData commentData = spectrumAnalysisMapper.viewComment(sampleId); + if(Objects.nonNull(commentData)) { + temp = commentData.getComment()==null?"":commentData.getComment().trim(); + if(StringUtils.isNotBlank(temp)) { + comments += "\n\nComments From "+commentData.getAnalyst()+"\n:"+temp; + } + } + } + result.setSuccess(true); + result.setResult(comments); + return result; + } + + public Result peakInformation(Integer sampleId){ + Result result = new Result(); + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(sampleId.toString()); + if (Objects.isNull(phd)){ + result.error500("请先选择解析文件!"); + return result; + } + List vPeak = phd.getVPeak(); + List tablePeaks = new LinkedList<>(); + if (CollectionUtils.isNotEmpty(vPeak)){ + for (PeakInfo peak: vPeak){ + TablePeak tablePeak = new TablePeak(); + tablePeak.setEnergy(String.format("%.3f", peak.energy)); + tablePeak.setCentroid(String.format("%.3f", peak.peakCentroid)); + tablePeak.setMultiplet(String.valueOf(peak.multiIndex)); + tablePeak.setFWHM(String.format("%.3f", peak.fwhm)); + tablePeak.setNetArea(String.format("%.3f", peak.area)); + tablePeak.setAreaErr(peak.area>0?String.format("%.3f",(peak.areaErr/peak.area)*100):"0"); + tablePeak.setSignificant(String.format("%.3f", peak.significance)); + tablePeak.setSensitivity(String.format("%.3f", peak.sensitivity)); + List nuclides = peak.nuclides; + String nuclide = ""; + if (CollectionUtils.isNotEmpty(nuclides)){ + for (String name:nuclides) { + nuclide+=name+StringPool.COMMA; + } + nuclide = nuclide.substring(0, nuclide.length()-1); + } + tablePeak.setIndentify(nuclide); + tablePeaks.add(tablePeak); + } + } + result.setSuccess(true); + result.setResult(tablePeaks); + return result; + } + + @Override + public Result viewARR(Integer sampleId, HttpServletResponse response) { + Result result = new Result(); + if(Objects.isNull(sampleId)) { + result.error500("The file isn't existed."); + return result; + } + //获取自动处理生成的报告地址 + String reportPath = spectrumAnalysisMapper.viewARR(sampleId); + if(StringUtils.isBlank(reportPath.trim())) { + result.error500("The file isn't existed."); + return result; + } + String pathName = reportPath.substring(0, reportPath.lastIndexOf(StringPool.SLASH)); + String fileName = reportPath.substring(reportPath.lastIndexOf(StringPool.SLASH)+1)+".txt"; + //连接ftp + FTPClient ftpClient = ftpUtil.LoginFTP(); + if (Objects.isNull(ftpClient)){ + throw new RuntimeException("ftp连接失败"); + } + InputStream inputStream = null; + ServletOutputStream outputStream = null; + try { + //切换被动模式 + ftpClient.enterLocalPassiveMode(); + ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); + // 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项 + ftpClient.setControlEncoding("UTF-8"); + ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); + pathName=StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + pathName; + ftpClient.changeWorkingDirectory(pathName); + List ftpFiles = Arrays.asList(ftpClient.listFiles()); + ftpFiles=ftpFiles.stream().filter(item -> item.getName().equals(fileName)).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(ftpFiles)){ + throw new RuntimeException("ftp下对应的报告文件不存在"); + } + FTPFile ftpFile = ftpFiles.get(0); + if (Objects.nonNull(ftpFile)){ + inputStream = ftpClient.retrieveFileStream(ftpFile.getName()); + outputStream = response.getOutputStream(); + byte[] buffer = new byte[1024]; + int bytesRead; + // 将文件输出流写入到输出流中 + while ((bytesRead = inputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, bytesRead); + } + } + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + try { + if (Objects.nonNull(ftpClient)){ + ftpClient.disconnect(); + } + if (ObjectUtil.isNotNull(inputStream)){ + inputStream.close(); + } + if (ObjectUtil.isNotNull(outputStream)){ + outputStream.close(); + } + } catch (IOException e) { + throw new RuntimeException(e); + } + } + result.setSuccess(true); + return result; + } + + @Override + public Result viewRRR(Integer sampleId) { + Result result = new Result(); + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(sampleId.toString()); + if (Objects.isNull(phd)){ + result.error500("请先选择解析文件!"); + return result; + } + String reportContent = gammaFileUtil.GetReportContent(phd, false); + result.setSuccess(true); + result.setResult(reportContent); + return result; + } + + @Override + public Result radionuclideActivity(Integer sampleId) { + Result result = new Result(); + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(sampleId.toString()); + if (Objects.isNull(phd)){ + result.error500("请先选择解析文件!"); + return result; + } + Map map = gammaFileUtil.UpdateDatasNuclideActivity(phd.getMapNucActMda(), phd.getUsedSetting().getRefTime_act(), phd.getUsedSetting().getRefTime_conc()); + result.setSuccess(true); + result.setResult(map); + return result; + } + + @Override + public Result Spectrum(Integer sampleId) { + Result result = new Result(); + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(sampleId.toString()); + if (Objects.isNull(phd)){ + result.error500("请先选择解析文件!"); + return result; + } + String spectrum = gammaFileUtil.MakeUpSpectrum(phd); + result.setSuccess(true); + result.setResult(spectrum); + return result; + } + + @Override + public Result sampleInformation(Integer sampleId) { + Result result = new Result(); + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(sampleId.toString()); + if (Objects.isNull(phd)){ + result.error500("请先选择解析文件!"); + return result; + } + Map map = new HashMap<>(); + try { + String collect_start = phd.getCollect().getCollection_start_date() + " " + phd.getCollect().getCollection_start_time(); + String collect_stop = phd.getCollect().getCollection_stop_date() + " " + phd.getCollect().getCollection_stop_time(); + String acq_start = phd.getAcq().getAcquisition_start_date() + " " + phd.getAcq().getAcquisition_start_time(); + Date collect_stop_dt = DateUtils.parseDate(collect_stop.substring(0, collect_stop.indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); + Date collect_start_dt = DateUtils.parseDate(collect_start.substring(0, collect_start.indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); + double Sampling_Time = (collect_start_dt.getTime()/1000 - collect_stop_dt.getTime()/1000) / 3600.0; + + Date acq_start_dt = DateUtils.parseDate(acq_start.substring(0, acq_start.indexOf(StringPool.DOT)), "yyyy/MM/dd HH:mm:ss"); + double Decay_Time = (collect_stop_dt.getTime()/1000 - acq_start_dt.getTime()/1000) / 3600.0; + + String acq_stop = DateUtils.formatDate(new Date((long) (acq_start_dt.getTime()/1000 + phd.getAcq().getAcquisition_live_time())), "yyyy/MM/dd HH:mm:ss"); + + map.put("stationId", phd.getHeader().getSite_code()); + map.put("sampleId", phd.getId_sample()); + map.put("sampleQuantity", String.format("%.2f", phd.getCollect().getAir_volume())+" m3"); + map.put("collectStart", collect_start); + map.put("collectStop", collect_stop); + map.put("acquisitionStart", acq_start); + map.put("acquisitionStop", acq_stop); + + map.put("detectorId", phd.getHeader().getDetector_code()); + map.put("sampleGeometry", phd.getHeader().getSample_geometry()); + map.put("sampleType", phd.getHeader().getSystem_type()); + map.put("samplingTime", String.format("%.2f", Sampling_Time)+" hours"); + map.put("decayTime", String.format("%.2f", Decay_Time)+" hours"); + map.put("acquisitionTime", String.format("%.2f", phd.getAcq().getAcquisition_real_time() / 3600.0)+" hours"); + map.put("avgFlowRate", String.format("%.2f", phd.getCollect().getAir_volume() / Sampling_Time)+" m3/hour"); + } catch (ParseException e) { + throw new RuntimeException(e); + } + result.setSuccess(true); + result.setResult(map); + return result; + } + + @Override + public Result viewQCResult(Integer sampleId) { + Result result = new Result(); + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(sampleId.toString()); + if (Objects.isNull(phd)){ + result.error500("请先选择解析文件!"); + return result; + } + Map m_mapQC = phd.getQcItems(); + int size_map = m_mapQC.size(); + if(size_map < 1){ + return result; + } + List qcResultList = new LinkedList<>(); + for(Map.Entry iter: m_mapQC.entrySet()){ + TableQCResult item = new TableQCResult(); + String name = iter.getKey(); + if(name.equals("Ba140-MDC")){ + name += " (uBq/m3)"; + } else if(name.equals("Be7-FWHM")){ + name += " (keV)"; + } else if(name.equals("Xe133-MDC")){ + name += " (uBq/m3)"; + } else if(name.equals("acq_time")){ + name += " (h)"; + } else if(name.equals("airFlow")){ + name += " (m3/h)"; + } else if(name.equals("col_time")){ + name += " (h)"; + } else if(name.equals("decay_time")){ + name += " (h)"; + } else if(name.equals("samp_vol")){ + name += " (m3)"; + } + item.setName(name); + + item.setFlag(iter.getValue().isBPass() ? "PASS" : "FAIL"); + + item.setValue(iter.getValue().getValue()); + + String standard=""; + List strList = Arrays.asList(iter.getValue().getStandard().split(StringPool.COMMA)); + for (String str : strList) { + if(str.contains("-")) { + if(str.contains("(") || str.contains("[")){ + standard += iter.getKey(); + } + } else if(str.contains("(")) { + standard += str.replace("(", "") + " < " + iter.getKey(); + } + else if(str.contains(")")) + { + standard += " < " + str.replace(")", ""); + } + else if(str.contains("[")) + { + standard += str.replace("[", "") + " <= " + iter.getKey(); + } + else if(str.contains("]")) + { + standard += " <= " + str.replace("]", ""); + } + } + item.setStandard(standard); + qcResultList.add(item); + } + result.setSuccess(true); + result.setResult(qcResultList); + return result; + } + + @Override + public Result viewRLR(Integer sampleId) { + Result result = new Result(); + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(sampleId.toString()); + if (Objects.isNull(phd)){ + result.error500("请先选择解析文件!"); + return result; + } + Map map = new HashMap<>(); + Date curTime = new Date(); + String responsible_person = "wang shilian"; + String software = "GammaAnalyser,GammaAnalyALG"; + int num = phd.getVPeak().size(); + + // Init #Header + if(StringUtils.isNotBlank(phd.getMsgInfo().getMsg_id())){ + // 1: MSG_ID + map.put("header_msg_id", phd.getMsgInfo().getMsg_id()); + } + map.put("header_data_type", "MINIRLR"); // 2: DataType + map.put("header_priority_level", "Routine"); // 3: Priority Level + if(StringUtils.isNotBlank(phd.getHeader().getSite_code())){ + // 4: Station code + map.put("header_station_code", phd.getHeader().getSite_code()); + } + if(StringUtils.isNotBlank(phd.getHeader().getSample_ref_id())){ + // 5: SRID + map.put("header_srid", phd.getHeader().getSample_ref_id()); + } + map.put("header_lab_code", "CNL06"); // 6: Laboratory Code + map.put("header_lab_detector", "CNL06_001"); // 7: Laboratory Detector Code + map.put("header_report_type", "FIN"); // 8: Report Type + map.put("header_report_number", "1"); // 9: Report Number + map.put("header_sample_category", "Category C"); // 10:Sample Category + map.put("header_transmission", curTime); // 11:Message Transmission Time + // Init #Objective + map.put("Obj_purpose", "The purpose of this analysis is proficiency test."); + map.put("Obj_authorized", "High-resolution non-destructive gamma spectroscopy."); + map.put("Obj_instruction", "`0"); + // Init #Collection + String col_start = phd.getCollect().getCollection_start_date() + " " + phd.getCollect().getCollection_start_time(); + String col_stop = phd.getCollect().getCollection_stop_date() + " " + phd.getCollect().getCollection_stop_time(); + map.put("collect_start", col_start); + map.put("collect_stop", col_stop); + map.put("collect_airVolume", phd.getCollect().getAir_volume()); + // Init #SampleReceipt + if(StringUtils.isNotBlank(phd.getHeader().getSample_ref_id())){ + map.put("Receipt_srid", phd.getHeader().getSample_ref_id()); + } + map.put("Receipt_sealNum", "0"); + map.put("Receipt_sample", curTime); + map.put("Receipt_package", "Parcel."); + map.put("Receipt_seal", "Good."); + map.put("Receipt_sample", "Good."); + // Init #Test + map.put("Test_type", "Analysis of a reference sample."); + map.put("Test_completion", curTime); + map.put("Test_person", responsible_person); + map.put("Test_purpose", "The purpose of this analysis is proficiency test exercise."); + // Init #PeaksMethod + map.put("PeakMethod_software", software); + map.put("PeakMethod_location", "0"); + // Init #PeakFit + List peakFitList = new LinkedList<>(); + String energy_uncert = "-9999"; + double live_time = phd.getAcq().getAcquisition_live_time(); + for(int i=0; i 0 ? String.valueOf(peak.areaErr/peak.area*100) : "0"; + tablePeak.setAreaErr(area_err); + String rate = live_time > 0 ? String.valueOf(peak.area/live_time) : "0"; + tablePeak.setNetCountRate(rate); + tablePeak.setNcRateErr(area_err); + tablePeak.setLc(String.valueOf(peak.lc)); + tablePeak.setSignificance(String.valueOf(peak.significance)); + peakFitList.add(tablePeak); + } + map.put("peakFit", peakFitList); + // Init #g_AnalysisMethods + map.put("AnalyMethod_software", software); + map.put("AnalyMethod_nuclide", "Interactive"); + map.put("AnalyMethod_baseline", "GammaAnalyALG"); + map.put("AnalyMethod_lc", "CTBT/PTS/INF.96/Rev.6"); + map.put("AnalyMethod_calib", "0"); + // Init #PeakAssociation + String Explanation_Level = "100.000"; + List associationList = new LinkedList<>(); + for(int i=0; i nuclides = phd.getVPeak().get(i).nuclides; + String iden = ""; + for (String str:nuclides) { + iden+=str+","; + } + iden = iden.length()>0?iden.substring(0, iden.length()-1):""; + tableAssociation.setIdentified(iden); + associationList.add(tableAssociation); + } + map.put("Association", associationList); + // Init #References + if(StringUtils.isNotBlank(phd.getHeader().getMeasurement_id())) { + map.put("Reference_samplePHD", phd.getHeader().getMeasurement_id()); + map.put("Reference_CalibPHD", phd.getHeader().getMeasurement_id()); + } + map.put("Reference_physical", "Table of Isotopes CD ROM Edition, Version 1.0, March,1998"); + // Init #Results + String coverage_factor = "2.00"; + String level_confidence = "95.00"; + + map.put("Result_act_ref", phd.getUsedSetting().getRefTime_act()); + map.put("Result_conc_ref", phd.getUsedSetting().getRefTime_conc()); + List tableResultList = new LinkedList<>(); + for(Map.Entry it : phd.getMapNucActMda().entrySet()){ + if(it.getValue().isBCalculateMDA()) { + TableResult tableResult = new TableResult(); + NuclideActMda nuc = it.getValue(); + tableResult.setNuclide(it.getKey()); + tableResult.setActivity(String.valueOf(nuc.getActivity())); + String act_err = nuc.getActivity() > 0 ? String.valueOf(nuc.getAct_err()/nuc.getActivity()*100) : "0"; + tableResult.setActErr(act_err); + tableResult.setFactor1(coverage_factor); + tableResult.setConfidence1(level_confidence); + tableResult.setConc(String.valueOf(nuc.getConcentration()/1000)); + tableResult.setConcErr(act_err); + tableResult.setFactor2(coverage_factor); + tableResult.setConfidence2(level_confidence); + tableResultList.add(tableResult); + } + } + map.put("Result", tableResultList); + // Init #NuclideRatios + // Init #g_CoincidenceCorrection + // Init #MDA + // Init #Conclusions + map.put("conclusion_person", responsible_person); + map.put("Conclusion_IDC", "0"); + List listNuc = phd.getMapNucActMda().keySet().stream().collect(Collectors.toList()); + String nuc = ""; + for (String str:listNuc) { + nuc+=str+","; + } + map.put("Conclusion_Lab", "The nuclides "+nuc.substring(0, nuc.length()-1)+" are identified in the reference sample definitely."); + map.put("Conclusion_Res", "0"); + // Init #Comment + map.put("Comment", "0"); + + result.setSuccess(true); + result.setResult(map); + return result; + } + + @Override + public Result viewAutomaticAnalysisLog(Integer sampleId, HttpServletResponse response) { + Result result = new Result(); + if (Objects.isNull(sampleId)){ + result.error500("The file isn't existed."); + return result; + } + String logPath = spectrumAnalysisMapper.findAutomaticLogPath(sampleId); + if (StringUtils.isBlank(logPath)){ + result.error500("The file isn't existed."); + return result; + } + String pathName = logPath.substring(0, logPath.lastIndexOf(StringPool.SLASH)); + String fileName = logPath.substring(logPath.lastIndexOf(StringPool.SLASH) + 1); + //连接ftp + FTPClient ftpClient = ftpUtil.LoginFTP(); + if (Objects.isNull(ftpClient)){ + throw new RuntimeException("ftp连接失败"); + } + InputStream inputStream = null; + ServletOutputStream outputStream = null; + try { + //切换被动模式 + ftpClient.enterLocalPassiveMode(); + ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); + // 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项 + ftpClient.setControlEncoding("UTF-8"); + ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); + pathName=StringPool.SLASH + spectrumPathProperties.getLogPath() + StringPool.SLASH + pathName; + ftpClient.changeWorkingDirectory(pathName); + List ftpFiles = Arrays.asList(ftpClient.listFiles()); + ftpFiles=ftpFiles.stream().filter(item -> item.getName().equals(fileName)).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(ftpFiles)){ + throw new RuntimeException("ftp下对应的报告文件不存在"); + } + FTPFile ftpFile = ftpFiles.get(0); + if (Objects.nonNull(ftpFile)){ + inputStream = ftpClient.retrieveFileStream(ftpFile.getName()); + outputStream = response.getOutputStream(); + byte[] buffer = new byte[1024]; + int bytesRead; + // 将文件输出流写入到输出流中 + while ((bytesRead = inputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, bytesRead); + } + } + } catch (IOException e) { + throw new RuntimeException(e); + } finally { + try { + if (Objects.nonNull(ftpClient)){ + ftpClient.disconnect(); + } + if (ObjectUtil.isNotNull(inputStream)){ + inputStream.close(); + } + if (ObjectUtil.isNotNull(outputStream)){ + outputStream.close(); + } + } catch (IOException e) { + throw new RuntimeException(e); + } + } + result.setSuccess(true); + return result; + } + + @Override + public Result viewGammaviewerLog(Integer sampleId) { + Result result = new Result(); + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(sampleId.toString()); + if (Objects.isNull(phd)){ + result.error500("请先选择解析文件!"); + return result; + } + String reportContent = gammaFileUtil.GetReportContent(phd, true); + result.setSuccess(true); + result.setResult(reportContent); + return result; + } + } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SysDefaultNuclideSpectrumServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SysDefaultNuclideSpectrumServiceImpl.java new file mode 100644 index 00000000..42863b9b --- /dev/null +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/SysDefaultNuclideSpectrumServiceImpl.java @@ -0,0 +1,30 @@ +package org.jeecg.modules.service.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.jeecg.modules.base.entity.postgre.SysDefaultNuclide; +import org.jeecg.modules.mapper.SysDefaultNuclideSpectrumMapper; +import org.jeecg.modules.service.ISysDefaultNuclideSpectrumService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@Service("defaultNuclideSpectrumService") +@DS("master") +public class SysDefaultNuclideSpectrumServiceImpl extends ServiceImpl implements ISysDefaultNuclideSpectrumService { + + @Override + @Transactional(propagation = Propagation.REQUIRES_NEW) + public List findNuclidesByUserName(String userName) { + //查询当前用户的核素信息 + List nuclides = this.baseMapper.findNuclidesByUserName(userName); + if (CollectionUtils.isEmpty(nuclides)){ + nuclides = this.baseMapper.findNuclidesByUserName("admin"); + } + return nuclides; + } + +}