自动处理增加逻辑判断,如果对应路径文件数据存在,判断数据状态如果是P,则抛出文件重复异常,如果是F,不进行处理,如果对应路径文件数据不存在,则正常存储数据
This commit is contained in:
parent
0a2a2c2260
commit
a48f162d1d
|
@ -224,37 +224,41 @@ public abstract class AbstractS_D_Q_G_SpectrumHandler extends AbstractSpectrumHa
|
||||||
this.startIntoDatabaseTime = new Date();
|
this.startIntoDatabaseTime = new Date();
|
||||||
//如果数据已经存储,不在重复存储
|
//如果数据已经存储,不在重复存储
|
||||||
final GardsSampleData query = spectrumServiceQuotes.getSampleDataService().findByInputFileName(super.spectrumFileRelativePath);
|
final GardsSampleData query = spectrumServiceQuotes.getSampleDataService().findByInputFileName(super.spectrumFileRelativePath);
|
||||||
|
//如果数据已经存储 并且状态是 P 则判断文件重复 如果数据已经存储并且状态是 F 不进行处理
|
||||||
if(Objects.nonNull(query)){
|
if(Objects.nonNull(query)){
|
||||||
this.sampleData = query;
|
this.sampleData = query;
|
||||||
this.endIntoDatabaseTime = new Date();
|
this.endIntoDatabaseTime = new Date();
|
||||||
//设置文件重复标记为true
|
if (query.getStatus().equalsIgnoreCase(SampleStatus.COMPLETE.value)) {
|
||||||
this.parsingProcessLog.setFileRepeat(true);
|
//设置文件重复标记为true
|
||||||
//发送文件重复错误事件,后续统计报告使用
|
this.parsingProcessLog.setFileRepeat(true);
|
||||||
spectrumServiceQuotes.getApplicationContext().publishEvent(new RepeatErrorEvent());
|
//发送文件重复错误事件,后续统计报告使用
|
||||||
ErrorLogManager.getInstance().write(new SpectrumErrorEvent(new Date(),ErrorType.FILE_REPEAT.getContent(),super.spectrumFile.getName()));
|
spectrumServiceQuotes.getApplicationContext().publishEvent(new RepeatErrorEvent());
|
||||||
throw new FileRepeatException("file repeat");
|
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());
|
} else if (Objects.isNull(query)) { // 如果没有查询出对应的数据 则对数据进行存储操作
|
||||||
try{
|
DataSourceSwitcher.switchToOracle();
|
||||||
//存储基础数据
|
final TransactionStatus transactionStatus = spectrumServiceQuotes.getTransactionManager().getTransaction(spectrumServiceQuotes.getTransactionDefinition());
|
||||||
this.sampleData = spectrumServiceQuotes.getSpectrumBaseBlockService().create(this.sourceData,super.spectrumFileRelativePath,status);
|
try{
|
||||||
//存储其他块数据
|
//存储基础数据
|
||||||
for(String labels : spectrumFileLabels){
|
this.sampleData = spectrumServiceQuotes.getSpectrumBaseBlockService().create(this.sourceData,super.spectrumFileRelativePath,status);
|
||||||
final ISpectrumBlockService spectrumBlockService = spectrumServiceQuotes.getSpectrumBlockService().get(labels);
|
//存储其他块数据
|
||||||
if(Objects.nonNull(spectrumBlockService)){
|
for(String labels : spectrumFileLabels){
|
||||||
spectrumBlockService.create(sourceData,this.sampleData);
|
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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user