fix:1.添加能谱错误事件类型

This commit is contained in:
panbaolin 2024-01-02 15:24:33 +08:00
parent 43381353b8
commit 0e7d84dbcb
3 changed files with 71 additions and 17 deletions

View File

@ -5,6 +5,7 @@ import cn.hutool.core.io.FileUtil;
import org.jeecg.common.constant.StringConstant;
import org.jeecg.common.properties.SpectrumPathProperties;
import org.jeecg.modules.eneity.event.SpectrumErrorEvent;
import org.jeecg.modules.enums.ErrorEventType;
import org.jeecg.modules.enums.ErrorType;
import java.io.File;
@ -46,21 +47,26 @@ public class ErrorLogManager {
String errorContent = "";
//文件名称
String fileName = "";
//台站找不到格式化报错信息
if(event.getErrorType().equals(ErrorType.STATION_ERROR)){
errorContent = String.format(ErrorType.STATION_ERROR.getContent(),event.getFormatArgs());
}else{
errorContent = event.getErrorType().getContent();
}
//headeracquisitionariSamplerFlow错误使用mesg_id生成文件名称
if(event.getErrorType().equals(ErrorType.HEADER_ERROR) || event.getErrorType().equals(ErrorType.ACQUISITION_ERROR) ||
event.getErrorType().equals(ErrorType.AIR_SAMPLER_FLOW_ERROR)){
//第一个参数就是msg_id
fileName = event.getFormatArgs()[0]+SUFFIX;
}else{
fileName = event.getFileName().substring(0,event.getFileName().lastIndexOf(StringConstant.DOT))+SUFFIX;
if(event.getEventType() == ErrorEventType.STATIC_EVENT.getEventType()){
//台站找不到格式化报错信息
if(event.getErrorType().equals(ErrorType.STATION_ERROR)){
errorContent = String.format(ErrorType.STATION_ERROR.getContent(),event.getFormatArgs());
}else{
errorContent = event.getErrorType().getContent();
}
//headeracquisitionariSamplerFlow错误使用mesg_id生成文件名称
if(event.getErrorType().equals(ErrorType.HEADER_ERROR) || event.getErrorType().equals(ErrorType.ACQUISITION_ERROR) ||
event.getErrorType().equals(ErrorType.AIR_SAMPLER_FLOW_ERROR)){
//第一个参数就是msg_id
fileName = event.getFormatArgs()[0]+SUFFIX;
}else{
fileName = event.getFileName().substring(0,event.getFileName().lastIndexOf(StringConstant.DOT))+SUFFIX;
}
}else if(event.getEventType() == ErrorEventType.DYNAMIC_EVENT.getEventType()){
errorContent = event.getDynamicErrorContent();
}
StringBuilder logFilePath = new StringBuilder();
logFilePath.append(spectrumPathProperties.getRootPath());
logFilePath.append(File.separator);

View File

@ -1,22 +1,36 @@
package org.jeecg.modules.eneity.event;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.jeecg.modules.enums.ErrorEventType;
import org.jeecg.modules.enums.ErrorType;
import java.util.Date;
public class SpectrumErrorEvent {
/**
* 事件类型
* 0静态枚举(默认)1动态内容
*/
@Setter @Getter
private int eventType;
@Setter @Getter
private Date time;
/**
* eventType 为0时内容为静态枚举类型
*/
@Setter @Getter
private ErrorType errorType;
/**
* eventType 为1时内容为动态传入内容
*/
@Setter @Getter
private String dynamicErrorContent;
@Setter @Getter
private String fileName;
@ -25,10 +39,18 @@ public class SpectrumErrorEvent {
public SpectrumErrorEvent() {}
public SpectrumErrorEvent(Date time,String dynamicErrorContent,String fileName) {
this.time = time;
this.dynamicErrorContent = dynamicErrorContent;
this.fileName = fileName;
this.setEventType(ErrorEventType.DYNAMIC_EVENT.getEventType());
}
public SpectrumErrorEvent(Date time,ErrorType errorType,String fileName) {
this.time = time;
this.errorType = errorType;
this.fileName = fileName;
this.setEventType(ErrorEventType.STATIC_EVENT.getEventType());
}
public SpectrumErrorEvent(Date time,ErrorType errorType,String fileName,String... formatArgs) {
@ -36,6 +58,6 @@ public class SpectrumErrorEvent {
this.errorType = errorType;
this.fileName = fileName;
this.formatArgs = formatArgs;
this.setEventType(ErrorEventType.STATIC_EVENT.getEventType());
}
}

View File

@ -0,0 +1,26 @@
package org.jeecg.modules.enums;
/**
* 错误事件类型
*/
public enum ErrorEventType {
/**
* 静态错误事件headeracq等
*/
STATIC_EVENT(0),
/**
* 动态错误事件手动传入
*/
DYNAMIC_EVENT(1);
private int eventType;
ErrorEventType(int eventType) {
this.eventType = eventType;
}
public int getEventType(){
return this.eventType;
}
}