package com.ruoyi.tdengine.service.impl;

import com.ruoyi.common.core.constant.TdEngineConstants;
import com.ruoyi.tdengine.api.domain.DeviceStatus;
import com.ruoyi.tdengine.mapper.DeviceStatusMapper;
import com.ruoyi.tdengine.service.IDeviceStatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description: 设备状态信息业务服务
 * @ClassName: DeviceStatusServiceImpl
 * @Author : xins
 * @Date :2023-09-05  13:27
 * @Version :1.0
 */
@Service
public class DeviceStatusServiceImpl implements IDeviceStatusService {

    @Autowired
    private DeviceStatusMapper deviceStatusMapper;

    /**
     * @return List<DeviceStatus>
     * @param: DeviceStatus
     * @description 获取时间范围内每天的在线设备
     * @author xins
     * @date 2023-09-05 13:23
     */
    @Override
    public List<DeviceStatus> getOnlineDevicesGroupByDay(DeviceStatus queryDeviceStatus) {

        Map<String, Object> params = queryDeviceStatus.getParams();
        params.put("databaseName", TdEngineConstants.PLATFORM_DB_NAME);
        params.put("superTableName", TdEngineConstants.DEFAULT_DEVICE_STATUS_SUPER_TABLE_NAME);
//        DeviceStatus queryDeviceStatus = new DeviceStatus();
//        params.put("beginTime", beginTime);
//        params.put("endTime", endTime);
//        queryDeviceStatus.setParams(params);
//        if (sceneId != null) {
//            queryDeviceStatus.setSceneId(sceneId);
//        }

        List<DeviceStatus> deviceStatuses = deviceStatusMapper.getOnlineDevicesGroupByDay(queryDeviceStatus);

        return deviceStatuses;
    }
}
