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;

/**
 * @author hongbo.pan
 * @date 2022/9/20
 */
@RestController
@Api(tags = "在途管理-车辆定位")
@RequestMapping("/inTransit/position")
public class InTransitPositionController {

    @Autowired
    private InTransitFactory inTransitFactory;

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

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

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

}
