package com.fastbee.deviceData.api.devlink.service;

import com.fastbee.deviceData.domain.DeviceRealtimedataMeteorology;
import com.fastbee.deviceData.mapper.DeviceRealtimedataMeteorologyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;


/**
 * devLink气象设备数据服务
 */
@Service
public class DevLinkMetDataService extends DevLinkRealTimeDataService {

    @Autowired
    private DevLinkAuthorizationService authorizationService;

    @Autowired
    private DeviceRealtimedataMeteorologyMapper deviceRealtimedataMeteorologyMapper;


    //封装数据
    public DeviceRealtimedataMeteorology setData(Map<String, String> propertiesMap){
        DeviceRealtimedataMeteorology build = DeviceRealtimedataMeteorology.builder()
                .deviceId(propertiesMap.get("deviceId"))
                .airTemp(toBigDecimalValue(propertiesMap.get("airTemp")))
                .airHumi(toBigDecimalValue(propertiesMap.get("airHumi")))
                .windSpeed(toBigDecimalValue(propertiesMap.get("windSpeed")))
                .windDir(toBigDecimalValue(propertiesMap.get("windDir")))
                .airPre(toBigDecimalValue(propertiesMap.get("airPre")))
                .guangzhao(toBigDecimalValue(propertiesMap.get("guangzhao")))
                .fushe(toBigDecimalValue(propertiesMap.get("fushe")))
                .sumRain(toBigDecimalValue(propertiesMap.get("sumRain")))
                .sumRain(toBigDecimalValue(propertiesMap.get("sumRain")))
                .insRain(toBigDecimalValue(propertiesMap.get("insRain")))
                .dayRain(toBigDecimalValue(propertiesMap.get("dayRain")))
                .zhengfa(toBigDecimalValue(propertiesMap.get("zhengfa")))
                .soilTemp(toBigDecimalValue(propertiesMap.get("soilTemp")))
                .soilHumi(toBigDecimalValue(propertiesMap.get("soilHumi")))
                .build();


        System.err.println(build);
        return build;
    }

    public static void main(String[] args) {
        DevLinkMetDataService devLinkMetDataService = new DevLinkMetDataService();
        Map<String, String> metDeviceRealData = devLinkMetDataService.getMetDeviceRealData("3269");
        devLinkMetDataService.setData(metDeviceRealData);
    }
}
