From 589d1dff2ce8554ee53b818a98db000df7fdf4e7 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期二, 22 七月 2025 10:19:17 +0800
Subject: [PATCH] 2025年07月22日10:19:08
---
app/src/main/java/com/hdl/photovoltaic/other/HdlMessageLogic.java | 115 +++++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 90 insertions(+), 25 deletions(-)
diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlMessageLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlMessageLogic.java
index b1af7fc..05d0f10 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlMessageLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlMessageLogic.java
@@ -11,6 +11,7 @@
import com.hdl.photovoltaic.internet.api.HttpApi;
import com.hdl.photovoltaic.listener.CloudCallBeak;
import com.hdl.photovoltaic.ui.bean.MessageBean;
+import com.hdl.photovoltaic.ui.bean.UnCountBean;
import java.util.ArrayList;
import java.util.Comparator;
@@ -23,7 +24,7 @@
public class HdlMessageLogic {
private static volatile HdlMessageLogic sHdlMessageLogic;
- private final int pageSize = 50;//椤垫暟
+ private final int pageSize = 100;//椤垫暟
private List<MessageBean> mListMessage = new ArrayList<>();
@@ -74,6 +75,21 @@
return sortList(newList);
}
+ /**
+ * 娑堟伅鍏ㄩ儴宸茶(鏈湴缂撳瓨)
+ *
+ * @param isRead 鏄惁璇诲彇(true宸茶鍙�)
+ */
+ public void setAllRead(boolean isRead) {
+ for (int i = 0; i < mListMessage.size(); i++) {
+ MessageBean messageBean = mListMessage.get(i);
+ if (messageBean == null) {
+ continue;
+ }
+ messageBean.setRead(isRead);
+ }
+ }
+
/**
* 鑾峰彇鎭㈠涓紦瀛樺垪琛�
@@ -115,6 +131,18 @@
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+ unReadList.sort(new Comparator<MessageBean>() {
+ @Override
+ public int compare(MessageBean o1, MessageBean o2) {
+ if (o1 == null && o2 == null) {
+ return -1;
+ }
+ //鍊掑簭锛堥『搴� Long.compare(o2.getCreateTime(), o1.getCreateTime())锛�
+ return Long.compare(o2.getCreateTime(), o1.getCreateTime());
+ }
+ });
+ }
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
readList.sort(new Comparator<MessageBean>() {
@Override
public int compare(MessageBean o1, MessageBean o2) {
@@ -122,11 +150,10 @@
return -1;
}
//鍊掑簭锛堥『搴� Long.compare(o2.getCreateTime(), o1.getCreateTime())锛�
- return Long.compare(o1.getCreateTime(), o2.getCreateTime());
+ return Long.compare(o2.getCreateTime(), o1.getCreateTime());
}
});
}
-
if (unReadList.size() > 0) {
newList.addAll(unReadList);
}
@@ -166,7 +193,8 @@
break;
}
}
- } catch (Exception ignored) {
+ } catch (Exception e) {
+ String ss = e.getMessage();
}
}
@@ -196,14 +224,14 @@
}
} catch (Exception e) {
String mes = e.getMessage();
- HdlLogLogic.print("--->" + mes);
+ HdlLogLogic.print("---" + mes);
}
}
/**
- * 娣诲姞娑堟伅鍒板垪琛ㄩ噷闈�
+ * 娣诲姞娑堟伅鍒板垪琛ㄩ噷闈�(鍗曚釜鎻掑叆)
*
- * @param messageBean -
+ * @param messageBean 鍗曚釜
* @param position 琛ㄧず鍔犲埌鍒楄〃鐨勪綅缃�
*/
public void setListMessage(MessageBean messageBean, int position) {
@@ -227,14 +255,14 @@
}
} catch (Exception e) {
String mes = e.getMessage();
- HdlLogLogic.print("--->" + mes);
+ HdlLogLogic.print("---" + mes);
}
}
/**
* 娣诲姞娑堟伅鍒板垪琛ㄩ噷闈�
*
- * @param list -
+ * @param list 鍒楄〃
*/
public void setListMessage(List<MessageBean> list) {
try {
@@ -282,14 +310,25 @@
*
* @param cloudCallBeak -
*/
- public void getMessageUntreatedCount(CloudCallBeak<String> cloudCallBeak) {
+ public void getMessageUntreatedCount(String homeId, CloudCallBeak<UnCountBean> cloudCallBeak) {
String requestUrl = HttpApi.POST_Message_UntreatedCount;
JsonObject json = new JsonObject();
+ if (!TextUtils.isEmpty(homeId)) {
+ json.addProperty("homeId", homeId);
+ }
HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() {
@Override
public void onSuccess(String str) {
+ if (TextUtils.isEmpty(str)) {
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onSuccess(new UnCountBean());
+ }
+ return;
+ }
+
+ UnCountBean unCountBean = new Gson().fromJson(str, UnCountBean.class);
if (cloudCallBeak != null) {
- cloudCallBeak.onSuccess(str);
+ cloudCallBeak.onSuccess(unCountBean);
}
}
@@ -460,26 +499,50 @@
}
+
/**
- * 鑾峰彇鎸囧畾椤电殑鑾峰彇娑堟伅鍒楄〃(鐢ㄤ簬C绔�)
+ * 鑾峰彇鎸囧畾椤电殑鑾峰彇娑堟伅鍒楄〃
*
- * @param pageNo 椤电爜
- * @param messageStateType all:鍏ㄩ儴,UNTREATED:鏈鐞�,PROCESSED:宸插鐞�;
- * @param filter_key 绫诲瀷锛堣澶囷紝绛夌骇锛屾椂闂达級
- * @param filter_value deviceType锛圛NV 锛氶�嗗彉鍣紱BMS 锛欱MS鎺у埗鐩掞紱BATTERY 锛氱數姹犲崟鍏冿級锛�
- * type锛團AULT 锛氭晠闅滐紱 WARN 锛氬憡璀︼紱 EVENT 锛氫簨浠�(鎻愮ず)锛夛紱
- * timeType锛圱ODAY 锛氫粖澶╋紱LAST_3_DAYS: 杩�3澶╋紱LAST_7_DAYS 锛氳繎7澶╋紱LAST_30_DAYS 锛氳繎30澶╋級锛�
- * @param cloudCallBeak -
+ * @param homeId 鐢电珯id(濉�""榛樿璐﹀彿涓嬫墍鏈夋秷鎭�)
+ * @param pageNo 椤电爜
+ * @param messageStateType all:鍏ㄩ儴,UNTREATED:鏈鐞�,PROCESSED:宸插鐞�;
+ * @param deviceType_filter_key 绫诲瀷锛堣澶囷紝绛夌骇锛屾椂闂达級
+ * @param deviceType_filter_value deviceType锛圛NV 锛氶�嗗彉鍣紱BMS 锛欱MS鎺у埗鐩掞紱BATTERY 锛氱數姹犲崟鍏冿級锛�
+ * type锛團AULT 锛氭晠闅滐紱 WARN 锛氬憡璀︼紱 EVENT 锛氫簨浠�(鎻愮ず)锛夛紱
+ * timeType锛圱ODAY 锛氫粖澶╋紱LAST_3_DAYS: 杩�3澶╋紱LAST_7_DAYS 锛氳繎7澶╋紱LAST_30_DAYS 锛氳繎30澶╋級锛�
+ * @param search_title 鎶ヨ鍚嶇О
+ * @param cloudCallBeak -
*/
- public void getPageNoMessageList_C(int pageNo, String messageStateType, String filter_key, String filter_value, CloudCallBeak<MessageListClass> cloudCallBeak) {
+ public void getPageNoMessageList(
+ String homeId,
+ int pageNo,
+ String messageStateType,
+ String deviceType_filter_key,
+ String deviceType_filter_value,
+ String type_filter_key,
+ String type_filter_value,
+ String timeType_filter_key,
+ String timeType_filter_value,
+ String search_title, CloudCallBeak<MessageListClass> cloudCallBeak) {
String requestUrl = HttpApi.POST_Message_List;
JsonObject json = new JsonObject();
-
+ if (!TextUtils.isEmpty(homeId)) {
+ json.addProperty("homeId", homeId);
+ }
if (!MessageStateType.all.equals(messageStateType)) {
json.addProperty("status", messageStateType);
}
- if (!TextUtils.isEmpty(filter_key) && !TextUtils.isEmpty(filter_value)) {
- json.addProperty(filter_key, filter_value);
+ if (!TextUtils.isEmpty(deviceType_filter_key) && !TextUtils.isEmpty(deviceType_filter_value)) {
+ json.addProperty(deviceType_filter_key, deviceType_filter_value);
+ }
+ if (!TextUtils.isEmpty(type_filter_key) && !TextUtils.isEmpty(type_filter_value)) {
+ json.addProperty(type_filter_key, type_filter_value);
+ }
+ if (!TextUtils.isEmpty(timeType_filter_key) && !TextUtils.isEmpty(timeType_filter_value)) {
+ json.addProperty(timeType_filter_key, timeType_filter_value);
+ }
+ if (!TextUtils.isEmpty(search_title)) {
+ json.addProperty("title", search_title);
}
json.addProperty("pageNo", pageNo);//椤电爜
json.addProperty("pageSize", pageSize);//椤垫暟
@@ -580,13 +643,15 @@
/**
* 娑堟伅鍏ㄩ儴宸茶
*
- * @param homeId 娑堟伅id
+ * @param homeId 娑堟伅id(涓嶄紶宸茶鎵�鏈夌數绔欑殑锛屼紶鍊煎凡璇绘寚瀹氱數绔欑殑)
* @param cloudCallBeak -
*/
public void messageAllRead(String homeId, CloudCallBeak<Boolean> cloudCallBeak) {
String requestUrl = HttpApi.POST_Message_AllRead;
JsonObject json = new JsonObject();
- json.addProperty("homeId", homeId);
+ if (!TextUtils.isEmpty(homeId)) {
+ json.addProperty("homeId", homeId);
+ }
HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() {
@Override
public void onSuccess(String str) {
--
Gitblit v1.8.0