From b9cc7390e8e8ce64c41c26fb369c98ce669d660c Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期三, 07 五月 2025 15:02:30 +0800
Subject: [PATCH] Merge branch '1.2.0'

---
 app/src/main/java/com/hdl/photovoltaic/other/HdlCommonLogic.java |  107 +++++++++++++++++++++--------------------------------
 1 files changed, 43 insertions(+), 64 deletions(-)

diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlCommonLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlCommonLogic.java
index 441f7b7..a935e16 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlCommonLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlCommonLogic.java
@@ -1,46 +1,32 @@
 package com.hdl.photovoltaic.other;
 
-import android.app.Activity;
 import android.content.Context;
 import android.graphics.Bitmap;
-import android.os.SystemClock;
 import android.text.SpannableStringBuilder;
 import android.text.TextPaint;
 import android.text.TextUtils;
 import android.text.style.ClickableSpan;
 import android.view.View;
-import android.view.inputmethod.InputMethodManager;
 import android.widget.ImageView;
 import android.widget.TextView;
 
 import androidx.annotation.NonNull;
 
-import com.google.gson.JsonObject;
 import com.google.zxing.BarcodeFormat;
 import com.google.zxing.EncodeHintType;
 import com.google.zxing.common.BitMatrix;
 import com.google.zxing.qrcode.QRCodeWriter;
-import com.hdl.linkpm.sdk.user.HDLLinkPMUser;
 import com.hdl.photovoltaic.HDLApp;
 import com.hdl.photovoltaic.R;
-import com.hdl.photovoltaic.config.ConstantManage;
-import com.hdl.photovoltaic.config.UserConfigManage;
-import com.hdl.photovoltaic.enums.HomepageTitleTabSwitch;
 import com.hdl.photovoltaic.enums.LowerTagType;
 import com.hdl.photovoltaic.enums.UnitType;
 import com.hdl.photovoltaic.utils.GlideUtils;
 import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus;
-import com.hdl.sdk.link.core.callback.BaseCallBack;
 
 import org.greenrobot.eventbus.EventBus;
-import org.json.JSONObject;
 
-import java.io.InputStream;
-import java.io.OutputStream;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
-import java.net.InetSocketAddress;
-import java.net.Socket;
 import java.util.Hashtable;
 
 /**
@@ -76,14 +62,15 @@
 
 
     /**
-     * @param value 鍊�
+     * @param value    鍊�
+     * @param unitType 闇�瑕佽浆鐨勫崟浣嶏紙kW锛宬Wh锛�
      * @return 瀛楃涓插�艰繑鍥�
      */
