package com.bonus.sgzb.app.mapper;

import com.bonus.sgzb.app.domain.LeaseApplyDetails;
import com.bonus.sgzb.app.domain.LeaseApplyInfo;
import com.bonus.sgzb.app.domain.TmTask;
import com.bonus.sgzb.base.api.domain.BackApplyInfo;
import com.bonus.sgzb.base.api.domain.MachinePart;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

/**
* Description:
* @Author 阮世耀
* @Create 2023/12/13 15:14
* @Version 1.0
*/

@Mapper
public interface TmTaskMapper {

    /**
     * 获取领料审核列表 by_TmTask
     * @param record 筛选条件
     * @return TmTask列表
     */
    List<TmTask> getAuditListByLeaseTmTask(@Param("record") TmTask record);

    List<TmTask> getAuditListByLeaseTmTaskByPeople(@Param("record") TmTask record);

    List<TmTask> getAuditManageListByLeaseTmTask(@Param("record") TmTask record);

    List<LeaseApplyInfo> getAuditListByLeaseInfo(@Param("record") TmTask record);
    List<LeaseApplyInfo> getAuditManageListByLeaseInfo(@Param("record") TmTask record);

    List<LeaseApplyDetails> getLeaseApplyDetails(@Param("record") LeaseApplyInfo record);
    List<LeaseApplyDetails> getLeaseApplyManageDetails(@Param("record") LeaseApplyInfo record);

    /** 更新TmTask审批状态 */
    int updateTmTaskAuditStatus(@Param("record") TmTask record);

    /** 更新LeaseApplyInfo审批信息 */
    int updateLeaseApplyInfoAuditInfo(@Param("record") LeaseApplyInfo record);

    List<LeaseApplyInfo> getLeaseApplyInfo(Integer taskId);

    /** 更新LeaseApplyInfo驳回信息 */
    int updateLeaseApplyInfoRejectInfo(@Param("record") LeaseApplyInfo record);

    /** 更新leaseApplyDetails审批信息 */
    int updateLeaseApplyDetailsAuditInfo(@Param("record") LeaseApplyDetails record);

    /** 更新leaseApplyDetails驳回信息 */
    int updateLeaseApplyDetailsRejectInfo(@Param("record") LeaseApplyDetails record);

    int deleteTaskByPrimaryKey(String taskId);

    int deleteTaskInfoByTaskId(String taskId);

    int deleteDetailsByTaskId(@Param("id") String id);

    int deleteDetailsByParentId(String parentId);

    int insert(TmTask record);

    int insertOrUpdate(TmTask record);

    int insertOrUpdateSelective(TmTask record);

    int insertSelective(TmTask record);

    TmTask selectByPrimaryKey(Long taskId);

    /**
     * 修改Tm_task任务表
     * @param record 参数对象
     * @return 结果
     */
    int updateByPrimaryKeySelective(TmTask record);

    int updateByPrimaryKey(TmTask record);

    int updateBatch(List<TmTask> list);

    int updateBatchSelective(List<TmTask> list);

    int batchInsert(@Param("list") List<TmTask> list);

    int insertAgreement(TmTask record);

    int updateAgreementByTask(TmTask record);

    int selectNumByMonth(Date nowDate);

    TmTask getLeaseListTmTask(TmTask task);

    Integer getAgreementIdByUnit(TmTask task);
    List<LeaseApplyInfo> getLeaseListByLeaseInfo(TmTask task);
    List<LeaseApplyDetails> getLeaseApplyDetailsByApply(@Param("record") LeaseApplyInfo record);

    void updateLeaseInfo(LeaseApplyInfo task);

    List<LeaseApplyInfo> getListSome(Long taskId);

    LeaseApplyInfo getListSomeol(LeaseApplyInfo info);

    Integer getKgByMaType(Integer typeId);

    List<LeaseApplyDetails> getLeaseApplyDetailsCq(@Param("record") LeaseApplyInfo leaseApplyInfo);

    List<TmTask> getLeaseOutListByUser(TmTask task);

    List<TmTask> getLeaseDetailByParentId(TmTask record);

    List<TmTask> getMaTypeDetails(LeaseApplyDetails leaseApplyDetails);

    MachinePart getMachineParts(TmTask typeId);

    List<TmTask> getMaTypeDetailsByTypeId(BackApplyInfo backApplyInfo);

    List<TmTask> getManageTypeByTypeId(TmTask tmTask);

    int getCountMachine(BackApplyInfo record);

    int getCountMachineByPidAndTid(MachinePart machinePart);

    /**
     * 获取任务编号
     *
     * @param nowDate
     * @param taskType
     * @return
     */
    String selectTaskNumByMonths(@Param("date") Date nowDate, @Param("taskType") Integer taskType);

    /**
     * 根据任务id删除任务协议关联表
     * @param taskId
     * @return
     */
    int deleteTaskAgreementByTaskId(@Param("taskId") String taskId);

    int updateLeaseApplyInfoRejectInfoCq(@Param("record") LeaseApplyInfo leaseApplyInfo);

    int updateLeaseApplyInfoAuditInfoCq(@Param("record") LeaseApplyInfo leaseApplyInfo);
}