package com.ktg.iscs.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ktg.iscs.domain.IsMaterialsLoan;
import com.ktg.iscs.domain.dto.materialsLoan.AddLoanDTO;
import com.ktg.iscs.domain.dto.materialsLoan.MaterialsLoanPageDTO;
import com.ktg.iscs.domain.dto.materialsLoan.ReminderPageDTO;
import com.ktg.iscs.domain.dto.materialsLoan.ReturnLoanDTO;
import com.ktg.iscs.domain.vo.materialsLoan.MaterialsLoanPageVO;
import com.ktg.iscs.domain.vo.materialsLoan.ReminderPageVO;

import java.util.List;

/**
 * 物资借出Service接口
 *
 * @author cgj
 * @date 2024-11-08
 */
public interface IIsMaterialsLoanService extends IService<IsMaterialsLoan>
{
    /**
     * 查询物资借出
     *
     * @param materialsLoanId 物资借出主键
     * @return 物资借出
     */
    IsMaterialsLoan selectIsMaterialsLoanByMaterialsLoanId(Long materialsLoanId);

    /**
     * 查询物资借出列表
     *
     * @param isMaterialsLoan 物资借出
     * @return 物资借出集合
     */
    List<IsMaterialsLoan> selectIsMaterialsLoanList(IsMaterialsLoan isMaterialsLoan);

    /**
     * 新增物资借出
     *
     * @param dto 物资借出
     * @return 结果
     */
    int insertIsMaterialsLoan(AddLoanDTO dto) throws Exception;

    /**
     * 修改物资借出
     *
     * @param isMaterialsLoan 物资借出
     * @return 结果
     */
    int updateIsMaterialsLoan(IsMaterialsLoan isMaterialsLoan);

    /**
     * 批量删除物资借出
     *
     * @param materialsLoanIds 需要删除的物资借出主键集合
     * @return 结果
     */
    int deleteIsMaterialsLoanByMaterialsLoanIds(String materialsLoanIds);

    /**
     * 删除物资借出信息
     *
     * @param materialsLoanId 物资借出主键
     * @return 结果
     */
    int deleteIsMaterialsLoanByMaterialsLoanId(Long materialsLoanId);

    Page<MaterialsLoanPageVO> getIsMaterialsLoanPage(Page<IsMaterialsLoan> page, MaterialsLoanPageDTO dto);

    /**
     * 物资归还
     * @param dto
     * @return
     */
    Boolean returnIsMaterialsLoan(ReturnLoanDTO dto);

    /**
     * 归还提醒
     * @param page
     * @param dto
     * @return
     */
    Page<ReminderPageVO> getReturnReminderPage(Page<IsMaterialsLoan> page, ReminderPageDTO dto);

    /**
     * 过期提醒
     * @param page
     * @param dto
     * @return
     */
    Page<ReminderPageVO> getExpiredReminderPage(Page<IsMaterialsLoan> page, ReminderPageDTO dto);

    /**
     * 根据物资id获取物资的最近一条未归还的借取记录
     * @param materialsIdList 物资id
     * @return
     */
    List<Long> getLastLoanRecord(List<Long> materialsIdList);

}
