From 6e397c664037b898b5e9d9955da1d953089e679e Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期二, 09 六月 2026 17:32:07 +0800
Subject: [PATCH] 【市一】手术随访对接
---
ruoyi-quartz/src/main/resources/mapper/quartz/CollectHISMapper.xml | 6
smartor/src/main/java/com/smartor/domain/PatMedOperation.java | 6 +
smartor/src/main/resources/mapper/smartor/PatArchiveMapper.xml | 9 ++
ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/CollectHISServiceImpl.java | 72 ++++++++++++++++++
smartor/src/main/resources/mapper/smartor/PatMedOperationItemMapper.xml | 118 +++++++++++++++++++++++++++--
smartor/src/main/resources/mapper/smartor/PatMedOperationMapper.xml | 6 -
smartor/src/main/java/com/smartor/mapper/PatArchiveMapper.java | 2
smartor/src/main/java/com/smartor/mapper/PatMedOperationItemMapper.java | 15 +++
8 files changed, 218 insertions(+), 16 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 5569719..8884243 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
@@ -334,9 +334,22 @@
patMedOperation.setLastStartTime(startTime);
patMedOperation.setLastEndTime(endTime);
List<PatMedOperation> patMedOperations = chMapper.selectOperList(patMedOperation);
+ Map<String, Long> patIdHisMap = buildOperationPatIdHisMap(patMedOperations);
+
log.info("鍚屾鎵嬫湳淇℃伅鏁伴噺" + patMedOperations.size());
for (PatMedOperation operation : patMedOperations) {
try {
+ Long patId = patIdHisMap.get(operation.getPatidHis());
+ if (patId == null) {
+ patId = syncSinglePatient(operation.getPatidHis());
+ if (patId != null) {
+ patIdHisMap.put(operation.getPatidHis(), patId);
+ }
+ }
+
+ if (patId != null) {
+ operation.setPatid(patId);
+ }
PatMedOperation oper = new PatMedOperation();
oper.setOpid(operation.getOpid());
List<PatMedOperation> patMedOperations1 = patMedOperationMapper.selectPatMedOperationList(oper);
@@ -389,9 +402,68 @@
log.info("鍚屾鎵嬫湳璇︽儏淇℃伅:" + ex.getMessage());
}
}
+
+// try {
+// patMedOperationItemMapper.deleteHardPatMedOperationItemByOpId(operation.getOpid());
+// count += patMedOperationItemMapper.insertPatMedOperationItems(patMedOperationItems);
+// }catch (Exception ex) {
+// log.info("鍚屾鎵嬫湳璇︽儏淇℃伅:" + ex.getMessage());
+// }
}
return count;
}
+
+ private Map<String, Long> buildOperationPatIdHisMap(List<PatMedOperation> operations) {
+ List<String> patidHiss = operations.stream()
+ .map(PatMedOperation::getPatidHis)
+ .filter(StringUtils::isNotEmpty)
+ .distinct()
+ .collect(Collectors.toList());
+
+ if (CollectionUtils.isEmpty(patidHiss)) {
+ return new HashMap<>();
+ }
+
+ return patArchiveMapper.selectPatArchiveByPatidHiss(patidHiss).stream()
+ .filter(item -> StringUtils.isNotEmpty(item.getPatidHis()) && item.getId() !=
+ null)
+ .collect(Collectors.toMap(
+ PatArchive::getPatidHis,
+ PatArchive::getId,
+ (a, b) -> a
+ ));
+ }
+
+ private Long syncSinglePatient(String patidHis) {
+ if (StringUtils.isEmpty(patidHis)) {
+ return null;
+ }
+
+ PatArchive hisQuery = new PatArchive();
+ hisQuery.setPatidHis(patidHis);
+ hisQuery.setPageSize(5);
+ List<PatArchive> hisArchives = chMapper.selectPatArchiveList(hisQuery);
+ if (CollectionUtils.isEmpty(hisArchives)) {
+ return null;
+ }
+
+ PatArchive localQuery = new PatArchive();
+ localQuery.setPatidHis(patidHis);
+ List<PatArchive> localArchives = patArchiveMapper.selectPatArchiveList(localQuery);
+
+ PatArchive hisArchive = hisArchives.get(0);
+ if (CollectionUtils.isNotEmpty(localArchives)) {
+ hisArchive.setId(localArchives.get(0).getId());
+ hisArchive.setUpdateTime(new Date());
+ patArchiveMapper.updatePatArchive(hisArchive);
+ return localArchives.get(0).getId();
+ } else {
+ hisArchive.setCreateTime(new Date());
+ patArchiveMapper.insertPatArchiveSingle(hisArchive);
+ return hisArchive.getId();
+ }
+ }
+
@Override
public Integer selectPatMedInhospList(PatMedInhosp patMedInhosp) {
List<PatMedInhosp> patMedInhospList = chMapper.selectPatMedInhospList(patMedInhosp);
diff --git a/ruoyi-quartz/src/main/resources/mapper/quartz/CollectHISMapper.xml b/ruoyi-quartz/src/main/resources/mapper/quartz/CollectHISMapper.xml
index 1e46f20..94aeecc 100644
--- a/ruoyi-quartz/src/main/resources/mapper/quartz/CollectHISMapper.xml
+++ b/ruoyi-quartz/src/main/resources/mapper/quartz/CollectHISMapper.xml
@@ -226,7 +226,7 @@
<resultMap type="com.smartor.domain.PatMedOuthosp" id="PatMedOuthospResult">
<result property="id" column="id"/>
<result property="serialnum" column="serialnum"/>
- <result property="patid" column="patid"/>
+ <result property="patidHis" column="patid"/>
<result property="hospitalname" column="hospitalname"/>
<result property="hospitalcode" column="hospitalcode"/>
<result property="icd10code" column="icd10code"/>
@@ -338,7 +338,7 @@
<resultMap type="com.smartor.domain.PatMedOperation" id="PatMedOperationResult">
<result property="id" column="id"/>
- <result property="patid" column="patid"/>
+ <result property="patidHis" column="patid_his"/>
<result property="patcode" column="patcode"/>
<result property="paname" column="paname"/>
<result property="opreqid" column="opreqid"/>
@@ -817,7 +817,7 @@
<select id="selectOperList" parameterType="com.smartor.domain.PatMedOperation"
resultMap="PatMedOperationResult">
select
- o.patid,
+ o.patid_his,
o.patcode,
o.paname,
o.opreqid,
diff --git a/smartor/src/main/java/com/smartor/domain/PatMedOperation.java b/smartor/src/main/java/com/smartor/domain/PatMedOperation.java
index 3aa232f..d6b6ae6 100644
--- a/smartor/src/main/java/com/smartor/domain/PatMedOperation.java
+++ b/smartor/src/main/java/com/smartor/domain/PatMedOperation.java
@@ -35,6 +35,12 @@
private Long patid;
/**
+ * his绯荤粺ID
+ */
+ @ApiModelProperty("his绯荤粺ID")
+ private String patidHis;
+
+ /**
* 鐥呬汉缂栧彿
*/
@ApiModelProperty("鐥呬汉缂栧彿")
diff --git a/smartor/src/main/java/com/smartor/mapper/PatArchiveMapper.java b/smartor/src/main/java/com/smartor/mapper/PatArchiveMapper.java
index 72836dd..a215622 100644
--- a/smartor/src/main/java/com/smartor/mapper/PatArchiveMapper.java
+++ b/smartor/src/main/java/com/smartor/mapper/PatArchiveMapper.java
@@ -26,6 +26,8 @@
List<PatArchive> selectPatArchiveByPatnos(@Param("patnos") List<String> patnos);
+ List<PatArchive> selectPatArchiveByPatidHiss(@Param("patidHiss") List<String> patidHiss);
+
/**
* 鏌ヨ鎮h�呮。妗堝垪琛�
*
diff --git a/smartor/src/main/java/com/smartor/mapper/PatMedOperationItemMapper.java b/smartor/src/main/java/com/smartor/mapper/PatMedOperationItemMapper.java
index 614fd61..0c16172 100644
--- a/smartor/src/main/java/com/smartor/mapper/PatMedOperationItemMapper.java
+++ b/smartor/src/main/java/com/smartor/mapper/PatMedOperationItemMapper.java
@@ -38,6 +38,13 @@
public int insertPatMedOperationItem(PatMedOperationItem patMedOperationItem);
/**
+ * 鏂板鎮h�呮鏌ユ楠岃褰曞瓙
+ *
+ * @param patMedOperationItems 鎮h�呮鏌ユ楠岃褰曞瓙
+ * @return 缁撴灉
+ */
+ public int insertPatMedOperationItems(List<PatMedOperationItem> patMedOperationItems);
+ /**
* 淇敼鎮h�呮鏌ユ楠岃褰曞瓙
*
* @param patMedOperationItem 鎮h�呮鏌ユ楠岃褰曞瓙
@@ -60,4 +67,12 @@
* @return 缁撴灉
*/
public int deletePatMedOperationItemByIds(Long[] ids);
+
+ /**
+ * 鍒犻櫎鎮h�呮鏌ユ楠岃褰曞瓙
+ *
+ * @param opid 鎮h�呮鏌ユ楠岃褰曞瓙涓婚敭
+ * @return 缁撴灉
+ */
+ public int deleteHardPatMedOperationItemByOpId(String opid);
}
diff --git a/smartor/src/main/resources/mapper/smartor/PatArchiveMapper.xml b/smartor/src/main/resources/mapper/smartor/PatArchiveMapper.xml
index 22b3f4a..b51c18d 100644
--- a/smartor/src/main/resources/mapper/smartor/PatArchiveMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/PatArchiveMapper.xml
@@ -283,6 +283,15 @@
</foreach>
</select>
+ <select id="selectPatArchiveByPatidHiss" resultMap="PatArchiveResult">
+ SELECT id, patid_his
+ FROM pat_archive
+ WHERE patid_his IN
+ <foreach item="patidHis" collection="patidHiss" open="(" separator="," close=")">
+ #{patidHis}
+ </foreach>
+ </select>
+
<insert id="insertPatArchiveSingle" parameterType="com.smartor.domain.PatArchive" useGeneratedKeys="true"
keyProperty="id">
insert into pat_archive
diff --git a/smartor/src/main/resources/mapper/smartor/PatMedOperationItemMapper.xml b/smartor/src/main/resources/mapper/smartor/PatMedOperationItemMapper.xml
index 25ba255..080bf13 100644
--- a/smartor/src/main/resources/mapper/smartor/PatMedOperationItemMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/PatMedOperationItemMapper.xml
@@ -96,11 +96,9 @@
where id = #{id}
</select>
- <insert id="insertPatMedOperationItem" parameterType="com.smartor.domain.PatMedOperationItem">
+ <insert id="insertPatMedOperationItem" parameterType="com.smartor.domain.PatMedOperationItem" useGeneratedKeys="true" keyProperty="id">
insert into pat_med_operation_item
<trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="id != null">id,
- </if>
<if test="operationid != null">operationid,
</if>
<if test="opid != null">opid,
@@ -149,8 +147,6 @@
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="id != null">#{id},
- </if>
<if test="operationid != null">#{operationid},
</if>
<if test="opid != null">#{opid},
@@ -276,7 +272,110 @@
where id = #{id}
</update>
- <update id="deletePatMedOperationItemById" parameterType="Long">
+ <insert id="insertPatMedOperationItems">
+ insert into pat_med_operation_item
+ <trim prefix="(" suffix=")" suffixOverrides=",">
+ <if test="operationid != null">operationid,
+ </if>
+ <if test="opid != null">opid,
+ </if>
+ <if test="opcode != null">opcode,
+ </if>
+ <if test="opdesc != null">opdesc,
+ </if>
+ <if test="mainFlag != null">main_flag,
+ </if>
+ <if test="incitypecode != null">incitypecode,
+ </if>
+ <if test="incitypedesc != null">incitypedesc,
+ </if>
+ <if test="oplevelcode != null">oplevelcode,
+ </if>
+ <if test="opleveldesc != null">opleveldesc,
+ </if>
+ <if test="opposition != null">opposition,
+ </if>
+ <if test="delFlag != null">del_flag,
+ </if>
+ <if test="updateBy != null">update_by,
+ </if>
+ <if test="updateTime != null">update_time,
+ </if>
+ <if test="createBy != null">create_by,
+ </if>
+ <if test="createTime != null">create_time,
+ </if>
+ <if test="isupload != null">isupload,
+ </if>
+ <if test="uploadTime != null">upload_time,
+ </if>
+ <if test="orgid != null">orgid,
+ </if>
+ <if test="pguid != null">pguid,
+ </if>
+ <if test="guid != null">guid,
+ </if>
+ <if test="pid != null">pid,
+ </if>
+ <if test="opercheckFlag != null">opercheck_flag,
+ </if>
+ <if test="longTaskReason != null">long_task_reason,
+ </if>
+ </trim>
+ values
+ <foreach item="item" index="index" collection="list" separator=",">
+ <trim prefix="(" suffix=")" suffixOverrides=",">
+ <if test="operationid != null">#{item.operationid},
+ </if>
+ <if test="opid != null">#{item.opid},
+ </if>
+ <if test="opcode != null">#{item.opcode},
+ </if>
+ <if test="opdesc != null">#{item.opdesc},
+ </if>
+ <if test="mainFlag != null">#{item.mainFlag},
+ </if>
+ <if test="incitypecode != null">#{item.incitypecode},
+ </if>
+ <if test="incitypedesc != null">#{item.incitypedesc},
+ </if>
+ <if test="oplevelcode != null">#{item.oplevelcode},
+ </if>
+ <if test="opleveldesc != null">#{item.opleveldesc},
+ </if>
+ <if test="opposition != null">#{item.opposition},
+ </if>
+ <if test="delFlag != null">#{item.delFlag},
+ </if>
+ <if test="updateBy != null">#{item.updateBy},
+ </if>
+ <if test="updateTime != null">#{item.updateTime},
+ </if>
+ <if test="createBy != null">#{item.createBy},
+ </if>
+ <if test="createTime != null">#{item.createTime},
+ </if>
+ <if test="isupload != null">#{item.isupload},
+ </if>
+ <if test="uploadTime != null">#{item.uploadTime},
+ </if>
+ <if test="orgid != null">#{item.orgid},
+ </if>
+ <if test="pguid != null">#{item.pguid},
+ </if>
+ <if test="guid != null">#{item.guid},
+ </if>
+ <if test="pid != null">#{item.pid},
+ </if>
+ <if test="opercheckFlag != null">#{item.opercheckFlag},
+ </if>
+ <if test="longTaskReason != null">#{item.longTaskReason},
+ </if>
+ </trim>
+ </foreach>
+ </insert>
+
+ <update id="deletePatMedOperationItemById" parameterType="Long">
update pat_med_operation_item
<trim prefix="SET" suffixOverrides=",">
del_flag =1
@@ -284,7 +383,7 @@
where id = #{id}
</update>
- <update id="deletePatMedOperationItemByIds" parameterType="String">
+ <update id="deletePatMedOperationItemByIds" parameterType="String">
update pat_med_operation_item
<trim prefix="SET" suffixOverrides=",">
del_flag =1
@@ -295,7 +394,10 @@
</foreach>
</update>
-
+ <delete id="deleteHardPatMedOperationItemByOpId" parameterType="String">
+ delete from pat_med_operation_item
+ where opid = #{opid}
+ </delete>
</mapper>
diff --git a/smartor/src/main/resources/mapper/smartor/PatMedOperationMapper.xml b/smartor/src/main/resources/mapper/smartor/PatMedOperationMapper.xml
index 092198d..b5c058d 100644
--- a/smartor/src/main/resources/mapper/smartor/PatMedOperationMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/PatMedOperationMapper.xml
@@ -364,11 +364,9 @@
where id = #{id}
</select>
- <insert id="insertPatMedOperation" parameterType="com.smartor.domain.PatMedOperation">
+ <insert id="insertPatMedOperation" parameterType="com.smartor.domain.PatMedOperation" useGeneratedKeys="true" keyProperty="id">
insert into pat_med_operation
<trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="id != null">id,
- </if>
<if test="patid != null">patid,
</if>
<if test="patcode != null">patcode,
@@ -511,8 +509,6 @@
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="id != null">#{id},
- </if>
<if test="patid != null">#{patid},
</if>
<if test="patcode != null">#{patcode},
--
Gitblit v1.9.3