From 4c0da4f99ca97d2cfcaa00fd5cd9c3d69d089bfa Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期三, 22 四月 2026 19:39:04 +0800
Subject: [PATCH] 获取subid

---
 smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java |   87 ++++++++++++++++++++++++++++++++++++-------
 1 files changed, 73 insertions(+), 14 deletions(-)

diff --git a/smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java
index 66c5a2e..f58bb00 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java
@@ -7,6 +7,7 @@
 import com.ruoyi.common.core.domain.entity.SysUserDept;
 import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.exception.base.BaseException;
+import com.ruoyi.common.utils.AesUtils;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.DtoConversionUtils;
 import com.ruoyi.common.utils.StringUtils;
@@ -24,6 +25,8 @@
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
@@ -154,6 +157,9 @@
         sysUser.setCampusid("1");
         //鏍规嵁userName鍒ゆ柇涓�涓嬶紝鏄笉鏄箣鍓嶆湁鏂板
         SysUser sysUser1 = null;
+        if (StringUtils.isEmpty(sysUser.getUserName()) || StringUtils.isEmpty(sysUser.getOrgid())) {
+            return false;
+        }
         List<SysUser> sysUserList = sysUserMapper.selectUserList(sysUser);
         if (CollectionUtils.isNotEmpty(sysUserList)) {
             sysUser1 = sysUserList.get(0);
@@ -548,6 +554,17 @@
         }
         if (CollectionUtils.isNotEmpty(epai)) externalInHospPatientAddrInfo = epai2.get(0);
         if (CollectionUtils.isNotEmpty(epli)) externalInHospPatientLiaisonInfo = epli2.get(0);
+        List<HashMap<String, Object>> bingRenKZXXList = ObjectUtils.isNotEmpty(yeWuXX) ? (List<HashMap<String, Object>>) yeWuXX.get("BingRenKZXXList") : null;
+        if (CollectionUtils.isNotEmpty(bingRenKZXXList)) {
+            for (HashMap<String, Object> bingRenKZXX : bingRenKZXXList) {
+                String XiangMuDM = ObjectUtils.isNotEmpty(bingRenKZXX.get("XiangMuDM")) ? bingRenKZXX.get("XiangMuDM").toString() : null;
+                if (StringUtils.isNotEmpty(XiangMuDM) && XiangMuDM.equals("DuanHaoXX")) {
+                    externalInHospPatientInfo.setDuanHaoXX(ObjectUtils.isNotEmpty(bingRenKZXX.get("XiangMuZMC")) ? bingRenKZXX.get("XiangMuZMC").toString() : null);
+                    break;
+                }
+            }
+        }
+
         //鏂板鎮h�呭熀鏈俊鎭柊澧炴垨淇敼
         PatArchive patArchive = addPatArchive(externalInHospPatientInfo, externalInHospPatientAddrInfo, externalInHospPatientLiaisonInfo);
 
