Explorar el Código

修复数据不存在导致空指针

wangming hace 10 meses
padre
commit
981ef313be

+ 31 - 0
luckysheet/src/main/java/com/xc/luckysheet/db/server/JfGridUpdateService.java

@@ -777,6 +777,12 @@ public class JfGridUpdateService {
             if (_celldatas != null) {
                 for (int x = _celldatas.size() - 1; x >= 0; x--) {
                     JSONObject _cell=_celldatas.getJSONObject(x);
+
+                    if(_cell.get("r") == null || _cell.get("c") == null) {
+                        _celldatas.remove(x);
+                        continue;
+                    }
+
                     Integer _r = Integer.parseInt(_cell.get("r").toString());
                     Integer _c = Integer.parseInt(_cell.get("c").toString());
                     //判断是否添加
@@ -1038,6 +1044,12 @@ public class JfGridUpdateService {
         for (int x = _celldatas.size() - 1; x >= 0; x--) {
             try {
                 JSONObject _cell = _celldatas.getJSONObject(x);
+
+                if(_cell.get("r") == null || _cell.get("c") == null) {
+                        _celldatas.remove(x);
+                    continue;
+                }
+
                 Integer _r = Integer.parseInt(_cell.get("r").toString());
                 Integer _c = Integer.parseInt(_cell.get("c").toString());
                 for (ConfigMergeModel _cmModel : _list) {
@@ -1497,6 +1509,11 @@ public class JfGridUpdateService {
             for (int x = 0; x < _count; x++) {
                 JSONObject bson = dbObject.get(x);
                 String i = bson.get("i").toString();//	当前sheet的index值
+
+                if(bson == null || bson.get("c") == null) {
+                    continue;
+                }
+
                 Integer r = Integer.parseInt(bson.get("r").toString());//	单元格的行号
                 Integer c = Integer.parseInt(bson.get("c").toString());//	单元格的列号
                 Object v = bson.get("v");  //	单元格的值 v=null 删除单元格
@@ -1571,6 +1588,11 @@ public class JfGridUpdateService {
                             int _total = _celldata.size();
                             for (int y = 0; y < _total; y++) {
                                 JSONObject _b =_celldata.getJSONObject(y);
+
+                                if(_b.get("r") == null || _b.get("c") == null) {
+                                    continue;
+                                }
+
                                 if (_b.get("r").toString().equals(r + "") && _b.get("c").toString().equals(c + "")) {
                                     _b.put("v", v);
                                     _position = y;
@@ -1596,6 +1618,11 @@ public class JfGridUpdateService {
                             int _total = _celldata.size();
                             for (int y = 0; y < _total; y++) {
                                 JSONObject _b = _celldata.getJSONObject(y);
+
+                                if(_b.get("r") == null || _b.get("c") == null) {
+                                    continue;
+                                }
+
                                 if (_b.get("r").toString().equals(r + "") && _b.get("c").toString().equals(c + "")) {
                                     _position = y;
                                     break;
@@ -1676,6 +1703,10 @@ public class JfGridUpdateService {
             return "";
         }
 
+        if(bson == null || bson.get("c") == null) {
+            return "";
+        }
+
         //不压缩处理
         try {
             log.info("start---Operation_v" + bson.toString());