From f042d058f0655a2dbe1026c94d4054288fce0e17 Mon Sep 17 00:00:00 2001
From: wangxuanran <3055088966@qq.com>
Date: Wed, 19 Jul 2023 15:35:30 +0800
Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E4=B8=8B=E4=B8=80=E4=B8=AA?=
=?UTF-8?q?=E4=BA=BA=E5=91=98/=E9=83=A8=E9=97=A8=E6=96=B9=E6=B3=95?=
=?UTF-8?q?=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/java/aiyh/utils/Util.java | 45 ++++++++++++++---
.../XkHospitalCommonDefinition.java | 50 +++----------------
.../row/HrmDepartmentRowDefinition.java | 10 +++-
.../table/HrmDepartmentTableDefinition.java | 35 ++++++++++---
.../mapper/XkHospitalDataAsyncMapper.java | 4 +-
.../wang/xk_hospital/test/XkHospitalTest.java | 36 +++++++++++++
6 files changed, 119 insertions(+), 61 deletions(-)
diff --git a/src/main/java/aiyh/utils/Util.java b/src/main/java/aiyh/utils/Util.java
index 136bd19..f0dd810 100644
--- a/src/main/java/aiyh/utils/Util.java
+++ b/src/main/java/aiyh/utils/Util.java
@@ -12,6 +12,7 @@ import aiyh.utils.mapUtil.UtilHashMap;
import aiyh.utils.mapUtil.UtilLinkedHashMap;
import aiyh.utils.mapper.UtilMapper;
import aiyh.utils.recordset.RecordsetUtil;
+import aiyh.utils.recordset.RsThreadLocalManager;
import aiyh.utils.service.UtilService;
import aiyh.utils.sqlUtil.builderSql.impl.BuilderSqlImpl;
import aiyh.utils.sqlUtil.whereUtil.Where;
@@ -106,6 +107,7 @@ public class Util extends weaver.general.Util {
static ToolUtil toolUtil = new ToolUtil();
private static RecordSet rs;
private static volatile Logger log = null;
+ private static final RsThreadLocalManager LOCAL_MANAGER = new RsThreadLocalManager();
static {
try {
@@ -4111,14 +4113,15 @@ public class Util extends weaver.general.Util {
* @return 部门id
**/
public static int getNextDepartmentId(int subId){
- RecordSet insertRs = new RecordSet();
char separator = weaver.general.Util.getSeparator();
String uuid = UUID.randomUUID().toString();
+ String empty = "";
String para = uuid + separator +uuid + separator +
- "" + separator + "" + separator + subId + separator + 1 + separator + "";
- insertRs.executeProc("HrmDepartment_Insert", para);
- if(insertRs.next()){
- return insertRs.getInt(1);
+ empty + separator + empty + separator + subId + separator + 1 + separator + empty;
+ RecordSet procRs = getThreadRecord();
+ procRs.executeProc("HrmDepartment_Insert", para);
+ if(procRs.next()){
+ return procRs.getInt(1);
}
return -1;
}
@@ -4132,13 +4135,43 @@ public class Util extends weaver.general.Util {
* @return 人员id
**/
public static int getNextHrmId(){
- RecordSet procRs = new RecordSet();
+ RecordSet procRs = getThreadRecord();
procRs.executeProc("HrmResourceMaxId_Get", "");
if (procRs.next()) {
return procRs.getInt(1);
}
return -1;
}
+
+ /**
+ *
获取当前线程rs对象
+ * @author xuanran.wang
+ * @dateTime 2023/7/19 15:28
+ * @return recordSet对象
+ **/
+ public static RecordSet getThreadRecord(){
+ String name = Thread.currentThread().getId() + "_" + Thread.currentThread().getName();
+ return getRecordFromRsManger(name);
+ }
+
+ /**
+ * 通过名字获取rs池中rs对象
+ * @author xuanran.wang
+ * @dateTime 2023/7/19 15:29
+ * @param name rs池中的key
+ * @return recordSet对象
+ **/
+ public static RecordSet getRecordFromRsManger(String name){
+ RecordSet rs = LOCAL_MANAGER.getRs(name);
+ if(null == rs){
+ LOCAL_MANAGER.setRecordSet(name);
+ rs = LOCAL_MANAGER.getRs(name);
+ if(null == rs){
+ rs = new RecordSet();
+ }
+ }
+ return rs;
+ }
}
diff --git a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/XkHospitalCommonDefinition.java b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/XkHospitalCommonDefinition.java
index 477ed90..e447d77 100644
--- a/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/XkHospitalCommonDefinition.java
+++ b/src/main/java/com/api/xuanran/wang/xk_hospital/data_async/definitions/XkHospitalCommonDefinition.java
@@ -8,10 +8,6 @@ import com.engine.common.service.impl.ThemeServiceImpl;
import org.apache.log4j.Logger;
import weaver.hrm.company.DepartmentComInfo;
import weaver.hrm.resource.ResourceComInfo;
-import weaver.matrix.MatrixUtil;
-
-import java.util.List;
-import java.util.Map;
import java.util.concurrent.ExecutorService;
/**
@@ -49,14 +45,16 @@ public class XkHospitalCommonDefinition {
* 部门缓存
**/
protected static final DepartmentComInfo DEPARTMENT_COM_INFO = new DepartmentComInfo();
- /**
- * 人员缓存
- **/
- protected static ResourceComInfo RESOURCE_COM_INFO = null;
+
/**
* 系统主题接口
**/
protected static final ThemeServiceImpl THEME_SERVICE = new ThemeServiceImpl();
+ /**
+ * 人员缓存
+ **/
+ protected static ResourceComInfo RESOURCE_COM_INFO = null;
+
static {
try {
RESOURCE_COM_INFO = new ResourceComInfo();
@@ -66,40 +64,4 @@ public class XkHospitalCommonDefinition {
}
}
- /**
- * 同步系统缓存
- * @param table 表名
- * @param idList 数据id集合
- */
- protected void synCache(String table, List idList){
- if (DEPARTMENT.equals(table)) {
- threadPoolInstance.execute(()->{
- try {
- DEPARTMENT_COM_INFO.removeCache();
- MatrixUtil.sysDepartmentData();
- }catch (Exception e){
- log.error("同步系统部门缓存error : " + e.getMessage());
- Util.logErrorStr(e);
- }
- });
- }else if(HRM_RESOURCE.equals(table)){
- try {
- List