Ver código fonte

修复被除数为0导致月报生成异常的问题

lixing 3 anos atrás
pai
commit
f82b3394cb

+ 4 - 4
src/main/java/com/persagy/apm/report/indicator/factory/EnergyBudgetFactory.java

@@ -53,7 +53,7 @@ public class EnergyBudgetFactory {
         Double currentMonth = energyUsageFactory.getMonthlyUsageValue(energyUsageDefine, reportMonth, projectId);
         String currentMonthStr = currentMonth == null ? null : String.valueOf(currentMonth);
         return new AttrValueVO(BudgetContentCodes.currentMonth.name(),
-            currentMonthStr, AttrValueTypeEnum.number_1);
+                currentMonthStr, AttrValueTypeEnum.number_1);
     }
 
     /**
@@ -175,7 +175,7 @@ public class EnergyBudgetFactory {
      * @version V1.0 2021/7/27 2:38 下午
      */
     private Double getProportion(Double usage, Double budget) {
-        if (usage != null && budget != null) {
+        if (usage != null && budget != null && budget != 0d) {
             return DataUtils.doubleDivide(usage, budget);
         }
         return null;
@@ -192,7 +192,7 @@ public class EnergyBudgetFactory {
      */
     public AttrValueVO getMonthlyProportion(Double currentMonth, Double monthlyBudget) {
         Double proportion = getProportion(currentMonth, monthlyBudget);
-        String proportionStr = proportion == null? null:String.valueOf(proportion);
+        String proportionStr = proportion == null ? null : String.valueOf(proportion);
         return new AttrValueVO(BudgetContentCodes.monthlyProportion.name(),
                 proportionStr, AttrValueTypeEnum.percent_1, DataConstants.PERCENT);
     }
@@ -208,7 +208,7 @@ public class EnergyBudgetFactory {
      */
     public AttrValueVO getAnnualProportion(Double aggregate, Double annualBudget) {
         Double proportion = getProportion(aggregate, annualBudget);
-        String proportionStr = proportion == null? null:String.valueOf(proportion);
+        String proportionStr = proportion == null ? null : String.valueOf(proportion);
         return new AttrValueVO(BudgetContentCodes.annualProportion.name(),
                 proportionStr, AttrValueTypeEnum.percent_1, DataConstants.PERCENT);
     }

+ 1 - 1
src/main/java/com/persagy/apm/report/indicator/factory/EnergyEfficiencyFactory.java

@@ -128,7 +128,7 @@ public class EnergyEfficiencyFactory {
      * @version V1.0 2021/8/2 6:49 下午
      */
     public AttrValueVO getUnqualifiedProportion(Double projectCount, Double unqualifiedCount) {
-        if (projectCount == null || unqualifiedCount == null) {
+        if (projectCount == null || unqualifiedCount == null || projectCount == 0d) {
             return new AttrValueVO(AreaEnergyEfficiencyContentCodes.unqualifiedProportion.name(),
                     null, AttrValueTypeEnum.percent_2);
         }

+ 1 - 1
src/main/java/com/persagy/apm/report/indicator/factory/EnvFactory.java

@@ -189,7 +189,7 @@ public class EnvFactory {
      * @version V1.0 2021/8/4 4:14 下午
      */
     public AttrValueVO getHandleProportion(Double handledCount, Double totalCount) {
-        if (handledCount == null || totalCount == null) {
+        if (handledCount == null || totalCount == null || totalCount == 0d) {
             return new AttrValueVO(ProjectEnvContentCodes.handleProportion.name(),
                     null, AttrValueTypeEnum.percent_2, DataConstants.PERCENT);
         }

+ 1 - 1
src/main/java/com/persagy/apm/report/indicator/utils/IndicatorUtils.java

@@ -64,7 +64,7 @@ public class IndicatorUtils {
      */
     public static Double getPerSqmValue(Double value, Double area) {
         Double perSqm = null;
-        if (value != null && area != null) {
+        if (value != null && area != null && area != 0d) {
             perSqm = DataUtils.doubleDivide(value, area);
         }
         return perSqm;