package digital.laboratory.platform.imr.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import digital.laboratory.platform.imr.dto.CombinationOut;
import digital.laboratory.platform.imr.entity.InventorySample;
import digital.laboratory.platform.imr.entity.SampleStorage;
import digital.laboratory.platform.imr.vo.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 *  Mapper 接口
 *
 * @author Zhang Xiaolong created at  2023-03-27
 * @describe  Mapper 类
 */
@Mapper
public interface SampleStorageMapper extends BaseMapper<SampleStorage> {



    /**
     * sample_storage表中样本详细信息
     * @param id
     * @return
     */
    RepositorySampleVO getSampleDetailed(String id);


    /**
     * 通过id获取样本信息
     * @param sampleId
     * @return
     */
    OutSampleVO getSampleById(String sampleId);

    /**
     * 通过编号获取样本信息
     * @param sampleNo
     * @return
     */
    OutSampleVO getSampleByNo(String sampleNo);




    /**
     * 通过编号获取样本信息集合
     * @param sampleNo
     * @return
     */
    List<OutSampleVO> getSampleListByNo(String sampleNo);


    /**
     * 待存放样本列表
     * @param
     * @return
     */
    IPage<RepositorySampleVO> getToBeStoredSample(@Param("page") Page<SampleStorage> page,@Param(Constants.WRAPPER)QueryWrapper qw);

    /**
     * 仓库现有样本分页
     * @param page
     * @param qw
     * @return
     */
    IPage<RepositorySampleVO> getSampleVOList(@Param("page") Page<SampleStorage> page,@Param(Constants.WRAPPER) QueryWrapper<SampleStorage> qw);

    /**
     * 查询仓库现有样本；并且状态不在领用中
     * @param page
     * @param notIn
     * @return
     */
    IPage<OutSampleVO> getSampleInfo(@Param("page")Page<SampleStorage> page, @Param(Constants.WRAPPER)QueryWrapper<SampleStorage> qw);
    List<OutSampleVO> getSampleInfoList(@Param(Constants.WRAPPER)QueryWrapper<SampleStorage> qw);


    IPage<BaseSampleVO> getSampleInfoTwo(@Param("page")Page<SampleStorage> page, @Param(Constants.WRAPPER)QueryWrapper<SampleStorage> qw);

    /**
     *  待归还样本id
     * @param page
     * @param updateTime
     * @return
     */
    IPage<ToBeReturnVO> toBeReturned(@Param("page")Page<SampleStorage> page, @Param(Constants.WRAPPER) QueryWrapper<SampleStorage> updateTime);

    /*
    归还详情
     */
    RecipientDTO toBeReturnedDetail(String sampleId);

    /**
     * 创建申请查询样本接口
     * @param samplePage
     * @param ne
     * @return
     */
    IPage<BaseSampleVO> getSampleInfoByHolder(@Param("page") Page<SampleStorage> samplePage,@Param(Constants.WRAPPER) QueryWrapper<SampleStorage> ne);

    IPage<BaseSampleVO> getDestructionSample(@Param("page") Page<SampleStorage> samplePage,@Param(Constants.WRAPPER) QueryWrapper<SampleStorage> ne);

    /**
     * 出库清单数据
     * @param ids
     * @return
     */
    List<InventorySample> getSampleInventory(@Param(Constants.WRAPPER) QueryWrapper<SampleStorage> ne);

    /**
     * 入库查看样本详情
     * @param id
     * @return
     */
    BaseSampleDetail getSampleDetailInfo(String id);





    String getEntrustmentName(@Param("id")String entrustmentId);

    String getHairJobName(@Param("id")String hairJobId);

    String getSewageJobName(@Param("id")String sewageJobId);

    //通用检材受理
    String getEventName(@Param("id")String sampleId);

    String getFeatureName(@Param("id")String sampleId);

    //查询委托方
    String returnOutboundQuery(@Param("id")String sampleId);






    /*------------额外的测试接口*/
    List<OutSampleVO> getWTSample(@Param("dto")CombinationOut combinationOut);

    List<OutSampleVO> getWSSample(@Param("dto")CombinationOut combinationOut);

    List<OutSampleVO> getMFSample(@Param("dto")CombinationOut combinationOut);

    List<OutSampleVO> getSJSample(@Param("dto")CombinationOut combinationOut);


    List<OutSampleVO> getTZSample(@Param("dto")CombinationOut combinationOut);

    Long getTransferCount(String id);

    Long getWitnessCount(String id);


    int queryTransfer(@Param("userId")String userId);

    String getUserName(@Param("userId")String userId);


    List<OutSampleVO> choseSampleList();

    double getQuality(@Param("id")String sampleId);
}