package com.sckw.report.controller;

import com.sckw.core.web.response.BaseResult;
import com.sckw.order.api.model.OrderExecutionDisplayVo;
import com.sckw.report.service.KwCapacityAnalysisService;
import com.sckw.report.service.KwHomeService;
import com.sckw.report.service.KwOrderExecutionService;
import com.sckw.report.service.KwRealtimeSalesService;
import com.sckw.transport.api.model.vo.CurrentCapacityAnalysisVo;
import com.sckw.transport.api.model.vo.RealtimeSalesVolumeVo;
import com.sckw.transport.api.model.vo.TransportTopStatisticsVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@AllArgsConstructor
@RestController
@RequestMapping("/kwBiCapacityAnalysis")
@Tag(name = "BI Dashboard", description = "BI Dashboard")
public class BiDashboardController {
    private final KwHomeService kwHomeService;
    private final KwCapacityAnalysisService capacityAnalysisService;
    private final KwOrderExecutionService orderExecutionService;
    private final KwRealtimeSalesService realtimeSalesService;

    @GetMapping("/transportTopStatistics")
    @Operation(summary = "运输顶部统计", description = "总运量, 总趟次, 今日趟次, 今日运量")
    public BaseResult<TransportTopStatisticsVo> transportTopStatistics() {
        return BaseResult.success(kwHomeService.transportTopStatistics());
    }

    @PostMapping("/currentDisplay")
    @Operation(summary = "当前运力展示", description = "待命, 装货和配送中")
    public BaseResult<CurrentCapacityAnalysisVo> currentDisplay() {
        return BaseResult.success(capacityAnalysisService.currentCapacityAnalysis());
    }

    @PostMapping("/currentDisplayBySubtask")
    @Operation(summary = "按子任务划分的当前运力", description = "按子任务划分的待命, 装货和配送中")
    public BaseResult<CurrentCapacityAnalysisVo> currentDisplayBySubtask() {
        return BaseResult.success(capacityAnalysisService.currentCapacityAnalysisBySubtask());
    }

    @GetMapping("/display")
    @Operation(summary = "订单执行展示", description = "订单执行指标和列表")
    public BaseResult<List<OrderExecutionDisplayVo>> display() {
        return BaseResult.success(orderExecutionService.orderExecutionDisplay());
    }

    @GetMapping("/volume")
    @Operation(summary = "实时销量", description = "实时销量趋势")
    public BaseResult<RealtimeSalesVolumeVo> volume() {
        return BaseResult.success(realtimeSalesService.realtimeSalesVolume());
    }
}