package com.bonus.sgzb.app.mapper;

import com.bonus.sgzb.app.domain.LeaseApplyDetails;
import com.bonus.sgzb.app.domain.TmTask;
import com.bonus.sgzb.base.api.domain.LeaseOutDetails;
import com.bonus.sgzb.base.api.domain.MaType;
import com.bonus.sgzb.base.api.domain.MachinePart;
import com.bonus.sgzb.base.api.domain.SltAgreementInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * Description:
 *
 * @Author 阮世耀
 * @Create 2023/12/17 15:10
 * @Version 1.0
 */

@Mapper
public interface LeaseOutDetailsMapper {

    /** 查询出库详情 */
    List<LeaseOutDetails> selectListByParentId(String parentId);

    /**
     * 领料出库列表
     * @param bean 参数
     * @return 列表
     */
    List<LeaseOutDetails> leaseOutRecordList(LeaseOutDetails bean);

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

    /** 插入领料出库详细表 */
    int insert(LeaseOutDetails record);

    /** 插入领料出库详情表 -- 根据字段选择注入 */
    int insertSelective(LeaseOutDetails record);

    /**
     * 减少 (ma_type 设备规格表)的库存数量
     */
    int updateMaTypeStockNum(@Param("record") LeaseOutDetails leaseOutDetails);

    /**
     * 修改机具设备(ma_machine表)的状态为：在用
     */
    int updateMaMachineStatus(@Param("record") LeaseOutDetails leaseOutDetails);

    /**
     * 插入(tm_task_agreement 任务协议表)协议信息
     */
    int insertAgreementInfo(@Param("record") LeaseOutDetails leaseOutDetails);

    String getTaskId(Integer parentId);

    int updateTaskStatus(@Param("taskId") String taskId,@Param("status")int status);

    String getMachineStatus(LeaseOutDetails record);

    /**
     * 综合查询--领用记录查询
     * @param bean
     * @return List<LeaseApplyDetails>
     */
    List<LeaseApplyDetails> leaseOutRecord(LeaseApplyDetails bean);

    /**
     * 综合查询--工程在用查询
     * @param bean
     * @return List<LeaseApplyDetails>
     */
    List<LeaseApplyDetails> proUseRecord(LeaseApplyDetails bean);

    String getAgreementId(String taskId);

    MaType getMaType(Integer typeId);

    String getProtocol(String agreementId);

    int insSltInfo(@Param("record") LeaseOutDetails record, @Param("agreementId")String agreementId,@Param("ma") MaType ma);

    SltAgreementInfo getSltAgreementInfo(LeaseOutDetails record);

    int updSltInfo(SltAgreementInfo sltAgreementInfo);

    MaType selectByTypeId(@Param("record") LeaseOutDetails record);

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

    LeaseApplyDetails getOutboundNum(LeaseOutDetails record);

    List<TmTask> getMaTypeDetails(LeaseOutDetails record);

    MachinePart getMachineParts(TmTask typeId);

    int updateMaTypeStockNumCt(TmTask record);

    int getmaChineByCt(LeaseOutDetails record);

    void updateMaTypeNum(LeaseApplyDetails leaseApplyDetails);

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

    int updateLeaseApplyDetails(@Param("record") LeaseOutDetails record);
}
