From 4bc924d0ce29560a5e1ad1adf1042de032d954a1 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期四, 04 十二月 2025 14:50:56 +0800
Subject: [PATCH] 2025年12月04日14:50:54

---
 app/src/main/java/com/hdl/photovoltaic/other/HdlPushLogic.java |   97 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 96 insertions(+), 1 deletions(-)

diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlPushLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlPushLogic.java
index 02dba2f..0643bf0 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlPushLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlPushLogic.java
@@ -2,14 +2,21 @@
 
 import android.content.Context;
 import android.content.Intent;
+import android.os.Build;
 import android.text.TextUtils;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.google.gson.Gson;
+import com.google.gson.JsonObject;
+import com.hdl.linkpm.sdk.core.exception.HDLException;
+import com.hdl.photovoltaic.config.AppConfigManage;
 import com.hdl.photovoltaic.config.ConstantManage;
 import com.hdl.photovoltaic.config.UserConfigManage;
 import com.hdl.photovoltaic.enums.MessageStateType;
+import com.hdl.photovoltaic.internet.HttpClient;
+import com.hdl.photovoltaic.internet.api.HttpApi;
+import com.hdl.photovoltaic.listener.CloudCallBeak;
 import com.hdl.photovoltaic.push.PushMessageInfoBean;
 import com.hdl.photovoltaic.ui.BPowerStationActivity;
 import com.hdl.photovoltaic.ui.bean.MessageBean;
@@ -47,6 +54,78 @@
     }
 
     /**
+     * 娣诲姞鎺ㄩ�乀oken
+     *
+     * @param cloudCallBeak -
+     */
+    public void pushAdd(CloudCallBeak<String> cloudCallBeak) {
+        String requestUrl = HttpApi.POST_push_add;
+        JsonObject json = new JsonObject();
+        json.addProperty("deviceName", Build.MODEL);//璁惧鍚嶇О
+        json.addProperty("deviceType", "Android");//璁惧绫诲瀷
+        json.addProperty("produce", AppConfigManage.isIsOnlineServer());//琛ㄧず鏄惁鏄寮忔湇鍔″櫒
+        json.addProperty("pushToken", UserConfigManage.getInstance().getPushToken());//App鐨勬帹閫乀oken锛屽湪鏋佸厜涓篟egId
+        json.addProperty("software", "PHOTOVOLTAIC");//杞欢鏉ユ簮鎶奝HOTOVOLTAIC鏀规垚XENTERRA锛屼篃灏变簯绔鐨勯�氶亾鍙凤紙channel)
+        json.addProperty("platform", "ALIYUN_APNS");//闃块噷浜戠殑鐗堟湰鐨刾latform
+//        json.addProperty("platform", "FCM");//google鐨勭増鏈殑platform
+        json.addProperty("language", UserConfigManage.getInstance().getCurrentAppLanguage());//2.0杩藉姞鐨勫瓧娈�
+
+        HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() {
+            @Override
+            public void onSuccess(String pushId) {
+                if (!TextUtils.isEmpty(pushId)) {
+                    UserConfigManage.getInstance().setPushId(pushId);
+                    UserConfigManage.getInstance().Save();
+                }
+                if (cloudCallBeak != null) {
+                    cloudCallBeak.onSuccess(pushId);
+                }
+
+            }
+
+            @Override
+            public void onFailure(HDLException e) {
+                if (cloudCallBeak != null) {
+                    cloudCallBeak.onFailure(e);
+                }
+            }
+        });
+
+
+    }
+
+    /**
+     * 鍒犻櫎鎺ㄩ�乀oken
+     *
+     * @param cloudCallBeak -
+     */
+    public void pushDel(CloudCallBeak<String> cloudCallBeak) {
+        String requestUrl = HttpApi.POST_push_del;
+        JsonObject json = new JsonObject();
+        json.addProperty("pushId", UserConfigManage.getInstance().getPushId());
+        json.addProperty("pushToken", UserConfigManage.getInstance().getPushToken());
+
+        HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() {
+            @Override
+            public void onSuccess(String jsonStr) {
+                if (cloudCallBeak != null) {
+                    cloudCallBeak.onSuccess(jsonStr);
+                }
+
+            }
+
+            @Override
+            public void onFailure(HDLException e) {
+                if (cloudCallBeak != null) {
+                    cloudCallBeak.onFailure(e);
+                }
+            }
+        });
+
+
+    }
+
+    /**
      * 鎺ㄩ�佹暟鎹粺涓�澶勭悊鐨勬柟娉�
      *
      * @param context             涓婁笅鏂�
@@ -72,7 +151,7 @@
             }
         } else {
 //            if (isOpened) {
-                //浜у搧缁忕悊璇存殏鏃朵笉鍋� 2024骞�03鏈�29鏃�10:34:44
+            //浜у搧缁忕悊璇存殏鏃朵笉鍋� 2024骞�03鏈�29鏃�10:34:44
 //                boolean existsActivity = AppManagerUtils.getAppManager().existsActivity(MessageCenterListActivity.class);
 //                if (existsActivity) {
 //                    //瀛樺湪鍞竴涓�绉嶅彲鑳藉氨鏄綋鍓嶆椿鍔ㄧ獥鍙e氨鏄畠
@@ -157,6 +236,22 @@
                         pushMessageInfoBean.setMessageType(messageType);
                     }
                 }
+                if (TextUtils.isEmpty(title)) {
+                    if (expandDataObject.containsKey("title")) {
+                        String messageTitle = Objects.requireNonNull(expandDataObject.get("title")).toString();
+                        if (!TextUtils.isEmpty(messageTitle)) {
+                            pushMessageInfoBean.setTitle(messageTitle);
+                        }
+                    }
+                }
+                if (TextUtils.isEmpty(content)) {
+                    if (expandDataObject.containsKey("content")) {
+                        String messageContent = Objects.requireNonNull(expandDataObject.get("content")).toString();
+                        if (!TextUtils.isEmpty(messageContent)) {
+                            pushMessageInfoBean.setTitle(messageContent);
+                        }
+                    }
+                }
                 if (expandDataObject.containsKey("homeId")) {
                     String homeId = Objects.requireNonNull(expandDataObject.get("homeId")).toString();
                     if (!TextUtils.isEmpty(homeId)) {

--
Gitblit v1.8.0