package com.bonus.material.lease.mapper;

import java.util.List;
import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
import com.bonus.common.biz.domain.lease.LeaseConfirmSign;
import com.bonus.common.biz.domain.lease.LeaseOutDetails;
import com.bonus.common.biz.domain.lease.LeaseOutSign;
import com.bonus.material.lease.domain.LeaseApplyDetails;
import org.apache.ibatis.annotations.Param;

/**
 * 领料任务Mapper接口
 *
 * @author xsheng
 * @date 2024-10-16
 */
public interface LeaseApplyInfoMapper {
    /**
     * 查询领料任务
     *
     * @param leaseApplyInfo
     * @return 领料任务
     */
    LeaseApplyInfo selectLeaseApplyInfoById(LeaseApplyInfo leaseApplyInfo);

    /**
     * 查询领料任务列表
     *
     * @param leaseApplyInfo 领料任务
     * @return 领料任务集合
     */
    List<LeaseApplyInfo> selectLeaseApplyInfoList(LeaseApplyInfo leaseApplyInfo);

    /**
     * 新增领料任务
     *
     * @param leaseApplyInfo 领料任务
     * @return 结果
     */
    int insertLeaseApplyInfo(LeaseApplyInfo leaseApplyInfo);

    /**
     * 修改领料任务
     *
     * @param leaseApplyInfo 领料任务
     * @return 结果
     */
    int updateLeaseApplyInfo(LeaseApplyInfo leaseApplyInfo);

    /**
     * 领料任务电子签名
     */
    int updateLeaseApplyInfoSign(LeaseApplyInfo leaseApplyInfo);

    /**
     * 材料员确认

     * @return
     */
    int confirmLeaseTask(LeaseApplyDetails details);

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

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

    /**
     * 查询领料任务的单位类型是否是班组
     * @param leaseId 领料任务id
     * @return 领料单位类型
     */
    Long selectLeaseApplyInfoIsTeam(Long leaseId);

    /**
     * 根据单位id查询单位类型
     */
    Long selectUnitTypeByUnitId(Long unitId);

    /**
     * 查询领料任务的单位ID
     * @param leaseId 领料任务id
     * @return 单位ID
     */
    Long selectLeaseApplyInfoUnitIdByLeaseId(Long leaseId);

    /**
     * 根据班组ID和工程ID查询挂靠的项目部的协议id
     * @param teamId 班组单位id
     * @param projectId 工程id
     * @return 挂靠的项目部协议id
     */
    LeaseOutDetails selectProjectUnitAgreementIdByTeamAndProject(@Param("teamId") Integer teamId, @Param("projectId") Integer projectId);

    String getTaskId(Long parentId);

    /** 设置审批人为默认的董班长 --防止代码冲突 **/
    Long getDirectAuditBy();

    /** 设置审批人签名url  防止代码冲突  **/
    String getDirectAuditUrl(LeaseApplyInfo leaseApplyInfo);

    /** 设置发料单位  防止代码冲突  **/
    String getSendUnit(LeaseApplyInfo leaseApplyInfo);

    /**
     * 查询领用出库数据
     * @param leaseApplyInfo
     * @return
     */
    List<LeaseApplyInfo> selectPublishList(LeaseApplyInfo leaseApplyInfo);

    /**
     * 查询领料单的领料单出库签名
     * @param id
     * @return
     */
    List<LeaseOutSign> selectLeaseApplyOutList(Long id);

    /**
     * 修改领用发布签名
     * @param leaseApplyInfo
     * @return
     */
    int updateLeasePublishInfoSign(LeaseApplyInfo leaseApplyInfo);

    /**
     * 新增领用发布签名
     * @param leaseApplyInfo
     * @return
     */
    int insertLeaseSign(LeaseApplyInfo leaseApplyInfo);

    /**
     * 查询未签名的领用单
     * @param leaseApplyInfo
     * @return
     */
    List<LeaseApplyInfo> selectNoSignList(LeaseApplyInfo leaseApplyInfo);

    List<LeaseApplyInfo> selectCompleteOutList(LeaseApplyInfo leaseApplyInfo);

    int checkPermission(@Param("externalId") String externalId,@Param("username") String username);

    List<LeaseApplyDetails> selectOutDetailsList(LeaseApplyInfo leaseApplyInfo);

    int updateLeaseApplyInfoConfirm(Long id);

    LeaseApplyInfo getLeaseInfoById(LeaseApplyInfo bean);

    List<LeaseApplyDetails> getDetailsLeaseList(LeaseApplyDetails bean);

    LeaseConfirmSign getLeaseConfirmSign(LeaseApplyDetails bean);

    /**
     * 首先根据用户名去ma_type_manage表查询是否存在绑定物资信息
     * @param userId
     * @return
     */
    List<Long> selectTypeIdList(Long userId);

    /**
     * 查询领用单的领用单出库签名
     * @param id
     * @return
     */
    List<LeaseOutSign> selectOutList(@Param("id") Long id, @Param("leaseSignId") String leaseSignId);

    /**
     * 查询领用单的领用单出库签名
     * @param leaseApplyInfo
     * @return
     */
    LeaseApplyInfo selectLeaseApplyInfoPublishList(LeaseApplyInfo leaseApplyInfo);

    /**
     * 领用数据查询
     * @param leaseApplyInfo
     * @return
     */
    List<LeaseApplyInfo> selectLeaseOutList(LeaseApplyInfo leaseApplyInfo);

    /**
     * 领用数据查询
     * @param leaseApplyInfo
     * @return
     */
    List<LeaseApplyInfo> selectPublish(LeaseApplyInfo leaseApplyInfo);

    List<LeaseApplyInfo> getUserList(LeaseApplyInfo leaseApplyInfo);

    LeaseApplyInfo getUserPhoneById(LeaseApplyInfo item);

    LeaseApplyInfo getOutList(LeaseApplyInfo applyInfo);

    /**
     * 统计时间段出库总数量
     * @param leaseApplyInfo
     * @return
     */
    LeaseApplyInfo getOutNum(LeaseApplyInfo leaseApplyInfo);

    /**
     * 根据id去查询确认总出库数量
     * @param applyInfo
     * @return
     */
    LeaseApplyInfo getInfoList(LeaseApplyInfo applyInfo);

    /**
     * 查询是否存在出库数据
     * @param id
     * @return
     */
    List<LeaseApplyDetails> selectInfo(Long id);

    /**
     * 修改领用单的领用单出库数量
     * @param leaseApplyDetails
     * @return
     */
    int updateLeaseNum(LeaseApplyDetails leaseApplyDetails);

    /**
     * 修改领用单的领用单出库数量
     * @param leaseApplyDetails
     * @return
     */
    int updateLeaseNumTwo(LeaseApplyDetails leaseApplyDetails);

    /**
     * 查询领用单的领用单出库数量
     * @param leaseApplyDetails
     * @return
     */
    LeaseApplyDetails getPublishNum(LeaseApplyDetails leaseApplyDetails);

    /**
     * 修改领用单的领用单出库数量
     * @param leaseApplyDetails
     * @return
     */
    int updateLeasePublish(LeaseApplyDetails leaseApplyDetails);
}
