Bladeren bron

修复无法设置边框问题

wangming 1 jaar geleden
bovenliggende
commit
11f8942200

+ 3 - 4
luckysheet-db/src/main/java/com/xc/luckysheet/db/IRecordDataUpdataHandle.java

@@ -1,8 +1,8 @@
 package com.xc.luckysheet.db;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.xc.luckysheet.entity.GridRecordDataModel;
-import org.springframework.stereotype.Repository;
 
 import java.util.List;
 
@@ -126,7 +126,7 @@ public interface IRecordDataUpdataHandle {
      * @param words
      * @return
      */
-    boolean updateJsonbForInsertNull(JSONObject query, String word, JSONObject db, Integer position, String words);
+    boolean updateJsonbForInsertNull(JSONObject query, String word, JSON db, Integer position, String words);
 
     /**
      * jsonb数据中元素添加元素
@@ -148,7 +148,6 @@ public interface IRecordDataUpdataHandle {
      * @param words
      * @return
      */
-    boolean updateJsonbForSetRootNull(JSONObject query, String word, JSONObject db, Integer position, String words);
-
+    boolean updateJsonbForSetRootNull(JSONObject query, String word, JSON db, Integer position, String words);
 
 }

+ 15 - 0
luckysheet-db/src/main/java/com/xc/luckysheet/util/JfGridFileUtil.java

@@ -279,6 +279,21 @@ public class JfGridFileUtil {
         return null;
     }
 
+    /**
+     * 从对象中获取一个指定的对象
+     * @param dbObject
+     * @param k
+     * @return
+     */
+    public static JSONArray getArrayByObject(JSONObject dbObject, String k){
+        if(dbObject!=null){
+            if(dbObject.containsKey(k)){
+                return dbObject.getJSONArray(k);
+            }
+        }
+        return null;
+    }
+
 
 
     /**

+ 3 - 2
luckysheet-mongo/src/main/java/com/xc/luckysheet/mongo/impl/RecordDataUpdataHandle.java

@@ -1,5 +1,6 @@
 package com.xc.luckysheet.mongo.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.mongodb.BasicDBList;
 import com.mongodb.BasicDBObject;
@@ -381,7 +382,7 @@ public class RecordDataUpdataHandle extends BaseHandle implements IRecordDataUpd
      * @return
      */
     @Override
