package com.ningdatech.carapi.car.rpt.controller;

import com.ningdatech.carapi.car.rpt.manage.RptMonthManage;
import com.ningdatech.carapi.car.rpt.model.dto.RptMonthOverspeedCompanyParamDTO;
import com.ningdatech.carapi.car.rpt.model.dto.RptMonthSpecialOfflineParamDTO;
import com.ningdatech.carapi.car.rpt.model.dto.RptMonthSpecialOverspeedCompanyParamDTO;
import com.ningdatech.carapi.car.rpt.model.dto.RptMonthSpecialOverspeedVehiclesParamDTO;
import com.ningdatech.carapi.car.rpt.model.vo.RptMonthOverspeedCompanyVO;
import com.ningdatech.carapi.car.rpt.model.vo.RptMonthOverspeedSpecialCompanyVO;
import com.ningdatech.carapi.car.rpt.model.vo.RptMonthOverspeedSpecialVehiclesVO;
import com.ningdatech.carapi.car.rpt.model.vo.RptMonthSpecialOfflineVO;
import com.ningdatech.carapi.common.util.ExcelDownUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 报表统计 前端控制器
 * </p>
 *
 * @author PoffyZhang
 * @since 2022-11-08
 */

@RequestMapping("/api/car-rpt")
@RequiredArgsConstructor
@RestController
@Api(tags = "车辆管理-统计报表")
@Validated
public class RptMonthController {

    private final RptMonthManage rptMonthManage;

    @ApiOperation("浙江省超速企业月报")
    @GetMapping("/monthly-overspeed-company")
    public List<RptMonthOverspeedCompanyVO> monthlyOverspeedCompany(
            @Valid @ModelAttribute RptMonthOverspeedCompanyParamDTO param) {
        return rptMonthManage.monthlyOverspeedCompany(param);
    }

    @ApiOperation("浙江省专用车辆排名月报")
    @GetMapping("/monthly-special-overspeed-company")
    public List<RptMonthOverspeedSpecialCompanyVO> monthlySpecialOverspeedCompany(
            @Valid @ModelAttribute RptMonthSpecialOverspeedCompanyParamDTO param) {
        return rptMonthManage.monthlySpecialOverspeedCompany(param);
    }

    @ApiOperation("浙江省专用车辆不上线排序月报")
    @GetMapping("/monthly-special-offline")
    public List<RptMonthSpecialOfflineVO> monthlySpecialOffline(
            @Valid @ModelAttribute RptMonthSpecialOfflineParamDTO param) {
        return rptMonthManage.monthlySpecialOffline(param);
    }

    @ApiOperation("浙江省专用车辆月对比")
    @GetMapping("/monthly-special-overspeed-vehicles")
    public List<RptMonthOverspeedSpecialVehiclesVO> monthlyOverspeedVehicles(
            @Valid @ModelAttribute RptMonthSpecialOverspeedVehiclesParamDTO param) {
        return rptMonthManage.monthlyOverspeedVehicles(param);
    }

    @ApiOperation("浙江省超速企业排名月报表导出")
    @GetMapping("/ZJ-overSpeed-enterprise-rank-monthReport-export")
    public void overSpeedEnterpriseRankMonthReportExport
            (RptMonthOverspeedCompanyParamDTO req, HttpServletResponse response){
        ExcelDownUtil.downXls(response,req,rptMonthManage::overSpeedEnterpriseRankMonthReportExport);
    }

    @ApiOperation("浙江省超速专用车辆排名月报表导出")
    @GetMapping("/ZJ-overSpeed-special-vehicles-rank-monthReport-export")
    public void overSpeedSpecialVehiclesRankMonthReportExport
            (RptMonthSpecialOverspeedCompanyParamDTO req, HttpServletResponse response){
        ExcelDownUtil.downXls(response,req,rptMonthManage::overSpeedSpecialVehiclesRankMonthReportExport);
    }

    @ApiOperation("浙江省不上线的专用车辆排序表月报导出")
    @GetMapping("/ZJ-special-vehicles-offline-sorting-monthReport-export")
    public void specialVehiclesOfflineSortingMonthReportExport
            (RptMonthSpecialOfflineParamDTO req, HttpServletResponse response){
        ExcelDownUtil.downXls(response,req,rptMonthManage::specialVehiclesOfflineSortingMonthReportExport);
    }

    @ApiOperation("浙江省超速专用车辆月对比报表导出")
    @GetMapping("/ZJ-overSpeed-special-vehicles-contrast-monthReport-export")
    public void overSpeedSpecialVehiclesContrastMonthReportExport
            (RptMonthSpecialOverspeedVehiclesParamDTO req, HttpServletResponse response){
        ExcelDownUtil.downXls(response,req,rptMonthManage::overSpeedSpecialVehiclesContrastMonthReportExport);
    }
}
