package cn.iocoder.lyzsys.module.tjt.controller.admin.report;

import cn.iocoder.lyzsys.framework.apilog.core.annotation.ApiAccessLog;
import cn.iocoder.lyzsys.module.tjt.controller.admin.report.vo.EmployeeOutputSummaryExportReqVO;
import cn.iocoder.lyzsys.module.tjt.controller.admin.report.vo.ProjectBudgetExportReqVO;
import cn.iocoder.lyzsys.module.tjt.controller.admin.report.vo.ProjectLeadQuarterOutputExportReqVO;
import cn.iocoder.lyzsys.module.tjt.controller.admin.report.vo.ProjectOverviewExportReqVO;
import cn.iocoder.lyzsys.module.tjt.controller.admin.report.vo.ProjectQuarterOutputExportReqVO;
import cn.iocoder.lyzsys.module.tjt.controller.admin.report.vo.SpecialtyPersonOutputExportReqVO;
import cn.iocoder.lyzsys.module.tjt.service.report.ProjectOutputReportService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;

import static cn.iocoder.lyzsys.framework.apilog.core.enums.OperateTypeEnum.EXPORT;

@Tag(name = "管理后台 - 产值报表导出")
@RestController
@RequestMapping("/tjt/report")
@Validated
public class ProjectOutputReportController {

    @Resource
    private ProjectOutputReportService projectOutputReportService;

    @GetMapping("/project-budget/export-excel")
    @Operation(summary = "导出项目考核产值预算表")
    @PreAuthorize("@ss.hasPermission('tjt:report-budget:export')")
    @ApiAccessLog(operateType = EXPORT)
    public void exportProjectBudgetExcel(HttpServletResponse response,
                                         @Valid ProjectBudgetExportReqVO reqVO) throws IOException {
        projectOutputReportService.exportProjectBudgetExcel(response, reqVO);
    }

    @GetMapping("/project-quarter-output/export-excel")
    @Operation(summary = "导出项目级年度季度计取表")
    @PreAuthorize("@ss.hasPermission('tjt:report-project-quarter:export')")
    @ApiAccessLog(operateType = EXPORT)
    public void exportProjectQuarterOutputExcel(HttpServletResponse response,
                                                @Valid ProjectQuarterOutputExportReqVO reqVO) throws IOException {
        projectOutputReportService.exportProjectQuarterOutputExcel(response, reqVO);
    }

    @GetMapping("/project-lead-quarter-output/export-excel")
    @Operation(summary = "导出项目负责人年度季度计取表")
    @PreAuthorize("@ss.hasPermission('tjt:report-project-quarter:export')")
    @ApiAccessLog(operateType = EXPORT)
    public void exportProjectLeadQuarterOutputExcel(HttpServletResponse response,
                                                    @Valid ProjectLeadQuarterOutputExportReqVO reqVO)
            throws IOException {
        projectOutputReportService.exportProjectLeadQuarterOutputExcel(response, reqVO);
    }

    @GetMapping("/specialty-person-output/export-excel")
    @Operation(summary = "导出专业内人员年度季度计取表")
    @PreAuthorize("@ss.hasPermission('tjt:report-specialty-person:export')")
    @ApiAccessLog(operateType = EXPORT)
    public void exportSpecialtyPersonOutputExcel(HttpServletResponse response,
                                                 @Valid SpecialtyPersonOutputExportReqVO reqVO) throws IOException {
        projectOutputReportService.exportSpecialtyPersonOutputExcel(response, reqVO);
    }

    @GetMapping("/project-overview/export-excel")
    @Operation(summary = "导出项目总览表")
    @PreAuthorize("@ss.hasPermission('tjt:report-summary:export')")
    @ApiAccessLog(operateType = EXPORT)
    public void exportProjectOverviewExcel(HttpServletResponse response,
                                           @Valid ProjectOverviewExportReqVO reqVO) throws IOException {
        projectOutputReportService.exportProjectOverviewExcel(response, reqVO);
    }

    @GetMapping("/employee-output-summary/export-excel")
    @Operation(summary = "导出员工个人考核产值汇总表")
    @PreAuthorize("@ss.hasPermission('tjt:report-summary:export')")
    @ApiAccessLog(operateType = EXPORT)
    public void exportEmployeeOutputSummaryExcel(HttpServletResponse response,
                                                 @Valid EmployeeOutputSummaryExportReqVO reqVO)
            throws IOException {
        projectOutputReportService.exportEmployeeOutputSummaryExcel(response, reqVO);
    }

}
