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

import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.log.aop.annotation.UserLog;
import com.prolog.rdc.tms.app.model.dto.business.*;
import com.prolog.rdc.tms.app.model.vo.business.LoadingScanCodeVO;
import com.prolog.rdc.tms.app.model.vo.business.LoadingScanConfirmVO;
import com.prolog.rdc.tms.app.model.vo.business.LoadingScanQueryVO;
import com.prolog.rdc.tms.app.model.vo.business.LoadingScanShipbillDetailVO;
import com.prolog.rdc.tms.app.service.business.LoadingScanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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 java.util.List;

/**
 * @author hongbo.pan
 * @date 2022/12/8
 */
@RestController
@Api(tags = "装车扫描")
@RequestMapping("/loadingScan")
public class LoadingScanController {

	@Autowired
	private LoadingScanService loadingScanService;

	@UserLog("获取月台扫描信息")
	@ApiOperation(value = "获取月台扫描信息", notes = "获取月台扫描信息")
	@PostMapping("/getPlatformScanInfo")
	public RestMessage<List<LoadingScanPlatformDTO>> getPlatformScanInfo(@RequestBody @Valid LoadingScanQueryVO vo) {
		return RestMessage.newInstance(true, "操作成功！", loadingScanService.getPlatformScanInfo(vo));
	}

	@UserLog("获取派车单扫描信息")
	@ApiOperation(value = "获取派车单扫描信息", notes = "获取派车单扫描信息")
	@PostMapping("/getLoadingBillScanInfo")
	public RestMessage<LoadingScanLoadingBillDTO> getLoadingBillScanInfo(@RequestBody @Valid LoadingScanQueryVO vo) {
		return RestMessage.newInstance(true, "操作成功！", loadingScanService.getLoadingBillScanInfo(vo));
	}

	@UserLog("获取运单扫描信息")
	@ApiOperation(value = "获取运单扫描信息", notes = "获取运单扫描信息")
	@PostMapping("/getShipBillScanInfo")
	public RestMessage<LoadingScanShipBillDTO> getShipBillScanInfo(@RequestBody LoadingScanQueryVO vo) {
		return RestMessage.newInstance(true, "操作成功！", loadingScanService.getShipBillScanInfo(vo));
	}

	@UserLog("获取运单明细扫描信息")
	@ApiOperation(value = "获取运单明细扫描信息", notes = "获取运单明细扫描信息")
	@PostMapping("/getShipBillDetailScanInfo")
	public RestMessage<LoadingScanShipBillDTO> getShipBillDetailScanInfo(@RequestBody LoadingScanQueryVO vo) {
		return RestMessage.newInstance(true, "操作成功！", loadingScanService.getShipBillDetailScanInfo(vo));
	}

	@UserLog("扫描单号")
	@ApiOperation(value = "扫描单号", notes = "扫描单号")
	@PostMapping("/scanCode")
	public RestMessage<LoadingScanInfoDTO> scanCode(@RequestBody @Valid LoadingScanCodeVO vo) {
		return RestMessage.newInstance(true, "操作成功！", loadingScanService.scanCode(vo));
	}

	@UserLog("装车确认")
	@ApiOperation(value = "装车确认", notes = "装车确认")
	@PostMapping("/scanConfirm")
	public RestMessage<LoadingScanConfirmDTO> scanConfirm(@RequestBody @Valid LoadingScanConfirmVO vo) {
		return RestMessage.newInstance(true, "操作成功！", loadingScanService.scanConfirm(vo));
	}

	@UserLog("运单剔除")
	@ApiOperation(value = "运单剔除", notes = "运单剔除")
	@PostMapping("/shipBillOut")
	public RestMessage<Object> shipBillOut(@RequestBody @Valid LoadingScanConfirmVO vo) {
		loadingScanService.shipBillOut(vo);
		return RestMessage.newInstance(true, "操作成功！", null);
	}

	@UserLog("保存商品的扫描件数")
	@ApiOperation(value = "保存商品的扫描件数", notes = "保存商品的扫描件数")
	@PostMapping("/saveItemScanPcs")
	public RestMessage<Object> saveItemScanPcs(@RequestBody @Valid LoadingScanShipbillDetailVO vo) {
		loadingScanService.saveItemScanPcs(vo);
		return RestMessage.newInstance(true, "操作成功！", null);
	}

	@UserLog("部分装车确认")
	@ApiOperation(value = "部分装车确认", notes = "部分装车确认")
	@PostMapping("/partScanConfirm")
	public RestMessage<LoadingScanConfirmDTO> partScanConfirm(@RequestBody @Valid LoadingScanConfirmVO vo) {
		return RestMessage.newInstance(true, "操作成功！", loadingScanService.partScanConfirm(vo));
	}

}
