2024年03月11日20:54:25
备份一下代码
| | |
| | | public static final String POST_PowerStation_Info = "/home-wisdom/app/powerStation/info"; |
| | | //电站编辑 |
| | | public static final String POST_PowerStation_Edit = "/home-wisdom/app/powerStation/edit"; |
| | | //电站排序 |
| | | public static final String POST_PowerStation_UserSort = "/home-wisdom/app/powerStation/userSort"; |
| | | //endregion |
| | | |
| | | //region -----设备管理--------- |
| | | //添加逆变器 |
| | | public static final String POST_Device_Add = "/home-wisdom/program/device/independentRegister"; |
| | | //批量添加逆变器 |
| | | public static final String POST_Device_Add_All= "/home-wisdom/program/device/batchIndependentRegister"; |
| | | //获取逆变器列表 |
| | | public static final String POST_Device_List = "/home-wisdom/app/device/inverter/list"; |
| | | //删除逆变器 |
| | |
| | | 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 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 住宅(电站)移动位置 |
| | | * |
| | | * @param homeId 电站id |
| | | * @param frontHomeId 前面的电站id,如果不传表示排到第一位 |
| | | * @param cloudCallBeak - |
| | | */ |
| | | public void moveResidence(String homeId, String frontHomeId, CloudCallBeak<Boolean> cloudCallBeak) { |
| | | String requestUrl = HttpApi.POST_PowerStation_UserSort; |
| | | JsonObject json = new JsonObject(); |
| | | json.addProperty("homeId", homeId); |
| | | if (!TextUtils.isEmpty(frontHomeId)) { |
| | | json.addProperty("frontHomeId", frontHomeId); |
| | | } |
| | | // json.addProperty("zoneType", "zoneType"); |
| | | HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() { |
| | | @Override |
| | | public void onSuccess(String str) { |
| | | if (cloudCallBeak != null) { |
| | | cloudCallBeak.onSuccess(true); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | if (cloudCallBeak != null) { |
| | | cloudCallBeak.onFailure(e); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 删除住宅(电站) |
| | | * |
| | | * @param homeId - |
| | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.core.app.ActivityCompat; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.JsonObject; |
| | | import com.hdl.linkpm.sdk.core.exception.HDLException; |
| | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | |
| | | import io.dcloud.feature.unimp.DCUniMPJSCallback; |
| | | import okhttp3.ResponseBody; |
| | |
| | | case HDLUniMP.UNI_EVENT_REPLY_DEVICE_ADD: { |
| | | this.uniAddInverterDeviceToCloud(mode_type, data, callback); |
| | | } |
| | | //添加多个逆变器到云端 |
| | | case HDLUniMP.UNI_EVENT_REPLY_DEVICE_ADD_All: { |
| | | this.uniAddAllInverterDeviceToCloud(mode_type, data, callback); |
| | | } |
| | | |
| | | break; |
| | | //删除云端逆变器 |
| | | case HDLUniMP.UNI_EVENT_REPLY_DEVICE_DEL: { |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 逆变器添加到云端上 |
| | | * |
| | |
| | | } |
| | | |
| | | /** |
| | | * 多个逆变器添加到云端上 |
| | | * |
| | | * @param data uni数据 |
| | | * @param callback uni回调 |
| | | */ |
| | | private void uniAddAllInverterDeviceToCloud(String type, Object data, DCUniMPJSCallback callback) { |
| | | // com.alibaba.fastjson.JSONArray jsonArray = JSON.parseArray(data); |
| | | String mac = getKeyValue("mac", getKeyValue("data", data)); |
| | | String homeId = UserConfigManage.getInstance().getHomeId(); |
| | | GatewayBean gatewayBean = HDLLinkLocalGateway.getInstance().getLocalGateway(mac); |
| | | if (gatewayBean == null) { |
| | | uniCallbackData(type, null, -100, HDLApp.getInstance().getString(R.string.The_gateway_cannot_be_found_locally), callback); |
| | | |
| | | return; |
| | | } |
| | | List<GatewayBean> list = new ArrayList<>(); |
| | | //记录条数 |
| | | AtomicInteger atomicInteger = new AtomicInteger(0); |
| | | final boolean[] is_boolean = {false}; |
| | | for (int i = 0; i < list.size(); i++) { |
| | | |
| | | HdlDeviceLogic.getInstance().setGatewayRemoteParam(homeId, mac, new LinkCallBack<Boolean>() { |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | | HdlDeviceLogic.getInstance().editGatewayParam(mac, new LinkCallBack<Boolean>() { |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | | atomicInteger.set(atomicInteger.get() + 1); |
| | | //最后一条才做添加逆变器逻辑处理 |
| | | if (atomicInteger.get() == list.size()) { |
| | | HdlDeviceLogic.getInstance().addAllInverterDeviceToCloud(homeId, mac,list , new CloudCallBeak<Boolean>() { |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | | uniCallbackData(type, null, callback); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | uniCallbackData(type, null, e.getCode(), e.getMsg(), callback); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onError(HDLLinkException e) { |
| | | uniCallbackData(type, null, e.getCode(), e.getMsg(), callback); |
| | | is_boolean[0] = true; |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void onError(HDLLinkException e) { |
| | | uniCallbackData(type, null, e.getCode(), e.getMsg(), callback); |
| | | is_boolean[0] = true; |
| | | } |
| | | }); |
| | | if (is_boolean[0]) { |
| | | //只有中间有一条指令设置失败,默认全部失败; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 删除云端上逆变器 |
| | | * |
| | | * @param data uni数据 |
| | |
| | | |
| | | import android.Manifest; |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.content.pm.PackageManager; |
| | | import android.hardware.camera2.CameraManager; |
| | | import android.os.Bundle; |
| | |
| | | import com.hdl.photovoltaic.other.HdlUniLogic; |
| | | import com.hdl.photovoltaic.ui.adapter.HouseInfoAdapter; |
| | | import com.hdl.photovoltaic.ui.bean.HouseIdBean; |
| | | import com.hdl.photovoltaic.ui.newC.MessageCenterList; |
| | | import com.hdl.photovoltaic.ui.newC.PowerStationsListEdit; |
| | | import com.hdl.photovoltaic.uni.HDLUniMP; |
| | | import com.hdl.photovoltaic.utils.PermissionUtils; |
| | | import com.hdl.photovoltaic.widget.DelayedConfirmationCancelDialog; |
| | |
| | | |
| | | @Override |
| | | public void onMoveClick(int position, HouseIdBean houseIdBean) { |
| | | // HdlResidenceLogic.getInstance().delResidence(houseIdBean.getHomeId(), new CloudCallBeak<Boolean>() { |
| | | // @Override |
| | | // public void onSuccess(Boolean obj) { |
| | | //移动电站位置 |
| | | HdlResidenceLogic.getInstance().moveHouseId(houseIdBean.getHomeId()); |
| | | initData();//初始化缓存数据 |
| | | houseInfoAdapter.setList(houseListBeanIDList);//重新刷新列表 |
| | | nullDataUpdateUi(houseListBeanIDList);//检测数据是否为空 |
| | | // } |
| | | // |
| | | // @Override |
| | | // public void onFailure(HDLException e) { |
| | | // HdlThreadLogic.toast(_mActivity, e); |
| | | // } |
| | | // }); |
| | | String frontHomeId = ""; |
| | | if (position > 0) { |
| | | frontHomeId = houseListBeanIDList.get(position - 1).getHomeId(); |
| | | } |
| | | HdlResidenceLogic.getInstance().moveResidence(houseIdBean.getHomeId(), frontHomeId, new CloudCallBeak<Boolean>() { |
| | | @Override |
| | | public void onSuccess(Boolean obj) { |
| | | //移动电站位置 |
| | | HdlResidenceLogic.getInstance().moveHouseId(houseIdBean.getHomeId()); |
| | | initData();//初始化缓存数据 |
| | | houseInfoAdapter.setList(houseListBeanIDList);//重新刷新列表 |
| | | nullDataUpdateUi(houseListBeanIDList);//检测数据是否为空 |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | HdlThreadLogic.toast(_mActivity, e); |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | |
| | | public final static String UNI_EVENT_REPLY_DEVICE_NET_LIST = "net_list";//网络逆变器设备列表 |
| | | public final static String UNI_EVENT_REPLY_DEVICE_CHILD_LIST = "child_list";//逆变器【下挂】设备列表 |
| | | public final static String UNI_EVENT_REPLY_DEVICE_ADD = "add";//设备添加 |
| | | public final static String UNI_EVENT_REPLY_DEVICE_ADD_All = "add_all";//添加多个设备 |
| | | public final static String UNI_EVENT_REPLY_DEVICE_DEL = "del";//设备删除 |
| | | public final static String UNI_EVENT_REPLY_DEVICE_OID = "oid";//设备【包括下挂设备】oid列表 |
| | | public final static String UNI_EVENT_REPLY_DEVICE_TIME = "time";//设备时间读取 |