From de1e6ae16d3ed5429be750d50eaf846e09285779 Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期四, 28 三月 2024 16:02:10 +0800
Subject: [PATCH] 备份代码

---
 app/src/main/java/com/hdl/photovoltaic/ui/newC/adapter/MessageCenterListAdapter.java |   28 ++++++++-
 app/src/main/java/com/hdl/photovoltaic/enums/DeviceType.java                         |    9 +++
 app/src/main/java/com/hdl/photovoltaic/ui/bean/LinkAttributeBean.java                |   30 ++++++++++
 app/src/main/java/com/hdl/photovoltaic/ui/bean/LinkBean.java                         |   65 +++++++++++++++++++++
 app/src/main/java/com/hdl/photovoltaic/ui/bean/MessageBean.java                      |   21 +++++++
 app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java                        |   13 +++
 6 files changed, 161 insertions(+), 5 deletions(-)

diff --git a/app/src/main/java/com/hdl/photovoltaic/enums/DeviceType.java b/app/src/main/java/com/hdl/photovoltaic/enums/DeviceType.java
new file mode 100644
index 0000000..88ecb85
--- /dev/null
+++ b/app/src/main/java/com/hdl/photovoltaic/enums/DeviceType.java
@@ -0,0 +1,9 @@
+package com.hdl.photovoltaic.enums;
+
+public @interface DeviceType {
+    String inv = "INV";//閫嗗彉鍣�
+    String bms = "BMS";//BMS鎺у埗鐩�
+    String battery = "BATTERY";//鐢垫睜鍗曞厓
+
+}
+
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 8b43056..a94c8e2 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
@@ -43,6 +43,7 @@
 import com.hdl.photovoltaic.ui.bean.CloudInverterDeviceBean;
 import com.hdl.photovoltaic.ui.bean.DeviceTimeBean;
 import com.hdl.photovoltaic.ui.bean.Geolocation;
+import com.hdl.photovoltaic.ui.bean.LinkBean;
 import com.hdl.photovoltaic.ui.bean.OidBean;
 import com.hdl.photovoltaic.ui.me.AsRegardsActivity;
 import com.hdl.photovoltaic.ui.me.PersonalDataActivity;
@@ -58,6 +59,7 @@
 import com.hdl.sdk.link.common.exception.HDLLinkException;
 import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus;
 import com.hdl.sdk.link.core.bean.gateway.GatewayBean;
+import com.hdl.sdk.link.core.bean.response.BaseLocalResponse;
 import com.hdl.sdk.link.core.callback.GatewayCallBack;
 import com.hdl.sdk.link.core.callback.HDLLinkCallBack;
 import com.hdl.sdk.link.core.callback.ModbusCallBack;
@@ -1587,7 +1589,6 @@
         String mac = getKeyValue("mac", getKeyValue("data", data));
         String attribute_data = getKeyValue("attribute_data", getKeyValue("data", data));
         JsonArray jay = new JsonArray();
