Commit d4ce6f59 authored by neo's avatar neo

[dev] fixed period template project id

parent d244664d
......@@ -2,7 +2,13 @@ package pwc.taxtech.atms.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import pwc.taxtech.atms.constant.enums.EnumServiceType;
import pwc.taxtech.atms.dpo.ReportDto;
import pwc.taxtech.atms.dto.OperationResultDto;
......@@ -48,13 +54,13 @@ public class ReportController {
}
@RequestMapping(value = "reportData/{reportId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public OperationResultDto<ReportDataDto> getReportData(@PathVariable Long reportId) {
public OperationResultDto<ReportDataDto> getReportData(@PathVariable Long reportId, @RequestHeader String from) {
OperationResultDto resultDto = new OperationResultDto();
if (reportId == null || reportId == 0L) {
resultDto.setResult(false);
return resultDto;
}
return reportService.getCellData(reportId);
return reportService.getCellData(reportId, from);
}
@RequestMapping(value = "report/{templateId}/{period}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
......
......@@ -24,7 +24,7 @@ public interface ReportService {
List<CellTemplateReferenceDto> getTemplateReferences(int period);
OperationResultDto<ReportDataDto> getCellData(Long reportId);
OperationResultDto<ReportDataDto> getCellData(Long reportId, String porjectId);
OperationResultDto<ReportDto> getReportByTemplate(Long templateId, Integer period);
......
......@@ -70,7 +70,7 @@ public class ReportGeneratorImpl extends VatAbstractService implements ReportGen
Project project = projectMapper.selectByPrimaryKey(projectId);
PeriodTemplateExample periodTemplateExample = new PeriodTemplateExample();
periodTemplateExample.createCriteria().andIdIn(templateIds);
periodTemplateExample.createCriteria().andProjectIdEqualTo(projectId).andPeriodEqualTo(period).andIdIn(templateIds);
List<PeriodTemplate> periodTemplateList = periodTemplateMapper.selectByExample(periodTemplateExample);
List<Long> periodTemplateIdList = periodTemplateList.stream()
.map(PeriodTemplate::getTemplateId)
......
......@@ -367,13 +367,16 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
PeriodTemplateExample periodTemplateExample = new PeriodTemplateExample();
periodTemplateExample.createCriteria()
.andTemplateGroupIdEqualTo(templateGroupId.get())
.andProjectIdEqualTo(projectId)
.andPeriodEqualTo(period)
.andIsActiveAssociationEqualTo(true)
.andReportTypeEqualTo(reportType);
templateIds = periodTemplateMapper.selectByExample(periodTemplateExample).stream().map(PeriodTemplate::getId).collect(Collectors.toList());
} else {
PeriodTemplateExample periodTemplateExample = new PeriodTemplateExample();
periodTemplateExample.createCriteria().andTemplateGroupIdEqualTo(templateGroupId.get()).andPeriodEqualTo(period).andIsActiveAssociationEqualTo(true);
periodTemplateExample.createCriteria().andTemplateGroupIdEqualTo(templateGroupId.get())
.andProjectIdEqualTo(projectId)
.andPeriodEqualTo(period).andIsActiveAssociationEqualTo(true);
templateIds = periodTemplateMapper.selectByExample(periodTemplateExample).stream().map(PeriodTemplate::getId).collect(Collectors.toList());
}
......@@ -396,7 +399,7 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
}
@Override
public OperationResultDto<ReportDataDto> getCellData(Long reportId) {
public OperationResultDto<ReportDataDto> getCellData(Long reportId, String projectId) {
OperationResultDto resultDto = new OperationResultDto();
ReportDataDto dataDto = new ReportDataDto();
try {
......@@ -408,7 +411,7 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
}
PeriodTemplateExample example = new PeriodTemplateExample();
example.createCriteria().andTemplateIdEqualTo(report.getTemplateId()).andPeriodEqualTo(report.getPeriod());
example.createCriteria().andProjectIdEqualTo(projectId).andTemplateIdEqualTo(report.getTemplateId()).andPeriodEqualTo(report.getPeriod());
Optional<PeriodTemplate> reportTemplate = periodTemplateMapper.selectByExample(example).stream().findFirst();
if (!reportTemplate.isPresent()) {
resultDto.setResult(false);
......@@ -425,6 +428,7 @@ public class ReportServiceImpl extends VatAbstractService implements ReportServi
PeriodTemplateExample periodTemplateExample = new PeriodTemplateExample();
periodTemplateExample.createCriteria()
.andProjectIdEqualTo(projectId)
.andTemplateGroupIdEqualTo(reportTemplate.get().getTemplateGroupId())
.andPeriodEqualTo(report.getPeriod())
.andIsActiveAssociationEqualTo(true);
......
......@@ -2,12 +2,9 @@ package pwc.taxtech.atms.vat.service.impl.report.functions;
import pwc.taxtech.atms.common.util.SpringContextUtil;
import pwc.taxtech.atms.constant.enums.KeyValueConfigResultType;
import pwc.taxtech.atms.vat.entity.PeriodTemplate;
import pwc.taxtech.atms.vat.entity.PeriodTemplateExample;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class FormulaHelper {
......
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