-    public static String convertDoubleValue(String value) {
+    public static String convertDoubleValue(String value, String unitType) {
         if (TextUtils.isEmpty(value)) {
             return UnitType.noValue;
         }
-        return divideByOneThousandAndFormat(value).toString();
+        return divideByOneThousandAndFormat(value,unitType).toString();
     }
 
     /**
@@ -136,10 +123,10 @@
      * @param value 鍊�
      * @return BigDecimal
      */
-    public static BigDecimal divideByOneThousandAndFormat(String value) {
+    public static BigDecimal divideByOneThousandAndFormat(String value, String unitType) {
         try {
             double doubleValue = Double.parseDouble(value);
-            int mDoubleValue = doubleValue(value);
+            long mDoubleValue = doubleValue(value,unitType);
             if (mDoubleValue == 0) {
                 return getBigDecimal(value);
             } else {
@@ -157,17 +144,29 @@
      *
      * @param value 鍊�
      */
-    public static int doubleValue(String value) {
+    public static long doubleValue(String value, String unitType) {
         try {
             double doubleValue = Double.parseDouble(value);
-            if (doubleValue > 1000 && doubleValue < 1000 * 1000) {
-                return 1000;
-            } else if (doubleValue > 1000 * 1000 && doubleValue < 1000 * 1000 * 1000) {
-                return 1000 * 1000;
-            } else if (doubleValue > 1000 * 1000 * 1000) {
-                return 1000 * 1000 * 1000;
+            if (unitType.equals(UnitType.kW)) {
+                if (doubleValue > 1000 && doubleValue < 1000 * 1000) {
+                    return 1000 ;
+                } else if (doubleValue >= 1000 * 1000 && doubleValue < 1000 * 1000 * 1000) {
+                    return 1000 * 1000 ;
+                } else if (doubleValue >= 1000 * 1000 * 1000) {
+                    return 1000L * 1000 * 1000 ;
+                } else {
+                    return 1000;
+                }
             } else {
-                return 0;
+                if (doubleValue >= 1000 && doubleValue < 1000 * 1000) {
+                    return 1000;
+                } else if (doubleValue >= 1000 * 1000 && doubleValue < 1000 * 1000 * 1000) {
+                    return 1000 * 1000;
+                } else if (doubleValue >= 1000 * 1000 * 1000) {
+                    return 1000 * 1000 * 1000;
+                } else {
+                    return 0;
+                }
             }
         } catch (Exception e) {
             return 0;
@@ -175,43 +174,21 @@
 
     }
 
-    /**
-     * 杞崲鍗曚綅
-     *
-     * @param value    鍊�
-     * @param unitType 琛ㄧず鏄崟浣嶏紙鍔熺巼锛岀數閲忥級
-     */
-    public static String convertUnit(String value, String unitType) {
-        try {
-            double doubleValue = Double.parseDouble(value);
-            if (doubleValue > 1000 && doubleValue < 1000 * 1000) {
-                return unitType.equals(UnitType.kW) ? UnitType.mW : UnitType.mWh;
-            } else if (doubleValue > 1000 * 1000 && doubleValue < 1000 * 1000 * 1000) {
-                return unitType.equals(UnitType.kW) ? UnitType.gW : UnitType.gWh;
-            } else if (doubleValue > 1000 * 1000 * 1000) {
-                return unitType.equals(UnitType.kW) ? UnitType.tW : UnitType.tWh;
-            } else {
-                return unitType.equals(UnitType.kW) ? UnitType.kW : UnitType.kWh;
-            }
-        } catch (Exception e) {
-            return unitType.equals(UnitType.kW) ? UnitType.kW : UnitType.kWh;
-        }
 
-    }
 
     /**
-     * 杞崲(kWh)鍗曚綅
+     * 杞崲鐢甸噺(kWh)鍗曚綅
      *
      * @param value 鍊�
      */
-    public static String convertKWUnit(String value) {
+    public static String convertKWHUnit(String value) {
         try {
             double doubleValue = Double.parseDouble(value);
-            if (doubleValue > 1000 && doubleValue < 1000 * 1000) {
+            if (doubleValue >= 1000 && doubleValue < 1000 * 1000) {
                 return UnitType.mWh;
-            } else if (doubleValue > 1000 * 1000 && doubleValue < 1000 * 1000 * 1000) {
+            } else if (doubleValue >= 1000 * 1000 && doubleValue < 1000 * 1000 * 1000) {
                 return UnitType.gWh;
-            } else if (doubleValue > 1000 * 1000 * 1000) {
+            } else if (doubleValue >= 1000 * 1000 * 1000) {
                 return UnitType.tWh;
             } else {
                 return UnitType.kWh;
@@ -223,18 +200,20 @@
     }
 
     /**
-     * 杞崲(kW)鍗曚綅
+     * 杞崲鍔熺巼(kW)鍗曚綅
      *
      * @param value 鍊�
      */
-    public static String convertKWhUnit(String value) {
+    public static String convertKWUnit(String value) {
         try {
             double doubleValue = Double.parseDouble(value);
             if (doubleValue > 1000 && doubleValue < 1000 * 1000) {
+                return UnitType.kW;
+            } else if (doubleValue >= 1000 * 1000 && doubleValue < 1000 * 1000 * 1000) {
                 return UnitType.mW;
-            } else if (doubleValue > 1000 * 1000 && doubleValue < 1000 * 1000 * 1000) {
+            } else if (doubleValue >= 1000 * 1000 * 1000&&doubleValue < 1000 * 1000 * 1000*1000L) {
                 return UnitType.gW;
-            } else if (doubleValue > 1000 * 1000 * 1000) {
+            } else if (doubleValue >= 1000 * 1000 * 1000*1000L) {
                 return UnitType.tW;
             } else {
                 return UnitType.kW;
@@ -246,18 +225,18 @@
     }
 
     /**
-     * 杞崲(Wp)鍗曚綅
+     * 杞崲(kWp)鍗曚綅
      *
      * @param value 鍊�
      */
-    public static String convertWPUnit(String value) {
+    public static String convertKWPUnit(String value) {
         try {
             double doubleValue = Double.parseDouble(value);
-            if (doubleValue > 1000 && doubleValue < 1000 * 1000) {
+            if (doubleValue >= 1000 && doubleValue < 1000 * 1000) {
                 return UnitType.MWp;
-            } else if (doubleValue > 1000 * 1000 && doubleValue < 1000 * 1000 * 1000) {
+            } else if (doubleValue >= 1000 * 1000 && doubleValue < 1000 * 1000 * 1000) {
                 return UnitType.GWp;
-            } else if (doubleValue > 1000 * 1000 * 1000) {
+            } else if (doubleValue >= 1000 * 1000 * 1000) {
                 return UnitType.TWp;
             } else {
                 return UnitType.kWp;
@@ -379,7 +358,7 @@
                 public void updateDrawState(@NonNull TextPaint ds) {
                     super.updateDrawState(ds);
                     //璁剧疆瀛椾綋棰滆壊
-                    ds.setColor(HDLApp.getInstance().getResources().getColor(R.color.text_E6FFFFFF, null));
+                    ds.setColor(HDLApp.getInstance().getResources().getColor(R.color.text_FFACACAC, null));
                     // 鍘绘帀涓嬪垝绾�
                     ds.setUnderlineText(isUnderline);
                 }

--
Gitblit v1.8.0