From 1a0aaa0bd03b3a491c751b5ce1bfca16302767b1 Mon Sep 17 00:00:00 2001 From: mac <user@users-MacBook-Pro.local> Date: 星期三, 19 六月 2024 19:30:12 +0800 Subject: [PATCH] 2024年06月19日19:30:03 --- app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java | 187 +++++++++++++++++++++++++++++++++++++--------- 1 files changed, 151 insertions(+), 36 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..3806220 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,11 +170,10 @@ //鍒涘缓鐢电珯 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)); } break; //璇诲彇璇︽儏 @@ -180,23 +181,46 @@ } 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)); } 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)); + } + 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; @@ -627,6 +651,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 +762,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 +787,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 +812,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 +836,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 +856,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 +881,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 +906,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 +1949,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); } -- Gitblit v1.8.0