Merge remote-tracking branch 'origin/station' into station
This commit is contained in:
commit
3386e05ee0
|
@ -78,10 +78,10 @@ public class EmailServiceManager {
|
|||
boolean flag = false;
|
||||
try {
|
||||
socket.connect(new InetSocketAddress(email.getEmailServerAddress(),email.getPort()),5000);
|
||||
log.info("{}邮件服务连接测试成功",email.getEmailServerAddress());
|
||||
log.info("{}邮件服务连接测试成功",email.getName());
|
||||
flag = true;
|
||||
} catch (IOException e) {
|
||||
log.error("{}邮件服务连接测试失败,请检查邮件服务属性配置是否正确或邮件服务未开启,原因{}",email.getEmailServerAddress(),e.getMessage());
|
||||
log.error("{}邮件服务连接测试失败,请检查邮件服务属性配置是否正确或邮件服务未开启,原因{}",email.getName(),e.getMessage());
|
||||
}finally {
|
||||
try {
|
||||
if(null != socket){
|
||||
|
|
|
@ -19,7 +19,7 @@ public class GammaReportUtil {
|
|||
// 获取系统的临时目录
|
||||
String tempDir = System.getProperty("java.io.tmpdir");
|
||||
// 创建文件
|
||||
File file = new File(tempDir += System.currentTimeMillis());
|
||||
File file = new File(tempDir + System.currentTimeMillis());
|
||||
// 创建PrintWriter对象
|
||||
PrintWriter out = null;
|
||||
try {
|
||||
|
@ -54,6 +54,7 @@ public class GammaReportUtil {
|
|||
if (null != out) {
|
||||
out.close();
|
||||
}
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
public static void writeFile(List<Double> data, String fileType, String path){
|
||||
|
@ -79,6 +80,7 @@ public class GammaReportUtil {
|
|||
if (null != out) {
|
||||
out.close();
|
||||
}
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ public class MyLogFormatUtil {
|
|||
|
||||
List<String> channels = Arrays.asList("59.541", "88.034", "122.061", "165.857", "391.698", "661.657", "834.838", "898.036", "1115.540", "1173.230", "1332.490", "1836.050");
|
||||
List<String> energies = Arrays.asList("0.168", "0.176", "0.174", "0.155", "0.092", "0.059", "0.051", "0.040", "0.040", "0.031", "0.028", "0.022");
|
||||
List<String> errors = Arrays.asList("0.003", "0.004", "0.003", "0.003", "0.002", "0.001", "0.001", "0.001", "0.001", "0.001", "0.001", "0.000");
|
||||
List<String> errors = Arrays.asList("0.003", "0.004", "0.003", "0.003", "0.002", "0.001", "0.001", "0.001", "0.001", "0.001", "0.001");
|
||||
|
||||
List<AttributeItemVo> energys = new ArrayList<>();
|
||||
AttributeItemVo attributeItemVo = new AttributeItemVo();
|
||||
|
@ -142,7 +142,7 @@ public class MyLogFormatUtil {
|
|||
attributeItemVo.setAttribute("Error");
|
||||
attributeItemVo.setContext(errors);
|
||||
energys.add(attributeItemVo);
|
||||
// MyLogFormatUtil.getBlock(MyLogFormatUtil.SetSampleGEnergyChannel, "sampleId", energys);
|
||||
MyLogFormatUtil.getBlock(MyLogFormatUtil.SetSampleGEnergyChannel, "sampleId", energys);
|
||||
|
||||
|
||||
Console.log(getTitleFormat("Read calibration finished","."));
|
||||
|
@ -294,25 +294,21 @@ public class MyLogFormatUtil {
|
|||
return result;
|
||||
}
|
||||
// 计算每列数据中最长的字符串长度
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int[] columnWidths = new int[data.get(0).size()];
|
||||
for (List<String> row : data) {
|
||||
for (int i = 0; i < row.size(); i++) {
|
||||
// 获取长度
|
||||
columnWidths[i] = Math.max(columnWidths[i], row.get(i).length());
|
||||
}
|
||||
}
|
||||
|
||||
// 构造格式化字符串
|
||||
StringBuilder formatBuilder = new StringBuilder();
|
||||
for (int i = 0; i < columnWidths.length; i++) {
|
||||
formatBuilder.append("%-").append(columnWidths[i] + 4).append("s");
|
||||
}
|
||||
String format = formatBuilder.toString();
|
||||
// 格式化输出日志
|
||||
for (List<String> row : data) {
|
||||
result.add(String.format(format, row.toArray()));
|
||||
Console.log(String.format(format, row.toArray()));
|
||||
sb.append("%-").append(columnWidths[i] + 4).append("s");
|
||||
}
|
||||
// 构造格式化字符串
|
||||
result.add(String.format(sb.toString(), row.toArray()));
|
||||
result.add(STRING_END);
|
||||
Console.log(String.format(sb.toString(), row.toArray()));
|
||||
sb = new StringBuilder();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -214,8 +214,8 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
this.arrFilePath = ftpPath.toString();
|
||||
String arrFileTail = ARR_FILE_NAME_TAIL+ARR_FILE_SUFFIX;
|
||||
this.arrFileName = this.phdFileName.replace(DataType.SAMPLEPHD.getSuffix(),arrFileTail);
|
||||
//构造日志文件路径
|
||||
this.logFilePath = properties.getLogPath()+StringConstant.SLASH+this.ftpSavePath;
|
||||
//构造日志文件路径,不包括log前缀
|
||||
this.logFilePath = this.ftpSavePath;
|
||||
this.logFileName = this.phdFileName.replace(DataType.SAMPLEPHD.getSuffix(),SpectrumHandler.LOG_FILE_SUFFIX);
|
||||
}
|
||||
|
||||
|
@ -223,10 +223,6 @@ public class Sample_B_Analysis implements BlockConstant {
|
|||
* 调用dll库的分析B谱结果
|
||||
*/
|
||||
private void autoAnalyse() throws BAnalyseException, FileNotExistException {
|
||||
System.out.println("sam:"+this.sampleTempFilePath);
|
||||
System.out.println("gas:"+this.gasTempFilePath);
|
||||
System.out.println("det:"+this.detTempFilePath);
|
||||
|
||||
BgAnalyseResult analyseResult = EnergySpectrumHandler.bgAnalyse(this.sampleTempFilePath,this.gasTempFilePath,this.detTempFilePath);
|
||||
System.out.println(analyseResult);
|
||||
if(Objects.isNull(analyseResult) || !analyseResult.analyse_flag){
|
||||
|
|
|
@ -32,6 +32,9 @@ import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
|
|||
import org.jeecgframework.core.util.ApplicationContextUtil;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
|
||||
|
@ -122,7 +125,7 @@ public class Sample_G_Analysis {
|
|||
String pathName = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH));
|
||||
String fileName = sampleFilePath.substring(sampleFilePath.lastIndexOf(StringPool.SLASH)+1);
|
||||
boolean flag = gammaFileUtil.loadFile(pathName, fileName, phdFile, new Result());
|
||||
// 获取数据库 Gamma 默认参数
|
||||
// todo 测试阶段暂时注释掉,获取数据库 Gamma 默认参数
|
||||
// getSettingFromDB(phdFile);
|
||||
// 文件路径
|
||||
middleData.setAnalyses_save_filePath(this.sampleInputFilename);
|
||||
|
@ -142,7 +145,7 @@ public class Sample_G_Analysis {
|
|||
this.storageDataToDatabase(middleData, phdFile.getQcItems());
|
||||
|
||||
// 生成日志文件
|
||||
// writeLog(middleData.getAnalyses_LogPath(), middleData);
|
||||
writeLog(middleData.getAnalyses_LogPath(), middleData);
|
||||
// todo 报告文件
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
|
@ -199,6 +202,7 @@ public class Sample_G_Analysis {
|
|||
* @param middleData
|
||||
*/
|
||||
private void writeLog(String logFilePath, GStoreMiddleProcessData middleData) {
|
||||
logFilePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + logFilePath;
|
||||
String sampleId = middleData.getSample_id();
|
||||
MyLogFormatUtil myLogFormatUtil = new MyLogFormatUtil();
|
||||
List<String> writes = new LinkedList<>();
|
||||
|
@ -458,7 +462,21 @@ public class Sample_G_Analysis {
|
|||
String analyseEnd = MyLogFormatUtil.analyseResultsEnd.replace("%1", "date");
|
||||
writes.add(MyLogFormatUtil.getTitleFormat(analyseEnd));
|
||||
|
||||
FileUtil.writeLines(writes, logFilePath, "utf8");
|
||||
// 保存文件
|
||||
// 获取系统的临时目录
|
||||
String tempDir = System.getProperty("java.io.tmpdir");
|
||||
// 创建文件
|
||||
File file = FileUtil.writeLines(writes, tempDir + System.currentTimeMillis(), "utf8");
|
||||
String targetPath = StringUtils.substringBeforeLast(logFilePath, StringPool.SLASH);
|
||||
String targetName = StringUtils.substringAfterLast(logFilePath, StringPool.SLASH);
|
||||
try {
|
||||
ftpUtil.saveFile(targetPath, targetName, new FileInputStream(file));
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
// 删除临时文件
|
||||
if(null != file) file.delete();
|
||||
}
|
||||
}
|
||||
|
||||
public void saveAnalysis(GStoreMiddleProcessData middleData,Integer sampleId){
|
||||
|
@ -589,8 +607,7 @@ public class Sample_G_Analysis {
|
|||
calibration.setFunctionDef(efFunctionDef);
|
||||
calibration.setStartOfRange((int)efStartOfRange);
|
||||
calibration.setEndOfRange((int)efEndOfRange);
|
||||
// todo 暂时固定
|
||||
calibration.setCoeffString("1,2,3");
|
||||
calibration.setCoeffString(efCoeffString);
|
||||
calibration.setModdate(new Date());
|
||||
calibrations.add(calibration);
|
||||
}
|
||||
|
|
|
@ -1036,6 +1036,10 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
String gasFilePath = "";
|
||||
String detFilePath = "";
|
||||
List<GardsXeResultsSpectrum> xeDataList = new LinkedList<>();
|
||||
File sampleTmp = null;
|
||||
File gasTmp = null;
|
||||
File detTmp = null;
|
||||
try {
|
||||
//判断是否有sampleId和dbName 如果有则说明数据来源DB
|
||||
if (Objects.nonNull(sampleId) && StringUtils.isNotBlank(dbName)) {
|
||||
Integer analysisID = null;
|
||||
|
@ -1059,9 +1063,9 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
sampleFilePath = path;
|
||||
gasFilePath = path;
|
||||
detFilePath = path;
|
||||
File sampleTmp = phdFileUtil.analyzeFile(path, sampleFileName);
|
||||
File gasTmp = phdFileUtil.analyzeFile(path, gasFileName);
|
||||
File detTmp = phdFileUtil.analyzeFile(path, detFileName);
|
||||
sampleTmp = phdFileUtil.analyzeFile(path, sampleFileName);
|
||||
gasTmp = phdFileUtil.analyzeFile(path, gasFileName);
|
||||
detTmp = phdFileUtil.analyzeFile(path, detFileName);
|
||||
if ( Objects.isNull(sampleTmp) || Objects.isNull(gasTmp) || Objects.isNull(detTmp) ) {
|
||||
result.error500("ftp下文件不存在");
|
||||
return result;
|
||||
|
@ -1126,6 +1130,19 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
qcResult.setXe133MDCStatus("Failed");
|
||||
}
|
||||
}
|
||||
} 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(qcResult);
|
||||
return result;
|
||||
|
@ -1159,28 +1176,15 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
String userName = JwtUtil.getUserNameByToken(request);
|
||||
String sampleFilePath = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName;
|
||||
List<GardsXeResultsSpectrum> xeDataList = new LinkedList<>();
|
||||
if (Objects.nonNull(sampleId)) {
|
||||
sampleFilePath = spectrumAnalysisMapper.getSampleFilePath(sampleId);
|
||||
sampleFilePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH));
|
||||
//查询数据库中结果的Xe数据
|
||||
xeDataList = spectrumAnalysisMapper.getXeDataList(sampleId);
|
||||
} else {
|
||||
String path = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName;
|
||||
File sampleTmp = phdFileUtil.analyzeFile(path, sampleFileName);
|
||||
File gasTmp = phdFileUtil.analyzeFile(path, gasFileName);
|
||||
File detTmp = phdFileUtil.analyzeFile(path, detFileName);
|
||||
if ( Objects.isNull(sampleTmp) || Objects.isNull(gasTmp) || Objects.isNull(detTmp) ) {
|
||||
result.error500("ftp下文件不存在");
|
||||
return result;
|
||||
}
|
||||
xeDataList = phdFileUtil.analyzeQCResultXe(sampleTmp, gasTmp, detTmp);
|
||||
}
|
||||
FTPClient ftpClient = ftpUtil.LoginFTP();
|
||||
if (Objects.isNull(ftpClient)){
|
||||
result.error500("ftp连接失败");
|
||||
return result;
|
||||
}
|
||||
InputStream inputStream = null;
|
||||
File sampleTmp = null;
|
||||
File gasTmp = null;
|
||||
File detTmp = null;
|
||||
try {
|
||||
//切换被动模式
|
||||
ftpClient.enterLocalPassiveMode();
|
||||
|
@ -1188,6 +1192,22 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
// 设置编码,当文件中存在中文且上传后文件乱码时可使用此配置项
|
||||
ftpClient.setControlEncoding("UTF-8");
|
||||
ftpClient.setFileTransferMode(FTPClient.STREAM_TRANSFER_MODE);
|
||||
if (Objects.nonNull(sampleId)) {
|
||||
sampleFilePath = spectrumAnalysisMapper.getSampleFilePath(sampleId);
|
||||
sampleFilePath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePath.substring(0, sampleFilePath.lastIndexOf(StringPool.SLASH));
|
||||
//查询数据库中结果的Xe数据
|
||||
xeDataList = spectrumAnalysisMapper.getXeDataList(sampleId);
|
||||
} else {
|
||||
String path = StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName;
|
||||
sampleTmp = phdFileUtil.analyzeFile(path, sampleFileName);
|
||||
gasTmp = phdFileUtil.analyzeFile(path, gasFileName);
|
||||
detTmp = phdFileUtil.analyzeFile(path, detFileName);
|
||||
if ( Objects.isNull(sampleTmp) || Objects.isNull(gasTmp) || Objects.isNull(detTmp) ) {
|
||||
result.error500("ftp下文件不存在");
|
||||
return result;
|
||||
}
|
||||
xeDataList = phdFileUtil.analyzeQCResultXe(sampleTmp, gasTmp, detTmp);
|
||||
}
|
||||
if (StringUtils.isNotBlank(sampleFilePath)){
|
||||
ftpClient.changeWorkingDirectory(sampleFilePath);
|
||||
inputStream = ftpClient.retrieveFileStream(sampleFileName);
|
||||
|
@ -1248,6 +1268,15 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
if (Objects.nonNull(inputStream)){
|
||||
inputStream.close();
|
||||
}
|
||||
if (Objects.nonNull(sampleTmp)) {
|
||||
sampleTmp.delete();
|
||||
}
|
||||
if (Objects.nonNull(gasTmp)) {
|
||||
gasTmp.delete();
|
||||
}
|
||||
if (Objects.nonNull(detTmp)) {
|
||||
detTmp.delete();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -2442,6 +2471,10 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
String samplePath = "";
|
||||
String gasPath = "";
|
||||
String detPath = "";
|
||||
File sampleTmp = null;
|
||||
File gasTmp = null;
|
||||
File detTmp = null;
|
||||
try {
|
||||
//如果sampleId不为空 说明数据来源数据库 查询出对应的文件路径
|
||||
if (Objects.nonNull(sampleId) && StringUtils.isNotBlank(dbName)){
|
||||
if (dbName.equalsIgnoreCase("auto")){
|
||||
|
@ -2464,9 +2497,9 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
detPath = path;
|
||||
}
|
||||
//根据文件路径 文件名称获取对应的临时文件
|
||||
File sampleTmp = phdFileUtil.analyzeFile(samplePath, sampleFileName);
|
||||
File gasTmp = phdFileUtil.analyzeFile(gasPath, gasFileName);
|
||||
File detTmp = phdFileUtil.analyzeFile(detPath, detFileName);
|
||||
sampleTmp = phdFileUtil.analyzeFile(samplePath, sampleFileName);
|
||||
gasTmp = phdFileUtil.analyzeFile(gasPath, gasFileName);
|
||||
detTmp = phdFileUtil.analyzeFile(detPath, detFileName);
|
||||
if (Objects.isNull(sampleTmp) || Objects.isNull(gasTmp) || Objects.isNull(detTmp)) {
|
||||
result.error500("ftp文件获取失败!");
|
||||
return result;
|
||||
|
@ -2494,6 +2527,19 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
}
|
||||
map.put("savedAnalysisResult", true);
|
||||
}
|
||||
} 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);
|
||||
return result;
|
||||
|
@ -2504,6 +2550,10 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
Result result = new Result();
|
||||
String userName = JwtUtil.getUserNameByToken(request);
|
||||
List<Map<String, Object>> mapList = new LinkedList<>();
|
||||
File sampleTmp = null;
|
||||
File gasTmp = null;
|
||||
File detTmp = null;
|
||||
try {
|
||||
if (CollectionUtils.isNotEmpty(sampleFileNames)) {
|
||||
for (int i=0; i<sampleFileNames.size(); i++) {
|
||||
String dbName = dbNames.get(i);
|
||||
|
@ -2545,9 +2595,9 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
detPath = StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + dbSpectrumFilePath.getDetBgFilePath().substring(0, dbSpectrumFilePath.getDetBgFilePath().lastIndexOf(StringPool.SLASH));
|
||||
}
|
||||
//根据文件路径 文件名称获取对应的临时文件
|
||||
File sampleTmp = phdFileUtil.analyzeFile(samplePath, sampleFileName);
|
||||
File gasTmp = phdFileUtil.analyzeFile(gasPath, gasFileName);
|
||||
File detTmp = phdFileUtil.analyzeFile(detPath, detFileName);
|
||||
sampleTmp = phdFileUtil.analyzeFile(samplePath, sampleFileName);
|
||||
gasTmp = phdFileUtil.analyzeFile(gasPath, gasFileName);
|
||||
detTmp = phdFileUtil.analyzeFile(detPath, detFileName);
|
||||
map.put("sampleFileName", sampleFileName);
|
||||
BgDataAnlyseResultIn resultIn = phdFileUtil.analyzeSpectrum(sampleTmp, gasTmp, detTmp, map);
|
||||
List<GardsXeResultsSpectrum> xeDataList = getXeDataList(resultIn, sampleId, analysisID);
|
||||
|
@ -2572,6 +2622,19 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
mapList.add(map);
|
||||
}
|
||||
}
|
||||
} 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);
|
||||
return result;
|
||||
|
@ -2642,9 +2705,11 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
if ( Objects.nonNull(dbSpectrumFilePath.getCollectStart()) && StringUtils.isNotBlank(dbSpectrumFilePath.getSiteDetCode()) ) {
|
||||
String collectStartStr = DateUtils.formatDate(dbSpectrumFilePath.getCollectStart(), "yyyy/MM/dd HH:mm:ss");
|
||||
String qcFilePath = spectrumAnalysisMapper.getQCFilePath(dbSpectrumFilePath.getSiteDetCode(), collectStartStr);
|
||||
if (StringUtils.isNotBlank(qcFilePath)) {
|
||||
anlyseResultIn.setQcFilePath(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + qcFilePath.substring(0, qcFilePath.lastIndexOf(StringPool.SLASH)));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
anlyseResultIn.setSampleFilePath(StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName);
|
||||
anlyseResultIn.setGasFilePath(StringPool.SLASH + spectrumPathProperties.getUploadPath() + StringPool.SLASH + userName);
|
||||
|
@ -2791,16 +2856,23 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
}
|
||||
}
|
||||
//上传本次文件到ftp人工交互存储路径下
|
||||
// File sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName());
|
||||
// File gasTmp = phdFileUtil.analyzeFile(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName());
|
||||
// File detTmp = phdFileUtil.analyzeFile(anlyseResultIn.getDetFilePath(), anlyseResultIn.getDetFileName());
|
||||
// try {
|
||||
// ftpUtil.saveFile(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePathName.substring(0, sampleFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getSampleFileName(), new FileInputStream(sampleTmp));
|
||||
// ftpUtil.saveFile(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + gasFilePathName.substring(0, gasFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getGasFileName(), new FileInputStream(gasTmp));
|
||||
// ftpUtil.saveFile(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + detFilePathName.substring(0, detFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getDetFileName(), new FileInputStream(detTmp));
|
||||
// } catch (FileNotFoundException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
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());
|
||||
ftpUtil.saveFile(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + sampleFilePathName.substring(0, sampleFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getSampleFileName(), new FileInputStream(sampleTmp));
|
||||
ftpUtil.saveFile(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + gasFilePathName.substring(0, gasFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getGasFileName(), new FileInputStream(gasTmp));
|
||||
ftpUtil.saveFile(StringPool.SLASH + spectrumPathProperties.getRootPath() + StringPool.SLASH + detFilePathName.substring(0, detFilePathName.lastIndexOf(StringPool.SLASH)), anlyseResultIn.getDetFileName(), new FileInputStream(detTmp));
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
sampleTmp.delete();
|
||||
gasTmp.delete();
|
||||
detTmp.delete();
|
||||
}
|
||||
result.setSuccess(true);
|
||||
return result;
|
||||
}
|
||||
|
@ -2836,7 +2908,6 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
gammaFittingPara = (List<String>) gammaMap.get("fittingPara");
|
||||
gammaFittingParaToUi = (List<String>) gammaMap.get("fittingParaToUi");
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(anlyseResultIn.getDbName())) {
|
||||
Integer sampleId = spectrumAnalysisMapper.getSampleIdLikeFileName(anlyseResultIn.getSampleFileName());
|
||||
Integer analysisID = null;
|
||||
|
@ -2874,7 +2945,6 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
getChannelAndEnergy(anlyseResultIn, betaList, gammaList);
|
||||
//分析文件内容
|
||||
analyzeSavePHDFile(anlyseResultIn, betaFittingPara, gammaFittingPara, betaFittingParaToUi, gammaFittingParaToUi);
|
||||
|
||||
// 返回需要Save的数据
|
||||
return anlyseResultIn;
|
||||
}
|
||||
|
@ -2890,7 +2960,6 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
roiChannels = ObjectUtil.isNotNull(roiChannels) ? roiChannels : new LinkedList<>();
|
||||
roiResults = ObjectUtil.isNotNull(roiResults) ? roiResults : new LinkedList<>();
|
||||
xeResults = ObjectUtil.isNotNull(xeResults) ? xeResults : new LinkedList<>();
|
||||
|
||||
// 转换ROIChannels数据
|
||||
List<ROIChannelsDto> roiChannelsDtosS = new LinkedList<>();
|
||||
List<ROIChannelsDto> roiChannelsDtosD = new LinkedList<>();
|
||||
|
@ -2932,7 +3001,6 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
xeResultsDto.shift();
|
||||
xeResultsDtos.add(xeResultsDto);
|
||||
}
|
||||
|
||||
result.put("gammaCalibrationSCE", anlyseResultIn.getGammaCalibrationSCE());
|
||||
result.put("gammaCalibrationSEC", anlyseResultIn.getGammaCalibrationSEC());
|
||||
result.put("gammaCalibrationGCE", anlyseResultIn.getGammaCalibrationGCE());
|
||||
|
@ -2961,10 +3029,8 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
ClassLoaderTemplateResolver resolver = new ClassLoaderTemplateResolver();
|
||||
resolver.setPrefix("excelTemplate/");
|
||||
templateEngine.setTemplateResolver(resolver);
|
||||
|
||||
Context context = new Context();
|
||||
context.setVariables(variables);
|
||||
|
||||
return templateEngine.process(SAVETOHTML.getName(), context);
|
||||
}
|
||||
|
||||
|
@ -3008,7 +3074,6 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
public void saveToExcel(BgDataAnlyseResultIn anlyseResultIn, HttpServletResponse response) {
|
||||
// 解析文件,生成导出数据
|
||||
Map<String, Object> analyze = exportData(anlyseResultIn);
|
||||
|
||||
// 将Null值替换为"",避免空指针异常(集合为空集合,不能为null)
|
||||
analyze.replaceAll((key, value) -> ObjectUtil.isNull(value) ? "" : value);
|
||||
String export = "SaveToExcel.xls";
|
||||
|
@ -3199,10 +3264,14 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
}
|
||||
|
||||
public void getChannelAndEnergy(BgDataAnlyseResultIn anlyseResultIn, List<SeriseData> betaList, List<SeriseData> gammaList) {
|
||||
File sampleTmp = null;
|
||||
File gasTmp = null;
|
||||
File detTmp = null;
|
||||
try {
|
||||
//获取ftp文件路径下临时文件
|
||||
File sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName());
|
||||
File gasTmp = phdFileUtil.analyzeFile(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName());
|
||||
File detTmp = phdFileUtil.analyzeFile(anlyseResultIn.getDetFilePath(), anlyseResultIn.getDetFileName());
|
||||
sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName());
|
||||
gasTmp = phdFileUtil.analyzeFile(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName());
|
||||
detTmp = phdFileUtil.analyzeFile(anlyseResultIn.getDetFilePath(), anlyseResultIn.getDetFileName());
|
||||
System.loadLibrary("ReadPHDFile");
|
||||
//如果勾选了Energy Calibration页面下sample Data
|
||||
if (Objects.nonNull(sampleTmp)) {
|
||||
|
@ -3294,17 +3363,33 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
anlyseResultIn.setB_energy_det(sourceData.b_electron_energy);
|
||||
}
|
||||
}
|
||||
} 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,List<String> betaFittingPara, List<String> gammaFittingPara,List<String> betaFittingParaToUi, List<String> gammaFittingParaToUi) {
|
||||
File sampleTmp = null;
|
||||
File gasTmp = null;
|
||||
File detTmp = null;
|
||||
try {
|
||||
//根据文件路径 文件名称获取对应的临时文件
|
||||
File sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName());
|
||||
File gasTmp = phdFileUtil.analyzeFile(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName());
|
||||
File detTmp = phdFileUtil.analyzeFile(anlyseResultIn.getDetFilePath(), anlyseResultIn.getDetFileName());
|
||||
sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName());
|
||||
gasTmp = phdFileUtil.analyzeFile(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName());
|
||||
detTmp = phdFileUtil.analyzeFile(anlyseResultIn.getDetFilePath(), anlyseResultIn.getDetFileName());
|
||||
//加载dll工具库
|
||||
System.loadLibrary("ReadPHDFile");
|
||||
//调用动态库解析文件
|
||||
|
||||
//Gamma Energy Calibration页面 如果点击过fitting使BGammaEnergyValid并且有勾选
|
||||
//如果三个sampleData,GasData,DetData数据都是被勾选状态 则需要传递新的参数重新分析 否则不需要改变数据分析当前文件内容
|
||||
BgAnalyseResult bgAnalyseResult = null;
|
||||
|
@ -3347,7 +3432,6 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
xe135.setNidFlag(anlyseResultIn.getXe135Flag());
|
||||
xeResultsSpectrumList.add(xe135);
|
||||
anlyseResultIn.setXeData(xeResultsSpectrumList);
|
||||
|
||||
if (anlyseResultIn.isBGammaEnergyValidSample()) {
|
||||
GardsCalibrationSpectrum gammaCalibrationSCE = new GardsCalibrationSpectrum();
|
||||
gammaCalibrationSCE.setCoeff1(Double.valueOf(gammaFittingPara.get(0)));
|
||||
|
@ -3417,7 +3501,6 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
anlyseResultIn.setGammaCalibrationDCE(gammaCalibrationDCE);
|
||||
anlyseResultIn.setGammaCalibrationDEC(gammaCalibrationDEC);
|
||||
}
|
||||
|
||||
if (anlyseResultIn.isBBetaEnergyValidSample()) {
|
||||
GardsCalibrationSpectrum betaCalibrationSCE = new GardsCalibrationSpectrum();
|
||||
betaCalibrationSCE.setCoeff1(Double.valueOf(betaFittingPara.get(0)));
|
||||
|
@ -3487,7 +3570,6 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
anlyseResultIn.setBetaCalibrationDCE(betaCalibrationDCE);
|
||||
anlyseResultIn.setBetaCalibrationDEC(betaCalibrationDEC);
|
||||
}
|
||||
|
||||
List<GardsROIChannelsSpectrum> roiChannelsSpectrumList = new LinkedList<>();
|
||||
for (int i=0; i<bgAnalyseResult.S_ROI_B_Boundary_start.size(); i++) {
|
||||
GardsROIChannelsSpectrum roiChannels = new GardsROIChannelsSpectrum();
|
||||
|
@ -3545,9 +3627,23 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
roiResultsSpectrumList.add(roiResults);
|
||||
}
|
||||
anlyseResultIn.setRoiResultsSpectrumList(roiResultsSpectrumList);
|
||||
} 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,List<String> betaFittingPara, List<String> gammaFittingPara) {
|
||||
try {
|
||||
//根据文件路径 文件名称获取对应的临时文件
|
||||
File sampleTmp = phdFileUtil.analyzeFile(anlyseResultIn.getSampleFilePath(), anlyseResultIn.getSampleFileName());
|
||||
File gasTmp = phdFileUtil.analyzeFile(anlyseResultIn.getGasFilePath(), anlyseResultIn.getGasFileName());
|
||||
|
@ -3555,7 +3651,6 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
//加载dll工具库
|
||||
System.loadLibrary("ReadPHDFile");
|
||||
//调用动态库解析文件
|
||||
|
||||
//Gamma Energy Calibration页面 如果点击过fitting使BGammaEnergyValid并且有勾选
|
||||
//如果三个sampleData,GasData,DetData数据都是被勾选状态 则需要传递新的参数重新分析 否则不需要改变数据分析当前文件内容
|
||||
BgAnalyseResult bgAnalyseResult = null;
|
||||
|
@ -3598,7 +3693,6 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
xe135.setNidFlag(anlyseResultIn.getXe135Flag());
|
||||
xeResultsSpectrumList.add(xe135);
|
||||
anlyseResultIn.setXeData(xeResultsSpectrumList);
|
||||
|
||||
List<GardsCalibrationSpectrum> gammaCalibrationSpectrumList = new LinkedList<>();
|
||||
if (anlyseResultIn.isBGammaEnergyValidSample()) {
|
||||
GardsCalibrationSpectrum gammaCalibrationS = new GardsCalibrationSpectrum();
|
||||
|
@ -3646,7 +3740,6 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
gammaCalibrationSpectrumList.add(gammaCalibrationD);
|
||||
}
|
||||
anlyseResultIn.setGammaCalibrationSpectrumList(gammaCalibrationSpectrumList);
|
||||
|
||||
List<GardsCalibrationSpectrum> betaCalibrationSpectrumList = new LinkedList<>();
|
||||
if (anlyseResultIn.isBBetaEnergyValidSample()) {
|
||||
GardsCalibrationSpectrum betaCalibrationS = new GardsCalibrationSpectrum();
|
||||
|
@ -3751,7 +3844,13 @@ public class SpectrumAnalysisServiceImpl implements ISpectrumAnalysisService {
|
|||
roiResultsSpectrumList.add(roiResults);
|
||||
}
|
||||
anlyseResultIn.setRoiResultsSpectrumList(roiResultsSpectrumList);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<GardsCalibrationPairs> getCalibrationPairs(BgDataAnlyseResultIn anlyseResultIn, Integer sampleId, Integer gasId, Integer detId, Integer idAnalysis) {
|
||||
List<GardsCalibrationPairs> calibrationPairsList = new LinkedList<>();
|
||||
|
|
|
@ -60,11 +60,8 @@ public class JeecgAutoProcessApplication extends SpringBootServletInitializer im
|
|||
public void run(String... args) throws Exception {
|
||||
//调用dll
|
||||
System.loadLibrary("ReadPHDFile");
|
||||
//根据配置文件配置邮件获取策略定义时间条件
|
||||
Date systemStartupTime = null;
|
||||
if(EmailReceivePolicy.HISTORY_ORDER_RECEIVE.getPolicy().equals(taskProperties.getReceivePolicy())){
|
||||
systemStartupTime = DateUtils.parseDate("1970-01-01 00:00:00","yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
//根据配置文件配置邮件获取策略定义时间条件,默认EmailReceivePolicy.HISTORY_ORDER_RECEIVE.getPolicy()
|
||||
Date systemStartupTime = DateUtils.parseDate("1970-01-01 00:00:00","yyyy-MM-dd HH:mm:ss");
|
||||
if(EmailReceivePolicy.CURR_DATE_ORDER_RECEIVE.getPolicy().equals(taskProperties.getReceivePolicy())){
|
||||
systemStartupTime = new Date();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user