From 6103f627eb0e5179fc725f631f277b2530432314 Mon Sep 17 00:00:00 2001 From: mac <user@users-MacBook-Pro.local> Date: 星期四, 20 六月 2024 15:40:44 +0800 Subject: [PATCH] 备份代码 --- app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java | 208 +++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 165 insertions(+), 43 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..70a53be 100644 --- a/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java +++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java @@ -33,7 +33,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; @@ -168,42 +170,72 @@ //鍒涘缓鐢电珯 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) { @@ -627,6 +659,96 @@ //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);//鍒犻櫎鐢电珯缂撳瓨 + //uni鏀跺埌鎴愬姛缁撴灉鍝嶅簲鍚�,浼氳嚜鍔ㄥ叧闂皬绋嬪簭锛屽湪HDLUniMPSDKManager绫婚噷闈㈡湁鏂规硶()鐩戝惉鍒板皬绋嬪簭鍏抽棴锛岀洃鍚埌灏忕▼搴忓叧闂簨浠跺悗锛屼細閲嶆柊鑾峰彇鐢电珯鍒楄〃杩涜鍒风晫闈紱 + uniSuccessCallback(type, obj, callback); + + } + + @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); + } + + @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 +770,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) { } } @@ -673,10 +795,10 @@ */ 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 +820,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) { } } @@ -722,7 +844,9 @@ * 鑾峰彇鍛樺伐鍒楄〃 */ private void uniGetStaffList(String type, Object data, DCUniMPJSCallback callback) { - HdlMemberLogic.getInstance().getStaffList(1, 50, new CloudCallBeak<PageNumberObject<List<StaffBean>>>() { + 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>>>() { @Override public void onSuccess(PageNumberObject<List<StaffBean>> obj) { uniSuccessCallback(type, obj.getList(), callback); @@ -740,10 +864,10 @@ */ 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 +889,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 +914,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 +1957,11 @@ 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(); - } HdlDeviceLogic.getInstance().delInverterDevice(homeId, deviceId, new CloudCallBeak<Boolean>() { @Override public void onSuccess(Boolean obj) { + //绉婚櫎鏈湴缂撳瓨 + HdlDeviceLogic.getInstance().removeLocalCacheMemoryGatewayToDeviceId(homeId, deviceId); uniSuccessCallback(type, null, callback); } @@ -2271,12 +2394,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