From 1157a16f1be979f062ef49f7b76a545ecc231dc9 Mon Sep 17 00:00:00 2001 From: cmg <527198563@qq.com> Date: 星期五, 16 八月 2024 11:01:00 +0800 Subject: [PATCH] 杭州全民健康数据 --- src/main/java/com/hx/util/MapUtil.java | 24 ++++++++++++++++++++---- 1 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/hx/util/MapUtil.java b/src/main/java/com/hx/util/MapUtil.java index 2bdd0cd..392bae2 100644 --- a/src/main/java/com/hx/util/MapUtil.java +++ b/src/main/java/com/hx/util/MapUtil.java @@ -35,12 +35,12 @@ */ public static int getInt(Map<String, Object> map, String key) { - if(map == null || StringUtils.isEmpty(key)) + if(map == null || StringUtils.isEmpty(key) || null == map.get(key) || StringUtils.isEmpty(map.get(key).toString())) { return -1; } - return null == map.get(key) ? -1 : Integer.parseInt(map.get(key).toString()); + return Integer.parseInt(map.get(key).toString()); } /** @@ -51,12 +51,12 @@ */ public static int getIntZero(Map<String, Object> map, String key) { - if(map == null || StringUtils.isEmpty(key)) + if(map == null || StringUtils.isEmpty(key) || null == map.get(key) || StringUtils.isEmpty(map.get(key).toString())) { return 0; } - return null == map.get(key) ? 0 : Integer.parseInt(map.get(key).toString()); + return Integer.parseInt(map.get(key).toString()); } /** @@ -74,4 +74,20 @@ return null == map.get(key) ? BigDecimal.ZERO : new BigDecimal(map.get(key).toString()); } + + /** + * 鑾峰彇娴偣鏁帮紝榛樿杩斿洖0 + * @param map + * @param key + * @return + */ + public static Double getDoubleZero(Map<String, Object> map, String key) + { + if(map == null || StringUtils.isEmpty(key)) + { + return 0D; + } + + return null == map.get(key) ? 0D : Double.parseDouble(map.get(key).toString()); + } } -- Gitblit v1.8.0