自动处理增加逻辑判断,如果对应路径文件数据存在,判断数据状态如果是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();
|
||||
//如果数据已经存储,不在重复存储
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user