From 9860f1c54fcd332951d135f6f79591f23b0650ee Mon Sep 17 00:00:00 2001
From: hongawen <83944980@qq.com>
Date: Thu, 10 Apr 2025 09:12:32 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=85=AC=E5=85=B1=E6=96=B9?=
=?UTF-8?q?=E6=B3=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
njcn-common/pom.xml | 8 +++
.../java/com/njcn/common/utils/PubUtils.java | 64 +++++++++++++++++++
2 files changed, 72 insertions(+)
create mode 100644 njcn-common/src/main/java/com/njcn/common/utils/PubUtils.java
diff --git a/njcn-common/pom.xml b/njcn-common/pom.xml
index ff91f43..3b9639f 100644
--- a/njcn-common/pom.xml
+++ b/njcn-common/pom.xml
@@ -24,6 +24,7 @@
1.68
2.13.4.1
2.17.0
+ 3.0.2
1.7.32
1.2.12
4.4.0
@@ -97,6 +98,13 @@
${jackson.jsr310.version}
+
+ com.google.code.findbugs
+ jsr305
+ ${jsr-version}
+
+
+
org.springframework.boot
diff --git a/njcn-common/src/main/java/com/njcn/common/utils/PubUtils.java b/njcn-common/src/main/java/com/njcn/common/utils/PubUtils.java
new file mode 100644
index 0000000..3cc15ff
--- /dev/null
+++ b/njcn-common/src/main/java/com/njcn/common/utils/PubUtils.java
@@ -0,0 +1,64 @@
+package com.njcn.common.utils;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+/**
+ * @author hongawen
+ * @version 1.0
+ * @data 2025/3/28 11:23
+ */
+public class PubUtils {
+
+ /**
+ * 根据参数返回double的四舍五入值
+ *
+ * @param i 保留的位数
+ * @param value double原值
+ */
+ public static double doubleRound(int i, double value) {
+ BigDecimal bp = new BigDecimal(value);
+ return bp.setScale(i, RoundingMode.HALF_UP).doubleValue();
+ }
+
+ /**
+ * 根据参数返回double的四舍五入值
+ *
+ * @param i 保留的位数
+ * @param value double原值
+ */
+ public static String doubleRoundStr(int i, double value) {
+ BigDecimal bp = new BigDecimal(value);
+ return bp.setScale(i, RoundingMode.HALF_UP).toPlainString();
+ }
+
+ public static void sortByDoubleValue(List