package com.prolog.rdc.tms.controller;

import java.util.List;

import javax.validation.Valid;

import com.prolog.rdc.tms.model.dto.*;
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.model.vo.AbnormalShipbillAdvancedQueryVO;
import com.prolog.rdc.tms.model.vo.AbnormalShipbillItemQueryVO;
import com.prolog.rdc.tms.model.vo.AbnormalShipbillPackageQueryVO;
import com.prolog.rdc.tms.model.vo.AbnormalShipbillQueryVO;
import com.prolog.rdc.tms.service.AbnormalShipbillService;

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

/**
 * 运输管理——异常订单控制层
 * 
 * @author xyf
 * @since 2022/4/11 12:23
 */
@RestController
@Api(tags = "运输管理-异常订单控制层")
@RequestMapping("/abnormalShipbill")
public class AbnormalShipbillController {

	@Autowired
	private AbnormalShipbillService service;

	@UserLog("运单分页查询")
	@ApiOperation(value = "运单分页查询", notes = "运单分页查询")
	@PostMapping("/page")
	public RestMessage<Page<AbnormalShipbillPageDTO>> queryAbnormalShipbillPage(@RequestBody @Valid AbnormalShipbillQueryVO vo) {
		Page<AbnormalShipbillPageDTO> page = service.queryAbnormalShipbillPage(vo);
		return RestMessage.newInstance(true, "查询成功！", page);
	}

	@UserLog("运单高级查询")
	@ApiOperation(value = "运单高级查询", notes = "运单高级查询")
	@PostMapping("/advanced_page")
	public RestMessage<Page<AbnormalShipbillPageDTO>> advancedQueryAbnormalShipbillPage(@RequestBody @Valid AbnormalShipbillAdvancedQueryVO abnormalShipbillAdvancedQueryVO) {
		Page<AbnormalShipbillPageDTO> page = service.advancedQueryAbnormalShipbillPage(abnormalShipbillAdvancedQueryVO);
		return RestMessage.newInstance(true, "查询成功！", page);
	}

	@UserLog("运单商品查询")
	@ApiOperation(value = "运单商品查询", notes = "运单商品查询")
	@PostMapping("/item")
	public RestMessage<Page<AbnormalShipbillItemDTO>> listItemDetailData(@RequestBody  @Valid AbnormalShipbillItemQueryVO abnormalShipbillItemQueryVO) {
		Page<AbnormalShipbillItemDTO> page = service.listItemDetailData(abnormalShipbillItemQueryVO);
		return RestMessage.newInstance(true, "查询成功！", page);
	}

	@UserLog("运单包裹查询")
	@ApiOperation(value = "运单包裹查询", notes = "运单包裹查询")
	@PostMapping("/package")
	public RestMessage<Page<AbnormalShipbillPackageDTO>> listPackageData(@RequestBody  @Valid AbnormalShipbillPackageQueryVO abnormalShipbillPackageQueryVO) {
		Page<AbnormalShipbillPackageDTO> page = service.listPackageData(abnormalShipbillPackageQueryVO);
		return RestMessage.newInstance(true, "查询成功！", page);
	}

	// STD-DEVELOP20220823 lhb 异常关闭 20220926 start
	@UserLog("运单异常查询")
	@ApiOperation(value = "运单异常查询", notes = "运单异常查询")
	@PostMapping("/abnormal")
	public RestMessage<Page<AbnormalShipbillDTO>> listAbnormalData(@RequestBody  @Valid AbnormalShipbillItemQueryVO abnormalShipbillItemQueryVO) {
		Page<AbnormalShipbillDTO> page = service.listAbnormalData(abnormalShipbillItemQueryVO);
		return RestMessage.newInstance(true, "查询成功！", page);
	}
	// STD-DEVELOP20220823 lhb 异常关闭 20220926 end

	@UserLog("关闭运单的一个异常")
	@ApiOperation(value = "关闭运单的一个异常", notes = "关闭运单的一个异常")
	@PostMapping("/close_abnormal_shipbill")
	public RestMessage<Object> closeAbnormalShipbill(@RequestBody List<String> ids) {
		service.closeAbnormalShipbill(ids);
		return RestMessage.newInstance(true, "操作成功！", null);
	}

	@UserLog("关闭运单全部异常")
	@ApiOperation(value = "关闭运单全部异常", notes = "关闭运单全部异常")
	@PostMapping("/close")
	public RestMessage<Object> closeShipbill(@RequestBody List<String> ids) {
		service.closeShipbill(ids);
		return RestMessage.newInstance(true, "操作成功！", null);
	}

	@UserLog("导出")
	@ApiOperation(value = "导出", notes = "导出")
	@PostMapping("/export")
	public RestMessage<Page<AbnormalShipbillExportDTO>> exportPage(@RequestBody AbnormalShipbillQueryVO vo) {
		return RestMessage.newInstance(true, "导出成功！", null);
	}

}
