package cn.iocoder.yudao.module.system.dal.mysql.statistics;

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.system.controller.admin.statistics.vo.RobotWorkingHoursStatisticsPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.statistics.RobotWorkingHoursStatisticsDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * 车辆工作时长统计 Mapper
 *
 * @author 陈宾顺
 */
@Mapper
public interface RobotWorkingHoursStatisticsMapper extends BaseMapperX<RobotWorkingHoursStatisticsDO> {

    default PageResult<RobotWorkingHoursStatisticsDO> selectPage(RobotWorkingHoursStatisticsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<RobotWorkingHoursStatisticsDO>()
                .eqIfPresent(RobotWorkingHoursStatisticsDO::getPositionMapId, reqVO.getPositionMapId())
                .eqIfPresent(RobotWorkingHoursStatisticsDO::getRobotNo, reqVO.getRobotNo())
                .eqIfPresent(RobotWorkingHoursStatisticsDO::getDuration, reqVO.getDuration())
                .eqIfPresent(RobotWorkingHoursStatisticsDO::getDurationType, reqVO.getDurationType())
                .betweenIfPresent(RobotWorkingHoursStatisticsDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(RobotWorkingHoursStatisticsDO::getId));
    }

    /**
     * 查询工作时间
     * @param type  type  1:周, 2:月,  3:季度
     * @param positionMapId  地图Id
     * @return
     */
    List<RobotWorkingHoursStatisticsDO> getRobotWorkHourStatistics(@Param("type") String type,
                                                                   @Param("positionMapId") String positionMapId);
}