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

import com.ningdatech.carapi.car.rpt.manage.RptTendaysManage;
import com.ningdatech.carapi.car.rpt.model.dto.RptTendaysOfflineWeekSpecialParamDTO;
import com.ningdatech.carapi.car.rpt.model.dto.RptTendaysOverspeedSpecialCompanyParamDTO;
import com.ningdatech.carapi.car.rpt.model.dto.RptTendaysOverspeedSpecialVehiclesParamDTO;
import com.ningdatech.carapi.car.rpt.model.po.RptTendaysSpecialOfflineWeekPO;
import com.ningdatech.carapi.car.rpt.model.vo.RptTendaysSpecialOfflineWeekVO;
import com.ningdatech.carapi.car.rpt.model.vo.RptTendaysSpecialOverspeedCompanyVO;
import com.ningdatech.carapi.car.rpt.model.vo.RptTendaysSpecialOverspeedVehiclesVO;
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 RptTendaysController {

    private final RptTendaysManage rptTendaysManage;

    @ApiOperation("浙江省专用车辆超速企业旬报")
    @GetMapping("/tendays-special-overspeed-company")
    public List<RptTendaysSpecialOverspeedCompanyVO> tendaysSpecialOverspeedCompany(
            @Valid @ModelAttribute RptTendaysOverspeedSpecialCompanyParamDTO param) {
        return rptTendaysManage.tendaysSpecialOverspeedCompany(param);
    }

    @ApiOperation("浙江省专用车辆超速车辆排序旬报")
    @GetMapping("/tendays-special-overspeed-vehicles")
    public List<RptTendaysSpecialOverspeedVehiclesVO> tendaysSpecialOverspeedVehicles(
            @Valid @ModelAttribute RptTendaysOverspeedSpecialVehiclesParamDTO param) {
        return rptTendaysManage.tendaysSpecialOverspeedVehicles(param);
    }

    @ApiOperation("全省一周不上线的专用车辆旬报")
    @GetMapping("/tendays-special-offline-week")
    public List<RptTendaysSpecialOfflineWeekVO> tendaysSpecialOfflineWeek(
            @Valid @ModelAttribute RptTendaysOfflineWeekSpecialParamDTO param) {
        return rptTendaysManage.tendaysSpecialOfflineWeek(param);
    }

    @ApiOperation("全省专用车辆企业排序表导出")
    @GetMapping("/special-vehicles-enterprise-sorting-tenDaysReport-export")
    public void specialVehiclesEnterpriseSortingTenDaysReportExport
            (RptTendaysOverspeedSpecialCompanyParamDTO req, HttpServletResponse response){
        ExcelDownUtil.downXls(response,req,rptTendaysManage::specialVehiclesEnterpriseSortingTenDaysReportExport);
    }

    @ApiOperation("企业专用车辆排序表导出")
    @GetMapping("/enterprise-special-vehicles-sorting-tenDaysReport-export")
    public void enterpriseSpecialVehiclesSortingTenDaysReportExport
            (RptTendaysOverspeedSpecialVehiclesParamDTO req, HttpServletResponse response){
        ExcelDownUtil.downXls(response,req,rptTendaysManage::enterpriseSpecialVehiclesSortingTenDaysReportExport);
    }

    @ApiOperation("全省一周以上不上线的专用车辆排序导出")
    @GetMapping("/special-vehicles-offline-week-tenDaysReport-export")
    public void specialVehiclesOfflineWeekTenDaysReportExport
            (RptTendaysOfflineWeekSpecialParamDTO req, HttpServletResponse response){
        ExcelDownUtil.downXls(response,req,rptTendaysManage::specialVehiclesOfflineWeekTenDaysReportExport);
    }
}
