From 83c12d3f28e5c43ecda8eca20cecb68bb0c58e87 Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期三, 09 十月 2024 11:12:03 +0800
Subject: [PATCH] 2024年10月09日11:12:01
---
app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java | 441 +++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 362 insertions(+), 79 deletions(-)
diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
index ae214d1..fbc9de8 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
@@ -10,7 +10,6 @@
import android.location.Location;
import android.location.LocationManager;
import android.os.IBinder;
-import android.print.PageRange;
import android.provider.Settings;
import android.text.TextUtils;
@@ -36,16 +35,18 @@
import com.hdl.photovoltaic.config.UserConfigManage;
import com.hdl.photovoltaic.internet.HttpServer.MyNanoHttpServer;
import com.hdl.photovoltaic.internet.TcpClient;
-import com.hdl.photovoltaic.internet.api.HttpApi;
import com.hdl.photovoltaic.internet.api.TopicApi;
import com.hdl.photovoltaic.listener.CloudCallBeak;
import com.hdl.photovoltaic.listener.LinkCallBack;
import com.hdl.photovoltaic.ui.bean.CUserInfo;
import com.hdl.photovoltaic.ui.bean.CloudInverterDeviceBean;
+import com.hdl.photovoltaic.ui.bean.DeviceInfoBean;
import com.hdl.photovoltaic.ui.bean.DeviceTimeBean;
import com.hdl.photovoltaic.ui.bean.Geolocation;
+import com.hdl.photovoltaic.ui.bean.HouseIdBean;
import com.hdl.photovoltaic.ui.bean.LinkBean;
import com.hdl.photovoltaic.ui.bean.MemberBean;
+import com.hdl.photovoltaic.ui.bean.NotRunBean;
import com.hdl.photovoltaic.ui.bean.OidBean;
import com.hdl.photovoltaic.ui.bean.StaffBean;
import com.hdl.photovoltaic.ui.bean.UnCountBean;
@@ -70,7 +71,6 @@
import com.hdl.sdk.link.core.connect.HDLModBusConnect;
import com.hdl.sdk.link.core.connect.HDLUdpConnect;
import com.hdl.sdk.link.gateway.HDLLinkLocalGateway;
-import com.huawei.hms.api.Api;
import org.greenrobot.eventbus.EventBus;
import org.json.JSONObject;
@@ -153,11 +153,13 @@
break;
//鐢ㄦ埛鏈湴缂撳瓨淇℃伅
case HDLUniMP.UNI_EVENT_REPLY_USER_LOCAL_INFO: {
+ HdlLogLogic.print("鏈湴澶村儚璺緞---->>>" + UserConfigManage.getInstance().getUserImageUrl());
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("user_name", UserConfigManage.getInstance().getUserName());
jsonObject.addProperty("user_image_url", UserConfigManage.getInstance().getUserImageUrl());
jsonObject.addProperty("user_account", UserConfigManage.getInstance().getAccount());
uniSuccessCallback(mode_type, jsonObject, callback);
+
}
break;
}
@@ -165,44 +167,80 @@
} else if (HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL.equals(topic)) {
//浣忓畢妯″潡
switch (type) {
+ //鎵爜娣诲姞鐢电珯
+ case HDLUniMP.UNI_EVENT_REPLY_HOME_ADD: {
+ String url = getKeyValue("url", getKeyValue("data", data));
+ //EventBus浜嬩欢鍒嗗彂
+ HdlCommonLogic.getInstance().postEventBusSticky(
+ HDLUniMP.UNI_EVENT_REPLY_HOME_ADD,
+ HDLUniMP.UNI_EVENT_REPLY_HOME_ADD,
+ url);
+
+ if (callback != null) {
+ uniSuccessCallback(type, null, callback);
+ }
+ }
+ break;
+ //璐﹀彿涓嬫槸鍚︽湁鐢电珯鍒楄〃
+ case HDLUniMP.UNI_EVENT_REPLY_HOME_LIST: {
+ if (callback != null) {
+ uniSuccessCallback(type, HdlResidenceLogic.getInstance().getHouseIdList().size(), callback);
+ }
+ }
+ break;
//鍒涘缓鐢电珯
case HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION: {
//EventBus浜嬩欢鍒嗗彂
- BaseEventBus baseEventBus = new BaseEventBus();
- baseEventBus.setTopic(HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL);
- baseEventBus.setType(HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION);
- baseEventBus.setData(getKeyValue("data", data));
- EventBus.getDefault().post(baseEventBus);
+ HdlCommonLogic.getInstance().postEventBus(
+ HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL,
+ HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION,
+ getKeyValue("data", data));
+ if (callback != null) {
+ uniSuccessCallback(type, null, callback);
+ }
}
+
break;
//璇诲彇璇︽儏
case HDLUniMP.UNI_EVENT_REPLY_HOME_DETAILS: {
-
+ if (callback != null) {
+ uniSuccessCallback(type, null, callback);
+ }
+ }
+ break;
+ //鐢电珯鍒犻櫎
+ case HDLUniMP.UNI_EVENT_REPLY_HOME_DEl: {
+ this.uniGetDelResidence(mode_type, data, callback);
}
break;
//鍏抽棴璇︽儏椤�
case HDLUniMP.UNI_EVENT_REPLY_HOME_CLOSE_HOME_DETAILS_PAGE: {
//EventBus浜嬩欢鍒嗗彂
- BaseEventBus baseEventBus = new BaseEventBus();
- baseEventBus.setType(HDLUniMP.UNI_EVENT_REPLY_HOME_CLOSE_HOME_DETAILS_PAGE);
- baseEventBus.setData(getKeyValue("data", data));
- EventBus.getDefault().post(baseEventBus);
+ // todo 鍦℉DLUniMPSDKManager绫婚噷闈㈡湁鏂规硶()鐩戝惉鍒板皬绋嬪簭鍏抽棴锛岀劧鍚庡彂甯冭皟鐢‥ventBus鍙戝竷鍑哄幓;
+// HdlCommonLogic.getInstance().postEventBus(
+// HDLUniMP.UNI_EVENT_REPLY_HOME_CLOSE_HOME_DETAILS_PAGE,
+// LowerTagType.power_station.toString(),
+// getKeyValue("data", data));
+ if (callback != null) {
+ uniSuccessCallback(type, null, callback);
+ }
}
break;
//浣忓畢銆愮數绔欍�戠紪杈�
case HDLUniMP.UNI_EVENT_REPLY_HOME_EDIT: {
//EventBus浜嬩欢鍒嗗彂
- BaseEventBus baseEventBus = new BaseEventBus();
- baseEventBus.setTopic(HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL);
- baseEventBus.setType(HDLUniMP.UNI_EVENT_REPLY_HOME_EDIT);
- baseEventBus.setData(getKeyValue("data", data));
- EventBus.getDefault().post(baseEventBus);
+ HdlCommonLogic.getInstance().postEventBus(
+ HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL,
+ HDLUniMP.UNI_EVENT_REPLY_HOME_EDIT,
+ getKeyValue("data", data));
+ if (callback != null) {
+ uniSuccessCallback(type, null, callback);
+ }
}
break;
//鐢电珯鐨勪氦浠樹簩缁寸爜(瀹夎鍟�)
case HDLUniMP.UNI_EVENT_REPLY_HOME_DELIVERYURLQRCODE: {
uniGetDeliveryUrlQrcode(type, data, callback);
-
}
break;
//鐢电珯鎵嬪姩浜や粯(瀹夎鍟�)
@@ -219,9 +257,7 @@
break;
}
- if (callback != null) {
- uniSuccessCallback(type, null, callback);
- }
+
} else if (HDLUniMP.UNI_EVENT_REPLY_DEVICE_MODEL.equals(topic)) {
//璁惧妯″潡
switch (type) {
@@ -308,6 +344,21 @@
//璁惧鍚嶇О淇敼(淇敼鏄簯绔痮id鍚嶇О锛岃澶囦娇鐢╩odbus鍗忚淇敼)
case HDLUniMP.UNI_EVENT_REPLY_DEVICE_EDIT_NAME: {
this.uniOidEditName(mode_type, data, callback);
+ }
+ break;
+ //鑾峰彇鏈繍琛岄�嗗彉鍣ㄥ垪琛�
+ case HDLUniMP.UNI_EVENT_REPLY_DEVICE_NOT_RUN_DEVICE_LIST: {
+ this.uniGetListNotRun(mode_type, data, callback);
+ }
+ break;
+ //蹇嵎寮�鍚�嗗彉鍣�
+ case HDLUniMP.UNI_EVENT_REPLY_DEVICE_OPEN_DEVICE_LIST: {
+ this.uniSetDeviceStartup(mode_type, data, callback);
+ }
+ break;
+ //鑾峰彇璁惧璇︽儏
+ case HDLUniMP.UNI_EVENT_REPLY_DEVICE_OPEN_DEVICE_info: {
+ this.uniGetDeviceInfo(mode_type, data, callback);
}
break;
}
@@ -469,9 +520,17 @@
break;
//娑堟伅涓績
case HDLUniMP.UNI_EVENT_REPLY_MINE_MESSAGE_CENTER: {
+ String homeId = getKeyValue("homeId", getKeyValue("data", data));
+ String isShowFault = getKeyValue("isShowFault", getKeyValue("data", data));
Intent intent = new Intent();
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setClass(HDLApp.getInstance(), MessageCenterList.class);
+ if (!TextUtils.isEmpty(homeId)) {
+ intent.putExtra("homeId", homeId);
+ }
+ if (!TextUtils.isEmpty(isShowFault)) {
+ intent.putExtra("isShowFault", isShowFault);
+ }
HDLApp.getInstance().startActivity(intent);
}
break;
@@ -489,6 +548,12 @@
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setClass(HDLApp.getInstance(), SetActivity.class);
HDLApp.getInstance().startActivity(intent);
+
+ }
+ break;
+ //涓嬭浇鎴愬憳锛堝瓙璐﹀彿锛夊ご鍍�
+ case HDLUniMP.UNI_EVENT_REPLY_DOWNLOAD_MEMBER_AVATAR: {
+ uniGetHeadPIortrait(type, data, callback);
}
break;
@@ -525,6 +590,13 @@
}
break;
+ //鍛樺伐璇︽儏鑾峰彇
+ case HDLUniMP.UNI_EVENT_REPLY_STAFF_DETAIL: {
+ uniGetStaffInfo(type, data, callback);
+
+ }
+
+ break;
//鍛樺伐鍒犻櫎
case HDLUniMP.UNI_EVENT_REPLY_STAFF_DELETE: {
@@ -539,7 +611,7 @@
}
break;
//鑾峰彇褰撳墠璐﹀彿鍦ㄥ叕鍙哥殑韬唤
- case HDLUniMP.UNI_EVENT_REPLY_USERRIGHTTYPe: {
+ case HDLUniMP.UNI_EVENT_REPLY_USERRIGHTTYP: {
uniGetUserRightType(type, data, callback);
}
@@ -613,12 +685,6 @@
HdlLogLogic.print("uni---缁勮uni鍙戦�佹暟鎹牸寮�---" + json, false);
}
- public void openUniMPDelay(String path, JSONObject jsonObject) {
- JSONObject json = this.createdJSONObject(jsonObject, true);
- HDLUniMPSDKManager.getInstance().openUniMPDelay(HDLUniMP.UNI_APP_ID, path, json, HdlUniLogic.this);
- HdlLogLogic.print("uni---缁勮uni鍙戦�佹暟鎹牸寮�---" + json, false);
- }
-
/**
* 鍘熺敓銆愪富鍔ㄣ�戝悜灏忕▼搴忓彂閫侀�氱煡浜嬩欢
* 娉ㄦ剰锛氶渶瑕佹彁鍓嶅皬绋嬪簭鍦ㄨ繍琛屾墠鍙垚鍔�
@@ -643,6 +709,63 @@
//endregion
//region ******uni鎺ュ彛鏂规硶******
+
+ /**
+ * 鐢电珯鍒犻櫎
+ */
+ private void uniGetDelResidence(String type, Object data, DCUniMPJSCallback callback) {
+
+
+ String homeId = getKeyValue("homeId", getKeyValue("data", data));
+ HdlResidenceLogic.getInstance().delResidence(homeId, new CloudCallBeak<Boolean>() {
+ @Override
+ public void onSuccess(Boolean obj) {
+ if (callback != null) {
+ uniSuccessCallback(type, null, callback);
+ }
+ List<GatewayBean> list = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(homeId);
+ for (int i = 0; i < list.size(); i++) {
+ GatewayBean gatewayBean = list.get(i);
+ HdlDeviceLogic.getInstance().initializeInverter(gatewayBean.getDevice_mac(), null);
+ }
+ list.clear();//娓呯┖缂撳瓨;
+// HDLLinkLocalGateway.getInstance().getGatewayList().clear();
+ HdlResidenceLogic.getInstance().delHouseId(homeId);//鍒犻櫎鐢电珯缂撳瓨
+ if (UserConfigManage.getInstance().isBAccount()) {
+ //B绔�
+ //鏀跺埌鎴愬姛缁撴灉鍝嶅簲鍚�,浼氳嚜鍔ㄥ叧闂皬绋嬪簭锛屽湪HDLUniMPSDKManager绫婚噷闈㈡湁鏂规硶()鐩戝惉鍒板皬绋嬪簭鍏抽棴锛岀洃鍚埌灏忕▼搴忓叧闂簨浠跺悗锛屼細閲嶆柊鑾峰彇鐢电珯鍒楄〃杩涜鍒风晫闈紱
+ if (null != HDLUniMPSDKManager.getInstance().getUniMP()) {
+ HDLUniMPSDKManager.getInstance().getUniMP().closeUniMP();
+ }
+ } else {
+ //C绔�
+ List<HouseIdBean> HouseIdList = HdlResidenceLogic.getInstance().getHouseIdList();
+ if (HouseIdList.size() == 0) {
+ String path = HDLUniMP.UNI_EVENT_OPEN_HOME_Null_C;
+ HdlUniLogic.getInstance().openUniMP(path, null);
+ } else {
+ HouseIdBean houseIdBean = HouseIdList.get(0);//榛樿鎷跨涓�涓�
+ HdlResidenceLogic.getInstance().switchHouse(houseIdBean);
+ JsonObject jsonObject = new JsonObject();
+ jsonObject.addProperty("homeId", houseIdBean.getHomeId());
+ jsonObject.addProperty("homeName", houseIdBean.getHomeName());
+ jsonObject.addProperty("powerStationStatus", houseIdBean.getPowerStationStatus() + "");
+ HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean();
+ uniCallBackBaseBean.setType(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_REFRESH_DETAILS);
+ uniCallBackBaseBean.setData(jsonObject);
+ HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean);
+ }
+
+
+ }
+ }
+
+ @Override
+ public void onFailure(HDLException e) {
+ uniExceptionCallback(type, e, callback);
+ }
+ });
+ }
/**
* 鐢电珯鎺堟潈瀹夎鍟�(C绔�)
@@ -677,6 +800,10 @@
@Override
public void onSuccess(Boolean obj) {
uniSuccessCallback(type, obj, callback);
+ //鏀跺埌鎴愬姛缁撴灉鍝嶅簲鍚�,浼氳嚜鍔ㄥ叧闂皬绋嬪簭锛屽湪HDLUniMPSDKManager绫婚噷闈㈡湁鏂规硶()鐩戝惉鍒板皬绋嬪簭鍏抽棴锛岀洃鍚埌灏忕▼搴忓叧闂簨浠跺悗锛屼細閲嶆柊鑾峰彇鐢电珯鍒楄〃杩涜鍒风晫闈紱
+ if (null != HDLUniMPSDKManager.getInstance().getUniMP()) {
+ HDLUniMPSDKManager.getInstance().getUniMP().closeUniMP();
+ }
}
@Override
@@ -728,10 +855,10 @@
*/
private void uniGetStaffEdit(String type, Object data, DCUniMPJSCallback callback) {
StaffBean staffBean = new StaffBean();
- String member_info = getKeyValue("staffInfo", getKeyValue("data", data));
- if (!TextUtils.isEmpty(member_info)) {
+ String staffInfo = getKeyValue("staffInfo", getKeyValue("data", data));
+ if (!TextUtils.isEmpty(staffInfo)) {
try {
- staffBean = new Gson().fromJson(member_info, StaffBean.class);
+ staffBean = new Gson().fromJson(staffInfo, StaffBean.class);
} catch (Exception ignored) {
}
}
@@ -749,14 +876,14 @@
}
/**
- * 鍛樺伐娣诲姞
+ * 鍛樺伐鍒犻櫎
*/
private void uniGetStaffDelete(String type, Object data, DCUniMPJSCallback callback) {
StaffBean staffBean = new StaffBean();
- String member_info = getKeyValue("staffInfo", getKeyValue("data", data));
- if (!TextUtils.isEmpty(member_info)) {
+ String staffInfo = getKeyValue("staffInfo", getKeyValue("data", data));
+ if (!TextUtils.isEmpty(staffInfo)) {
try {
- staffBean = new Gson().fromJson(member_info, StaffBean.class);
+ staffBean = new Gson().fromJson(staffInfo, StaffBean.class);
} catch (Exception ignored) {
}
}
@@ -778,10 +905,10 @@
*/
private void uniGetStaffAdd(String type, Object data, DCUniMPJSCallback callback) {
StaffBean staffBean = new StaffBean();
- String member_info = getKeyValue("staffInfo", getKeyValue("data", data));
- if (!TextUtils.isEmpty(member_info)) {
+ String staffInfo = getKeyValue("staffInfo", getKeyValue("data", data));
+ if (!TextUtils.isEmpty(staffInfo)) {
try {
- staffBean = new Gson().fromJson(member_info, StaffBean.class);
+ staffBean = new Gson().fromJson(staffInfo, StaffBean.class);
} catch (Exception ignored) {
}
}
@@ -799,15 +926,14 @@
}
/**
- * 鑾峰彇鍛樺伐鍒楄〃
+ * 鑾峰彇鍛樺伐璇︽儏
*/
- private void uniGetStaffList(String type, Object data, DCUniMPJSCallback callback) {
- long pageNo = Long.parseLong(getKeyValue("pageNo", getKeyValue("data", data)));
- long pageSize = Long.parseLong(getKeyValue("pageSize", getKeyValue("data", data)));
- HdlMemberLogic.getInstance().getStaffList(pageNo, pageSize, new CloudCallBeak<PageNumberObject<List<StaffBean>>>() {
+ private void uniGetStaffInfo(String type, Object data, DCUniMPJSCallback callback) {
+ String userId = getKeyValue("userId", getKeyValue("data", data));
+ HdlMemberLogic.getInstance().getStaffInfo(userId, new CloudCallBeak<StaffBean>() {
@Override
- public void onSuccess(PageNumberObject<List<StaffBean>> obj) {
- uniSuccessCallback(type, obj.getList(), callback);
+ public void onSuccess(StaffBean obj) {
+ uniSuccessCallback(type, obj, callback);
}
@Override
@@ -818,14 +944,34 @@
}
/**
+ * 鑾峰彇鍛樺伐鍒楄〃
+ */
+ private void uniGetStaffList(String type, Object data, DCUniMPJSCallback callback) {
+ long pageNo = Long.parseLong(getKeyValue("pageNo", getKeyValue("data", data)));
+ long pageSize = Long.parseLong(getKeyValue("pageSize", getKeyValue("data", data)));
+ HdlMemberLogic.getInstance().getStaffList(pageNo, pageSize, new CloudCallBeak<PageNumberObject<StaffBean>>() {
+ @Override
+ public void onSuccess(PageNumberObject<StaffBean> obj) {
+ uniSuccessCallback(type, obj.getList(), callback);
+ }
+
+ @Override
+ public void onFailure(HDLException e) {
+ uniExceptionCallback(type, e, callback);
+ }
+ });
+ }
+
+
+ /**
* 鎴愬憳缂栬緫
*/
private void uniGetMemberEdit(String type, Object data, DCUniMPJSCallback callback) {
MemberBean memberBean = new MemberBean();
- String member_info = getKeyValue("memberInfo", getKeyValue("data", data));
- if (!TextUtils.isEmpty(member_info)) {
+ String memberInfo = getKeyValue("memberInfo", getKeyValue("data", data));
+ if (!TextUtils.isEmpty(memberInfo)) {
try {
- memberBean = new Gson().fromJson(member_info, MemberBean.class);
+ memberBean = new Gson().fromJson(memberInfo, MemberBean.class);
} catch (Exception ignored) {
}
}
@@ -847,10 +993,10 @@
*/
private void uniGetMemberDelete(String type, Object data, DCUniMPJSCallback callback) {
MemberBean memberBean = new MemberBean();
- String member_info = getKeyValue("memberInfo", getKeyValue("data", data));
- if (!TextUtils.isEmpty(member_info)) {
+ String memberInfo = getKeyValue("memberInfo", getKeyValue("data", data));
+ if (!TextUtils.isEmpty(memberInfo)) {
try {
- memberBean = new Gson().fromJson(member_info, MemberBean.class);
+ memberBean = new Gson().fromJson(memberInfo, MemberBean.class);
} catch (Exception ignored) {
}
}
@@ -872,16 +1018,42 @@
*/
private void uniGetMemberAdd(String type, Object data, DCUniMPJSCallback callback) {
MemberBean memberBean = new MemberBean();
- String member_info = getKeyValue("memberInfo", getKeyValue("data", data));
- if (!TextUtils.isEmpty(member_info)) {
+ String memberInfo = getKeyValue("memberInfo", getKeyValue("data", data));
+ if (!TextUtils.isEmpty(memberInfo)) {
try {
- memberBean = new Gson().fromJson(member_info, MemberBean.class);
+ memberBean = new Gson().fromJson(memberInfo, MemberBean.class);
} catch (Exception ignored) {
}
}
HdlMemberLogic.getInstance().getMemberAdd(memberBean, new CloudCallBeak<Boolean>() {
@Override
public void onSuccess(Boolean obj) {
+ uniSuccessCallback(type, obj, callback);
+ }
+
+ @Override
+ public void onFailure(HDLException e) {
+ uniExceptionCallback(type, e, callback);
+ }
+ });
+ }
+
+ /**
+ * 涓嬭浇鎴愬憳锛堝瓙璐﹀彿锛夊ご鍍�
+ */
+ private void uniGetHeadPIortrait(String type, Object data, DCUniMPJSCallback callback) {
+ MemberBean memberBean = new MemberBean();
+ String memberInfo = getKeyValue("memberInfo", getKeyValue("data", data));
+ if (!TextUtils.isEmpty(memberInfo)) {
+ try {
+ memberBean = new Gson().fromJson(memberInfo, MemberBean.class);
+ } catch (Exception ignored) {
+ }
+ }
+
+ HdlMemberLogic.getInstance().getHeadPIortrait(memberBean, new CloudCallBeak<byte[]>() {
+ @Override
+ public void onSuccess(byte[] obj) {
uniSuccessCallback(type, obj, callback);
}
@@ -1023,7 +1195,9 @@
*/
private void uniGetCurrentDeviceFirmwares(String type, Object data, DCUniMPJSCallback callback) {
String deviceOidId = getKeyValue("deviceOidId", getKeyValue("data", data));//浜戠涓婅澶噄d
- HdlOtaLogic.getInstance().getCurrentDeviceFirmwares(deviceOidId, new CloudCallBeak<List<DeviceFirmwareBean>>() {
+ String oid = getKeyValue("oid", getKeyValue("data", data));//璁惧oid
+ String homeId = getKeyValue("homeId", getKeyValue("data", data));//鐢电珯id
+ HdlOtaLogic.getInstance().getCurrentDeviceFirmwares(deviceOidId, oid, homeId, new CloudCallBeak<List<DeviceFirmwareBean>>() {
@Override
public void onSuccess(List<DeviceFirmwareBean> obj) {
uniSuccessCallback(type, obj, callback);
@@ -1274,7 +1448,8 @@
*/
private void uniGetCurrentGatewayDrivers(String type, Object data, DCUniMPJSCallback callback) {
String deviceOid = getKeyValue("oid", getKeyValue("data", data));
- HdlOtaLogic.getInstance().getCurrentGatewayDrivers(deviceOid, new CloudCallBeak<List<GatewayDriverBean>>() {
+ String homeId = getKeyValue("homeId", getKeyValue("data", data));//鐢电珯id
+ HdlOtaLogic.getInstance().getCurrentGatewayDrivers(deviceOid, homeId, new CloudCallBeak<List<GatewayDriverBean>>() {
@Override
public void onSuccess(List<GatewayDriverBean> obj) {
uniSuccessCallback(type, obj, callback);
@@ -1603,21 +1778,29 @@
if (cUserInfo == null) {
return;
}
- UserConfigManage.getInstance().setBingPhone(cUserInfo.getMemberPhone());
- UserConfigManage.getInstance().setBingEmail(cUserInfo.getMemberEmail());
- UserConfigManage.getInstance().Save();
+
//鑾峰彇鐢ㄦ埛澶村儚璺緞
if (cUserInfo.getMemberHeadIcon().contains("http")) {
- UserConfigManage.getInstance().setUserImageUrl(cUserInfo.getMemberHeadIcon());
//鏇存柊鐢ㄦ埛澶村儚
uniSuccessCallback(type, cUserInfo, callback);
+ UserConfigManage.getInstance().setUserName(cUserInfo.getMemberName());
+ UserConfigManage.getInstance().setBingPhone(cUserInfo.getMemberPhone());
+ UserConfigManage.getInstance().setBingEmail(cUserInfo.getMemberEmail());
+ UserConfigManage.getInstance().setUserImageUrl(cUserInfo.getMemberHeadIcon());
+ UserConfigManage.getInstance().Save();
+ HdlLogLogic.print("澶村儚璺緞---->>>" + cUserInfo.getMemberHeadIcon());
} else {
HdlAccountLogic.getInstance().getImageKey_C(cUserInfo.getMemberHeadIcon(), new CloudCallBeak<String>() {
@Override
public void onSuccess(String url) {
cUserInfo.setMemberHeadIcon(url);
- UserConfigManage.getInstance().setUserImageUrl(cUserInfo.getMemberHeadIcon());
uniSuccessCallback(type, cUserInfo, callback);
+ UserConfigManage.getInstance().setUserName(cUserInfo.getMemberName());
+ UserConfigManage.getInstance().setBingPhone(cUserInfo.getMemberPhone());
+ UserConfigManage.getInstance().setBingEmail(cUserInfo.getMemberEmail());
+ UserConfigManage.getInstance().setUserImageUrl(cUserInfo.getMemberHeadIcon());
+ UserConfigManage.getInstance().Save();
+ HdlLogLogic.print("澶村儚璺緞---->>>" + cUserInfo.getMemberHeadIcon());
}
@Override
@@ -1876,6 +2059,22 @@
@Override
public void onFailure(HDLException e) {
+ //娣诲姞閫嗗彉鍣ㄥけ璐ュ悗鍒濆鍖栭�嗗彉鍣�
+ HdlLogLogic.print("娣诲姞閫嗗彉鍣ㄥけ璐ュ悗寮�濮嬪垵濮嬪寲閫嗗彉鍣�-->", true);
+ for (int i = 0; i < list.size(); i++) {
+ GatewayBean gatewayBean = list.get(i);
+ HdlDeviceLogic.getInstance().initializeInverter(gatewayBean.getDevice_mac(), new LinkCallBack<Boolean>() {
+ @Override
+ public void onSuccess(Boolean obj) {
+ HdlLogLogic.print("鍒濆鍖栭�嗗彉鍣ㄦ垚鍔�-->mac:" + gatewayBean.getDevice_mac(), true);
+ }
+
+ @Override
+ public void onError(HDLLinkException e) {
+ HdlLogLogic.print("鍒濆鍖栭�嗗彉鍣ㄥけ璐�-->mac:" + gatewayBean.getDevice_mac(), true);
+ }
+ });
+ }
uniCallbackData(type, null, e.getCode(), e.getMsg(), callback);
}
});
@@ -1915,18 +2114,38 @@
private void uniDelInverterDevice(String type, Object data, DCUniMPJSCallback callback) {
String deviceId = getKeyValue("deviceId", getKeyValue("data", data));
String homeId = getKeyValue("homeId", getKeyValue("data", data));
- if (TextUtils.isEmpty(homeId)) {
- homeId = UserConfigManage.getInstance().getHomeId();
- }
+ String mac = getKeyValue("mac", getKeyValue("data", data));
HdlDeviceLogic.getInstance().delInverterDevice(homeId, deviceId, new CloudCallBeak<Boolean>() {
@Override
public void onSuccess(Boolean obj) {
+ //鍒濆鍖栭�嗗彉鍣ㄨ澶�
+ HdlDeviceLogic.getInstance().initializeInverter(mac, null);
+ //绉婚櫎鏈湴缂撳瓨
+ HdlDeviceLogic.getInstance().removeLocalCacheMemoryGatewayToDeviceId(homeId, deviceId);
uniSuccessCallback(type, null, callback);
}
@Override
public void onFailure(HDLException e) {
- uniCallbackData(type, null, e.getCode(), e.getMsg(), callback);
+ if (e.getCode() == 121005) {
+ //璁惧涓嶅瓨鍦紙121005锛夌姸鎬佺爜
+ //鍒濆鍖栭�嗗彉鍣ㄨ澶�
+ HdlDeviceLogic.getInstance().initializeInverter(mac, new LinkCallBack<Boolean>() {
+ @Override
+ public void onSuccess(Boolean obj) {
+ //绉婚櫎鏈湴缂撳瓨
+ HdlDeviceLogic.getInstance().removeLocalCacheMemoryGatewayToDeviceId(homeId, deviceId);
+ uniSuccessCallback(type, null, callback);
+ }
+
+ @Override
+ public void onError(HDLLinkException e) {
+ uniCallbackData(type, null, e.getCode(), e.getMsg(), callback);
+ }
+ });
+ } else {
+ uniCallbackData(type, null, e.getCode(), e.getMsg(), callback);
+ }
}
});
}
@@ -1966,19 +2185,14 @@
HdlDeviceLogic.getInstance().getCurrentHomeLocalAndCloudGatewayList(homeId, new CloudCallBeak<List<GatewayBean>>() {
@Override
public void onSuccess(List<GatewayBean> list) {
- if (list == null || list.size() == 0) {
- if (callback != null) {
- uniSuccessCallback(type, list, callback);
- }
- return;
- }
if (callback != null) {
uniSuccessCallback(type, list, callback);
}
//EventBus浜嬩欢鍒嗗彂,杩涘叆浣忓畢寮�濮嬭闃呬富棰�
BaseEventBus baseEventBus = new BaseEventBus();
+ baseEventBus.setTopic(HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST);
baseEventBus.setType(HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST);
- baseEventBus.setData(list);
+ baseEventBus.setData(homeId);
EventBus.getDefault().post(baseEventBus);
//杩涙潵浣忓畢璇︽儏閮借涓婁紶涓�娆id鍒楄〃鍒颁簯绔�;
HdlDeviceLogic.getInstance().uploadOidDataToCloud(homeId, list, false, null);
@@ -2146,7 +2360,7 @@
/**
* 鍒濆鍖栭�嗗彉鍣�
*
- * @param type 璐﹀彿
+ * @param type 绫诲瀷
* @param data uni璇锋眰鏁版嵁
* @param callback uni鍥炶皟
*/
@@ -2168,7 +2382,7 @@
/**
* 鍒濆鍖栭�嗗彉鍣�
*
- * @param type 璐﹀彿
+ * @param type 绫诲瀷
* @param data uni璇锋眰鏁版嵁
* @param callback uni鍥炶皟
*/
@@ -2215,7 +2429,7 @@
/**
* 淇敼璁惧鍚嶇О閫嗗彉鍣˙MS鐢垫睜鍖�
*
- * @param type 璐﹀彿
+ * @param type 绫诲瀷
* @param data uni璇锋眰鏁版嵁
* @param callback uni鍥炶皟
*/
@@ -2228,6 +2442,76 @@
@Override
public void onSuccess(Boolean obj) {
uniSuccessCallback(type, obj, callback);
+ }
+
+ @Override
+ public void onFailure(HDLException e) {
+ uniCallbackData(type, null, e.getCode(), e.getMsg(), callback);
+ }
+ });
+ }
+
+ /**
+ * 鑾峰彇鏈繍琛岄�嗗彉鍣ㄥ垪琛�
+ *
+ * @param type 绫诲瀷
+ * @param data uni璇锋眰鏁版嵁
+ * @param callback uni鍥炶皟
+ */
+ public void uniGetListNotRun(String type, Object data, DCUniMPJSCallback callback) {
+ String homeId = getKeyValue("homeId", getKeyValue("data", data));
+ HdlDeviceLogic.getInstance().getListNotRun(homeId, new CloudCallBeak<List<NotRunBean>>() {
+ @Override
+ public void onSuccess(List<NotRunBean> obj) {
+ uniSuccessCallback(type, obj, callback);
+ }
+
+ @Override
+ public void onFailure(HDLException e) {
+ uniCallbackData(type, null, e.getCode(), e.getMsg(), callback);
+ }
+ });
+ }
+
+ /**
+ * 閫嗗彉鍣ㄥ紑鏈�
+ *
+ * @param type 绫诲瀷
+ * @param data uni璇锋眰鏁版嵁
+ * @param callback uni鍥炶皟
+ */
+ public void uniSetDeviceStartup(String type, Object data, DCUniMPJSCallback callback) {
+ String homeId = getKeyValue("homeId", getKeyValue("data", data));
+ String aryJson = getKeyValue("deviceIds", getKeyValue("data", data));
+ JsonArray jsonArray = new Gson().fromJson(aryJson, JsonArray.class);
+ HdlDeviceLogic.getInstance().setDeviceStartup(homeId, jsonArray, new CloudCallBeak<Boolean>() {
+ @Override
+ public void onSuccess(Boolean obj) {
+ uniSuccessCallback(type, obj, callback);
+ }
+
+ @Override
+ public void onFailure(HDLException e) {
+ uniCallbackData(type, null, e.getCode(), e.getMsg(), callback);
+ }
+ });
+ }
+
+ /**
+ * 鑾峰彇璁惧璇︽儏
+ *
+ * @param type 绫诲瀷
+ * @param data uni璇锋眰鏁版嵁
+ * @param callback uni鍥炶皟
+ */
+ public void uniGetDeviceInfo(String type, Object data, DCUniMPJSCallback callback) {
+ String homeId = getKeyValue("homeId", getKeyValue("data", data));
+ String aryJson = getKeyValue("deviceIds", getKeyValue("data", data));
+ JsonArray jsonArray = new Gson().fromJson(aryJson, JsonArray.class);
+ HdlDeviceLogic.getInstance().getDeviceInfo(homeId, jsonArray, new CloudCallBeak<List<DeviceInfoBean>>() {
+ @Override
+ public void onSuccess(List<DeviceInfoBean> list) {
+ uniSuccessCallback(type, list, callback);
}
@Override
@@ -2353,12 +2637,11 @@
if (callback != null) {
callback.invoke(getJSONObject(uniCallBackBaseBean));
// callback.invoke(uniCallBackBaseBean);
- HdlLogLogic.print("uni---鍥炲---" + type + "---" + new Gson().toJson(uniCallBackBaseBean), true);
+ HdlLogLogic.print("鍥炲---uni---" + type + "---" + new Gson().toJson(uniCallBackBaseBean), true);
}
} catch (Exception e) {
- HdlLogLogic.print("uni---鍥炲---" + type + "---" + e.getMessage(), true);
+ HdlLogLogic.print("鍥炲---uni---" + type + "---" + e.getMessage(), true);
}
-
}
--
Gitblit v1.8.0