diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/ErrorLogManager.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/ErrorLogManager.java index 12fbc580..2e7b6758 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/ErrorLogManager.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/ErrorLogManager.java @@ -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(); - } - //header、acquisition、ariSamplerFlow错误使用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(); + } + //header、acquisition、ariSamplerFlow错误使用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); diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/eneity/event/SpectrumErrorEvent.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/eneity/event/SpectrumErrorEvent.java index 90e64bf5..1c1f7306 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/eneity/event/SpectrumErrorEvent.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/eneity/event/SpectrumErrorEvent.java @@ -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()); } - } diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/enums/ErrorEventType.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/enums/ErrorEventType.java new file mode 100644 index 00000000..4ae00204 --- /dev/null +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/enums/ErrorEventType.java @@ -0,0 +1,26 @@ +package org.jeecg.modules.enums; + +/** + * 错误事件类型 + */ +public enum ErrorEventType { + + /** + * 静态错误事件header、acq等 + */ + STATIC_EVENT(0), + /** + * 动态错误事件,手动传入 + */ + DYNAMIC_EVENT(1); + + private int eventType; + + ErrorEventType(int eventType) { + this.eventType = eventType; + } + + public int getEventType(){ + return this.eventType; + } +}