package com.bonus.material.lease.mapper;

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

import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
import com.bonus.material.back.domain.vo.MaCodeVo;
import com.bonus.material.basic.domain.BmQrcodeInfo;
import com.bonus.material.lease.domain.LeaseApplyDetails;
import com.bonus.common.biz.domain.lease.LeaseOutDetails;
import com.bonus.material.lease.domain.vo.LeaseOutVo;
import org.apache.ibatis.annotations.Param;

/**
 * 领料任务详细Mapper接口
 * 
 * @author xsheng
 * @date 2024-10-16
 */
public interface LeaseApplyDetailsMapper {
    /**
     * 查询领料任务详细
     * 
     * @param id 领料任务详细主键
     * @return 领料任务详细
     */
    LeaseApplyDetails selectLeaseApplyDetailsById(Long id);

    /**
     * 查询领料任务详细列表
     * 
     * @param leaseApplyDetails 领料任务详细
     * @return 领料任务详细集合
     */
    List<LeaseApplyDetails> selectLeaseApplyDetailsList(LeaseApplyDetails leaseApplyDetails);

    /**
     * 新增领料任务详细
     * 
     * @param leaseApplyDetails 领料任务详细
     * @return 结果
     */
    int insertLeaseApplyDetails(LeaseApplyDetails leaseApplyDetails);

    int insertLeaseApplyDetailsList(List<LeaseApplyDetails> leaseApplyDetails);

    /**
     * 修改领料任务详细
     * 
     * @param leaseApplyDetails 领料任务详细
     * @return 结果
     */
    int updateLeaseApplyDetails(LeaseApplyDetails leaseApplyDetails);

    /**
     * 删除领料任务详细
     * 
     * @param id 领料任务详细主键
     * @return 结果
     */
    int deleteLeaseApplyDetailsById(Long id);

    /**
     * 批量删除领料任务详细
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    int deleteLeaseApplyDetailsByIds(Long[] ids);

    int deleteLeaseApplyDetailsByParentIds(Long[] ids);

    List<LeaseApplyDetails> getByParentId(Long parentId);

    /**
     * 修改 （lease_apply_details 领料任务详细表）的已领数量
     */
    int updateLeaseApplyDetailsOutNum(@Param("record") LeaseOutDetails leaseOutDetails);

    LeaseApplyDetails getLeaseApplyDetails(@Param("record") LeaseOutDetails record);

    int updateLeaseApplyDetailsByLeaseOutRecord(@Param("record") LeaseOutDetails record);

    LeaseApplyDetails getOutboundNum(LeaseOutDetails record);

    String selectMaTypeNameByParentId(Long parentId);

    /**
     * 根据qrcode查询在库机具信息
     * @param bmQrcodeInfo
     * @return
     */
    List<LeaseOutDetails> getInfoByQrcode(BmQrcodeInfo bmQrcodeInfo);

    /**
     * 根据领料任务id查询机具信息
     * @param id
     * @param typeId
     * @return
     */
    List<MaCodeVo> getCodeList(@Param("id") Long id, @Param("typeId") Long typeId);

    /**
     * 批量获取编码详情，优化N+1查询问题
     * @param id 申请ID
     * @param typeIds 类型ID列表
     * @return 编码详情列表
     */
    List<MaCodeVo> getCodeListBatch(@Param("id") Long id, @Param("typeIds") List<Long> typeIds);

    /**
     * 获取领料出库单详情
     * @param leaseApplyInfo
     * @return
     */
    List<LeaseOutVo> selectLeaseOutDetailsList(LeaseApplyInfo leaseApplyInfo);

    /**
     * 根据领料任务id查询领料任务详细
     * @param leaseApplyDetails
     * @return
     */
    LeaseApplyDetails getInnerById(LeaseApplyDetails leaseApplyDetails);

    /**
     * 根据领料任务id查询领料任务详细
     * @param leaseApplyDetails
     * @return
     */
    List<LeaseApplyDetails> getDetailsById(LeaseApplyDetails leaseApplyDetails);

    /**
     * 领料退回
     * @param leaseOutDetails
     * @return
     */
    int updateBackDetailsOutNum(LeaseOutDetails leaseOutDetails);

    /**
     * 根据机具id查询领料任务详细
     * @param maId
     * @return
     */
    List<LeaseOutVo> selectByMaId(@Param("maId") Long maId);

    /**
     * 根据领料任务id查询领料任务详细
     * @param leaseApplyInfo
     * @return
     */
    List<LeaseApplyDetails> getDetailsPublish(LeaseApplyInfo leaseApplyInfo);

    /**
     * 根据领料任务id查询领料任务详细
     * @param leaseApplyDetails
     * @return
     */
    LeaseApplyDetails selectInfo(LeaseApplyDetails leaseApplyDetails);

    /**
     * 根据领用任务批次查询领用任务详细
     * @param leaseApplyDetails
     * @return
     */
    List<LeaseApplyDetails> selectPublishDetails(LeaseApplyDetails leaseApplyDetails);

    /**
     * 根据领用任务批次删除领用任务详细
     * @param leaseOutDetails
     * @return
     */
    int deletePublishTask(LeaseOutDetails leaseOutDetails);

    /**
     * 领用修改lease_apply_details
     * @param record
     * @return
     */
    int updateLeaseApplyPublishDetailsOutNum(LeaseApplyDetails record);

    /**
     * 获取领用任务详细
     * @param record
     * @return
     */
    List<LeaseApplyDetails> getLeasePublishApplyDetails(@Param("record") LeaseOutDetails record);

    /**
     * 查询数量设备待出库详情
     * @param leaseOutDetails
     * @return
     */
    LeaseApplyDetails getPendingLeaseApplyDetails(LeaseOutDetails leaseOutDetails);

    /**
     * 查询编码设备待出库详情
     * @param leaseOutDetails
     * @return
     */
    List<LeaseApplyDetails> getPendingCodeLeaseApplyDetails(LeaseOutDetails leaseOutDetails);

    /**
     * 查询待出库详情
     * @param detail
     * @return
     */
    BigDecimal getOutNum(LeaseApplyDetails detail);

    /**
     * 获取领用任务
     * @param record
     * @return
     */
    LeaseApplyDetails getLeasePublishApply(LeaseOutDetails record);

    /**
     * 修改领用任务详细
     * @param bean
     * @return
     */
    int updateLeaseApplyPublishDetails(LeaseApplyDetails bean);

    /**
     * 获取领用任务详细
     * @param leaseOutDetails
     * @return
     */
    List<LeaseApplyDetails> getLeaseMaCode(LeaseOutDetails leaseOutDetails);

    /**
     * 获取待出库数量
     * @param leaseOutDetails
     * @return
     */
    LeaseApplyDetails getPengNum(LeaseOutDetails leaseOutDetails);

    LeaseApplyDetails getPendLease(LeaseOutDetails leaseOutDetails);
}
