package com.zt.plat.module.erp.dal.mysql.erp;

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.erp.controller.admin.erp.vo.ErpProductiveOrderPageReqVO;
import com.zt.plat.module.erp.dal.dataobject.erp.ErpProductiveOrderDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * ERP生产订单 Mapper
 *
 * @author 后台管理
 */
@Mapper
public interface ErpProductiveOrderMapper extends BaseMapperX<ErpProductiveOrderDO> {

    default PageResult<ErpProductiveOrderDO> selectPage(ErpProductiveOrderPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ErpProductiveOrderDO>()
                .likeIfPresent(ErpProductiveOrderDO::getCompanyNumber, reqVO.getCompanyNumber())
                .likeIfPresent(ErpProductiveOrderDO::getFactoryNumber, reqVO.getFactoryNumber())
                .likeIfPresent(ErpProductiveOrderDO::getFactoryName, reqVO.getFactoryName())
                .likeIfPresent(ErpProductiveOrderDO::getOrderNumber, reqVO.getOrderNumber())
                .betweenIfPresent(ErpProductiveOrderDO::getStartDate, reqVO.getStartDate())
                .betweenIfPresent(ErpProductiveOrderDO::getEndDate, reqVO.getEndDate())
                .likeIfPresent(ErpProductiveOrderDO::getMainMaterialNumber, reqVO.getMainMaterialNumber())
                .eqIfPresent(ErpProductiveOrderDO::getUnit, reqVO.getUnit())
                .likeIfPresent(ErpProductiveOrderDO::getMaterialDescription, reqVO.getMaterialDescription())
                .eqIfPresent(ErpProductiveOrderDO::getProcessingList, reqVO.getProcessingList())
                .eqIfPresent(ErpProductiveOrderDO::getProcessingNumber, reqVO.getProcessingNumber())
                .likeIfPresent(ErpProductiveOrderDO::getProcessingDescription, reqVO.getProcessingDescription())
                .eqIfPresent(ErpProductiveOrderDO::getObjectNumber, reqVO.getObjectNumber())
                .eqIfPresent(ErpProductiveOrderDO::getWorkCenterNumber, reqVO.getWorkCenterNumber())
                .likeIfPresent(ErpProductiveOrderDO::getWorkCenterDescription, reqVO.getWorkCenterDescription())
                .eqIfPresent(ErpProductiveOrderDO::getCostcenterNumber, reqVO.getCostcenterNumber())
                .likeIfPresent(ErpProductiveOrderDO::getCostcenterName, reqVO.getCostcenterName())
                .orderByDesc(ErpProductiveOrderDO::getId));
    }

}