Commit 5f8bf929 authored by neo's avatar neo

Revert "[Bugfix] fixed datasource re mapping each regenatrater"

This reverts commit e28290f5.
parent 02949c4b
......@@ -201,8 +201,13 @@ public class ReportServiceImpl {
.andPeriodEqualTo(period);
List<PeriodDataSource> periodDataSources = periodDataSourceMapper.selectByExample(periodDataSourceExample);
PeriodCellDataSourceExample allMappingExample = new PeriodCellDataSourceExample();
allMappingExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period);
List<PeriodCellDataSource> allPcds = periodCellDataSourceMapper.selectByExample(allMappingExample);
Set<Long> periodDsIds = Sets.newHashSet(Long.MAX_VALUE);
List<Long> periodManualDsIds = new ArrayList<>();
List<Long> periodManualCellDataIds = new ArrayList<>();
if (isMergeManualData) {
periodDataSources.forEach(m -> {
......@@ -213,17 +218,36 @@ public class ReportServiceImpl {
}
});
if (!periodManualDsIds.isEmpty()) {
PeriodCellDataSourceExample periodCellDataSourceExample = new PeriodCellDataSourceExample();
periodCellDataSourceExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period)
.andDataSourceIdIn(periodManualDsIds);
List<PeriodCellDataSource> manualCellDataSource = periodCellDataSourceMapper.selectByExample(periodCellDataSourceExample);
if (!manualCellDataSource.isEmpty()) {
periodManualCellDataIds.addAll(manualCellDataSource.stream().map(PeriodCellDataSource::getCellDataId)
.collect(Collectors.toList()));
}
}
if (!allPcds.isEmpty()) {
List<Long> allPcdsIds = allPcds.stream().map(m -> m.getDataSourceId()).collect(Collectors.toList());
allPcdsIds.removeAll(periodManualDsIds);
periodDsIds.addAll(allPcdsIds);
}
} else {
periodDsIds.addAll(periodDataSources.stream().map(m -> m.getId()).collect(Collectors.toList()));
if (!allPcds.isEmpty())
periodDsIds.addAll(allPcds.stream().map(m -> m.getDataSourceId()).collect(Collectors.toList()));
}
PeriodDataSourceDetailExample periodDataSourceDetailExample = new PeriodDataSourceDetailExample();
periodDataSourceDetailExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period)
.andDataSourceIdIn(Lists.newArrayList(periodDsIds));
periodDataSourceDetailMapper.deleteByExample(periodDataSourceDetailExample);
periodDataSourceDetailMapper.deleteByExample(periodDataSourceDetailExample);
PeriodCellDataSourceExample periodCellDataSourceExample = new PeriodCellDataSourceExample();
periodCellDataSourceExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period);
periodCellDataSourceExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period)
.andDataSourceIdIn(Lists.newArrayList(periodDsIds));
periodCellDataSourceMapper.deleteByExample(periodCellDataSourceExample);
......@@ -233,12 +257,20 @@ public class ReportServiceImpl {
PeriodReportExample periodReportExample = new PeriodReportExample();
periodReportExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period);
periodReportMapper.deleteByExample(periodReportExample);
List<PeriodReport> reports = periodReportMapper.selectByExample(periodReportExample);
List<Long> reportIds = Lists.newArrayList(Long.MAX_VALUE);
reportIds.addAll(reports.stream().map(m -> m.getId()).collect(Collectors.toList()));
PeriodCellDataExample periodCellDataExample = new PeriodCellDataExample();
periodCellDataExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period);
periodCellDataMapper.deleteByExample(periodCellDataExample);
if (isMergeManualData) {
if (periodManualCellDataIds.isEmpty()) periodManualCellDataIds.add(Long.MAX_VALUE);
periodCellDataExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period).andIdNotIn(periodManualCellDataIds);
} else {
periodCellDataExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period);
}
periodCellDataMapper.deleteByExample(periodCellDataExample);
periodReportMapper.deleteByExample(periodReportExample);
}
......@@ -487,6 +519,7 @@ public class ReportServiceImpl {
reportGenerator.updateWorkbookCaclsValueToDb(projectId, periodParam, workbook, resources, genJob);
reportGenerator.updateManaCellDataWithNewReport(projectId, periodParam);
genJob.setStatus(WrapPeriodJobDto.STATUS_END);
periodJobMapper.updateByPrimaryKey(genJob);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment