package com.sckw.order.controller;

import cn.hutool.core.date.LocalDateTimeUtil;
import com.sckw.order.api.model.OrderExecutionDisplayVo;
import com.sckw.order.api.model.OrderPara;
import com.sckw.order.api.model.TradeOrderPara;
import com.sckw.order.api.model.TradeOrderVo;
import com.sckw.order.serivce.KwoTradeOrderService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author lfdc
 * @desc 物流订单Controller-v4.2
 * @date 2024-03-11 11:06:06
 */
@Slf4j
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/tradeOrder")
@Tag(name = "物流订单相关接口")
public class McpController {

    private final KwoTradeOrderService kwoTradeOrderService;


    @GetMapping(value = "/trade")
    @Operation(summary = "查询贸易订单", description = "查询贸易订单")
    public List<TradeOrderVo> list(@ParameterObject OrderPara orderPara) {
        TradeOrderPara tradeOrderPara = new TradeOrderPara();
        tradeOrderPara.setStartTime(LocalDateTimeUtil.parse(orderPara.getStartTime(), "yyyy-MM-dd HH:mm:ss"));
        tradeOrderPara.setEndTime(LocalDateTimeUtil.parse(orderPara.getEndTime(), "yyyy-MM-dd HH:mm:ss"));
        tradeOrderPara.setUserId(orderPara.getUserId());
        tradeOrderPara.setOrderNo(orderPara.getOrderNo());
        return  kwoTradeOrderService.queryOrder(tradeOrderPara);
    }

    @GetMapping(value = "/orderExecutionDisplay")
    @Operation(summary = "订单执行情况看板", description = "已下单未结算订单的计划量、已装载、车次、完成率")
    public List<OrderExecutionDisplayVo> orderExecutionDisplay() {
        return kwoTradeOrderService.listOrderExecutionDisplay();
    }

}
