package cn.iocoder.yudao.module.pms.dal.mysql.qhse.soc;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.pms.controller.admin.qhse.soc.vo.IotSocSummaryPageReqVO;
import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.soc.IotSocSummaryDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.Set;

/**
 * SOC卡汇总 Mapper
 *
 * @author 超级管理员
 */
@Mapper
public interface IotSocSummaryMapper extends BaseMapperX<IotSocSummaryDO> {

    default PageResult<IotSocSummaryDO> selectPage(IotSocSummaryPageReqVO reqVO, Set<Long> ids) {
        return selectPage(reqVO, new LambdaQueryWrapperX<IotSocSummaryDO>()
                .eqIfPresent(IotSocSummaryDO::getProject, reqVO.getProject())
                .betweenIfPresent(IotSocSummaryDO::getObservationDate, reqVO.getObservationDate())
                .eqIfPresent(IotSocSummaryDO::getSocClass, reqVO.getSocClass())
                .likeIfPresent(IotSocSummaryDO::getClassName, reqVO.getClassName())
                .likeIfPresent(IotSocSummaryDO::getUserName, reqVO.getUserName())
                .eqIfPresent(IotSocSummaryDO::getPost, reqVO.getPost())
//                .eqIfPresent(IotSocSummaryDO::getDeptId, reqVO.getDeptId())
                .eqIfPresent(IotSocSummaryDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(IotSocSummaryDO::getCreateTime, reqVO.getCreateTime())
                .likeIfPresent(IotSocSummaryDO::getDeptName, reqVO.getDeptName())
                .inIfPresent(IotSocSummaryDO::getDeptId, ids)
                .orderByDesc(IotSocSummaryDO::getId));
    }

    default Long selectCountBySocClassAndTime(IotSocSummaryPageReqVO reqVO, Set<Long> ids) {
        return selectCount(new LambdaQueryWrapperX<IotSocSummaryDO>()
                .inIfPresent(IotSocSummaryDO::getDeptId, ids)
                .inIfPresent(IotSocSummaryDO::getSocClass, reqVO.getSocClasses())
                .betweenIfPresent(IotSocSummaryDO::getObservationDate, reqVO.getObservationDate()));
    }

}