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

import com.prolog.rdc.tms.app.model.vo.business.AppointmentShipbillQueryVO;
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 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.app.model.dto.business.AppointmentQueryDTO;
import com.prolog.rdc.tms.app.model.dto.business.PickUpAppointmentDTO;
import com.prolog.rdc.tms.app.model.vo.business.BusinessAppointmentQueryVO;
import com.prolog.rdc.tms.app.model.vo.business.PickUpAppointmentConfirmVO;
import com.prolog.rdc.tms.app.model.vo.business.PickUpAppointmentVO;
import com.prolog.rdc.tms.app.service.business.AppointmentService;

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

/**
 * 业务APP-待预约控制层
 *
 * @author lhb
 * @since 2022-04-11 09:04:35
 */
@RestController
@Api(tags = "业务APP--待预约控制层")
@RequestMapping("/appointment")
public class AppointmentController {

	@Autowired
	private AppointmentService appointmentService;

	@UserLog("待预约运单模式查询")
	@ApiOperation(value = "待预约运单模式查询", notes = "待预约运单模式查询")
	@PostMapping("/page")
	public RestMessage<Page<AppointmentQueryDTO>> queryAppointmentShipbillExecute(@RequestBody BusinessAppointmentQueryVO appointmentQueryVO) {
		try {
			Page<AppointmentQueryDTO> appointmentDTOs = appointmentService.queryAppointmentShipbill(appointmentQueryVO);
			return RestMessage.newInstance(true, "查询成功", appointmentDTOs);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("待预约派车单模式查询")
	@ApiOperation(value = "待预约派车单模式查询", notes = "待预约派车单模式查询")
	@PostMapping("/page_load_bill")
	public RestMessage<Page<AppointmentQueryDTO>> queryAppointmentLoadBill(@RequestBody BusinessAppointmentQueryVO appointmentQueryVO) {
		try {
			Page<AppointmentQueryDTO> appointmentDTOs = appointmentService.queryAppointmentLoadBill(appointmentQueryVO);
			return RestMessage.newInstance(true, "查询成功", appointmentDTOs);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("提货预约")
	@ApiOperation(value = "提货预约", notes = "提货预约")
	@PostMapping("/pick_up_appointment")
	public RestMessage<PickUpAppointmentDTO> pickUpAppointmentQuery(@RequestBody PickUpAppointmentVO appointmentVO) {
		try {
			PickUpAppointmentDTO appointmentDTO = appointmentService.pickUpAppointmentQuery(appointmentVO);
			return RestMessage.newInstance(true, "提货预约成功", appointmentDTO);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("提货预约确认")
	@ApiOperation(value = "提货预约确认", notes = "提货预约确认")
	@PostMapping("/pick_up_appointment_confirm")
	public RestMessage<String> pickUpAppointmentConfirm(@RequestBody PickUpAppointmentConfirmVO confirmVO) {
		try {
			appointmentService.pickUpAppointmentConfirm(confirmVO);
			return RestMessage.newInstance(true, "提货预约确认成功", null);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	// STD-DEVELOP20220823 lhb 预约运单详情 20220831 start
	@UserLog("预约运单详情查询")
	@ApiOperation(value = "预约运单详情查询", notes = "预约运单详情查询")
	@PostMapping("/query_shipbill")
	public RestMessage<Page<AppointmentQueryDTO>> queryShipbillInfoExecute(@RequestBody AppointmentShipbillQueryVO appointmentQueryVO) {
		try {
			Page<AppointmentQueryDTO> appointmentDTOs = appointmentService.queryShipbillInfo(appointmentQueryVO);
			return RestMessage.newInstance(true, "查询成功", appointmentDTOs);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}
	// STD-DEVELOP20220823 lhb 预约运单详情 20220831 end
}
