| 
					
				 | 
			
			
				@@ -0,0 +1,75 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+package kd.bos.newdevportal.table; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.dataentity.utils.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.db.DB; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.db.DBRoute; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.entity.EntityMetadataCache; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.entity.datamodel.ListSelectedRow; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.entity.datamodel.ListSelectedRowCollection; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.exception.KDException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.form.control.events.ItemClickEvent; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.list.BillList; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.metadata.dao.MetadataDao; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.EventObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Iterator; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * TableListPlugin 添加表注释和表字段注释 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * <p> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * 添加表注释和表字段注释 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * </p> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * @author ww 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * @version 1.0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+public class TableListPlugin extends TableManagerListPlugin { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void registerListener(EventObject e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        super.registerListener(e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.addItemClickListeners(new String[]{"toolbarap"}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void itemClick(ItemClickEvent evt) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String itemKey = evt.getItemKey(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if ("nckd_remark".equals(itemKey)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            BillList billList = (BillList)this.getControl("billlistap"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            ListSelectedRowCollection list =  billList.getSelectedRows(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for (ListSelectedRow detail : list) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Object pk = detail.getPrimaryKeyValue(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                String pkStr = String.valueOf(pk); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                String[] info = pkStr.split("@@"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (info.length < 2) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    throw new KDException("err data"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //获取数据字典明细 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                String tablename = info[0];//表名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                String entityId = info[1];//id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                String dbroute = EntityMetadataCache.getDataEntityType(MetadataDao.getEntityNumberById(info[1])).getDBRouteKey(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                TableInfoProvider provider = TableInfoProvider.create(DBRoute.of(dbroute == null ? "sys" : dbroute)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                String refEntityNum =  StringUtils.isNotBlank(entityId) ? MetadataDao.getNumberById(entityId) : null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                DesignerTable table =  provider.getTableInfo(tablename == null ? "t_bd_attachment" : tablename, refEntityNum); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //表注释 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                String comment = table.getName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                StringBuilder sql = new StringBuilder(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (table != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    sql.append("/*dialect*/ COMMENT ON TABLE " + tablename + " IS '" + comment + "';"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    //获取表字段 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    Iterator fields = table.getCols().iterator(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    while(fields.hasNext()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        DesignerColumn col = (DesignerColumn)fields.next(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        String f_fieldkey = col.getCode();//字段标识 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        String f_fieldname = col.getName();//字段名称 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        sql.append("/*dialect*/ COMMENT ON COLUMN " + tablename + "." +f_fieldkey + " IS '" + f_fieldname + "';"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    // 获取SQL字符串 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    String sqlContent = sql.toString(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    //执行 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    DBRoute route = DBRoute.of(dbroute); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    DB.execute(route, sqlContent); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 |