package com.prolog.rdc.tms.app.controller.web;

import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.log.aop.annotation.UserLog;
import com.prolog.rdc.tms.app.model.dto.NavigationLoadingBillDTO;
import com.prolog.rdc.tms.app.model.dto.NavigationLoadingBillDetailDTO;
import com.prolog.rdc.tms.app.model.vo.NavigationLoadingBillDetailQueryVO;
import com.prolog.rdc.tms.app.model.vo.NavigationLoadingBillQueryVO;
import com.prolog.rdc.tms.app.service.NavigationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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 javax.annotation.Resource;
import java.util.List;

/**
 * @author yaohai
 * @version v1.0.0
 * @since 2023/08/24 17:18
 **/
@Api(tags = "司机APP-导航")
@RestController
@RequestMapping("/navigation")
public class NavigationController {

    @Resource
    private NavigationService navigationService;

    /**
     * 入参：司机id
     * 业务逻辑：根据司机账号获取指派的(启运、部分送达)派车单信息，优先未完成，多个启运状态优先创建时间最早
     * 出参：派车单id、派车单号、车牌号、总里程、总任务数、待完成任务数、总重量、总体积
     * @return
     */
    @UserLog("司机版APP选择任务路线页面-获取派车单列表")
    @ApiOperation(value = "司机版APP选择任务路线页面-获取派车单列表", notes = "司机版APP选择任务路线页面-获取派车单列表")
    @PostMapping("/getLoadingBillByDriverId")
    public RestMessage<List<NavigationLoadingBillDTO>> getLoadingBillByDriverId(@RequestBody NavigationLoadingBillQueryVO queryVO) {
        try {
            List<NavigationLoadingBillDTO> result = navigationService.getLoadingBillByDriverId(queryVO);
            return RestMessage.newInstance(true, "查询成功", result);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, "查询失败:" + e.getMessage(), null);
        }
    }


    /**
     * 入参：派车单id,是否查询仅完成
     * @return
     */
    @UserLog("司机版APP选择任务路线页面-获取任务列表")
    @ApiOperation(value = "司机版APP选择任务路线页面-获取任务列表", notes = "司机版APP选择任务路线页面-获取任务列表")
    @PostMapping("/getLoadingBillDetail")
    public RestMessage<List<NavigationLoadingBillDetailDTO>> getLoadingBillDetail(@RequestBody NavigationLoadingBillDetailQueryVO queryVO) {
        try {
            List<NavigationLoadingBillDetailDTO> result = navigationService.getLoadingBillDetail(queryVO);
            return RestMessage.newInstance(true, "查询成功", result);
        } catch (Exception e) {
            e.printStackTrace();
            return RestMessage.newInstance(false, "查询失败:" + e.getMessage(), null);
        }
    }

}
