package com.jwipc.order.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jwipc.order.entity.PurchaseOrderDetail;
import com.jwipc.order.model.po.PurchaseOrderDetailPO;
import com.jwipc.order.model.query.PurchaseOrderDetailQuery;
import com.jwipc.order.model.query.PurchaseOrderDetailsQuery;
import org.apache.ibatis.annotations.Param;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

/**
 * <p>
 * 采购订单明细 Mapper 接口
 * </p>
 *
 * @author zhangjie
 * @since 2024-03-05
 */
public interface PurchaseOrderDetailMapper extends BaseMapper<PurchaseOrderDetail> {

    List<PurchaseOrderDetailPO> findList(Page<PurchaseOrderDetailPO> page, @Param("q") PurchaseOrderDetailQuery query);
    List<PurchaseOrderDetailPO> findDetails(Page<PurchaseOrderDetailPO> page, @Param("q") PurchaseOrderDetailsQuery query);

    List<PurchaseOrderDetailPO> findListUnlockForDeliveryCreate(@Param("ids") List<String> ids);

    List<PurchaseOrderDetailPO> findList(@Param("q") PurchaseOrderDetailQuery query);

    PurchaseOrderDetail findForMark(@Param("status") Set<Integer> poStatus,
                                    @Param("orderCode") String orderCode,
                                    @Param("orderRow") String orderRow);

    List<PurchaseOrderDetail> findForVerCount(@Param("materialCode") String materialCode, @Param("status") Set<Integer> poStatus,@Param("factoryCode") String factoryCode);

    Long findCountForPage(@Param("q")PurchaseOrderDetailQuery query);

    /**
     * 查询数据
     * @param query
     * @return
     */
    List<PurchaseOrderDetail> getPurchaseOrderDetailListByList(@Param("query") List<PurchaseOrderDetail> query);

    List<PurchaseOrderDetail> findByMaterialCodeAndFactoryWithStatus(@Param("materialCode") String materialCode,
                                                                     @Param("factory") String factory,
                                                                     @Param("status") ArrayList<Integer> status,
                                                                     @Param("delFlag") int delFlag,@Param("type") String type);

    List<PurchaseOrderDetailPO> findNumByMaterialCodeList();
    List<PurchaseOrderDetailPO> findNumByMaterialCodeList1(String productCode);

    String findNewestForShortagePlan(@Param("material") String matnr,@Param("factory") String werks);

    List<PurchaseOrderDetail> findBysupplierCodeAndFactoryCode(@Param("supplierCode")String supplierCode,  @Param("factoryCode") String factoryCode,@Param("orderCode")String orderCode);
}
