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

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

/**
 * devLink光伏设备数据服务
 */
@Service
public class DevLinkPhotovoltaicDataService extends DevLinkRealTimeDataService{
    @Autowired
    private DevLinkAuthorizationService authorizationService;
    @Autowired
    private DeviceRealtimedataPhotovoltaicMapper photovoltaicMapper;
    //封装数据
    public DeviceRealtimedataPhotovoltaic setData(Map<String, String> propertiesMap){
        DeviceRealtimedataPhotovoltaic photovoltaic = DeviceRealtimedataPhotovoltaic.builder()
                .airTemp(toBigDecimalValue(propertiesMap.get("airTemp")))
                .mppTemp(toBigDecimalValue(propertiesMap.get("mppTemp")))
                .batteryCap(toBigDecimalValue(propertiesMap.get("batteryCap")))
                .batteryVolt(toBigDecimalValue(propertiesMap.get("batteryVolt")))
                .batteryCur(toBigDecimalValue(propertiesMap.get("batteryCur")))
                .batteryPower(toBigDecimalValue(propertiesMap.get("batteryPower")))
                .loadVolt(toBigDecimalValue(propertiesMap.get("loadVolt")))
                .loadCur(toBigDecimalValue(propertiesMap.get("loadCur")))
                .loadPower(toBigDecimalValue(propertiesMap.get("loadPower")))
                .photVolt(toBigDecimalValue(propertiesMap.get("photVolt")))
                .photCur(toBigDecimalValue(propertiesMap.get("photCur")))
                .photPower(toBigDecimalValue(propertiesMap.get("photPower")))
                .cumChargeDay(toBigDecimalValue(propertiesMap.get("cum_charge_day")))
                .cumChargeMon(toBigDecimalValue(propertiesMap.get("cum_charge_mon")))
                .cumChargeYear(toBigDecimalValue(propertiesMap.get("cum_charge_year")))
                .cumChargeAll(toBigDecimalValue(propertiesMap.get("cum_charge_all")))
                .cumEleDay(toBigDecimalValue(propertiesMap.get("cum_ele_day")))
                .cumEleMon(toBigDecimalValue(propertiesMap.get("cum_ele_mon")))
                .cumEleYear(toBigDecimalValue(propertiesMap.get("cum_ele_year")))
                .cumEleAll(toBigDecimalValue(propertiesMap.get("cum_ele_all")))
                .shoudong(toBigDecimalValue(propertiesMap.get("shoudong")))
                .control(toBigDecimalValue(propertiesMap.get("control")))
                .airTemp2(toBigDecimalValue(propertiesMap.get("airTemp_2")))
                .mppTemp2(toBigDecimalValue(propertiesMap.get("mppTemp_2")))
                .batteryCap2(toBigDecimalValue(propertiesMap.get("batteryCap_2")))
                .batteryVolt2(toBigDecimalValue(propertiesMap.get("batteryVolt_2")))
                .batteryCur2(toBigDecimalValue(propertiesMap.get("batteryCur_2")))
                .batteryPower2(toBigDecimalValue(propertiesMap.get("batteryPower_2")))
                .loadVolt2(toBigDecimalValue(propertiesMap.get("loadVolt_2")))
                .loadCur2(toBigDecimalValue(propertiesMap.get("loadCur_2")))
                .loadPower2(toBigDecimalValue(propertiesMap.get("loadPower_2")))
                .photVolt2(toBigDecimalValue(propertiesMap.get("photVolt_2")))
                .photCur2(toBigDecimalValue(propertiesMap.get("photCur_2")))
                .photPower2(toBigDecimalValue(propertiesMap.get("photPower_2")))
                .cumChargeDay2(toBigDecimalValue(propertiesMap.get("cum_charge_day_2")))
                .cumChargeMon2(toBigDecimalValue(propertiesMap.get("cum_charge_mon_2")))
                .cumChargeYear2(toBigDecimalValue(propertiesMap.get("cum_charge_year_2")))
                .cumChargeAll2(toBigDecimalValue(propertiesMap.get("cum_charge_all_2")))
                .cumEleDay2(toBigDecimalValue(propertiesMap.get("cum_ele_day_2")))
                .cumEleYear2(toBigDecimalValue(propertiesMap.get("cum_ele_year_2")))
                .cumEleAll2(toBigDecimalValue(propertiesMap.get("cum_ele_all_2")))
                .shoudong2(toBigDecimalValue(propertiesMap.get("shoudong_2")))
                .control2(toBigDecimalValue(propertiesMap.get("control_2")))
                .cumEleMon2(toBigDecimalValue(propertiesMap.get("cum_ele_mon_2")))
                .build();

        System.err.println(photovoltaic);
        return photovoltaic;
    }
    public static void main(String[] args) {
        DevLinkPhotovoltaicDataService devLinkPhotovoltaicDataService = new DevLinkPhotovoltaicDataService();
        Map<String, String> metDeviceRealData = devLinkPhotovoltaicDataService.getMetDeviceRealData("3276");
        devLinkPhotovoltaicDataService.setData(metDeviceRealData);

    }
}
