From 59d063d41533367cb4fd031370a9e6fa4ff6e2fc Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Wed, 20 Sep 2023 16:21:48 +0800 Subject: [PATCH] =?UTF-8?q?GammaController=E5=8A=9F=E8=83=BDEnergy=20Calib?= =?UTF-8?q?ration,Resolution=20Calibration,=20Efficiency=20Calibration?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E6=96=B0=E5=A2=9Ewidth=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E8=AE=A1=E7=AE=97=20GammaController=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=AF=BC=E5=85=A5=E6=9C=AC=E5=9C=B0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=B4=E6=97=B6=E5=8A=A0=E8=BD=BDEnergy=20Calibration,Resolu?= =?UTF-8?q?tion=20Calibration,=20Efficiency=20Calibration=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jeecg/common/util/GammaFileUtil.java | 154 +++++++-- .../modules/controller/GammaController.java | 49 ++- .../jeecg/modules/entity/vo/ChangeData.java | 3 +- .../jeecg/modules/service/IGammaService.java | 24 +- .../service/impl/GammaServiceImpl.java | 312 ++++++++++++++++-- 5 files changed, 464 insertions(+), 78 deletions(-) diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/common/util/GammaFileUtil.java index 18febbd2..8bfcbb30 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 @@ -1502,9 +1502,9 @@ public class GammaFileUtil { NuclidesIdent(phd, nuclideLinesMap); RunQC(phd); String Warning = "Finish three tasks:\n"+ - "\t1.Update efficiencies of all peaks;\n"+ - "\t2.Identify nuclides again;\n"+ - "\t3.Test QC again."; + "\t1.Update efficiencies of all peaks;\n"+ + "\t2.Identify nuclides again;\n"+ + "\t3.Test QC again."; } else { if(bSingle) { // AnalyseFlowChart flow_dlg(this); @@ -2028,7 +2028,7 @@ public class GammaFileUtil { return equation; } - public void UpdateChartEnergy(List m_vCurEnergy, ParameterInfo m_curParam, List m_vCurCentroid, PHDFile phd, Map map) { + public void UpdateChartEnergy(List m_vCurEnergy, ParameterInfo m_curParam, List m_vCurCentroid, PHDFile phd, Double width, Map map) { System.loadLibrary("GammaAnaly"); int num = m_vCurEnergy.size(); if(num < 1){ @@ -2044,7 +2044,7 @@ public class GammaFileUtil { List vChan = new LinkedList<>(); double MaxChan = Double.valueOf(phd.getSpec().getNum_g_channel()); double d = 1; - double dStep = MaxChan / 30 * 2; + double dStep = MaxChan / width * 2; while(d < MaxChan) { vChan.add(d); d+= dStep; @@ -2093,7 +2093,7 @@ public class GammaFileUtil { return equation; } - public void UpdateChartResolution(List m_vCurEnergy, ParameterInfo m_curParam, List m_vCurReso, PHDFile phd, Map map) { + public void UpdateChartResolution(List m_vCurEnergy, ParameterInfo m_curParam, List m_vCurReso, PHDFile phd, Double width, Map map) { System.loadLibrary("GammaAnaly"); int num = m_vCurEnergy.size(); if(num < 1) return; @@ -2111,7 +2111,7 @@ public class GammaFileUtil { List vEner = CalValuesHandler.calFcnEval(vChan, phd.getUsedEnerPara().getP()).counts; double d = vEner.get(0), maxE = vEner.get(1); - double dStep = maxE / 30 * 2; + double dStep = maxE / width * 2; vEner.remove(vEner.size()-1); while(d < maxE) { @@ -2226,7 +2226,7 @@ public class GammaFileUtil { return equation; } - public void UpdateChartEfficiency(List m_vCurEnergy, ParameterInfo m_curParam, List m_vCurEffi, PHDFile phd, Map map) { + public void UpdateChartEfficiency(List m_vCurEnergy, ParameterInfo m_curParam, List m_vCurEffi, PHDFile phd, Double width, Map map) { System.loadLibrary("GammaAnaly"); int num = m_vCurEnergy.size(); if(num < 1) return; @@ -2245,7 +2245,7 @@ public class GammaFileUtil { List vEner = CalValuesHandler.calFcnEval(vChan, phd.getUsedEnerPara().getP()).counts; double d = vEner.get(0); double maxE = vEner.get(1); - double dStep = maxE / 30 * 2; + double dStep = maxE / width * 2; vEner.remove(vEner.size()-1); while(d < maxE) { @@ -3510,7 +3510,7 @@ public class GammaFileUtil { // #Acquisition spectrum.append("#Acquisition\r\n"); spectrum.append(phd.getAcq().getAcquisition_start_date()+StringPool.SPACE+phd.getAcq().getAcquisition_start_time()+ - StringPool.SPACE+RightFill(String.format("%.2f", phd.getAcq().getAcquisition_real_time()), 14)+ + StringPool.SPACE+RightFill(String.format("%.2f", phd.getAcq().getAcquisition_real_time()), 14)+ StringPool.SPACE+RightFill(String.format("%.2f", phd.getAcq().getAcquisition_live_time()), 14)+"\r\n"); // #Processing @@ -3536,15 +3536,15 @@ public class GammaFileUtil { int fieldWidth = 12; for(int i=0; i loadCompareData(String compareFileName, String userName, long m_nCount, Result result) { + List m_vecCompare = new LinkedList<>(); + String compareFilePath = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName; + //连接ftp + FTPClient ftpClient = ftpUtil.LoginFTP(); + if (Objects.isNull(ftpClient)){ + result.error500("ftp连接失败"); + return m_vecCompare; + } + InputStream inputStream = null; + //加载dll工具库 + System.loadLibrary("ReadPHDFile"); + try { + //切换被动模式 + ftpClient.enterLocalPassiveMode(); + ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE); + // 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项 + ftpClient.setControlEncoding("UTF-8"); + ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE); + ftpClient.changeWorkingDirectory(compareFilePath); + List ftpFiles = Arrays.asList(ftpClient.listFiles()); + ftpFiles = ftpFiles.stream().filter(item -> item.getName().equals(compareFileName)).collect(Collectors.toList()); + if (ftpFiles.size() == 0) { + result.error500("ftp获取文件数据失败"); + return m_vecCompare; + } + FTPFile ftpFile = ftpFiles.get(0); + if (Objects.nonNull(ftpFile)) { + inputStream = ftpClient.retrieveFileStream(ftpFile.getName()); + //声明一个临时文件 + File file = File.createTempFile("tmp", null); + //将ftp文件的输入流复制给临时文件 + FileUtils.copyInputStreamToFile(inputStream, file); + //读取文件信息 + EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath()); + //判断当前用来进行比较的文件的#g_Spectrum数量是否与原文件的大小一致 + if (struct.num_g_channel != m_nCount) { + result.error500("We can't compare two Spectrum files if their number of Counts are different!"); + return m_vecCompare; + } + m_vecCompare = struct.g_counts; + if (struct.g_begin_channel == 0) { + m_vecCompare.add(0L); + m_vecCompare.remove(0); + } + } + }catch (IOException e) { + throw new RuntimeException(e); + } finally { + try { + if (Objects.nonNull(ftpClient)){ + ftpClient.disconnect(); + } + if (Objects.nonNull(inputStream)){ + inputStream.close(); + } + } catch (IOException e) { + throw new RuntimeException(e); + } + } + return m_vecCompare; + } + + public List CompareData(List m_vecCompare, long m_nCount, Map colorMap, List vEnergy){ + List datalist = new LinkedList<>(); + int size = m_vecCompare.size(); + if(size == m_nCount) { + ChartData data1 = new ChartData(); + data1.setName("Compare"); + data1.setGroup("channel"); + data1.setColor(colorMap.get("Color_Compare")); + // Compare two Spectrum in Channel + for(int i=0; i KorSumInput(CoeffData coeffData); - Result energyCalibration(Integer sampleId, String fileName, String currentText); + Result energyCalibration(Integer sampleId, String fileName, String currentText, Double width); - Result changeDataEnergy(List m_vCurCentroid, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer sampleId, String fileName); + Result changeDataEnergy(List m_vCurCentroid, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer sampleId, String fileName, Double width); Result applyDataEnergy(List m_vCurCentroid, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, String curCalName, Integer sampleId, String fileName); void saveDataEnergy(List m_vCurCentroid, List m_vCurEnergy, List m_vCurUncert, HttpServletResponse response); - Result resolutionCalibration(Integer sampleId, String fileName, String currentText); + Result callDataEnergy(MultipartFile file, String sampleFileName, Double width, String currentText); - Result changeDataResolution(List m_vCurReso, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer sampleId, String fileName); + Result resolutionCalibration(Integer sampleId, String fileName, String currentText, Double width); + + Result changeDataResolution(List m_vCurReso, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer sampleId, String fileName, Double width); Result applyDataResolution(List m_vCurReso, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, String curCalName, Integer sampleId, String fileName); void saveDataResolution(List m_vCurReso, List m_vCurEnergy, List m_vCurUncert, HttpServletResponse response); - Result EfficiencyCalibration(Integer sampleId, String fileName, String currentText); + Result callDataResolution(MultipartFile file, String sampleFileName, Double width, String currentText); - Result changeDataEfficiency(List m_vCurEffi, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer funcId, Integer sampleId, String fileName); + Result EfficiencyCalibration(Integer sampleId, String fileName, String currentText, Double width); + + Result changeDataEfficiency(List m_vCurEffi, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer funcId, Integer sampleId, String fileName, Double width); Result applyDataEfficiency(List m_vCurEffi, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, String curCalName, Integer sampleId, String fileName); void saveDataEfficiency(List m_vCurEffi, List m_vCurEnergy, List m_vCurUncert, Integer funId, HttpServletResponse response); + Result callDataEfficiency(MultipartFile file, String sampleFileName, Double width, String currentText); + Result NuclideLibrary(Integer sampleId, String fileName, String editEnergy, double err, String libraryName, String nuclideName, HttpServletRequest request); Result configUserLibrary(Integer sampleId, String fileName, HttpServletRequest request); @@ -136,6 +144,6 @@ public interface IGammaService{ Result updateColorConfig(ColorInfo colorInfo, HttpServletRequest request); - Result saveToDB(String fileName, String userName); + Result saveToDB(String fileName, HttpServletRequest request); } diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java index 06107427..ff1cc027 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 @@ -11,6 +11,7 @@ import cn.hutool.core.util.StrUtil; import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.StringPool; +import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; import com.google.common.cache.Cache; import org.apache.commons.net.ftp.FTPClient; @@ -34,6 +35,7 @@ import org.jeecg.modules.service.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; @@ -225,6 +227,27 @@ public class GammaServiceImpl implements IGammaService { return result; } + @Override + public Result Compare(String fileName, String compareFileName, HttpServletRequest request) { + Result result = new Result(); + String userName = JwtUtil.getUserNameByToken(request); + //获取当前角色配置的颜色信息 + Map colorMap = sysUserColorService.initColor(userName); + //获取缓存的phd数据 + Cache phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(fileName); + long m_nCount = phd.getSpec().getNum_g_channel(); + List vEnergy = phd.getVEnergy(); + //获取Compare数据 + List m_vecCompare = gammaFileUtil.loadCompareData(compareFileName, userName, m_nCount, result); + if (CollectionUtils.isNotEmpty(m_vecCompare)) { + List chartDataList = gammaFileUtil.CompareData(m_vecCompare, m_nCount, colorMap, vEnergy); + result.setSuccess(true); + result.setResult(chartDataList); + } + return result; + } + @Override public Result configure(Integer sampleId, String fileName) { Result result = new Result(); @@ -301,8 +324,8 @@ public class GammaServiceImpl implements IGammaService { result.setResult(map); }else { String warning = "The spectrum needn't Analyed. Maybe:\n"+ - "1. It has already Analyed.\n"+ - "2. You didn't change any setting or calibration."; + "1. It has already Analyed.\n"+ + "2. You didn't change any setting or calibration."; result.error500(warning); } return result; @@ -1138,7 +1161,7 @@ public class GammaServiceImpl implements IGammaService { } @Override - public Result energyCalibration(Integer sampleId, String fileName, String currentText) { + public Result energyCalibration(Integer sampleId, String fileName, String currentText, Double width) { Result result = new Result(); Map map = new HashMap<>(); System.loadLibrary("GammaAnaly"); @@ -1181,7 +1204,7 @@ public class GammaServiceImpl implements IGammaService { map.put("table", energyDataList); String equation = gammaFileUtil.UpdateEquationEnergy(m_curParam); map.put("equation", equation); - gammaFileUtil.UpdateChartEnergy(m_vCurEnergy, m_curParam, m_vCurCentroid, phd, map); + gammaFileUtil.UpdateChartEnergy(m_vCurEnergy, m_curParam, m_vCurCentroid, phd, width, map); map.put("rg_low", phd.getBaseCtrls().getRg_low()); map.put("rg_high", phd.getBaseCtrls().getRg_high()); } @@ -1191,7 +1214,7 @@ public class GammaServiceImpl implements IGammaService { } @Override - public Result changeDataEnergy(List m_vCurCentroid, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer sampleId, String fileName) { + public Result changeDataEnergy(List m_vCurCentroid, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer sampleId, String fileName, Double width) { Result result = new Result(); Map map = new HashMap<>(); Cache phdCache = localCache.getPHDCache(); @@ -1200,13 +1223,13 @@ public class GammaServiceImpl implements IGammaService { result.error500("请先选择解析文件!"); return result; } - DataChangeEnergy(m_vCurCentroid, m_vCurEnergy, m_vCurUncert, m_curParam, phd, map); + DataChangeEnergy(m_vCurCentroid, m_vCurEnergy, m_vCurUncert, m_curParam, phd, width, map); result.setSuccess(true); result.setResult(map); return result; } - private void DataChangeEnergy(List m_vCurCentroid, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, PHDFile phd, Map map) { + private void DataChangeEnergy(List m_vCurCentroid, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, PHDFile phd, Double width, Map map) { System.loadLibrary("GammaAnaly"); if(m_vCurEnergy.size() < 1) { return; @@ -1249,7 +1272,7 @@ public class GammaServiceImpl implements IGammaService { map.put("table", energyDataList); String equation = gammaFileUtil.UpdateEquationEnergy(m_curParam); map.put("equation", equation); - gammaFileUtil.UpdateChartEnergy(m_vCurEnergy, m_curParam, m_vCurCentroid, phd, map); + gammaFileUtil.UpdateChartEnergy(m_vCurEnergy, m_curParam, m_vCurCentroid, phd, width, map); } @Override @@ -1283,7 +1306,7 @@ public class GammaServiceImpl implements IGammaService { StringBuffer strBuffer = new StringBuffer(); strBuffer.append("#g_Energy").append("\n"); for (int i=0; i phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(sampleFileName); + if (Objects.nonNull(file)) { + String fileName = file.getOriginalFilename(); + //从最后一个。切割文件名称 获取文件名称后缀 + String fileSuffix = fileName.substring(fileName.lastIndexOf(StringPool.DOT)); + if (fileSuffix.equalsIgnoreCase(".ent")) { + Map map = new HashMap<>(); + List m_vCurCentroid = new LinkedList<>(); + List m_vCurEnergy = new LinkedList<>(); + List m_vCurUncert = new LinkedList<>(); + try { + //创建临时文件 + File tmpFile = File.createTempFile("tmp", null); + //复制上传文件的输入流到临时文件 + FileUtils.copyInputStreamToFile(file.getInputStream() ,tmpFile); + //读取文件所有行 + List readLines = FileUtils.readLines(tmpFile, "UTF-8"); + //遍历文件行数据 + for (int i=0; i values = Arrays.asList(content.split("\t\t")); + m_vCurEnergy.add(Double.valueOf(values.get(0))); + m_vCurCentroid.add(Double.valueOf(values.get(1))); + m_vCurUncert.add(Double.valueOf(values.get(2))); + } + } + } + map.put("uncert", m_vCurUncert); + ParameterInfo m_curParam = new ParameterInfo(); + if (StringUtils.isNotBlank(currentText)) { + m_curParam = phd.getMapEnerPara().get(currentText); + } + map.put("param", m_curParam); + 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"); @@ -1350,7 +1447,7 @@ public class GammaServiceImpl implements IGammaService { map.put("table", resolutionDataList); String equation = gammaFileUtil.UpdateEquationResolution(m_curParam); map.put("equation", equation); - gammaFileUtil.UpdateChartResolution(m_vCurEnergy, m_curParam, m_vCurReso, phd, map); + gammaFileUtil.UpdateChartResolution(m_vCurEnergy, m_curParam, m_vCurReso, phd, width, map); map.put("ECutAnalysis_Low", phd.getSetting().getECutAnalysis_Low()); map.put("G_energy_span", phd.getSpec().getG_energy_span()); } @@ -1360,7 +1457,7 @@ public class GammaServiceImpl implements IGammaService { } @Override - public Result changeDataResolution(List m_vCurReso, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer sampleId, String fileName) { + public Result changeDataResolution(List m_vCurReso, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer sampleId, String fileName, Double width) { Result result = new Result(); Map map = new HashMap<>(); System.loadLibrary("GammaAnaly"); @@ -1370,13 +1467,13 @@ public class GammaServiceImpl implements IGammaService { result.error500("请先选择解析文件!"); return result; } - DataChangeResolution(m_vCurReso, m_vCurEnergy, m_vCurUncert, m_curParam, phd, map); + DataChangeResolution(m_vCurReso, m_vCurEnergy, m_vCurUncert, m_curParam, phd, width, map); result.setSuccess(true); result.setResult(map); return result; } - public void DataChangeResolution(List m_vCurReso, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, PHDFile phd, Map map) { + public void DataChangeResolution(List m_vCurReso, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, PHDFile phd, Double width, Map map) { System.loadLibrary("GammaAnaly"); m_curParam.setP(CalValuesHandler.calFitPara("Cal_Resolution", 4, m_vCurEnergy, m_vCurReso, m_vCurUncert)); map.put("uncert", m_vCurUncert); @@ -1408,7 +1505,7 @@ public class GammaServiceImpl implements IGammaService { map.put("table", resolutionDataList); String equation = gammaFileUtil.UpdateEquationResolution(m_curParam); map.put("equation", equation); - gammaFileUtil.UpdateChartResolution(m_vCurEnergy, m_curParam, m_vCurReso, phd, map); + gammaFileUtil.UpdateChartResolution(m_vCurEnergy, m_curParam, m_vCurReso, phd, width, map); } @Override @@ -1442,7 +1539,7 @@ public class GammaServiceImpl implements IGammaService { StringBuffer strBuffer = new StringBuffer(); strBuffer.append("#g_Resolution").append("\n"); for (int i=0; i phdCache = localCache.getPHDCache(); + PHDFile phd = phdCache.getIfPresent(sampleFileName); + if (Objects.nonNull(file)) { + String fileName = file.getOriginalFilename(); + //从最后一个。切割文件名称 获取文件名称后缀 + String fileSuffix = fileName.substring(fileName.lastIndexOf(StringPool.DOT)); + if (fileSuffix.equalsIgnoreCase(".ent")) { + Map map = new HashMap<>(); + List m_vCurReso = new LinkedList<>(); + List m_vCurEnergy = new LinkedList<>(); + List m_vCurUncert = new LinkedList<>(); + try { + //创建临时文件 + File tmpFile = File.createTempFile("tmp", null); + //复制上传文件的输入流到临时文件 + FileUtils.copyInputStreamToFile(file.getInputStream() ,tmpFile); + //读取文件所有行 + List readLines = FileUtils.readLines(tmpFile, "UTF-8"); + //遍历文件行数据 + for (int i=0; i values = Arrays.asList(content.split("\t\t")); + m_vCurEnergy.add(Double.valueOf(values.get(0))); + m_vCurReso.add(Double.valueOf(values.get(1))); + m_vCurUncert.add(Double.valueOf(values.get(2))); + } + } + } + map.put("uncert", m_vCurUncert); + ParameterInfo m_curParam = new ParameterInfo(); + if (StringUtils.isNotBlank(currentText)) { + m_curParam = phd.getMapResoPara().get(currentText); + } + map.put("param", m_curParam); + 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<>(); @@ -1518,7 +1689,7 @@ public class GammaServiceImpl implements IGammaService { map.put("table", efficiencyDataList); String equation = gammaFileUtil.UpdateEquationEfficiency(m_vCurEnergy, m_curParam); map.put("equation", equation); - gammaFileUtil.UpdateChartEfficiency(m_vCurEnergy, m_curParam, m_vCurEffi, phd, map); + gammaFileUtil.UpdateChartEfficiency(m_vCurEnergy, m_curParam, m_vCurEffi, phd, width, map); map.put("ECutAnalysis_Low", phd.getSetting().getECutAnalysis_Low()); map.put("G_energy_span", phd.getSpec().getG_energy_span()); } @@ -1528,7 +1699,7 @@ public class GammaServiceImpl implements IGammaService { } @Override - public Result changeDataEfficiency(List m_vCurEffi, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer funcId, Integer sampleId, String fileName) { + public Result changeDataEfficiency(List m_vCurEffi, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer funcId, Integer sampleId, String fileName, Double width) { Result result = new Result(); Map map = new HashMap<>(); System.loadLibrary("GammaAnaly"); @@ -1538,13 +1709,13 @@ public class GammaServiceImpl implements IGammaService { result.error500("请先选择解析文件!"); return result; } - DataChangeEfficiency(m_vCurEffi, m_vCurEnergy, m_vCurUncert, m_curParam, funcId, phd, map); + DataChangeEfficiency(m_vCurEffi, m_vCurEnergy, m_vCurUncert, m_curParam, funcId, phd, width, map); result.setSuccess(true); result.setResult(map); return result; } - public void DataChangeEfficiency(List m_vCurEffi, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer funcId, PHDFile phd, Map map) { + public void DataChangeEfficiency(List m_vCurEffi, List m_vCurEnergy, List m_vCurUncert, ParameterInfo m_curParam, Integer funcId, PHDFile phd, Double width, Map map) { System.loadLibrary("GammaAnaly"); m_curParam.setP(CalValuesHandler.calFitPara("Cal_Efficiency", funcId, m_vCurEnergy, m_vCurEffi, m_vCurUncert)); map.put("uncert", m_vCurUncert); @@ -1562,8 +1733,7 @@ public class GammaServiceImpl implements IGammaService { efficiencyData.setDelta(String.format("%.3f", delta)); efficiencyDataList.add(efficiencyData); } - } - else { + } else { for(int i=0; i map = new HashMap<>(); + List m_vCurEffi = new LinkedList<>(); + List m_vCurEnergy = new LinkedList<>(); + List m_vCurUncert = new LinkedList<>(); + Double m_nFunId = 1.0; + try { + //创建临时文件 + File tmpFile = File.createTempFile("tmp", null); + //复制上传文件的输入流到临时文件 + FileUtils.copyInputStreamToFile(file.getInputStream() ,tmpFile); + //读取文件所有行 + List readLines = FileUtils.readLines(tmpFile, "UTF-8"); + //遍历文件行数据 + for (int i=0; i values = Arrays.asList(content.split("\t\t")); + m_vCurEnergy.add(Double.valueOf(values.get(0))); + m_vCurEffi.add(Double.valueOf(values.get(1))); + m_vCurUncert.add(Double.valueOf(values.get(2))); + } + if (content.contains("FitType")) { + List values = Arrays.asList(content.split("=")); + if (values.size() == 2) { + m_nFunId = Double.valueOf(values.get(1)); + } + } + } + } + } + map.put("uncert", m_vCurUncert); + ParameterInfo m_curParam = new ParameterInfo(); + if (StringUtils.isNotBlank(currentText)) { + m_curParam = phd.getMapEffiPara().get(currentText); + } + if (m_curParam.getP().size()>0){ + m_curParam.getP().set(0, m_nFunId); + } else { + m_curParam.getP().add(m_nFunId); + } + map.put("param", m_curParam); + 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 phdCache = localCache.getPHDCache();