package com.prolog.rdc.tms.controller;

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.core.pojo.Page;
import com.prolog.framework.log.aop.annotation.UserLog;
import com.prolog.rdc.tms.model.dto.ContoinerBillConsigneeCountDTO;
import com.prolog.rdc.tms.model.dto.ContoinerBillConsigneeDetailsListDTO;
import com.prolog.rdc.tms.model.dto.ContoinerBillConsigneePageDTO;
import com.prolog.rdc.tms.model.dto.ContoinerBillContainerCountDTO;
import com.prolog.rdc.tms.model.dto.ContoinerBillContainerPageDTO;
import com.prolog.rdc.tms.model.dto.ContoinerBillLogQueryDTO;
import com.prolog.rdc.tms.model.dto.ContoinerBillReturnCountDTO;
import com.prolog.rdc.tms.model.dto.ContoinerBillReturnDetailsListDTO;
import com.prolog.rdc.tms.model.dto.ContoinerBillReturnPageDTO;
import com.prolog.rdc.tms.model.vo.ContoinerBillConsigneeDetailsListVO;
import com.prolog.rdc.tms.model.vo.ContoinerBillConsigneePageVO;
import com.prolog.rdc.tms.model.vo.ContoinerBillContainerAbnormalVO;
import com.prolog.rdc.tms.model.vo.ContoinerBillContainerPageVO;
import com.prolog.rdc.tms.model.vo.ContoinerBillLogQueryVO;
import com.prolog.rdc.tms.model.vo.ContoinerBillReturnCancelVO;
import com.prolog.rdc.tms.model.vo.ContoinerBillReturnDetailsListVO;
import com.prolog.rdc.tms.model.vo.ContoinerBillReturnModifyVO;
import com.prolog.rdc.tms.model.vo.ContoinerBillReturnPageVO;
import com.prolog.rdc.tms.model.vo.ContoinerBillReturnReceiptedVO;
import com.prolog.rdc.tms.model.vo.ContoinerBillReturnSaveVO;
import com.prolog.rdc.tms.service.ContainerBillService;

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


/**
 *
 * 运输管理-在途容器控制层
 *
 * @className    :ContainerBillController
 * @author       :fanzw
 * @date         :2023/6/8
 * @description  :
 *
 * @version      :1.2.1
 *
 */
@RestController
@Api(tags = "运输管理-在途容器控制层")
@RequestMapping("/containerBill")
public class ContainerBillController {

    @Autowired
    private ContainerBillService containerBillService;

