package cn.iocoder.yudao.module.pms.dal.mysql.maintain.material;

import java.time.LocalDateTime;
import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.pms.controller.admin.maintain.material.vo.IotMaintainMaterialPageReqVO;
import cn.iocoder.yudao.module.pms.dal.dataobject.maintain.material.IotMaintainMaterialDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * 工单物料 Mapper
 *
 * @author 李鹏辉
 */
@Mapper
public interface IotMaintainMaterialMapper extends BaseMapperX<IotMaintainMaterialDO> {

    default PageResult<IotMaintainMaterialDO> selectPage(IotMaintainMaterialPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<IotMaintainMaterialDO>()
                .eqIfPresent(IotMaintainMaterialDO::getCode, reqVO.getCode())
                .likeIfPresent(IotMaintainMaterialDO::getName, reqVO.getName())
                .eqIfPresent(IotMaintainMaterialDO::getUnit, reqVO.getUnit())
                .eqIfPresent(IotMaintainMaterialDO::getPrice, reqVO.getPrice())
                .eqIfPresent(IotMaintainMaterialDO::getSourceType, reqVO.getSourceType())
                .eqIfPresent(IotMaintainMaterialDO::getDepleteCount, reqVO.getDepleteCount())
                .eqIfPresent(IotMaintainMaterialDO::getTotalCount, reqVO.getTotalCount())
                .eqIfPresent(IotMaintainMaterialDO::getSapCode, reqVO.getSapCode())
                .eqIfPresent(IotMaintainMaterialDO::getStatus, reqVO.getStatus())
                .eqIfPresent(IotMaintainMaterialDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(IotMaintainMaterialDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(IotMaintainMaterialDO::getId));
    }


    IPage<IotMaintainMaterialDO> selectMaterialsByDept(IPage<IotMaintainMaterialDO> page, @Param("deptId") Long deptId, @Param("parentDept") Long parentDept);
}
