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.MPJLambdaWrapperX;
import com.zt.plat.module.qms.business.bus.controller.vo.BusinessSampleDispatchDetailExtendRespVO;
import com.zt.plat.module.qms.business.bus.controller.vo.BusinessSubSampleExtendRespVO;
import com.zt.plat.module.qms.business.bus.controller.vo.BusinessSubSamplePageReqVO;
import com.zt.plat.module.qms.business.bus.controller.vo.BusinessSubSampleReqVO;
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayTaskDataDO;
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessSubSampleAnalysisGroupDO;
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessSubSampleDO;
import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigSubSampleDO;
import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigWarehouseLocationDO;
import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigWarehouseLocationParDO;
import com.zt.plat.module.qms.common.dic.dal.dataobject.DictionaryBusinessDO;
import com.zt.plat.module.qms.enums.QmsCommonConstant;
import com.zt.plat.module.qms.enums.QmsWarehouseLocationConstant;
import jakarta.validation.Valid;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
import org.apache.ibatis.annotations.Mapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;

/**
 * 子样业务 Mapper
 *
 * @author 后台管理
 */
@Mapper
public interface BusinessSubSampleMapper extends BaseMapperX<BusinessSubSampleDO> {

    default PageResult<BusinessSubSampleExtendRespVO> selectPage(BusinessSubSamplePageReqVO reqVO) {
        return selectJoinPage(reqVO, BusinessSubSampleExtendRespVO.class, new MPJLambdaWrapperX<BusinessSubSampleDO>()
        		.selectSub(BusinessAssayTaskDataDO.class, s -> s.selectCount(BusinessAssayTaskDataDO::getId).eq(BusinessAssayTaskDataDO::getBusinessSubSampleId, BusinessSubSampleDO::getId), BusinessSubSampleExtendRespVO::getAssayTaskCount)
        		.leftJoin(ConfigSubSampleDO.class, ConfigSubSampleDO::getId, BusinessSubSampleDO::getConfigSubSampleId)
        		.leftJoin(DictionaryBusinessDO.class, DictionaryBusinessDO::getId, BusinessSubSampleDO::getDictionaryBusinessId)
				//库位
				.leftJoin(ConfigWarehouseLocationDO.class, ConfigWarehouseLocationDO::getId, BusinessSubSampleDO::getConfigWarehouseLocationInfomationId)
				//仓库
				.leftJoin(ConfigWarehouseLocationParDO.class, ConfigWarehouseLocationParDO::getId, ConfigWarehouseLocationDO::getParentId)
        		.selectAll(BusinessSubSampleDO.class)
        		.selectAs(DictionaryBusinessDO::getName, BusinessSubSampleExtendRespVO::getDictionaryBusinessName)
        		.selectAs(ConfigSubSampleDO::getIsPrint, BusinessSubSampleExtendRespVO::getIsPrint)
        		.selectAs(ConfigSubSampleDO::getPrintTemplate, BusinessSubSampleExtendRespVO::getPrintTemplate)
				.selectAs(ConfigWarehouseLocationDO::getCode, BusinessSubSampleExtendRespVO::getWarehouseLocationCode)
				.selectAs(ConfigWarehouseLocationParDO::getName, BusinessSubSampleExtendRespVO::getWarehouseName)
                .eqIfPresent(BusinessSubSampleDO::getBusinessBaseSampleId, reqVO.getBusinessBaseSampleId())
                .eqIfPresent(BusinessSubSampleDO::getBusinessSubParentSampleId, reqVO.getBusinessSubParentSampleId())
                .eqIfPresent(BusinessSubSampleDO::getConfigSubSampleId, reqVO.getConfigSubSampleId())
                .eqIfPresent(BusinessSubSampleDO::getDictionaryBusinessId, reqVO.getDictionaryBusinessId())
                .eqIfPresent(BusinessSubSampleDO::getConfigWarehouseLocationInfomationId, reqVO.getConfigWarehouseLocationInfomationId())
                .eqIfPresent(BusinessSubSampleDO::getSampleId, reqVO.getSampleId())
                .eqIfPresent(BusinessSubSampleDO::getGroupId, reqVO.getGroupId())
                .eqIfPresent(BusinessSubSampleDO::getBatchCode, reqVO.getBatchCode())
                .eqIfPresent(BusinessSubSampleDO::getDualFlag, reqVO.getDualFlag())
                .likeIfPresent(BusinessSubSampleDO::getSampleName, reqVO.getSampleName())
                .eqIfPresent(BusinessSubSampleDO::getSampleCode, reqVO.getSampleCode())
                .eqIfPresent(BusinessSubSampleDO::getSampleAssayCode, reqVO.getSampleAssayCode())
                .eqIfPresent(BusinessSubSampleDO::getSampleReturnCode, reqVO.getSampleReturnCode())
                .eqIfPresent(BusinessSubSampleDO::getIsWeighing, reqVO.getIsWeighing())
                .eqIfPresent(BusinessSubSampleDO::getLastSampleWeight, reqVO.getLastSampleWeight())
                .eqIfPresent(BusinessSubSampleDO::getLastBalanceCode, reqVO.getLastBalanceCode())
                .eqIfPresent(BusinessSubSampleDO::getConfigSampleFlowId, reqVO.getConfigSampleFlowId())
                .eqIfPresent(BusinessSubSampleDO::getSampleFlowNodeKey, reqVO.getSampleFlowNodeKey())
                .inIfPresent(BusinessSubSampleDO::getSampleFlowNodeKey, reqVO.getSampleFlowNodeKeyList())
                .betweenIfPresent(BusinessSubSampleDO::getSampleFlowNodeTime, reqVO.getSampleFlowNodeTime())
                .eqIfPresent(BusinessSubSampleDO::getNextSampleFlowNode, reqVO.getNextSampleFlowNode())
                .eqIfPresent(BusinessSubSampleDO::getIsMaterialAssayStandard, reqVO.getIsMaterialAssayStandard())
                .eqIfPresent(BusinessSubSampleDO::getAssayLevel, reqVO.getAssayLevel())
                .eqIfPresent(BusinessSubSampleDO::getSampleStatus, reqVO.getSampleStatus())
                .eqIfPresent(BusinessSubSampleDO::getAssayOperator, reqVO.getAssayOperator())
                .eqIfPresent(BusinessSubSampleDO::getIsAssignTasked, reqVO.getIsAssignTasked())
                .betweenIfPresent(BusinessSubSampleDO::getAssignTaskTime, reqVO.getAssignTaskTime())
                .eqIfPresent(BusinessSubSampleDO::getIsReported, reqVO.getIsReported())
                .eqIfPresent(BusinessSubSampleDO::getReporter, reqVO.getReporter())
                .betweenIfPresent(BusinessSubSampleDO::getReportTime, reqVO.getReportTime())
                .betweenIfPresent(BusinessSubSampleDO::getReturnTime, reqVO.getReturnTime())
                .eqIfPresent(BusinessSubSampleDO::getReturnStatus, reqVO.getReturnStatus())
				.eqIfPresent(BusinessSubSampleDO::getDispatchStatus, reqVO.getDispatchStatus())
                .eqIfPresent(BusinessSubSampleDO::getReturnCodePrintCount, reqVO.getReturnCodePrintCount())
                .betweenIfPresent(BusinessSubSampleDO::getPrintLastTime, reqVO.getPrintLastTime())
                .eqIfPresent(BusinessSubSampleDO::getUpSampleRecordId, reqVO.getUpSampleRecordId())
                .eqIfPresent(BusinessSubSampleDO::getAnalysisRemark, reqVO.getAnalysisRemark())
                .eqIfPresent(BusinessSubSampleDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
                .betweenIfPresent(BusinessSubSampleDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(BusinessSubSampleDO::getUpdateCount, reqVO.getUpdateCount())
                .eqIfPresent(BusinessSubSampleDO::getRemark, reqVO.getRemark())
                .eqIfPresent(BusinessSubSampleDO::getUpSampleRecordId, reqVO.getUpSampleRecordId())
				.likeIfPresent(ConfigWarehouseLocationDO::getCode, reqVO.getWarehouseLocationCode())
                .orderByDesc(BusinessSubSampleDO::getSampleFlowNodeTime)
                .orderByAsc("NVL(REGEXP_SUBSTR(SMP_CD, '^(.*-)'), SMP_CD)")
                .orderByAsc("CASE WHEN INSTR(SMP_CD, '-') = 0 THEN 0 WHEN REGEXP_LIKE(REGEXP_SUBSTR(SMP_CD, '[^-]+$'), '[^0-9]') THEN 9999999 ELSE CAST(REGEXP_SUBSTR(SMP_CD, '[^-]+$') AS BIGINT) END")
//                .orderByAsc(BusinessSubSampleDO::getSampleCode)
                );
    }

	default PageResult<BusinessSubSampleExtendRespVO> selectAnalysisGroupPage(BusinessSubSamplePageReqVO reqVO) {
		return selectJoinPage(reqVO, BusinessSubSampleExtendRespVO.class, new MPJLambdaWrapperX<BusinessSubSampleDO>()
				.rightJoin(BusinessSubSampleAnalysisGroupDO.class, BusinessSubSampleAnalysisGroupDO::getBusinessSubSampleId, BusinessSubSampleDO::getId)
        		.leftJoin(ConfigSubSampleDO.class, ConfigSubSampleDO::getId, BusinessSubSampleDO::getConfigSubSampleId)
        		.leftJoin(DictionaryBusinessDO.class, DictionaryBusinessDO::getId, BusinessSubSampleDO::getDictionaryBusinessId)
				.leftJoin(ConfigWarehouseLocationDO.class, ConfigWarehouseLocationDO::getCode, ConfigSubSampleDO::getConfigWarehouseLocationCode)
        		.selectAll(BusinessSubSampleDO.class)
        		.selectAs(DictionaryBusinessDO::getName, BusinessSubSampleExtendRespVO::getDictionaryBusinessName)
        		.selectAs(ConfigSubSampleDO::getIsPrint, BusinessSubSampleExtendRespVO::getIsPrint)
        		.selectAs(ConfigSubSampleDO::getPrintTemplate, BusinessSubSampleExtendRespVO::getPrintTemplate)
				.selectAs(BusinessSubSampleAnalysisGroupDO::getAssayDepartmentId, BusinessSubSampleExtendRespVO::getAssayDepartmentId)
				.selectAs(BusinessSubSampleAnalysisGroupDO::getAssayDepartmentName, BusinessSubSampleExtendRespVO::getAssayDepartmentName)
				.selectAs(ConfigWarehouseLocationDO::getCode, BusinessSubSampleExtendRespVO::getWarehouseLocationCode)
				.selectAs(ConfigWarehouseLocationDO::getName, BusinessSubSampleExtendRespVO::getWarehouseName)
                .eqIfPresent(BusinessSubSampleDO::getBusinessBaseSampleId, reqVO.getBusinessBaseSampleId())
                .eqIfPresent(BusinessSubSampleDO::getBusinessSubParentSampleId, reqVO.getBusinessSubParentSampleId())
                .eqIfPresent(BusinessSubSampleDO::getConfigSubSampleId, reqVO.getConfigSubSampleId())
                .eqIfPresent(BusinessSubSampleDO::getDictionaryBusinessId, reqVO.getDictionaryBusinessId())
                .eqIfPresent(BusinessSubSampleDO::getConfigWarehouseLocationInfomationId, reqVO.getConfigWarehouseLocationInfomationId())
                .eqIfPresent(BusinessSubSampleDO::getSampleId, reqVO.getSampleId())
                .eqIfPresent(BusinessSubSampleDO::getGroupId, reqVO.getGroupId())
                .eqIfPresent(BusinessSubSampleDO::getBatchCode, reqVO.getBatchCode())
                .eqIfPresent(BusinessSubSampleDO::getDualFlag, reqVO.getDualFlag())
                .likeIfPresent(BusinessSubSampleDO::getSampleName, reqVO.getSampleName())
                .eqIfPresent(BusinessSubSampleDO::getSampleCode, reqVO.getSampleCode())
                .eqIfPresent(BusinessSubSampleDO::getSampleAssayCode, reqVO.getSampleAssayCode())
                .eqIfPresent(BusinessSubSampleDO::getSampleReturnCode, reqVO.getSampleReturnCode())
                .eqIfPresent(BusinessSubSampleDO::getIsWeighing, reqVO.getIsWeighing())
                .eqIfPresent(BusinessSubSampleDO::getLastSampleWeight, reqVO.getLastSampleWeight())
                .eqIfPresent(BusinessSubSampleDO::getLastBalanceCode, reqVO.getLastBalanceCode())
                .eqIfPresent(BusinessSubSampleDO::getConfigSampleFlowId, reqVO.getConfigSampleFlowId())
                .eqIfPresent(BusinessSubSampleDO::getSampleFlowNodeKey, reqVO.getSampleFlowNodeKey())
                .inIfPresent(BusinessSubSampleDO::getSampleFlowNodeKey, reqVO.getSampleFlowNodeKeyList())
                .betweenIfPresent(BusinessSubSampleDO::getSampleFlowNodeTime, reqVO.getSampleFlowNodeTime())
                .eqIfPresent(BusinessSubSampleDO::getNextSampleFlowNode, reqVO.getNextSampleFlowNode())
                .eqIfPresent(BusinessSubSampleDO::getIsMaterialAssayStandard, reqVO.getIsMaterialAssayStandard())
                .eqIfPresent(BusinessSubSampleDO::getAssayLevel, reqVO.getAssayLevel())
                .eqIfPresent(BusinessSubSampleDO::getSampleStatus, reqVO.getSampleStatus())
                .eqIfPresent(BusinessSubSampleDO::getAssayOperator, reqVO.getAssayOperator())
                .eqIfPresent(BusinessSubSampleDO::getIsAssignTasked, reqVO.getIsAssignTasked())
                .betweenIfPresent(BusinessSubSampleDO::getAssignTaskTime, reqVO.getAssignTaskTime())
                .eqIfPresent(BusinessSubSampleDO::getIsReported, reqVO.getIsReported())
                .eqIfPresent(BusinessSubSampleDO::getReporter, reqVO.getReporter())
                .betweenIfPresent(BusinessSubSampleDO::getReportTime, reqVO.getReportTime())
                .betweenIfPresent(BusinessSubSampleDO::getReturnTime, reqVO.getReturnTime())
                .eqIfPresent(BusinessSubSampleDO::getReturnStatus, reqVO.getReturnStatus())
				.eqIfPresent(BusinessSubSampleDO::getDispatchStatus, reqVO.getDispatchStatus())
                .eqIfPresent(BusinessSubSampleDO::getReturnCodePrintCount, reqVO.getReturnCodePrintCount())
                .betweenIfPresent(BusinessSubSampleDO::getPrintLastTime, reqVO.getPrintLastTime())
                .eqIfPresent(BusinessSubSampleDO::getUpSampleRecordId, reqVO.getUpSampleRecordId())
                .eqIfPresent(BusinessSubSampleDO::getAnalysisRemark, reqVO.getAnalysisRemark())
                .eqIfPresent(BusinessSubSampleDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
                .betweenIfPresent(BusinessSubSampleDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(BusinessSubSampleDO::getUpdateCount, reqVO.getUpdateCount())
                .eqIfPresent(BusinessSubSampleDO::getRemark, reqVO.getRemark())
                .eqIfPresent(BusinessSubSampleDO::getUpSampleRecordId, reqVO.getUpSampleRecordId())
                .eqIfPresent(BusinessSubSampleAnalysisGroupDO::getAssayDepartmentId, reqVO.getAssayDepartmentId())
                .eqIfPresent(BusinessSubSampleAnalysisGroupDO::getAssayDepartmentName, reqVO.getAssayDepartmentName())
                .eqIfPresent(BusinessSubSampleAnalysisGroupDO::getSampleStatus, reqVO.getAssayDepartmentStatus())
                .inIfPresent(BusinessSubSampleAnalysisGroupDO::getSampleStatus, reqVO.getAssayDepartmentStatusList())
                .eqIfPresent(BusinessSubSampleAnalysisGroupDO::getIsSend, reqVO.getIsSendSample())
                .orderByDesc(BusinessSubSampleDO::getSampleFlowNodeTime)
                .orderByAsc("NVL(REGEXP_SUBSTR(SMP_CD, '^(.*-)'), SMP_CD)")
                .orderByAsc("CASE WHEN INSTR(SMP_CD, '-') = 0 THEN 0 WHEN REGEXP_LIKE(REGEXP_SUBSTR(SMP_CD, '[^-]+$'), '[^0-9]') THEN 9999999 ELSE CAST(REGEXP_SUBSTR(SMP_CD, '[^-]+$') AS BIGINT) END")
                //.orderByAsc(BusinessSubSampleDO::getSampleCode)
                );
	}

	default List<BusinessSubSampleExtendRespVO> selectList(@Valid BusinessSubSampleReqVO reqVO) {
		return selectJoinList(BusinessSubSampleExtendRespVO.class, new MPJLambdaWrapperX<BusinessSubSampleDO>()
        		.selectSub(BusinessAssayTaskDataDO.class, s -> s.selectCount(BusinessAssayTaskDataDO::getId).eq(BusinessAssayTaskDataDO::getBusinessSubSampleId, BusinessSubSampleDO::getId), BusinessSubSampleExtendRespVO::getAssayTaskCount)
        		.leftJoin(DictionaryBusinessDO.class, DictionaryBusinessDO::getId, BusinessSubSampleDO::getDictionaryBusinessId)
        		.leftJoin(ConfigSubSampleDO.class, ConfigSubSampleDO::getId, BusinessSubSampleDO::getConfigSubSampleId)
        		.selectAll(BusinessSubSampleDO.class)
        		.selectAs(DictionaryBusinessDO::getName, BusinessSubSampleExtendRespVO::getDictionaryBusinessName)
        		.selectAs(ConfigSubSampleDO::getIsPrint, BusinessSubSampleExtendRespVO::getIsPrint)
        		.selectAs(ConfigSubSampleDO::getPrintTemplate, BusinessSubSampleExtendRespVO::getPrintTemplate)
                .eqIfPresent(BusinessSubSampleDO::getBusinessBaseSampleId, reqVO.getBusinessBaseSampleId())
                .eqIfPresent(BusinessSubSampleDO::getBusinessSubParentSampleId, reqVO.getBusinessSubParentSampleId())
                .eqIfPresent(BusinessSubSampleDO::getConfigSubSampleId, reqVO.getConfigSubSampleId())
                .eqIfPresent(BusinessSubSampleDO::getDictionaryBusinessId, reqVO.getDictionaryBusinessId())
                .eqIfPresent(BusinessSubSampleDO::getConfigWarehouseLocationInfomationId, reqVO.getConfigWarehouseLocationInfomationId())
                .eqIfPresent(BusinessSubSampleDO::getSampleId, reqVO.getSampleId())
                .eqIfPresent(BusinessSubSampleDO::getGroupId, reqVO.getGroupId())
                .eqIfPresent(BusinessSubSampleDO::getBatchCode, reqVO.getBatchCode())
                .eqIfPresent(BusinessSubSampleDO::getDualFlag, reqVO.getDualFlag())
                .likeIfPresent(BusinessSubSampleDO::getSampleName, reqVO.getSampleName())
                .eqIfPresent(BusinessSubSampleDO::getSampleCode, reqVO.getSampleCode())
                .eqIfPresent(BusinessSubSampleDO::getSampleAssayCode, reqVO.getSampleAssayCode())
                .eqIfPresent(BusinessSubSampleDO::getSampleReturnCode, reqVO.getSampleReturnCode())
                .eqIfPresent(BusinessSubSampleDO::getIsWeighing, reqVO.getIsWeighing())
                .eqIfPresent(BusinessSubSampleDO::getLastSampleWeight, reqVO.getLastSampleWeight())
                .eqIfPresent(BusinessSubSampleDO::getLastBalanceCode, reqVO.getLastBalanceCode())
                .eqIfPresent(BusinessSubSampleDO::getConfigSampleFlowId, reqVO.getConfigSampleFlowId())
                .eqIfPresent(BusinessSubSampleDO::getSampleFlowNodeKey, reqVO.getSampleFlowNodeKey())
                .inIfPresent(BusinessSubSampleDO::getSampleFlowNodeKey, reqVO.getSampleFlowNodeKeyList())
                .betweenIfPresent(BusinessSubSampleDO::getSampleFlowNodeTime, reqVO.getSampleFlowNodeTime())
                .eqIfPresent(BusinessSubSampleDO::getNextSampleFlowNode, reqVO.getNextSampleFlowNode())
                .eqIfPresent(BusinessSubSampleDO::getIsMaterialAssayStandard, reqVO.getIsMaterialAssayStandard())
                .eqIfPresent(BusinessSubSampleDO::getAssayLevel, reqVO.getAssayLevel())
                .eqIfPresent(BusinessSubSampleDO::getSampleStatus, reqVO.getSampleStatus())
                .eqIfPresent(BusinessSubSampleDO::getAssayOperator, reqVO.getAssayOperator())
                .eqIfPresent(BusinessSubSampleDO::getIsAssignTasked, reqVO.getIsAssignTasked())
                .betweenIfPresent(BusinessSubSampleDO::getAssignTaskTime, reqVO.getAssignTaskTime())
                .eqIfPresent(BusinessSubSampleDO::getIsReported, reqVO.getIsReported())
                .eqIfPresent(BusinessSubSampleDO::getReporter, reqVO.getReporter())
                .betweenIfPresent(BusinessSubSampleDO::getReportTime, reqVO.getReportTime())
                .betweenIfPresent(BusinessSubSampleDO::getReturnTime, reqVO.getReturnTime())
                .eqIfPresent(BusinessSubSampleDO::getReturnStatus, reqVO.getReturnStatus())
				.eqIfPresent(BusinessSubSampleDO::getDispatchStatus, reqVO.getDispatchStatus())
                .eqIfPresent(BusinessSubSampleDO::getReturnCodePrintCount, reqVO.getReturnCodePrintCount())
                .betweenIfPresent(BusinessSubSampleDO::getPrintLastTime, reqVO.getPrintLastTime())
                .eqIfPresent(BusinessSubSampleDO::getUpSampleRecordId, reqVO.getUpSampleRecordId())
                .eqIfPresent(BusinessSubSampleDO::getAnalysisRemark, reqVO.getAnalysisRemark())
                .eqIfPresent(BusinessSubSampleDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
                .betweenIfPresent(BusinessSubSampleDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(BusinessSubSampleDO::getUpdateCount, reqVO.getUpdateCount())
                .eqIfPresent(BusinessSubSampleDO::getRemark, reqVO.getRemark())
                .eqIfPresent(BusinessSubSampleDO::getUpSampleRecordId, reqVO.getUpSampleRecordId())
                .orderByDesc(BusinessSubSampleDO::getId));
	}

	default BusinessSubSampleExtendRespVO selectExtendById(Long id) {
		return selectJoinOne(BusinessSubSampleExtendRespVO.class, new MPJLambdaWrapperX<BusinessSubSampleDO>()
        		.leftJoin(DictionaryBusinessDO.class, DictionaryBusinessDO::getId, BusinessSubSampleDO::getDictionaryBusinessId)
        		.leftJoin(ConfigSubSampleDO.class, ConfigSubSampleDO::getId, BusinessSubSampleDO::getConfigSubSampleId)
        		.selectAll(BusinessSubSampleDO.class)
        		.selectAs(DictionaryBusinessDO::getName, BusinessSubSampleExtendRespVO::getDictionaryBusinessName)
        		.selectAs(ConfigSubSampleDO::getIsPrint, BusinessSubSampleExtendRespVO::getIsPrint)
        		.selectAs(ConfigSubSampleDO::getPrintTemplate, BusinessSubSampleExtendRespVO::getPrintTemplate)
        		.selectAs(ConfigSubSampleDO::getCodePrintQuantity, BusinessSubSampleExtendRespVO::getCodePrintQuantity)
                .eq(BusinessSubSampleDO::getId, id)
                .eq(BusinessSubSampleDO::getSampleStatus, QmsCommonConstant.NORMAL)
                .eq(BusinessSubSampleDO::getIsEnabled, QmsCommonConstant.YES)
                .orderByDesc(BusinessSubSampleDO::getId));
	}

	default List<BusinessSubSampleExtendRespVO> getBySampleCode(BusinessSubSampleReqVO reqVO) {
		return selectJoinList(BusinessSubSampleExtendRespVO.class, new MPJLambdaWrapperX<BusinessSubSampleDO>()
        		.leftJoin(DictionaryBusinessDO.class, DictionaryBusinessDO::getId, BusinessSubSampleDO::getDictionaryBusinessId)
        		.leftJoin(ConfigSubSampleDO.class, ConfigSubSampleDO::getId, BusinessSubSampleDO::getConfigSubSampleId)
        		.selectAll(BusinessSubSampleDO.class)
        		.selectAs(DictionaryBusinessDO::getName, BusinessSubSampleExtendRespVO::getDictionaryBusinessName)
        		.selectAs(ConfigSubSampleDO::getIsPrint, BusinessSubSampleExtendRespVO::getIsPrint)
        		.selectAs(ConfigSubSampleDO::getPrintTemplate, BusinessSubSampleExtendRespVO::getPrintTemplate)
                .eqIfPresent(BusinessSubSampleDO::getSampleCode, reqVO.getSampleCode())
                .eqIfPresent(BusinessSubSampleDO::getSampleStatus, QmsCommonConstant.NORMAL)
                .eqIfPresent(BusinessSubSampleDO::getIsEnabled, QmsCommonConstant.YES)
                .orderByDesc(BusinessSubSampleDO::getId));
	}

	default List<BusinessSubSampleExtendRespVO> getBySampleCodeAndFlowKey(BusinessSubSampleReqVO reqVO) {
		return selectJoinList(BusinessSubSampleExtendRespVO.class, new MPJLambdaWrapperX<BusinessSubSampleDO>()
        		.leftJoin(DictionaryBusinessDO.class, DictionaryBusinessDO::getId, BusinessSubSampleDO::getDictionaryBusinessId)
        		.leftJoin(ConfigSubSampleDO.class, ConfigSubSampleDO::getId, BusinessSubSampleDO::getConfigSubSampleId)
        		.selectAll(BusinessSubSampleDO.class)
        		.selectAs(DictionaryBusinessDO::getName, BusinessSubSampleExtendRespVO::getDictionaryBusinessName)
        		.selectAs(ConfigSubSampleDO::getIsPrint, BusinessSubSampleExtendRespVO::getIsPrint)
        		.selectAs(ConfigSubSampleDO::getPrintTemplate, BusinessSubSampleExtendRespVO::getPrintTemplate)
                .eqIfPresent(BusinessSubSampleDO::getSampleCode, reqVO.getSampleCode())
                .eqIfPresent(BusinessSubSampleDO::getSampleFlowNodeKey, reqVO.getSampleFlowNodeKey())
                .inIfPresent(BusinessSubSampleDO::getSampleFlowNodeKey, reqVO.getSampleFlowNodeKeyList())
                .eqIfPresent(BusinessSubSampleDO::getSampleStatus, QmsCommonConstant.NORMAL)
                .eqIfPresent(BusinessSubSampleDO::getIsEnabled, QmsCommonConstant.YES)
                .orderByDesc(BusinessSubSampleDO::getId));
	}


	Page<BusinessSubSampleExtendRespVO> selectPageForDispatch(IPage<?> page, @Param("param") BusinessSubSamplePageReqVO reqVO);

}