package com.ktg.iscs.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ktg.common.mapper.BaseMapperX;
import com.ktg.iscs.domain.IsJobTicket;
import com.ktg.iscs.domain.dto.ticket.PageTicketDTO;
import com.ktg.iscs.domain.vo.ticket.JobTicketDetailVO;
import com.ktg.iscs.domain.vo.ticket.MonitorTicketPageVO;
import com.ktg.iscs.domain.vo.ticket.PageTicketVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 作业票Mapper接口
 *
 * @author cgj
 * @date 2024-10-18
 */
@Mapper
public interface IsJobTicketMapper extends BaseMapperX<IsJobTicket>
{
    /**
     * 查询作业票
     *
     * @param ticketId 作业票主键
     * @return 作业票
     */
    IsJobTicket selectIsJobTicketByTicketId(Long ticketId);

    /**
     * 查询作业票列表
     *
     * @param isJobTicket 作业票
     * @return 作业票集合
     */
    List<IsJobTicket> selectIsJobTicketList(IsJobTicket isJobTicket);

    /**
     * 新增作业票
     *
     * @param isJobTicket 作业票
     * @return 结果
     */
    int insertIsJobTicket(IsJobTicket isJobTicket);

    /**
     * 修改作业票
     *
     * @param isJobTicket 作业票
     * @return 结果
     */
    int updateIsJobTicket(IsJobTicket isJobTicket);

    /**
     * 删除作业票
     *
     * @param ticketId 作业票主键
     * @return 结果
     */
    int deleteIsJobTicketByTicketId(Long ticketId);

    /**
     * 批量删除作业票
     *
     * @param ticketIds 需要删除的数据主键集合
     * @return 结果
     */
    int deleteIsJobTicketByTicketIds(Long[] ticketIds);

    Page<PageTicketVO> getIsJobTicketPage(Page<IsJobTicket> page, @Param(value = "dto") PageTicketDTO dto);

    Page<MonitorTicketPageVO> getMonitorJobTicketPage(Page<IsJobTicket> page, @Param(value = "dto") PageTicketDTO dto);

    List<IsJobTicket> getTicketListByAttrValue(@Param(value = "userId") Long userId);


    /**
     * 上锁取钥匙后未归还的重复点位作业票干扰
     * @param pointIds
     * @return
     */
    List<JobTicketDetailVO> selectConflictTicket1(@Param(value = "pointIds") List<Long> pointIds, @Param(value = "ticketId") Long ticketId);

    /**
     * 上锁取钥匙后已归还
     * @param pointIds
     * @return
     */
    List<JobTicketDetailVO> selectConflictTicket2(@Param(value = "pointIds") List<Long> pointIds, @Param(value = "ticketId") Long ticketId);


}
