package com.cf.imes.module.executor.dal.mysql.plan;

import java.util.*;

import com.cf.imes.framework.common.pojo.PageResult;
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
import com.cf.imes.module.executor.dal.dataobject.plan.PlanDO;
import org.apache.ibatis.annotations.Mapper;
import com.cf.imes.module.executor.controller.admin.plan.vo.*;

/**
 * 生产单开料排单 Mapper
 *
 * @author 晨丰科技
 */
@Mapper
public interface PlanMapper extends BaseMapperX<PlanDO> {

    default PageResult<PlanDO> selectPage(PlanPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<PlanDO>()
                .eqIfPresent(PlanDO::getPlanNo, reqVO.getPlanNo())
                .eqIfPresent(PlanDO::getSort, reqVO.getSort())
                .eqIfPresent(PlanDO::getType, reqVO.getType())
                .eqIfPresent(PlanDO::getStatus, reqVO.getStatus())
                .eqIfPresent(PlanDO::getIsPay, reqVO.getIsPay())
                .eqIfPresent(PlanDO::getMachineId, reqVO.getMachineId())
                .betweenIfPresent(PlanDO::getPlanTime, reqVO.getPlanTime())
                .eqIfPresent(PlanDO::getOrderNos, reqVO.getOrderNos())
                .eqIfPresent(PlanDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(PlanDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(PlanDO::getOperator, reqVO.getOperator())
                .betweenIfPresent(PlanDO::getProduceTime, reqVO.getProduceTime())
                .orderByDesc(PlanDO::getId));
    }

    List<PlateOptimize> selectPlateListByPlanId(Long planId);
}