fix:1、新 beta 谱 自动处理删除查询 qc 和 det 相关内容;

2、解决 readPHDFile 读#histogram 错误问题
This commit is contained in:
orgin 2024-09-13 10:55:11 +08:00
parent 944e1b2398
commit 6f2a66a83b
7 changed files with 69 additions and 48 deletions

View File

@ -766,7 +766,7 @@ public class EmailServiceManager {
* 若此次获取的邮件是上次删除失败的邮件直接删除
* @param message
*/
public boolean check(Message message,String messageId){
public boolean check(Message message, String messageId){
boolean exist = false;
try {
String key = RedisConstant.EMAIL_MSG_ID+StringConstant.COLON+messageId;

View File

@ -1,9 +1,12 @@
package org.jeecg.modules;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ArrayUtils;
import org.jeecg.common.constant.StringConstant;
import org.jeecg.common.email.EmailLogManager;
import org.jeecg.common.email.EmailServiceManager;
import org.jeecg.common.properties.TaskProperties;
@ -90,13 +93,19 @@ public class EmailParsingActuator extends Thread{
if(ArrayUtils.isNotEmpty(messages)){
//检验获取的邮件是否在之前删除失败列表中若在直接调用邮件API删除并且此次数组里元素也删除
for(int i=messages.length-1;i>=0;i--){
String messageId = null;
if (null == messages[i].getHeader("Message-ID")) {
messages = ArrayUtils.remove(messages, i);
continue;
// 有些邮箱拿不到 message-ID换成主题+接收时间
String subject = messages[i].getSubject().replace(" ", StringConstant.UNDER_LINE);
String receivedStr = DateUtil.format(messages[i].getReceivedDate(), DatePattern.NORM_DATETIME_MINUTE_PATTERN);
messageId = subject + StringConstant.UNDER_LINE + receivedStr;
// messages = ArrayUtils.remove(messages, i);
// continue;
} else {
messageId = ((MimeMessage) messages[i]).getMessageID();
}
if (!messages[i].isExpunged()){
String messageId = ((MimeMessage) messages[i]).getMessageID();
final boolean exist = emailServiceManager.check(messages[i],messageId);
final boolean exist = emailServiceManager.check(messages[i], messageId);
messageIds.add(messageId);
if(exist){
messages = ArrayUtils.remove(messages,i);

View File

@ -9,6 +9,7 @@ import org.apache.logging.log4j.util.Strings;
import org.jeecg.common.constant.StringConstant;
import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.common.util.DateUtils;
import org.jeecg.common.util.SelfStationUtil;
import org.jeecg.common.util.SelfUtil;
import org.jeecg.modules.ErrorLogManager;
import org.jeecg.modules.base.entity.original.GardsSampleData;
@ -92,7 +93,7 @@ public abstract class AbstractS_D_Q_G_SpectrumHandler extends AbstractSpectrumHa
// 如果是自建台站能谱需要单独处理Histogram数据避免性能问题
EnergySpectrumStruct sourceData = null;
if (super.spectrumFile.length() > (1024 * 1024 * 4L)) {
sourceData = SelfUtil.getSourceDataNotHis(super.spectrumFile.getAbsolutePath());
sourceData = SelfStationUtil.getSourceDataNotHis(super.spectrumFile.getAbsolutePath());
} else {
sourceData = EnergySpectrumHandler.getSourceData(super.spectrumFile.getAbsolutePath());
}
@ -329,4 +330,4 @@ public abstract class AbstractS_D_Q_G_SpectrumHandler extends AbstractSpectrumHa
}
return Strings.EMPTY;
}
}
}

View File

@ -172,10 +172,10 @@ public class Sample_C_Analysis {
// parsingProcessLog.setSample_C_Analysis(this);
//查询det数据sampleId,inputFileName sample数据在构造函数已经传过来
this.queryPHDFile();
// this.queryPHDFile();
//查找det谱PHD文件 sample谱PHD文件位置在构造函数已经传过来
this.getPHDFile();
// this.getPHDFile();
// Beta谱进行分析 TODO Analysis
@ -197,7 +197,7 @@ public class Sample_C_Analysis {
GStoreMiddleProcessData middleData4 = new GStoreMiddleProcessData(this.sampleInputFilename);
// 读取文件内容并附值
this.setPHDFile(phdFile1, phdFile2, phdFile3, phdFile4);
// this.setPHDFile(phdFile1, phdFile2, phdFile3, phdFile4);
// 获取数据库 Gamma 默认参数
getSettingFromDB(phdFile1, phdFile2, phdFile3, phdFile4);
@ -430,9 +430,10 @@ public class Sample_C_Analysis {
ErrorLogManager.getInstance().write(new SpectrumErrorEvent(new Date(), ErrorType.GAS_OR_DET_ERROR,this.sampleFilename));
throw new FileNotExistException("gas or det file is no exist or is error..");
}
this.detStruct = EnergySpectrumHandler.getSourceData(this.detFileFinalPath);
// this.detStruct = EnergySpectrumHandler.getSourceData(this.detFileFinalPath);
this.detStruct = SelfStationUtil.getSourceDataNotHis(this.detFileFinalPath);
}
/**
* 读取计算MDC参数文件方法
*/
@ -543,8 +544,7 @@ public class Sample_C_Analysis {
try {
Integer sampleId = this.sampleData.getSampleId();
// 保存分析结果 ==> INSERT INTO RNAUTO.GARDS_ANALYSES TODO 填充Beta分析产生的报告和日志地址
saveAnalysis(sampleId, this.detSampleData, this.startAnalysisTime,
this.endAnalysisTime, null, null);
saveAnalysis(sampleId, this.detSampleData, this.startAnalysisTime, this.endAnalysisTime, null, null);
// 获取分析结果ID ==> SELECT IDANALYSIS
idAnalysis = serviceQuotes.getAnalysesService().getIdAnalysis(sampleId);
// 保存分析结果 ==> INSERT INTO RNAUTO.GARDS_ANALYSES

View File

@ -1,5 +1,7 @@
package org.jeecg.modules.spectrum;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
@ -93,6 +95,11 @@ public class SpectrumParsingActuator implements Runnable{
//解析之前先把邮件唯一信息存储到redis
String messageId = ((MimeMessage) message).getMessageID();
if (StrUtil.isEmpty(messageId)) {
String subjectStr = message.getSubject().replace(" ", "_");
String receivedStr = DateUtil.format(message.getReceivedDate(), DatePattern.NORM_DATETIME_MINUTE_PATTERN);
messageId = subjectStr + StringConstant.UNDER_LINE + receivedStr;
}
receiveDate = DateUtils.formatDate(message.getReceivedDate(),"yyyy-MM-dd HH:mm:ss");
String emlName = subject+ StringConstant.UNDER_LINE+ receiveDate;
String key = RedisConstant.EMAIL_MSG_ID+StringConstant.COLON+messageId;

View File

@ -48,7 +48,7 @@ public class SelfStationUtil extends AbstractLogOrReport {
* @param phdPath 文件地址
* @return
*/
public HashMap<String, Object> readPHDFile(String phdPath) {
public static HashMap<String, Object> readPHDFile(String phdPath) {
try {
File file = new File(phdPath);
HashMap<String, Object> result = Maps.newHashMap();
@ -65,12 +65,14 @@ public class SelfStationUtil extends AbstractLogOrReport {
currentName = line;
// 首行
String s = reader.readLine();
String[] split = s.split(" ");
hCountArr = new long[Integer.parseInt(split[0])][Integer.parseInt(split[1])];
result.put("g_channels", Long.parseLong(split[0]));
result.put("b_channels", Long.parseLong(split[1]));
result.put("g_energy_span", Long.parseLong(split[2]));
result.put("b_energy_span", Long.parseLong(split[3]));
String[] split = s.split(" ");
long[] array = Arrays.stream(split).filter(StrUtil::isNotEmpty).mapToLong(Long::parseLong).toArray();
// todo 暂时反着写邮件中是错误的正确的为 0 1
hCountArr = new long[(int)array[1]][(int)array[0]];
result.put("g_channels", array[1]);
result.put("b_channels", array[0]);
result.put("g_energy_span", array[2]);
result.put("b_energy_span", array[3]);
Console.log(s);
continue;
}
@ -142,6 +144,35 @@ public class SelfStationUtil extends AbstractLogOrReport {
return map;
}
/**
* 调用dll解析phd文件dll不解析histogram块数据
* @param filePathName 文件地址
* @return
*/
public static EnergySpectrumStruct getSourceDataNotHis(String filePathName) {
EnergySpectrumStruct struct = null;
try {
if (Objects.nonNull(filePathName)) {
//解析文件内容
long start = System.currentTimeMillis();
struct = EnergySpectrumHandler.getSourceDataNotHis(filePathName);
Console.log("getsource:{}", (System.currentTimeMillis() - start));
start = System.currentTimeMillis();
HashMap<String, Object> hisMap = readPHDFile(filePathName);
Console.log("readPHDFile:{}", (System.currentTimeMillis() - start));
struct.setH_count_arr((long[][]) hisMap.get("h_count"));
struct.setG_channels((long) hisMap.get("g_channels"));
struct.setB_channels((long) hisMap.get("b_channels"));
struct.setG_energy_span((long) hisMap.get("g_energy_span"));
struct.setB_energy_span((long) hisMap.get("b_energy_span"));
}
} catch (Exception e) {
e.printStackTrace();
log.error("getSourceDataNotHis Error:{}", e.getMessage());
}
return struct;
}
public List<Long> roiList(Integer startChannel, Integer endChannel, long betaChannels, long gammaChannels, List<Long> h_counts) {
// g_counts

View File

@ -344,33 +344,6 @@ public class SelfUtil {
return phd;
}
/**
* 调用dll解析phd文件dll不解析histogram块数据
* @param filePathName 文件地址
* @return
*/
public static EnergySpectrumStruct getSourceDataNotHis(String filePathName) {
EnergySpectrumStruct struct = null;
try {
if (Objects.nonNull(filePathName)) {
//解析文件内容
long start = System.currentTimeMillis();
struct = EnergySpectrumHandler.getSourceDataNotHis(filePathName);
Console.log("getsource:{}", (System.currentTimeMillis() - start));
start = System.currentTimeMillis();
HashMap<String, Object> hisMap = readPHDFile(filePathName);
Console.log("readPHDFile:{}", (System.currentTimeMillis() - start));
struct.setH_count_arr((long[][]) hisMap.get("h_count"));
struct.setG_channels((long) hisMap.get("g_channels"));
struct.setB_channels((long) hisMap.get("b_channels"));
struct.setG_energy_span((long) hisMap.get("g_energy_span"));
struct.setB_energy_span((long) hisMap.get("b_energy_span"));
}
} catch (Exception e) {
log.error("getSourceDataNotHis Error:{}", e.getMessage());
}
return struct;
}
/**
* 解析 #histogram块数据