Explorar o código

给表添加注释修改

wanwei hai 6 meses
pai
achega
c4f58bcdec
Modificáronse 1 ficheiros con 17 adicións e 10 borrados
  1. 17 10
      src/main/java/kd/bos/newdevportal/table/TableListPlugin.java

+ 17 - 10
src/main/java/kd/bos/newdevportal/table/TableListPlugin.java

@@ -1,5 +1,7 @@
 package kd.bos.newdevportal.table;
 
+import cfca.org.slf4j.Logger;
+import cfca.org.slf4j.LoggerFactory;
 import kd.bos.dataentity.utils.StringUtils;
 import kd.bos.db.DB;
 import kd.bos.db.DBRoute;
@@ -22,6 +24,7 @@ import java.util.stream.Collectors;
  * @version 1.0
  */
 public class TableListPlugin extends TableManagerListPlugin {
+    public static final Logger log = LoggerFactory.getLogger(TableListPlugin.class);
     public void registerListener(EventObject e) {
         super.registerListener(e);
         this.addItemClickListeners(new String[]{"toolbarap"});
@@ -36,21 +39,26 @@ public class TableListPlugin extends TableManagerListPlugin {
             // 统计成功和失败的次数
             int successCount = 0;
             int failureCount = 0;
-            for (ListSelectedRow detail : list) {
-                Object pk = detail.getPrimaryKeyValue();
+            for (int i = 0; i < list.size(); i++) {
+                Object pk = list.get(i).getPrimaryKeyValue();
                 String pkStr = String.valueOf(pk);
                 String[] info = pkStr.split("@@");
                 if (info.length < 2) {
                     failureCount++; // 如果数据不正确,增加失败计数
                     continue; // 跳过此条记录,继续处理下一条
                 }
-                //获取数据字典明细
-                String tablename = info[0];//表名称
-                String entityId = info[1];//id
-                String dbroute = EntityMetadataCache.getDataEntityType(MetadataDao.getEntityNumberById(info[1])).getDBRouteKey();
-                // 根据 dbroute 将数据分组
-                entityIdGroups.computeIfAbsent(dbroute, k -> new ArrayList<>()).add(pkStr);
+                try {
+                    //获取数据字典明细
+                    String tablename = info[0];//表名称
+                    String entityId = info[1];//id
+                    String dbroute = EntityMetadataCache.getDataEntityType(MetadataDao.getEntityNumberById(info[1])).getDBRouteKey();
+                    // 根据 dbroute 将数据分组
+                    entityIdGroups.computeIfAbsent(dbroute, k -> new ArrayList<>()).add(pkStr);
+                } catch (Exception e) {
+                    log.info(info[0] + "添加注释失败,错误原因:"+e.toString());
+                }
             }
+
             // 打印每个分组的 tablename
             for (Map.Entry<String, List<String >> entry : entityIdGroups.entrySet()) {
                 String dbroute = entry.getKey();
@@ -100,8 +108,7 @@ public class TableListPlugin extends TableManagerListPlugin {
                             DB.execute(route, sqlContent);
                             successCount++; // 增加成功计数
                         } catch (Exception e) {
-                            // 处理执行过程中可能出现的异常
-                            e.printStackTrace(); // 可以替换为日志记录
+                            log.info(tablename + "执行sql失败,错误原因:"+e.toString());
                             failureCount++; // 增加失败计数
                         }
                     }else {