-//{"id":"c2d8b26b-3371-4fed-a190-78da31b454cf","time_stamp":"1711531144489","objects":[{"sid":"010126005C000251333036333237"}]}
         if (!TextUtils.isEmpty(attribute_data)) {
             try {
                 Gson gson = new Gson();
@@ -1601,7 +1602,15 @@
         TcpClient.getInstance().sendDataToLinkGateway(mac, TopicApi.PROPERTY_READ, jay, "", new HDLLinkCallBack() {
             @Override
             public void onSuccess(String msg) {
-                uniCallbackData(type, msg, callback);
+                try {
+                    Gson gson = new Gson();
+                    Type typeOfT = new TypeToken<BaseLocalResponse<List<LinkBean>>>() {
+                    }.getType();
+                    BaseLocalResponse<List<LinkBean>> baseLocalResponse = gson.fromJson(msg, typeOfT);
+                    uniCallbackData(type, baseLocalResponse, callback);
+                } catch (Exception e) {
+                    uniCallbackData(type, msg, -2, "", callback);
+                }
             }
 
             @Override
diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/bean/LinkAttributeBean.java b/app/src/main/java/com/hdl/photovoltaic/ui/bean/LinkAttributeBean.java
new file mode 100644
index 0000000..c9e67fe
--- /dev/null
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/bean/LinkAttributeBean.java
@@ -0,0 +1,30 @@
+package com.hdl.photovoltaic.ui.bean;
+
+import java.io.Serializable;
+
+public class LinkAttributeBean implements Serializable {
+
+    /**
+     * key : generator_power
+     * value : 0.0
+     */
+
+    private String key;
+    private String value;
+
+    public String getKey() {
+        return key == null ? "" : key;
+    }
+
+    public void setKey(String key) {
+        this.key = key;
+    }
+
+    public String getValue() {
+        return value == null ? "" : value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+}
diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/bean/LinkBean.java b/app/src/main/java/com/hdl/photovoltaic/ui/bean/LinkBean.java
new file mode 100644
index 0000000..cb8e3f2
--- /dev/null
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/bean/LinkBean.java
@@ -0,0 +1,65 @@
+package com.hdl.photovoltaic.ui.bean;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+public class LinkBean implements Serializable {
+
+
+    /**
+     * sid : 010126005C000251333036333237
+     * name : ECU
+     * spk : energy.hdl_inverter
+     * online : true
+     */
+
+    private String sid;
+    private String name;
+    private String spk;
+    private String online;
+
+
+    private List<LinkAttributeBean> status;
+
+    public String getSid() {
+        return sid == null ? "" : sid;
+    }
+
+    public void setSid(String sid) {
+        this.sid = sid;
+    }
+
+    public String getName() {
+        return name == null ? "" : name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getSpk() {
+        return spk == null ? "" : spk;
+    }
+
+    public void setSpk(String spk) {
+        this.spk = spk;
+    }
+
+    public String getOnline() {
+        return online == null ? "" : online;
+    }
+
+    public void setOnline(String online) {
+        this.online = online;
+    }
+
+    public List<LinkAttributeBean> getStatus() {
+        return status == null ? new ArrayList<>() : status;
+    }
+
+    public void setStatus(List<LinkAttributeBean> status) {
+        this.status = status;
+    }
+}
+
diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/bean/MessageBean.java b/app/src/main/java/com/hdl/photovoltaic/ui/bean/MessageBean.java
index 5e2f030..d21c488 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/bean/MessageBean.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/bean/MessageBean.java
@@ -19,6 +19,11 @@
     private String deviceOid;//璁惧oid
     private String deviceDesc;//璁惧澶囨敞
 
+
+    private String deviceType;//璁惧绫诲瀷(INV 锛� 閫嗗彉鍣�, BMS 锛� BMS鎺у埗鐩�, BATTERY 锛� 鐢垫睜鍗曞厓)
+    private String deviceTypeDesc;//璁惧绫诲瀷鎻忚堪
+
+
     private String typeDesc;//绫诲瀷鎻忚堪
     private String effectScope;//褰卞搷鑼冨洿 NO_EFFECT : 鏃犲奖鍝嶈寖鍥存姤璀�
     private String effectScopeDesc;//褰卞搷鑼冨洿鎻忚堪
@@ -30,6 +35,22 @@
 
     private HouseInfoBean.Location location = new HouseInfoBean.Location();//鐢电珯鍦板潃
 
+    public String getDeviceType() {
+        return deviceType == null ? "" : deviceType;
+    }
+
+    public void setDeviceType(String deviceType) {
+        this.deviceType = deviceType;
+    }
+
+    public String getDeviceTypeDesc() {
+        return deviceTypeDesc == null ? "" : deviceTypeDesc;
+    }
+
+    public void setDeviceTypeDesc(String deviceTypeDesc) {
+        this.deviceTypeDesc = deviceTypeDesc;
+    }
+
     public String getDeviceOidId() {
         return deviceOidId == null ? "" : deviceOidId;
     }
diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/newC/adapter/MessageCenterListAdapter.java b/app/src/main/java/com/hdl/photovoltaic/ui/newC/adapter/MessageCenterListAdapter.java
index 96c12cb..551b1b9 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/newC/adapter/MessageCenterListAdapter.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/newC/adapter/MessageCenterListAdapter.java
@@ -12,6 +12,7 @@
 import androidx.recyclerview.widget.RecyclerView;
 
 import com.hdl.photovoltaic.R;
+import com.hdl.photovoltaic.enums.DeviceType;
 import com.hdl.photovoltaic.enums.MessageAlarmStateType;
 import com.hdl.photovoltaic.ui.bean.MessageBean;
 import com.hdl.photovoltaic.utils.TimeUtils;
@@ -43,9 +44,9 @@
     @Override
     public void onBindViewHolder(@NonNull MessageCenterListAdapter.MyViewHolder holder, int position) {
         MessageBean messageBean = this.mList.get(position);
-        holder.item_home_name_tv.setText(messageBean.getTitle());
-        String strName = messageBean.getType() + "(" + messageBean.getDeviceDesc() + ")";
-        holder.item_content_tv.setText(strName);
+        holder.item_content_tv.setText(messageBean.getTitle());
+        String strName = getDeviceTypeStr(messageBean.getDeviceType()) + "(" + messageBean.getDeviceDesc() + ")";
+        holder.item_home_name_tv.setText(strName);
         String date = TimeUtils.getTimeFromTimestamp(messageBean.getCreateTime());
         holder.item_time_tv.setText(date);
         String type = "";//FAULT:鏁呴殰,WARN:鍛婅,EVENT:浜嬩欢
@@ -99,6 +100,25 @@
         notifyDataSetChanged();
     }
 
+    /**
+     * 閫氳繃鏋氫妇杞崲璁惧绫诲瀷鐨勫瓧绗�
+     *
+     * @param deviceType //璁惧绫诲瀷(INV 锛� 閫嗗彉鍣�, BMS 锛� BMS鎺у埗鐩�, BATTERY 锛� 鐢垫睜鍗曞厓)
+     * @return 璁惧绫诲瀷
+     */
+    private String getDeviceTypeStr(String deviceType) {
+        switch (deviceType) {
+            case DeviceType.inv:
+                return mContext.getString(R.string.alarm_all_device_inverter);
+            case DeviceType.bms:
+                return mContext.getString(R.string.alarm_all_device_bms);
+            case DeviceType.battery:
+                return mContext.getString(R.string.alarm_all_device_battery_cell);
+            default:
+                return "";
+        }
+    }
+
 
     public void setNoOnclickListener(OnclickListener onClickListener) {
         this.mOnClickListener = onClickListener;
@@ -124,4 +144,6 @@
     public interface OnclickListener {
         void onClick(int position, MessageBean messageBean);
     }
+
+
 }

--
Gitblit v1.8.0