From 63013400c2790a650878445c8352992df71103b2 Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期三, 19 七月 2023 11:42:59 +0800
Subject: [PATCH] Merge branch 'master' of http://dev.vci-tech.com:1065/r/ubcs

---
 Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/web/util/VciBaseUtil.java |   66 +++++++++++++++++++++++++++++---
 1 files changed, 59 insertions(+), 7 deletions(-)

diff --git a/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/web/util/VciBaseUtil.java b/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/web/util/VciBaseUtil.java
index 7bf4b8b..7bf46f2 100644
--- a/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/web/util/VciBaseUtil.java
+++ b/Source/UBCS/ubcs-service-api/ubcs-util-api/src/main/java/com/vci/ubcs/starter/web/util/VciBaseUtil.java
@@ -5,6 +5,8 @@
 // (powered by FernFlower decompiler)
 //
 
+import cn.hutool.core.lang.Snowflake;
+import cn.hutool.core.util.IdUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.serializer.SerializerFeature;
 import com.baomidou.mybatisplus.annotation.TableField;
@@ -52,7 +54,12 @@
 	}
 
 	public static String getPk() {
-		return UUID.randomUUID().toString();
+		return String.valueOf(getPKLong(1,1));
+	}
+
+	public static  Long getPKLong(long workerId,long dataCenterId){
+		Snowflake snowflake = IdUtil.getSnowflake(workerId,dataCenterId);
+		return snowflake.nextId();
 	}
 
 	public static int getIntForBoolean(boolean b) {
@@ -862,7 +869,7 @@
 	}
 
 	public static String getTableName(String btmname) {
-		return (VciQueryWrapperForDO.USER_TABLE_COMPATIBILITY ? "pl_code_" : "vcibt_") + btmname.trim().toLowerCase();
+		return (VciQueryWrapperForDO.USER_TABLE_COMPATIBILITY ? "vcibt_" : "pl_code_") + btmname.trim().toLowerCase();
 	}
 
 	public static Field getTsField(Class c) {
@@ -1136,7 +1143,38 @@
 	public static <T> Collection<Collection<T>> switchCollectionForOracleIn(Collection<T> list) {
 		return switchCollectionForOracleIn(list, 500);
 	}
-
+	/**
+	 * oracle in 鏌ヨ涓嶈兘瓒呰繃1000锛岃浆鎹竴涓嬮泦鍚�
+	 * 鐢变簬SQL璇彞1000涓彲鑳藉緢闀匡紝瓒呰繃oracle10g锛屾墍浠ョ壓鐗叉�ц兘鍒嗛厤涓�500涓暟缁�
+	 * @param list 闇�瑕佽浆鎹㈢殑鍒楄〃鍐呭
+	 * @return 鍒嗙粍鍚庣殑list
+	 */
+	public static <T> List<List<T>> switchListForOracleIn(List<T> list) {
+		List<List<T>> listHasList = new ArrayList<List<T>>();
+		if(list == null){
+			return listHasList;
+		}
+		List<T> newList = new ArrayList<T>();
+		for(Object obj : list){
+			//涓轰簡璁﹍ist杩樺彲浠ユ坊鍔犲唴瀹癸紝鍥犱负浣跨敤sublist鍚庯紝list涓嶈兘鍐岮dd浜�
+			newList.add((T)obj);
+		}
+		int muti = 1;
+		if(newList.size() >500){
+			int balance = newList.size()%500;
+			muti = (newList.size() - balance)/500 + (balance == 0?0:1);
+		}
+		for(int i = 0 ; i < muti; i ++){
+			int start = i*500;
+			int end = start + 500;
+			if(i == muti-1 || end >newList.size() ){
+				end = newList.size();
+			}
+			List subList = newList.subList(start,end);
+			listHasList.add(subList);
+		}
+		return listHasList;
+	}
 	public static <T> Collection<Collection<T>> switchCollectionForOracleIn(Collection<T> collection, int preSize) {
 		Collection<Collection<T>> listHasList = new ArrayList();
 		if (collection == null) {
@@ -1256,13 +1294,14 @@
 	 * @return Map瀵硅薄
 	 * @version 2016骞�3鏈�20鏃� 11:03:01
 	 */
-	public static Map convertBean2Map(Object bean) throws Exception {
+	public static Map convertBean2Map(Object bean,Set<String> existFild) throws Exception {
 		Class type = bean.getClass();
 		Map returnMap = new HashMap();
 		BeanInfo beanInfo = Introspector.getBeanInfo(type);
 		PropertyDescriptor[] propertyDescriptors = beanInfo
 			.getPropertyDescriptors();
 		Field[] declaredFields = type.getDeclaredFields();
+		Map<String, String> fieldMap = new HashMap();
 		String existField = "";
 		for (Field declaredField : declaredFields) {
 			declaredField.setAccessible(true);
@@ -1274,6 +1313,10 @@
 				Boolean fieldValue = tableField.exist();
 				if(fieldValue == false){
 					existField += declaredField.getName().toLowerCase()+",";
+				}
+				String value = tableField.value();
+				if(net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils.isNotBlank(value)){
+					fieldMap.put(declaredField.getName(), value);
 				}
 			}
 		}
@@ -1289,12 +1332,21 @@
 
 				if (result != null) {
 					if ("data".equals(propertyName)){
-						returnMap.putAll((Map) result);
+						if(existFild == null){
+							returnMap.putAll((Map) result);
+						}else{
+							Map resulMap = (Map) result;
+							for (Object o : resulMap.keySet()) {
+								if(existFild.contains(o)){
+									returnMap.put(o,resulMap.get(o));
+								}
+							}
+						}
 					}else {
-						returnMap.put(propertyName, result);
+						returnMap.put(fieldMap.containsKey(propertyName)?fieldMap.get(propertyName):propertyName, result);
 					}
 				} else {
-					returnMap.put(propertyName, "");
+					returnMap.put(fieldMap.containsKey(propertyName)?fieldMap.get(propertyName):propertyName, "");
 				}
 			}
 		}

--
Gitblit v1.9.3