package com.sckw.transport.controller;

import com.sckw.core.web.response.BaseResult;
import com.sckw.transport.model.TaskStatisticsVo;
import com.sckw.transport.model.param.FleetRankingReq;
import com.sckw.transport.model.param.LogisticsOrderStatisticsReq;
import com.sckw.transport.model.param.TaskStatisticsReq;
import com.sckw.transport.model.vo.FleetRankingVo;
import com.sckw.transport.model.vo.LogOrderStatisticsVo;
import com.sckw.transport.service.KwfTaskService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * @author cxf
 * @desc 任务统计接口
 */
@RestController
@RequestMapping("/task")
@RequiredArgsConstructor
@Tag(name = "任务和车辆数据统计模块", description = "任务和车辆数据统计模块")
public class KwfTaskController {
    private final KwfTaskService kwfTaskService;

    /**
     * 任务和车辆数据统计
     */
    @PostMapping("/taskStatistics")
    @Operation(summary = "任务和车辆数据统计", description = "任务和车辆数据统计")
    public BaseResult<TaskStatisticsVo> getTaskStatistics(@RequestBody TaskStatisticsReq req)  {
        TaskStatisticsVo truckInfoVo = kwfTaskService.getTaskStatistics(req);
        return BaseResult.success(truckInfoVo);
    }

    /**
     * 获取高德地图apiKey
     */
    @GetMapping("/getMapApikey")
    @Operation(summary = "获取高德地图apiKey", description = "获取高德地图apiKey")
    public BaseResult<String> getMapApikey()  {
        return BaseResult.success(kwfTaskService.getMapApikey());
    }

    @PostMapping("/getWaybillOrderStatistics")
    @Operation(summary = "获取物流运单数据", description = "获取物流运单数据")
    public BaseResult<LogOrderStatisticsVo> getWaybillOrderStatistics(@Valid @RequestBody LogisticsOrderStatisticsReq req)  {
        return BaseResult.success(kwfTaskService.getWaybillOrderStatistics(req));
    }

    @PostMapping("/getFleetRanking")
    @Operation(summary = "获取车队排名", description = "获取车队排名")
    public BaseResult<FleetRankingVo> getFleetRanking(@Valid @RequestBody FleetRankingReq req)  {
        return BaseResult.success(kwfTaskService.getFleetRanking(req));
    }
}
