Browse Source

解决报空指针的BUG

wukai 3 ngày trước cách đây
mục cha
commit
e5302d7924

+ 7 - 7
jjt-biz/src/main/java/com/jjt/biz/service/impl/ApiYrServiceImpl.java

@@ -126,19 +126,19 @@ public class ApiYrServiceImpl implements IApiYrService {
             Pair<Integer, Integer> pair = deviceStatus.get(deviceId);
 
             Integer lengthA = teamMap.get("A").getKey();
-            Integer lengthB = teamMap.get("B").getKey();
-            if (lengthB == null) {
-                lengthB = 0;
+            Integer lengthB = 0;
+            if (teamMap.get("B") != null) {
+                lengthB = teamMap.get("B").getKey();
             }
             Integer length = lengthA + lengthB;
 
             BigDecimal weightA = teamMap.get("A").getValue();
-            BigDecimal weightB = teamMap.get("B").getValue();
-            if (weightB == null) {
-                weightB = BigDecimal.ZERO;
+            BigDecimal weightB = BigDecimal.ZERO;
+            if (teamMap.get("B") != null) {
+                weightB = teamMap.get("B").getValue();
             }
             BigDecimal weight = weightA.add(weightB);
-            
+
             YrProdEfficiencyVO vo = arr[deviceId];
             if (pair != null) {
                 vo.setTotal(pair.getKey());