package com.prolog.rdc.tms.controller.intransit;

import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.core.pojo.Page;
import com.prolog.framework.log.aop.annotation.UserLog;
import com.prolog.rdc.tms.model.dto.intransit.LoadingBillHeaderPageDTO;
import com.prolog.rdc.tms.model.dto.ShipbillHeaderPageDTO;
import com.prolog.rdc.tms.model.vo.intransit.InTransitQueryVO;
import com.prolog.rdc.tms.service.impl.intransit.InTransitFactory;
import com.prolog.rdc.tms.util.DataUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
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 java.util.List;

/**
 * @author hongbo.pan
 * @date 2022/9/20
 */
@RestController
@Api(tags = "在途管理-车辆轨迹")
@RequestMapping("/inTransit/track")
public class InTransitTrackController {

    @Autowired
    private InTransitFactory inTransitFactory;

    @UserLog("轨迹查询")
    @ApiOperation(value = "轨迹查询", notes = "轨迹查询")
    @PostMapping("/getTrack/{positionType}")
    public RestMessage<List<Object>> getTrack(@PathVariable(required = false) String positionType, @RequestBody InTransitQueryVO vo) {
        DataUtils.setBillIdAndNo(vo);
        List<Object> dtoList = inTransitFactory.getInTransitService(positionType).getTrack(vo);
        return RestMessage.newInstance(true, "查询成功！", dtoList);
    }

    @UserLog("运单查询(分页)")
    @ApiOperation(value = "运单查询(分页)", notes = "运单查询(分页)")
    @PostMapping("/getTrackShipBill/{positionType}")
    public RestMessage<Page<ShipbillHeaderPageDTO>> getTrackShipBill(@PathVariable(required = false) String positionType, @RequestBody InTransitQueryVO vo) {
        DataUtils.setBillIdAndNo(vo);
        Page<ShipbillHeaderPageDTO> page = inTransitFactory.getInTransitService(positionType).getTrackShipBill(vo);
        return RestMessage.newInstance(true, "查询成功！", page);
    }

    @UserLog("派车单查询(分页)")
    @ApiOperation(value = "派车单查询(分页)", notes = "派车单查询(分页)")
    @PostMapping("/getTrackLoadingBill/{positionType}")
    public RestMessage<Page<LoadingBillHeaderPageDTO>> getTrackLoadingBill(@PathVariable(required = false) String positionType, @RequestBody InTransitQueryVO vo) {
        DataUtils.setBillIdAndNo(vo);
        Page<LoadingBillHeaderPageDTO> page = inTransitFactory.getInTransitService(positionType).getTrackLoadingBill(vo);
        return RestMessage.newInstance(true, "查询成功！", page);
    }

}
