| | |
| | | import com.google.gson.JsonObject; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.hdl.linkpm.sdk.core.exception.HDLException; |
| | | import com.hdl.linkpm.sdk.home.type.GatewayType; |
| | | import com.hdl.photovoltaic.config.AppConfigManage; |
| | | import com.hdl.photovoltaic.config.UserConfigManage; |
| | | import com.hdl.photovoltaic.internet.HttpClient; |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | |
| | | import io.dcloud.common.adapter.util.DeviceInfo; |
| | | |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * 添加多个逆变器到云端上 |
| | | * |
| | | * @param mac - |
| | | * @param cloudCallBeak - |
| | | */ |
| | | public void addAllInverterDeviceToCloud(String homeId, String mac, List<GatewayBean> list, CloudCallBeak<Boolean> cloudCallBeak) { |
| | | |
| | | String requestUrl = HttpApi.POST_Device_Add_All; |
| | | JsonObject json = new JsonObject(); |
| | | json.addProperty("homeId", homeId); |
| | | JsonArray ary = new JsonArray(); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | GatewayBean gatewayBean=list.get(i); |
| | | JsonObject inverterInfo = new JsonObject(); |
| | | inverterInfo.addProperty("mac",gatewayBean.getDevice_mac()); |
| | | inverterInfo.addProperty("spk",gatewayBean.getGatewayType()); |
| | | inverterInfo.addProperty("sid",gatewayBean.getSid()); |
| | | inverterInfo.addProperty("oid",gatewayBean.getOid()); |
| | | inverterInfo.addProperty("name",gatewayBean.getDevice_name()); |
| | | ary.add(inverterInfo); |
| | | } |
| | | json.add("devices", ary); |
| | | // json.addProperty("zoneType", "password");//区域 |
| | | |
| | | HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() { |
| | | @Override |
| | | public void onSuccess(String str) { |
| | | if (cloudCallBeak != null) { |
| | | cloudCallBeak.onSuccess(true); |
| | | //临时的逻辑,上传oid列表到云端 |
| | | uploadDataToCloud(UserConfigManage.getInstance().getHomeId(), mac, null); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | if (cloudCallBeak != null) { |
| | | cloudCallBeak.onFailure(e); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 获取云端逆变器列表 |
| | | * |
| | | * @param homeId 住宅id |