package com.sckw.transport.controller;

import com.sckw.core.web.response.BaseResult;
import com.sckw.transport.api.model.vo.CurrentCapacityAnalysisVo;
import com.sckw.transport.api.model.vo.RealtimeSalesVolumeVo;
import com.sckw.transport.service.dashboard.RealtimeSalesVolumeService;
import com.sckw.transport.service.dashboard.SubtaskCapacityAnalysisService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
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;

/**
 * 数据看板类开放接口（供报表等 Feign 调用）
 */
@RestController
@RequestMapping("/dashboard")
@RequiredArgsConstructor
@Tag(name = "运输看板", description = "统计类接口")
public class TransportDashboardController {

    private final RealtimeSalesVolumeService realtimeSalesVolumeService;
    private final SubtaskCapacityAnalysisService subtaskCapacityAnalysisService;

    @Operation(summary = "实时销量", description = "近12个整点，每点统计上一小时完成运单净重（吨），按商品分线")
    @GetMapping("/realtimeSalesVolume")
    public BaseResult<RealtimeSalesVolumeVo> realtimeSalesVolume() {
        return BaseResult.success(realtimeSalesVolumeService.build());
    }

    @Operation(summary = "当前运力分析（子运单口径）", description = "基于 kwt_waybill_order_subtask 聚合运单维度：待进场、装载作业、配送中")
    @PostMapping("/currentCapacityAnalysisBySubtask")
    public BaseResult<CurrentCapacityAnalysisVo> currentCapacityAnalysisBySubtask() {
        return BaseResult.success(subtaskCapacityAnalysisService.analyze());
    }
}
