ReportController.java 8.83 KB
Newer Older
1 2
package pwc.taxtech.atms.controller;

3
import org.apache.commons.lang3.StringUtils;
4 5
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
6
import org.springframework.http.ResponseEntity;
7
import org.springframework.web.bind.annotation.*;
8
import pwc.taxtech.atms.constant.enums.EnumServiceType;
9
import pwc.taxtech.atms.dpo.ReportDto;
10
import pwc.taxtech.atms.dto.OperationResultDto;
11
import pwc.taxtech.atms.dto.vatdto.*;
12
import pwc.taxtech.atms.vat.entity.PeriodCellTemplateConfig;
neo's avatar
neo committed
13
import pwc.taxtech.atms.vat.entity.PeriodJob;
14
import pwc.taxtech.atms.vat.entity.VatEnterpriseAccount;
15
import pwc.taxtech.atms.vat.service.impl.ReportServiceImpl;
16 17

import java.util.List;
frank.xa.zhang's avatar
frank.xa.zhang committed
18
import java.util.Optional;
19 20 21 22

@RestController
@RequestMapping(value = "api/v1/Report")
public class ReportController {
frank.xa.zhang's avatar
frank.xa.zhang committed
23
    @Autowired
24
    ReportServiceImpl reportService;
25

26
    @RequestMapping(value = "export", method = RequestMethod.POST)
27
    public ResponseEntity getExportFile(@RequestBody ReportExportDto report) {
28 29 30
        return ResponseEntity.ok(reportService.export(report.getReportData(), "~"));
    }

31 32 33
    @RequestMapping(value = "template/{projectId}/{serviceType}/{period}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public OperationResultDto<List<ReportDto>> getTemplate(@PathVariable String projectId, @PathVariable int serviceType, @PathVariable Integer period) {
        return reportService.getReportTemplate(projectId, EnumServiceType.getEnumByCode(serviceType), period);
34
    }
35

sherlock's avatar
sherlock committed
36 37 38 39 40
    @RequestMapping(value = "filterTemplate/{projectId}/{serviceType}/{period}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public OperationResultDto<List<ReportDto>> getFilterTemplate(@PathVariable String projectId, @PathVariable int serviceType, @PathVariable Integer period) {
        return reportService.getFilterReportTemplate(projectId, EnumServiceType.getEnumByCode(serviceType), period);
    }

41 42 43 44 45
    @RequestMapping(value = "generateByTotal/{projectId}/{mergeManual}/{period}", method = RequestMethod.POST,
            produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ResponseEntity generateAllData(@PathVariable String projectId, @PathVariable Integer period,
                                          @RequestParam Optional<String> generator, @PathVariable Boolean mergeManual) {
        return ResponseEntity.ok(reportService.generateData(projectId, EnumServiceType.VAT, mergeManual, period, null, generator));
46
    }
frank.xa.zhang's avatar
frank.xa.zhang committed
47

neo's avatar
neo committed
48 49
    @RequestMapping(value = "getRunningJob/{projectId}/{period}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
50 51 52 53 54
    public PeriodJobDto getRunningJob(@PathVariable String projectId, @PathVariable Integer period) {
        PeriodJob job = reportService.getRunningJob(projectId, period);
        if (job != null)
            return new PeriodJobDto().copyFromPeriodJob(job);
        else return null;
neo's avatar
neo committed
55 56 57 58
    }

    @RequestMapping(value = "getJobStatus/{projectId}//{period}/{jobId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
59 60
    public PeriodJobDto getJobStatus(@PathVariable String projectId, @PathVariable Integer period, @PathVariable String jobId) {
        return new PeriodJobDto().copyFromPeriodJob(reportService.getJobStatus(projectId, period, jobId));
neo's avatar
neo committed
61 62
    }

frank.xa.zhang's avatar
frank.xa.zhang committed
63 64
    @RequestMapping(value = "templateReferences/{period}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public List<CellTemplateReferenceDto> getTemplateReferences(@PathVariable int period) {
frank.xa.zhang's avatar
frank.xa.zhang committed
65 66
        return reportService.getTemplateReferences(period);
    }
67 68

    @RequestMapping(value = "reportData/{reportId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
69
    public OperationResultDto<ReportDataDto> getReportData(@PathVariable Long reportId, @RequestHeader String from) {
70 71 72 73 74
        OperationResultDto resultDto = new OperationResultDto();
        if (reportId == null || reportId == 0L) {
            resultDto.setResult(false);
            return resultDto;
        }
75
        return reportService.getCellData(reportId, from);
76
    }
77 78

    @RequestMapping(value = "report/{templateId}/{period}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
79
    public OperationResultDto<ReportDto> getReportByTemplate(@PathVariable Long templateId, @PathVariable Integer period, @RequestHeader String from) {
80 81 82 83 84 85
        OperationResultDto resultDto = new OperationResultDto();
        if (templateId == null || templateId == 0L || period == null || period == 0) {
            resultDto.setResult(false);
            resultDto.setResultMsg("templateId or period is invalid");
            return resultDto;
        }
86
        return reportService.getReportByTemplate(templateId, period, from);
87 88 89
    }

    @RequestMapping(value = "getCellTemplateConfig/{reportTemplateId}/{period}/{rowIndex}/{columnIndex}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
90 91 92 93 94 95
    public OperationResultDto<PeriodCellTemplateConfig> getCellTemplateConfig(@PathVariable Long reportTemplateId,
                                                                              @PathVariable Integer period,
                                                                              @PathVariable int rowIndex,
                                                                              @PathVariable int columnIndex,
                                                                              @RequestHeader("from") String projectId) {
        return reportService.getCellTemplateConfig(reportTemplateId, period, rowIndex, columnIndex, projectId);
96 97
    }

98
    @RequestMapping(value = "getStdAccountByIndustry/{industryId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
99 100 101 102 103 104
    public OperationResultDto<List<VatEnterpriseAccount>> getStdAccountByIndustry(@PathVariable String industryId, @RequestHeader String from) {
        String projectId = StringUtils.EMPTY;
        if (StringUtils.isNotBlank(from) && from.split("@").length > 0) {
            projectId = from.split("@")[0];
        }
        return reportService.getStdAccountByIndustry(industryId, projectId);
105 106
    }

107
    @RequestMapping(value = "getCellAccountRange/{reportTemplateId}/{period}/{rowIndex}/{columnIndex}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
108
    public OperationResultDto<List<VatEnterpriseAccountResultDto>> getCellAccountRange(@PathVariable Long reportTemplateId, @PathVariable Integer period, @PathVariable int rowIndex, @PathVariable int columnIndex, @RequestHeader String from) {
109 110 111 112
        String projectId = StringUtils.EMPTY;
        if (StringUtils.isNotBlank(from) && from.split("@").length > 0) {
            projectId = from.split("@")[0];
        }
113
        return reportService.getCellAccountRange(reportTemplateId, period, rowIndex, columnIndex, projectId);
114
    }
115

116
    @RequestMapping(value = "addCellManualData", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
117
    public ResponseEntity addCellManualDataSource(@RequestBody ManualDataSourceDto data, @RequestHeader String from) {
118 119 120 121
        String projectId = StringUtils.EMPTY;
        if (StringUtils.isNotBlank(from) && from.split("@").length > 0) {
            projectId = from.split("@")[0];
        }
122
        return ResponseEntity.ok(reportService.addCellManualDataSource(data, from));
123
    }
124 125 126 127 128

    @RequestMapping(value = "addDataSource", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public OperationResultDto<String> addDataSource(@RequestBody DataSourceDto datasource) {
        return reportService.addDataSource(datasource);
    }
129

130 131
    @RequestMapping(value = "getAllDataItems/{dataSourceType}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public OperationResultDto<String> getAllDataItems(@PathVariable Integer dataSourceType) {
132 133
        return reportService.getAllDataItems(dataSourceType);
    }
134 135


136 137
    @RequestMapping(value = "addDataSourceItems", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public OperationResultDto addDataSourceItems(@RequestBody DataSourceDto dataSource) {
138 139
        return reportService.addDataSourceItems(dataSource);
    }
140

141 142 143
    @RequestMapping(value = "getDataSourceDetailList/{dataSourceId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public OperationResultDto<String> getDataSourceDetailList(@PathVariable Long dataSourceId) {
        return reportService.getDataSourceDetailList(dataSourceId);
144
    }
145 146

    @RequestMapping(value = "hasManualDataSource/{projectId}/{period}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
147 148
    public Boolean hasManualDataSource(@PathVariable String projectId, @PathVariable Integer period) {
        return reportService.hasManualDataSource(projectId, period);
149
    }
150 151


152
}