-    public boolean updateJsonbForInsertNull(JSONObject query, String word, JSONObject db, Integer position, String words) {
+    public boolean updateJsonbForInsertNull(JSONObject query, String word, JSON db, Integer position, String words) {
         Query q=new Query();
         q.addCriteria(tranToCriteria(query));
 
@@ -427,7 +428,7 @@ public class RecordDataUpdataHandle extends BaseHandle implements IRecordDataUpd
      * @return
      */
     @Override
-    public boolean updateJsonbForSetRootNull(JSONObject query, String word, JSONObject db, Integer position, String words) {
+    public boolean updateJsonbForSetRootNull(JSONObject query, String word, JSON db, Integer position, String words) {
         Query q=new Query();
         q.addCriteria(tranToCriteria(query));
 

+ 2 - 2
luckysheet-mysql/src/main/java/com/xc/luckysheet/mysql/impl/RecordDataUpdataHandle.java

@@ -431,7 +431,7 @@ public class RecordDataUpdataHandle extends BaseHandle implements IRecordDataUpd
      */
     @Transactional(value = "mysqlTxManager",rollbackFor = Exception.class)
     @Override
-    public boolean updateJsonbForInsertNull(JSONObject query, String word, JSONObject db, Integer position, String words) {
+    public boolean updateJsonbForInsertNull(JSONObject query, String word, JSON db, Integer position, String words) {
         try{
             if(word!=null){
                 word=word.replace(",",".");
@@ -523,7 +523,7 @@ public class RecordDataUpdataHandle extends BaseHandle implements IRecordDataUpd
      */
     @Transactional(value = "mysqlTxManager",rollbackFor = Exception.class)
     @Override
-    public boolean updateJsonbForSetRootNull(JSONObject query, String word, JSONObject db, Integer position, String words) {
+    public boolean updateJsonbForSetRootNull(JSONObject query, String word, JSON db, Integer position, String words) {
         return updateJsonbForInsertNull(query, word, db, position, words);
 //        try{
 //            log.info("select:"+query.toString(SerializerFeature.WriteMapNullValue));

+ 3 - 2
luckysheet-postgre/src/main/java/com/xc/luckysheet/postgres/impl/RecordDataUpdataHandle.java

@@ -1,5 +1,6 @@
 package com.xc.luckysheet.postgres.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.serializer.SerializerFeature;
 import com.xc.luckysheet.JfGridConfigModel;
@@ -416,7 +417,7 @@ public class RecordDataUpdataHandle extends BaseHandle implements IRecordDataUpd
      */
     @Transactional(value = "postgresTxManager",rollbackFor = Exception.class)
     @Override
-    public boolean updateJsonbForInsertNull(JSONObject query, String word, JSONObject db, Integer position, String words) {
+    public boolean updateJsonbForInsertNull(JSONObject query, String word, JSON db, Integer position, String words) {
         String condition="";
         try{
             log.info("select:"+query.toString(SerializerFeature.WriteMapNullValue));
@@ -494,7 +495,7 @@ public class RecordDataUpdataHandle extends BaseHandle implements IRecordDataUpd
      */
     @Transactional(value = "postgresTxManager",rollbackFor = Exception.class)
     @Override
-    public boolean updateJsonbForSetRootNull(JSONObject query, String word, JSONObject db, Integer position, String words) {
+    public boolean updateJsonbForSetRootNull(JSONObject query, String word, JSON db, Integer position, String words) {
         String condition="";
         try{
             log.info("select:{}",query.toString(SerializerFeature.WriteMapNullValue));

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

@@ -402,7 +402,7 @@ public class JfGridUpdateService {
                 return "更新失败";
             }
         } catch (Exception ex) {
-            log.error(ex.getMessage());
+            log.error("执行sql异常, {}", ex);
         }
         return "";
     }
@@ -441,7 +441,7 @@ public class JfGridUpdateService {
             }
 
         } catch (Exception ex) {
-            log.error(ex.getMessage());
+            log.error("执行sql异常, {}", ex);
         }
         return "";
     }
@@ -492,7 +492,7 @@ public class JfGridUpdateService {
                 }
             }
         } catch (Exception ex) {
-            log.error(ex.getMessage());
+            log.error("执行sql异常, {}", ex);
         }
         return "";
     }
@@ -532,7 +532,7 @@ public class JfGridUpdateService {
                 return "更新失败";
             }
         } catch (Exception ex) {
-            log.error(ex.getMessage());
+            log.error("执行sql异常, {}", ex);
         }
         return "";
     }
@@ -587,7 +587,7 @@ public class JfGridUpdateService {
             }
 
         } catch (Exception ex) {
-            log.error(ex.getMessage());
+            log.error("执行sql异常, {}", ex);
         }
         return "";
     }
@@ -645,7 +645,7 @@ public class JfGridUpdateService {
             }
 
         } catch (Exception ex) {
-            log.error(ex.getMessage());
+            log.error("执行sql异常, {}", ex);
         }
         return "";
     }
@@ -811,7 +811,7 @@ public class JfGridUpdateService {
 
 
         } catch (Exception ex) {
-            log.error(ex.getMessage());
+            log.error("执行sql异常, {}", ex);
         }
         return "";
     }
@@ -943,7 +943,7 @@ public class JfGridUpdateService {
 
 
         } catch (Exception ex) {
-            log.error(ex.getMessage());
+            log.error("执行sql异常, {}", ex);
             return ex.getMessage();
         }
         return "";
@@ -976,7 +976,7 @@ public class JfGridUpdateService {
                     }
                 }
             } catch (Exception ex) {
-                log.error(ex.getMessage());
+                log.error("执行sql异常, {}", ex);
             }
         }
     }
@@ -1144,7 +1144,7 @@ public class JfGridUpdateService {
             }
 
         } catch (Exception ex) {
-            log.error(ex.getMessage());
+            log.error("执行sql异常, {}", ex);
         }
         return "";
     }
@@ -1201,7 +1201,7 @@ public class JfGridUpdateService {
             }
 
         } catch (Exception ex) {
-            log.error(ex.getMessage());
+            log.error("执行sql异常, {}", ex);
         }
         return "";
     }
@@ -1240,7 +1240,7 @@ public class JfGridUpdateService {
                 return "更新失败";
             }
         } catch (Exception ex) {
-            log.error(ex.getMessage());
+            log.error("执行sql异常, {}", ex);
         }
         return "";
     }
