فهرست منبع

td查询为空处理

lengfaqiang 2 سال پیش
والد
کامیت
8706dcdf20

+ 19 - 13
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/DeviceService.java

@@ -542,16 +542,18 @@ public class DeviceService {
                         double angleInRadians = Math.toRadians(selected == null ? 0L : Double.parseDouble(selected.getVal()));
                         double cosValue = Math.cos(angleInRadians);
                         if (org.apache.commons.lang3.StringUtils.isNotBlank(val)) {
-                            double doubleValue = (new BigDecimal(val).subtract(currentValue)).divide(new BigDecimal(360),9, RoundingMode.HALF_UP).doubleValue();
+                            double doubleValue = (new BigDecimal(val).subtract(currentValue)).divide(new BigDecimal(360), 9, RoundingMode.HALF_UP).doubleValue();
                             offsetValue = new BigDecimal(equatorial_circumference).multiply(new BigDecimal(cosValue)).multiply(new BigDecimal(doubleValue));
                         }
                     }
 //                    currentMeasurement.put(itemName, offsetValue);
                     vo.setCurrentMeasurementValue(offsetValue == null ? null : offsetValue.toString());
-                    Date date = slopeData.getTs();
-                    if (date!=null){
-                        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM-dd HH:mm:ss");
-                        vo.setCurrentMeasurementTime(simpleDateFormat.format(date));
+                    if (slopeData != null) {
+                        Date date = slopeData.getTs();
+                        if (date != null) {
+                            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM-dd HH:mm:ss");
+                            vo.setCurrentMeasurementTime(simpleDateFormat.format(date));
+                        }
                     }
                 }
                 itemList.clear();
@@ -564,10 +566,12 @@ public class DeviceService {
 //                    currentMeasurement.put(itemName, offsetValue);
 //                    vo.setCurrentMeasurementValue(offsetValue == null ? null : offsetValue.toString());
                     vo.setCurrentMeasurementValue(val);
-                    Date date = slopeData.getTs();
-                    if (date!=null){
-                        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM-dd HH:mm:ss");
-                        vo.setCurrentMeasurementTime(simpleDateFormat.format(date));
+                    if (slopeData != null) {
+                        Date date = slopeData.getTs();
+                        if (date != null) {
+                            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM-dd HH:mm:ss");
+                            vo.setCurrentMeasurementTime(simpleDateFormat.format(date));
+                        }
                     }
 
                 }
@@ -581,10 +585,12 @@ public class DeviceService {
 //                    currentMeasurement.put(itemName, offsetValue);
 //                    vo.setCurrentMeasurementValue(offsetValue == null ? null : offsetValue.toString());
                     vo.setCurrentMeasurementValue(val);
-                    Date date = slopeData.getTs();
-                    if (date!=null){
-                        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM-dd HH:mm:ss");
-                        vo.setCurrentMeasurementTime(simpleDateFormat.format(date));
+                    if (slopeData != null) {
+                        Date date = slopeData.getTs();
+                        if (date != null) {
+                            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM-dd HH:mm:ss");
+                            vo.setCurrentMeasurementTime(simpleDateFormat.format(date));
+                        }
                     }
                 }
                 map.put(itemName, vo);

+ 2 - 2
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/KwsAlarmService.java

@@ -527,7 +527,7 @@ public class KwsAlarmService {
     }
 
     public HttpResult dataAlarm(AlarmStatisticsQuery query, HttpServletRequest request) {
-        int type = 1;
+        int type = 2;
         String startTime = query.getStartTime();
         String endTime = query.getEndTime();
         String latitude = query.getLatitude();
@@ -645,7 +645,7 @@ public class KwsAlarmService {
 
 
     public HttpResult deviceAlarm(AlarmStatisticsQuery query, HttpServletRequest request) {
-        int type = 2;
+        int type = 1;
         String startTime = query.getStartTime();
         String endTime = query.getEndTime();
         String latitude = query.getLatitude();