From 947f3be7cc756edca18334f71671c2003eff755f Mon Sep 17 00:00:00 2001 From: nieziyan Date: Fri, 29 Dec 2023 19:33:29 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix=EF=BC=9AsaveQCCheck=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/service/impl/SysDatabaseServiceImpl.java | 9 +++++++-- .../org/jeecg/modules/spectrum/Sample_G_Analysis.java | 9 +++++---- .../src/main/resources/application.yml | 1 + 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/SysDatabaseServiceImpl.java b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/SysDatabaseServiceImpl.java index 0027344c..2cedb6b6 100644 --- a/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/SysDatabaseServiceImpl.java +++ b/jeecg-module-abnormal-alarm/src/main/java/org/jeecg/modules/service/impl/SysDatabaseServiceImpl.java @@ -399,8 +399,13 @@ public class SysDatabaseServiceImpl extends ServiceImpl 0) { + if (!gardsNuclIdedDto.getNucl_ided_Nuclidename().isEmpty()) { String base_NuclideName = "nucl_ided_Nuclidename"; List gardsNuclIdeds = mapFields(gardsNuclIdedDto, gardsNuclIded, base_NuclideName, fieldMap); @@ -868,7 +868,7 @@ public class Sample_G_Analysis { String base_QC = String.valueOf(qcItems.size()); QcCheckDto qcCheckDto = new QcCheckDto(); BeanUtil.copyProperties(middleData,qcCheckDto); - if (qcItems.size() > 0) { + if (!qcItems.isEmpty()) { GardsQcCheck gardsQcCheck = new GardsQcCheck(); List gardsQcChecks = mapFields(qcCheckDto, gardsQcCheck,base_QC,fieldMap); for (GardsQcCheck qcCheck : gardsQcChecks) { @@ -1131,9 +1131,10 @@ public class Sample_G_Analysis { if (type == String.class) { tartgetField.set(tartget, value); } else if (type == Integer.class || type == int.class) { - tartgetField.set(tartget,Integer.valueOf(value)); + // 避免类似0.000的String值转Integer时NumberFormatException + tartgetField.set(tartget, Double.valueOf(value).intValue()); } else if (type == Double.class || type == double.class) { - tartgetField.set(tartget,Double.valueOf(value)); + tartgetField.set(tartget, Double.valueOf(value)); } else if (type == Boolean.class || type == boolean.class) { tartgetField.set(tartget, Boolean.valueOf(value)); } diff --git a/jeecg-server-cloud/armd-spectrum-analysis-start/src/main/resources/application.yml b/jeecg-server-cloud/armd-spectrum-analysis-start/src/main/resources/application.yml index 3deaf293..c5ee5723 100644 --- a/jeecg-server-cloud/armd-spectrum-analysis-start/src/main/resources/application.yml +++ b/jeecg-server-cloud/armd-spectrum-analysis-start/src/main/resources/application.yml @@ -16,4 +16,5 @@ spring: import: - optional:nacos:armd.yaml - optional:nacos:armd-@profile.name@.yaml + - optional:nacos:IDC-Data.yaml - optional:nacos:armd-analysis-@profile.name@.yaml From 0b17702d4337e4055f4d320c62dd321e4139ecac Mon Sep 17 00:00:00 2001 From: nieziyan Date: Fri, 29 Dec 2023 20:02:38 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix=EF=BC=9AsaveQCCheck=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/spectrum/Sample_G_Analysis.java | 62 ++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) 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 7091a1e6..f4723357 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 @@ -1093,7 +1093,7 @@ public class Sample_G_Analysis { return gardsAnalyses; } - public List mapFields(T1 source, T2 tartget, String baseLine, Map fieldMap) { + /* public List mapFields(T1 source, T2 tartget, String baseLine, Map fieldMap) { try { List result = new ArrayList<>(); Class sourceClass = source.getClass(); @@ -1147,6 +1147,66 @@ public class Sample_G_Analysis { e.printStackTrace(); return new ArrayList<>(); } + }*/ + + public List mapFields(T1 source, T2 tartget, String baseLine, Map fieldMap) { + try { + List result = new ArrayList<>(); + Class sourceClass = source.getClass(); + boolean isNumber = NumberUtil.isNumber(baseLine); + int total; + if (isNumber){ + total = Integer.parseInt(baseLine); + }else { + Field declaredField = sourceClass.getDeclaredField(baseLine); + declaredField.setAccessible(true); + List baseList = (List) declaredField.get(source); + if (CollUtil.isEmpty(baseList)) + return result; + total = baseList.size(); + } + Class tartgetClass = (Class) tartget.getClass(); + Field[] sourceFields = sourceClass.getDeclaredFields(); + for (int i = 0; i < total; i++) { + tartget = tartgetClass.newInstance(); + for (Field sourceField : sourceFields) { + try { + sourceField.setAccessible(true); + List sourceList = (List) sourceField.get(source); + if (CollUtil.isEmpty(sourceList)) + continue; + if (sourceList.size() <= i) + continue; + String value = sourceList.get(i); + if (StrUtil.isNotBlank(value)){ + String sourceFieldName = sourceField.getName(); + String targetFieldName = fieldMap.get(sourceFieldName); + targetFieldName = StrUtil.isBlank(targetFieldName) ? sourceFieldName : targetFieldName; + Field tartgetField = tartgetClass.getDeclaredField(targetFieldName); + tartgetField.setAccessible(true); + Class type = tartgetField.getType(); + if (type == String.class) { + tartgetField.set(tartget, value); + } else if (type == Integer.class || type == int.class) { + // 避免类似0.000的String值转Integer时NumberFormatException + tartgetField.set(tartget, Double.valueOf(value).intValue()); + } else if (type == Double.class || type == double.class) { + tartgetField.set(tartget, Double.valueOf(value)); + } else if (type == Boolean.class || type == boolean.class) { + tartgetField.set(tartget, Boolean.valueOf(value)); + } + } + }catch (Exception e){ + log.error("Sample_G_Analysis.mapFields()值映射异常: {}", e.getMessage()); + } + } + result.add(tartget); + } + return result; + } catch (Exception e) { + e.printStackTrace(); + return new ArrayList<>(); + } } private void setPHDFile(PHDFile phdFile, EnergySpectrumStruct spectrumStruct) { From bb511d23e284d9aed8f031a2751652874f9516e6 Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Fri, 29 Dec 2023 20:05:11 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=A4=84=E7=90=86?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=86=85=E5=AE=B9=E8=A7=A3=E6=9E=90=EF=BC=8C?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=E6=A0=BC=E5=BC=8F=E9=94=99=E8=AF=AF=E6=83=85?= =?UTF-8?q?=E5=86=B5=E4=B8=8B=E6=96=87=E4=BB=B6=E9=9C=80=E8=A6=81=E6=94=BE?= =?UTF-8?q?=E7=BD=AE=E5=88=B0errorfile=E6=96=87=E4=BB=B6=E5=A4=B9=E4=B8=8B?= =?UTF-8?q?=EF=BC=8C=E8=A1=A8=E7=A4=BA=E6=96=87=E4=BB=B6=E4=B8=8D=E5=8F=AF?= =?UTF-8?q?=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../properties/SpectrumPathProperties.java | 5 ++ .../exception/DateFormatErrorException.java | 12 +++ .../AbstractS_D_Q_G_SpectrumHandler.java | 73 +++++++++++++++++-- .../spectrum/AbstractSpectrumHandler.java | 27 +++++-- .../jeecg/modules/spectrum/AlertSpectrum.java | 19 +++++ .../spectrum/HealthStatusSpectrum.java | 19 +++++ .../jeecg/modules/spectrum/MetSpectrum.java | 19 +++++ 7 files changed, 164 insertions(+), 10 deletions(-) create mode 100644 jeecg-module-auto-process/src/main/java/org/jeecg/modules/exception/DateFormatErrorException.java diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/SpectrumPathProperties.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/SpectrumPathProperties.java index 4e44e1e2..43ac51f1 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/SpectrumPathProperties.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/SpectrumPathProperties.java @@ -64,6 +64,11 @@ public class SpectrumPathProperties implements Serializable { */ private String filesourcePath; + /** + * 错误文件存储路径 + */ + private String errorFilePath; + /** * 能谱文件存储路径以能谱系统类型/能谱类型为key,以存储路径为value */ diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/exception/DateFormatErrorException.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/exception/DateFormatErrorException.java new file mode 100644 index 00000000..4e60cd5f --- /dev/null +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/exception/DateFormatErrorException.java @@ -0,0 +1,12 @@ +package org.jeecg.modules.exception; + +/** + * 判断日期是否是正确格式 + */ +public class DateFormatErrorException extends RuntimeException { + + public DateFormatErrorException(String message) { + super(message); + } + +} diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/AbstractS_D_Q_G_SpectrumHandler.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/AbstractS_D_Q_G_SpectrumHandler.java index 0cea7364..eb21a45a 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/AbstractS_D_Q_G_SpectrumHandler.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/AbstractS_D_Q_G_SpectrumHandler.java @@ -1,21 +1,20 @@ package org.jeecg.modules.spectrum; import cn.hutool.core.io.FileUtil; +import com.baomidou.mybatisplus.core.toolkit.StringPool; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.util.Strings; import org.jeecg.common.constant.StringConstant; import org.jeecg.common.properties.SpectrumPathProperties; +import org.jeecg.common.util.DateUtils; import org.jeecg.modules.base.entity.original.GardsSampleData; import org.jeecg.modules.base.enums.SampleStatus; import org.jeecg.modules.config.datasource.DataSourceSwitcher; import org.jeecg.modules.eneity.event.FormatErrorEvent; import org.jeecg.modules.eneity.event.RepeatErrorEvent; -import org.jeecg.modules.exception.AcquisitionBlockException; -import org.jeecg.modules.exception.FileRepeatException; -import org.jeecg.modules.exception.HeaderBlockException; -import org.jeecg.modules.exception.PHD_ReadException; +import org.jeecg.modules.exception.*; import org.jeecg.modules.native_jni.EnergySpectrumHandler; import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct; import org.jeecg.modules.service.ISpectrumBlockService; @@ -25,9 +24,11 @@ import java.io.*; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.text.ParseException; import java.util.Date; import java.util.List; import java.util.Objects; +import java.util.Random; /** * 样品谱(Samplephd)、探测器本地谱(Detbkphd)、QC谱(Qcphd)、气体谱(Gasbkphd) @@ -99,7 +100,39 @@ public abstract class AbstractS_D_Q_G_SpectrumHandler extends AbstractSpectrumHa spectrumServiceQuotes.getApplicationContext().publishEvent(new FormatErrorEvent()); throw new PHD_ReadException("THE PHDFile has some blocks can't be read:"+super.spectrumFile.getAbsolutePath()); } - this.sourceData = sourceData; + try { + //如果是其中单一一个为空 抛出异常 + //如果两个都为空 就不抛出异常 + //如果两个都不为空 进行日期格式化 格式化失败 + if ((StringUtils.isBlank(sourceData.collection_start_date) && StringUtils.isNotBlank(sourceData.collection_start_time)) || + (StringUtils.isBlank(sourceData.collection_start_time) && StringUtils.isNotBlank(sourceData.collection_start_date))) { + throw new RuntimeException(); + } else if (StringUtils.isNotBlank(sourceData.collection_start_time) && StringUtils.isNotBlank(sourceData.collection_start_date)) { + DateUtils.parseDate(sourceData.collection_start_date + StringPool.SPACE + sourceData.collection_start_time); + } + + if ((StringUtils.isBlank(sourceData.collection_stop_date) && StringUtils.isNotBlank(sourceData.collection_stop_time)) || + (StringUtils.isBlank(sourceData.collection_stop_time) && StringUtils.isNotBlank(sourceData.collection_stop_date))) { + throw new RuntimeException(); + } else if (StringUtils.isNotBlank(sourceData.collection_stop_time) && StringUtils.isNotBlank(sourceData.collection_stop_date)) { + DateUtils.parseDate(sourceData.collection_stop_date + StringPool.SPACE + sourceData.collection_stop_time); + } + + if ((StringUtils.isBlank(sourceData.acquisition_start_date) && StringUtils.isNotBlank(sourceData.acquisition_start_time)) || + (StringUtils.isBlank(sourceData.acquisition_start_time) && StringUtils.isNotBlank(sourceData.acquisition_start_date))) { + throw new RuntimeException(); + } else if (StringUtils.isNotBlank(sourceData.acquisition_start_time) && StringUtils.isNotBlank(sourceData.acquisition_start_date)) { + DateUtils.parseDate(sourceData.acquisition_start_date + StringPool.SPACE + sourceData.acquisition_start_time); + } + } catch (Exception e) { + //将文件移动到错误文件目录 + super.isDateFormatErr = true; + //发送格式化错误事件,后续统计报告使用 + spectrumServiceQuotes.getApplicationContext().publishEvent(new FormatErrorEvent()); + throw new DateFormatErrorException("This PHDFile contains the wrong date format content:"+super.spectrumFile.getAbsolutePath()); + } finally { + this.sourceData = sourceData; + } } /** @@ -144,6 +177,36 @@ public abstract class AbstractS_D_Q_G_SpectrumHandler extends AbstractSpectrumHa super.spectrumFile = FileUtil.rename(super.spectrumFile, newFileName.toString(), true); } + /** + * 对错误的本地能谱临时文件进行改名 + */ + @Override + protected void updateErrorSpectrumFileName() throws FileNotFoundException { + StringBuilder newFileName = new StringBuilder(); + newFileName.append(this.sourceData.detector_code); + newFileName.append(StringConstant.DASH); + if (StringUtils.isNotBlank(this.sourceData.acquisition_start_date) && StringUtils.isNotBlank(this.sourceData.acquisition_start_time)) { + newFileName.append(StringUtils.replace(this.sourceData.acquisition_start_date,StringConstant.SLASH,"")); + newFileName.append(StringConstant.UNDER_LINE); + newFileName.append(StringUtils.replace(this.sourceData.acquisition_start_time.substring(0,this.sourceData.acquisition_start_time.lastIndexOf(":")),":","")); + } else { + newFileName.append(""); + } + if (StringUtils.isNotBlank(this.sourceData.spectrum_quantity) && Double.isFinite(this.sourceData.acquisition_live_time)) { + newFileName.append(super.spectrumServiceQuotes.getNameStandUtil().GetSuffix(super.currDataType.getType(),this.sourceData.spectrum_quantity,String.valueOf(this.sourceData.acquisition_live_time))); + } else { + Random ran = new Random(); + double live_time = ran.nextDouble() * 10000; + newFileName.append(super.spectrumServiceQuotes.getNameStandUtil().GetSuffix(super.currDataType.getType(),this.sourceData.spectrum_quantity,String.valueOf(live_time))); + } + if(!super.spectrumFile.exists()){ + //发送格式化错误事件,后续统计报告使用 + spectrumServiceQuotes.getApplicationContext().publishEvent(new FormatErrorEvent()); + throw new FileNotFoundException(super.spectrumFile.getAbsolutePath()+" does not exist"); + } + super.spectrumFile = FileUtil.rename(super.spectrumFile, newFileName.toString(), true); + } + /** * 读取邮件内容#开头的标签 * @throws Exception diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/AbstractSpectrumHandler.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/AbstractSpectrumHandler.java index 1502f4ea..2f9b75b4 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/AbstractSpectrumHandler.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/AbstractSpectrumHandler.java @@ -60,6 +60,8 @@ public abstract class AbstractSpectrumHandler extends AbstractChain { * 返回调用方(filesource,undel,SpectrumParsingActuator)的文件名称 */ protected StringBuilder returnFileName; + + protected boolean isDateFormatErr = false; /** * 保存当前能谱文件有哪些#开头的标签 */ @@ -148,6 +150,11 @@ public abstract class AbstractSpectrumHandler extends AbstractChain { */ protected abstract void updateSpectrumFileName() throws FileNotFoundException; + /** + * 对错误的本地能谱临时文件进行改名 + */ + protected abstract void updateErrorSpectrumFileName() throws FileNotFoundException; + /** * 处理原始数据 */ @@ -222,11 +229,21 @@ public abstract class AbstractSpectrumHandler extends AbstractChain { protected void handleParseingFailFile(Exception e) throws FileNotFoundException { if(!SpectrumSource.FORM_FILE_UNDEL.getSourceType().equals(spectrumSource) && !(e instanceof FileRepeatException)){ try { - //解析失败会把文件移动到undeal目录 - final String rootPath = spectrumServiceQuotes.getSpectrumPathProperties().getRootPath(); - final String undealPath = spectrumServiceQuotes.getSpectrumPathProperties().getUndealPath(); - final String finalPath = rootPath+File.separator+undealPath; - FileOperation.copyFile(spectrumFile,finalPath,true); + if (isDateFormatErr) { + //修改能谱文件名称 + this.updateErrorSpectrumFileName(); + //解析失败会把文件移动到undeal目录 + final String rootPath = spectrumServiceQuotes.getSpectrumPathProperties().getRootPath(); + final String errorFilePath = spectrumServiceQuotes.getSpectrumPathProperties().getErrorFilePath(); + final String finalPath = rootPath+File.separator+errorFilePath; + FileOperation.moveFile(spectrumFile,finalPath,true); + } else { + //解析失败会把文件移动到undeal目录 + final String rootPath = spectrumServiceQuotes.getSpectrumPathProperties().getRootPath(); + final String undealPath = spectrumServiceQuotes.getSpectrumPathProperties().getUndealPath(); + final String finalPath = rootPath+File.separator+undealPath; + FileOperation.copyFile(spectrumFile,finalPath,true); + } } catch (IOException ex) { ex.printStackTrace(); } diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/AlertSpectrum.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/AlertSpectrum.java index 59a768ef..3c04e2ea 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/AlertSpectrum.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/AlertSpectrum.java @@ -141,6 +141,25 @@ public class AlertSpectrum extends AbstractSpectrumHandler{ super.spectrumFile = FileOperation.rename(super.spectrumFile,newFileName.toString(),true); } + @Override + protected void updateErrorSpectrumFileName() throws FileNotFoundException { + StringBuilder newFileName = new StringBuilder(); + newFileName.append(this.sourceData.station_code); + newFileName.append(StringConstant.UNDER_LINE); + newFileName.append(super.currDataType.getType()); + newFileName.append(StringConstant.DASH); + newFileName.append(StringUtils.replace(this.sourceData.date,StringConstant.SLASH,"")); + newFileName.append(StringConstant.UNDER_LINE); + newFileName.append(StringUtils.replace(this.sourceData.time,":","")); + newFileName.append(super.currDataType.getSuffix()); + if(!super.spectrumFile.exists()){ + //发送格式化错误事件,后续统计报告使用 + spectrumServiceQuotes.getApplicationContext().publishEvent(new FormatErrorEvent()); + throw new FileNotFoundException(super.spectrumFile.getAbsolutePath()+" does not exist"); + } + super.spectrumFile = FileOperation.rename(super.spectrumFile,newFileName.toString(),true); + } + /** * 处理原始数据 */ diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/HealthStatusSpectrum.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/HealthStatusSpectrum.java index fee454f4..64023e11 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/HealthStatusSpectrum.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/HealthStatusSpectrum.java @@ -136,6 +136,25 @@ public class HealthStatusSpectrum extends AbstractSpectrumHandler{ super.spectrumFile = FileOperation.rename(super.spectrumFile,newFileName.toString(),true); } + @Override + protected void updateErrorSpectrumFileName() throws FileNotFoundException { + StringBuilder newFileName = new StringBuilder(); + newFileName.append(this.sourceData.station_code); + newFileName.append(StringConstant.UNDER_LINE); + newFileName.append(super.currDataType.getType()); + newFileName.append(StringConstant.DASH); + newFileName.append(StringUtils.replace(this.sourceData.start_date,StringConstant.SLASH,"")); + newFileName.append(StringConstant.UNDER_LINE); + newFileName.append(StringUtils.replace(this.sourceData.start_time,":","")); + newFileName.append(super.currDataType.getSuffix()); + if(!super.spectrumFile.exists()){ + //发送格式化错误事件,后续统计报告使用 + spectrumServiceQuotes.getApplicationContext().publishEvent(new FormatErrorEvent()); + throw new FileNotFoundException(super.spectrumFile.getAbsolutePath()+" does not exist"); + } + super.spectrumFile = FileOperation.rename(super.spectrumFile,newFileName.toString(),true); + } + /** * 处理原始数据 */ diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/MetSpectrum.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/MetSpectrum.java index 927be44e..64d7e15d 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/MetSpectrum.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/spectrum/MetSpectrum.java @@ -132,6 +132,25 @@ public class MetSpectrum extends AbstractSpectrumHandler{ super.spectrumFile = FileOperation.rename(super.spectrumFile,newFileName.toString(),true); } + @Override + protected void updateErrorSpectrumFileName() throws FileNotFoundException { + StringBuilder newFileName = new StringBuilder(); + newFileName.append(this.sourceData.station_code); + newFileName.append(StringConstant.UNDER_LINE); + newFileName.append(super.currDataType.getType()); + newFileName.append(StringConstant.DASH); + newFileName.append(StringUtils.replace(this.sourceData.met_start_date.get(0),StringConstant.SLASH,"")); + newFileName.append(StringConstant.UNDER_LINE); + newFileName.append(StringUtils.replace(this.sourceData.met_start_time.get(0),":","")); + newFileName.append(super.currDataType.getSuffix()); + if(!super.spectrumFile.exists()){ + //发送格式化错误事件,后续统计报告使用 + spectrumServiceQuotes.getApplicationContext().publishEvent(new FormatErrorEvent()); + throw new FileNotFoundException(super.spectrumFile.getAbsolutePath()+" does not exist"); + } + super.spectrumFile = FileOperation.rename(super.spectrumFile,newFileName.toString(),true); + } + /** * 处理原始数据 */