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

import java.util.List;

import javax.annotation.Resource;

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.AppointmentConfirmationDTO;
import com.prolog.rdc.tms.app.model.dto.PendingFullLinkQueryDTO;
import com.prolog.rdc.tms.app.model.dto.PendingPickUpDetailQueryDTO;
import com.prolog.rdc.tms.app.model.vo.AutoCheckInVO;
import com.prolog.rdc.tms.app.model.vo.FullLinkAppointmentConfirmationVO;
import com.prolog.rdc.tms.app.model.vo.PendingFullLinkPickUpSignInVO;
import com.prolog.rdc.tms.app.model.vo.PendingFullLinkPickUpStartShipmentVO;
import com.prolog.rdc.tms.app.model.vo.PendingFullLinkQueryVO;
import com.prolog.rdc.tms.app.service.PendingFullLinkService;

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

/**
 *
 *
 * 司机APP-全链路
 *
 * @className :PendingFullLinkController
 * @author :qian.yh
 * @creationTime :2022/08/15
 * @description :
 *
 * @modifier :
 * @modifyTime :
 * @reviseRemarks:
 *
 * @version :1.0.0
 *
 */
@Api(tags = "司机APP-全链路控制层")
@RestController
@RequestMapping("/pending_full_link")
public class PendingFullLinkController {
	@Resource
	private PendingFullLinkService pendingFullLinkService;

	@UserLog("仓库全链路查询")
	@ApiOperation(value = "仓库全链路查询", notes = "仓库全链路查询")
	@PostMapping("/pending_full_link_query")
	public RestMessage<List<PendingFullLinkQueryDTO>> pendingFullLinkQuery(@RequestBody PendingFullLinkQueryVO pendingFullLinkQueryVO) {
		try {
			List<PendingFullLinkQueryDTO> dtos = pendingFullLinkService.pendingFullLinkQuery(pendingFullLinkQueryVO);
			return RestMessage.newInstance(true, "查询成功", dtos);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("全链路预约登记")
	@ApiOperation(value = "全链路预约登记", notes = "全链路预约登记")
	@PostMapping("/pending_full_link_appointment_confirmation")
	public RestMessage<AppointmentConfirmationDTO> fullLinkAppointmentConfirmation(@RequestBody FullLinkAppointmentConfirmationVO pendingPickUpStartShipmentVO) {
		try {
			AppointmentConfirmationDTO dto = pendingFullLinkService.fullLinkAppointmentConfirmation(pendingPickUpStartShipmentVO);
			return RestMessage.newInstance(true, "全链路预约登记 成功", dto);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("全链路提货签到")
	@ApiOperation(value = "全链路提货签到", notes = "全链路提货签到")
	@PostMapping("/pending_full_link_pick_up_sign_in")
	public RestMessage<String> pendingFullLinkPickUpSignIn(@RequestBody PendingFullLinkPickUpSignInVO pendingPickUpSignInVO) {
		try {
			pendingFullLinkService.pendingFullLinkPickUpSignIn(pendingPickUpSignInVO);
			return RestMessage.newInstance(true, "提货签到成功", null);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("全链路启运登记")
	@ApiOperation(value = "全链路启运登记", notes = "全链路启运登记")
	@PostMapping("/pending_full_link_pick_up_start_shipment")
	public RestMessage<List<PendingPickUpDetailQueryDTO>> pendingFullLinkPickUpStartShipment(@RequestBody PendingFullLinkPickUpStartShipmentVO pendingPickUpStartShipmentVO) {
		try {
			List<PendingPickUpDetailQueryDTO> dtos = pendingFullLinkService.pendingFullLinkPickUpStartShipment(pendingPickUpStartShipmentVO);
			return RestMessage.newInstance(true, "启运登记成功", dtos);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("自动签到")
	@ApiOperation(value = "自动签到", notes = "自动签到")
	@PostMapping("/auto_check_in")
	public RestMessage<String> autoCheckIn(@RequestBody AutoCheckInVO autoCheckInVO) {
		try {
			pendingFullLinkService.autoCheckIn(autoCheckInVO);
			return RestMessage.newInstance(true, "自动签到", null);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}
}
