GammaController功能Energy Calibration,Resolution Calibration, Efficiency Calibration功能新增width字段进行计算

GammaController新增导入本地文件临时加载Energy Calibration,Resolution Calibration, Efficiency Calibration功能
This commit is contained in:
qiaoqinzheng 2023-09-20 16:21:48 +08:00
parent 89d24abd35
commit 59d063d415
5 changed files with 464 additions and 78 deletions

View File

@ -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<Double> m_vCurEnergy, ParameterInfo m_curParam, List<Double> m_vCurCentroid, PHDFile phd, Map<String, Object> map) {
public void UpdateChartEnergy(List<Double> m_vCurEnergy, ParameterInfo m_curParam, List<Double> m_vCurCentroid, PHDFile phd, Double width, Map<String, Object> map) {
System.loadLibrary("GammaAnaly");
int num = m_vCurEnergy.size();
if(num < 1){
@ -2044,7 +2044,7 @@ public class GammaFileUtil {
List<Double> 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<Double> m_vCurEnergy, ParameterInfo m_curParam, List<Double> m_vCurReso, PHDFile phd, Map<String, Object> map) {
public void UpdateChartResolution(List<Double> m_vCurEnergy, ParameterInfo m_curParam, List<Double> m_vCurReso, PHDFile phd, Double width, Map<String, Object> map) {
System.loadLibrary("GammaAnaly");
int num = m_vCurEnergy.size();
if(num < 1) return;
@ -2111,7 +2111,7 @@ public class GammaFileUtil {
List<Double> 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<Double> m_vCurEnergy, ParameterInfo m_curParam, List<Double> m_vCurEffi, PHDFile phd, Map<String, Object> map) {
public void UpdateChartEfficiency(List<Double> m_vCurEnergy, ParameterInfo m_curParam, List<Double> m_vCurEffi, PHDFile phd, Double width, Map<String, Object> map) {
System.loadLibrary("GammaAnaly");
int num = m_vCurEnergy.size();
if(num < 1) return;
@ -2245,7 +2245,7 @@ public class GammaFileUtil {
List<Double> 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<phd.getCertificate().getG_energy().size(); ++i) {
spectrum.append(phd.getCertificate().getNuclide_name().get(i)+
StringPool.SPACE+phd.getCertificate().getHalf_life_time().get(i)+
StringPool.SPACE+phd.getCertificate().getTime_unit().get(i)+
StringPool.SPACE+phd.getCertificate().getActivity_nuclide_time_assay().get(i)+
StringPool.SPACE+phd.getCertificate().getUncertainty().get(i)+
StringPool.SPACE+phd.getCertificate().getG_energy().get(i)+
StringPool.SPACE+phd.getCertificate().getG_intensity().get(i)+
StringPool.SPACE+phd.getCertificate().getElectron_decay_mode().get(i)+
StringPool.SPACE+phd.getCertificate().getMaximum_energy().get(i)+
StringPool.SPACE+phd.getCertificate().getIntensity_b_particle().get(i)+"\r\n");
StringPool.SPACE+phd.getCertificate().getHalf_life_time().get(i)+
StringPool.SPACE+phd.getCertificate().getTime_unit().get(i)+
StringPool.SPACE+phd.getCertificate().getActivity_nuclide_time_assay().get(i)+
StringPool.SPACE+phd.getCertificate().getUncertainty().get(i)+
StringPool.SPACE+phd.getCertificate().getG_energy().get(i)+
StringPool.SPACE+phd.getCertificate().getG_intensity().get(i)+
StringPool.SPACE+phd.getCertificate().getElectron_decay_mode().get(i)+
StringPool.SPACE+phd.getCertificate().getMaximum_energy().get(i)+
StringPool.SPACE+phd.getCertificate().getIntensity_b_particle().get(i)+"\r\n");
}
}
@ -3559,7 +3559,7 @@ public class GammaFileUtil {
GEnergyBlock g_ener = phd.getUsedEnerKD();
for(int i=0; i<g_ener.getG_energy().size(); ++i) {
spectrum.append(RightFill(String.format("%.9f", Double.valueOf(g_ener.getG_energy().get(i))), 16)+
StringPool.SPACE+RightFill(String.format("%.9f", Double.valueOf(g_ener.getCentroid_channel().get(i))), 16)+
StringPool.SPACE+RightFill(String.format("%.9f", Double.valueOf(g_ener.getCentroid_channel().get(i))), 16)+
StringPool.SPACE+RightFill((Objects.isNull(g_ener.getUncertainty().get(i)) ? "0.5" : String.format("%.9f", Double.valueOf(g_ener.getUncertainty().get(i)))), 16)+"\r\n");
}
@ -3568,7 +3568,7 @@ public class GammaFileUtil {
GResolutionBlock g_reso = phd.getUsedResoKD();
for(int i=0; i<g_reso.getFWHM().size(); ++i) {
spectrum.append(RightFill(String.format("%.9f", Double.valueOf(g_reso.getG_energy().get(i))), 16)+
StringPool.SPACE+RightFill(String.format("%.9f", Double.valueOf(g_reso.getFWHM().get(i))), 16)+
StringPool.SPACE+RightFill(String.format("%.9f", Double.valueOf(g_reso.getFWHM().get(i))), 16)+
StringPool.SPACE+RightFill((Objects.isNull(g_reso.getUncertainty().get(i)) ? "0.5" : String.format("%.9f", Double.valueOf(g_reso.getUncertainty().get(i)))), 16)+"\r\n");
}
@ -3577,7 +3577,7 @@ public class GammaFileUtil {
GEfficiencyBlock g_effi = phd.getUsedEffiKD();
for(int i=0; i<g_effi.getEfficiency().size(); ++i) {
spectrum.append(RightFill(String.format("%.9f", Double.valueOf(g_effi.getG_energy().get(i))), 16)+
StringPool.SPACE+RightFill(String.format("%.9f", Double.valueOf(g_effi.getEfficiency().get(i))), 16)+
StringPool.SPACE+RightFill(String.format("%.9f", Double.valueOf(g_effi.getEfficiency().get(i))), 16)+
StringPool.SPACE+RightFill((Objects.isNull(g_effi.getUncertainty().get(i)) ? "0.5" : String.format("%.9f", Double.valueOf(g_effi.getUncertainty().get(i)))), 16)+"\r\n");
}
@ -3587,7 +3587,7 @@ public class GammaFileUtil {
TotaleffBlock g_totE = phd.getUsedTotEKD();
for(int i=0; i<g_totE.getRecord_count(); ++i) {
spectrum.append(RightFill(String.format("%.9f", Double.valueOf(g_totE.getG_energy().get(i))), 16)+
StringPool.SPACE+RightFill(String.format("%.9f", Double.valueOf(g_totE.getTotal_efficiency().get(i))), 16)+
StringPool.SPACE+RightFill(String.format("%.9f", Double.valueOf(g_totE.getTotal_efficiency().get(i))), 16)+
StringPool.SPACE+RightFill((Objects.isNull(g_totE.getUncertainty().get(i)) ? "0.5" : String.format("%.9f", Double.valueOf(g_totE.getUncertainty().get(i)))), 16));
}
}
@ -3600,11 +3600,11 @@ public class GammaFileUtil {
int len = phd.getSpec().getCounts().size();
for(; i<len-4; i+=5,j+=5) {
spectrum.append(RightFill(String.valueOf(j), 5)+
StringPool.SPACE+RightFill(String.valueOf(phd.getSpec().getCounts().get(i)), 10)+
StringPool.SPACE+RightFill(String.valueOf(phd.getSpec().getCounts().get(i+1)), 10)+
StringPool.SPACE+RightFill(String.valueOf(phd.getSpec().getCounts().get(i+2)), 10)+
StringPool.SPACE+RightFill(String.valueOf(phd.getSpec().getCounts().get(i+3)), 10)+
StringPool.SPACE+RightFill(String.valueOf(phd.getSpec().getCounts().get(i+4)), 10)+"\r\n");
StringPool.SPACE+RightFill(String.valueOf(phd.getSpec().getCounts().get(i)), 10)+
StringPool.SPACE+RightFill(String.valueOf(phd.getSpec().getCounts().get(i+1)), 10)+
StringPool.SPACE+RightFill(String.valueOf(phd.getSpec().getCounts().get(i+2)), 10)+
StringPool.SPACE+RightFill(String.valueOf(phd.getSpec().getCounts().get(i+3)), 10)+
StringPool.SPACE+RightFill(String.valueOf(phd.getSpec().getCounts().get(i+4)), 10)+"\r\n");
}
if(i < len) {
spectrum.append(RightFill(String.valueOf(j), 5)+StringPool.SPACE+RightFill(String.valueOf(phd.getSpec().getCounts().get(i)), 10));
@ -4032,4 +4032,102 @@ public class GammaFileUtil {
}
}
public List<Long> loadCompareData(String compareFileName, String userName, long m_nCount, Result result) {
List<Long> 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<FTPFile> 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<ChartData> CompareData(List<Long> m_vecCompare, long m_nCount, Map<String, String> colorMap, List<Double> vEnergy){
List<ChartData> 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<size; ++i) {
SeriseData seriseData = new SeriseData();
seriseData.setX(i+1);
seriseData.setY(m_vecCompare.get(i));
data1.getPointlist().add(seriseData);
}
datalist.add(data1);
if(vEnergy.size() == size) {
ChartData data2 = new ChartData();
data2.setName("Compare");
data2.setGroup("energy");
data2.setColor(colorMap.get("Color_Compare"));
// Compare two Spectrum in Energy
for(int i=0; i<size; ++i) {
SeriseData seriseData = new SeriseData();
seriseData.setX(vEnergy.get(i));
seriseData.setY(m_vecCompare.get(i));
data2.getPointlist().add(seriseData);
}
datalist.add(data2);
}
}
return datalist;
}
}

View File

@ -8,6 +8,7 @@ import org.jeecg.modules.entity.vo.*;
import org.jeecg.modules.service.IGammaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -37,6 +38,10 @@ public class GammaController {
public Result gammaByFile(String fileName, HttpServletRequest request) {
return gammaService.gammaByFile(fileName, request);
}
@GetMapping("Compare")
public Result Compare(String fileName, String compareFileName, HttpServletRequest request) {
return gammaService.Compare(fileName, compareFileName, request);
}
@GetMapping("configure")
@ApiOperation(value = "analyze菜单下configure页面数据", notes = "analyze菜单下configure页面数据")
@ -175,14 +180,14 @@ public class GammaController {
@GetMapping("energyCalibration")
@ApiOperation(value = "查看Energy Calibration数据", notes = "查看Energy Calibration数据")
public Result energyCalibration(Integer sampleId, String fileName, String currentText) {
return gammaService.energyCalibration(sampleId, fileName, currentText);
public Result energyCalibration(Integer sampleId, String fileName, String currentText, Double width) {
return gammaService.energyCalibration(sampleId, fileName, currentText, width);
}
@PostMapping("changeDataEnergy")
@ApiOperation(value = "修改Energy Calibration数据", notes = "修改Energy Calibration数据")
public Result changeDataEnergy(@RequestBody ChangeData changeData) {
return gammaService.changeDataEnergy(changeData.getM_vCurCentroid(), changeData.getM_vCurEnergy(), changeData.getM_vCurUncert(), changeData.getM_curParam(), changeData.getSampleId(), changeData.getFileName());
return gammaService.changeDataEnergy(changeData.getM_vCurCentroid(), changeData.getM_vCurEnergy(), changeData.getM_vCurUncert(), changeData.getM_curParam(), changeData.getSampleId(), changeData.getFileName(), changeData.getWidth());
}
@PostMapping("applyDataEnergy")
@ -197,16 +202,22 @@ public class GammaController {
gammaService.saveDataEnergy(changeData.getM_vCurCentroid(), changeData.getM_vCurEnergy(), changeData.getM_vCurUncert(), response);
}
@PostMapping("callDataEnergy")
@ApiOperation(value = "导入Energy Calibration数据", notes = "导入Energy Calibration数据")
public Result callDataEnergy(MultipartFile file, String sampleFileName, Double width, String currentText) {
return gammaService.callDataEnergy(file, sampleFileName, width, currentText);
}
@GetMapping("resolutionCalibration")
@ApiOperation(value = "查看Resolution Calibration数据", notes = "查看Resolution Calibration数据")
public Result resolutionCalibration(Integer sampleId, String fileName, String currentText) {
return gammaService.resolutionCalibration(sampleId, fileName, currentText);
public Result resolutionCalibration(Integer sampleId, String fileName, String currentText, Double width) {
return gammaService.resolutionCalibration(sampleId, fileName, currentText, width);
}
@PostMapping("changeDataResolution")
@ApiOperation(value = "修改Resolution Calibration数据", notes = "修改Resolution Calibration数据")
public Result changeDataResolution(@RequestBody ChangeData changeData) {
return gammaService.changeDataResolution(changeData.getM_vCurReso(), changeData.getM_vCurEnergy(), changeData.getM_vCurUncert(), changeData.getM_curParam(), changeData.getSampleId(), changeData.getFileName());
return gammaService.changeDataResolution(changeData.getM_vCurReso(), changeData.getM_vCurEnergy(), changeData.getM_vCurUncert(), changeData.getM_curParam(), changeData.getSampleId(), changeData.getFileName(), changeData.getWidth());
}
@PostMapping("applyDataResolution")
@ -221,16 +232,22 @@ public class GammaController {
gammaService.saveDataResolution(changeData.getM_vCurReso(), changeData.getM_vCurEnergy(), changeData.getM_vCurUncert(), response);
}
@PostMapping("callDataResolution")
@ApiOperation(value = "导入Resolution Calibration数据", notes = "导入Resolution Calibration数据")
public Result callDataResolution(MultipartFile file, String sampleFileName, Double width, String currentText) {
return gammaService.callDataResolution(file, sampleFileName, width, currentText);
}
@GetMapping("EfficiencyCalibration")
@ApiOperation(value = "查看Efficiency Calibration数据", notes = "查看Efficiency Calibration数据")
public Result EfficiencyCalibration(Integer sampleId, String fileName, String currentText) {
return gammaService.EfficiencyCalibration(sampleId, fileName, currentText);
public Result EfficiencyCalibration(Integer sampleId, String fileName, String currentText, Double width) {
return gammaService.EfficiencyCalibration(sampleId, fileName, currentText, width);
}
@PostMapping("changeDataEfficiency")
@ApiOperation(value = "修改Efficiency Calibration数据", notes = "修改Efficiency Calibration数据")
public Result changeDataEfficiency(@RequestBody ChangeData changeData) {
return gammaService.changeDataEfficiency(changeData.getM_vCurEffi(), changeData.getM_vCurEnergy(), changeData.getM_vCurUncert(), changeData.getM_curParam(), changeData.getFuncId(), changeData.getSampleId(), changeData.getFileName());
return gammaService.changeDataEfficiency(changeData.getM_vCurEffi(), changeData.getM_vCurEnergy(), changeData.getM_vCurUncert(), changeData.getM_curParam(), changeData.getFuncId(), changeData.getSampleId(), changeData.getFileName(), changeData.getWidth());
}
@PostMapping("applyDataEfficiency")
@ -245,6 +262,12 @@ public class GammaController {
gammaService.saveDataEfficiency(changeData.getM_vCurEffi(), changeData.getM_vCurEnergy(), changeData.getM_vCurUncert(), changeData.getFuncId(), response);
}
@PostMapping("callDataEfficiency")
@ApiOperation(value = "导入Efficiency Calibration数据", notes = "导入Efficiency Calibration数据")
public Result callDataEfficiency(MultipartFile file, String sampleFileName, Double width, String currentText) {
return gammaService.callDataEfficiency(file, sampleFileName, width, currentText);
}
@GetMapping("NuclideLibrary")
@ApiOperation(value = "查看Nuclide Library页面数据", notes = "查看Nuclide Library页面数据")
public Result NuclideLibrary(Integer sampleId, String fileName, String editEnergy, double err, String libraryName, String nuclideName, HttpServletRequest request) {
@ -277,7 +300,7 @@ public class GammaController {
@GetMapping("exportPeakInformation")
public void exportPeakInformation(Integer sampleId, String fileName,
HttpServletResponse response){
HttpServletResponse response){
gammaService.exportPeakInformation(sampleId, fileName, response);
}
@ -311,7 +334,7 @@ public class GammaController {
@GetMapping("exportRadionuclideActivity")
public void exportRadionuclideActivity(Integer sampleId, String fileName,
HttpServletResponse response){
HttpServletResponse response){
gammaService.exportRadionuclideActivity(sampleId, fileName, response);
}
@ -387,8 +410,8 @@ public class GammaController {
@GetMapping("saveToDB")
@ApiOperation(value = "Save To DB按钮", notes = "Save To DB按钮")
public Result saveToDB(String fileName, String userName) {
return gammaService.saveToDB(fileName, userName);
public Result saveToDB(String fileName, HttpServletRequest request) {
return gammaService.saveToDB(fileName, request);
}
}

View File

@ -1,7 +1,6 @@
package org.jeecg.modules.entity.vo;
import lombok.Data;
import org.jeecg.modules.entity.vo.ParameterInfo;
import java.io.Serializable;
import java.util.List;
@ -29,4 +28,6 @@ public class ChangeData implements Serializable {
private Integer funcId;
private Double width;
}

View File

@ -3,11 +3,11 @@ package org.jeecg.modules.service;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.base.bizVo.GammaRLR;
import org.jeecg.modules.entity.vo.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
public interface IGammaService{
@ -17,6 +17,8 @@ public interface IGammaService{
Result gammaByFile(String fileName, HttpServletRequest request);
Result Compare(String fileName, String compareFileName, HttpServletRequest request);
Result configure(Integer sampleId, String fileName);
Result Reprocessing(ConfigureData configureData, HttpServletRequest request);
@ -63,30 +65,36 @@ public interface IGammaService{
List<InputData> KorSumInput(CoeffData coeffData);
Result energyCalibration(Integer sampleId, String fileName, String currentText);
Result energyCalibration(Integer sampleId, String fileName, String currentText, Double width);
Result changeDataEnergy(List<Double> m_vCurCentroid, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, ParameterInfo m_curParam, Integer sampleId, String fileName);
Result changeDataEnergy(List<Double> m_vCurCentroid, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, ParameterInfo m_curParam, Integer sampleId, String fileName, Double width);
Result applyDataEnergy(List<Double> m_vCurCentroid, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, ParameterInfo m_curParam, String curCalName, Integer sampleId, String fileName);
void saveDataEnergy(List<Double> m_vCurCentroid, List<Double> m_vCurEnergy, List<Double> 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<Double> m_vCurReso, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, ParameterInfo m_curParam, Integer sampleId, String fileName);
Result resolutionCalibration(Integer sampleId, String fileName, String currentText, Double width);
Result changeDataResolution(List<Double> m_vCurReso, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, ParameterInfo m_curParam, Integer sampleId, String fileName, Double width);
Result applyDataResolution(List<Double> m_vCurReso, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, ParameterInfo m_curParam, String curCalName, Integer sampleId, String fileName);
void saveDataResolution(List<Double> m_vCurReso, List<Double> m_vCurEnergy, List<Double> 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<Double> m_vCurEffi, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, ParameterInfo m_curParam, Integer funcId, Integer sampleId, String fileName);
Result EfficiencyCalibration(Integer sampleId, String fileName, String currentText, Double width);
Result changeDataEfficiency(List<Double> m_vCurEffi, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, ParameterInfo m_curParam, Integer funcId, Integer sampleId, String fileName, Double width);
Result applyDataEfficiency(List<Double> m_vCurEffi, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, ParameterInfo m_curParam, String curCalName, Integer sampleId, String fileName);
void saveDataEfficiency(List<Double> m_vCurEffi, List<Double> m_vCurEnergy, List<Double> 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);
}

View File

@ -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<String, String> colorMap = sysUserColorService.initColor(userName);
//获取缓存的phd数据
Cache<String, PHDFile> phdCache = localCache.getPHDCache();
PHDFile phd = phdCache.getIfPresent(fileName);
long m_nCount = phd.getSpec().getNum_g_channel();
List<Double> vEnergy = phd.getVEnergy();
//获取Compare数据
List<Long> m_vecCompare = gammaFileUtil.loadCompareData(compareFileName, userName, m_nCount, result);
if (CollectionUtils.isNotEmpty(m_vecCompare)) {
List<ChartData> 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<String, Object> 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<Double> m_vCurCentroid, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, ParameterInfo m_curParam, Integer sampleId, String fileName) {
public Result changeDataEnergy(List<Double> m_vCurCentroid, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, ParameterInfo m_curParam, Integer sampleId, String fileName, Double width) {
Result result = new Result();
Map<String, Object> map = new HashMap<>();
Cache<String, PHDFile> 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<Double> m_vCurCentroid, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, ParameterInfo m_curParam, PHDFile phd, Map<String, Object> map) {
private void DataChangeEnergy(List<Double> m_vCurCentroid, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, ParameterInfo m_curParam, PHDFile phd, Double width, Map<String, Object> 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<m_vCurCentroid.size(); i++) {
strBuffer.append(m_vCurEnergy.get(i)).append(" ").append(m_vCurCentroid.get(i)).append(" ").append(m_vCurUncert.get(i)).append("\n");
strBuffer.append(m_vCurEnergy.get(i)).append("\t\t").append(m_vCurCentroid.get(i)).append("\t\t").append(m_vCurUncert.get(i)).append("\n");
}
OutputStream fos = null;
try {
@ -1307,7 +1330,81 @@ public class GammaServiceImpl implements IGammaService {
}
@Override
public Result resolutionCalibration(Integer sampleId, String fileName, String currentText) {
public Result callDataEnergy(MultipartFile file, String sampleFileName, Double width, String currentText) {
Result result = new Result();
Cache<String, PHDFile> 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<String, Object> map = new HashMap<>();
List<Double> m_vCurCentroid = new LinkedList<>();
List<Double> m_vCurEnergy = new LinkedList<>();
List<Double> m_vCurUncert = new LinkedList<>();
try {
//创建临时文件
File tmpFile = File.createTempFile("tmp", null);
//复制上传文件的输入流到临时文件
FileUtils.copyInputStreamToFile(file.getInputStream() ,tmpFile);
//读取文件所有行
List<String> readLines = FileUtils.readLines(tmpFile, "UTF-8");
//遍历文件行数据
for (int i=0; i<readLines.size(); i++) {
String line = readLines.get(i);
if (line.contains("#g_Energy") || line.contains("#Energy")) {
for (int j=i+1; j<readLines.size(); j++) {
String content = readLines.get(j);
if (content.contains("#")) {
break;
}
List<String> 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<Double> vFit = CalValuesHandler.calFcnEval(m_vCurCentroid, m_curParam.getP()).counts;
List<EnergyData> energyDataList = new LinkedList<>();
for(int i=0; i<num; ++i) {
EnergyData energyData = new EnergyData();
double delta = (m_vCurEnergy.get(i) - vFit.get(i)) / m_vCurEnergy.get(i) * 100;
energyData.setChannel(String.format("%.3f", m_vCurCentroid.get(i)));
energyData.setEnergy(String.format("%.3f", m_vCurEnergy.get(i)));
energyData.setFit(String.format("%.3f", vFit.get(i)));
energyData.setDelta(String.format("%.3f", delta));
energyDataList.add(energyData);
}
map.put("table", energyDataList);
String equation = gammaFileUtil.UpdateEquationEnergy(m_curParam);
map.put("equation", equation);
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());
result.setSuccess(true);
result.setResult(map);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
return result;
}
@Override
public Result resolutionCalibration(Integer sampleId, String fileName, String currentText, Double width) {
Result result = new Result();
Map<String, Object> 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<Double> m_vCurReso, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, ParameterInfo m_curParam, Integer sampleId, String fileName) {
public Result changeDataResolution(List<Double> m_vCurReso, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, ParameterInfo m_curParam, Integer sampleId, String fileName, Double width) {
Result result = new Result();
Map<String, Object> 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<Double> m_vCurReso, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, ParameterInfo m_curParam, PHDFile phd, Map<String, Object> map) {
public void DataChangeResolution(List<Double> m_vCurReso, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, ParameterInfo m_curParam, PHDFile phd, Double width, Map<String, Object> 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<m_vCurReso.size(); i++) {
strBuffer.append(m_vCurEnergy.get(i)).append(" ").append(m_vCurReso.get(i)).append(" ").append(m_vCurUncert.get(i)).append("\n");
strBuffer.append(m_vCurEnergy.get(i)).append("\t\t").append(m_vCurReso.get(i)).append("\t\t").append(m_vCurUncert.get(i)).append("\n");
}
OutputStream fos = null;
try {
@ -1466,7 +1563,81 @@ public class GammaServiceImpl implements IGammaService {
}
@Override
public Result EfficiencyCalibration(Integer sampleId, String fileName, String currentText) {
public Result callDataResolution(MultipartFile file, String sampleFileName, Double width, String currentText) {
Result result = new Result();
Cache<String, PHDFile> 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<String, Object> map = new HashMap<>();
List<Double> m_vCurReso = new LinkedList<>();
List<Double> m_vCurEnergy = new LinkedList<>();
List<Double> m_vCurUncert = new LinkedList<>();
try {
//创建临时文件
File tmpFile = File.createTempFile("tmp", null);
//复制上传文件的输入流到临时文件
FileUtils.copyInputStreamToFile(file.getInputStream() ,tmpFile);
//读取文件所有行
List<String> readLines = FileUtils.readLines(tmpFile, "UTF-8");
//遍历文件行数据
for (int i=0; i<readLines.size(); i++) {
String line = readLines.get(i);
if (line.contains("#g_Resolution") || line.contains("#Resolution")) {
for (int j=i+1; j<readLines.size(); j++) {
String content = readLines.get(j);
if (content.contains("#")) {
break;
}
List<String> 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<Double> vFit = CalValuesHandler.calFcnEval(m_vCurEnergy, m_curParam.getP()).counts;
List<ResolutionData> resolutionDataList = new LinkedList<>();
for(int i=0; i<num; ++i) {
ResolutionData resolutionData = new ResolutionData();
double delta = (m_vCurReso.get(i) - vFit.get(i)) / m_vCurReso.get(i) * 100;
resolutionData.setEnergy(String.format("%.3f", m_vCurEnergy.get(i)));
resolutionData.setFwhm(String.format("%.3f", m_vCurReso.get(i)));
resolutionData.setFit(String.format("%.3f", vFit.get(i)));
resolutionData.setDelta(String.format("%.3f", delta));
resolutionDataList.add(resolutionData);
}
map.put("table", resolutionDataList);
String equation = gammaFileUtil.UpdateEquationResolution(m_curParam);
map.put("equation", equation);
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());
result.setSuccess(true);
result.setResult(map);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
return result;
}
@Override
public Result EfficiencyCalibration(Integer sampleId, String fileName, String currentText, Double width) {
Result result = new Result();
Map<String, Object> map = new HashMap<>();
List<String> 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<Double> m_vCurEffi, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, ParameterInfo m_curParam, Integer funcId, Integer sampleId, String fileName) {
public Result changeDataEfficiency(List<Double> m_vCurEffi, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, ParameterInfo m_curParam, Integer funcId, Integer sampleId, String fileName, Double width) {
Result result = new Result();
Map<String, Object> 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<Double> m_vCurEffi, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, ParameterInfo m_curParam, Integer funcId, PHDFile phd, Map<String, Object> map) {
public void DataChangeEfficiency(List<Double> m_vCurEffi, List<Double> m_vCurEnergy, List<Double> m_vCurUncert, ParameterInfo m_curParam, Integer funcId, PHDFile phd, Double width, Map<String, Object> 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<m_vCurEnergy.size(); ++i) {
EfficiencyData efficiencyData = new EfficiencyData();
efficiencyData.setEnergy(String.format("%.3f", m_vCurEnergy.get(i)));
@ -1577,7 +1747,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);
}
@Override
@ -1611,7 +1781,7 @@ public class GammaServiceImpl implements IGammaService {
StringBuffer strBuffer = new StringBuffer();
strBuffer.append("#g_Efficiency").append("\n");
for (int i=0; i<m_vCurEffi.size(); i++) {
strBuffer.append(m_vCurEnergy.get(i)).append(" ").append(m_vCurEffi.get(i)).append(" ").append(m_vCurUncert.get(i)).append("\n");
strBuffer.append(m_vCurEnergy.get(i)).append("\t\t").append(m_vCurEffi.get(i)).append("\t\t").append(m_vCurUncert.get(i)).append("\n");
}
strBuffer.append("FitType = ").append(funId);
OutputStream fos = null;
@ -1635,6 +1805,91 @@ public class GammaServiceImpl implements IGammaService {
}
}
@Override
public Result callDataEfficiency(MultipartFile file, String sampleFileName, Double width, String currentText) {
Result result = new Result();
Cache<String, PHDFile> 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(".eft")) {
Map<String, Object> map = new HashMap<>();
List<Double> m_vCurEffi = new LinkedList<>();
List<Double> m_vCurEnergy = new LinkedList<>();
List<Double> m_vCurUncert = new LinkedList<>();
Double m_nFunId = 1.0;
try {
//创建临时文件
File tmpFile = File.createTempFile("tmp", null);
//复制上传文件的输入流到临时文件
FileUtils.copyInputStreamToFile(file.getInputStream() ,tmpFile);
//读取文件所有行
List<String> readLines = FileUtils.readLines(tmpFile, "UTF-8");
//遍历文件行数据
for (int i=0; i<readLines.size(); i++) {
String line = readLines.get(i);
if (line.contains("#g_Efficiency") || line.contains("#Efficiency")) {
for (int j=i+1; j<readLines.size(); j++) {
String content = readLines.get(j);
if (!content.contains("#") && !content.contains("FitType")) {
List<String> 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<String> 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<Double> vFit = CalValuesHandler.calFcnEval(m_vCurEnergy, m_curParam.getP()).counts;
List<EfficiencyData> efficiencyDataList = new LinkedList<>();
for(int i=0; i<num; ++i) {
double delta = (m_vCurEffi.get(i) - vFit.get(i)) / m_vCurEffi.get(i) * 100;
EfficiencyData efficiencyData = new EfficiencyData();
efficiencyData.setEnergy(String.format("%.3f", m_vCurEnergy.get(i)));
efficiencyData.setEfficiency(String.format("%.3f", m_vCurEffi.get(i)));
efficiencyData.setFit(String.format("%.3f", vFit.get(i)));
efficiencyData.setDelta(String.format("%.3f", delta));
efficiencyDataList.add(efficiencyData);
}
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, width, map);
map.put("ECutAnalysis_Low", phd.getSetting().getECutAnalysis_Low());
map.put("G_energy_span", phd.getSpec().getG_energy_span());
result.setSuccess(true);
result.setResult(map);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
return result;
}
@Override
public Result NuclideLibrary(Integer sampleId, String fileName, String editEnergy, double err, String libraryName, String nuclideName, HttpServletRequest request) {
Result result = new Result();
@ -1732,9 +1987,9 @@ public class GammaServiceImpl implements IGammaService {
userLibraryName = userLibraryName.stream().distinct().collect(Collectors.toList());
boolean save = defaultNuclideSpectrumService.saveNuclidesByUserName(userLibraryName, userName, phd.getHeader().getSystem_type().toUpperCase());
if (save) {
result.success("修改成功!");
result.success("修改成功!");
} else {
result.success("修改失败!");
result.success("修改失败!");
}
return result;
}
@ -2540,8 +2795,9 @@ public class GammaServiceImpl implements IGammaService {
}
@Override
public Result saveToDB(String fileName, String userName) {
public Result saveToDB(String fileName, HttpServletRequest request) {
Result result = new Result();
String userName = JwtUtil.getUserNameByToken(request);
boolean bRet = true;
boolean needUploadSpec = false;
Cache<String, PHDFile> phdCache = localCache.getPHDCache();