package com.zt.plat.module.contractorder.dal.mysql.originalmaterialprocessing;

import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.zt.plat.module.contractorder.controller.admin.originalmaterialprocessing.vo.OriginalMaterialProcessingPageReqVO;
import com.zt.plat.module.contractorder.dal.dataobject.originalmaterialprocessing.OriginalMaterialProcessingDO;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface OriginalMaterialProcessingMapper extends BaseMapperX<OriginalMaterialProcessingDO> {

    default PageResult<OriginalMaterialProcessingDO> selectPage(OriginalMaterialProcessingPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<OriginalMaterialProcessingDO>()
                .eqIfPresent(OriginalMaterialProcessingDO::getOrderSAPNumber, reqVO.getOrderSAPNumber())
                .eqIfPresent(OriginalMaterialProcessingDO::getSystemOrderNumber, reqVO.getSystemOrderNumber())
                .eqIfPresent(OriginalMaterialProcessingDO::getCpName, reqVO.getCpName())
                .eqIfPresent(OriginalMaterialProcessingDO::getSupplierNumber, reqVO.getSupplierNumber())
                .likeIfPresent(OriginalMaterialProcessingDO::getSupplierName, reqVO.getSupplierName())
                .eqIfPresent(OriginalMaterialProcessingDO::getType, reqVO.getType())
                .eqIfPresent(OriginalMaterialProcessingDO::getVoucherDate, reqVO.getVoucherDate())
                .eqIfPresent(OriginalMaterialProcessingDO::getPurchaseOrganizationCustomsDeclaration, reqVO.getPurchaseOrganizationCustomsDeclaration())
                .likeIfPresent(OriginalMaterialProcessingDO::getReceiveFactoryName, reqVO.getReceiveFactoryName())
                .eqIfPresent(OriginalMaterialProcessingDO::getReceiveFactoryNumber, reqVO.getReceiveFactoryNumber())
                .likeIfPresent(OriginalMaterialProcessingDO::getReceiveWarehouseName, reqVO.getReceiveWarehouseName())
                .eqIfPresent(OriginalMaterialProcessingDO::getReceiveWarehouseNumber, reqVO.getReceiveWarehouseNumber())
                .eqIfPresent(OriginalMaterialProcessingDO::getPurchaseGroup, reqVO.getPurchaseGroup())
                .eqIfPresent(OriginalMaterialProcessingDO::getCurrencyNumber, reqVO.getCurrencyNumber())
                .eqIfPresent(OriginalMaterialProcessingDO::getExchangeRate, reqVO.getExchangeRate())
                .eqIfPresent(OriginalMaterialProcessingDO::getPaperContractNumber, reqVO.getPaperContractNumber())
                .eqIfPresent(OriginalMaterialProcessingDO::getAgreementNumber, reqVO.getAgreementNumber())
                .eqIfPresent(OriginalMaterialProcessingDO::getRemark, reqVO.getRemark())
                .eqIfPresent(OriginalMaterialProcessingDO::getAgentNumber, reqVO.getAgentNumber())
                .likeIfPresent(OriginalMaterialProcessingDO::getAgentName, reqVO.getAgentName())
                .eqIfPresent(OriginalMaterialProcessingDO::getContractNumber, reqVO.getContractNumber())
                .eqIfPresent(OriginalMaterialProcessingDO::getMaterialNumber, reqVO.getMaterialNumber())
                .likeIfPresent(OriginalMaterialProcessingDO::getMaterialName, reqVO.getMaterialName())
                .likeIfPresent(OriginalMaterialProcessingDO::getContractName, reqVO.getContractName())
                .eqIfPresent(OriginalMaterialProcessingDO::getTenantNumber, reqVO.getTenantNumber())
                .betweenIfPresent(OriginalMaterialProcessingDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(OriginalMaterialProcessingDO::getErpPurchaseCompanyNumber, reqVO.getErpPurchaseCompanyNumber())
                .likeIfPresent(OriginalMaterialProcessingDO::getErpPurchaseCompanyName, reqVO.getErpPurchaseCompanyName())
                .eqIfPresent(OriginalMaterialProcessingDO::getErpSalesCompanyNumber, reqVO.getErpSalesCompanyNumber())
                .likeIfPresent(OriginalMaterialProcessingDO::getErpSalesCompanyName, reqVO.getErpSalesCompanyName())
                .likeIfPresent(OriginalMaterialProcessingDO::getPurchaseOrganizationName, reqVO.getPurchaseOrganizationName())
                .eqIfPresent(OriginalMaterialProcessingDO::getErpStatus, reqVO.getErpStatus())
                .eqIfPresent(OriginalMaterialProcessingDO::getCause, reqVO.getCause())
                .eqIfPresent(OriginalMaterialProcessingDO::getStatus, reqVO.getStatus())
                .likeIfPresent(OriginalMaterialProcessingDO::getPurchaseGroupName, reqVO.getPurchaseGroupName())
                //.eqIfPresent(OriginalMaterialProcessingDO::getRelatedOrderId, reqVO.getRelatedOrderId())
                .eqIfPresent(OriginalMaterialProcessingDO::getSplyBsnTp, reqVO.getSplyBsnTp())
                .orderByDesc(OriginalMaterialProcessingDO::getId));
    }

}
