Commit 1467071b authored by neo's avatar neo

[dev] user mapper examole clear period cell data

parent 7243be85
......@@ -25,6 +25,8 @@ import pwc.taxtech.atms.dto.vatdto.VatEnterpriseAccountResultDto;
import pwc.taxtech.atms.entity.*;
import pwc.taxtech.atms.exception.NotSupportedException;
import pwc.taxtech.atms.service.impl.CellConfigTranslater;
import pwc.taxtech.atms.vat.dao.PeriodTaxPayerReportRuleMapper;
import pwc.taxtech.atms.vat.dao.PeriodTaxRuleSettingMapper;
import pwc.taxtech.atms.vat.dpo.DataSourceCellDataDto;
import pwc.taxtech.atms.vat.dpo.DataSourceExtendDto;
import pwc.taxtech.atms.vat.dpo.InputVATInvoiceItemExtendDto;
......@@ -44,10 +46,11 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static pwc.taxtech.atms.common.util.SpringContextUtil.periodEnterpriseAccountMapper;
@Component
public class ReportServiceImpl extends VatAbstractService implements ReportService {
private PeriodTaxRuleSettingMapper periodTaxRuleSettingMapper;
private PeriodTaxPayerReportRuleMapper periodTaxPayerReportRuleMapper;
@Override
public OperationResultDto<List<ReportDto>> getReportTemplate(String projectId, EnumServiceType serviceType, Integer periodParam) {
int period = periodParam != null ? periodParam : 0;
......@@ -116,6 +119,58 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
return operationResult;
}
private void clearPeriodData(String projectId, Integer period, List<Long> templateIds) {
PeriodFormulaBlockExample periodFormulaBlockExample = new PeriodFormulaBlockExample();
periodFormulaBlockExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period);
periodFormulaBlockMapper.deleteByExample(periodFormulaBlockExample);
PeriodTaxRuleSettingExample periodTaxRuleSettingExample = new PeriodTaxRuleSettingExample();
periodTaxRuleSettingExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period);
periodTaxRuleSettingMapper.deleteByExample(periodTaxRuleSettingExample);
PeriodCellTemplateExample periodCellTemplateExample = new PeriodCellTemplateExample();
periodCellTemplateExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period).andReportTemplateIdIn(templateIds);
periodCellTemplateMapper.deleteByExample(periodCellTemplateExample);
PeriodCellTemplateConfigExample periodCellTemplateConfigExample = new PeriodCellTemplateConfigExample();
periodCellTemplateConfigExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period).andReportTemplateIdIn(templateIds);
periodCellTemplateConfigMapper.deleteByExample(periodCellTemplateConfigExample);
PeriodTemplateExample periodTemplateExample = new PeriodTemplateExample();
periodTemplateExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period).andTemplateIdIn(templateIds)
periodTemplateMapper.deleteByExample(periodTemplateExample);
PeriodTaxPayerReportRuleExample periodTaxPayerReportRuleExample = new PeriodTaxPayerReportRuleExample();
periodTaxPayerReportRuleExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period);
periodTaxPayerReportRuleMapper.deleteByExample(periodTaxPayerReportRuleExample);
PeriodDataSourceExample periodDataSourceExample = new PeriodDataSourceExample();
periodDataSourceExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period);
List<PeriodDataSource> periodDataSources = periodDataSourceMapper.selectByExample(periodDataSourceExample);
PeriodDataSourceDetailExample periodDataSourceDetailExample = new PeriodDataSourceDetailExample();
periodDataSourceDetailExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period)
.andDataSourceIdIn(periodDataSources.stream().map(m -> m.getId()).collect(Collectors.toList()));
periodDataSourceDetailMapper.deleteByExample(periodDataSourceDetailExample);
PeriodCellDataSourceExample periodCellDataSourceExample = new PeriodCellDataSourceExample();
periodCellDataSourceExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period)
.andDataSourceIdIn(periodDataSources.stream().map(m -> m.getId()).collect(Collectors.toList()));
periodCellDataSourceMapper.deleteByExample(periodCellDataSourceExample);
periodDataSourceMapper.deleteByExample(periodDataSourceExample);
PeriodReportExample periodReportExample = new PeriodReportExample();
periodReportExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period);
List<PeriodReport> reports = periodReportMapper.selectByExample(periodReportExample);
PeriodCellDataExample periodCellDataExample = new PeriodCellDataExample();
periodCellDataExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period).andReportIdIn(
reports.stream().map(m -> m.getId()).collect(Collectors.toList()));
periodCellDataMapper.deleteByExample(periodCellDataExample);
periodReportMapper.deleteByExample(periodReportExample);
}
@Override
public OperationResultDto updateConfig(String projectId, Integer period, Boolean ifDeleteManualDataSource, String generator) {
OperationResultDto result = new OperationResultDto();
......@@ -157,7 +212,8 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
// dataSourceMapper.clearDataSourceWithPeriod(period);
// dataSourceMapper.clearCellDataWithPeriod(strExceptTemplateIds, period);
// dataSourceMapper.clearReportWithPeriod(period);
periodDataSourceMapper.clearDataWithPeriod(strExceptTemplateIds, period);
clearPeriodData(projectId, period, exceptTemplateIds);
// 根据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