diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/email/EmailLogEvent.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/email/EmailLogEvent.java new file mode 100644 index 00000000..c086e40a --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/email/EmailLogEvent.java @@ -0,0 +1,103 @@ +package org.jeecg.common.email; + +import lombok.Data; +import org.jeecg.modules.base.entity.postgre.SysEmail; + +import java.util.Date; + +/** + * 邮件日志事件 + */ +@Data +public class EmailLogEvent { + + /** + * 区分日志生成是getEmail还是sendEmail的日志 + */ + private String gsType; + /** + * 邮件配置对象 + */ + private SysEmail email; + /** + * 状态 + */ + private String state; + /** + * 当前位于邮箱流程的位置 + */ + private String logProcess; + /** + * 邮件主题 + */ + private String subject; + /** + * 接收时间 + */ + private Date recieveTime; + /** + * 能谱文件名称 + */ + private String emlPath; + /** + * PHD文件临时存储路径 + */ + private String phdMailLoadPath; + /** + * + * 日志时间 + */ + private Date logTime; + + public EmailLogEvent(){ + + } + + public EmailLogEvent(String gsType, SysEmail email, String state, String logProcess) { + this.gsType = gsType; + this.email = email; + this.state = state; + this.logProcess = logProcess; + this.logTime = new Date(); + } + + public EmailLogEvent(String gsType,String logProcess) { + this.gsType = gsType; + this.logProcess = logProcess; + this.logTime = new Date(); + } + + public EmailLogEvent(String gsType,String state, String logProcess) { + this.gsType = gsType; + this.state = state; + this.logProcess = logProcess; + this.logTime = new Date(); + } + + public EmailLogEvent(String gsType,String state, String logProcess,String phdMailLoadPath) { + this.gsType = gsType; + this.state = state; + this.logProcess = logProcess; + this.phdMailLoadPath = phdMailLoadPath; + this.logTime = new Date(); + } + + public EmailLogEvent(String gsType,String state, String logProcess,String subject,Date recieveTime,String emlPath) { + this.gsType = gsType; + this.state = state; + this.logProcess = logProcess; + this.subject = subject; + this.recieveTime = recieveTime; + this.emlPath = emlPath; + this.logTime = new Date(); + } + + public EmailLogEvent(String gsType,String state, String logProcess,String subject,Date recieveTime) { + this.gsType = gsType; + this.state = state; + this.logProcess = logProcess; + this.subject = subject; + this.recieveTime = recieveTime; + this.logTime = new Date(); + } +} diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/email/EmailLogManager.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/email/EmailLogManager.java new file mode 100644 index 00000000..668bf016 --- /dev/null +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/email/EmailLogManager.java @@ -0,0 +1,368 @@ +package org.jeecg.common.email; + +import cn.hutool.core.io.FileUtil; +import com.baomidou.mybatisplus.core.toolkit.StringPool; +import lombok.Setter; +import org.jeecg.common.constant.StringConstant; +import org.jeecg.common.properties.SpectrumPathProperties; +import org.jeecg.common.util.DateUtils; + +import java.io.File; +import java.time.LocalDateTime; +import java.util.*; + +/** + * 邮件过程日志 + */ +public class EmailLogManager { + + public static final String GS_TYPE_GET = "GET"; + public static final String GS_TYPE_SEND = "SEND"; + public static final String CONNECT = "CONNECT"; + public static final String GETALLID = "GETALLID"; + public static final String GETIDHEADER = "GETIDHEADER"; + public static final String GETIDBODY = "GETIDBODY"; + public static final String GETIDEML = "GETIDEML"; + public static final String DELETEID = "DELETEID"; + public static final String EXPUNGE = "EXPUNGE"; + public static final String DONE = "DONE"; + public static final String STATUS_SUCCESS = " SUCCESS"; + public static final String STATUS_ERROR = " ERROR"; + + private static final String FIXED_FILE_NAME = "Mail"; + private static final String FIXED_FILE_SUFFIX = ".log"; + private static final String LOG_SUFFIX = "....."; + + /** + * 邮箱连接全局日志事件 + */ + @Setter + private EmailLogEvent connectLogEvent = null; + /** + * 邮件同步全局日志事件 + */ + @Setter + private EmailLogEvent getAllIdLogEvent = null; + + /** + * 完成解析邮件流程的线程id集合 + */ + private LinkedList completeThreadIds = new LinkedList<>(); + + /** + * 线程邮件日志队列 + */ + private LinkedHashMap> queue = new LinkedHashMap<>(); + + private SpectrumPathProperties spectrumPathProperties; + + private static EmailLogManager emailLogManager = null; + + public static EmailLogManager getInstance(){ + return emailLogManager; + } + + public EmailLogManager(SpectrumPathProperties spectrumPathProperties) { + this.spectrumPathProperties = spectrumPathProperties; + EmailLogExecThread logExecThread = new EmailLogExecThread(); + logExecThread.setName("email-get-exec-thread"); + logExecThread.start(); + } + + /** + * 初始化 + * @param spectrumPathProperties + */ + public static void init(SpectrumPathProperties spectrumPathProperties){ + emailLogManager = new EmailLogManager(spectrumPathProperties); + } + + /** + * 追加日志事件 + * @param event + */ + public void offer(Long threadId,EmailLogEvent event){ + synchronized (completeThreadIds){ + if(queue.containsKey(threadId)){ + queue.get(threadId).offer(event); + if(EmailLogManager.DONE.equals(event.getLogProcess())){ + completeThreadIds.offer(threadId); + completeThreadIds.notify(); + } + }else{ + LinkedList logEventList = new LinkedList<>(); + logEventList.offer(event); + queue.put(threadId,logEventList); + } + } + } + + /** + * 获取日志事件 + * @return + * @throws InterruptedException + */ + public LinkedList take(Long threadId) throws InterruptedException { + synchronized (completeThreadIds){ + final LinkedList logEventList = queue.remove(threadId); + return logEventList; + } + } + + /** + * 获取解析邮件完成的线程id + * @return + * @throws InterruptedException + */ + public Long getCompleteThreadId() throws InterruptedException { + synchronized (completeThreadIds){ + if(completeThreadIds.isEmpty()){ + completeThreadIds.wait(); + return null; + } + final Long threadId = completeThreadIds.removeFirst(); + return threadId; + } + } + + /** + * 邮件日志执行线程 + */ + private class EmailLogExecThread extends Thread{ + + @Override + public void run() { + for(;;){ + try { + final Long threadId = EmailLogManager.getInstance().getCompleteThreadId(); + if(Objects.nonNull(threadId)){ + final LinkedList logEventList = EmailLogManager.getInstance().take(threadId); + if(Objects.nonNull(getAllIdLogEvent)){ + logEventList.addFirst(getAllIdLogEvent); + } + if(Objects.nonNull(connectLogEvent)){ + logEventList.addFirst(connectLogEvent); + } + List logContentList = new ArrayList<>(); + logEventList.forEach(logEvent->{ + final String logContent = getLogContent(logEvent); + logContentList.add(logContent); + }); + writeLog(GS_TYPE_GET,logContentList); + } + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + } + + /** + * 获取日志内容 + * @param event + */ + private String getLogContent(EmailLogEvent event) { + String logContent = ""; + switch (event.getLogProcess()) { + case CONNECT: + logContent = this.getConnectLog(event); + break; + case GETALLID: + logContent = this.getGetAllIdLog(event); + break; + case GETIDHEADER: + logContent = this.getIdHeaderLog(event); + break; + case GETIDBODY: + logContent = this.getIdBodyLog(event); + break; + case GETIDEML: + logContent = this.getIdEmlLog(event); + break; + case DELETEID: + logContent = this.getDeleteLog(event); + break; + case EXPUNGE: + logContent = this.getExpungeLog(event); + break; + case DONE: + logContent = this.getDoneLog(event); + break; + default: + break; + } + return logContent; + } + + /** + * 获取连接日志 + * @param event + * @return + */ + private String getConnectLog(EmailLogEvent event){ + StringBuilder logContent = new StringBuilder(); + logContent.append(DateUtils.formatDate(event.getLogTime(),"yyyy-MM-dd HH:mm:ss")); + logContent.append(" Connect Server:"); + logContent.append(event.getEmail().getEmailServerAddress()); + logContent.append(" Port:"); + logContent.append(event.getEmail().getPort()); + logContent.append(event.getState()); + logContent.append(LOG_SUFFIX); + logContent.append(System.lineSeparator()); + logContent.append(System.lineSeparator()); + return logContent.toString(); + } + + /** + * 获取邮件同步日志 + * @param event + * @return + */ + private String getGetAllIdLog(EmailLogEvent event){ + StringBuilder logContent = new StringBuilder(); + logContent.append(DateUtils.formatDate(event.getLogTime(),"yyyy-MM-dd HH:mm:ss")); + logContent.append(" Get All FileName "); + logContent.append(event.getState()); + logContent.append(LOG_SUFFIX); + logContent.append(System.lineSeparator()); + logContent.append(System.lineSeparator()); + return logContent.toString(); + } + + /** + * 获取获取邮件主题日志 + * @param event + * @return + */ + private String getIdHeaderLog(EmailLogEvent event){ + StringBuilder logContent = new StringBuilder(); + logContent.append(DateUtils.formatDate(event.getLogTime(),"yyyy-MM-dd HH:mm:ss")); + logContent.append(" Get FileNameHeader "); + logContent.append(event.getState()); + logContent.append(LOG_SUFFIX); + logContent.append(System.lineSeparator()); + logContent.append(System.lineSeparator()); + return logContent.toString(); + } + + /** + * 获取邮件内容日志 + * @param event + * @return + */ + private String getIdBodyLog(EmailLogEvent event){ + StringBuilder logContent = new StringBuilder(); + logContent.append(DateUtils.formatDate(event.getLogTime(),"yyyy-MM-dd HH:mm:ss")); + logContent.append(" Get File "); + logContent.append(event.getPhdMailLoadPath()); + logContent.append(event.getState()); + logContent.append(LOG_SUFFIX); + logContent.append(System.lineSeparator()); + logContent.append(System.lineSeparator()); + return logContent.toString(); + } + + /** + * 下载邮件日志 + * @param event + * @return + */ + private String getIdEmlLog(EmailLogEvent event){ + StringBuilder logContent = new StringBuilder(); + logContent.append(DateUtils.formatDate(event.getLogTime(),"yyyy-MM-dd HH:mm:ss")); + 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.getState()); + logContent.append(" EmlFile "); + logContent.append(event.getEmlPath()); + logContent.append(LOG_SUFFIX); + logContent.append(System.lineSeparator()); + logContent.append(System.lineSeparator()); + return logContent.toString(); + } + + /** + * 下载邮件日志 + * @param event + * @return + */ + private String getDeleteLog(EmailLogEvent event){ + StringBuilder logContent = new StringBuilder(); + logContent.append(DateUtils.formatDate(event.getLogTime(),"yyyy-MM-dd HH:mm:ss")); + 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.getState()); + logContent.append(LOG_SUFFIX); + logContent.append(System.lineSeparator()); + logContent.append(System.lineSeparator()); + return logContent.toString(); + } + + /** + * 下载邮件日志 + * @param event + * @return + */ + private String getExpungeLog(EmailLogEvent event){ + StringBuilder logContent = new StringBuilder(); + logContent.append(DateUtils.formatDate(event.getLogTime(),"yyyy-MM-dd HH:mm:ss")); + 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.getState()); + logContent.append(LOG_SUFFIX); + logContent.append(System.lineSeparator()); + logContent.append(System.lineSeparator()); + return logContent.toString(); + } + + /** + * 完成日志 + * @param event + * @return + */ + private String getDoneLog(EmailLogEvent event){ + StringBuilder logContent = new StringBuilder(); + logContent.append(DateUtils.formatDate(event.getLogTime(),"yyyy-MM-dd HH:mm:ss")); + logContent.append(" Done"); + logContent.append(LOG_SUFFIX); + logContent.append(System.lineSeparator()); + logContent.append(System.lineSeparator()); + return logContent.toString(); + } + + /** + * 把日志写入文件 + */ + private void writeLog(String gsType, List logContentList){ + LocalDateTime now = LocalDateTime.now(); + StringBuilder logFilePath = new StringBuilder(); + logFilePath.append(spectrumPathProperties.getRootPath()); + logFilePath.append(File.separator); + logFilePath.append(spectrumPathProperties.getLogPath()); + logFilePath.append(File.separator); + logFilePath.append(FIXED_FILE_NAME); + logFilePath.append(File.separator); + logFilePath.append(gsType); + logFilePath.append(File.separator); + logFilePath.append(now.getYear()); + logFilePath.append(File.separator); + logFilePath.append(now.getMonthValue()); + logFilePath.append(File.separator); + logFilePath.append(now.getYear()); + logFilePath.append(StringConstant.DASH); + logFilePath.append(now.getMonthValue()); + logFilePath.append(StringConstant.DASH); + logFilePath.append(now.getDayOfMonth()); + logFilePath.append(StringConstant.UNDER_LINE); + logFilePath.append(FIXED_FILE_NAME); + logFilePath.append(FIXED_FILE_SUFFIX); + + FileUtil.appendLines(logContentList,logFilePath.toString(),"UTF-8"); + } +} \ No newline at end of file diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/email/EmailServiceManager.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/email/EmailServiceManager.java index 3df1fa17..6c0a7a86 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/email/EmailServiceManager.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/email/EmailServiceManager.java @@ -1,25 +1,22 @@ package org.jeecg.common.email; import cn.hutool.core.util.ArrayUtil; -import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.google.common.collect.Lists; import com.sun.mail.imap.IMAPStore; import com.sun.mail.smtp.SMTPAddressFailedException; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.jeecg.common.api.dto.message.MessageDTO; +import org.jeecg.common.constant.StringConstant; import org.jeecg.common.constant.SymbolConstant; import org.jeecg.common.email.emuns.MailContentType; import org.jeecg.common.properties.SpectrumPathProperties; -import org.jeecg.common.util.LogFileUtil; +import org.jeecg.common.util.DateUtils; import org.jeecg.modules.base.entity.postgre.SysEmail; import org.jetbrains.annotations.NotNull; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.stereotype.Component; import javax.mail.*; -import javax.mail.internet.AddressException; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeUtility; @@ -38,6 +35,11 @@ import java.util.stream.Collectors; @Slf4j public class EmailServiceManager { + /** + * 存储到eml目录的Email文件后缀 + */ + private final static String SAVE_EML_SUFFIX = ".eml"; + private SysEmail email; private SpectrumPathProperties spectrumPathProperties; /** @@ -105,63 +107,77 @@ public class EmailServiceManager { /** * 接收邮件 */ - public Message[] receiveMail() throws MessagingException { - //配置邮件服务属性 - Properties props = new Properties(); - props.put("mail.store.protocol","imap"); - props.put("mail.imap.host",email.getEmailServerAddress()); - props.put("mail.imap.port",email.getPort()); - //获取邮件回话 - final Session session = Session.getInstance(props, new Authenticator() { - @Override - protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(email.getUsername(), email.getPassword()); - } - }); - Map iam = new HashMap<>(); - iam.put("name", "myname"); - iam.put("version", "1.0.0"); - iam.put("vendor", "myclient"); - iam.put("support-email", "testmail@test.com"); - //获取smtp协议的存储对象 - store = (IMAPStore) session.getStore(); - //连接 - store.connect(); - store.id(iam); - //获取收件箱 - folder = store.getFolder("INBOX");//INBOX - folder.open(Folder.READ_WRITE); - //如果邮箱邮件数量 > 0 - final int messageCount = folder.getMessageCount(); - if(messageCount > 0){ - Message[] messages = null; - if(Objects.isNull(this.systemStartupTime)){ - int finalNum = messageCount > this.receiveNum?this.receiveNum:messageCount; - //邮箱邮件下标是从1开始的 - return folder.getMessages(1,finalNum); - } - SearchTerm searchTerm = new ReceivedDateTerm(ComparisonTerm.GE,this.systemStartupTime); - messages = folder.search(searchTerm); - Arrays.sort(messages, (o1, o2) -> { - try { - return o1.getReceivedDate().compareTo(o2.getReceivedDate()); - } catch (MessagingException e) { - e.printStackTrace(); + public Message[] receiveMail() { + String status = EmailLogManager.STATUS_SUCCESS; + try{ + //配置邮件服务属性 + Properties props = new Properties(); + props.put("mail.store.protocol","imap"); + props.put("mail.imap.host",email.getEmailServerAddress()); + props.put("mail.imap.port",email.getPort()); + //获取邮件回话 + final Session session = Session.getInstance(props, new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(email.getUsername(), email.getPassword()); } - return 0; }); - if(this.receiveNum >= messages.length){ - return messages; - }else{ - return Arrays.copyOfRange(messages,0,this.receiveNum-1); + Map iam = new HashMap<>(); + iam.put("name", "myname"); + iam.put("version", "1.0.0"); + iam.put("vendor", "myclient"); + iam.put("support-email", "testmail@test.com"); + //获取smtp协议的存储对象 + store = (IMAPStore) session.getStore(); + //连接 + store.connect(); + store.id(iam); + //获取收件箱 + folder = store.getFolder("INBOX");//INBOX + folder.open(Folder.READ_WRITE); + //如果邮箱邮件数量 > 0 + final int messageCount = folder.getMessageCount(); + if(messageCount > 0){ + Message[] messages = null; + if(Objects.isNull(this.systemStartupTime)){ + int finalNum = messageCount > this.receiveNum?this.receiveNum:messageCount; + //邮箱邮件下标是从1开始的 + return folder.getMessages(1,finalNum); + } + SearchTerm searchTerm = new ReceivedDateTerm(ComparisonTerm.GE,this.systemStartupTime); + messages = folder.search(searchTerm); + Arrays.sort(messages, (o1, o2) -> { + try { + return o1.getReceivedDate().compareTo(o2.getReceivedDate()); + } catch (MessagingException e) { + e.printStackTrace(); + } + return 0; + }); + if(this.receiveNum >= messages.length){ + return messages; + }else{ + return Arrays.copyOfRange(messages,0,this.receiveNum-1); + } } + }catch (MessagingException e){ + status = EmailLogManager.STATUS_ERROR; + log.error("Email connection is abnormal, account is {}, service is {},the reason is {}.",email.getName(),email.getEmailServerAddress(),e.getMessage()); + e.printStackTrace(); + return null; + }finally { + EmailLogEvent connectEvent = new EmailLogEvent(EmailLogManager.GS_TYPE_GET,email,status,EmailLogManager.CONNECT); + EmailLogManager.getInstance().setConnectLogEvent(connectEvent); + //GetAllId C++原业务是把远程邮箱邮件同步到C++,本次java编写没有这一步,所以和Connect绑定,若Connect成功则GetAllId成功 + EmailLogEvent getAllEvent = new EmailLogEvent(EmailLogManager.GS_TYPE_GET,status,EmailLogManager.GETALLID); + EmailLogManager.getInstance().setGetAllIdLogEvent(getAllEvent); } return null; } /* - * 测试收件邮箱账号是否可以正常使用 - * */ + * 测试收件邮箱账号是否可以正常使用 + * */ public boolean canReceive(){ Integer port = email.getPort(); String username = email.getUsername(); @@ -174,6 +190,7 @@ public class EmailServiceManager { props.put("mail.imap.port", port); Session session = Session.getInstance(props, new Authenticator() { + @Override protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(username, password); } @@ -233,8 +250,10 @@ public class EmailServiceManager { props.put("mail.transport.protocol", "smtp"); props.put("mail.smtp.host", host); props.put("mail.smtp.port", port); + props.put("mail.smtp.auth", "true"); Session session = Session.getInstance(props, new Authenticator() { + @Override protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(username, password); } @@ -394,6 +413,28 @@ public class EmailServiceManager { } } + /** + * 获取邮件主题 + * @param message + * @return + */ + public String getMailSubject(@NotNull Message message) throws MessagingException { + String subject = ""; + String status = EmailLogManager.STATUS_SUCCESS; + try { + subject = MimeUtility.decodeText(message.getSubject()); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } catch (MessagingException e) { + status = EmailLogManager.STATUS_ERROR; + throw e; + }finally { + EmailLogEvent event = new EmailLogEvent(EmailLogManager.GS_TYPE_GET,status,EmailLogManager.GETIDHEADER); + EmailLogManager.getInstance().offer(Thread.currentThread().getId(),event); + } + return subject; + } + /** * 获取邮件内容 * @param part @@ -402,24 +443,14 @@ public class EmailServiceManager { * @throws IOException */ public void getMailContent(@NotNull Part part, StringBuilder content) throws MessagingException, IOException { - try { - if(part.isMimeType(MailContentType.PLAIN.getContentType())){ - content.append(part.getContent()); - }else if(part.isMimeType("multipart/*")){ - Multipart multipart = (Multipart) part.getContent(); - for(int i=0;i select - r.stationName as stationName, - r.dataType as dataType, - r.originalDataNumber as originalDataNumber, - r.anlyseDataNumber as anlyseDataNumber - from ( - select - substr(t.site_det_code,1,5) as stationName, - t.data_type as dataType, - ( - 1+ - (select count(*) from original.GARDS_ROI_LIMITS grl where grl.sample_id = t.sample_id)+ - (select count(*) from original.GARDS_SAMPLE_AUX gsa where gsa.sample_id = t.sample_id)+ - (select count(*) from original.GARDS_SAMPLE_CERT gsc where gsc.sample_id = t.sample_id)+ - (select count(*) from original.GARDS_SAMPLE_CERT_LINE gscl where gscl.sample_id = t.sample_id)+ - (select count(*) from original.GARDS_SAMPLE_DESCRIPTION gsd where gsd.sample_id = t.sample_id)+ - (select count(*) from original.GARDS_SAMPLE_RATIOS gsr where gsr.sample_id = t.sample_id)+ - (select count(*) from original.GARDS_SPECTRUM gs where gs.sample_id = t.sample_id)+ - (select count(*) from original.GARDS_TOTAL_EFFICIENCY_PAIRS gtep where gtep.sample_id = t.sample_id)+ - (select count(*) from original.GARDS_HISTOGRAM gh where gh.sample_id = t.sample_id)+ - (select count(*) from original.GARDS_CALIBRATION_PAIRS_ORIG gcp where gcp.sample_id = t.sample_id)+ - (select count(*) from original.GARDS_BG_EFFICIENCY_PAIRS gbep where gbep.sample_id = t.sample_id) - ) as originalDataNumber, - ( - (select count(*) from rnauto.GARDS_ANALYSES ga where ga.sample_id = t.sample_id)+ - (select count(*) from rnauto.GARDS_CALIBRATION gc where gc.sample_id = t.sample_id)+ - (select count(*) from rnauto.GARDS_CALIBRATION_PAIRS gcp where gcp.sample_id = t.sample_id)+ - (select count(*) from rnauto.GARDS_NUCL_IDED gn where gn.sample_id = t.sample_id)+ - (select count(*) from rnauto.GARDS_NUCL_LINES_IDED gnli where gnli.sample_id = t.sample_id)+ - (select count(*) from rnauto.GARDS_ROI_CHANNELS grc where grc.sample_id = t.sample_id)+ - (select count(*) from rnauto.GARDS_ROI_RESULTS grr where grr.sample_id = t.sample_id)+ - (select count(*) from rnauto.GARDS_XE_RESULTS gxr where gxr.sample_id = t.sample_id)+ - (select count(*) from rnauto.GARDS_PEAKS gp where gp.sample_id = t.sample_id)+ - (select count(*) from rnauto.GARDS_QC_CHECK gqc where gqc.sample_id = t.sample_id) - ) as anlyseDataNumber, - t.moddate - from original.GARDS_SAMPLE_DATA t - where t.moddate between #{beginDate} and #{endDate} - union all - select - min(t.station_code) as stationName, - 'MET' as dataType, - count(*) as originalDataNumber, - 0 as anlyseDataNumber, - min(t.moddate) as moddate - from original.GARDS_MET_DATA t - where t.moddate between #{beginDate} and #{endDate} - group by t.input_file_name - union all - select - min(t.station_code) as stationName, - 'SOH' as dataType, - count(*) as originalDataNumber, - 0 as anlyseDataNumber, - min(t.moddate) as moddate - from original.GARDS_SOH_DATA t - where t.moddate between #{beginDate} and #{endDate} - group by t.input_file_name - union all - select - t.station_code as stationName, - 'ALERT' as dataType, - 1 as originalDataNumber, - 0 as anlyseDataNumber, - t.time as moddate - from original.GARDS_ALERT_DATA t - where t.time between #{beginDate} and #{endDate} - ) r order by r.moddate asc + f.station_name as stationName, + f.data_type as dataType, + f.original_data_number as originalDataNumber, + f.anlyse_data_number as anlyseDataNumber + from( + select + r.station_name, + r.data_type, + sum(r.original_data_number) as original_data_number, + sum(r.anlyse_data_number) as anlyse_data_number + from( + select + substr(t.site_det_code,1,5) as station_name, + t.data_type, + 1 as original_data_number, + nvl2((select t.sample_id from rnauto.GARDS_ANALYSES ga where ga.sample_id = t.sample_id),1,0) as anlyse_data_number + from original.GARDS_SAMPLE_DATA t + where t.moddate between #{beginDate} and #{endDate} + ) r + group by r.station_name,r.data_type + union all + select + t.station_code as station_name, + 'MET' as data_type, + count(*) as original_data_number, + 0 as anlyse_data_number + from original.GARDS_MET_DATA t + where t.moddate between #{beginDate} and #{endDate} + group by t.station_code + union all + select + t.station_code as station_name, + 'SOH' as data_type, + count(*) as original_data_number, + 0 as anlyse_data_number + from original.GARDS_SOH_DATA t + where t.moddate between #{beginDate} and #{endDate} + group by t.station_code + union all + select + t.station_code as station_name, + 'ALERT' as data_type, + count(*) as original_data_number, + 0 as anlyseDataNumber + from original.GARDS_ALERT_DATA t + where t.time between #{beginDate} and #{endDate} + group by t.station_code + ) f order by f.station_name,f.data_type asc \ No newline at end of file diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsStationsService.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsStationsService.java index f462b7e0..636453aa 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsStationsService.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/GardsStationsService.java @@ -11,7 +11,10 @@ public interface GardsStationsService extends IService { /** * 校验台站编码是否存在 + * @param site_code + * @param fileName * @return + * @throws StationNotFoundException */ - GardsStations check(String site_code) throws StationNotFoundException; + GardsStations check(String site_code,String fileName) throws StationNotFoundException; } diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/AlertSpectrumServiceImpl.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/AlertSpectrumServiceImpl.java index aed8319b..93008725 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/AlertSpectrumServiceImpl.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/AlertSpectrumServiceImpl.java @@ -39,7 +39,7 @@ public class AlertSpectrumServiceImpl extends ServiceImpl implements GardsStationsService { + private final TaskProperties taskProperties; + private SpectrumPathProperties spectrumPathProperties; /** * 校验台站编码是否存在 - * * @param site_code + * @param fileName * @return + * @throws StationNotFoundException */ @Override - public GardsStations check(String site_code) throws StationNotFoundException { + public GardsStations check(String site_code,String fileName) throws StationNotFoundException { LambdaQueryWrapper gardsStationsQuery = new LambdaQueryWrapper<>(); gardsStationsQuery.select(GardsStations::getStationId); gardsStationsQuery.eq(GardsStations::getStationCode,site_code); final GardsStations station = this.baseMapper.selectOne(gardsStationsQuery); if (Objects.isNull(station)) { - throw new StationNotFoundException("station_code:"+site_code+"=0"); + StringBuilder logContent = new StringBuilder(); + logContent.append("station_code:"+site_code+"=0"); + logContent.append(StringConstant.SPACE); + logContent.append(taskProperties.getUndealFileTimeOut()); + + log.error("This station does not exist, the number is {}.",site_code); +// LogFileUtil.errorLog(spectrumServiceQuotes.getSpectrumPathProperties().getRootPath() + File.separator + spectrumServiceQuotes.getSpectrumPathProperties().getLogPath(), finalFileName.toString(), warning); + throw new StationNotFoundException("This station does not exist, the number is "+site_code+"."); } return station; } diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/MetSpectrumServiceImpl.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/MetSpectrumServiceImpl.java index 01b09677..400b2225 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/MetSpectrumServiceImpl.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/MetSpectrumServiceImpl.java @@ -45,7 +45,7 @@ public class MetSpectrumServiceImpl extends ServiceImpl list = Lists.newArrayList(); if(struct.record_count > 0){ for(int i=0;i roi = analyseResult.ROI.stream().map(Object::toString).collect(Collectors.toList()); - List s_roi_cts = analyseResult.s_roi_cts.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList()); - List g_roi_cts = analyseResult.g_roi_cts.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList()); - List d_roi_cts = analyseResult.d_roi_cts.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList()); + List s_roi_cts = analyseResult.s_roi_cts.stream().map(v->NumberFormatUtil.numberFormat(String.valueOf(v))).collect(Collectors.toList()); + List g_roi_cts = analyseResult.g_roi_cts.stream().map(v->NumberFormatUtil.numberFormat(String.valueOf(v))).collect(Collectors.toList()); + List d_roi_cts = analyseResult.d_roi_cts.stream().map(v->NumberFormatUtil.numberFormat(String.valueOf(v))).collect(Collectors.toList()); reportContent.append(grossCountsBlock); reportContent.append(System.lineSeparator()); @@ -693,14 +694,14 @@ public class Sample_B_Analysis implements BlockConstant { List roi_net_count_err = analyseResult.ROI_net_coutns_err; //此参数需第一位补0 analyseResult.LC_CTS.add(0,0D); - List lc = analyseResult.LC_CTS.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList()); + List lc = analyseResult.LC_CTS.stream().map(v->NumberFormatUtil.numberFormat(String.valueOf(v))).collect(Collectors.toList()); reportContent.append(netCountsBlock); reportContent.append(System.lineSeparator()); reportContent.append(super.rowFormat(rowTitle,StringConstant.SPACE,StringConstant.SPACE)); reportContent.append(System.lineSeparator()); for (int i=0;i conErr = analyseResult.ROI_con_uncer_err; analyseResult.LC.add(0,0.0D); analyseResult.MDC.add(0,0.0D); - List lc = analyseResult.LC.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList()); - List mdc = analyseResult.MDC.stream().map(v->super.formatToStr5(v)).collect(Collectors.toList()); + List lc = analyseResult.LC.stream().map(v->NumberFormatUtil.numberFormat(String.valueOf(v))).collect(Collectors.toList()); + List mdc = analyseResult.MDC.stream().map(v->NumberFormatUtil.numberFormat(String.valueOf(v))).collect(Collectors.toList()); reportContent.append(grossCountsBlock); reportContent.append(System.lineSeparator()); reportContent.append(super.rowFormat(rowTitle,StringConstant.SPACE,StringConstant.SPACE,StringConstant.SPACE)); reportContent.append(System.lineSeparator()); for (int i=0;ianalyseResult.MDC_Xe135?"1":"0"; String xe_131m_nid_flag = analyseResult.Xe131m_con>analyseResult.MDC_Xe131m?"1":"0"; diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_G_Analysis.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_G_Analysis.java index 1a1381dd..02aea1b5 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_G_Analysis.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/Sample_G_Analysis.java @@ -111,6 +111,7 @@ public class Sample_G_Analysis { public void analysis() throws GAnalyseException{ log.info("Gamma自动处理分析--Start"); + PHDFile phdFile = new PHDFile(); try { /* 准备Gamma分析需要的数据 */ GStoreMiddleProcessData middleData = new GStoreMiddleProcessData(); @@ -120,7 +121,6 @@ public class Sample_G_Analysis { GammaFileUtil gammaFileUtil = ApplicationContextUtil.getContext().getBean(GammaFileUtil.class); parameterProperties = ApplicationContextUtil.getContext().getBean(ParameterProperties.class); - PHDFile phdFile = new PHDFile(); phdFile.setXmlFilePath(parameterProperties.getFilePath()); // 解析PHD文件 spectrumPathProperties = SpringContextUtils.getBean(SpectrumPathProperties.class); @@ -173,8 +173,14 @@ public class Sample_G_Analysis { e.printStackTrace(); log.error("Sample_G_Analysis", e); throw new GAnalyseException("Sample Analyse Error at "+DateUtils.formatDate(new Date(),"yyyy-MM-dd HH:mm:ss")); - }finally { - + } finally { + //删除临时文件 + if (StringUtils.isNotBlank(phdFile.getTmpFilePath())) { + File tmpFile = new File(phdFile.getTmpFilePath()); + if (Objects.nonNull(tmpFile)) { + tmpFile.delete(); + } + } } log.info("Gamma自动处理分析--End"); } diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SamplephdSpectrum.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SamplephdSpectrum.java index 9940e541..43c3e873 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SamplephdSpectrum.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SamplephdSpectrum.java @@ -3,8 +3,6 @@ package org.jeecg.modules.spectrum; import org.jeecg.modules.base.enums.DataType; import org.jeecg.modules.base.enums.SampleStatus; import org.jeecg.modules.base.enums.SystemType; -import org.jeecg.modules.exception.FileRepeatException; - import java.util.Objects; /** @@ -19,7 +17,7 @@ public class SamplephdSpectrum extends AbstractS_D_Q_G_SpectrumHandler { protected void setChina() { AbstractSpectrumHandler spectrumHandler = new DetbkphdSpectrum(); spectrumHandler.initNext(super.spectrumServiceQuotes,super.spectrumFile, - super.currDataType,super.mailContent,super.fromUndel,super.returnFileName); + super.currDataType,super.mailContent,super.spectrumSource,super.returnFileName); spectrumHandler.setPrevious(this); super.setNext(spectrumHandler); } diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SpectrumParsingActuator.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SpectrumParsingActuator.java index c8ac63c1..f5ec2b75 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SpectrumParsingActuator.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SpectrumParsingActuator.java @@ -1,23 +1,13 @@ package org.jeecg.modules.spectrum; -import com.baomidou.mybatisplus.core.toolkit.StringPool; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; -import org.jeecg.common.constant.StringConstant; +import org.jeecg.common.email.EmailLogEvent; +import org.jeecg.common.email.EmailLogManager; import org.jeecg.common.email.EmailServiceManager; -import org.jeecg.common.properties.SpectrumPathProperties; -import org.jeecg.common.util.DateUtils; -import org.jeecg.common.util.LogFileUtil; import org.jeecg.modules.email.EmailProperties; -import org.jeecg.modules.exception.StationNotFoundException; - +import org.jeecg.modules.enums.SpectrumSource; import javax.mail.Message; -import javax.mail.MessagingException; -import javax.mail.internet.InternetAddress; -import javax.mail.internet.MimeUtility; -import java.io.File; -import java.io.FileOutputStream; -import java.util.Date; import java.util.concurrent.CountDownLatch; /** @@ -31,10 +21,7 @@ public class SpectrumParsingActuator implements Runnable{ private final static String EMAIL_BEGIN = "BEGIN IMS2.0"; private final static String MSG_TYPE = "MSG_TYPE DATA"; private final static String EMAIL_STOP = "STOP"; - /** - * 存储到eml目录的Email文件后缀 - */ - private final static String SAVE_EML_SUFFIX = ".eml"; + /** * 邮件对象 @@ -56,10 +43,6 @@ public class SpectrumParsingActuator implements Runnable{ * 相关Spring组件引用 */ private SpectrumServiceQuotes spectrumServiceQuotes; - /** - * 邮件保存路径相关属性 - */ - private SpectrumPathProperties spectrumPathProperties; /** * 邮件计数器 */ @@ -73,36 +56,29 @@ public class SpectrumParsingActuator implements Runnable{ this.emailServiceManager = emailServiceManager; this.taskLatch = taskLatch; this.spectrumServiceQuotes = spectrumServiceQuotes; - this.spectrumPathProperties = spectrumServiceQuotes.getSpectrumPathProperties(); this.emailCounter = emailCounter; } @Override public void run() { String subject = null; - StringBuilder mailContent = null; - String sendTime = null; - String receiveTime = null; - StringBuilder finalFileName = new StringBuilder(); try { + //获取邮件主题 + subject = emailServiceManager.getMailSubject(message); + + //获取邮件内容 + StringBuilder mailContent = new StringBuilder(); + emailServiceManager.getMailContent(message,mailContent); + //所有邮件都需以.eml格式存储到eml文件夹中 - downloadEmailToEmlDir(); + emailServiceManager.downloadEmailToEmlDir(message,emailCounter.getCurrValue()); //保存邮件日志到PG数据库 this.spectrumServiceQuotes.getMailLogService().create(message,emailProperties); - subject = MimeUtility.decodeText(message.getSubject()); - sendTime = DateUtils.formatDate(message.getSentDate(),"yyyy-MM-dd HH:mm:ss"); - receiveTime = DateUtils.formatDate(message.getReceivedDate(),"yyyy-MM-dd HH:mm:ss"); - mailContent = new StringBuilder(); - emailServiceManager.getMailContent(message,mailContent); - //读取文件内容成功后写入日志 - LogFileUtil.emailLog(spectrumServiceQuotes.getSpectrumPathProperties().getRootPath() + File.separator + spectrumServiceQuotes.getSpectrumPathProperties().getLogPath(),"Get", emailProperties, "Successful", "GETALLID", "", ""); - //读取文件内容成功后写入日志 - LogFileUtil.emailLog(spectrumServiceQuotes.getSpectrumPathProperties().getRootPath() + File.separator + spectrumServiceQuotes.getSpectrumPathProperties().getLogPath(),"Get", emailProperties, "Successful", "GETIDEML", subject, ""); //判断是否是IMS2.0协议文件 if(checkMailContent(mailContent,subject)){ AbstractSpectrumHandler spectrumHandler = new SamplephdSpectrum(); - spectrumHandler.init(mailContent.toString(),spectrumServiceQuotes,finalFileName); + spectrumHandler.init(mailContent.toString(),spectrumServiceQuotes,new StringBuilder(),SpectrumSource.FROM_FILE_SOURCE.getSourceType()); final boolean matchResult = spectrumHandler.saveEmailToLocal(); if(matchResult){ //开始解析 @@ -112,25 +88,12 @@ public class SpectrumParsingActuator implements Runnable{ } } } catch (Exception e) { - //生成日志 - String warning = ""; - if (e.getClass().equals(StationNotFoundException.class)) { - warning = e.getMessage()+ StringPool.SPACE+"timeout:0,waittime:"+spectrumServiceQuotes.getTaskProperties().getUndealFileTimeOut(); - } else { - warning = e.getMessage(); - } - LogFileUtil.errorLog(spectrumServiceQuotes.getSpectrumPathProperties().getRootPath() + File.separator + spectrumServiceQuotes.getSpectrumPathProperties().getLogPath(), finalFileName.toString(), warning); - log.error("This email failed to parse. The email subject is: {}, sent on: {}, received on: {}, and the reason for the failure is: {}",subject,sendTime,receiveTime,e.getMessage()); e.printStackTrace(); }finally { + emailServiceManager.removeMail(message); + EmailLogEvent expungeEvent = new EmailLogEvent(EmailLogManager.GS_TYPE_GET,EmailLogManager.DONE); + EmailLogManager.getInstance().offer(Thread.currentThread().getId(),expungeEvent); this.taskLatch.countDown(); - //删除邮箱中已处理过的邮件 - try { - emailServiceManager.removeMail(message); - } catch (MessagingException e) { - e.printStackTrace(); - } - LogFileUtil.emailLog(spectrumServiceQuotes.getSpectrumPathProperties().getRootPath() + File.separator + spectrumServiceQuotes.getSpectrumPathProperties().getLogPath(), "Get", null, "Successful", "DONE", "", ""); } } @@ -164,50 +127,4 @@ public class SpectrumParsingActuator implements Runnable{ return false; } - /** - * 把邮件下载到eml目录 - * 格式为:发件人_主题_年月日_时分秒毫秒_计数(0-10000) - * 当计数大于10000后从0开始,服务重启后也从0开始 - */ - private void downloadEmailToEmlDir() throws Exception{ - try { - //获取发件人 - final String address = ((InternetAddress) message.getFrom()[0]).getAddress(); - final String from = address.substring(0,address.indexOf(StringConstant.AT)); - //获取主题 - String subject = MimeUtility.decodeText(message.getSubject()); - if(subject.indexOf(StringConstant.SLASH) != -1){ - subject = StringUtils.replace(subject,StringConstant.SLASH,""); - } - if(subject.indexOf(StringConstant.COLON) != -1){ - subject = StringUtils.replace(subject,StringConstant.COLON,""); - } - - StringBuilder fileName = new StringBuilder(); - fileName.append(from); - fileName.append(StringConstant.UNDER_LINE); - fileName.append(subject); - fileName.append(StringConstant.UNDER_LINE); - fileName.append(DateUtils.formatDate(new Date(),"YYMMdd")); - fileName.append(StringConstant.UNDER_LINE); - fileName.append(DateUtils.formatDate(new Date(),"HHMMSSSSS")); - fileName.append(StringConstant.UNDER_LINE); - fileName.append(emailCounter.getCurrValue()); - fileName.append(SAVE_EML_SUFFIX); - final String rootPath = spectrumPathProperties.getRootPath(); - final String emlPath = spectrumPathProperties.getEmlPath(); - final File file = new File(rootPath+File.separator+emlPath+File.separator+fileName); - if(!file.exists()){ - file.setWritable(true); - file.setReadable(true); - file.createNewFile(); - } - message.writeTo(new FileOutputStream(file)); - } catch (Exception e) { - //读取文件内容成功后写入日志 - LogFileUtil.emailLog(spectrumServiceQuotes.getSpectrumPathProperties().getRootPath() + File.separator + spectrumServiceQuotes.getSpectrumPathProperties().getLogPath(),"Get", emailProperties, "Error", "GETIDEML", message.getSubject(), ""); - throw e; - } - - } } diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SpectrumServiceQuotes.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SpectrumServiceQuotes.java index 7c3d01ad..f62a115e 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SpectrumServiceQuotes.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/SpectrumServiceQuotes.java @@ -3,7 +3,6 @@ package org.jeecg.modules.spectrum; import lombok.Getter; import lombok.RequiredArgsConstructor; import org.jeecg.common.properties.*; -import org.jeecg.common.util.LogFileUtil; import org.jeecg.common.util.NameStandUtil; import org.jeecg.common.util.RedisStreamUtil; import org.jeecg.modules.datasource.OraDataSourceProperties; @@ -78,8 +77,6 @@ public class SpectrumServiceQuotes { private final NameStandUtil nameStandUtil; - private final LogFileUtil logFileUtil; - private final ApplicationContext applicationContext; /** diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java index 0544e81e..00503a48 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java @@ -887,7 +887,9 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi PHDFile phdFile = phdCache.getIfPresent(key); if (StringUtils.isNotBlank(phdFile.getTmpFilePath())) { File file = new File(phdFile.getTmpFilePath()); - file.delete(); + if (Objects.nonNull(file)) { + file.delete(); + } } // 删除指定key的Cache localCache.deletePHDCache(key); @@ -4951,7 +4953,14 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi String date = phd.getAcq().getAcquisition_start_date().replace("/", ""); String time = phd.getAcq().getAcquisition_start_time().replace(":", "").substring(0, 4); String dataType = phd.getMsgInfo().getData_type().substring(0, 1); - String phdFileName = String.format("%s-%s_%s_%s.PHD", detectorCode, date, time, dataType); + String spectrumQuantity = phd.getHeader().getSpectrum_quantity(); + double acquisitionLiveTime = phd.getAcq().getAcquisition_live_time(); + DecimalFormat df = new DecimalFormat("#.##########"); + //AUX09_003-20151226_1855 _S_FULL_40184.8.PHD + //将acquisition_live_time保留六位有效数字 如果保留一位小数后小数点后的值是0则四舍五入保留整数,否则按正常条件四舍五入保留小数位 + String numberCal = NumberFormatUtil.numberCal(String.valueOf(acquisitionLiveTime)); + numberCal = df.format(Double.valueOf(numberCal)); + String phdFileName = String.format("%s-%s_%s_%s_%s_%s.PHD", detectorCode, date, time, dataType, spectrumQuantity, numberCal); String spectrum = gammaFileUtil.makeUpSpectrum(phd); // 导出数据内容到txt文本 OutputStream fos = null; diff --git a/jeecg-server-cloud/armd-auto-process-start/src/main/java/org/jeecg/JeecgAutoProcessApplication.java b/jeecg-server-cloud/armd-auto-process-start/src/main/java/org/jeecg/JeecgAutoProcessApplication.java index 9d7d32ba..8aa0afa8 100644 --- a/jeecg-server-cloud/armd-auto-process-start/src/main/java/org/jeecg/JeecgAutoProcessApplication.java +++ b/jeecg-server-cloud/armd-auto-process-start/src/main/java/org/jeecg/JeecgAutoProcessApplication.java @@ -4,9 +4,9 @@ import cn.hutool.core.io.FileUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.FileUtils; +import org.jeecg.common.email.EmailLogManager; import org.jeecg.common.properties.SpectrumPathProperties; import org.jeecg.common.properties.TaskProperties; -import org.jeecg.common.util.DateUtils; import org.jeecg.common.util.oConvertUtils; import org.jeecg.modules.*; import org.jeecg.modules.email.EmailReceivePolicy; @@ -76,9 +76,11 @@ public class JeecgAutoProcessApplication extends SpringBootServletInitializer im } //校验临时存储目录是否存在,不存在则创建 checkTempStorageDirectory(); + //初始化邮箱邮件声明周期日志 + EmailLogManager.init(spectrumPathProperties); //校验存储目录是否存在,不存在则创建,存在无操作 checkStorageDirectory(); -// autoProcessManager.start(systemStartupTime); + autoProcessManager.start(systemStartupTime); undealHandleManager.start(); fileSourceHandleManager.start(); // 删除过期的文件 diff --git a/jeecg-server-cloud/armd-auto-process-start/src/main/resources/application.yml b/jeecg-server-cloud/armd-auto-process-start/src/main/resources/application.yml index b77b9afe..8607460a 100644 --- a/jeecg-server-cloud/armd-auto-process-start/src/main/resources/application.yml +++ b/jeecg-server-cloud/armd-auto-process-start/src/main/resources/application.yml @@ -15,6 +15,6 @@ spring: config: import: - optional:nacos:armd.yaml - - optional:nacos:armd-@profile.name@.yaml + - optional:nacos:armd-@profile.name@-pbl.yaml - optional:nacos:armd-analysis-@profile.name@.yaml