package com.fastbee.iot.strategy;

import cn.hutool.json.JSONObject;
import com.fastbee.common.core.domain.AjaxResult;
import com.fastbee.iot.strategy.factory.DeviceRealTimeDataGetFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/temp")
public class test11 {

    @Autowired
    private  DeviceRealTimeDataGetFactory dataGetFactory;


    @GetMapping("/test")
    public AjaxResult test(){

        String deviceId = "3269";
        String deviceBrand = "展连IOT";
//        String deviceId = "1017240042";
//        String deviceBrand = "仁科";
        Long productId = 143L;
        //获取设备对应数据获取器
        DeviceRealTimeDataGetStrategy DataGetMachine = dataGetFactory.getDeviceRealTimeDataGetStrategy(deviceBrand);
        System.err.println("获取到设备数据获取器："+DataGetMachine.getClass());
        //获取设备实时数据
        JSONObject deviceRealTimeData = DataGetMachine.getDeviceRealTimeData(deviceId);
        System.err.println("实时数据："+deviceRealTimeData);
        return AjaxResult.success(deviceRealTimeData);
    }




















    public static void main(String[] args) {
        String deviceId = "3270";
        String deviceBrand = "展连IOT";
        Long productId = 142L;
        //设备实时数据获取器工厂
        DeviceRealTimeDataGetFactory dataGetFactory = new DeviceRealTimeDataGetFactory();
        //获取设备对应数据获取器
        DeviceRealTimeDataGetStrategy DataGetMachine = dataGetFactory.getDeviceRealTimeDataGetStrategy(deviceBrand);
        //获取设备实时数据
        JSONObject deviceRealTimeData = DataGetMachine.getDeviceRealTimeData(deviceId);
        System.err.println(deviceRealTimeData);

        //获取实时数据存储器
        //映射并持久化设备数据




    }
}
