Merge remote-tracking branch 'origin/mdc' into mdc
This commit is contained in:
commit
1194956459
|
@ -2,7 +2,6 @@ package org.jeecg.common.email;
|
|||
|
||||
import lombok.Data;
|
||||
import org.jeecg.modules.base.entity.postgre.SysEmail;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
|
@ -34,7 +33,7 @@ public class EmailLogEvent {
|
|||
/**
|
||||
* 接收时间
|
||||
*/
|
||||
private Date recieveTime;
|
||||
private String recieveTime;
|
||||
/**
|
||||
* 能谱文件名称
|
||||
*/
|
||||
|
@ -82,7 +81,7 @@ public class EmailLogEvent {
|
|||
this.logTime = new Date();
|
||||
}
|
||||
|
||||
public EmailLogEvent(String gsType,String state, String logProcess,String subject,Date recieveTime,String emlPath) {
|
||||
public EmailLogEvent(String gsType,String state, String logProcess,String subject,String recieveTime,String emlPath) {
|
||||
this.gsType = gsType;
|
||||
this.state = state;
|
||||
this.logProcess = logProcess;
|
||||
|
@ -92,7 +91,7 @@ public class EmailLogEvent {
|
|||
this.logTime = new Date();
|
||||
}
|
||||
|
||||
public EmailLogEvent(String gsType,String state, String logProcess,String subject,Date recieveTime) {
|
||||
public EmailLogEvent(String gsType,String state, String logProcess,String subject,String recieveTime) {
|
||||
this.gsType = gsType;
|
||||
this.state = state;
|
||||
this.logProcess = logProcess;
|
||||
|
|
|
@ -238,7 +238,7 @@ public class EmailLogManager {
|
|||
logContent.append(" Get File subject:");
|
||||
logContent.append(event.getSubject());
|
||||
logContent.append(" recieve datetime:");
|
||||
logContent.append(DateUtils.formatDate(event.getRecieveTime(),"yyyy-MM-dd HH:mm:ss:SSS"));
|
||||
logContent.append(event.getRecieveTime());
|
||||
logContent.append(event.getState());
|
||||
logContent.append(" EmlFile ");
|
||||
logContent.append(event.getEmlPath());
|
||||
|
@ -259,7 +259,7 @@ public class EmailLogManager {
|
|||
logContent.append(" Delete File subject:");
|
||||
logContent.append(event.getSubject());
|
||||
logContent.append(" recieve datetime:");
|
||||
logContent.append(DateUtils.formatDate(event.getRecieveTime(),"yyyy-MM-dd HH:mm:ss:SSS"));
|
||||
logContent.append(event.getRecieveTime());
|
||||
logContent.append(event.getState());
|
||||
logContent.append(LOG_SUFFIX);
|
||||
logContent.append(System.lineSeparator());
|
||||
|
@ -278,7 +278,7 @@ public class EmailLogManager {
|
|||
logContent.append(" Expunge File subject:");
|
||||
logContent.append(event.getSubject());
|
||||
logContent.append(" recieve datetime:");
|
||||
logContent.append(DateUtils.formatDate(event.getRecieveTime(),"yyyy-MM-dd HH:mm:ss:SSS"));
|
||||
logContent.append(event.getRecieveTime());
|
||||
logContent.append(event.getState());
|
||||
logContent.append(LOG_SUFFIX);
|
||||
logContent.append(System.lineSeparator());
|
||||
|
|
|
@ -522,6 +522,7 @@ public class EmailServiceManager {
|
|||
String subject = "";
|
||||
File emlFile = null;
|
||||
String status = EmailLogManager.STATUS_SUCCESS;
|
||||
Date receivedDate = null;
|
||||
try {
|
||||
//获取发件人
|
||||
final String address = ((InternetAddress) message.getFrom()[0]).getAddress();
|
||||
|
@ -534,7 +535,7 @@ public class EmailServiceManager {
|
|||
if(subject.indexOf(StringConstant.COLON) != -1){
|
||||
subject = StringUtils.replace(subject,StringConstant.COLON,"");
|
||||
}
|
||||
|
||||
receivedDate = message.getReceivedDate();
|
||||
StringBuilder fileName = new StringBuilder();
|
||||
fileName.append(from);
|
||||
fileName.append(StringConstant.UNDER_LINE);
|
||||
|
@ -546,9 +547,9 @@ public class EmailServiceManager {
|
|||
fileName.append(StringConstant.UNDER_LINE);
|
||||
fileName.append("receive");
|
||||
fileName.append(StringConstant.UNDER_LINE);
|
||||
fileName.append(DateUtils.formatDate(message.getReceivedDate(),"YYMMdd"));
|
||||
fileName.append(DateUtils.formatDate(receivedDate,"YYMMdd"));
|
||||
fileName.append(StringConstant.UNDER_LINE);
|
||||
fileName.append(DateUtils.formatDate(message.getReceivedDate(),"HHMMSSSSS"));
|
||||
fileName.append(DateUtils.formatDate(receivedDate,"HHMMSSSSS"));
|
||||
fileName.append(StringConstant.UNDER_LINE);
|
||||
fileName.append(emailCounter);
|
||||
fileName.append(SAVE_EML_SUFFIX);
|
||||
|
@ -563,32 +564,13 @@ public class EmailServiceManager {
|
|||
log.error(errorMsg);
|
||||
throw new DownloadEmailException(errorMsg);
|
||||
}finally {
|
||||
EmailLogEvent event = new EmailLogEvent(EmailLogManager.GS_TYPE_GET,status,EmailLogManager.GETIDEML,subject,message.getReceivedDate(),
|
||||
EmailLogEvent event = new EmailLogEvent(EmailLogManager.GS_TYPE_GET,status,EmailLogManager.GETIDEML,subject,DateUtils.formatDate(receivedDate,"yyyy-MM-dd HH:mm:ss:SSS"),
|
||||
(Objects.isNull(emlFile)?" ":emlFile.getAbsolutePath()));
|
||||
EmailLogManager.getInstance().offer(Thread.currentThread().getId(),event);
|
||||
}
|
||||
|
||||
return emlFile;
|
||||
}
|
||||
|
||||
/*
|
||||
* 将eml中下载的未通过内容校验的邮件 移动到emlError目录
|
||||
* */
|
||||
public void emlToEmlError(File emlFile){
|
||||
if (ObjectUtil.isNull(emlFile)) return;
|
||||
final String filename = emlFile.getName();
|
||||
try {
|
||||
final String rootPath = spectrumPathProperties.getRootPath();
|
||||
final String emlErrorPath = spectrumPathProperties.getEmlErrorPath();
|
||||
File destDir = new File(rootPath + emlErrorPath);
|
||||
// 如果目标目录不存在 则先创建
|
||||
if (!destDir.exists()) destDir.mkdir();
|
||||
FileUtil.move(emlFile, destDir, true);
|
||||
}catch (Exception e){
|
||||
log.error("The error email {} move from eml to emlError failed: {}", filename, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除邮件
|
||||
* @param message
|
||||
|
@ -607,10 +589,10 @@ public class EmailServiceManager {
|
|||
log.error("Email deletion failed, the subject of the email is :{}, the reason is :{}.",subject,e.getMessage());
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
EmailLogEvent removeEvent = new EmailLogEvent(EmailLogManager.GS_TYPE_GET,status,EmailLogManager.DELETEID,subject,receivedDate);
|
||||
EmailLogEvent removeEvent = new EmailLogEvent(EmailLogManager.GS_TYPE_GET,status,EmailLogManager.DELETEID,subject,DateUtils.formatDate(receivedDate,"yyyy-MM-dd HH:mm:ss:SSS"));
|
||||
EmailLogManager.getInstance().offer(Thread.currentThread().getId(),removeEvent);
|
||||
//这里删除和彻底删除一起写入日志,java和C++处理有差异,java是在连接关闭时彻底删除的
|
||||
EmailLogEvent expungeEvent = new EmailLogEvent(EmailLogManager.GS_TYPE_GET,status,EmailLogManager.EXPUNGE,subject,receivedDate);
|
||||
EmailLogEvent expungeEvent = new EmailLogEvent(EmailLogManager.GS_TYPE_GET,status,EmailLogManager.EXPUNGE,subject,DateUtils.formatDate(receivedDate,"yyyy-MM-dd HH:mm:ss:SSS"));
|
||||
EmailLogManager.getInstance().offer(Thread.currentThread().getId(),expungeEvent);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
package org.jeecg.modules;
|
||||
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.jeecg.common.email.EmailLogManager;
|
||||
import org.jeecg.common.email.EmailServiceManager;
|
||||
import org.jeecg.common.properties.TaskProperties;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.modules.email.EmailProperties;
|
||||
import org.jeecg.modules.spectrum.EmailCounter;
|
||||
import org.jeecg.modules.spectrum.SpectrumLogManager;
|
||||
|
@ -22,6 +24,7 @@ import java.util.concurrent.*;
|
|||
/**
|
||||
* 邮件解析执行器
|
||||
*/
|
||||
@Slf4j
|
||||
public class EmailParsingActuator extends Thread{
|
||||
|
||||
private TaskProperties taskProperties;
|
||||
|
@ -58,7 +61,8 @@ public class EmailParsingActuator extends Thread{
|
|||
public void run() {
|
||||
for(;;){
|
||||
if (isStop) {
|
||||
System.out.println("EmailParsingActuator is Stop!");
|
||||
String nowDate = DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss");
|
||||
log.info(nowDate + " " +this.emailProperties.getName()+" EmailParsingActuator is Stop!");
|
||||
return;
|
||||
}
|
||||
long start = System.currentTimeMillis();
|
||||
|
@ -69,6 +73,7 @@ public class EmailParsingActuator extends Thread{
|
|||
try {
|
||||
Message[] messages = emailServiceManager.receiveMail();
|
||||
if(ArrayUtils.isNotEmpty(messages)){
|
||||
log.info("EmailParsingActuator本次获取邮件数量为:{}",messages.length);
|
||||
//检验获取的邮件是否在之前删除失败列表中,若在直接调用邮件API删除,并且此次数组里元素也删除
|
||||
for(int i=messages.length-1;i>=0;i--){
|
||||
if (!messages[i].isExpunged()){
|
||||
|
@ -80,6 +85,7 @@ public class EmailParsingActuator extends Thread{
|
|||
}
|
||||
}
|
||||
}
|
||||
log.info("EmailParsingActuator本次真实执行邮件数量为:{}",messages.length);
|
||||
CountDownLatch taskLatch = new CountDownLatch(messages.length);
|
||||
for(Message message : messages){
|
||||
SpectrumParsingActuator spectrumParsingActuator = new SpectrumParsingActuator();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.jeecg.modules.spectrum;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jeecg.common.constant.RedisConstant;
|
||||
|
@ -12,6 +13,8 @@ import org.jeecg.common.exception.DownloadEmailException;
|
|||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.modules.email.EmailProperties;
|
||||
import org.jeecg.modules.enums.SpectrumSource;
|
||||
import org.jeecg.modules.file.FileOperation;
|
||||
|
||||
import javax.mail.Message;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import java.io.File;
|
||||
|
@ -110,15 +113,20 @@ public class SpectrumParsingActuator implements Runnable{
|
|||
log.warn("This email {} parsing failed and is not listed in the Met, Alert, SOH, Sample, Detbkphd, QC, Gasbkphd spectra.",subject);
|
||||
}
|
||||
emailServiceManager.removeMail(message);
|
||||
}
|
||||
}else {
|
||||
// 如果邮件内容校验失败(邮件内容不完整) 将错误邮件从eml移动到emlError
|
||||
else {
|
||||
emailServiceManager.emlToEmlError(emlFile);
|
||||
if (Objects.nonNull(emlFile) && emlFile.exists()){
|
||||
final String rootPath = spectrumServiceQuotes.getSpectrumPathProperties().getRootPath();
|
||||
final String emlErrorPath = spectrumServiceQuotes.getSpectrumPathProperties().getEmlErrorPath();
|
||||
final String finalPath = rootPath+emlErrorPath;
|
||||
FileOperation.moveFile(emlFile,finalPath,true);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 如果邮件正常下载 则删除下载的邮件对象
|
||||
if (!(e instanceof DownloadEmailException))
|
||||
// 如果不是下载导致的失败,则删除下载的邮件对象
|
||||
if(!(e instanceof DownloadEmailException)){
|
||||
emailServiceManager.removeMail(message);
|
||||
}
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
try {
|
||||
|
|
|
@ -4359,6 +4359,17 @@ public class GammaFileUtil extends AbstractLogOrReport {
|
|||
return ftpUtil.downloadFile(fromPath, "betaGamma");
|
||||
}
|
||||
|
||||
public List<String> readLine(String filePath) {
|
||||
List<String> allLines = new ArrayList<>();
|
||||
try {
|
||||
File file = new File(filePath);
|
||||
return FileUtils.readLines(file, "UTF-8");
|
||||
}catch (IOException e){
|
||||
e.printStackTrace();
|
||||
return allLines;
|
||||
}
|
||||
}
|
||||
|
||||
public String makeUpSpectrum(PHDFile phd) {
|
||||
StringBuilder spectrum = new StringBuilder();
|
||||
//PHD文本内容头部部分
|
||||
|
|
|
@ -4411,6 +4411,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
@Override
|
||||
public Result Spectrum(Integer sampleId, String fileName, HttpServletRequest request) {
|
||||
Result result = new Result();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
String userName = JwtUtil.getUserNameByToken(request);
|
||||
Cache<String, PHDFile> phdCache = localCache.getPHDCache();
|
||||
PHDFile phd = phdCache.getIfPresent(fileName + StringPool.DASH + userName);
|
||||
|
@ -4419,8 +4420,13 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
return result;
|
||||
}
|
||||
String spectrum = gammaFileUtil.makeUpSpectrum(phd);
|
||||
map.put("Spectrum", spectrum);
|
||||
if(StringUtils.isNotBlank(phd.getTmpFilePath())) {
|
||||
List<String> lines = gammaFileUtil.readLine(phd.getTmpFilePath());
|
||||
map.put("phdSpectrum", lines);
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(spectrum);
|
||||
result.setResult(map);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -407,7 +407,7 @@ public class StationOperationServiceImpl extends ServiceImpl<StationOperationMap
|
|||
//根据缓存日期 得到开始查询时间
|
||||
LocalDateTime startDate = endDate.minusDays(cacheTime.intValue());
|
||||
//获取到开始时间的秒数
|
||||
long startMill = startDate.toInstant(ZoneOffset.UTC).toEpochMilli();
|
||||
long startMill = startDate.toInstant(ZoneOffset.UTC).toEpochMilli()/1000;
|
||||
//过滤出当前用户关注的台站信息
|
||||
List<StationData> stationDataList = new LinkedList<>();
|
||||
if (CollectionUtils.isNotEmpty(stationDataMap)) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user