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

import com.fastbee.deviceData.domain.DeviceRealtimedataMiaoqing;
import com.fastbee.deviceData.domain.DeviceRealtimedataPhotovoltaic;
import com.fastbee.deviceData.mapper.DeviceRealtimedataMiaoqingMapper;
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 DevLinkMiaoQingDataService extends DevLinkRealTimeDataService {
    @Autowired
    private DevLinkAuthorizationService authorizationService;
    @Autowired
    private DeviceRealtimedataMiaoqingMapper deviceRealtimedataMiaoqingMapper;
    public DeviceRealtimedataMiaoqing setData(Map<String, String> propertiesMap){
        DeviceRealtimedataMiaoqing miaoqing = DeviceRealtimedataMiaoqing.builder()
                .airTemp(toBigDecimalValue(propertiesMap.get("airTemp")))
                .mppTemp(toBigDecimalValue(propertiesMap.get("mppTemp")))
                .batteryCap(Long.parseLong(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")))
                .build();
        System.err.println(miaoqing);
        return miaoqing;
    }

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