package cn.iocoder.yudao.module.order.service.orderWarehouseApproval;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.service.IService;
import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import cn.iocoder.yudao.module.bpm.enums.WorkFlowEmus;
import cn.iocoder.yudao.module.order.dal.dataobject.orderWarehouseApproval.OrderWarehouseApprovalDO;
import cn.iocoder.yudao.module.order.vo.orderWarehouseAdjust.OrderWarehouseAdjustLastStatusBackVO;
import cn.iocoder.yudao.module.order.vo.orderWarehouseApproval.OrderWarehouseApprovalBackVO;
import cn.iocoder.yudao.module.order.vo.orderWarehouseApproval.OrderWarehouseApprovalCreateReqVO;
import cn.iocoder.yudao.module.order.vo.orderWarehouseApproval.OrderWarehouseApprovalQueryVO;
import cn.iocoder.yudao.module.order.vo.orderWarehouseApproval.OrderWarehouseApprovalUpdateReqVO;

import javax.validation.Valid;
import java.util.Collection;
import java.util.List;

/**
 * 入仓单审核 Service 接口
 *
 * @author yanghao
 */
public interface OrderWarehouseApprovalService extends IService<OrderWarehouseApprovalDO> {

    /**
     * 创建入仓单审核
     *
     * @param createReqVO 创建信息
     * @return 编号
     */
    Long createOrderWarehouseApproval(@Valid OrderWarehouseApprovalCreateReqVO createReqVO);


    /**
     * 是否批量调仓申请
     *
     * @param orderId
     * @param lang
     * @return
     */
    OrderWarehouseAdjustLastStatusBackVO adjustLastWithStatus(Long orderId, Integer lang);


    /**
     * 根据类型和bizId查询审批单
     *
     * @param type     审批类型
     * @param orderId 业务id
     * @return
     */
    OrderWarehouseApprovalDO selectOne(Integer type, Long orderId);


    /**
     * 创建审核并发起审批流程
     *
     * @param orderWarehouseApprovalDO 审批请求对象
     * @param workFlowEmus             审批类型
     * @param copyUserId
     * @return
     */
    Long applyAndCreate(OrderWarehouseApprovalDO orderWarehouseApprovalDO, WorkFlowEmus workFlowEmus, String[] copyUserId);

    /**
     * 取消审核流程
     * @param orderWarehouseApprovalDO 流程审核单
     * @param reason 取消原因
     */
    void cancelApplyAndUpdate(OrderWarehouseApprovalDO orderWarehouseApprovalDO, String reason);


    /**
     * 取消审核
     * @param orderApprovalId 审核id
     * @param reason 取消原因
     */
    void cancelOrderWarehouseApproval(Long orderApprovalId, String reason);

    /**
     * 更新入仓单审核
     *
     * @param updateReqVO 更新信息
     */
    void updateOrderWarehouseApproval(@Valid OrderWarehouseApprovalUpdateReqVO updateReqVO);

    /**
     * 更新入仓单审核
     *
     * @param orderWarehouseApprovalDO
     * @param result                   结果
     */
    void callbackUpdate(OrderWarehouseApprovalDO orderWarehouseApprovalDO, Integer result);

    /**
     * 删除入仓单审核
     *
     * @param id 编号
     */
    void deleteOrderWarehouseApproval(Long id);

    /**
     * 获得入仓单审核
     *
     * @param id 编号
     * @return 入仓单审核
     */
    OrderWarehouseApprovalDO getOrderWarehouseApproval(Long id);



    /**
     * 获得入仓单审核
     *
     * @param formId 审核表单 id
     * @return 入仓单审核
     */
    OrderWarehouseApprovalDO getOrderWarehouseApproval(String formId);

    /**
     * 获得入仓单审核列表
     *
     * @param ids 编号
     * @return 入仓单审核列表
     */
    List<OrderWarehouseApprovalDO> getOrderWarehouseApprovalList(Collection<Long> ids);

    /**
     * 获得入仓单审核分页
     *
     * @param page  分页查询
     * @param query 查询
     * @return 入仓单审核分页
     */
    PageResult<OrderWarehouseApprovalDO> getOrderWarehouseApprovalPage(OrderWarehouseApprovalQueryVO query, PageVO page);

    /**
     * 获得入仓单审核列表, 用于 Excel 导出
     *
     * @param query 查询
     * @return 入仓单审核列表
     */
    List<OrderWarehouseApprovalDO> getOrderWarehouseApprovalList(OrderWarehouseApprovalQueryVO query);

    /**
     * 根据orderItemId查询入仓修改申请
     *
     * @param formId
     * @return
     */
    OrderWarehouseApprovalBackVO getUpdateApprovalInfo(String formId);

    /**
     * 根据orderItemId查询调仓申请
     *
     * @param formId
     * @return
     */
    OrderWarehouseApprovalBackVO getAdjustApprovalInfo(Long formId);


    /**
     * 获取最近的一条入仓修改审核信息
     * @param orderId 订单id
     * @param orderItemId 订单项id
     * @return
     */
    OrderWarehouseApprovalBackVO getLastUpdateApprovalInfo(Long orderId, Long orderItemId);




}
