package com.jwipc.order.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jwipc.order.entity.DeliveryOrderDetail;
import com.jwipc.order.model.po.DeliveryOrderDetailPO;
import com.jwipc.order.model.query.DeliveryOrderDetailQuery;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 送货单明细 服务类
 * </p>
 *
 * @author zhangjie
 * @since 2024-03-06
 */
public interface IDeliveryOrderDetailService extends IService<DeliveryOrderDetail> {

    List<DeliveryOrderDetailPO> findForList(Page<DeliveryOrderDetailPO> orderDetailPOPage,
                                            DeliveryOrderDetailQuery query);

    List<DeliveryOrderDetailPO> findForList(DeliveryOrderDetailQuery query);

    BigDecimal findCountByMaterialCodeAndFactory(String materialCode, String factory, Integer status, int delFlag);

    /**
     * 查询在途数量
     *
     * @param purchaseOrderCode 采购单号
     * @param purchaseOrderRow 采购单行号
     * @param status 发货状态
     * @param delFlag 删除标记
     * @return
     */
    BigDecimal findCountByPurchaseDetail(String purchaseOrderCode, String purchaseOrderRow, int status, int delFlag);

    /**
     * 根据供应商编码和物料编码查询已经送货的数量
     * @param supplierCode
     * @param materialCode
     * @param delFlag
     * @return
     */
    BigDecimal findSendNumBySuplierCodeAndMaterialCode(String effectiveDate, String supplierCode, String materialCode, int delFlag);

    /**
     * 根据发货单ID查询已经生成送货单的送货数量总和
     * @param orderId
     * @return
     */
    BigDecimal findSendNumByOrderId(@Param("orderId") String orderId);
}
