ReportAnalysisController.java 3.84 KB
Newer Older
eddie.woo's avatar
eddie.woo committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
package pwc.taxtech.atms.controller;

import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
import pwc.taxtech.atms.dto.ApiResultDto;
import pwc.taxtech.atms.service.impl.ReportAnalysisService;

import javax.annotation.Resource;
import java.util.Collections;

@RestController
@RequestMapping("/api/v1/reportAnalysis")
public class ReportAnalysisController extends BaseController {
    @Resource
    private ReportAnalysisService reportAnalysisService;

    @GetMapping("/burdenRateData/{projectId}")
    public ApiResultDto getBurdenRateData(@PathVariable String projectId) {
        if (StringUtils.isBlank(projectId)) {
            return ApiResultDto.success(Collections.emptyList());
        }
        try {
            return ApiResultDto.success(reportAnalysisService.getBurdenRateData(projectId));
        } catch (Exception e) {
            logger.error("getBurdenRateData error.", e);
        }
        return ApiResultDto.fail();
    }

    @GetMapping("/dispersion/{projectId}")
    public ApiResultDto dispersion(@PathVariable String projectId) {
        if (StringUtils.isBlank(projectId)) {
            return ApiResultDto.success(Collections.emptyList());
        }
        try {
            return ApiResultDto.success(reportAnalysisService.getDispersion(projectId));
        } catch (Exception e) {
            logger.error("getDispersion error.", e);
        }
        return ApiResultDto.fail();
    }

    @GetMapping("/incomeRate/{projectId}")
    public ApiResultDto incomeRate(@PathVariable String projectId) {
        if (StringUtils.isBlank(projectId)) {
            return ApiResultDto.success(Collections.emptyList());
        }
        try {
            return ApiResultDto.success(reportAnalysisService.getIncomeRate(projectId));
        } catch (Exception e) {
eddie.woo's avatar
eddie.woo committed
51
            logger.error("incomeRate error.", e);
eddie.woo's avatar
eddie.woo committed
52 53 54 55 56 57 58 59 60 61 62 63
        }
        return ApiResultDto.fail();
    }

    @GetMapping("/incomeVolatility/{projectId}")
    public ApiResultDto incomeVolatility(@PathVariable String projectId) {
        if (StringUtils.isBlank(projectId)) {
            return ApiResultDto.success(Collections.emptyList());
        }
        try {
            return ApiResultDto.success(reportAnalysisService.getIncomeVolatility(projectId));
        } catch (Exception e) {
eddie.woo's avatar
eddie.woo committed
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
            logger.error("incomeVolatility error.", e);
        }
        return ApiResultDto.fail();
    }

    @GetMapping("/vatIncomeRate/{projectId}/{period}")
    public ApiResultDto getVatIncomeRate(@PathVariable String projectId, @PathVariable Integer period) {
        if (StringUtils.isBlank(projectId)) {
            return ApiResultDto.success(Collections.emptyList());
        }
        try {
            return ApiResultDto.success(reportAnalysisService.getVatIncomeRate(projectId, period));
        } catch (Exception e) {
            logger.error("getVatIncomeRate error.", e);
        }
        return ApiResultDto.fail();
    }

    @GetMapping("/vatIncomeLine/{projectId}")
    public ApiResultDto getVatIncomeLine(@PathVariable String projectId) {
        if (StringUtils.isBlank(projectId)) {
            return ApiResultDto.success(Collections.emptyList());
        }
        try {
            return ApiResultDto.success(reportAnalysisService.getVatIncomeLine(projectId));
        } catch (Exception e) {
            logger.error("getVatIncomeLine error.", e);
        }
        return ApiResultDto.fail();
    }

    @GetMapping("/deduction/{projectId}")
    public ApiResultDto getDeduction(@PathVariable String projectId) {
        if (StringUtils.isBlank(projectId)) {
            return ApiResultDto.success(Collections.emptyList());
        }
        try {
            return ApiResultDto.success(reportAnalysisService.getDeduction(projectId));
        } catch (Exception e) {
            logger.error("getDeduction error.", e);
eddie.woo's avatar
eddie.woo committed
104 105 106 107
        }
        return ApiResultDto.fail();
    }
}