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

import java.util.List;

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.log.aop.annotation.UserLog;
import com.prolog.rdc.tms.app.model.dto.AppointmentBillDetailQueryDTO;
import com.prolog.rdc.tms.app.model.dto.AppointmentBillQueryDTO;
import com.prolog.rdc.tms.app.model.dto.AppointmentConfirmationDTO;
import com.prolog.rdc.tms.app.model.dto.PendingAppointmentDetailQueryDTO;
import com.prolog.rdc.tms.app.model.dto.PendingAppointmentQueryDTO;
import com.prolog.rdc.tms.app.model.dto.WarehouseAppointmentResourceQueryDTO;
import com.prolog.rdc.tms.app.model.vo.AppointmentBillDetailQueryVO;
import com.prolog.rdc.tms.app.model.vo.AppointmentBillQueryVO;
import com.prolog.rdc.tms.app.model.vo.AppointmentCancelVO;
import com.prolog.rdc.tms.app.model.vo.AppointmentConfirmationVO;
import com.prolog.rdc.tms.app.model.vo.PendingAppointmentDetailQueryVO;
import com.prolog.rdc.tms.app.model.vo.PendingAppointmentQueryVO;
import com.prolog.rdc.tms.app.model.vo.WarehouseAppointmentResourceQueryVO;
import com.prolog.rdc.tms.app.service.PendingAppointmentService;

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

/**
 *
 *
 * 司机APP-待预约
 *
 * @className :PendingAppointmentController
 * @author :qian.yh
 * @creationTime :2022/07/04
 * @description :
 *
 * @modifier :
 * @modifyTime :
 * @reviseRemarks:
 *
 * @version :1.0.0
 *
 */
@Api(tags = "司机APP-待预约控制层")
@RestController
@RequestMapping("/pending_appointment")
public class PendingAppointmentController {
	@Autowired
	private PendingAppointmentService pendingAppointmentService;

	@UserLog("仓库任务数汇总查询")
	@ApiOperation(value = "仓库任务数汇总查询", notes = "仓库任务数汇总查询")
	@PostMapping("/pending_appointment_query")
	public RestMessage<List<PendingAppointmentQueryDTO>> pendingAppointmentQuery(@RequestBody PendingAppointmentQueryVO pendingAppointmentQueryVO) {
		try {
			List<PendingAppointmentQueryDTO> dtos = pendingAppointmentService.pendingAppointmentQuery(pendingAppointmentQueryVO);
			return RestMessage.newInstance(true, "查询成功", dtos);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("司机待预约派车单模式查询")
	@ApiOperation(value = "司机待预约派车单模式查询", notes = "司机待预约派车单模式查询")
	@PostMapping("/pending_appointment_query_load_bill")
	public RestMessage<List<PendingAppointmentQueryDTO>> pendingAppointmentQueryLoadBill(@RequestBody PendingAppointmentQueryVO pendingAppointmentQueryVO) {
		try {
			List<PendingAppointmentQueryDTO> dtos = pendingAppointmentService.pendingAppointmentQueryLoadBill(pendingAppointmentQueryVO);
			return RestMessage.newInstance(true, "查询成功", dtos);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("仓库任务明细查询")
	@ApiOperation(value = "仓库任务明细查询", notes = "仓库任务明细查询")
	@PostMapping("/pending_appointment_detail_query")
	public RestMessage<List<PendingAppointmentDetailQueryDTO>> pendingAppointmentDetailQuery(@RequestBody PendingAppointmentDetailQueryVO pendingAppointmentDetailQueryVO) {
		try {
			List<PendingAppointmentDetailQueryDTO> dtos = pendingAppointmentService.pendingAppointmentDetailQuery(pendingAppointmentDetailQueryVO);
			return RestMessage.newInstance(true, "查询成功", dtos);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("仓库预约资源查询")
	@ApiOperation(value = "仓库预约资源查询", notes = "仓库预约资源查询")
	@PostMapping("/warehouse_appointment_resource_query")
	public RestMessage<WarehouseAppointmentResourceQueryDTO> warehouseAppointmentResourceQuery(@RequestBody WarehouseAppointmentResourceQueryVO warehouseAppointmentResourceQueryVO) {
		try {
			WarehouseAppointmentResourceQueryDTO dto = pendingAppointmentService.warehouseAppointmentResourceQuery(warehouseAppointmentResourceQueryVO);
			return RestMessage.newInstance(true, "查询成功", dto);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("预约确认")
	@ApiOperation(value = "预约确认", notes = "预约确认")
	@PostMapping("/appointment_confirmation")
	public RestMessage<AppointmentConfirmationDTO> appointmentConfirmation(@RequestBody AppointmentConfirmationVO appointmentConfirmationVO) {
		try {
			appointmentConfirmationVO.setFullLink(Boolean.FALSE);
			AppointmentConfirmationDTO dto = pendingAppointmentService.appointmentConfirmation(appointmentConfirmationVO);
			return RestMessage.newInstance(true, "预约成功", dto);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("司机预约单信息查询")
	@ApiOperation(value = "司机预约单信息查询", notes = "司机预约单信息查询")
	@PostMapping("/appointment_bill_query")
	public RestMessage<List<AppointmentBillQueryDTO>> appointmentBillQuery(@RequestBody AppointmentBillQueryVO appointmentBillQueryVO) {
		try {
			List<AppointmentBillQueryDTO> dtos = pendingAppointmentService.appointmentBillQuery(appointmentBillQueryVO);
			return RestMessage.newInstance(true, "司机预约单信息查询成功", dtos);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("司机预约中信息查询")
	@ApiOperation(value = "司机预约中信息查询", notes = "司机预约中信息查询")
	@PostMapping("/appointment_doing_bill_query")
	public RestMessage<List<AppointmentBillQueryDTO>> appointmentDoingBillQuery(@RequestBody AppointmentBillQueryVO appointmentBillQueryVO) {
		try {
			List<AppointmentBillQueryDTO> dtos = pendingAppointmentService.appointmentDoingBillQuery(appointmentBillQueryVO);
			return RestMessage.newInstance(true, "司机预约单信息查询成功", dtos);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("司机预约单明细信息查询")
	@ApiOperation(value = "司机预约单明细信息查询", notes = "司机预约单明细信息查询")
	@PostMapping("/appointment_bill_detail_query")
	public RestMessage<List<AppointmentBillDetailQueryDTO>> appointmentBillDetailQuery(@RequestBody AppointmentBillDetailQueryVO appointmentBillDetailQueryVO) {
		try {
			List<AppointmentBillDetailQueryDTO> dtos = pendingAppointmentService.appointmentBillDetailQuery(appointmentBillDetailQueryVO);
			return RestMessage.newInstance(true, "司机预约单信息查询成功", dtos);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("预约取消")
	@ApiOperation(value = "预约取消", notes = "预约取消")
	@PostMapping("/appointment_cancel")
	public RestMessage<String> appointmentCancel(@RequestBody AppointmentCancelVO appointmentCancelVO) {
		try {
			pendingAppointmentService.appointmentCancel(appointmentCancelVO);
			return RestMessage.newInstance(true, "预约取消成功", null);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

}
