package com.prolog.rdc.tms.controller;

import com.prolog.rdc.tms.model.dto.WholeCarDeliveryItemDTO;
import com.prolog.rdc.tms.model.dto.WholeCarDeliveryPackDTO;
import com.prolog.rdc.tms.model.dto.WholeCarDeliveryShibillDTO;
import com.prolog.rdc.tms.model.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
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.validation.Valid;

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.OutStockOnWayPageDTO;
import com.prolog.rdc.tms.service.OutStockOnWayService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 运输管理——出库在途控制层
 *
 * Company: 湖北普罗格科技股份有限公司
 *
 * @author xyf
 * @since 2022/4/11 12:23
 */
@RestController
@Api(tags = "运输管理-出库在途控制层")
@RequestMapping("/out_stock_on_way")
public class OutStockOnWayController {

	@Autowired
	private OutStockOnWayService service;

	@UserLog("主界面派车单分页查询")
	@ApiOperation(value = "主界面派车单分页查询", notes = "主界面派车单分页查询")
	@PostMapping("/query_page")
	public RestMessage<Page<OutStockOnWayPageDTO>> queryPage(@RequestBody @Valid OutStockOnWayQueryVO vo) throws Exception {
		Page<OutStockOnWayPageDTO> page = service.queryPage(vo);
		return RestMessage.newInstance(true, "查询成功！", page);
	}

	@UserLog("主界面派车单高级查询")
	@ApiOperation(value = "主界面派车单高级查询", notes = "主界面派车单高级查询")
	@PostMapping("/advanced_query_page")
	public RestMessage<Page<OutStockOnWayPageDTO>> advancedQueryPage(@RequestBody @Valid OutStockOnWayAdvancedQueryVO vo) throws Exception {
		Page<OutStockOnWayPageDTO> page = service.advancedQueryPage(vo);
		return RestMessage.newInstance(true, "查询成功！", page);
	}

	@UserLog("配载运单分页查询")
	@ApiOperation(value = "配载运单分页查询", notes = "配载运单分页查询")
	@PostMapping("/shipbill")
	public RestMessage<Page<WholeCarDeliveryShibillDTO>> queryShipbill(@RequestBody WholeCarDeliveryShipbillQueryVO vo) throws Exception {
		Page<WholeCarDeliveryShibillDTO> page = service.queryShipbill(vo.getPageNum(),vo.getPageSize(),vo.getLoadingBillId());
		return RestMessage.newInstance(true, "查询成功！", page);
	}

	@UserLog("配载商品分页查询")
	@ApiOperation(value = "配载商品分页查询", notes = "配载商品分页查询")
	@PostMapping("/item")
	public RestMessage<Page<WholeCarDeliveryItemDTO>> queryItem(@RequestBody WholeCarDeliveryItemQueryVO vo) throws Exception {
		Page<WholeCarDeliveryItemDTO> page = service.queryItem(vo);
		return RestMessage.newInstance(true, "查询成功！", page);
	}

	@UserLog("配载包裹分页查询")
	@ApiOperation(value = "配载包裹分页查询", notes = "配载包裹分页查询")
	@PostMapping("/pack")
	public RestMessage<Page<WholeCarDeliveryPackDTO>> queryPack(@RequestBody WholeCarDeliveryPackQueryVO vo) throws Exception {
		Page<WholeCarDeliveryPackDTO> page = service.queryPack(vo);
		return RestMessage.newInstance(true, "查询成功！", page);
	}

	@UserLog("派车单送达确认")
	@ApiOperation(value = "派车单送达确认", notes = "派车单送达确认")
	@PostMapping("/loadingDeliveryConfirm")
	public RestMessage<Object> loadingDeliveryConfirm(@RequestBody DeliveryConfirmVO vo) throws Exception {
		service.loadingDeliveryConfirm(vo);
		return RestMessage.newInstance(true, "操作成功！", null);
	}

	@UserLog("派车单客服反馈")
	@ApiOperation(value = "派车单客服反馈", notes = "派车单客服反馈")
	@PostMapping("/loadingFeedback")
	public RestMessage<Object> loadingFeedback(@RequestBody WholeCarFeedbackVO vo) throws Exception {
		service.loadingFeedback(vo);
		return RestMessage.newInstance(true, "操作成功！", null);
	}

	@UserLog("派车单异常登记")
	@ApiOperation(value = "派车单异常登记", notes = "派车单异常登记")
	@PostMapping("/loadingAbnormalRegister")
	public RestMessage<Object> loadingAbnormalRegister(@RequestBody WholeCarAbnormalRegisterVO vo) throws Exception {
		service.loadingAbnormalRegister(vo);
		return RestMessage.newInstance(true, "操作成功！", null);
	}

	@UserLog("运单送达确认")
	@ApiOperation(value = "运单送达确认", notes = "运单送达确认")
	@PostMapping("/shipbillDeliveryConfirm")
	public RestMessage<Object> shipbillDeliveryConfirm(@RequestBody DeliveryConfirmVO vo) throws Exception {
		service.loadingDeliveryConfirm(vo);
		return RestMessage.newInstance(true, "操作成功！", null);
	}

	@UserLog("运单客服反馈")
	@ApiOperation(value = "运单客服反馈", notes = "运单客服反馈")
	@PostMapping("/shipbillFeedback")
	public RestMessage<Object> shipbillFeedback(@RequestBody WholeCarFeedbackVO vo) throws Exception {
		service.loadingFeedback(vo);
		return RestMessage.newInstance(true, "操作成功！", null);
	}

	@UserLog("运单异常登记")
	@ApiOperation(value = "运单异常登记", notes = "运单异常登记")
	@PostMapping("/shipbillAbnormalRegister")
	public RestMessage<Object> shipbillAbnormalRegister(@RequestBody WholeCarAbnormalRegisterVO vo) throws Exception {
		service.loadingAbnormalRegister(vo);
		return RestMessage.newInstance(true, "操作成功！", null);
	}

}
