From a48f162d1deca954847e8c3096fb5e1cf27f4d56 Mon Sep 17 00:00:00 2001 From: qiaoqinzheng Date: Tue, 2 Jan 2024 10:57:13 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=A4=84=E7=90=86=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E9=80=BB=E8=BE=91=E5=88=A4=E6=96=AD=EF=BC=8C=E5=A6=82?= =?UTF-8?q?=E6=9E=9C=E5=AF=B9=E5=BA=94=E8=B7=AF=E5=BE=84=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=AD=98=E5=9C=A8=EF=BC=8C=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=8A=B6=E6=80=81=E5=A6=82=E6=9E=9C=E6=98=AF?= =?UTF-8?q?P=EF=BC=8C=E5=88=99=E6=8A=9B=E5=87=BA=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E5=BC=82=E5=B8=B8=EF=BC=8C=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E6=98=AFF=EF=BC=8C=E4=B8=8D=E8=BF=9B=E8=A1=8C=E5=A4=84?= =?UTF-8?q?=E7=90=86=EF=BC=8C=E5=A6=82=E6=9E=9C=E5=AF=B9=E5=BA=94=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E6=96=87=E4=BB=B6=E6=95=B0=E6=8D=AE=E4=B8=8D=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=EF=BC=8C=E5=88=99=E6=AD=A3=E5=B8=B8=E5=AD=98=E5=82=A8?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractS_D_Q_G_SpectrumHandler.java | 58 ++++++++++--------- 1 file changed, 31 insertions(+), 27 deletions(-) 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 e001b0aa..e11eae51 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 @@ -224,37 +224,41 @@ public abstract class AbstractS_D_Q_G_SpectrumHandler extends AbstractSpectrumHa this.startIntoDatabaseTime = new Date(); //如果数据已经存储,不在重复存储 final GardsSampleData query = spectrumServiceQuotes.getSampleDataService().findByInputFileName(super.spectrumFileRelativePath); + //如果数据已经存储 并且状态是 P 则判断文件重复 如果数据已经存储并且状态是 F 不进行处理 if(Objects.nonNull(query)){ this.sampleData = query; this.endIntoDatabaseTime = new Date(); - //设置文件重复标记为true - this.parsingProcessLog.setFileRepeat(true); - //发送文件重复错误事件,后续统计报告使用 - spectrumServiceQuotes.getApplicationContext().publishEvent(new RepeatErrorEvent()); - ErrorLogManager.getInstance().write(new SpectrumErrorEvent(new Date(),ErrorType.FILE_REPEAT.getContent(),super.spectrumFile.getName())); - throw new FileRepeatException("file repeat"); - } - DataSourceSwitcher.switchToOracle(); - final TransactionStatus transactionStatus = spectrumServiceQuotes.getTransactionManager().getTransaction(spectrumServiceQuotes.getTransactionDefinition()); - try{ - //存储基础数据 - this.sampleData = spectrumServiceQuotes.getSpectrumBaseBlockService().create(this.sourceData,super.spectrumFileRelativePath,status); - //存储其他块数据 - for(String labels : spectrumFileLabels){ - final ISpectrumBlockService spectrumBlockService = spectrumServiceQuotes.getSpectrumBlockService().get(labels); - if(Objects.nonNull(spectrumBlockService)){ - spectrumBlockService.create(sourceData,this.sampleData); - } + if (query.getStatus().equalsIgnoreCase(SampleStatus.COMPLETE.value)) { + //设置文件重复标记为true + this.parsingProcessLog.setFileRepeat(true); + //发送文件重复错误事件,后续统计报告使用 + spectrumServiceQuotes.getApplicationContext().publishEvent(new RepeatErrorEvent()); + ErrorLogManager.getInstance().write(new SpectrumErrorEvent(new Date(),ErrorType.FILE_REPEAT.getContent(),super.spectrumFile.getName())); + throw new FileRepeatException("file repeat"); + } + } else if (Objects.isNull(query)) { // 如果没有查询出对应的数据 则对数据进行存储操作 + DataSourceSwitcher.switchToOracle(); + final TransactionStatus transactionStatus = spectrumServiceQuotes.getTransactionManager().getTransaction(spectrumServiceQuotes.getTransactionDefinition()); + try{ + //存储基础数据 + this.sampleData = spectrumServiceQuotes.getSpectrumBaseBlockService().create(this.sourceData,super.spectrumFileRelativePath,status); + //存储其他块数据 + for(String labels : spectrumFileLabels){ + final ISpectrumBlockService spectrumBlockService = spectrumServiceQuotes.getSpectrumBlockService().get(labels); + if(Objects.nonNull(spectrumBlockService)){ + spectrumBlockService.create(sourceData,this.sampleData); + } + } + //提交事务 + this.spectrumServiceQuotes.getTransactionManager().commit(transactionStatus); + }catch (Exception e){ + //回滚事务 + spectrumServiceQuotes.getTransactionManager().rollback(transactionStatus); + throw e; + }finally { + this.endIntoDatabaseTime = new Date(); + DataSourceSwitcher.clearDataSource(); } - //提交事务 - this.spectrumServiceQuotes.getTransactionManager().commit(transactionStatus); - }catch (Exception e){ - //回滚事务 - spectrumServiceQuotes.getTransactionManager().rollback(transactionStatus); - throw e; - }finally { - this.endIntoDatabaseTime = new Date(); - DataSourceSwitcher.clearDataSource(); } } }