From d047a35e640a59e02a422d9a9a62c752c88b69b5 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期三, 28 十月 2026 15:51:52 +0800
Subject: [PATCH] 【丽水】 同一 inhospid + taskid 已存在未删除的首次随访(upid 为空)时,不再插入,避免出现两条首次随访

---
 smartor/src/main/java/com/smartor/service/impl/PatMedInhospServiceImpl.java |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/smartor/src/main/java/com/smartor/service/impl/PatMedInhospServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/PatMedInhospServiceImpl.java
index 9160c37..e1ba487 100644
--- a/smartor/src/main/java/com/smartor/service/impl/PatMedInhospServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/PatMedInhospServiceImpl.java
@@ -708,6 +708,29 @@
         //璁板綍insertServiceSubtask璇彞杩斿洖鐘舵��
         Integer i = 0;
         try {
+            // 鍏滃簳锛氫换鍔℃ā鏉夸慨鏀逛細閲嶇疆 pat_med_inhosp 鐨勫鐞嗘爣璁帮紝浣嗗凡瀹屾垚鐨勯璁夸笉浼氬垹闄ゃ��
+            // 鍚屼竴 inhospid + taskid 宸插瓨鍦ㄦ湭鍒犻櫎鐨勯娆¢殢璁匡紙upid 涓虹┖锛夋椂锛屼笉鍐嶆彃鍏ワ紝閬垮厤鍑虹幇涓ゆ潯棣栨闅忚銆�
+            if (check
+                    && ("2".equals(serviceTask.getServiceType()) || "13".equals(serviceTask.getServiceType()))
+                    && (type == 1 || type == 2 || type == 3)) {
+                ServiceSubtaskEntity firstQuery = new ServiceSubtaskEntity();
+                firstQuery.setInhospid(patMedInhosp1.getInhospid());
+                firstQuery.setTaskid(taskid);
+                List<ServiceSubtask> firstList = serviceSubtaskMapper.selectServiceSubtaskList(firstQuery);
+                boolean firstExists = CollectionUtils.isNotEmpty(firstList)
+                        && firstList.stream().anyMatch(item -> item.getUpid() == null);
+                if (firstExists) {
+                    log.info("鎮h�厈}宸插瓨鍦ㄩ娆¢殢璁夸换鍔★紝璺宠繃閲嶅鐢熸垚, taskid={}, type={}",
+                            patMedInhosp1.getInhospid(), taskid, type);
+                    PatMedInhosp flagUpdate = new PatMedInhosp();
+                    flagUpdate.setInhospid(patMedInhosp1.getInhospid());
+                    if (type == 1) flagUpdate.setDeptcheckFlag("1");
+                    if (type == 2) flagUpdate.setWardcheckFlag("1");
+                    if (type == 3) flagUpdate.setDiagcheckFlag("1");
+                    patMedInhospMapper.updatePatMedInhosp(flagUpdate);
+                    return;
+                }
+            }
             //鍏堝垽鏂竴涓嬶紝鏄惁闇�瑕佹牎楠�
             if (check && (Objects.isNull(serviceSubtask.getTaskSituation()) || serviceSubtask.getTaskSituation() != 6)) {
                 //鍦ㄦ柊澧炰箣鍓嶏紝鍏堥�氳繃鎮h�匢D锛宻endstate=2鏌ヨ涓�涓嬶紝鍦ㄦ墍鏈夐暱鏈熶换鍔′腑锛屾槸涓嶆槸杩樻湁璇ユ偅鑰呭緟鎵ц鐨勪换鍔★紝鏈夌殑璇�,姣旇緝涔嬪墠鐨別ndtime鏄惁灏忎簬褰撳墠鐨別ndtaime,濡傛灉涔嬪墠鐨勫皬浜庣幇鍦ㄧ殑锛屽垯鐩存帴灏嗕箣鍓嶇殑鍋滄帀锛堝師鍥犲啀鍏ラ櫌锛�

--
Gitblit v1.9.3