From e4aa9db5e3c91c969adf2361f8069b8c54244e1a Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期二, 15 四月 2025 12:02:39 +0800
Subject: [PATCH] 获取轮灌组详情接口,对轮灌组增加终止状态判断

---
 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/util/AmountToChinese.java |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/util/AmountToChinese.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/util/AmountToChinese.java
new file mode 100644
index 0000000..ebcb3e0
--- /dev/null
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/util/AmountToChinese.java
@@ -0,0 +1,57 @@
+package com.dy.pipIrrGlobal.util;
+
+import java.math.BigDecimal;
+
+/**
+ * @author ZhuBaoMin
+ * @date 2024-02-01 9:58
+ * @LastEditTime 2024-02-01 9:58
+ * @Description 閲戦鏁板瓧杞腑鏂囧ぇ鍐�
+ */
+public class AmountToChinese {
+    private static final String[] CN_UPPER_NUMBER = { "闆�", "澹�", "璐�", "鍙�", "鑲�", "浼�", "闄�", "鏌�", "鎹�", "鐜�" };
+    private static final String[] CN_UPPER_MONETRAY_UNIT = { "鍒�", "瑙�", "鍏�", "鎷�", "浣�", "浠�", "涓�", "鎷�", "浣�", "浠�", "浜�", "鎷�", "浣�", "浠�" };
+    private static final String CN_FULL = "鏁�";
+    private static final String CN_NEGATIVE = "璐�";
+    private static final int MONEY_PRECISION = 2;
+    private static final String CN_ZEOR_FULL = "闆跺厓" + CN_FULL;
+
+    public static String toChinese(BigDecimal amount) {
+        StringBuilder result = new StringBuilder();
+        amount = amount.setScale(MONEY_PRECISION, BigDecimal.ROUND_HALF_UP);
+        long number = amount.movePointRight(MONEY_PRECISION).setScale(0, BigDecimal.ROUND_HALF_UP).longValue();
+        boolean zero = true;
+        int unitIndex = 0;
+        if (number == 0) {
+            return CN_ZEOR_FULL;
+        }
+        if (number < 0) {
+            number = -number;
+            result.append(CN_NEGATIVE);
+        }
+        long scale = 10;
+        while (true) {
+            if (number == 0) {
+                break;
+            }
+            long numIndex = number % scale;
+            if (zero && numIndex == 0) {
+                zero = false;
+            }
+            if (numIndex != 0) {
+                result.insert(0, CN_UPPER_MONETRAY_UNIT[unitIndex])
+                        .insert(0, CN_UPPER_NUMBER[(int) numIndex]);
+                zero = false;
+            }
+            else if (!zero) {
+                result.insert(0, CN_UPPER_NUMBER[(int) numIndex]);
+            }
+            number = number / scale;
+            unitIndex++;
+        }
+        if (zero) {
+            result.append(CN_FULL);
+        }
+        return result.toString();
+    }
+}

--
Gitblit v1.8.0