@@ -596,7 +613,7 @@
         patMedInhosp1.setDeptcode(externalInHospPatientInfo.getDangQianKSID());
 
         if (ObjectUtils.isNotEmpty(SuiFangJH)) {
-            patMedInhosp1.setFuflag(ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangBS")) ? SuiFangJH.get("SuiFangBS").toString() : null);
+            patMedInhosp1.setFuflag(ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangBS")) ? SuiFangJH.get("SuiFangBS").toString() : "1");
             if (ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangRQ"))) {
                 try {
                     SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -630,9 +647,10 @@
         patMedInhosp1.setInhospstate("1");
         if (deathFlag) {
             //鐥呬汉姝讳骸鏃犻』闅忚
-            patMedInhosp1.setFuflag("1");
+            patMedInhosp1.setFuflag("0");
             //鏇存柊鐥呬汉 notrequiredFlag
             patArchive.setNotrequiredFlag("1");
+            patArchive.setNotrequiredreason("鎮h�呭凡绂讳笘");
             patArchiveMapper.updatePatArchive(patArchive);
             //瀵瑰凡缁忕敓鎴愮殑闅忚浠诲姟杩涜澶勭悊
             ServiceSubtaskEntity serviceSubtaskVO = new ServiceSubtaskEntity();
@@ -640,8 +658,8 @@
             serviceSubtaskVO.setSendstate(2L);
             List<ServiceSubtask> serviceSubtaskList = serviceSubtaskMapper.selectServiceSubtaskList(serviceSubtaskVO);
             for (ServiceSubtask serviceSubtask : serviceSubtaskList) {
-                serviceSubtask.setSendstate(6L);
-                serviceSubtask.setRemark(serviceSubtask.getRemark() + ";鐥呬汉宸叉浜★紝涓嶉殢璁�");
+                serviceSubtask.setSendstate(4L);
+                serviceSubtask.setRemark(serviceSubtask.getRemark() + ";鎮h�呭凡绂讳笘锛屼笉闅忚");
                 serviceSubtaskMapper.updateServiceSubtask(serviceSubtask);
             }
         }
@@ -652,7 +670,7 @@
             patMedInhosp1.setCampusid("1");
             if (CollectionUtils.isNotEmpty(noLongTask) && noLongTask.contains(patMedInhosp1.getOrgid())) {
                 //涓嶉渶瑕侀暱鏈熶换鍔¢殢璁�
-                patMedInhosp1.setFuflag("1");
+                patMedInhosp1.setFuflag("0");
             }
             int i = patMedInhospMapper.updatePatMedInhosp(patMedInhosp1);
             if (i != 1) return false;
@@ -675,7 +693,7 @@
             patMedInhosp1.setCreateTime(new Date());
             if (CollectionUtils.isNotEmpty(noLongTask) && noLongTask.contains(patMedInhosp1.getOrgid())) {
                 //涓嶉渶瑕侀暱鏈熶换鍔¢殢璁�
-                patMedInhosp1.setFuflag("1");
+                patMedInhosp1.setFuflag("0");
             }
 
             int i = patMedInhospMapper.insertPatMedInhosp(patMedInhosp1);
@@ -754,7 +772,7 @@
         patMedInhosp1.setDeptcode(externalInHospPatientInfo.getDangQianKSID());
 
         if (ObjectUtils.isNotEmpty(SuiFangJH)) {
-            patMedInhosp1.setFuflag(ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangBS")) ? SuiFangJH.get("SuiFangBS").toString() : null);
+            patMedInhosp1.setFuflag(ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangBS")) ? SuiFangJH.get("SuiFangBS").toString() : "1");
             if (ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangRQ"))) {
                 try {
                     SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -797,7 +815,7 @@
             patMedInhosp1.setOrgid(ObjectUtils.isNotEmpty(BingRenXX) && ObjectUtils.isNotEmpty(BingRenXX.get("ZuZhiJGID")) ? BingRenXX.get("ZuZhiJGID").toString() : null);
             if (CollectionUtils.isNotEmpty(noLongTask) && noLongTask.contains(patMedInhosp1.getOrgid())) {
                 //涓嶉渶瑕侀暱鏈熶换鍔¢殢璁�
-                patMedInhosp1.setFuflag("1");
+                patMedInhosp1.setFuflag("0");
             }
             int i = patMedInhospMapper.updatePatMedInhosp(patMedInhosp1);
             if (i != 1) return false;
@@ -820,7 +838,7 @@
             patMedInhosp1.setCreateTime(new Date());
             if (CollectionUtils.isNotEmpty(noLongTask) && noLongTask.contains(patMedInhosp1.getOrgid())) {
                 //涓嶉渶瑕侀暱鏈熶换鍔¢殢璁�
-                patMedInhosp1.setFuflag("1");
+                patMedInhosp1.setFuflag("0");
             }
             int i = patMedInhospMapper.insertPatMedInhosp(patMedInhosp1);
             if (i != 1) return false;
@@ -970,7 +988,7 @@
         patMedInhosp1.setDeptcode(externalInHospPatientInfo.getDangQianKSID());
 
         if (ObjectUtils.isNotEmpty(SuiFangJH)) {
-            patMedInhosp1.setFuflag(ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangBS")) ? SuiFangJH.get("SuiFangBS").toString() : null);
+            patMedInhosp1.setFuflag(ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangBS")) ? SuiFangJH.get("SuiFangBS").toString() : "1");
             if (ObjectUtils.isNotEmpty(SuiFangJH.get("SuiFangRQ"))) {
                 try {
                     SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -1160,7 +1178,7 @@
                 patMedOuthosp.setDrcode(externalDiagnosisInfo.getZhenDuanYSID());
                 patMedOuthosp.setDrname(externalDiagnosisInfo.getZhenDuanYSXM());
                 patMedOuthosp.setIcd10code(externalDiagnosisInfo.getIcd10());
-                patMedOuthosp.setFuflag("0");
+                patMedOuthosp.setFuflag("1");
             }
         }
         for (ExternalWZInfo externalWZInfo : ExternalWZInfoList) {
@@ -1177,7 +1195,7 @@
             patMedOuthosp.setUpdateTime(new Date());
             if (CollectionUtils.isNotEmpty(noLongTask) && noLongTask.contains(patMedOuthosp.getOrgid())) {
                 //涓嶉渶瑕侀暱鏈熶换鍔¢殢璁匡紝鐢卞尰鐢熻嚜宸卞幓闅忚锛堜附姘翠腑鍖婚櫌棣栨鎻愬嚭锛�
-                patMedOuthosp.setFuflag("1");
+                patMedOuthosp.setFuflag("0");
             }
             i = patMedOuthospService.updatePatMedOuthosp(patMedOuthosp);
         } else {
@@ -1185,7 +1203,7 @@
             patMedOuthosp.setUpdateTime(new Date());
             if (CollectionUtils.isNotEmpty(noLongTask) && noLongTask.contains(patMedOuthosp.getOrgid())) {
                 //涓嶉渶瑕侀暱鏈熶换鍔¢殢璁�
-                patMedOuthosp.setFuflag("1");
+                patMedOuthosp.setFuflag("0");
             }
             i = patMedOuthospService.insertPatMedOuthosp(patMedOuthosp);
 
@@ -1455,7 +1473,7 @@
         patArchive.setPatientno(externalInHospPatientInfo.getJiuZhenKH());
         patArchive.setBirthdate(parse);
         patArchive.setPatidHis(externalInHospPatientInfo.getBingRenID());
-        patArchive.setSourcefrom(1);
+        patArchive.setSourcefrom(1L);
         patArchive.setPattype("2");
         patArchive.setName(externalInHospPatientInfo.getXingMing());
         if (StringUtils.isNotEmpty(externalInHospPatientInfo.getXingBieDM()))
@@ -1487,6 +1505,9 @@
         patArchive.setTelcode(externalInHospPatientInfo.getLianXiDH());
         if (StringUtils.isEmpty(patArchive.getTelcode()))
             patArchive.setTelcode(externalInHospPatientInfo.getLianXiRDH());
+        //澧炲姞鐭彿淇℃伅
+        if (StringUtils.isNotEmpty(externalInHospPatientInfo.getDuanHaoXX()))
+            patArchive.setTelshortcode(externalInHospPatientInfo.getDuanHaoXX());
         patArchive.setRelativetelcode(externalInHospPatientInfo.getLianXiRDH());
         patArchive.setGuid(externalInHospPatientInfo.getZuZhiJGID());
         patArchive.setInhospno(externalInHospPatientInfo.getBingAnHao());
@@ -1837,6 +1858,44 @@
         return true;
     }
 
+    @Override
+    public Map<String, Object> query360PatInfolwl(Long patid, SysUser sysUser) {
+        Map<String, Object> result = new HashMap<>();
+        PatArchive pa = patArchiveMapper.selectPatArchiveByPatid(patid);
+        if (pa.getPatientno() == null) {
+            result.put("url", null);
+            result.put("error", "鎮h�呯紪鍙蜂负绌�");
+            return result;
+        }
+
+        StringBuffer sbf = new StringBuffer("http://cfdata.nhyfy.cn/cfdata/h360/patient-summary?");
+        sbf.append("referer=thirdparty");
+        sbf.append("&encode=1");
+        sbf.append("&patientMainIndexNum=" + AesUtils.encrypt(pa.getPatientno()));
+        sbf.append("&workId=" + AesUtils.encrypt(sysUser.getUserName()));
+        sbf.append("&workName=" + AesUtils.encrypt(sysUser.getNickName()));
+        sbf.append("&hisOrgCode=" + AesUtils.encrypt("20001001"));
+        sbf.append("&hisOrgName=" + AesUtils.encrypt("鍗楀崕澶у闄勫睘绗竴鍖婚櫌"));
+        sbf.append("&hisHosCode=" + AesUtils.encrypt("30001002"));
+        sbf.append("&hisHosName=" + AesUtils.encrypt("鍗楀崕澶у闄勫睘绗竴鍖婚櫌"));
+        String url360 = null;
+        try {
+            url360 = URLEncoder.encode(sbf.toString(), "UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            throw new RuntimeException(e);
+        }
+
+        StringBuffer stringBuffer = new StringBuffer("http://cfdata.nhyfy.cn/cfdata/login/nologin?");
+        //accountNo瀵规帴浜轰笉缁欙紝鍏堢┖鐫�---------------------------------------------------------------
+        stringBuffer.append("accountNo=");
+        stringBuffer.append("&source=third");
+        stringBuffer.append("&redirectUrl=" + url360);
+
+        result.put("url", stringBuffer.toString());
+        result.put("error", null);
+        return result;
+    }
+
     private Boolean getType(String type, Map dataMap) {
         switch (type) {
             case "BR_DA_DangAnJL":

--
Gitblit v1.9.3