From e70f05c79c91d5159524e6b6033206ad3fc8c02b Mon Sep 17 00:00:00 2001
From: lihang <lihang@vci-tech.com>
Date: 星期四, 20 四月 2023 10:17:10 +0800
Subject: [PATCH] 元数据联调修正
---
Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/util/VciBaseUtil.java | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 113 insertions(+), 0 deletions(-)
diff --git a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/util/VciBaseUtil.java b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/util/VciBaseUtil.java
index 379bfc5..58336f4 100644
--- a/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/util/VciBaseUtil.java
+++ b/Source/UBCS/ubcs-service-api/ubcs-code-api/src/main/java/com/vci/ubcs/com/vci/starter/web/util/VciBaseUtil.java
@@ -10,6 +10,7 @@
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.vci.ubcs.com.vci.starter.exception.VciBaseException;
import com.vci.ubcs.com.vci.starter.web.pagemodel.SessionInfo;
+import com.vci.ubcs.com.vci.starter.web.toolmodel.DateConverter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.CollectionUtils;
@@ -34,6 +35,7 @@
import java.util.stream.Collectors;
public class VciBaseUtil {
+
private static Logger log = LoggerFactory.getLogger(VciBaseUtil.class);
public static final String NOTIN = "not in";
private static String localIp = null;
@@ -43,6 +45,15 @@
public static String getPk() {
return UUID.randomUUID().toString();
+ }
+
+ public static SessionInfo getCurrentUserSessionInfo() throws VciBaseException {
+ SessionInfo si = getCurrentUserSessionInfoNotException();
+ if (si == null) {
+ throw new VciBaseException("noLogin", new String[]{"娌℃湁褰撳墠鐢ㄦ埛淇℃伅"});
+ } else {
+ return si;
+ }
}
public static int getIntForBoolean(boolean b) {
@@ -1094,5 +1105,107 @@
}
}
+ public static <T> Collection<Collection<T>> switchCollectionForOracleIn(Collection<T> list) {
+ return switchCollectionForOracleIn(list, 500);
+ }
+
+ public static <T> Collection<Collection<T>> switchCollectionForOracleIn(Collection<T> collection, int preSize) {
+ Collection<Collection<T>> listHasList = new ArrayList();
+ if (collection == null) {
+ return listHasList;
+ } else {
+ List<T> newList = new ArrayList();
+ Iterator var4 = collection.iterator();
+
+ while(var4.hasNext()) {
+ Object obj = var4.next();
+ newList.add((T) obj);
+ }
+
+ int muti = 1;
+ int i;
+ if (newList.size() > preSize) {
+ i = newList.size() % preSize;
+ muti = (newList.size() - i) / preSize + (i == 0 ? 0 : 1);
+ }
+
+ for(i = 0; i < muti; ++i) {
+ int start = i * preSize;
+ int end = start + preSize;
+ if (i == muti - 1 || end > newList.size()) {
+ end = newList.size();
+ }
+
+ List subList = newList.subList(start, end);
+ listHasList.add(subList);
+ }
+
+ return listHasList;
+ }
+ }
+ public static short getShort(String s) {
+// short i = false;
+ if (s == null) {
+ return 0;
+ } else {
+ try {
+ short i = Short.parseShort(s);
+ return i;
+ } catch (Exception var3) {
+ return 0;
+ }
+ }
+ }
+
+ public static void setValueForField(Field field, Object obj, String value) {
+ try {
+ if (field != null && StringUtils.isNotBlank(value)) {
+ field.setAccessible(true);
+ Method setMethod = getSetmethod(field.getDeclaringClass(), field.getName());
+ Class type = field.getType();
+ Object valueObj = null;
+ if (!type.equals(Integer.TYPE) && !type.equals(Integer.class)) {
+ if (!type.equals(Float.TYPE) && !type.equals(Float.class)) {
+ if (!type.equals(Long.TYPE) && !type.equals(Long.class)) {
+ if (!type.equals(Double.class) && !type.equals(Double.TYPE)) {
+ if (type.equals(Date.class)) {
+ DateConverter dateConverter = new DateConverter();
+ dateConverter.setAsText(value);
+ valueObj = dateConverter.getValue();
+ } else if (type.equals(String.class)) {
+ valueObj = value;
+ } else {
+ valueObj = value;
+ if (log.isErrorEnabled()) {
+ log.error("涓嶆敮鎸佺殑绫诲瀷" + type.toString());
+ }
+ }
+ } else {
+ valueObj = getDouble(value);
+ }
+ } else {
+ valueObj = getLong(value);
+ }
+ } else {
+ valueObj = getFloat(value);
+ }
+ } else {
+ valueObj = getInt(value);
+ }
+
+ if (setMethod != null) {
+ setMethod.invoke(obj, valueObj);
+ } else {
+ field.set(obj, valueObj);
+ }
+ }
+ } catch (Throwable var7) {
+ if (log.isErrorEnabled()) {
+ log.error("璁剧疆灞炴�х殑鍊煎嚭閿欎簡閿欒", var7);
+ }
+ }
+
+ }
+
}
--
Gitblit v1.9.3