Commit 7a473ec4 authored by neo's avatar neo

[dev] do not delete maunual data

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