package com.zt.plat.module.qms.business.bus.dal.mapper;

import java.util.*;

import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.zt.plat.module.qms.business.bus.controller.vo.*;
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessSubSampleAssessmentDO;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
import org.apache.ibatis.annotations.Mapper;

/**
 * 子样判定业务 Mapper
 *
 * @author 后台管理
 */
@Mapper
public interface BusinessSubSampleAssessmentMapper extends BaseMapperX<BusinessSubSampleAssessmentDO> {

    default PageResult<BusinessSubSampleAssessmentDO> selectPage(BusinessSubSampleAssessmentPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BusinessSubSampleAssessmentDO>()
                .eqIfPresent(BusinessSubSampleAssessmentDO::getBusinessSubParentSampleId, reqVO.getBusinessSubParentSampleId())
                .eqIfPresent(BusinessSubSampleAssessmentDO::getBusinessSubSampleId, reqVO.getBusinessSubSampleId())
                .eqIfPresent(BusinessSubSampleAssessmentDO::getConfigAssayMethodId, reqVO.getConfigAssayMethodId())
                .eqIfPresent(BusinessSubSampleAssessmentDO::getTaskType, reqVO.getTaskType())
                .eqIfPresent(BusinessSubSampleAssessmentDO::getAssayType, reqVO.getAssayType())
                .eqIfPresent(BusinessSubSampleAssessmentDO::getAssessmentStatus, reqVO.getAssessmentStatus())
                .eqIfPresent(BusinessSubSampleAssessmentDO::getRetestCount, reqVO.getRetestCount())
                .eqIfPresent(BusinessSubSampleAssessmentDO::getIsRecheck, reqVO.getIsRecheck())
                .eqIfPresent(BusinessSubSampleAssessmentDO::getIsReported, reqVO.getIsReported())
                .eqIfPresent(BusinessSubSampleAssessmentDO::getReportedStatus, reqVO.getReportedStatus())
                .eqIfPresent(BusinessSubSampleAssessmentDO::getReporter, reqVO.getReporter())
                .betweenIfPresent(BusinessSubSampleAssessmentDO::getReportTime, reqVO.getReportTime())
                .eqIfPresent(BusinessSubSampleAssessmentDO::getReportDescription, reqVO.getReportDescription())
                .eqIfPresent(BusinessSubSampleAssessmentDO::getResultTreatmentWay, reqVO.getResultTreatmentWay())
                .eqIfPresent(BusinessSubSampleAssessmentDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
                .betweenIfPresent(BusinessSubSampleAssessmentDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(BusinessSubSampleAssessmentDO::getUpdateCount, reqVO.getUpdateCount())
                .eqIfPresent(BusinessSubSampleAssessmentDO::getRemark, reqVO.getRemark())
                .orderByDesc(BusinessSubSampleAssessmentDO::getId));
    }
    
    default BusinessSubSampleAssessmentDO selectByBusinessSubParentSampleIdAndConfigAssayMethodId(Long businessSubParentSampleId, Long configAssayMethodId) {
    	return selectOne(new LambdaQueryWrapperX<BusinessSubSampleAssessmentDO>()
    			.eq(BusinessSubSampleAssessmentDO::getBusinessSubParentSampleId, businessSubParentSampleId)
    			.eq(BusinessSubSampleAssessmentDO::getConfigAssayMethodId, configAssayMethodId));
    }
    
    default List<BusinessSubSampleAssessmentDO> selectByBusinessSubParentSampleIdsAndConfigAssayMethodId(List<Long> businessSubParentSampleIds, Long configAssayMethodId) {
    	return selectList(new LambdaQueryWrapperX<BusinessSubSampleAssessmentDO>()
    			.in(BusinessSubSampleAssessmentDO::getBusinessSubParentSampleId, businessSubParentSampleIds)
    			.eq(BusinessSubSampleAssessmentDO::getConfigAssayMethodId, configAssayMethodId));
    }
    
    default BusinessSubSampleAssessmentDO selectByBusinessSubSampleIdAndConfigAssayMethodIdAndRetestCount(Long businessSubSampleId, Long configAssayMethodId, Integer retestCount) {
    	return selectOne(new LambdaQueryWrapperX<BusinessSubSampleAssessmentDO>()
    			.eq(BusinessSubSampleAssessmentDO::getBusinessSubSampleId, businessSubSampleId)
    			.eq(BusinessSubSampleAssessmentDO::getConfigAssayMethodId, configAssayMethodId)
    			.eq(BusinessSubSampleAssessmentDO::getRetestCount, retestCount));
    }
    
    @Deprecated
    default List<BusinessSubSampleAssessmentDO> selectByBusinessSubSampleIdsAndConfigAssayMethodIdAndRetestCount(List<Long> businessSubSampleIds, Long configAssayMethodId, Integer retestCount) {
    	return selectList(new LambdaQueryWrapperX<BusinessSubSampleAssessmentDO>()
    			.in(BusinessSubSampleAssessmentDO::getBusinessSubSampleId, businessSubSampleIds)
    			.eq(BusinessSubSampleAssessmentDO::getConfigAssayMethodId, configAssayMethodId)
    			.eq(BusinessSubSampleAssessmentDO::getRetestCount, retestCount));
    }

}