	@UserLog("容器维度查询")
	@ApiOperation(value = "容器维度查询", notes = "容器维度查询")
	@PostMapping("/page")
	public RestMessage<Page<ContoinerBillContainerPageDTO>> pageContoinerBillContainerExecute(@RequestBody ContoinerBillContainerPageVO contoinerBillContainerPageVO) {
		try {
			Page<ContoinerBillContainerPageDTO> contoinerBillContainerPageDTOs = containerBillService.pageContoinerBillContainerData(contoinerBillContainerPageVO);
			return RestMessage.newInstance(true, "查询成功", contoinerBillContainerPageDTOs);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("容器维度统计查询")
	@ApiOperation(value = "容器维度统计查询", notes = "容器维度统计查询")
	@PostMapping("/container/count")
	public RestMessage<ContoinerBillContainerCountDTO> countContoinerBillContainerExecute(@RequestBody ContoinerBillContainerPageVO contoinerBillContainerPageVO) {
		try {
			ContoinerBillContainerCountDTO contoinerBillContainerCountDTO = containerBillService.countContoinerBillContainerData(contoinerBillContainerPageVO);
			return RestMessage.newInstance(true, "查询成功", contoinerBillContainerCountDTO);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("容器业务日志查询")
	@ApiOperation(value = "容器业务日志查询", notes = "容器业务日志查询")
	@PostMapping("/log/query")
	public RestMessage<List<ContoinerBillLogQueryDTO>> listContoinerBillLogExecute(@RequestBody ContoinerBillLogQueryVO contoinerBillLogQueryVO) {
		try {
			List<ContoinerBillLogQueryDTO> contoinerBillLogQueryDTOs = containerBillService.listContoinerBillLogData(contoinerBillLogQueryVO);
			return RestMessage.newInstance(true, "查询成功", contoinerBillLogQueryDTOs);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("容器异常处理")
	@ApiOperation(value = "容器异常处理", notes = "容器异常处理")
	@PostMapping("/abnormal")
	public RestMessage<String> abnormalContoinerBillContainerExecute(@RequestBody ContoinerBillContainerAbnormalVO contoinerBillContainerAbnormalVO) {
		try {
			containerBillService.abnormalContoinerBillContainerData(contoinerBillContainerAbnormalVO);
			return RestMessage.newInstance(true, "异常处理成功", null);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("门店在途查询")
	@ApiOperation(value = "门店在途查询", notes = "门店在途查询")
	@PostMapping("/consignee/page")
	public RestMessage<Page<ContoinerBillConsigneePageDTO>> pageContoinerBillConsigneeExecute(@RequestBody ContoinerBillConsigneePageVO contoinerBillConsigneePageVO) {
		try {
			Page<ContoinerBillConsigneePageDTO> contoinerBillConsigneePageDTOs = containerBillService.pageContoinerBillConsigneeData(contoinerBillConsigneePageVO);
			return RestMessage.newInstance(true, "查询成功", contoinerBillConsigneePageDTOs);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("门店在途统计查询")
	@ApiOperation(value = "门店在途统计查询", notes = "门店在途统计查询")
	@PostMapping("/consignee/count")
	public RestMessage<ContoinerBillConsigneeCountDTO> countContoinerBillConsigneeExecute(@RequestBody ContoinerBillConsigneePageVO contoinerBillConsigneePageVO) {
		try {
			ContoinerBillConsigneeCountDTO contoinerBillConsigneeCountDTO = containerBillService.countContoinerBillConsigneeData(contoinerBillConsigneePageVO);
			return RestMessage.newInstance(true, "查询成功", contoinerBillConsigneeCountDTO);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("门店在途容器明细查询")
	@ApiOperation(value = "门店在途容器明细查询", notes = "门店在途容器明细查询")
	@PostMapping("/consignee/details")
	public RestMessage<List<ContoinerBillConsigneeDetailsListDTO>> listContoinerBillConsigneeDetailsExecute(@RequestBody ContoinerBillConsigneeDetailsListVO contoinerBillConsigneeDetailsListVO) {
		try {
			List<ContoinerBillConsigneeDetailsListDTO> contoinerBillConsigneeDetailsListDTOs = containerBillService.listContoinerBillConsigneeDetailsData(contoinerBillConsigneeDetailsListVO);
			return RestMessage.newInstance(true, "查询成功", contoinerBillConsigneeDetailsListDTOs);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("归还容器")
	@ApiOperation(value = "归还容器", notes = "归还容器")
	@PostMapping("/return/save")
	public RestMessage<String> saveContoinerBillReturnExecute(@RequestBody ContoinerBillReturnSaveVO contoinerBillReturnSaveVO) {
		try {
			containerBillService.saveContoinerBillReturnData(contoinerBillReturnSaveVO);
			return RestMessage.newInstance(true, "保存成功", null);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("容器归还单查询")
	@ApiOperation(value = "容器归还单查询", notes = "容器归还单查询")
	@PostMapping("/return/page")
	public RestMessage<Page<ContoinerBillReturnPageDTO>> pageContoinerBillReturnExecute(@RequestBody ContoinerBillReturnPageVO contoinerBillReturnPageVO) {
		try {
			Page<ContoinerBillReturnPageDTO> contoinerBillReturnPageDTOs = containerBillService.pageContoinerBillReturnData(contoinerBillReturnPageVO);
			return RestMessage.newInstance(true, "查询成功", contoinerBillReturnPageDTOs);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("容器归还单统计查询")
	@ApiOperation(value = "容器归还单统计查询", notes = "容器归还单统计查询")
	@PostMapping("/return/count")
	public RestMessage<ContoinerBillReturnCountDTO> countContoinerBillReturnExecute(@RequestBody ContoinerBillReturnPageVO contoinerBillReturnPageVO) {
		try {
			ContoinerBillReturnCountDTO contoinerBillReturnCountDTO = containerBillService.countContoinerBillReturnData(contoinerBillReturnPageVO);
			return RestMessage.newInstance(true, "查询成功", contoinerBillReturnCountDTO);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("容器归还单明细查询")
	@ApiOperation(value = "容器归还单明细查询", notes = "容器归还单明细查询")
	@PostMapping("/return/details")
	public RestMessage<List<ContoinerBillReturnDetailsListDTO>> listContoinerBillReturnDetailsExecute(@RequestBody ContoinerBillReturnDetailsListVO contoinerBillReturnDetailsListVO) {
		try {
			List<ContoinerBillReturnDetailsListDTO> contoinerBillReturnDetailsListDTOs = containerBillService.listContoinerBillReturnDetailsData(contoinerBillReturnDetailsListVO);
			return RestMessage.newInstance(true, "查询成功", contoinerBillReturnDetailsListDTOs);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("容器归还单取消")
	@ApiOperation(value = "容器归还单取消", notes = "容器归还单取消")
	@PostMapping("/return/cancel")
	public RestMessage<String> cancelContoinerBillReturnExecute(@RequestBody List<ContoinerBillReturnCancelVO> contoinerBillReturnCancelVOs) {
		try {
			containerBillService.cancelContoinerBillReturnData(contoinerBillReturnCancelVOs);
			return RestMessage.newInstance(true, "取消成功", null);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("容器归还单修改")
	@ApiOperation(value = "容器归还单修改", notes = "容器归还单修改")
	@PostMapping("/return/modify")
	public RestMessage<String> modifyContoinerBillReturnExecute(@RequestBody ContoinerBillReturnModifyVO contoinerBillReturnModifyVO) {
		try {
			containerBillService.modifyContoinerBillReturnData(contoinerBillReturnModifyVO);
			return RestMessage.newInstance(true, "修改成功", null);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("容器归还单签收")
	@ApiOperation(value = "容器归还单签收", notes = "容器归还单签收")
	@PostMapping("/return/receipted")
	public RestMessage<String> receiptedContoinerBillReturnExecute(@RequestBody ContoinerBillReturnReceiptedVO contoinerBillReturnReceiptedVO) {
		try {
			containerBillService.receiptedContoinerBillReturnData(contoinerBillReturnReceiptedVO);
			return RestMessage.newInstance(true, "签收成功", null);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}


}
