Merge remote-tracking branch 'origin/station' into station

This commit is contained in:
nieziyan 2023-09-28 10:42:52 +08:00
commit 3386e05ee0
7 changed files with 886 additions and 779 deletions

View File

@ -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){

View File

@ -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();
}
}

View File

@ -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());
// 构造格式化字符串
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();
}
// 构造格式化字符串
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()));
}
result.add(STRING_END);
return result;
}

View File

@ -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){

View File

@ -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);
}

View File

@ -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();
}