beta,gamma新增字段缓存临时文件全路径,删除候选列表数据时删除临时文件,不再频繁调用ftp
This commit is contained in:
parent
702b4c3d0f
commit
e85d0ad2e8
|
@ -65,6 +65,7 @@ public class GammaFileUtil extends AbstractLogOrReport {
|
|||
phd.setFilename(fileName);
|
||||
String fromPath = pathName + StringPool.SLASH + fileName;
|
||||
File file = ftpUtil.downloadFile(fromPath, "betaGamma");
|
||||
phd.setTmpFilePath(file.getAbsolutePath());
|
||||
if (Objects.isNull(file)) {
|
||||
result.error500("ftp file can't find");
|
||||
return false;
|
||||
|
@ -235,9 +236,6 @@ public class GammaFileUtil extends AbstractLogOrReport {
|
|||
|
||||
}catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
if (Objects.nonNull(file))
|
||||
file.delete();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -274,9 +272,7 @@ public class GammaFileUtil extends AbstractLogOrReport {
|
|||
|
||||
String baselineFileName = prefixName+"_"+subFileName + ".baseline";
|
||||
String fromPathBase = pathName + StringPool.SLASH + baselineFileName;
|
||||
File file = ftpUtil.downloadFile(fromPathBase, "betaGamma");
|
||||
inputStreamBase = new FileInputStream(file);
|
||||
// inputStreamBase = ftpUtil.downloadFileStream(fromPathBase);
|
||||
inputStreamBase = ftpUtil.downloadFileStream(fromPathBase);
|
||||
// 调用处理BaseCtrl的方法
|
||||
ReadBaseCtrlInfo(phd, inputStreamBase);
|
||||
// 将phdFile的BaseCtrls的BaseLine部分数据 赋值给 phdFile的vBase
|
||||
|
@ -1262,8 +1258,6 @@ public class GammaFileUtil extends AbstractLogOrReport {
|
|||
}
|
||||
|
||||
public boolean AnalyseSpectrum(PHDFile phd, Map<String, NuclideLines> mapLines){
|
||||
//解析获取临时文件信息
|
||||
File tmpFile = analyzeFile(phd.getFilepath(), phd.getFilename());
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
try {
|
||||
String phdStr = mapper.writeValueAsString(phd);
|
||||
|
@ -1271,7 +1265,7 @@ public class GammaFileUtil extends AbstractLogOrReport {
|
|||
if (ObjectUtil.isNull(analysisProcess)){
|
||||
analysisProcess = ApplicationContextUtil.getContext().getBean(AnalysisProcess.class);
|
||||
}
|
||||
String strValue = CalValuesHandler.analyseSpectrum(phdStr, nuclideLinesMap, tmpFile.getAbsolutePath(), analysisProcess);
|
||||
String strValue = CalValuesHandler.analyseSpectrum(phdStr, nuclideLinesMap, phd.getTmpFilePath(), analysisProcess);
|
||||
Map<String, Object> parseMap = JSON.parseObject(strValue, Map.class);
|
||||
for (Map.Entry<String, Object> entry:parseMap.entrySet()) {
|
||||
if (entry.getKey().equalsIgnoreCase("bAnalyed")) {
|
||||
|
@ -1465,10 +1459,6 @@ public class GammaFileUtil extends AbstractLogOrReport {
|
|||
} catch (RuntimeException e) {
|
||||
e.printStackTrace();
|
||||
log.error("AnalyseSpectrum(): {}", e.getMessage());
|
||||
} finally {
|
||||
if (Objects.nonNull(tmpFile)) {
|
||||
tmpFile.delete();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -3031,7 +3021,7 @@ public class GammaFileUtil extends AbstractLogOrReport {
|
|||
//上传本次文件到ftp人工交互存储路径下
|
||||
File sampleTmp = null;
|
||||
try {
|
||||
sampleTmp = analyzeFile(StringPool.SLASH + ftpUtil.getFtpRootPath() + fileAnlyse.getFilepath(), fileAnlyse.getFilename());
|
||||
sampleTmp = new File(fileAnlyse.getTmpFilePath());
|
||||
if (Objects.nonNull(sampleTmp)) {
|
||||
bRet = ftpUtil.saveFile(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + middleData.analyses_save_filePath.substring(0, middleData.analyses_save_filePath.lastIndexOf(StringPool.SLASH)), middleData.analyses_save_filePath.substring(middleData.analyses_save_filePath.lastIndexOf(StringPool.SLASH)+1), new FileInputStream(sampleTmp));
|
||||
}
|
||||
|
|
|
@ -281,17 +281,13 @@ public class PHDFileUtil extends AbstractLogOrReport {
|
|||
}
|
||||
|
||||
public List<String> readLine(String filePath) {
|
||||
File file = null;
|
||||
List<String> allLines = new ArrayList<>();
|
||||
try {
|
||||
file = ftpUtil.downloadFile(filePath, "betaGamma");
|
||||
return FileUtils.readLines(file, ftpUtil.getEncoding());
|
||||
File file = new File(filePath);
|
||||
return FileUtils.readLines(file, "UTF-8");
|
||||
}catch (IOException e){
|
||||
e.printStackTrace();
|
||||
return allLines;
|
||||
} finally {
|
||||
if (ObjectUtil.isNotNull(file))
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -431,7 +427,6 @@ public class PHDFileUtil extends AbstractLogOrReport {
|
|||
detBgMap.put("DetBgBtn", "RedLight");
|
||||
qcMap.put("DetBgBtn", "RedLight");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Map<String, String> getFileData(String filePath, String sampleFileName) {
|
||||
|
@ -583,47 +578,46 @@ public class PHDFileUtil extends AbstractLogOrReport {
|
|||
return rData;
|
||||
}
|
||||
|
||||
public File analyzeFile(String path, String fileName) {
|
||||
//连接ftp
|
||||
FTPClient ftpClient = ftpUtil.LoginFTP();
|
||||
InputStream inputStream = null;
|
||||
File file = null;
|
||||
try {
|
||||
//被动模式
|
||||
ftpClient.enterLocalPassiveMode();
|
||||
//设置文件类型--二进制文件
|
||||
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
|
||||
//
|
||||
ftpClient.setControlEncoding("UTF-8");
|
||||
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
|
||||
//切换文件路径
|
||||
ftpClient.changeWorkingDirectory(path);
|
||||
inputStream = ftpClient.retrieveFileStream(fileName);
|
||||
if (Objects.nonNull(inputStream)){
|
||||
file = File.createTempFile("betaGamma", null);
|
||||
//将ftp文件的输入流复制给临时文件
|
||||
FileUtils.copyInputStreamToFile(inputStream, file);
|
||||
}
|
||||
} 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 file;
|
||||
}
|
||||
// public File analyzeFile(String path, String fileName) {
|
||||
// //连接ftp
|
||||
// FTPClient ftpClient = ftpUtil.LoginFTP();
|
||||
// InputStream inputStream = null;
|
||||
// File file = null;
|
||||
// try {
|
||||
// //被动模式
|
||||
// ftpClient.enterLocalPassiveMode();
|
||||
// //设置文件类型--二进制文件
|
||||
// ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
|
||||
// //
|
||||
// ftpClient.setControlEncoding("UTF-8");
|
||||
// ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
|
||||
// //切换文件路径
|
||||
// ftpClient.changeWorkingDirectory(path);
|
||||
// inputStream = ftpClient.retrieveFileStream(fileName);
|
||||
// if (Objects.nonNull(inputStream)){
|
||||
// file = File.createTempFile("betaGamma", null);
|
||||
// //将ftp文件的输入流复制给临时文件
|
||||
// FileUtils.copyInputStreamToFile(inputStream, file);
|
||||
// }
|
||||
// } 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 file;
|
||||
// }
|
||||
|
||||
public boolean analyzeSpectrum(File sampleTmp, File gasTmp, File detTmp, BgCalibratePara BgCalPara, Map<String, Object> map, BetaDataFile betaDataFile) {
|
||||
boolean bRet = true;
|
||||
long start = System.currentTimeMillis();
|
||||
//调用动态库解析文件
|
||||
BgAnalyseResult analyseResult = null;
|
||||
if (Objects.isNull(BgCalPara)) {
|
||||
|
@ -723,47 +717,6 @@ public class PHDFileUtil extends AbstractLogOrReport {
|
|||
}
|
||||
}
|
||||
|
||||
public EnergySpectrumStruct analyzeFileSourceData(String filePath, String fileName) {
|
||||
EnergySpectrumStruct struct = null;
|
||||
FTPClient ftpClient = ftpUtil.LoginFTP();
|
||||
InputStream inputStream = null;
|
||||
File file = null;
|
||||
try {
|
||||
//切换被动模式
|
||||
ftpClient.enterLocalPassiveMode();
|
||||
ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
|
||||
// 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项
|
||||
ftpClient.setControlEncoding("UTF-8");
|
||||
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
|
||||
ftpClient.changeWorkingDirectory(filePath);
|
||||
inputStream = ftpClient.retrieveFileStream(fileName);
|
||||
if (Objects.nonNull(inputStream)){
|
||||
//声明一个临时文件
|
||||
file = File.createTempFile("betaGamma", null);
|
||||
//将ftp文件的输入流复制给临时文件
|
||||
FileUtils.copyInputStreamToFile(inputStream, file);
|
||||
struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
try {
|
||||
if (Objects.nonNull(ftpClient)){
|
||||
ftpClient.disconnect();
|
||||
}
|
||||
if (Objects.nonNull(inputStream)){
|
||||
inputStream.close();
|
||||
}
|
||||
if (Objects.nonNull(file)) {
|
||||
file.delete();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return struct;
|
||||
}
|
||||
|
||||
public EnergySpectrumStruct analyzeFileSourceData(File uploadFile) {
|
||||
EnergySpectrumStruct struct = null;
|
||||
InputStream inputStream = null;
|
||||
|
|
|
@ -226,21 +226,21 @@ public class SpectrumAnalysesController {
|
|||
}
|
||||
|
||||
@PostMapping("saveToHTML")
|
||||
public void saveToHTML(HttpServletResponse response,
|
||||
public void saveToHTML(HttpServletRequest request, HttpServletResponse response,
|
||||
@RequestBody BgDataAnlyseResultIn anlyseResultIn){
|
||||
spectrumAnalysisService.saveToHTML(anlyseResultIn, response);
|
||||
spectrumAnalysisService.saveToHTML(anlyseResultIn, request, response);
|
||||
}
|
||||
|
||||
@PostMapping("saveToExcel")
|
||||
public void saveToExcel(HttpServletResponse response,
|
||||
public void saveToExcel(HttpServletRequest request, HttpServletResponse response,
|
||||
@RequestBody BgDataAnlyseResultIn anlyseResultIn){
|
||||
spectrumAnalysisService.saveToExcel(anlyseResultIn, response);
|
||||
spectrumAnalysisService.saveToExcel(anlyseResultIn, request, response);
|
||||
}
|
||||
|
||||
@PostMapping("saveToTxt")
|
||||
public void saveToTxt(HttpServletResponse response,
|
||||
public void saveToTxt(HttpServletRequest request, HttpServletResponse response,
|
||||
@RequestBody BgDataAnlyseResultIn anlyseResultIn){
|
||||
spectrumAnalysisService.saveToTxt(anlyseResultIn, response);
|
||||
spectrumAnalysisService.saveToTxt(anlyseResultIn, request, response);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -80,9 +80,9 @@ public interface ISpectrumAnalysisService {
|
|||
|
||||
Result saveToDB(BgDataAnlyseResultIn anlyseResultIn, HttpServletRequest request);
|
||||
|
||||
void saveToHTML(BgDataAnlyseResultIn anlyseResultIn, HttpServletResponse response);
|
||||
void saveToHTML(BgDataAnlyseResultIn anlyseResultIn, HttpServletRequest request, HttpServletResponse response);
|
||||
|
||||
void saveToExcel(BgDataAnlyseResultIn anlyseResultIn, HttpServletResponse response);
|
||||
void saveToExcel(BgDataAnlyseResultIn anlyseResultIn, HttpServletRequest request, HttpServletResponse response);
|
||||
|
||||
void saveToTxt(BgDataAnlyseResultIn anlyseResultIn, HttpServletResponse response);
|
||||
void saveToTxt(BgDataAnlyseResultIn anlyseResultIn, HttpServletRequest request, HttpServletResponse response);
|
||||
}
|
||||
|
|
|
@ -890,6 +890,12 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String username = loginUser.getUsername();
|
||||
String key = fileName + StrUtil.DASHED + username;
|
||||
Cache<String, PHDFile> phdCache = localCache.getPHDCache();
|
||||
PHDFile phdFile = phdCache.getIfPresent(key);
|
||||
if (StringUtils.isNotBlank(phdFile.getTmpFilePath())) {
|
||||
File file = new File(phdFile.getTmpFilePath());
|
||||
file.delete();
|
||||
}
|
||||
// 删除指定key的Cache
|
||||
localCache.deletePHDCache(key);
|
||||
}
|
||||
|
@ -3728,24 +3734,11 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
if (StringUtils.isBlank(reportPath)) {
|
||||
throw new RuntimeException("The automatic handler generated report does not exist!");
|
||||
}
|
||||
String pathName = ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + 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 connection failed");
|
||||
}
|
||||
String pathFileName = ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + reportPath + ".txt";
|
||||
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);
|
||||
ftpClient.changeWorkingDirectory(pathName);
|
||||
inputStream = ftpClient.retrieveFileStream(fileName);
|
||||
inputStream = ftpUtil.downloadFileStream(pathFileName);
|
||||
if (Objects.nonNull(inputStream)) {
|
||||
outputStream = response.getOutputStream();
|
||||
byte[] buffer = new byte[1024];
|
||||
|
@ -3759,9 +3752,6 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
try {
|
||||
if (Objects.nonNull(ftpClient)) {
|
||||
ftpClient.disconnect();
|
||||
}
|
||||
if (ObjectUtil.isNotNull(inputStream)) {
|
||||
inputStream.close();
|
||||
}
|
||||
|
@ -3778,24 +3768,11 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
public void exportARR(Integer sampleId, HttpServletResponse response) {
|
||||
// 获取自动处理生成的报告地址
|
||||
String reportPath = spectrumAnalysisMapper.viewARR(sampleId);
|
||||
String pathName = ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + 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 connection failed");
|
||||
}
|
||||
String pathFileName = ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + reportPath + ".txt";
|
||||
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);
|
||||
ftpClient.changeWorkingDirectory(pathName);
|
||||
inputStream = ftpClient.retrieveFileStream(fileName);
|
||||
inputStream = ftpUtil.downloadFileStream(pathFileName);
|
||||
if (Objects.nonNull(inputStream)) {
|
||||
// 设置响应类型
|
||||
response.setContentType("application/octet-stream");
|
||||
|
@ -3813,9 +3790,6 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
try {
|
||||
if (Objects.nonNull(ftpClient)) {
|
||||
ftpClient.disconnect();
|
||||
}
|
||||
if (ObjectUtil.isNotNull(inputStream)) {
|
||||
inputStream.close();
|
||||
}
|
||||
|
@ -4317,24 +4291,11 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
if (StringUtils.isBlank(logPath)) {
|
||||
throw new RuntimeException("The log generated by the automatic processor does not exist!");
|
||||
}
|
||||
String pathName = ftpUtil.getFtpRootPath() + spectrumPathProperties.getLogPath() + StringPool.SLASH + 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 connection failed");
|
||||
}
|
||||
String pathFileName = ftpUtil.getFtpRootPath() + spectrumPathProperties.getLogPath() + StringPool.SLASH + logPath;
|
||||
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);
|
||||
ftpClient.changeWorkingDirectory(pathName);
|
||||
inputStream = ftpClient.retrieveFileStream(fileName);
|
||||
inputStream = ftpUtil.downloadFileStream(pathFileName);
|
||||
if (Objects.nonNull(inputStream)) {
|
||||
outputStream = response.getOutputStream();
|
||||
byte[] buffer = new byte[1024];
|
||||
|
@ -4348,9 +4309,6 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
try {
|
||||
if (Objects.nonNull(ftpClient)) {
|
||||
ftpClient.disconnect();
|
||||
}
|
||||
if (ObjectUtil.isNotNull(inputStream)) {
|
||||
inputStream.close();
|
||||
}
|
||||
|
|
|
@ -412,6 +412,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
betaDataFile.setSampleFileName(sampleFileName);
|
||||
sampleTmp = ftpUtil.downloadFile(betaDataFile.getSampleFilePathName(), "betaGamma");
|
||||
if (Objects.nonNull(sampleTmp)) {
|
||||
betaDataFile.setSampleTmpPath(sampleTmp.getAbsolutePath());
|
||||
EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(sampleTmp.getAbsolutePath());
|
||||
betaDataFile.setSampleStruct(struct);
|
||||
sampleMap = phdFileUtil.getSourceData(struct, sample.getSampleId(), sample.getStatus(), "sample", betaDataFile);
|
||||
|
@ -425,6 +426,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
betaDataFile.setGasFileName(gasFileName);
|
||||
gasTmp = ftpUtil.downloadFile(betaDataFile.getGasFilePathName(), "betaGamma");
|
||||
if (Objects.nonNull(gasTmp)) {
|
||||
betaDataFile.setGasTmpPath(gasTmp.getAbsolutePath());
|
||||
EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(gasTmp.getAbsolutePath());
|
||||
betaDataFile.setGasStruct(struct);
|
||||
gasBgMap = phdFileUtil.getSourceData(struct, gasBg.getSampleId(), gasBg.getStatus(), "gas", betaDataFile);
|
||||
|
@ -438,6 +440,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
betaDataFile.setDetFileName(detFileName);
|
||||
detTmp = ftpUtil.downloadFile(betaDataFile.getDetFilePathName(), "betaGamma");
|
||||
if (Objects.nonNull(detTmp)) {
|
||||
betaDataFile.setDetTmpPath(detTmp.getAbsolutePath());
|
||||
EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(detTmp.getAbsolutePath());
|
||||
betaDataFile.setDetStruct(struct);
|
||||
detBgMap = phdFileUtil.getSourceData(struct, detBg.getSampleId(), detBg.getStatus(), "det", betaDataFile);
|
||||
|
@ -451,6 +454,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
betaDataFile.setQcFileName(qcFileName);
|
||||
qcTmp = ftpUtil.downloadFile(betaDataFile.getQcFilePathName(), "betaGamma");
|
||||
if (Objects.nonNull(qcTmp)) {
|
||||
betaDataFile.setQcTmpPath(qcTmp.getAbsolutePath());
|
||||
EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(qcTmp.getAbsolutePath());
|
||||
betaDataFile.setQcStruct(struct);
|
||||
qcMap = phdFileUtil.getSourceData(struct, qc.getSampleId(), qc.getStatus(), "qc", betaDataFile);
|
||||
|
@ -509,19 +513,6 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (Objects.nonNull(sampleTmp)) {
|
||||
sampleTmp.delete();
|
||||
}
|
||||
if (Objects.nonNull(gasTmp)) {
|
||||
gasTmp.delete();
|
||||
}
|
||||
if (Objects.nonNull(detTmp)) {
|
||||
detTmp.delete();
|
||||
}
|
||||
if (Objects.nonNull(qcTmp)) {
|
||||
qcTmp.delete();
|
||||
}
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(resultMap);
|
||||
|
@ -554,7 +545,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
String detBgFilePath = path + StringPool.SLASH + detFileName;
|
||||
String dbQcFilePath = path + StringPool.SLASH + qcFileName;
|
||||
if(StringUtils.isNotBlank(sampleFileName)){
|
||||
EnergySpectrumStruct struct = getSourceData(sampleFilePath);
|
||||
EnergySpectrumStruct struct = getSourceData(sampleFilePath, "sample", betaDataFile);
|
||||
if (Objects.nonNull(struct)) {
|
||||
betaDataFile.setSampleStruct(struct);
|
||||
betaDataFile.setSampleFilePathName(sampleFilePath);
|
||||
|
@ -565,7 +556,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
}
|
||||
}
|
||||
if(StringUtils.isNotBlank(gasFileName)){
|
||||
EnergySpectrumStruct struct = getSourceData(gasBgFilePath);
|
||||
EnergySpectrumStruct struct = getSourceData(gasBgFilePath, "gas", betaDataFile);
|
||||
if (Objects.nonNull(struct)) {
|
||||
betaDataFile.setGasStruct(struct);
|
||||
betaDataFile.setGasFilePathName(gasBgFilePath);
|
||||
|
@ -576,7 +567,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
}
|
||||
}
|
||||
if(StringUtils.isNotBlank(detFileName)){
|
||||
EnergySpectrumStruct struct = getSourceData(detBgFilePath);
|
||||
EnergySpectrumStruct struct = getSourceData(detBgFilePath, "det", betaDataFile);
|
||||
if (Objects.nonNull(struct)) {
|
||||
betaDataFile.setDetStruct(struct);
|
||||
betaDataFile.setDetFilePathName(detBgFilePath);
|
||||
|
@ -587,7 +578,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
}
|
||||
}
|
||||
if(StringUtils.isNotBlank(qcFileName)){
|
||||
EnergySpectrumStruct struct = getSourceData(dbQcFilePath);
|
||||
EnergySpectrumStruct struct = getSourceData(dbQcFilePath, "qc", betaDataFile);
|
||||
if (Objects.nonNull(struct)) {
|
||||
betaDataFile.setQcStruct(struct);
|
||||
betaDataFile.setQcFilePathName(dbQcFilePath);
|
||||
|
@ -640,20 +631,27 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
}
|
||||
|
||||
//获取文件解析结果
|
||||
public EnergySpectrumStruct getSourceData(String filePathName) {
|
||||
public EnergySpectrumStruct getSourceData(String filePathName, String type, BetaDataFile betaDataFile) {
|
||||
EnergySpectrumStruct struct = null;
|
||||
File file = null;
|
||||
try {
|
||||
//根据完整的文件路径 获取临时文件
|
||||
file = ftpUtil.downloadFile(filePathName, "betaGamma");
|
||||
//解析文件内容
|
||||
struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath());
|
||||
if (Objects.nonNull(file)) {
|
||||
if (type.equalsIgnoreCase("sample")) {
|
||||
betaDataFile.setSampleTmpPath(file.getAbsolutePath());
|
||||
} else if (type.equalsIgnoreCase("gas")) {
|
||||
betaDataFile.setGasTmpPath(file.getAbsolutePath());
|
||||
} else if (type.equalsIgnoreCase("det")) {
|
||||
betaDataFile.setDetTmpPath(file.getAbsolutePath());
|
||||
} else if (type.equalsIgnoreCase("qc")) {
|
||||
betaDataFile.setQcTmpPath(file.getAbsolutePath());
|
||||
}
|
||||
//解析文件内容
|
||||
struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (Objects.nonNull(file)) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
return struct;
|
||||
}
|
||||
|
@ -697,6 +695,28 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
public void deleteSpectrumCacheData(String sampleFileName, HttpServletRequest request) {
|
||||
String userName = JwtUtil.getUserNameByToken(request);
|
||||
String betaKey = sampleFileName + "-" + userName;
|
||||
Cache<String, BetaDataFile> cache = betaCache.getBetaCache();
|
||||
BetaDataFile betaDataFile = cache.getIfPresent(betaKey);
|
||||
String sampleTmpPath = betaDataFile.getSampleTmpPath();
|
||||
if (StringUtils.isNotBlank(sampleTmpPath)) {
|
||||
File file = new File(sampleTmpPath);
|
||||
file.delete();
|
||||
}
|
||||
String gasTmpPath = betaDataFile.getGasTmpPath();
|
||||
if (StringUtils.isNotBlank(gasTmpPath)) {
|
||||
File file = new File(gasTmpPath);
|
||||
file.delete();
|
||||
}
|
||||
String detTmpPath = betaDataFile.getDetTmpPath();
|
||||
if (StringUtils.isNotBlank(detTmpPath)) {
|
||||
File file = new File(detTmpPath);
|
||||
file.delete();
|
||||
}
|
||||
String qcTmpPath = betaDataFile.getQcTmpPath();
|
||||
if (StringUtils.isNotBlank(qcTmpPath)) {
|
||||
File file = new File(qcTmpPath);
|
||||
file.delete();
|
||||
}
|
||||
betaCache.deleteBetaCache(betaKey);
|
||||
}
|
||||
|
||||
|
@ -1168,20 +1188,20 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
return result;
|
||||
}
|
||||
Map<String, List<String>> map = new HashMap<>();
|
||||
if(StringUtils.isNotBlank(betaDataFile.getSampleFilePathName())) {
|
||||
List<String> lines = phdFileUtil.readLine(betaDataFile.getSampleFilePathName());
|
||||
if(StringUtils.isNotBlank(betaDataFile.getSampleTmpPath())) {
|
||||
List<String> lines = phdFileUtil.readLine(betaDataFile.getSampleTmpPath());
|
||||
map.put("sample", lines);
|
||||
}
|
||||
if(StringUtils.isNotBlank(betaDataFile.getGasFilePathName())) {
|
||||
List<String> lines = phdFileUtil.readLine(betaDataFile.getGasFilePathName());
|
||||
if(StringUtils.isNotBlank(betaDataFile.getGasTmpPath())) {
|
||||
List<String> lines = phdFileUtil.readLine(betaDataFile.getGasTmpPath());
|
||||
map.put("gasBg", lines);
|
||||
}
|
||||
if(StringUtils.isNotBlank(betaDataFile.getDetFilePathName())) {
|
||||
List<String> lines = phdFileUtil.readLine(betaDataFile.getDetFilePathName());
|
||||
if(StringUtils.isNotBlank(betaDataFile.getDetTmpPath())) {
|
||||
List<String> lines = phdFileUtil.readLine(betaDataFile.getDetTmpPath());
|
||||
map.put("detBg", lines);
|
||||
}
|
||||
if (StringUtils.isNotBlank(betaDataFile.getQcFilePathName())) {
|
||||
List<String> lines = phdFileUtil.readLine(betaDataFile.getQcFilePathName());
|
||||
if (StringUtils.isNotBlank(betaDataFile.getQcTmpPath())) {
|
||||
List<String> lines = phdFileUtil.readLine(betaDataFile.getQcTmpPath());
|
||||
map.put("qc", lines);
|
||||
}
|
||||
result.setSuccess(true);
|
||||
|
@ -2644,10 +2664,6 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
}
|
||||
|
||||
private Map<String, Object> BetaGammaAnalyzeCurrentProcess(AnalyseData analyseData, BetaDataFile betaDataFile) {
|
||||
//根据文件路径 文件名称获取对应的临时文件
|
||||
File sampleTmp = null;
|
||||
File gasTmp = null;
|
||||
File detTmp = null;
|
||||
//声明一个map 缓存xeData计算后的结果
|
||||
Map<String, Object> xeMap = new HashMap<>();
|
||||
try {
|
||||
|
@ -2721,13 +2737,18 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
//判断是否勾选了qc
|
||||
spectrum_group.BgCalPara.bApplyNewCalicQc = analyseData.isQcData();
|
||||
betaDataFile.setBgPara(spectrum_group.BgCalPara);
|
||||
//获取sample文件
|
||||
sampleTmp = ftpUtil.downloadFile(betaDataFile.getSampleFilePathName(), "betaGamma");
|
||||
//获取gas文件
|
||||
gasTmp = ftpUtil.downloadFile(betaDataFile.getGasFilePathName(), "betaGamma");
|
||||
//获取det文件
|
||||
detTmp = ftpUtil.downloadFile(betaDataFile.getDetFilePathName(), "betaGamma");
|
||||
|
||||
File sampleTmp = null;
|
||||
File gasTmp = null;
|
||||
File detTmp = null;
|
||||
if (StringUtils.isNotBlank(betaDataFile.getSampleTmpPath())) {
|
||||
sampleTmp = new File(betaDataFile.getSampleTmpPath());
|
||||
}
|
||||
if (StringUtils.isNotBlank(betaDataFile.getGasTmpPath())) {
|
||||
gasTmp = new File(betaDataFile.getGasTmpPath());
|
||||
}
|
||||
if (StringUtils.isNotBlank(betaDataFile.getDetTmpPath())) {
|
||||
detTmp = new File(betaDataFile.getDetTmpPath());
|
||||
}
|
||||
if (Objects.nonNull(sampleTmp) && Objects.nonNull(gasTmp) && Objects.nonNull(detTmp)) {
|
||||
//调用分析方法进行分析操作
|
||||
boolean bRet = phdFileUtil.analyzeSpectrum(sampleTmp, gasTmp, detTmp, spectrum_group.BgCalPara, xeMap, betaDataFile);
|
||||
|
@ -2785,16 +2806,6 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (Objects.nonNull(sampleTmp)) {
|
||||
sampleTmp.delete();
|
||||
}
|
||||
if (Objects.nonNull(gasTmp)) {
|
||||
gasTmp.delete();
|
||||
}
|
||||
if (Objects.nonNull(detTmp)) {
|
||||
detTmp.delete();
|
||||
}
|
||||
}
|
||||
return xeMap;
|
||||
}
|
||||
|
@ -2804,9 +2815,6 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
Cache<String, BetaDataFile> cache = betaCache.getBetaCache();
|
||||
//返回最终结果用的map
|
||||
Map<String, Map<String, Object>> analyseResultMap = new HashMap<>();
|
||||
File sampleTmp = null;
|
||||
File gasTmp = null;
|
||||
File detTmp = null;
|
||||
try {
|
||||
//需要操作的数据集合
|
||||
for (String sampleFileName: analyseData.getSampleFileNames()){
|
||||
|
@ -2887,9 +2895,18 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
spectrum_group.BgCalPara.bApplyNewCalicDetBg = analyseData.isDetBgData();
|
||||
spectrum_group.BgCalPara.bApplyNewCalicQc = analyseData.isQcData();
|
||||
sampleBetaData.setBgPara(spectrum_group.BgCalPara);
|
||||
sampleTmp = ftpUtil.downloadFile(sampleBetaData.getSampleFilePathName(), "betaGamma");
|
||||
gasTmp = ftpUtil.downloadFile(sampleBetaData.getGasFilePathName(), "betaGamma");
|
||||
detTmp = ftpUtil.downloadFile(sampleBetaData.getDetFilePathName(), "betaGamma");
|
||||
File sampleTmp = null;
|
||||
File gasTmp = null;
|
||||
File detTmp = null;
|
||||
if (StringUtils.isNotBlank(sampleBetaData.getSampleTmpPath())) {
|
||||
sampleTmp = new File(sampleBetaData.getSampleTmpPath());
|
||||
}
|
||||
if (StringUtils.isNotBlank(sampleBetaData.getGasTmpPath())) {
|
||||
gasTmp = new File(sampleBetaData.getGasTmpPath());
|
||||
}
|
||||
if (StringUtils.isNotBlank(sampleBetaData.getDetTmpPath())) {
|
||||
detTmp = new File(sampleBetaData.getDetTmpPath());
|
||||
}
|
||||
if (Objects.nonNull(sampleTmp) && Objects.nonNull(gasTmp) && Objects.nonNull(detTmp)) {
|
||||
//调用分析方法进行分析操作
|
||||
boolean bRet = phdFileUtil.analyzeSpectrum(sampleTmp, gasTmp, detTmp, spectrum_group.BgCalPara, xeMap, sampleBetaData);
|
||||
|
@ -2951,16 +2968,6 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (Objects.nonNull(sampleTmp)) {
|
||||
sampleTmp.delete();
|
||||
}
|
||||
if (Objects.nonNull(gasTmp)) {
|
||||
gasTmp.delete();
|
||||
}
|
||||
if (Objects.nonNull(detTmp)) {
|
||||
detTmp.delete();
|
||||
}
|
||||
}
|
||||
return analyseResultMap.get(currentFileName);
|
||||
}
|
||||
|
@ -2978,16 +2985,21 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
return result;
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
//生成临时文件
|
||||
File sampleTmp = null;
|
||||
File gasTmp = null;
|
||||
File detTmp = null;
|
||||
BgCalibratePara BgCalPara = null;
|
||||
try {
|
||||
//根据文件路径 文件名称获取对应的临时文件
|
||||
sampleTmp = ftpUtil.downloadFile(betaDataFile.getSampleFilePathName(), "betaGamma");
|
||||
gasTmp = ftpUtil.downloadFile(betaDataFile.getGasFilePathName(), "betaGamma");
|
||||
detTmp = ftpUtil.downloadFile(betaDataFile.getDetFilePathName(), "betaGamma");
|
||||
File sampleTmp = null;
|
||||
File gasTmp = null;
|
||||
File detTmp = null;
|
||||
if (StringUtils.isNotBlank(betaDataFile.getSampleTmpPath())) {
|
||||
sampleTmp = new File(betaDataFile.getSampleTmpPath());
|
||||
}
|
||||
if (StringUtils.isNotBlank(betaDataFile.getGasTmpPath())) {
|
||||
gasTmp = new File(betaDataFile.getGasTmpPath());
|
||||
}
|
||||
if (StringUtils.isNotBlank(betaDataFile.getDetTmpPath())) {
|
||||
detTmp = new File(betaDataFile.getDetTmpPath());
|
||||
}
|
||||
if (Objects.isNull(sampleTmp) || Objects.isNull(gasTmp) || Objects.isNull(detTmp)) {
|
||||
result.error500("Failed to obtain the ftp file. Procedure!");
|
||||
return result;
|
||||
|
@ -3063,16 +3075,6 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (Objects.nonNull(sampleTmp)) {
|
||||
sampleTmp.delete();
|
||||
}
|
||||
if (Objects.nonNull(gasTmp)) {
|
||||
gasTmp.delete();
|
||||
}
|
||||
if (Objects.nonNull(detTmp)) {
|
||||
detTmp.delete();
|
||||
}
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(map);
|
||||
|
@ -3087,9 +3089,6 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
//获取本地缓存
|
||||
Cache<String, BetaDataFile> cache = betaCache.getBetaCache();
|
||||
Map<String, Map<String, Object>> mapList = new HashMap<>();
|
||||
File sampleTmp = null;
|
||||
File gasTmp = null;
|
||||
File detTmp = null;
|
||||
try {
|
||||
if (CollectionUtils.isNotEmpty(sampleFileNames)) {
|
||||
for (int i=0; i<sampleFileNames.size(); i++) {
|
||||
|
@ -3099,9 +3098,18 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
//获取缓存数据
|
||||
BetaDataFile betaDataFile = cache.getIfPresent(sampleFileName + "-" + userName);
|
||||
//根据文件路径 文件名称获取对应的临时文件
|
||||
sampleTmp = ftpUtil.downloadFile(betaDataFile.getSampleFilePathName(), "betaGamma");
|
||||
gasTmp = ftpUtil.downloadFile(betaDataFile.getGasFilePathName(), "betaGamma");
|
||||
detTmp = ftpUtil.downloadFile(betaDataFile.getDetFilePathName(), "betaGamma");
|
||||
File sampleTmp = null;
|
||||
File gasTmp = null;
|
||||
File detTmp = null;
|
||||
if (StringUtils.isNotBlank(betaDataFile.getSampleTmpPath())) {
|
||||
sampleTmp = new File(betaDataFile.getSampleTmpPath());
|
||||
}
|
||||
if (StringUtils.isNotBlank(betaDataFile.getGasTmpPath())) {
|
||||
gasTmp = new File(betaDataFile.getGasTmpPath());
|
||||
}
|
||||
if (StringUtils.isNotBlank(betaDataFile.getDetTmpPath())) {
|
||||
detTmp = new File(betaDataFile.getDetTmpPath());
|
||||
}
|
||||
//获取缓存内容
|
||||
List<SeriseData> betaList = new LinkedList<>();
|
||||
List<String> betaFittingParaToUi = new LinkedList<>();
|
||||
|
@ -3177,16 +3185,6 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (Objects.nonNull(sampleTmp)) {
|
||||
sampleTmp.delete();
|
||||
}
|
||||
if (Objects.nonNull(gasTmp)) {
|
||||
gasTmp.delete();
|
||||
}
|
||||
if (Objects.nonNull(detTmp)) {
|
||||
detTmp.delete();
|
||||
}
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(mapList.get(currentFileName));
|
||||
|
@ -3333,26 +3331,26 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
return result;
|
||||
}
|
||||
//处理数据 获取对应的channel/energy值
|
||||
getChannelAndEnergy(anlyseResultIn, betaList, gammaList);
|
||||
getChannelAndEnergy(anlyseResultIn, betaList, gammaList, betaDataFile);
|
||||
//分析文件内容
|
||||
analyzePHDFile(anlyseResultIn, BgCalPara, betaFittingPara, gammaFittingPara);
|
||||
analyzePHDFile(anlyseResultIn, BgCalPara, betaFittingPara, gammaFittingPara, betaDataFile);
|
||||
//判断文件是否存储过 如果没有则解析文件并进行存储
|
||||
if ( !OriginalDataStore(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName(), gasFilePathName, anlyseResultIn.getUserName()) ){
|
||||
if ( !OriginalDataStore(betaDataFile, "gas", gasFilePathName) ){
|
||||
result.error500("gasFile save failed");
|
||||
return result;
|
||||
}
|
||||
if ( !OriginalDataStore(anlyseResultIn.getDetFilePath(), anlyseResultIn.getGasFileName(), detFilePathName, anlyseResultIn.getUserName()) ){
|
||||
if ( !OriginalDataStore(betaDataFile, "det", detFilePathName) ){
|
||||
result.error500("detFile save failed");
|
||||
return result;
|
||||
}
|
||||
if (StringUtils.isNotBlank(anlyseResultIn.getQcFileName())) {
|
||||
if ( !OriginalDataStore(anlyseResultIn.getQcFilePath(), anlyseResultIn.getQcFileName(), qcFilePathName, anlyseResultIn.getUserName()) ){
|
||||
if ( !OriginalDataStore(betaDataFile, "qc", qcFilePathName) ){
|
||||
result.error500("qcFile save failed");
|
||||
return result;
|
||||
}
|
||||
qcId = spectrumAnalysisMapper.getSampleId(qcFilePathName);
|
||||
}
|
||||
if ( !OriginalDataStore(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName(), sampleFilePathName, anlyseResultIn.getUserName()) ){
|
||||
if ( !OriginalDataStore(betaDataFile, "sample", sampleFilePathName) ){
|
||||
result.error500("sampleFile save failed");
|
||||
return result;
|
||||
}
|
||||
|
@ -3465,44 +3463,43 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
}
|
||||
}
|
||||
//上传本次文件到ftp人工交互存储路径下
|
||||
File sampleTmp = null;
|
||||
File gasTmp = null;
|
||||
File detTmp = null;
|
||||
File qcTmp = null;
|
||||
try {
|
||||
sampleTmp = ftpUtil.downloadFile(betaDataFile.getSampleFilePathName(), "betaGamma");
|
||||
gasTmp = ftpUtil.downloadFile(betaDataFile.getGasFilePathName(), "betaGamma");
|
||||
detTmp = ftpUtil.downloadFile(betaDataFile.getDetFilePathName(), "betaGamma");
|
||||
qcTmp = ftpUtil.downloadFile(betaDataFile.getQcFilePathName(), "betaGamma");
|
||||
ftpUtil.saveFile(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + sampleFilePathName.substring(0, sampleFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getSampleFileName(), new FileInputStream(sampleTmp));
|
||||
ftpUtil.saveFile(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + gasFilePathName.substring(0, gasFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getGasFileName(), new FileInputStream(gasTmp));
|
||||
ftpUtil.saveFile(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + detFilePathName.substring(0, detFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getDetFileName(), new FileInputStream(detTmp));
|
||||
ftpUtil.saveFile(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + qcFilePathName.substring(0, qcFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getQcFileName(), new FileInputStream(qcTmp));
|
||||
if (StringUtils.isNotBlank(betaDataFile.getSampleTmpPath())) {
|
||||
File sampleTmp = new File(betaDataFile.getSampleTmpPath());
|
||||
ftpUtil.saveFile(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + sampleFilePathName.substring(0, sampleFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getSampleFileName(), new FileInputStream(sampleTmp));
|
||||
}
|
||||
if (StringUtils.isNotBlank(betaDataFile.getGasTmpPath())) {
|
||||
File gasTmp = new File(betaDataFile.getGasTmpPath());
|
||||
ftpUtil.saveFile(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + gasFilePathName.substring(0, gasFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getGasFileName(), new FileInputStream(gasTmp));
|
||||
}
|
||||
if (StringUtils.isNotBlank(betaDataFile.getDetTmpPath())) {
|
||||
File detTmp = new File(betaDataFile.getDetTmpPath());
|
||||
ftpUtil.saveFile(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + detFilePathName.substring(0, detFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getDetFileName(), new FileInputStream(detTmp));
|
||||
}
|
||||
if (StringUtils.isNotBlank(betaDataFile.getQcTmpPath())) {
|
||||
File qcTmp = new File(betaDataFile.getQcTmpPath());
|
||||
ftpUtil.saveFile(StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + qcFilePathName.substring(0, qcFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getQcFileName(), new FileInputStream(qcTmp));
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
sampleTmp.delete();
|
||||
gasTmp.delete();
|
||||
detTmp.delete();
|
||||
qcTmp.delete();
|
||||
}
|
||||
if (Objects.nonNull(sampleId)) {
|
||||
SpectrumData sampleData = getSpectrumData(sampleId);
|
||||
SpectrumData sampleData = getSpectrumData(sampleId, betaDataFile, "sample");
|
||||
betaDataFile.setSampleSpectrumData(sampleData);
|
||||
map.put("sample", sampleData);
|
||||
}
|
||||
if (Objects.nonNull(gasId)) {
|
||||
SpectrumData gasData = getSpectrumData(gasId);
|
||||
SpectrumData gasData = getSpectrumData(gasId, betaDataFile, "gas");
|
||||
betaDataFile.setGasSpectrumData(gasData);
|
||||
map.put("gas", gasData);
|
||||
}
|
||||
if (Objects.nonNull(detId)) {
|
||||
SpectrumData detData = getSpectrumData(detId);
|
||||
SpectrumData detData = getSpectrumData(detId, betaDataFile, "det");
|
||||
betaDataFile.setDetSpectrumData(detData);
|
||||
map.put("det", detData);
|
||||
}
|
||||
if (Objects.nonNull(qcId)) {
|
||||
SpectrumData qcData = getSpectrumData(qcId);
|
||||
SpectrumData qcData = getSpectrumData(qcId, betaDataFile, "qc");
|
||||
betaDataFile.setQcSpectrumData(qcData);
|
||||
map.put("qc", qcData);
|
||||
}
|
||||
|
@ -3551,9 +3548,9 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
anlyseResultIn.setDetFilePath(betaDataFile.getDetFilePathName().substring(0, betaDataFile.getDetFilePathName().lastIndexOf(StringPool.SLASH)));
|
||||
anlyseResultIn.setQcFilePath(betaDataFile.getQcFilePathName().substring(0, betaDataFile.getQcFilePathName().lastIndexOf(StringPool.SLASH)));
|
||||
//处理数据 获取对应的channel/energy值
|
||||
getChannelAndEnergy(anlyseResultIn, betaList, gammaList);
|
||||
getChannelAndEnergy(anlyseResultIn, betaList, gammaList, betaDataFile);
|
||||
//分析文件内容
|
||||
analyzeSavePHDFile(anlyseResultIn, BgCalPara, betaFittingPara, gammaFittingPara, betaFittingParaToUi, gammaFittingParaToUi);
|
||||
analyzeSavePHDFile(anlyseResultIn, BgCalPara, betaFittingPara, gammaFittingPara, betaFittingParaToUi, gammaFittingParaToUi, betaDataFile);
|
||||
// 返回需要Save的数据
|
||||
return anlyseResultIn;
|
||||
}
|
||||
|
@ -3646,11 +3643,13 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
/*
|
||||
* 提取(saveToHtml|saveToTxt|saveToExcel)公共部分
|
||||
* */
|
||||
private Map<String, Object> exportData(BgDataAnlyseResultIn anlyseResultIn){
|
||||
private Map<String, Object> exportData(BgDataAnlyseResultIn anlyseResultIn, String userName){
|
||||
// 解析文件,生成导出数据
|
||||
Map<String, Object> analyze = shiftSaveData(getSaveData(anlyseResultIn));
|
||||
Cache<String, BetaDataFile> cache = betaCache.getBetaCache();
|
||||
BetaDataFile betaDataFile = cache.getIfPresent(anlyseResultIn.getSampleFileName() + "-" + userName);
|
||||
// 转换能谱结构数据
|
||||
EnergySpectrumStruct energySpectrumStruct = phdFileUtil.analyzeFileSourceData(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName());
|
||||
EnergySpectrumStruct energySpectrumStruct = betaDataFile.getSampleStruct();
|
||||
ESStructDto esStructDto = new ESStructDto();
|
||||
ClassUtil.copyProperties(energySpectrumStruct, esStructDto);
|
||||
analyze.putAll(BeanUtil.beanToMap(esStructDto));
|
||||
|
@ -3661,9 +3660,10 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public void saveToHTML(BgDataAnlyseResultIn anlyseResultIn, HttpServletResponse response) {
|
||||
public void saveToHTML(BgDataAnlyseResultIn anlyseResultIn, HttpServletRequest request, HttpServletResponse response) {
|
||||
String userName = JwtUtil.getUserNameByToken(request);
|
||||
// 解析文件,生成导出数据
|
||||
Map<String, Object> analyze = exportData(anlyseResultIn);
|
||||
Map<String, Object> analyze = exportData(anlyseResultIn, userName);
|
||||
// 解析生成Html字符串并导出为Html文件
|
||||
String result = parseHtml(analyze);
|
||||
PrintWriter writer = null;
|
||||
|
@ -3685,9 +3685,10 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public void saveToExcel(BgDataAnlyseResultIn anlyseResultIn, HttpServletResponse response) {
|
||||
public void saveToExcel(BgDataAnlyseResultIn anlyseResultIn, HttpServletRequest request, HttpServletResponse response) {
|
||||
String userName = JwtUtil.getUserNameByToken(request);
|
||||
// 解析文件,生成导出数据
|
||||
Map<String, Object> analyze = exportData(anlyseResultIn);
|
||||
Map<String, Object> analyze = exportData(anlyseResultIn, userName);
|
||||
// 将Null值替换为"",避免空指针异常(集合为空集合,不能为null)
|
||||
analyze.replaceAll((key, value) -> ObjectUtil.isNull(value) ? "" : value);
|
||||
String export = "SaveToExcel.xls";
|
||||
|
@ -3701,9 +3702,10 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public void saveToTxt(BgDataAnlyseResultIn anlyseResultIn, HttpServletResponse response) {
|
||||
public void saveToTxt(BgDataAnlyseResultIn anlyseResultIn, HttpServletRequest request, HttpServletResponse response) {
|
||||
String userName = JwtUtil.getUserNameByToken(request);
|
||||
// 解析文件,生成导出数据
|
||||
Map<String, Object> analyze = exportData(anlyseResultIn);
|
||||
Map<String, Object> analyze = exportData(anlyseResultIn, userName);
|
||||
|
||||
// 生成指定格式的导出数据备用
|
||||
List<ROIChannelsDto> roiChannelsDtosS = (List<ROIChannelsDto>) analyze.get("roiChannelsS");
|
||||
|
@ -3890,15 +3892,15 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
return xeResultStrs;
|
||||
}
|
||||
|
||||
public void getChannelAndEnergy(BgDataAnlyseResultIn anlyseResultIn, List<SeriseData> betaList, List<SeriseData> gammaList) {
|
||||
public void getChannelAndEnergy(BgDataAnlyseResultIn anlyseResultIn, List<SeriseData> betaList, List<SeriseData> gammaList, BetaDataFile betaDataFile) {
|
||||
File sampleTmp = null;
|
||||
File gasTmp = null;
|
||||
File detTmp = null;
|
||||
try {
|
||||
//获取ftp文件路径下临时文件
|
||||
sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName());
|
||||
gasTmp = phdFileUtil.analyzeFile(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName());
|
||||
detTmp = phdFileUtil.analyzeFile(anlyseResultIn.getDetFilePath(), anlyseResultIn.getDetFileName());
|
||||
sampleTmp = new File(betaDataFile.getSampleTmpPath());
|
||||
gasTmp = new File(betaDataFile.getGasTmpPath());
|
||||
detTmp = new File(betaDataFile.getDetTmpPath());
|
||||
//如果勾选了Energy Calibration页面下sample Data
|
||||
if (Objects.nonNull(sampleTmp)) {
|
||||
if(anlyseResultIn.isCheckSample()) {
|
||||
|
@ -3991,28 +3993,18 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (Objects.nonNull(sampleTmp)) {
|
||||
sampleTmp.delete();
|
||||
}
|
||||
if (Objects.nonNull(gasTmp)) {
|
||||
gasTmp.delete();
|
||||
}
|
||||
if (Objects.nonNull(detTmp)) {
|
||||
detTmp.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void analyzeSavePHDFile(BgDataAnlyseResultIn anlyseResultIn, BgCalibratePara BgCalPara, List<String> betaFittingPara, List<String> gammaFittingPara,List<String> betaFittingParaToUi, List<String> gammaFittingParaToUi) {
|
||||
public void analyzeSavePHDFile(BgDataAnlyseResultIn anlyseResultIn, BgCalibratePara BgCalPara, List<String> betaFittingPara, List<String> gammaFittingPara,List<String> betaFittingParaToUi, List<String> gammaFittingParaToUi, BetaDataFile betaDataFile) {
|
||||
File sampleTmp = null;
|
||||
File gasTmp = null;
|
||||
File detTmp = null;
|
||||
try {
|
||||
//根据文件路径 文件名称获取对应的临时文件
|
||||
sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName());
|
||||
gasTmp = phdFileUtil.analyzeFile(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName());
|
||||
detTmp = phdFileUtil.analyzeFile(anlyseResultIn.getDetFilePath(), anlyseResultIn.getDetFileName());
|
||||
sampleTmp = new File(betaDataFile.getSampleTmpPath());
|
||||
gasTmp = new File(betaDataFile.getGasTmpPath());
|
||||
detTmp = new File(betaDataFile.getDetTmpPath());
|
||||
//调用动态库解析文件
|
||||
//Gamma Energy Calibration页面 如果点击过fitting使BGammaEnergyValid并且有勾选
|
||||
//如果三个sampleData,GasData,DetData数据都是被勾选状态 则需要传递新的参数重新分析 否则不需要改变数据分析当前文件内容
|
||||
|
@ -4255,28 +4247,18 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (Objects.nonNull(sampleTmp)) {
|
||||
sampleTmp.delete();
|
||||
}
|
||||
if (Objects.nonNull(gasTmp)) {
|
||||
gasTmp.delete();
|
||||
}
|
||||
if (Objects.nonNull(detTmp)) {
|
||||
detTmp.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void analyzePHDFile(BgDataAnlyseResultIn anlyseResultIn, BgCalibratePara BgCalPara, List<String> betaFittingPara, List<String> gammaFittingPara) {
|
||||
public void analyzePHDFile(BgDataAnlyseResultIn anlyseResultIn, BgCalibratePara BgCalPara, List<String> betaFittingPara, List<String> gammaFittingPara, BetaDataFile betaDataFile) {
|
||||
File sampleTmp = null;
|
||||
File gasTmp = null;
|
||||
File detTmp = null;
|
||||
try {
|
||||
//根据文件路径 文件名称获取对应的临时文件
|
||||
sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName());
|
||||
gasTmp = phdFileUtil.analyzeFile(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName());
|
||||
detTmp = phdFileUtil.analyzeFile(anlyseResultIn.getDetFilePath(), anlyseResultIn.getDetFileName());
|
||||
sampleTmp = new File(betaDataFile.getSampleTmpPath());
|
||||
gasTmp = new File(betaDataFile.getGasTmpPath());
|
||||
detTmp = new File(betaDataFile.getDetTmpPath());
|
||||
//调用动态库解析文件
|
||||
//Gamma Energy Calibration页面 如果点击过fitting使BGammaEnergyValid并且有勾选
|
||||
//如果三个sampleData,GasData,DetData数据都是被勾选状态 则需要传递新的参数重新分析 否则不需要改变数据分析当前文件内容
|
||||
|
@ -4480,16 +4462,6 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (Objects.nonNull(sampleTmp)) {
|
||||
sampleTmp.delete();
|
||||
}
|
||||
if (Objects.nonNull(gasTmp)) {
|
||||
gasTmp.delete();
|
||||
}
|
||||
if (Objects.nonNull(detTmp)) {
|
||||
detTmp.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4574,74 +4546,74 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
return calibrationPairsList;
|
||||
}
|
||||
|
||||
public void getROILimit(BgDataAnlyseResultIn anlyseResultIn) {
|
||||
File sampleTmp = null;
|
||||
try {
|
||||
//获取ftp文件路径下临时文件
|
||||
sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName());
|
||||
if (Objects.nonNull(sampleTmp)){
|
||||
EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData(sampleTmp.getAbsolutePath());
|
||||
List<Double> poiBX1 = sourceData.POI_B_x1;
|
||||
List<Double> poiBX2 = sourceData.POI_B_x2;
|
||||
List<Double> poiGY1 = sourceData.POI_G_y1;
|
||||
List<Double> poiGY2 = sourceData.POI_G_y2;
|
||||
//ROI Limit
|
||||
List<String> report_limit_roi = new LinkedList<>();
|
||||
for(int pos=1;pos<=poiBX1.size();pos++) {
|
||||
report_limit_roi.add(String.valueOf(pos));
|
||||
}
|
||||
List<String> beginB = new LinkedList<>();
|
||||
for(int pos=1;pos<=poiBX1.size();pos++) {
|
||||
beginB.add(String.valueOf(poiBX1.get(pos)));
|
||||
}
|
||||
List<String> endB = new LinkedList<>();
|
||||
for(int pos=0;pos<poiBX2.size();pos++) {
|
||||
endB.add(String.valueOf(poiBX2.get(pos)));
|
||||
}
|
||||
List<String> beginG = new LinkedList<>();
|
||||
for(int pos=1;pos<=poiGY1.size();pos++) {
|
||||
beginG.add(String.valueOf(poiGY1.get(pos)));
|
||||
}
|
||||
List<String> endG = new LinkedList<>();
|
||||
for(int pos=0;pos<poiGY2.size();pos++) {
|
||||
endG.add(String.valueOf(poiGY2.get(pos)));
|
||||
}
|
||||
//ratios
|
||||
List<String> ratio_id = sourceData.ratio_id;
|
||||
List<String> ROI_num_highter_G_energy_ROI = sourceData.ROI_num_highter_G_energy_ROI;
|
||||
List<String> ROI_num_lower_G_energy_ROI = sourceData.ROI_num_lower_G_energy_ROI;
|
||||
List<Double> count_ratio = sourceData.count_ratio;
|
||||
List<Double> count_ratio_uncertainty = sourceData.count_ratio_uncertainty;
|
||||
List<String> countRatioList = new LinkedList<>();
|
||||
for(int pos=0;pos<count_ratio.size();pos++) {
|
||||
countRatioList.add(String.valueOf(count_ratio.get(pos)));
|
||||
}
|
||||
List<String> countRatioUncertaintyList = new LinkedList<>();
|
||||
for(int pos=0;pos<count_ratio_uncertainty.size();pos++) {
|
||||
countRatioUncertaintyList.add(String.valueOf(count_ratio_uncertainty.get(pos)));
|
||||
}
|
||||
//bg_efficiency
|
||||
List<Double> bg_efficiency = sourceData.bg_efficiency;
|
||||
List<String> nuclide_name = sourceData.nuclide_name;
|
||||
List<String> ROI_number = sourceData.ROI_number;
|
||||
List<Double> uncertainty = sourceData.uncertainty;
|
||||
List<String> efficiencyList = new LinkedList<>();
|
||||
for(int pos=0;pos<bg_efficiency.size();pos++) {
|
||||
efficiencyList.add(String.valueOf(bg_efficiency.get(pos)));
|
||||
}
|
||||
List<String> uncertaintyList = new LinkedList<>();
|
||||
for(int pos=0;pos<uncertainty.size();pos++) {
|
||||
uncertaintyList.add(String.valueOf(uncertainty.get(pos)));
|
||||
}
|
||||
}
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (Objects.nonNull(sampleTmp)) {
|
||||
sampleTmp.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
// public void getROILimit(BgDataAnlyseResultIn anlyseResultIn) {
|
||||
// File sampleTmp = null;
|
||||
// try {
|
||||
// //获取ftp文件路径下临时文件
|
||||
// sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName());
|
||||
// if (Objects.nonNull(sampleTmp)){
|
||||
// EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData(sampleTmp.getAbsolutePath());
|
||||
// List<Double> poiBX1 = sourceData.POI_B_x1;
|
||||
// List<Double> poiBX2 = sourceData.POI_B_x2;
|
||||
// List<Double> poiGY1 = sourceData.POI_G_y1;
|
||||
// List<Double> poiGY2 = sourceData.POI_G_y2;
|
||||
// //ROI Limit
|
||||
// List<String> report_limit_roi = new LinkedList<>();
|
||||
// for(int pos=1;pos<=poiBX1.size();pos++) {
|
||||
// report_limit_roi.add(String.valueOf(pos));
|
||||
// }
|
||||
// List<String> beginB = new LinkedList<>();
|
||||
// for(int pos=1;pos<=poiBX1.size();pos++) {
|
||||
// beginB.add(String.valueOf(poiBX1.get(pos)));
|
||||
// }
|
||||
// List<String> endB = new LinkedList<>();
|
||||
// for(int pos=0;pos<poiBX2.size();pos++) {
|
||||
// endB.add(String.valueOf(poiBX2.get(pos)));
|
||||
// }
|
||||
// List<String> beginG = new LinkedList<>();
|
||||
// for(int pos=1;pos<=poiGY1.size();pos++) {
|
||||
// beginG.add(String.valueOf(poiGY1.get(pos)));
|
||||
// }
|
||||
// List<String> endG = new LinkedList<>();
|
||||
// for(int pos=0;pos<poiGY2.size();pos++) {
|
||||
// endG.add(String.valueOf(poiGY2.get(pos)));
|
||||
// }
|
||||
// //ratios
|
||||
// List<String> ratio_id = sourceData.ratio_id;
|
||||
// List<String> ROI_num_highter_G_energy_ROI = sourceData.ROI_num_highter_G_energy_ROI;
|
||||
// List<String> ROI_num_lower_G_energy_ROI = sourceData.ROI_num_lower_G_energy_ROI;
|
||||
// List<Double> count_ratio = sourceData.count_ratio;
|
||||
// List<Double> count_ratio_uncertainty = sourceData.count_ratio_uncertainty;
|
||||
// List<String> countRatioList = new LinkedList<>();
|
||||
// for(int pos=0;pos<count_ratio.size();pos++) {
|
||||
// countRatioList.add(String.valueOf(count_ratio.get(pos)));
|
||||
// }
|
||||
// List<String> countRatioUncertaintyList = new LinkedList<>();
|
||||
// for(int pos=0;pos<count_ratio_uncertainty.size();pos++) {
|
||||
// countRatioUncertaintyList.add(String.valueOf(count_ratio_uncertainty.get(pos)));
|
||||
// }
|
||||
// //bg_efficiency
|
||||
// List<Double> bg_efficiency = sourceData.bg_efficiency;
|
||||
// List<String> nuclide_name = sourceData.nuclide_name;
|
||||
// List<String> ROI_number = sourceData.ROI_number;
|
||||
// List<Double> uncertainty = sourceData.uncertainty;
|
||||
// List<String> efficiencyList = new LinkedList<>();
|
||||
// for(int pos=0;pos<bg_efficiency.size();pos++) {
|
||||
// efficiencyList.add(String.valueOf(bg_efficiency.get(pos)));
|
||||
// }
|
||||
// List<String> uncertaintyList = new LinkedList<>();
|
||||
// for(int pos=0;pos<uncertainty.size();pos++) {
|
||||
// uncertaintyList.add(String.valueOf(uncertainty.get(pos)));
|
||||
// }
|
||||
// }
|
||||
// } catch (Exception e){
|
||||
// e.printStackTrace();
|
||||
// } finally {
|
||||
// if (Objects.nonNull(sampleTmp)) {
|
||||
// sampleTmp.delete();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
public List<GardsCalibration> getCalibration(BgDataAnlyseResultIn anlyseResultIn, Integer sampleId, Integer gasId, Integer detId, Integer idAnalysis) {
|
||||
List<GardsCalibration> calibrationSpectrumList = new LinkedList<>();
|
||||
|
@ -4823,7 +4795,7 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
}
|
||||
|
||||
@Transactional
|
||||
public boolean OriginalDataStore(String filePath, String fileName, String filePathName, String userName) {
|
||||
public boolean OriginalDataStore(BetaDataFile betaDataFile, String type, String filePathName) {
|
||||
//根据新的文件路径名称查询数据是否存在
|
||||
GardsSampleData isExist = spectrumAnalysisMapper.findSampleByFile(filePathName);
|
||||
//如果数据已经存入过数据库 则 修改状态后返回
|
||||
|
@ -4832,27 +4804,25 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
spectrumAnalysisMapper.updateAnalysesStatus(filePathName);
|
||||
return true;
|
||||
}
|
||||
//连接ftp
|
||||
FTPClient ftpClient = ftpUtil.LoginFTP();
|
||||
InputStream inputStream = null;
|
||||
//读取文件内容
|
||||
EnergySpectrumStruct sourceData = null;
|
||||
File file = null;
|
||||
try {
|
||||
//被动模式
|
||||
ftpClient.enterLocalPassiveMode();
|
||||
//设置文件类型--二进制文件
|
||||
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
|
||||
//
|
||||
ftpClient.setControlEncoding("UTF-8");
|
||||
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
|
||||
//切换文件路径
|
||||
ftpClient.changeWorkingDirectory(filePath);
|
||||
inputStream = ftpClient.retrieveFileStream(fileName);
|
||||
if (Objects.nonNull(inputStream)){
|
||||
file = File.createTempFile("betaGamma", null);
|
||||
//将ftp文件的输入流复制给临时文件
|
||||
FileUtils.copyInputStreamToFile(inputStream, file);
|
||||
//读取文件内容
|
||||
EnergySpectrumStruct sourceData = EnergySpectrumHandler.getSourceData(file.getAbsolutePath());
|
||||
if (Objects.nonNull(betaDataFile)){
|
||||
|
||||
if (type.equalsIgnoreCase("sample")) {
|
||||
file = new File(betaDataFile.getSampleTmpPath());
|
||||
sourceData = betaDataFile.getSampleStruct();
|
||||
} else if (type.equalsIgnoreCase("gas")) {
|
||||
file = new File(betaDataFile.getGasTmpPath());
|
||||
sourceData = betaDataFile.getGasStruct();
|
||||
} else if (type.equalsIgnoreCase("det")) {
|
||||
file = new File(betaDataFile.getDetTmpPath());
|
||||
sourceData = betaDataFile.getDetStruct();
|
||||
} else if (type.equalsIgnoreCase("qc")) {
|
||||
file = new File(betaDataFile.getQcTmpPath());
|
||||
sourceData = betaDataFile.getQcStruct();
|
||||
}
|
||||
//获取文件中块名信息
|
||||
List<String> readLines = getFileBlockList(file);
|
||||
//查询台站id
|
||||
|
@ -4903,22 +4873,8 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
}
|
||||
}
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
try {
|
||||
if (Objects.nonNull(ftpClient)){
|
||||
ftpClient.disconnect();
|
||||
}
|
||||
if (Objects.nonNull(inputStream)){
|
||||
inputStream.close();
|
||||
}
|
||||
if (Objects.nonNull(file)) {
|
||||
file.delete();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4961,15 +4917,24 @@ public class SpectrumAnalysisServiceImpl extends AbstractLogOrReport implements
|
|||
return roiResultsList;
|
||||
}
|
||||
|
||||
public SpectrumData getSpectrumData(Integer sampleId) {
|
||||
public SpectrumData getSpectrumData(Integer sampleId, BetaDataFile betaDataFile, String type) {
|
||||
//根据 sampleId获取sampleData的数据内容
|
||||
GardsSampleDataSpectrum sampleData = spectrumAnalysisMapper.getSampleData(sampleId);
|
||||
//获取文件存储路径
|
||||
String inputFileName = sampleData.getInputFileName();
|
||||
//拼接完整的ftp路径
|
||||
String filePath = StringPool.SLASH + ftpUtil.getFtpRootPath() + spectrumPathProperties.getSaveFilePath() + StringPool.SLASH + inputFileName;
|
||||
File file = ftpUtil.downloadFile(filePath, "betaGamma");
|
||||
EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(file.getAbsolutePath());
|
||||
File file = null;
|
||||
EnergySpectrumStruct struct = null;
|
||||
if (type.equalsIgnoreCase("sample")) {
|
||||
file = new File(betaDataFile.getSampleTmpPath());
|
||||
struct = betaDataFile.getSampleStruct();
|
||||
} else if (type.equalsIgnoreCase("gas")) {
|
||||
file = new File(betaDataFile.getGasTmpPath());
|
||||
struct = betaDataFile.getGasStruct();
|
||||
} else if (type.equalsIgnoreCase("det")) {
|
||||
file = new File(betaDataFile.getDetTmpPath());
|
||||
struct = betaDataFile.getDetStruct();
|
||||
} else if (type.equalsIgnoreCase("qc")) {
|
||||
file = new File(betaDataFile.getQcTmpPath());
|
||||
struct = betaDataFile.getQcStruct();
|
||||
}
|
||||
SpectrumData spectrumData = new SpectrumData();
|
||||
try {
|
||||
//封装散点图下的基础数据信息
|
||||
|
|
Loading…
Reference in New Issue
Block a user