Procházet zdrojové kódy

完善电度采集,负值都取绝对值然后计算

hfxc226 před 6 měsíci
rodič
revize
3996c6fbd1

+ 7 - 4
platform-service/src/main/java/com/platform/service/big/impl/BigScreenSbInfoServiceImpl.java

@@ -202,6 +202,9 @@ public class BigScreenSbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, Sb
      */
     @Override
     public JSONArray getMonthOrDayReport(RemoteDegreeLogDTO record, Boolean isDay) {
+
+        // 缩小倍数,哈光宇传过来的10倍的
+        BigDecimal d = new BigDecimal(10);
         if (record.getYear() == null) {
             throw new BusinessException("请选择年份");
         }
@@ -268,7 +271,7 @@ public class BigScreenSbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, Sb
                                             positiveTotal = positiveTotal.subtract(new BigDecimal(lastR.get().getResult()).abs());
                                         }
                                     }
-                                    dictJsonObject.put("positive", positiveTotal.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP).doubleValue());
+                                    dictJsonObject.put("positive", positiveTotal.divide(d, 2, RoundingMode.HALF_UP).doubleValue());
                                 } else {
                                     negativeTotal = negativeTotal.add(new BigDecimal(degreeLog.getResult()));
                                     // 找到上个时间
@@ -284,7 +287,7 @@ public class BigScreenSbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, Sb
                                             negativeTotal = negativeTotal.subtract(new BigDecimal(lastR.get().getResult()).abs());
                                         }
                                     }
-                                    dictJsonObject.put("negative", negativeTotal.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP).doubleValue());
+                                    dictJsonObject.put("negative", negativeTotal.divide(d, 2, RoundingMode.HALF_UP).doubleValue());
                                 }
                             }
                         }
@@ -368,8 +371,8 @@ public class BigScreenSbInfoServiceImpl extends BaseServiceImpl<SbInfoMapper, Sb
                             }
                         }
                     }
-                    dictJsonObject.put("positive", positiveTotal.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP).doubleValue());
-                    dictJsonObject.put("negative", negativeTotal.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP).doubleValue());
+                    dictJsonObject.put("positive", positiveTotal.divide(d, 2, RoundingMode.HALF_UP).doubleValue());
+                    dictJsonObject.put("negative", negativeTotal.divide(d, 2, RoundingMode.HALF_UP).doubleValue());
                     lineArray.add(dictJsonObject);
                 }
                 jsonObject.put("lines", lineArray);