package com.ruoyi.logistics.controller;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.logistics.domain.LargeRequest;
import com.ruoyi.logistics.service.LargeScreenReportService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;

/**
 * 大屏展示报表
 *
 * @author RuiJing
 * @date 2026-04-07
 */
@RestController
@RequestMapping("/large")
public class LargeScreenReportController  extends BaseController {

    private static final Logger logger = LoggerFactory.getLogger(LargeScreenReportController.class);

    @Autowired
    LargeScreenReportService largeScreenReportService;

    /**
     * 京东顺丰下单量
     * 参数： 开始结束时间
     * 供应商
     */

    @PostMapping("/queryOrderTypeReport")
    public AjaxResult queryOrderTypeReport(@RequestBody LargeRequest largeRequest) {
        try {
            List<Map> result = largeScreenReportService.queryOrderTypeReport(largeRequest);
            return AjaxResult.success(result);
        } catch (Exception e) {
            return AjaxResult.error("系统错误！");
        }
    }


    /**
     * 每日订单量
     * 参数： 开始结束时间
     *       供应商
     */
    @PostMapping("/queryDayOrdersReport")
    public AjaxResult queryDayOrdersReport(@RequestBody LargeRequest largeRequest) {
        try {
            Map result = largeScreenReportService.queryDayOrdersReport(largeRequest);
            return AjaxResult.success(result);
        } catch (Exception e) {
            return AjaxResult.error("系统错误！");
        }
    }

    /**
     * 各省份发货订单量
     * 参数： 开始结束时间
     *       供应商
     */
    @PostMapping("/queryProvinceOrdersReport")
    public AjaxResult queryProvinceOrdersReport(@RequestBody LargeRequest largeRequest) {
        try {
            Map result = largeScreenReportService.queryProvinceOrdersReport(largeRequest);
            return AjaxResult.success(result);
        } catch (Exception e) {
            return AjaxResult.error("系统错误！");
        }
    }

    /**
     * 运输类型统计
     * 参数： 开始结束时间
     *       供应商
     */




    @PostMapping("/queryTransportTypeReport")
    public AjaxResult queryTransportTypeReport(@RequestBody LargeRequest largeRequest) {
        try {
            List<Map> result = largeScreenReportService.queryTransportTypeReport(largeRequest);
            return AjaxResult.success(result);
        } catch (Exception e) {
            return AjaxResult.error("系统错误！");
        }
    }

    /**
     * 物流费用统计
     * 参数： 开始结束时间
     *       供应商
     */
    @PostMapping("/queryFreeOrdersReport")
    public AjaxResult queryFreeOrdersReport(@RequestBody LargeRequest largeRequest) {
        try {
            List<Map> result = largeScreenReportService.queryFreeOrdersReport(largeRequest);
            return AjaxResult.success(result);
        } catch (Exception e) {
            return AjaxResult.error("系统错误！");
        }
    }

    /**
     * 供应商排名  金额 下单量
     * 参数： 开始结束时间
     *       供应商
     *       类型  1 金额  2 下单量
     */
    @PostMapping("/queryOrdersReportByType")
    public AjaxResult queryOrdersReportByType(@RequestBody LargeRequest largeRequest) {
        try {
            List<Map> result = largeScreenReportService.queryOrdersReportByType(largeRequest);
            return AjaxResult.success(result);
        } catch (Exception e) {
            return AjaxResult.error("系统错误！");
        }
    }





    /**
     * 供应商月份金额统计
     * 参数： 开始结束时间
     *       供应商
     */
    @PostMapping("/queryDeptMonthlyGrowthRate")
    public AjaxResult queryDeptMonthlyGrowthRate(@RequestBody LargeRequest largeRequest) {
        try {
            Map result = largeScreenReportService.queryDeptMonthlyGrowthRate(largeRequest);
            return AjaxResult.success(result);
        } catch (Exception e) {
            return AjaxResult.error("系统错误！"+e.getMessage());
        }
    }


    /**
     * 供应商下拉查询列表
     *
     */

    @PostMapping("/queryDeptList")
    public AjaxResult queryDeptList(@RequestBody LargeRequest largeRequest) {
        try {
            List<Map> result = largeScreenReportService.queryDeptList( largeRequest);
            return AjaxResult.success(result);
        } catch (Exception e) {
            return AjaxResult.error("系统错误！");
        }
    }


    /**
     * 省份下拉列表
     *
     */
    @PostMapping("/queryProvinceList")
    public AjaxResult queryProvinceList(@RequestBody LargeRequest largeRequest) {
        try {
            List<Map> result = largeScreenReportService.queryProvinceList(largeRequest);
            return AjaxResult.success(result);
        } catch (Exception e) {
            return AjaxResult.error("系统错误！");
        }
    }

    /**
     * 省份查询轨迹
     *
     */
    @PostMapping("/queryLogisticsTrajectory")
    public AjaxResult queryLogisticsTrajectory(@RequestBody LargeRequest largeRequest) {
        try {
            Map result = largeScreenReportService.queryLogisticsTrajectory(largeRequest);
            return AjaxResult.success(result);
        } catch (Exception e) {
            return AjaxResult.error("系统错误！"+e.getMessage());
        }
    }
}