From 8a857fe1b0b69dafbdaa15b45edab03a2c3bcdb2 Mon Sep 17 00:00:00 2001 From: 田源 <lastanimals@163.com> Date: 星期二, 09 七月 2024 09:52:47 +0800 Subject: [PATCH] 成员管理表格查询 增删改 分配成员 统计 下载导入模板 --- Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/VciBaseUtil.java | 51 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 48 insertions(+), 3 deletions(-) diff --git a/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/VciBaseUtil.java b/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/VciBaseUtil.java index 913d390..6d17c4f 100644 --- a/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/VciBaseUtil.java +++ b/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/util/VciBaseUtil.java @@ -1,8 +1,12 @@ package com.vci.starter.web.util; import cn.hutool.core.bean.BeanUtil; +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.vci.common.exception.VciExceptionTool; +import com.vci.corba.common.PLException; import com.vci.starter.web.annotation.Id; import com.vci.starter.web.annotation.VciBtmType; import com.vci.starter.web.annotation.VciLinkType; @@ -48,6 +52,23 @@ public class VciBaseUtil { /** + * 鑾峰彇寮傚父淇℃伅,鍥犱负鎶涘嚭鐨勫紓甯镐笉鍚岋紝鑾峰彇閿欒淇℃伅鐨勬柟寮忓瓨鍦ㄥ樊寮傛墍浠ユ棤娉曠粺涓�鑾峰彇 + * 鍚庣画鏈夊叾浠栧紓甯搁渶瑕佽幏鍙栵紝鑷娣诲姞澶勭悊閫昏緫锛� + * @param e + * @return + */ + public static String getExceptionMessage(Exception e){ + String exceptionStr = VciExceptionTool.getExceptionStr(e); + if(exceptionStr.contains("VciBaseException")){ + return e.getMessage(); + }else if(exceptionStr.contains("PLException")){ + return Arrays.stream(((PLException) e).messages).collect(Collectors.joining("\n")); + }else { + return e.getMessage(); + } + } + + /** * 鏃ュ織瀵硅薄 */ private static Logger log = LoggerFactory.getLogger(VciBaseUtil.class); @@ -59,6 +80,19 @@ */ public static String getPk() { return UUID.randomUUID().toString(); + } + + /** + * 闆姳ID + * @return + */ + public static String getSnowflakePk() { + return String.valueOf(getSnowflakePk(1,1)); + } + + public static Long getSnowflakePk(long workerId,long dataCenterId){ + Snowflake snowflake = IdUtil.getSnowflake(workerId,dataCenterId); + return snowflake.nextId(); } /** @@ -1210,7 +1244,7 @@ * @return 浼氳瘽瀵硅薄 */ public static SessionInfo getCurrentUserSessionInfoNotException() { - return WebThreadLocalUtil.getCurrentUserSessionInfoInThread().get(); + return WebThreadLocalUtil.getCurrentUserSessionInfoInThread(); } /** @@ -1218,7 +1252,7 @@ * @param sessionInfo 鐢ㄦ埛瀵硅薄 */ public static void setCurrentUserSessionInfo(SessionInfo sessionInfo){ - WebThreadLocalUtil.getCurrentUserSessionInfoInThread().set(sessionInfo); + WebThreadLocalUtil.setCurrentUserSessionInfoInThread(sessionInfo); } /** @@ -1226,7 +1260,7 @@ * @return true琛ㄧず鏌ヨ */ public static boolean isQueryTotal(){ - String needQueryTotal = WebThreadLocalUtil.getNeedQueryTotalInThread().get(); + String needQueryTotal = WebThreadLocalUtil.getNeedQueryTotalInThread(); if("false".equalsIgnoreCase(needQueryTotal)){ return false; }else{ @@ -1929,4 +1963,15 @@ } return new String(c); } + + /** + * 灏唖tring闆嗗悎杞负stirng鏁扮粍 + * @param strCollection string闆嗗悎 + * @return string鏁扮粍 + */ + public static String[] collection2StrArr(Collection<String> strCollection){ + String[] strArr = new String[strCollection.size()]; + strCollection.toArray(strArr); + return strArr; + } } -- Gitblit v1.9.3