gamma功能加载数据增加返回内容vPeak数据
error日志报错信息去掉多余参数
This commit is contained in:
parent
7c23d956af
commit
fe6cd6bdc0
|
@ -0,0 +1,131 @@
|
|||
package org.jeecg.common.util;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||
import org.jeecg.common.properties.TaskProperties;
|
||||
import org.jeecg.modules.base.entity.postgre.SysEmail;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
@Component
|
||||
public class LogFileUtil {
|
||||
/**
|
||||
* 相关Spring组件引用
|
||||
*/
|
||||
@Autowired
|
||||
private SpectrumPathProperties spectrumPathProperties;
|
||||
|
||||
|
||||
public void errorLog(String spectrumFileName, String warning) {
|
||||
String logFilePath = spectrumPathProperties.getRootPath() + File.separator + spectrumPathProperties.getLogPath() + File.separator + "Error";
|
||||
File logPath = new File(logFilePath);
|
||||
if (!logPath.exists()) {
|
||||
logPath.mkdir();
|
||||
}
|
||||
String logFileName = logFilePath + File.separator + spectrumFileName.replace("PHD", "log");
|
||||
File logFile = new File(logFileName);
|
||||
StringBuffer out = new StringBuffer();
|
||||
String nowDate = DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss");
|
||||
out.append(nowDate+ StringPool.SPACE + "Data Anlyse Error:");
|
||||
out.append(warning);
|
||||
out.append(System.lineSeparator());
|
||||
out.append(System.lineSeparator());
|
||||
out.append(System.lineSeparator());
|
||||
FileWriter writer = null;
|
||||
try {
|
||||
writer = new FileWriter(logFile, true);
|
||||
writer.write(out.toString());
|
||||
} catch (IOException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
} finally {
|
||||
try {
|
||||
if (Objects.nonNull(writer)) {
|
||||
writer.close();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* GSType 区分日志生成是getEmail还是sendEmail的日志 warning是日志内容 state是状态 成功、失败 logProccess是当前位于邮箱流程的位置
|
||||
* @param GSType
|
||||
* @param email
|
||||
* @param state
|
||||
* @param logProcess
|
||||
*/
|
||||
public void emailLog(String GSType, SysEmail email, String state, String logProcess) {
|
||||
String warning = "";
|
||||
switch (logProcess) {
|
||||
case "CONNECT":
|
||||
warning="Connect Server:"+email.getEmailServerAddress()+" Port:"+email.getPort()+" "+state+".....";
|
||||
break;
|
||||
case "GETALLID":
|
||||
warning="Get All FileName "+state+".....";
|
||||
break;
|
||||
case "GETIDHEADER":
|
||||
warning="Get FileNameHeader "+state+".....";
|
||||
break;
|
||||
case "GETIDBODY":
|
||||
warning="Get File "+"FileName"+" FileNameBody "+state+".....";
|
||||
break;
|
||||
case "GETIDATTACH":
|
||||
warning="Get File "+"subject"+" AttachFile "+"FileName"+" "+state+".....";
|
||||
break;
|
||||
case "GETIDEML":
|
||||
warning="Get File "+"subject"+" EmlFile "+"FileName";
|
||||
break;
|
||||
case "DELETEID":
|
||||
warning="Delete File "+"subject"+" "+state+".....";
|
||||
break;
|
||||
case "EXPUNGE":
|
||||
warning="Expunge File "+"subject"+" "+state+".....";
|
||||
break;
|
||||
case "DONE":
|
||||
warning="Done";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
String logFilePath = spectrumPathProperties.getRootPath() + File.separator + spectrumPathProperties.getLogPath() + File.separator + "Mail" + File.separator + GSType + File.separator + now.getYear() + File.separator + now.getMonthValue();
|
||||
File logPath = new File(logFilePath);
|
||||
if (!logPath.exists()) {
|
||||
logPath.mkdirs();
|
||||
}
|
||||
String logFileName = logFilePath + File.separator + now.getYear() + StringPool.DASH + now.getMonthValue() + StringPool.DASH + now.getDayOfMonth() + StringPool.UNDERSCORE + "Mail.log";
|
||||
File logFile = new File(logFileName);
|
||||
StringBuffer out = new StringBuffer();
|
||||
String nowDate = DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss");
|
||||
out.append(nowDate+ StringPool.SPACE);
|
||||
out.append(warning);
|
||||
out.append(System.lineSeparator());
|
||||
out.append(System.lineSeparator());
|
||||
out.append(System.lineSeparator());
|
||||
FileWriter writer = null;
|
||||
try {
|
||||
writer = new FileWriter(logFile, true);
|
||||
writer.write(out.toString());
|
||||
} catch (IOException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
} finally {
|
||||
try {
|
||||
if (Objects.nonNull(writer)) {
|
||||
writer.close();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
package org.jeecg.common.util;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
||||
import org.jeecg.common.properties.SpectrumPathProperties;
|
||||
import org.jeecg.common.properties.TaskProperties;
|
||||
import org.jeecg.modules.exception.StationNotFoundException;
|
||||
import org.jeecg.modules.spectrum.SpectrumServiceQuotes;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
@Component
|
||||
public class LogFileUtil {
|
||||
|
||||
/**
|
||||
* 任务属性
|
||||
*/
|
||||
@Autowired
|
||||
private TaskProperties taskProperties;
|
||||
/**
|
||||
* 相关Spring组件引用
|
||||
*/
|
||||
@Autowired
|
||||
private SpectrumPathProperties spectrumPathProperties;
|
||||
|
||||
|
||||
public void errorLog(String spectrumFileName, String warning, Exception e) {
|
||||
String logFilePath = spectrumPathProperties.getRootPath() + File.separator + spectrumPathProperties.getLogPath() + File.separator + "Error";
|
||||
File logPath = new File(logFilePath);
|
||||
if (!logPath.exists()) {
|
||||
logPath.mkdir();
|
||||
}
|
||||
String logFileName = logFilePath + File.separator + spectrumFileName.replace("PHD", "log");
|
||||
File logFile = new File(logFileName);
|
||||
StringBuffer out = new StringBuffer();
|
||||
String nowDate = DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss");
|
||||
out.append(nowDate+ StringPool.SPACE + "Data Anlyse Error:");
|
||||
out.append(warning);
|
||||
out.append(System.lineSeparator());
|
||||
out.append(System.lineSeparator());
|
||||
out.append(System.lineSeparator());
|
||||
FileWriter writer = null;
|
||||
try {
|
||||
writer = new FileWriter(logFile, true);
|
||||
writer.write(out.toString());
|
||||
} catch (IOException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
} finally {
|
||||
try {
|
||||
if (Objects.nonNull(writer)) {
|
||||
writer.close();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -154,7 +154,7 @@ public class FileSourceHandleManager{
|
|||
} else {
|
||||
warning = e.getMessage();
|
||||
}
|
||||
spectrumServiceQuotes.getLogFileUtil().errorLog(finalFileName.toString(), warning, e);
|
||||
spectrumServiceQuotes.getLogFileUtil().errorLog(finalFileName.toString(), warning);
|
||||
|
||||
log.error("Parsing the {} file of the filesource directory failed.The reason is {}",spectrumFile.getName(),e.getMessage());
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -164,7 +164,7 @@ public class UndealHandleManager{
|
|||
} else {
|
||||
warning = e.getMessage();
|
||||
}
|
||||
spectrumServiceQuotes.getLogFileUtil().errorLog(finalFileName.toString(), warning, e);
|
||||
spectrumServiceQuotes.getLogFileUtil().errorLog(finalFileName.toString(), warning);
|
||||
log.error("The {} file of the undeal directory fails to be parsed again.The reason is {}",spectrumFile.getName(),e.getMessage());
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
|
|
|
@ -87,9 +87,10 @@ public class SpectrumParsingActuator implements Runnable{
|
|||
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");
|
||||
System.out.println(subject);
|
||||
mailContent = new StringBuilder();
|
||||
emailServiceManager.getMailContent(message,mailContent);
|
||||
//读取文件内容成功后写入日志
|
||||
spectrumServiceQuotes.getLogFileUtil().emailLog("Get", emailProperties, "Successful", "GETALLID");
|
||||
//所有邮件都需以.eml格式存储到eml文件夹中
|
||||
downloadEmailToEmlDir();
|
||||
//判断是否是IMS2.0协议文件
|
||||
|
@ -107,6 +108,9 @@ public class SpectrumParsingActuator implements Runnable{
|
|||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (e.getClass().equals(MessagingException.class)) {
|
||||
spectrumServiceQuotes.getLogFileUtil().emailLog("Get", emailProperties, "Error", "GETALLID");
|
||||
}
|
||||
//生成日志
|
||||
String warning = "";
|
||||
if (e.getClass().equals(StationNotFoundException.class)) {
|
||||
|
@ -114,7 +118,7 @@ public class SpectrumParsingActuator implements Runnable{
|
|||
} else {
|
||||
warning = e.getMessage();
|
||||
}
|
||||
spectrumServiceQuotes.getLogFileUtil().errorLog(finalFileName.toString(), warning, e);
|
||||
spectrumServiceQuotes.getLogFileUtil().errorLog(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 {
|
||||
|
|
|
@ -463,6 +463,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
map.put("dead_time", String.format("%.2f", deadTime*100));
|
||||
map.put("checkBox_updateCal", phd.getSetting().isBUpdateCal());
|
||||
map.put("bAnalyed", phd.isBAnalyed());
|
||||
map.put("peak", phd.getVPeak());
|
||||
// 更新页面折线图信息
|
||||
gammaFileUtil.UpdateChart(phd, map, colorMap);
|
||||
//将当前加载的phd信息加入到缓存中 文件名称作为缓存信息的key
|
||||
|
@ -800,6 +801,7 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi
|
|||
map.put("dead_time", String.format("%.2f", deadTime*100));
|
||||
map.put("checkBox_updateCal", phd.getSetting().isBUpdateCal());
|
||||
map.put("bAnalyed", phd.isBAnalyed());
|
||||
map.put("peak", phd.getVPeak());
|
||||
gammaFileUtil.UpdateChart(phd, map, colorMap);
|
||||
phdCache.put(fileName+"-"+userName, phd);
|
||||
localCache.setPHDCache(phdCache);
|
||||
|
|
Loading…
Reference in New Issue
Block a user