From caf0e22cb16cc01d3775db11b82787d5ba22c402 Mon Sep 17 00:00:00 2001
From: jinpengyong <jpy123456>
Date: Wed, 29 Dec 2021 16:02:27 +0800
Subject: [PATCH] 行业贡献率因子上下限判断

---
 screen-api/src/main/java/com/moral/api/service/impl/ProfessionServiceImpl.java |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/screen-api/src/main/java/com/moral/api/service/impl/ProfessionServiceImpl.java b/screen-api/src/main/java/com/moral/api/service/impl/ProfessionServiceImpl.java
index a52a729..0a7dcfa 100644
--- a/screen-api/src/main/java/com/moral/api/service/impl/ProfessionServiceImpl.java
+++ b/screen-api/src/main/java/com/moral/api/service/impl/ProfessionServiceImpl.java
@@ -230,7 +230,7 @@
                 //������������aqi������������������������
                 String sensorName = senorMap.get(sensorCode);
                 if (sensorName != null) {
-                    cityValue = (Double) dataValue.get(sensorName);
+                    cityValue = Double.parseDouble(dataValue.get(sensorName).toString());
                 }
             }
             resultMap.put("cityValue", cityValue);
@@ -277,7 +277,7 @@
                     //���������������������
                     NumberFormat numberFormat = NumberFormat.getInstance();
                     numberFormat.setMaximumFractionDigits(2);
-                    if (allDeviceSum != null) {
+                    if (allDeviceSum != null && (Double) allDeviceSum != 0d) {
                         contributionRate = numberFormat.format(professionSum / ((Double) allDeviceSum) * 100) + "%";
                     }
                 }
@@ -349,7 +349,7 @@
                 //������������aqi������������������������
                 String sensorName = senorMap.get(sensorCode);
                 if (sensorName != null) {
-                    cityValue = (Double) dataValue.get(sensorName);
+                    cityValue = Double.parseDouble(dataValue.get(sensorName).toString());
                 }
             }
             resultMap.put("cityValue", cityValue);
@@ -394,7 +394,7 @@
                     //���������������������
                     NumberFormat numberFormat = NumberFormat.getInstance();
                     numberFormat.setMaximumFractionDigits(2);
-                    if (allDeviceSum != null) {
+                    if (allDeviceSum != null && (Double) allDeviceSum != 0d) {
                         contributionRate = numberFormat.format(professionSum / ((Double) allDeviceSum) * 100) + "%";
                     }
                 }
@@ -421,8 +421,12 @@
         QueryWrapper<Sensor> sensorQueryWrapper = new QueryWrapper<>();
         sensorQueryWrapper.select("lower", "upper").eq("code", sensorCode);
         Sensor sensor = sensorService.getOne(sensorQueryWrapper);
-        Double sensorLower = sensor.getLower();
-        Double sensorUpper = sensor.getUpper();
+        Double sensorLower = null;
+        Double sensorUpper = null;
+        if (sensor != null) {
+            sensorLower = sensor.getLower();
+            sensorUpper = sensor.getUpper();
+        }
 
         //���������������������������
         List<String> allMacs = deviceService.getMacsByOrganizationId(orgId);
@@ -473,7 +477,7 @@
                 //������������aqi������������������������
                 String sensorName = senorMap.get(sensorCode);
                 if (sensorName != null) {
-                    cityValue = (Double) dataValue.get(sensorName);
+                    cityValue = Double.parseDouble(dataValue.get(sensorName).toString());
                 }
             }
             resultMap.put("cityValue", cityValue);
@@ -518,7 +522,7 @@
                     //���������������������
                     NumberFormat numberFormat = NumberFormat.getInstance();
                     numberFormat.setMaximumFractionDigits(2);
-                    if (allDeviceSum != null) {
+                    if (allDeviceSum != null && (Double) allDeviceSum != 0d) {
                         contributionRate = numberFormat.format(professionSum / ((Double) allDeviceSum) * 100) + "%";
                     }
                 }

--
Gitblit v1.8.0