package com.maintain.business.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.maintain.business.domain.ErpMaterial;
import com.maintain.business.domain.ErpMaterialInventoryRecord;
import com.maintain.business.domain.bo.ErpMaterialInventoryRecordBo;
import com.maintain.business.domain.vo.ErpMaterialInventoryRecordVo;
import com.maintain.business.domain.vo.ErpMaterialVo;
import com.maintain.common.core.mapper.BaseMapperPlus;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 物料库存记录Mapper接口
 *
 * @author liushuai
 * @date 2025-07-16
 */
public interface ErpMaterialInventoryRecordMapper extends BaseMapperPlus<ErpMaterialInventoryRecordMapper, ErpMaterialInventoryRecord, ErpMaterialInventoryRecordVo> {


    /**
     * 自定义分页查询
     * @param page
     * @param queryWrapper
     * @return
     */
    Page<ErpMaterialInventoryRecordVo> customQueryPageList(@Param("page") Page<ErpMaterialInventoryRecord> page, @Param(Constants.WRAPPER) Wrapper<ErpMaterialInventoryRecord> queryWrapper);

    /**
     * 自定义查询
     * @param queryWrapper
     * @return
     */
    List<ErpMaterialInventoryRecordVo> customQueryList(@Param(Constants.WRAPPER) Wrapper<ErpMaterialInventoryRecord> queryWrapper);

    /**
     * 自定义分页查询（每一条入库记录运算）
     * @param page
     * @param queryWrapper
     * @return
     */
    Page<ErpMaterialInventoryRecordVo> customQueryPageInventoryList(@Param("page") Page<ErpMaterialInventoryRecord> page, @Param(Constants.WRAPPER) Wrapper<ErpMaterialInventoryRecord> queryWrapper);

    /**
     *
     * @param id
     * @return
     */
    ErpMaterialInventoryRecordVo customQueryInventoryById(@Param("id") Long id);


    /**
     * 查询物料库存列表
     */
    List<ErpMaterialInventoryRecordVo> queryListByWarehouseIdAndMaterialId(@Param("warehouseId") Long warehouseId, @Param("vendorId") Long vendorId, @Param("materialId") Long materialId, @Param("type") String type);


    /**
     * 根据仓库ID\供应商ID\物料ID动态计算物料库存
     */
    ErpMaterialInventoryRecordVo queryMaterialByWarehouseIdAndMaterialId(@Param("warehouseId") Long warehouseId, @Param("vendorId") Long vendorId, @Param("materialId") Long materialId);

}
