Commit 7a473ec4 authored by neo's avatar neo

[dev] do not delete maunual data

parent 6cb74496
......@@ -31,7 +31,7 @@ public class ReportController {
@PathVariable Boolean ifDeleteManualDataSource,
@PathVariable Integer period,
@RequestParam String generator) {
return reportService.updateConfig(projectId, period, ifDeleteManualDataSource, generator);
return reportService.updateConfig(projectId, period, ifDeleteManualDataSource, generator,true);
// OperationResultDto operationResultDto = new OperationResultDto();
// operationResultDto.setResult(true);
// return operationResultDto;
......
......@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import pwc.taxtech.atms.common.CommonUtils;
import pwc.taxtech.atms.common.util.SpringContextUtil;
import pwc.taxtech.atms.constant.Constant;
import pwc.taxtech.atms.constant.enums.*;
import pwc.taxtech.atms.dao.*;
import pwc.taxtech.atms.dpo.ReportDto;
......@@ -156,7 +157,7 @@ public class ReportServiceImpl {
return operationResult;
}
private void clearPeriodData(String projectId, Integer period, List<Long> templateIds) {
private void clearPeriodData(String projectId, Integer period, List<Long> templateIds, boolean isMergeManualData) {
if (templateIds.isEmpty()) templateIds.add(Long.MAX_VALUE);
PeriodFormulaBlockExample periodFormulaBlockExample = new PeriodFormulaBlockExample();
periodFormulaBlockExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period);
......@@ -183,10 +184,33 @@ public class ReportServiceImpl {
periodTaxPayerReportRuleMapper.deleteByExample(periodTaxPayerReportRuleExample);
PeriodDataSourceExample periodDataSourceExample = new PeriodDataSourceExample();
periodDataSourceExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period);
periodDataSourceExample.createCriteria().andProjectIdEqualTo(projectId)
.andPeriodEqualTo(period);
List<PeriodDataSource> periodDataSources = periodDataSourceMapper.selectByExample(periodDataSourceExample);
List<Long> periodDsIds = Lists.newArrayList(Long.MAX_VALUE);
periodDsIds.addAll(periodDataSources.stream().map(m -> m.getId()).collect(Collectors.toList()));
List<Long> periodManualDsIds = new ArrayList<>();
List<Long> periodManualCellDataIds = new ArrayList<>();
if (isMergeManualData) {
periodDataSources.forEach(m -> {
if (m.getType().intValue() != FormulaDataSourceType.KeyInSource.getCode().intValue()) {
periodDsIds.add(m.getId());
} else {
periodManualDsIds.add(m.getId());
}
});
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()));
} else {
periodDsIds.addAll(periodDataSources.stream().map(m -> m.getId()).collect(Collectors.toList()));
}
PeriodDataSourceDetailExample periodDataSourceDetailExample = new PeriodDataSourceDetailExample();
periodDataSourceDetailExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period)
.andDataSourceIdIn(periodDsIds);
......@@ -197,7 +221,10 @@ public class ReportServiceImpl {
.andDataSourceIdIn(periodDsIds);
periodCellDataSourceMapper.deleteByExample(periodCellDataSourceExample);
periodDataSourceMapper.deleteByExample(periodDataSourceExample);
PeriodDataSourceExample periodDataSourceDeleteExample = new PeriodDataSourceExample();
periodDataSourceExample.createCriteria().andIdIn(periodDsIds);
periodDataSourceMapper.deleteByExample(periodDataSourceDeleteExample);
PeriodReportExample periodReportExample = new PeriodReportExample();
periodReportExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period);
......@@ -206,14 +233,21 @@ public class ReportServiceImpl {
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).andReportIdIn(
reportIds);
if (!periodManualCellDataIds.isEmpty()) {
periodCellDataExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period).andReportIdIn(
reportIds).andIdNotIn(periodManualCellDataIds);
} else {
periodCellDataExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period).andReportIdIn(
reportIds);
}
periodCellDataMapper.deleteByExample(periodCellDataExample);
periodReportMapper.deleteByExample(periodReportExample);
}
public OperationResultDto updateConfig(String projectId, Integer period, Boolean ifDeleteManualDataSource, String generator) {
public OperationResultDto updateConfig(String projectId, Integer period, Boolean ifDeleteManualDataSource,
String generator,Boolean isMergeManualData) {
OperationResultDto result = new OperationResultDto();
try {
if (period == null) {
......@@ -240,7 +274,7 @@ public class ReportServiceImpl {
Long templateGroupId = projectMapper.getTemplateGroupIdByProject(projectId, EnumServiceType.VAT.getCode());
if (templateGroupId != null && templateGroupId != 0) {
// 先进行数据清理,包括period开头的所有报表配置表 条件Period
clearPeriodData(projectId, period, exceptTemplateIds);
clearPeriodData(projectId, period, exceptTemplateIds,isMergeManualData);
// 根据templategroupid 把 template 插入到 periodTemplate
TemplateExample example = new TemplateExample();
example.createCriteria().andTemplateGroupIdEqualTo(templateGroupId);
......
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