@@ -1290,7 +1290,7 @@ public class JfGridUpdateService {
             }
 
         } catch (Exception ex) {
-            log.error(ex.getMessage());
+            log.error("执行sql异常, {}", ex);
         }
         return "";
     }
@@ -1309,9 +1309,13 @@ public class JfGridUpdateService {
             String i = bson.get("i").toString();
             String k = bson.get("k").toString();
 
-            JSONObject _v = null;//需要替换的值
+            JSON _v = null;//需要替换的值
             if (bson.get("v") != null) {
-                _v = bson.getJSONObject("v");
+                if("borderInfo".equals(k)) {
+                    _v = bson.getJSONArray("v");
+                } else {
+                    _v = bson.getJSONObject("v");
+                }
             }
             if (_v == null) {
                 //没有要修改的值
@@ -1329,17 +1333,21 @@ public class JfGridUpdateService {
             //判断_v中是否存在null,则删除该参数
             boolean flag = false;
             String keys = "";
-            if (_v.keySet().size() != 0) {
-                for (String key : _v.keySet()) {
-                    if (_v.get(key) == null) {
-                        keys = key;
-                        flag = true;
+            if(!"borderInfo".equals(k)) {
+                JSONObject vObj = (JSONObject) _v;
+                if (vObj.keySet().size() != 0) {
+                    for (String key : vObj.keySet()) {
+                        if (vObj.get(key) == null) {
+                            keys = key;
+                            flag = true;
+                        }
                     }
+                } else {
+                    flag = true;
                 }
-            } else {
-                flag = true;
             }
 
+
             //Query query = new Query();
             //query.addCriteria(Criteria.where("list_id").is(gridKey).and("index").is(i).and("block_id").is(JfGridConfigModel.FirstBlockID));
             JSONObject query=getQuery(gridKey,i,JfGridConfigModel.FirstBlockID);
@@ -1359,7 +1367,13 @@ public class JfGridUpdateService {
                         return "删除失败";
                     }
                 } else {
-                    JSONObject _k = JfGridFileUtil.getObjectByObject(_config, k);
+                    JSON _k;
+//                    JSONObject _k = JfGridFileUtil.getObjectByObject(_config, k);
+                    if("borderInfo".equals(k)) {
+                        _k = JfGridFileUtil.getArrayByObject(_config, k);
+                    } else {
+                        _k = JfGridFileUtil.getObjectByObject(_config, k);
+                    }
                     if (_k != null) {
                         //新值覆盖旧值
                         //_k.putAll(_v);
@@ -1379,7 +1393,7 @@ public class JfGridUpdateService {
                 }
             }
         } catch (Exception ex) {
-            log.error(ex.getMessage());
+            log.error("执行sql异常, {}", ex);
         }
         return "";
     }
@@ -1566,7 +1580,7 @@ public class JfGridUpdateService {
             }
 
         } catch (Exception ex) {
-            log.error(ex.getMessage());
+            log.error("执行sql异常, {}", ex);
         }
         return "";
     }
@@ -1701,7 +1715,7 @@ public class JfGridUpdateService {
             }
 
         } catch (Exception ex) {
-            log.error(ex.getMessage());
+            log.error("执行sql异常, {}", ex);
         }
         return "";
     }
@@ -1729,7 +1743,7 @@ public class JfGridUpdateService {
                 return "改名失败";
             }
         } catch (Exception ex) {
-            log.error(ex.getMessage());
+            log.error("执行sql异常, {}", ex);
         }
         return "";
     }
@@ -1794,7 +1808,7 @@ public class JfGridUpdateService {
             }
 
         } catch (Exception ex) {
-            log.error(ex.getMessage());
+            log.error("执行sql异常, {}", ex);
         }
         return "";
     }
@@ -1890,7 +1904,7 @@ public class JfGridUpdateService {
             }
 
         } catch (Exception ex) {
-            log.error(ex.getMessage());
+            log.error("执行sql异常, {}", ex);
         }
         return "";
     }
@@ -2120,7 +2134,7 @@ public class JfGridUpdateService {
             }
             log.info("修改行列数据结果--end");
         } catch (Exception ex) {
-            log.error(ex.getMessage());
+            log.error("执行sql异常, {}", ex);
         }
 
         return "";
@@ -2158,7 +2172,7 @@ public class JfGridUpdateService {
             }
 
         } catch (Exception ex) {
-            log.error(ex.getMessage());
+            log.error("执行sql异常, {}", ex);
         }
         return "";
     }