From ecbb6791ae00a8a4076715b87a941c0a8557fa03 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期二, 13 一月 2026 11:31:34 +0800
Subject: [PATCH] 【市一】采集出入院增加院区id
---
ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/CollectHISServiceImpl.java | 134 +++++++++++++++++++++++++++++++++-----------
1 files changed, 99 insertions(+), 35 deletions(-)
diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/CollectHISServiceImpl.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/CollectHISServiceImpl.java
index 7612fae..c0c38f9 100644
--- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/CollectHISServiceImpl.java
+++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/CollectHISServiceImpl.java
@@ -12,6 +12,7 @@
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
@@ -41,6 +42,9 @@
private SysUserDeptMapper sysUserDeptMapper;
@Autowired
+ private SysUserOrgMapper sysUserOrgMapper;
+
+ @Autowired
private Icd10Mapper icd10Mapper;
@Autowired
@@ -65,6 +69,9 @@
private static final String PAT_ARCHIVE_TABLE = "pat_archive";
private static final String PAT_MED_INHOSP_TABLE = "pat_med_inhosp";
+ @Value("${spring.profiles.active}")
+ private String active;
+
@Override
public List<PatArchive> selectPatArchiveList(PatArchive patArchive) {
@@ -85,6 +92,7 @@
/**
* 鍚屾浠诲姟
+ *
* @param
* @return
*/
@@ -104,15 +112,15 @@
//鍚屾浣忛櫌鐥呬汉淇℃伅
List<Map<String, Object>> syncTemp = syncList.stream().filter(row -> row.get("syncName").equals("pat_med_inhosp")).collect(Collectors.toList());
if (syncTemp.size() > 0) {
- count+=syncMedInhosp(syncTemp.get(0).get("startTime") + "", endTime);
- utilsMapper.updateSql("update sys_sync_time set startTime='"+endTime+"' where syncName='pat_med_inhosp' ");
+ count += syncMedInhosp(syncTemp.get(0).get("startTime") + "", endTime);
+ utilsMapper.updateSql("update sys_sync_time set startTime='" + endTime + "' where syncName='pat_med_inhosp' ");
}
//鍚屾闂ㄨ瘖淇℃伅
syncTemp = syncList.stream().filter(row -> row.get("syncName").equals("pat_med_outhosp")).collect(Collectors.toList());
if (syncTemp.size() > 0) {
- count+=syncOuthosp(syncTemp.get(0).get("startTime") + "", endTime);
- utilsMapper.updateSql("update sys_sync_time set startTime='"+endTime+"' where syncName='pat_med_outhosp' ");
+ count += syncOuthosp(syncTemp.get(0).get("startTime") + "", endTime);
+ utilsMapper.updateSql("update sys_sync_time set startTime='" + endTime + "' where syncName='pat_med_outhosp' ");
}
@@ -124,10 +132,11 @@
/**
* 鍚屾鎮h�呭熀鏈俊鎭�
+ *
* @param
* @return
*/
- private Integer syncArchive(String startTime,String endTime) {
+ private Integer syncArchive(String startTime, String endTime) {
Integer count = 0;
PatArchive pa = new PatArchive();
pa.setLastStartTime(startTime);
@@ -148,8 +157,8 @@
count += patArchiveMapper.insertPatArchiveSingle(pm);
}
- }catch (Exception ex){
- log.info("鍙悓鎮h�呭熀鏈俊鎭�:"+ex.getMessage());
+ } catch (Exception ex) {
+ log.info("鍙悓鎮h�呭熀鏈俊鎭�:" + ex.getMessage());
}
}
@@ -158,10 +167,11 @@
/**
* 鍚屾鍑哄叆闄俊鎭�
+ *
* @param
* @return
*/
- private Integer syncMedInhosp(String startTime,String endTime) {
+ private Integer syncMedInhosp(String startTime, String endTime) {
Integer count = 0;
PatMedInhosp patMedInhosp = new PatMedInhosp();
patMedInhosp.setLastStartTime(startTime);
@@ -169,11 +179,11 @@
List<PatMedInhosp> patMedInhospList = chMapper.selectPatMedInhospList(patMedInhosp);
log.info("鍙悓姝ュ嚭鍏ラ櫌鏁伴噺" + patMedInhospList.size());
for (PatMedInhosp pm : patMedInhospList) {
- List<PatArchive> patArchives1=new ArrayList<>();
+ List<PatArchive> patArchives1 = new ArrayList<>();
try {
//鎮h�呭熀鏈俊鎭�
- if(ObjectUtils.isNotEmpty(pm.getPatno())) {
+ if (ObjectUtils.isNotEmpty(pm.getPatno())) {
PatArchive patArchive = new PatArchive();
patArchive.setPatientno(pm.getPatno());
patArchive.setPageSize(5);
@@ -193,12 +203,12 @@
}
}
}
- }catch (Exception ex) {
+ } catch (Exception ex) {
log.info("鍚屾偅鑰呭熀鏈俊鎭�:" + ex.getMessage());
}
try {
- if(patArchives1.size()>0) {
+ if (patArchives1.size() > 0) {
pm.setPatid(patArchives1.get(0).getId());
}
//鍚屾鍑哄叆闄�
@@ -207,10 +217,20 @@
List<PatMedInhosp> patMedInhospList1 = patMedInhospMapper.selectPatMedInhospListBySerialnum(pmi);
if (patMedInhospList1.size() == 0) {
pm.setCreateTime(new Date());
+ //甯備竴 闄㈠尯id瀵瑰簲orgid锛屾満鏋刬d涓洪粯璁ょ殑1
+ if(active.equals("hzszlyy")) {
+ pm.setCampusid(pm.getOrgid());
+ pm.setOrgid("1");
+ }
count += patMedInhospMapper.insertPatMedInhosp(pm);
} else {
pm.setInhospid(patMedInhospList1.get(0).getInhospid());
pm.setUpdateTime(new Date());
+ //甯備竴 闄㈠尯id瀵瑰簲orgid锛屾満鏋刬d涓洪粯璁ょ殑1
+ if(active.equals("hzszlyy")) {
+ pm.setCampusid(pm.getOrgid());
+ pm.setOrgid("1");
+ }
count += patMedInhospMapper.updatePatMedInhosp(pm);
}
} catch (Exception ex) {
@@ -222,10 +242,11 @@
/**
* 鍚屾闂ㄨ瘖淇℃伅
+ *
* @param
* @return
*/
- private Integer syncOuthosp(String startTime,String endTime) {
+ private Integer syncOuthosp(String startTime, String endTime) {
Integer count = 0;
PatMedOuthosp patMedOuthosp = new PatMedOuthosp();
patMedOuthosp.setLastStartTime(startTime);
@@ -252,7 +273,7 @@
}
}
- }catch (Exception ex) {
+ } catch (Exception ex) {
log.info("鍚屾偅鑰呭熀鏈俊鎭�:" + ex.getMessage());
}
@@ -263,9 +284,19 @@
if (patMedOuthospsTemp.size() > 0) {
patMedOuthosp1.setUpdateTime(new Date());
patMedOuthosp1.setId(patMedOuthospsTemp.get(0).getId());
+ //甯備竴 闄㈠尯id瀵瑰簲orgid锛屾満鏋刬d涓洪粯璁ょ殑1
+ if(active.equals("hzszlyy")) {
+ patMedOuthosp1.setCampusid(patMedOuthosp1.getOrgid());
+ patMedOuthosp1.setOrgid("1");
+ }
count += patMedOuthospMapper.updatePatMedOuthosp(patMedOuthosp1);
} else {
patMedOuthosp1.setCreateTime(new Date());
+ //甯備竴 闄㈠尯id瀵瑰簲orgid锛屾満鏋刬d涓洪粯璁ょ殑1
+ if(active.equals("hzszlyy")) {
+ patMedOuthosp1.setCampusid(patMedOuthosp1.getOrgid());
+ patMedOuthosp1.setOrgid("1");
+ }
count += patMedOuthospMapper.insertPatMedOuthosp(patMedOuthosp1);
}
} catch (Exception ex) {
@@ -278,7 +309,7 @@
@Override
public Integer selectPatMedInhospList(PatMedInhosp patMedInhosp) {
List<PatMedInhosp> patMedInhospList = chMapper.selectPatMedInhospList(patMedInhosp);
- log.info("鍙悓姝ョ梾浜烘暟閲�"+patMedInhospList.size());
+ log.info("鍙悓姝ョ梾浜烘暟閲�" + patMedInhospList.size());
for (PatMedInhosp pm : patMedInhospList) {
PatArchive patArchive = new PatArchive();
patArchive.setPatientno(pm.getPatno());
@@ -323,10 +354,8 @@
@Override
public Boolean hnDataGather(HnDataGatherVO hnDataGatherVO) {
- if(ObjectUtils.isEmpty(hnDataGatherVO.getStartTime()) )
- hnDataGatherVO.setStartTime(new Date());
- if(ObjectUtils.isEmpty(hnDataGatherVO.getEndTime()) )
- hnDataGatherVO.setEndTime(new Date());
+ if (ObjectUtils.isEmpty(hnDataGatherVO.getStartTime())) hnDataGatherVO.setStartTime(new Date());
+ if (ObjectUtils.isEmpty(hnDataGatherVO.getEndTime())) hnDataGatherVO.setEndTime(new Date());
LocalDate startDate = hnDataGatherVO.getStartTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
LocalDate endDate = hnDataGatherVO.getEndTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
@@ -415,10 +444,13 @@
@Override
public Integer selectUserList(SysUser sysUser) {
List<SysUser> sysUserList = chMapper.selectUserList(sysUser);
- SysUser suerTemp=new SysUser();
+ SysUser suerTemp = new SysUser();
List<SysUserDept> sysUserDeptAll = chMapper.yhyksxx(suerTemp);
+ //鐢ㄦ埛-闄㈠尯鍏崇郴
+ List<SysUserOrg> sysUserOrgAll = chMapper.yhyyqxx(suerTemp);
+
log.info("sysUserList鐨勯噰闆嗗埌鐨勬暟閲忎负锛歿}", sysUserList.size());
- int i =0;// sysUser2Mapper.batchUser(sysUserList);
+ int i = 0;// sysUser2Mapper.batchUser(sysUserList);
for (SysUser sysUser1 : sysUserList) {
// log.info("sysUser1鐨処D涓猴細{}", sysUser1.getUserId());
// log.info("sysUser1鐨凥ISUSERID涓猴細{}", sysUser1.getHisUserId());
@@ -438,17 +470,20 @@
//鏂板鐢ㄦ埛涓庨儴闂�
//List<SysUserDept> sysUserDept = chMapper.yhyksxx(sysUser1);
- List<SysUserDept> sysUserDept = sysUserDeptAll.stream()
- .filter((SysUserDept b) -> b.getUserCode().equals(sysUser1.getHisUserId()))
- .collect(Collectors.toList());
+ List<SysUserDept> sysUserDept = sysUserDeptAll.stream().filter((SysUserDept b) -> b.getUserCode().equals(sysUser1.getHisUserId())).collect(Collectors.toList());
for (SysUserDept sud : sysUserDept) {
if (usersTemp.size() > 0) {
sud.setUserId(usersTemp.get(0).getUserId());
- SysDept sysDeptTemp = sysDept2Mapper.selectDeptByCode(sud.getDeptCode());
- if (sysDeptTemp != null)
- sud.setDeptId(sysDeptTemp.getDeptId());
sysUserDeptMapper.insertSysUserDept(sud);
+ }
+ }
+ //鏂板鐢ㄦ埛涓庨櫌鍖�
+ List<SysUserOrg> sysUserOrg = sysUserOrgAll.stream().filter((SysUserOrg o) -> o.getUserId().equals(sysUser1.getHisUserId())).collect(Collectors.toList());
+ for (SysUserOrg suo : sysUserOrg) {
+ if (usersTemp.size() > 0) {
+ suo.setUserId(usersTemp.get(0).getUserId());
+ sysUserOrgMapper.insertSysUserOrg(suo);
}
}
}
@@ -458,20 +493,49 @@
@Override
public Integer selectDeptList(SysDept dept) {
- int count=0;
+ int count = 0;
List<SysDept> sysDepts = chMapper.selectDeptList(dept);
log.info("selectDeptList鐨勯噰闆嗗埌鐨勬暟閲忎负锛歿}", sysDepts.size());
- // count = sysDept2Mapper.batchDept(sysDepts);
- for(SysDept row : sysDepts){
- SysDept sysDeptTemp= sysDept2Mapper.selectDeptByCode(row.getDeptCode());
- if(sysDeptTemp!=null&&sysDeptTemp.getDeptName()!=null){
+ // count = sysDept2Mapper.batchDept(sysDepts);
+ for (SysDept row : sysDepts) {
+ SysDept sysDeptTemp = sysDept2Mapper.selectDeptByCode(row.getDeptCode(), null);
+ if (sysDeptTemp != null && sysDeptTemp.getDeptName() != null) {
row.setDeptId(sysDeptTemp.getDeptId());
- count+=sysDept2Mapper.updateDept(row);
- }else{
- count+=sysDept2Mapper.insertDept(row);
+ count += sysDept2Mapper.updateDept(row);
+ } else {
+ count += sysDept2Mapper.insertDept(row);
}
}
return count;
}
+
+ /**
+ * 妫�鏌ュ苟鎵ц鍒嗚〃鐨勬牳蹇冩柟娉�
+ *
+ * @param tableName 瑕佹鏌ョ殑琛ㄥ悕
+ */
+ private synchronized void checkAndShard(String tableName) {
+ long currentCount = shardingMapper.getTableCount(tableName);
+
+ if (currentCount >= SHARDING_THRESHOLD) {
+ log.warn("琛� '{}' 宸茶揪鍒板垎琛ㄩ槇鍊� {}锛屽噯澶囨墽琛屽垎琛ㄦ搷浣�...", tableName, SHARDING_THRESHOLD);
+
+ String newTableName = tableName + "_" + java.time.LocalDate.now().format(java.time.format.DateTimeFormatter.ofPattern("yyyy_MM"));
+ Long maxId = shardingMapper.getMaxId(tableName);
+ if (maxId == null) maxId = 0L;
+
+ shardingMapper.renameTable(tableName, newTableName);
+ log.info("宸插皢琛� '{}' 閲嶅懡鍚嶄负 '{}'", tableName, newTableName);
+
+ shardingMapper.createLikeTable(tableName, newTableName);
+ log.info("宸插垱寤烘柊琛� '{}'", tableName);
+
+ shardingMapper.setAutoIncrement(tableName, maxId + 1);
+ log.info("宸茶缃柊琛� '{}' 鐨勮嚜澧濱D璧峰鍊间负 {}", tableName, maxId + 1);
+
+ log.info("琛� '{}' 鐨勫垎琛ㄦ搷浣滃畬鎴愶紒", tableName);
+ }
+ }
+
}
--
Gitblit v1.9.3