From c660f059d4e07a1b784442a1bbb4a5109b82e837 Mon Sep 17 00:00:00 2001
From: hxb <hxb@hdlchina.com.cn>
Date: 星期二, 25 六月 2024 09:51:45 +0800
Subject: [PATCH] Merge branch 'dev' of http://172.16.1.23:6688/r/~wjc/HDLPhotovoltaicDebugAPP into dev
---
app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java | 281 +++++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 227 insertions(+), 54 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 89379c6..0fdda0d 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
@@ -10,6 +10,7 @@
import android.location.Location;
import android.location.LocationManager;
import android.os.IBinder;
+import android.os.SystemClock;
import android.print.PageRange;
import android.provider.Settings;
import android.text.TextUtils;
@@ -33,7 +34,9 @@
import com.hdl.photovoltaic.bean.ModBusBean;
import com.hdl.photovoltaic.bean.PageNumberObject;
import com.hdl.photovoltaic.config.AppConfigManage;
+import com.hdl.photovoltaic.config.ConstantManage;
import com.hdl.photovoltaic.config.UserConfigManage;
+import com.hdl.photovoltaic.enums.LowerTagType;
import com.hdl.photovoltaic.internet.HttpServer.MyNanoHttpServer;
import com.hdl.photovoltaic.internet.TcpClient;
import com.hdl.photovoltaic.internet.api.HttpApi;
@@ -89,6 +92,7 @@
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
+import io.dcloud.feature.sdk.DCUniMPSDK;
import io.dcloud.feature.unimp.DCUniMPJSCallback;
import okhttp3.ResponseBody;
@@ -165,45 +169,91 @@
} 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_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;
+ //鐢电珯鎵嬪姩浜や粯(瀹夎鍟�)
+ case HDLUniMP.UNI_EVENT_REPLY_HOME_DELIVERTOACCOUNT: {
+ uniGetDeliverToAccount(type, data, callback);
+
+ }
+ break;
+ //鐢电珯鎺堟潈瀹夎鍟�(C绔�)
+ case HDLUniMP.UNI_EVENT_REPLY_HOME_UPDATEDEBUGPERM: {
+ uniHomeUpdateDebugPerm(type, data, callback);
+
}
break;
+
}
- if (callback != null) {
- uniSuccessCallback(type, null, callback);
- }
+
} else if (HDLUniMP.UNI_EVENT_REPLY_DEVICE_MODEL.equals(topic)) {
//璁惧妯″潡
switch (type) {
@@ -507,6 +557,13 @@
}
break;
+ //鍛樺伐璇︽儏鑾峰彇
+ case HDLUniMP.UNI_EVENT_REPLY_STAFF_DETAIL: {
+ uniGetStaffInfo(type, data, callback);
+
+ }
+
+ break;
//鍛樺伐鍒犻櫎
case HDLUniMP.UNI_EVENT_REPLY_STAFF_DELETE: {
@@ -595,12 +652,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);
- }
-
/**
* 鍘熺敓銆愪富鍔ㄣ�戝悜灏忕▼搴忓彂閫侀�氱煡浜嬩欢
* 娉ㄦ剰锛氶渶瑕佹彁鍓嶅皬绋嬪簭鍦ㄨ繍琛屾墠鍙垚鍔�
@@ -627,6 +678,106 @@
//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) {
+ 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);//鍒犻櫎鐢电珯缂撳瓨
+ //鏀跺埌鎴愬姛缁撴灉鍝嶅簲鍚�,浼氳嚜鍔ㄥ叧闂皬绋嬪簭锛屽湪HDLUniMPSDKManager绫婚噷闈㈡湁鏂规硶()鐩戝惉鍒板皬绋嬪簭鍏抽棴锛岀洃鍚埌灏忕▼搴忓叧闂簨浠跺悗锛屼細閲嶆柊鑾峰彇鐢电珯鍒楄〃杩涜鍒风晫闈紱
+ if (null != HDLUniMPSDKManager.getInstance().getUniMP()) {
+ HDLUniMPSDKManager.getInstance().getUniMP().closeUniMP();
+ }
+ if (!UserConfigManage.getInstance().isBAccount()) {
+ HdlCommonLogic.getInstance().postEventBus(HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL, HDLUniMP.UNI_EVENT_REPLY_HOME_DEl, homeId);
+ }
+ }
+
+ @Override
+ public void onFailure(HDLException e) {
+ uniExceptionCallback(type, e, callback);
+ }
+ });
+ }
+
+ /**
+ * 鐢电珯鎺堟潈瀹夎鍟�(C绔�)
+ */
+ private void uniHomeUpdateDebugPerm(String type, Object data, DCUniMPJSCallback callback) {
+
+
+ String homeId = getKeyValue("homeId", getKeyValue("data", data));
+ boolean debugPerm = Boolean.parseBoolean(getKeyValue("debugPerm", getKeyValue("data", data)));
+ HdlResidenceLogic.getInstance().homeUpdateDebugPerm(homeId, debugPerm, 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 uniGetDeliverToAccount(String type, Object data, DCUniMPJSCallback callback) {
+
+ String homeId = getKeyValue("homeId", getKeyValue("data", data));
+ String account = getKeyValue("account", getKeyValue("data", data));
+ HdlResidenceLogic.getInstance().getDeliverToAccount(homeId, account, new CloudCallBeak<Boolean>() {
+ @Override
+ public void onSuccess(Boolean obj) {
+ uniSuccessCallback(type, obj, callback);
+ //鏀跺埌鎴愬姛缁撴灉鍝嶅簲鍚�,浼氳嚜鍔ㄥ叧闂皬绋嬪簭锛屽湪HDLUniMPSDKManager绫婚噷闈㈡湁鏂规硶()鐩戝惉鍒板皬绋嬪簭鍏抽棴锛岀洃鍚埌灏忕▼搴忓叧闂簨浠跺悗锛屼細閲嶆柊鑾峰彇鐢电珯鍒楄〃杩涜鍒风晫闈紱
+ if (null != HDLUniMPSDKManager.getInstance().getUniMP()) {
+ HDLUniMPSDKManager.getInstance().getUniMP().closeUniMP();
+ }
+ }
+
+ @Override
+ public void onFailure(HDLException e) {
+ uniExceptionCallback(type, e, callback);
+ }
+ });
+
+ }
+
+ /**
+ * 鐢电珯鐨勪氦浠樹簩缁寸爜(瀹夎鍟�)
+ */
+ private void uniGetDeliveryUrlQrcode(String type, Object data, DCUniMPJSCallback callback) {
+ String homeId = getKeyValue("homeId", getKeyValue("data", data));
+ HdlResidenceLogic.getInstance().getDeliveryUrlQrcode(homeId, new CloudCallBeak<String>() {
+ @Override
+ public void onSuccess(String obj) {
+ uniSuccessCallback(type, obj, callback);
+ }
+
+ @Override
+ public void onFailure(HDLException e) {
+ uniExceptionCallback(type, e, callback);
+ }
+ });
+
+ }
+
+ /**
* 鑾峰彇褰撳墠璐﹀彿鍦ㄥ叕鍙哥殑韬唤
*/
private void uniGetUserRightType(String type, Object data, DCUniMPJSCallback callback) {
@@ -648,10 +799,10 @@
*/
private void uniGetStaffEdit(String type, Object data, DCUniMPJSCallback callback) {
StaffBean staffBean = new StaffBean();
- String member_info = getKeyValue("staff_info", 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) {
}
}
@@ -669,14 +820,14 @@
}
/**
- * 鍛樺伐娣诲姞
+ * 鍛樺伐鍒犻櫎
*/
private void uniGetStaffDelete(String type, Object data, DCUniMPJSCallback callback) {
StaffBean staffBean = new StaffBean();
- String member_info = getKeyValue("staff_info", 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) {
}
}
@@ -698,10 +849,10 @@
*/
private void uniGetStaffAdd(String type, Object data, DCUniMPJSCallback callback) {
StaffBean staffBean = new StaffBean();
- String member_info = getKeyValue("staff_info", 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) {
}
}
@@ -719,13 +870,14 @@
}
/**
- * 鑾峰彇鍛樺伐鍒楄〃
+ * 鑾峰彇鍛樺伐璇︽儏
*/
- private void uniGetStaffList(String type, Object data, DCUniMPJSCallback callback) {
- HdlMemberLogic.getInstance().getStaffList(1, 50, 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
@@ -736,14 +888,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("member_info", 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) {
}
}
@@ -765,10 +937,10 @@
*/
private void uniGetMemberDelete(String type, Object data, DCUniMPJSCallback callback) {
MemberBean memberBean = new MemberBean();
- String member_info = getKeyValue("member_info", 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) {
}
}
@@ -790,10 +962,10 @@
*/
private void uniGetMemberAdd(String type, Object data, DCUniMPJSCallback callback) {
MemberBean memberBean = new MemberBean();
- String member_info = getKeyValue("member_info", 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) {
}
}
@@ -1833,12 +2005,14 @@
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);
}
@@ -2271,12 +2445,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