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


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.information.vo.DeviceInformationPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.information.DeviceInformationDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * 设备信息 Mapper
 *
 * @author 陈宾顺
 */
@Mapper
public interface DeviceInformationMapper extends BaseMapperX<DeviceInformationDO> {

    default PageResult<DeviceInformationDO> selectPage(DeviceInformationPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DeviceInformationDO>()
                .eqIfPresent(DeviceInformationDO::getDeviceType, reqVO.getDeviceType())
                .eqIfPresent(DeviceInformationDO::getDeviceNo, reqVO.getDeviceNo())
                .eqIfPresent(DeviceInformationDO::getMacAddress, reqVO.getMacAddress())
                .eqIfPresent(DeviceInformationDO::getUrl, reqVO.getUrl())
                .eqIfPresent(DeviceInformationDO::getPictureConfig, reqVO.getPictureConfig())
                .eqIfPresent(DeviceInformationDO::getDeviceStatus, reqVO.getDeviceStatus())
                .eqIfPresent(DeviceInformationDO::getDeviceEnable, reqVO.getDeviceEnable())
                .eqIfPresent(DeviceInformationDO::getDeviceAgreement, reqVO.getDeviceAgreement())
                .betweenIfPresent(DeviceInformationDO::getDeviceLastTime, reqVO.getDeviceLastTime())
                .betweenIfPresent(DeviceInformationDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DeviceInformationDO::getId));
    }

    /**
     * 更新设备使用中
     * @param deviceNo
     * @param deviceUseStatus
     * @param lastUser
     */
    void updateDeviceUseStatus(@Param("deviceNo") String deviceNo,
                               @Param("deviceUseStatus") Integer deviceUseStatus,
                               @Param("lastUser") String lastUser);

    /**
     * 设置设备空闲
     * @param lastUser
     */
    void setDeviceReleaseByLastUser(@Param("lastUser") String lastUser,
                                    @Param("deviceUseStatus") Integer deviceUseStatus);

    /**
     * 根据地图id删除
     * @param mapId
     */
    void deleteDeviceByMapId(@Param("mapId") Long mapId);

    /**
     * 更新车辆编号
     * @param oldRobotNo
     * @param newRobotNo
     */
    void updateRobotNo(@Param("oldRobotNo") String oldRobotNo, @Param("newRobotNo") String newRobotNo);

    /**
     * 清除车辆编号
     * @param robotNo
     */
    void clearRobotNo(@Param("robotNo") String robotNo);
}