package com.yuchen.saas.park.service.factory;

import com.yuchen.saas.park.api.enums.IotProductEnum;
import com.yuchen.saas.park.api.vo.park.devicepro.*;
import com.yuchen.saas.park.service.pull.property.device.SoilHumidityHandleImpl;
import com.yuchen.saas.park.service.pull.property.device.ValveControllerHandleImpl;
import com.yuchen.saas.park.service.pull.property.template.DeviceHandleBasePropertyValue;

/**
 * @Author: 肖润飞
 * @CreateTime: 2022/09/06 18:08
 * @Description: 创建产品属性对象的静态工厂
 * @Version: 1.0
 */
public class SimpleDeviceFactory {

    /**
     * 创建设备的属性对象
     * @param productKey 产品key
     * @return
     */
    public static DeviceBasePro createDevicePro(String productKey) {
        DeviceBasePro deviceBasePro = new DeviceBasePro();
        // 8.水压传感器
        if (productKey.equals(IotProductEnum.WATER_PRESSURE_DEVICE.getValue())) {
            deviceBasePro = new WaterPressureDevicePro();
        }
        // 9.三相电表
        if (productKey.equals(IotProductEnum.THREE_AMMETER_DEVICE.getValue())) {
            deviceBasePro = new ThreeAmmeterDevicePro();
        }
        // 10.单向电表
        if (productKey.equals(IotProductEnum.ONE_AMMETER_DEVICE.getValue())) {
            deviceBasePro = new OneAmmeterDevicePro();
        }
        // 11.水表
        if (productKey.equals(IotProductEnum.WATER_METER_DEVICE.getValue())) {
            deviceBasePro = new WaterMeterDevicePro();
        }
        // 12.土壤酸碱度传感器
        if (productKey.equals(IotProductEnum.SOIL_PH_DEVICE.getValue())) {
            deviceBasePro = new SoilPhDevicePro();
        }
        // 13.土壤温湿度传感器
        if (productKey.equals(IotProductEnum.SOIL_HUMIDITY_DEVICE.getValue())) {
            deviceBasePro = new SoilHumidityDevicePro();
        }
        // 14.阀门控制器
        if (productKey.equals(IotProductEnum.VALVE_CONTROLLER_DEVICE.getValue())) {
            deviceBasePro = new ValveControllerDevicePro();
        }
        // 15.井盖监测器
        if (productKey.equals(IotProductEnum.MANHOLE_COVER_DEVICE.getValue())) {
            deviceBasePro = new ManholeCoverDevicePro();
        }
        // 16.风向传感器
        if (productKey.equals(IotProductEnum.WIND_DIRECTION_DEVICE.getValue())) {
            deviceBasePro = new WindDirectionDevicePro();
        }
        // 17.消防栓监测器
        if (productKey.equals(IotProductEnum.HYDRANT_DEVICE.getValue())) {
            deviceBasePro = new HydrantDevicePro();
        }
        // 18.风速传感器
        if (productKey.equals(IotProductEnum.WIND_SPEED_DEVICE.getValue())) {
            deviceBasePro = new WindSpeedDevicePro();
        }
        // 19.雨量传感器
        if (productKey.equals(IotProductEnum.RAINFALL_DEVICE.getValue())) {
            deviceBasePro = new RainfallDevicePro();
        }
        // 20.气象站
        if (productKey.equals(IotProductEnum.WEATHER_STATION_DEVICE.getValue())) {
            deviceBasePro = new WeatherStationDevicePro();
        }
        // 21.门磁传感器
        if (productKey.equals(IotProductEnum.DOOR_DEVICE.getValue())) {
            deviceBasePro = new DoorDevicePro();
        }
        // 22.LoRaWAN网关
        if (productKey.equals(IotProductEnum.LORAWAN_GATEWAY.getValue())) {
            deviceBasePro = new LoRaWANDevicePro();
        }
        // 设置 clazz属性
        if (deviceBasePro != null) {
            deviceBasePro.setClazz(deviceBasePro.getClass().getName());
        }
        return deviceBasePro;
    }

    /**
     * 创建对象属性处理器
     * @param productKey 产品key
     * @return
     */
    public static DeviceHandleBasePropertyValue createDeviceHandle(String productKey) {
        DeviceHandleBasePropertyValue handle = null;
        // 13.土壤温湿度传感器
        if (productKey.equals(IotProductEnum.SOIL_HUMIDITY_DEVICE.getValue())) {
            handle = new SoilHumidityHandleImpl();
        }
        // 14.阀门控制器
        if (productKey.equals(IotProductEnum.VALVE_CONTROLLER_DEVICE.getValue())) {
            handle = new ValveControllerHandleImpl();
        }
        return handle;
    }

}