From 2225b1f0727fb74e10ac5692e68e4cd48f4f62d7 Mon Sep 17 00:00:00 2001 From: wjc <1243177876@qq.com> Date: 星期一, 03 三月 2025 15:02:14 +0800 Subject: [PATCH] 2025年03月03日15:02:11 --- app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java | 71 +++++++++++++++++++++++++++++++++-- 1 files changed, 66 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java index 571cc42..2f1d14c 100644 --- a/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java +++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java @@ -8,6 +8,8 @@ import com.google.gson.JsonObject; import com.google.gson.reflect.TypeToken; import com.hdl.linkpm.sdk.core.exception.HDLException; +import com.hdl.photovoltaic.bean.InverterBean; +import com.hdl.photovoltaic.bean.LocalResponse; import com.hdl.photovoltaic.bean.PageNumberObject; import com.hdl.photovoltaic.config.AppConfigManage; import com.hdl.photovoltaic.config.UserConfigManage; @@ -37,6 +39,7 @@ import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.concurrent.atomic.AtomicInteger; @@ -909,7 +912,7 @@ * @param mac 缃戝叧mac * @param linkCallBack 鍥炶皟 */ - public void getGatewayInfo(String mac, LinkCallBack<GatewayBean> linkCallBack) { + public void getGatewayInfo(String mac, LinkCallBack<InverterBean> linkCallBack) { String requestUrl = TopicApi.GET_GATEWAY_INFO; JsonObject json = new JsonObject(); json.addProperty("device_mac", mac); @@ -925,11 +928,11 @@ } Gson gson = new Gson(); - Type typeOfT = new TypeToken<BaseLocalResponse<GatewayBean>>() { + Type typeOfT = new TypeToken<BaseLocalResponse<InverterBean>>() { }.getType(); - BaseLocalResponse<GatewayBean> baseLocalResponse = gson.fromJson(json, typeOfT); + BaseLocalResponse<InverterBean> baseLocalResponse = gson.fromJson(json, typeOfT); if (baseLocalResponse == null || baseLocalResponse.getObjects() == null) { - linkCallBack.onSuccess(new GatewayBean()); + linkCallBack.onSuccess(new InverterBean()); } else { linkCallBack.onSuccess(baseLocalResponse.getObjects()); } @@ -1130,7 +1133,7 @@ List<String> removeSidList = new ArrayList<>(); for (int j = 0; j < HDLLinkLocalGateway.getInstance().getGatewayList().size(); j++) { GatewayBean gatewayBean = HDLLinkLocalGateway.getInstance().getGatewayList().get(j); - if (gatewayBean.getSpk().equals(INVERTER_DEVICE_SPK)) { + if (!isLoadCenterSpk(gatewayBean.getSpk())) { //涓嶆槸璐熻浇涓績鐨剆pk涓嶅仛澶勭悊锛� continue; } @@ -1346,6 +1349,16 @@ if (gatewayBean != null) { HDLLinkLocalGateway.getInstance().getGatewayList().remove(gatewayBean); } + } + + /** + * 鍒ゆ柇spk鏄惁鏄礋杞戒腑蹇� + * + * @param spk spk + * @return 鐪�=true锛屽惁鍒欒繑鍥瀎alse + */ + private boolean isLoadCenterSpk(String spk) { + return Objects.equals(spk, LC_SPK); } /** @@ -1644,6 +1657,46 @@ } /** + * 閫嗗彉鍣ㄥ瘑鐮佺櫥褰� + * + * @param mac 閫嗗彉鍣╩ac + * @param password 閫嗗彉鍣ㄥ瘑鐮� + */ + public void getPasswordVerification(String mac, String password, LinkCallBack<LocalResponse> callBeak) { + String requestUrl = TopicApi.DELETING_GATEWAY_password_verifiy; + JsonObject json = new JsonObject(); + json.addProperty("password", password); + json.addProperty("mac", mac); + TcpClient.getInstance().sendDataToLinkGateway(mac, false, requestUrl, json, "", new HDLLinkCallBack() { + @Override + public void onSuccess(String msg) { + try { + + Gson gson = new Gson(); + LocalResponse localResponse = gson.fromJson(msg, LocalResponse.class); + if (localResponse == null) { + localResponse = new LocalResponse(); + } + if (callBeak != null) { + callBeak.onSuccess(localResponse); + } + } catch (Exception e) { + if (callBeak != null) { + callBeak.onSuccess(new LocalResponse()); + } + } + } + + @Override + public void onError(HDLLinkException e) { + if (callBeak != null) { + callBeak.onError(e); + } + } + }); + } + + /** * 鍒锋柊閫嗗彉鍣ㄧ紦瀛樹俊鎭�(鍖呮嫭璁剧疆mqtt绉橀挜锛� * 娉�: //鐩殑鏄负浜嗚幏鍙栨嬁鍒扮綉鍏矷D锛宮qtt閫氳绉橀挜绛変俊鎭紝缂撳瓨鏈湴閫嗗彉鍣ㄥ垪琛ㄩ噷闈紝鍙戦�佹暟鎹暟鎹椂鑷姩鍘荤紦瀛樺垪琛ㄩ噷闈㈠幓鏌ユ壘锛� * 1:鏈湴瀛樺湪,鏇存柊淇℃伅鍗冲彲; @@ -1679,6 +1732,9 @@ gatewayBean.setDevice_name(cloudInverterDeviceBean.getName());//璁惧鍚嶇О gatewayBean.setGatewayType(cloudInverterDeviceBean.getSpk());//璁剧疆spk gatewayBean.setLocalEncrypt(true); + //绂荤綉閫嗗彉鍣� + gatewayBean.setOgMaster(cloudInverterDeviceBean.isOgMaster()); + //閫嗗彉鍣� gatewayBean.setMaster(GatewayMasterType.MasterTrue);//榛樿閮芥槸涓婚�嗗彉鍣�(浠ュ悗鏀寔浠庨�嗗彉鍣ㄨ鏇存敼) gatewayBean.setSystemStatusDesc(cloudInverterDeviceBean.getSystemStatusDesc());//璁惧鐘舵�� gatewayBean.setHwVersion(cloudInverterDeviceBean.getHwVersion());//杞欢鐗堟湰鍙� @@ -1707,6 +1763,7 @@ List<String> spks = new ArrayList<>(); spks.add(INVERTER_DEVICE_SPK); spks.add(LC_SPK); + spks.add(OFF_INVERTER_OG_SPK); return spks; } @@ -1730,4 +1787,8 @@ * 璐熻浇涓績spk */ public final String LC_SPK = "energy.hdl_lc"; + /** + * 绂荤嚎閫嗗彉鍣╯pk + */ + public final String OFF_INVERTER_OG_SPK = "energy.inverter_og"; } -- Gitblit v1.8.0