package com.xunhong.erp.turbo.biz.app.service;

import com.xunhong.erp.turbo.api.biz.api.PurchaseOrderServiceI;
import com.xunhong.erp.turbo.api.biz.dto.cmd.*;
import com.xunhong.erp.turbo.api.biz.dto.qry.LastVehicleNoQry;
import com.xunhong.erp.turbo.api.biz.dto.qry.PurchaseOrderCountQry;
import com.xunhong.erp.turbo.api.biz.dto.qry.PurchaseOrderListQry;
import com.xunhong.erp.turbo.api.biz.dto.qry.PurchaseOrderPageQry;
import com.xunhong.erp.turbo.api.biz.dto.qry.PurchaseOrderShowQry;
import com.xunhong.erp.turbo.api.biz.dto.vo.PurchaseOrderVO;
import com.xunhong.erp.turbo.base.dto.PageDTO;
import com.xunhong.erp.turbo.biz.app.executor.cmd.*;
import com.xunhong.erp.turbo.biz.app.executor.query.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author shenyifei
 */
@Slf4j
@Service
@DubboService(interfaceClass = PurchaseOrderServiceI.class, version = "1.0.0")
@RequiredArgsConstructor
public class PurchaseOrderServiceImpl implements PurchaseOrderServiceI {

	private final PurchaseOrderCreateCmdExe purchaseOrderCreateCmdExe;
	private final PurchaseOrderUpdateCmdExe purchaseOrderUpdateCmdExe;
	private final PurchaseOrderPageQryExe purchaseOrderPageQryExe;
	private final PurchaseOrderListQryExe purchaseOrderListQryExe;
	private final PurchaseOrderShowQryExe purchaseOrderShowQryExe;
	private final PurchaseOrderDestroyCmdExe purchaseOrderDestroyCmdExe;
	private final PurchaseOrderApproveCmdExe purchaseOrderApproveCmdExe;
	private final PurchaseOrderSubmitReviewCmdExe purchaseOrderSubmitReviewCmdExe;
	private final PurchaseOrderWithdrawReviewCmdExe purchaseOrderWithdrawReviewCmdExe;
	private final PurchaseOrderRejectApproveCmdExe purchaseOrderRejectApproveCmdExe;
	private final PurchaseOrderFinalApproveCmdExe purchaseOrderFinalApproveCmdExe;
	private final PurchaseOrderRejectFinalCmdExe purchaseOrderRejectFinalCmdExe;
	private final PurchaseOrderCountQryExe purchaseOrderCountQryExe;

	// 新增分步提交执行器
	private final PurchaseOrderStep1CmdExe purchaseOrderStep1CmdExe;
	private final PurchaseOrderStep2CmdExe purchaseOrderStep2CmdExe;
	private final PurchaseOrderStep3CmdExe purchaseOrderStep3CmdExe;

	private final LastVehicleNoQryExe lastVehicleNoQryExe;

	@Override
	public PurchaseOrderVO create(PurchaseOrderCreateCmd purchaseOrderCreateCmd) {
		return purchaseOrderCreateCmdExe.execute(purchaseOrderCreateCmd);
	}

	@Override
	public PageDTO<PurchaseOrderVO> page(PurchaseOrderPageQry purchaseOrderPageQry) {
		return PageDTO.of(purchaseOrderPageQryExe.execute(purchaseOrderPageQry));
	}

	@Override
	public List<PurchaseOrderVO> list(PurchaseOrderListQry purchaseOrderListQry) {
		return purchaseOrderListQryExe.execute(purchaseOrderListQry);
	}

	@Override
	public PurchaseOrderVO update(PurchaseOrderUpdateCmd purchaseOrderUpdateCmd) {
		return purchaseOrderUpdateCmdExe.execute(purchaseOrderUpdateCmd);
	}

	@Override
	public PurchaseOrderVO show(PurchaseOrderShowQry purchaseOrderShowQry) {
		return purchaseOrderShowQryExe.execute(purchaseOrderShowQry);
	}

	@Override
	public void destroy(PurchaseOrderDestroyCmd purchaseOrderDestroyCmd) {
		purchaseOrderDestroyCmdExe.execute(purchaseOrderDestroyCmd);
	}

	@Override
	public void approve(PurchaseOrderApproveCmd purchaseOrderApproveCmd) {
		purchaseOrderApproveCmdExe.execute(purchaseOrderApproveCmd);
	}

	@Override
	public void submitReview(PurchaseOrderSubmitReviewCmd purchaseOrderSubmitReviewCmd) {
		purchaseOrderSubmitReviewCmdExe.execute(purchaseOrderSubmitReviewCmd);
	}

	@Override
	public void withdrawReview(PurchaseOrderWithdrawReviewCmd purchaseOrderWithdrawReviewCmd) {
		purchaseOrderWithdrawReviewCmdExe.execute(purchaseOrderWithdrawReviewCmd);
	}

	@Override
	public void rejectApprove(PurchaseOrderRejectApproveCmd purchaseOrderRejectApproveCmd) {
		purchaseOrderRejectApproveCmdExe.execute(purchaseOrderRejectApproveCmd);
	}

	@Override
	public void finalApprove(PurchaseOrderFinalApproveCmd purchaseOrderFinalApproveCmd) {
		purchaseOrderFinalApproveCmdExe.execute(purchaseOrderFinalApproveCmd);
	}

	@Override
	public void rejectFinal(PurchaseOrderRejectFinalCmd purchaseOrderRejectFinalCmd) {
		purchaseOrderRejectFinalCmdExe.execute(purchaseOrderRejectFinalCmd);
	}

	@Override
	public Long countPurchaseOrderByState(PurchaseOrderCountQry purchaseOrderCountQry) {
		return purchaseOrderCountQryExe.execute(purchaseOrderCountQry);
	}

	// 新增分步提交方法
	@Override
	public PurchaseOrderVO saveStep1(PurchaseOrderStep1Cmd purchaseOrderStep1Cmd) {
		return purchaseOrderStep1CmdExe.execute(purchaseOrderStep1Cmd);
	}

	@Override
	public void saveStep2(PurchaseOrderStep2Cmd purchaseOrderStep2Cmd) {
		purchaseOrderStep2CmdExe.execute(purchaseOrderStep2Cmd);
	}

	@Override
	public void saveStep3(PurchaseOrderStep3Cmd purchaseOrderStep3Cmd) {
		purchaseOrderStep3CmdExe.execute(purchaseOrderStep3Cmd);
	}

	@Override
	public String getLastVehicleNo(LastVehicleNoQry lastVehicleNoQry) {
		return lastVehicleNoQryExe.execute(lastVehicleNoQry);
	}
}
