Commit eeb82d4d authored by neo's avatar neo

[Bugfix] fixed clean period cell data sources

parent 786164b8
......@@ -2,6 +2,7 @@ package pwc.taxtech.atms.vat.service.impl;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.ss.usermodel.Workbook;
......@@ -198,7 +199,12 @@ public class ReportServiceImpl {
periodDataSourceExample.createCriteria().andProjectIdEqualTo(projectId)
.andPeriodEqualTo(period);
List<PeriodDataSource> periodDataSources = periodDataSourceMapper.selectByExample(periodDataSourceExample);
List<Long> periodDsIds = Lists.newArrayList(Long.MAX_VALUE);
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<>();
......@@ -216,27 +222,36 @@ public class ReportServiceImpl {
periodCellDataSourceExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period)
.andDataSourceIdIn(periodManualDsIds);
List<PeriodCellDataSource> manualCellDataSource = periodCellDataSourceMapper.selectByExample(periodCellDataSourceExample);
if (!manualCellDataSource.isEmpty())
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(periodDsIds);
.andDataSourceIdIn(Lists.newArrayList(periodDsIds));
periodDataSourceDetailMapper.deleteByExample(periodDataSourceDetailExample);
PeriodCellDataSourceExample periodCellDataSourceExample = new PeriodCellDataSourceExample();
periodCellDataSourceExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period)
.andDataSourceIdIn(periodDsIds);
.andDataSourceIdIn(Lists.newArrayList(periodDsIds));
periodCellDataSourceMapper.deleteByExample(periodCellDataSourceExample);
PeriodDataSourceExample periodDataSourceDeleteExample = new PeriodDataSourceExample();
periodDataSourceDeleteExample.createCriteria().andIdIn(periodDsIds);
periodDataSourceDeleteExample.createCriteria().andIdIn(Lists.newArrayList(periodDsIds));
periodDataSourceMapper.deleteByExample(periodDataSourceDeleteExample);
PeriodReportExample periodReportExample = new PeriodReportExample();
......
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