From 4d537968ac6efb3a5e3d0f8ea5071d5254eb63c3 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期二, 29 七月 2025 14:37:17 +0800
Subject: [PATCH] 代码提交

---
 ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java |  463 +++++----------------------------------------------------
 1 files changed, 43 insertions(+), 420 deletions(-)

diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
index 74436c8..771bf63 100644
--- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
+++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
@@ -87,7 +87,7 @@
     private IServicePatientTempService iServicePatientTempService;
 
     @Autowired
-    private PlatformTransactionManager transactionManager;
+    private IHNGatherPatArchiveService ihnGatherPatArchiveService;
 
     @Autowired
     private SysUserImportMapper sysUserImportMapper;
@@ -125,8 +125,6 @@
     @Autowired
     IPatArchiveService patArchiveService;
 
-    @Autowired
-    IPatMedInhospService patMedInhospService;
 
     @Autowired
     IPatMedOuthospService patMedOuthospService;
@@ -137,14 +135,19 @@
     @Autowired
     IIvrTaskTemplateService iIvrTaskTemplateService;
 
-    @Value("${hosp_info_url}")
-    private String hospInfoUrl;
+    @Autowired
+    IXHGatherPatArchiveService ixhGatherPatArchiveService;
+
 
     @Value("${appid}")
     private String appid;
 
     @Value("${server.port}")
     private String port;
+
+
+    @Value("${spring.profiles.active}")
+    private String active;
 
     public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) {
         System.out.println(StringUtils.format("鎵ц澶氬弬鏂规硶锛� 瀛楃涓茬被鍨媨}锛屽竷灏旂被鍨媨}锛岄暱鏁村瀷{}锛屾诞鐐瑰瀷{}锛屾暣褰}", s, b, l, d, i));
@@ -211,34 +214,42 @@
      */
     public void dealHisData() {
         log.info("銆恉ealHisData銆戝紑濮嬫墽琛孒IS鏁版嵁閲囬泦浠诲姟");
-        long startTime = System.currentTimeMillis();
-        
-        try {
-            // 鑾峰彇鏄ㄥぉ0鐐瑰埌浠婂ぉ0鐐圭殑鏃堕棿鑼冨洿
-            LocalDateTime todayZero = LocalDateTime.now().with(LocalTime.MIN);
-            LocalDateTime yesterdayZero = todayZero.minusDays(1);
-            
-            log.info("銆恉ealHisData銆戦噰闆嗘椂闂磋寖鍥达細{} ~ {}", yesterdayZero, todayZero);
-            
-            // 閲囬泦鍏ラ櫌鏁版嵁
-            log.info("銆恉ealHisData銆戝紑濮嬮噰闆嗗叆闄㈡暟鎹�");
-            getInHospInfo("0", yesterdayZero, todayZero);
-            log.info("銆恉ealHisData銆戝叆闄㈡暟鎹噰闆嗗畬鎴�");
-            
-            // 閲囬泦鍑洪櫌鏁版嵁
-            log.info("銆恉ealHisData銆戝紑濮嬮噰闆嗗嚭闄㈡暟鎹�");
-            getInHospInfo("1", yesterdayZero, todayZero);
-            log.info("銆恉ealHisData銆戝嚭闄㈡暟鎹噰闆嗗畬鎴�");
-            
-            long endTime = System.currentTimeMillis();
-            log.info("銆恉ealHisData銆慔IS鏁版嵁閲囬泦浠诲姟瀹屾垚锛屾�昏�楁椂锛歿}ms", endTime - startTime);
-            
-        } catch (Exception e) {
-            log.error("銆恉ealHisData銆慔IS鏁版嵁閲囬泦寮傚父", e);
-            // 杩欓噷鍙互娣诲姞鍛婅閫氱煡閫昏緫锛屾瘮濡傚彂閫侀偖浠舵垨鐭俊
+        // 鑾峰彇鏄ㄥぉ0鐐瑰埌浠婂ぉ0鐐圭殑鏃堕棿鑼冨洿
+        LocalDateTime todayZero = LocalDateTime.now().with(LocalTime.MIN);
+        LocalDateTime yesterdayZero = todayZero.minusDays(1);
+        log.info("銆恉ealHisData銆戦噰闆嗘椂闂磋寖鍥达細{} ~ {}", yesterdayZero, todayZero);
+
+        if (active.trim().equals("xh")) {
+            try {
+                // 閲囬泦鍏ラ櫌鏁版嵁
+                log.info("銆恉ealHisData銆戞柊鍗庡紑濮嬮噰闆嗗叆闄㈡暟鎹�");
+                ixhGatherPatArchiveService.getInHospDataGather("0", yesterdayZero, todayZero);
+                log.info("銆恉ealHisData銆戞柊鍗庡叆闄㈡暟鎹噰闆嗗畬鎴�");
+
+                // 閲囬泦鍑洪櫌鏁版嵁
+                log.info("銆恉ealHisData銆戞柊鍗庡紑濮嬮噰闆嗗嚭闄㈡暟鎹�");
+                ixhGatherPatArchiveService.getInHospDataGather("1", yesterdayZero, todayZero);
+                log.info("銆恉ealHisData銆戞柊鍗庡嚭闄㈡暟鎹噰闆嗗畬鎴�");
+
+            } catch (Exception e) {
+                log.error("銆恉ealHisData銆戞柊鍗庢暟鎹噰闆嗗紓甯�", e);
+            }
+        } else if (active.trim().equals("hn")) {
+            try {
+                // 娌冲崡鏁版嵁閲囬泦
+                HnDataGatherVO hnDataGatherVO = new HnDataGatherVO();
+                log.info("銆恉ealHisData銆戞渤鍗楀紑濮嬮噰闆嗘暟鎹�");
+                ihnGatherPatArchiveService.hnDataGather(hnDataGatherVO);
+                log.info("銆恉ealHisData銆戞渤鍗楃粨鏉熼噰闆嗘暟鎹�");
+            } catch (Exception e) {
+                log.error("銆恉ealHisData銆戞渤鍗楁暟鎹噰闆嗗紓甯�", e);
+            }
         }
     }
 
+    /**
+     * 杩欎釜鍙槸鏂板崕涓存椂浣跨敤锛屽钩鏃剁敤涓嶅埌
+     */
     public void dealHisData2() {
         //灏嗘偅鑰呬俊鎭�佸嚭鍏ラ櫌鏁版嵁鍏ㄩ儴閲囬泦
         // 鎸囧畾鐨勫紑濮嬫棩鏈�
@@ -251,8 +262,8 @@
         // 浠庡紑濮嬫棩鏈熷埌褰撳墠鏃ユ湡閫愬ぉ鎵撳嵃
         for (LocalDate date = endDate; !date.isAfter(currentDate); date = date.plusDays(1)) {
             System.out.println(date.format(formatter));
-            getInHospInfo("0", date.minusDays(1).atStartOfDay(), date.atStartOfDay());
-            getInHospInfo("1", date.minusDays(1).atStartOfDay(), date.atStartOfDay());
+            ixhGatherPatArchiveService.getInHospDataGather("0", date.minusDays(1).atStartOfDay(), date.atStartOfDay());
+            ixhGatherPatArchiveService.getInHospDataGather("1", date.minusDays(1).atStartOfDay(), date.atStartOfDay());
         }
 
     }
@@ -548,7 +559,6 @@
                                 serviceSubtask.setResult("error");
                                 serviceSubtask.setRemark("绯荤粺閿欒");
                                 serviceSubtask.setSendstate(5L);
-//                                serviceSubtask.setFinishtime(new Date());
                                 serviceSubtask.setGuid(guid);
                                 iServiceSubtaskService.updateServiceSubtask(serviceSubtask);
                             }
@@ -560,7 +570,6 @@
                     RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample();
                     String taskId = rsaPublicKeyExample.encryptedData(ivrTask1.getTaskid().toString(), pub_key);
                     for (ServiceSubtask serviceSubtask : selectServiceSubtaskList) {
-                        //  log.error("serviceSubtask---------杩涙潵浜嗗悧锛焮}", serviceSubtask);
                         boolean dateToday = isDateToday(serviceSubtask.getLongSendTime());
                         if (dateToday) {
                             try {
@@ -571,14 +580,12 @@
                                     serviceSubtask.setResult("error");
                                     serviceSubtask.setRemark(patArchive.getNotrequiredreason());
                                     serviceSubtask.setSendstate(4L);
-//                                    serviceSubtask.setFinishtime(new Date());
                                     iServiceSubtaskService.insertServiceSubtask(serviceSubtask);
                                     continue;
                                 }
                                 String patid = rsaPublicKeyExample.encryptedData(serviceSubtask.getPatid().toString(), pub_key);
                                 String url = null;
                                 url = ip + ":" + req_path + "/outsideChainwt?param1=" + taskId + "&param2=" + patid + "&param3=" + URLEncoder.encode(ivrTask1.getTaskName(), StandardCharsets.UTF_8.toString()) + "&param5=false";
-//                                String wxCode = getWXCode(serviceSubtask.getSfzh(), url, serviceSubtask.getTaskName(), serviceSubtask.getTaskDesc(), "鏃�");
 
                                 //鑾峰彇寰俊鍏紬鍙疯姹備俊鎭牴鎹満鏋処D
                                 List<String> wxqqxx = WxGZHEnum.getDescByCode(patArchive.getOrgid());
@@ -588,7 +595,6 @@
                                     ss.setRemark("璇ユ満鏋勭殑鍏紬鍙烽厤缃俊鎭笉鍏紝鏃犳硶閫氳繃鍏紬鍙峰彂閫�");
                                     ss.setSendstate(5L);
                                     ss.setId(serviceSubtask.getId());
-//                                    ss.setFinishtime(new Date());
                                     serviceSubtaskMapper.updateServiceSubtask(ss);
                                     continue;
                                 }
@@ -599,7 +605,6 @@
                                     ss.setRemark("鍏紬鍙峰彂閫佸け璐�,his绯荤粺鐨勬偅鑰卛d涓虹┖");
                                     ss.setSendstate(5L);
                                     ss.setId(serviceSubtask.getId());
-//                                    ss.setFinishtime(new Date());
                                     serviceSubtaskMapper.updateServiceSubtask(ss);
                                     continue;
                                 }
@@ -635,7 +640,6 @@
                                 serviceSubtask.setResult("error");
                                 serviceSubtask.setRemark("绯荤粺閿欒");
                                 serviceSubtask.setSendstate(5L);
-//                                serviceSubtask.setFinishtime(new Date());
                                 serviceSubtask.setGuid(guid);
                                 iServiceSubtaskService.updateServiceSubtask(serviceSubtask);
                             }
@@ -646,387 +650,6 @@
             }
         }
     }
-
-
-    /**
-     * 鑾峰彇鎮h�呭嚭鍏ラ櫌淇℃伅
-     * @param cry 鍑哄叆闄㈢被鍨嬶細0-鍏ラ櫌锛�1-鍑洪櫌
-     * @param startTime 寮�濮嬫椂闂�
-     * @param endTime 缁撴潫鏃堕棿
-     */
-    @Transactional
-    public void getInHospInfo(String cry, LocalDateTime startTime, LocalDateTime endTime) {
-        String typeName = "0".equals(cry) ? "鍏ラ櫌" : "鍑洪櫌";
-        log.info("銆恎etInHospInfo銆戝紑濮嬭幏鍙杮}鎮h�呬俊鎭紝鏃堕棿鑼冨洿锛歿} ~ {}", typeName, startTime, endTime);
-        long startTimeMillis = System.currentTimeMillis();
-        
-        try {
-            // 绗竴姝ワ細鏋勫缓璇锋眰鍙傛暟骞惰皟鐢℉IS鎺ュ彛
-            List<ThiedInhospInfo> thiedInhospInfoList = fetchHisData(cry, startTime, endTime);
-            
-            if (CollectionUtils.isEmpty(thiedInhospInfoList)) {
-                log.info("銆恎etInHospInfo銆憑}鎮h�呬俊鎭负绌猴紝璺宠繃澶勭悊", typeName);
-                return;
-            }
-            
-            log.info("銆恎etInHospInfo銆戣幏鍙栧埌{}鏉}鎮h�呬俊鎭�", thiedInhospInfoList.size(), typeName);
-            
-            // 绗簩姝ワ細淇濆瓨鍘熷鏁版嵁鍒版枃浠讹紙鐢ㄤ簬澶囦唤锛�
-            saveRawDataToFile(cry, thiedInhospInfoList);
-            
-            // 绗笁姝ワ細澶勭悊鎮h�呮暟鎹�
-            processPatientData(thiedInhospInfoList, cry);
-            
-            long endTimeMillis = System.currentTimeMillis();
-            log.info("銆恎etInHospInfo銆憑}鎮h�呬俊鎭鐞嗗畬鎴愶紝鑰楁椂锛歿}ms", typeName, endTimeMillis - startTimeMillis);
-            
-        } catch (Exception e) {
-            log.error("銆恎etInHospInfo銆戣幏鍙杮}鎮h�呬俊鎭紓甯�", typeName, e);
-            throw new RuntimeException("鑾峰彇" + typeName + "鎮h�呬俊鎭け璐�", e);
-        }
-    }
-    
-    /**
-     * 绗竴姝ワ細璋冪敤HIS鎺ュ彛鑾峰彇鏁版嵁
-     */
-    private List<ThiedInhospInfo> fetchHisData(String cry, LocalDateTime startTime, LocalDateTime endTime) {
-        try {
-            // 鏋勫缓璇锋眰鍙傛暟
-            Map<String, String> requestParams = buildRequestParams(cry, startTime, endTime);
-            
-            // 鏋勫缓璇锋眰澶�
-            Map<String, String> headers = buildRequestHeaders(startTime);
-            
-            // 鍙戦�丠TTP璇锋眰
-            String result = HttpUtils.sendPostByHeader(hospInfoUrl, new Gson().toJson(requestParams), headers);
-            
-            // 瑙f瀽鍝嶅簲鏁版嵁
-            return parseResponseData(result);
-            
-        } catch (Exception e) {
-            log.error("銆恌etchHisData銆戣皟鐢℉IS鎺ュ彛寮傚父", e);
-            throw e;
-        }
-    }
-    
-    /**
-     * 鏋勫缓璇锋眰鍙傛暟
-     */
-    private Map<String, String> buildRequestParams(String cry, LocalDateTime startTime, LocalDateTime endTime) {
-        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.S");
-        Map<String, String> req = new HashMap<>();
-        
-        if ("1".equals(cry)) {
-            // 鍑洪櫌鍙傛暟
-            req.put("cashStartDate", startTime.format(formatter));
-            req.put("cashEndDate", endTime.format(formatter));
-            req.put("currStatus", "4");
-        } else {
-            // 鍏ラ櫌鍙傛暟
-            req.put("admissStartDate", startTime.format(formatter));
-            req.put("admissEndDate", endTime.format(formatter));
-            req.put("currStatus", "2");
-        }
-        
-        return req;
-    }
-    
-    /**
-     * 鏋勫缓璇锋眰澶�
-     */
-    private Map<String, String> buildRequestHeaders(LocalDateTime startTime) {
-        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.S");
-        Map<String, String> header = new HashMap<>();
-        header.put("x-hcsb-serviceno", "IS002347");
-        header.put("x-hcsb-version", "2.0");
-        header.put("x-hcsb-sourcesyscode", "14");
-        header.put("x-hcsb-token", "ArGE2JnHtxG/Zx5nrnGY4eOfMUJGGJokAJHigG1BrCY=");
-        header.put("x-hcsb-msgdate", startTime.format(formatter));
-        return header;
-    }
-    
-    /**
-     * 瑙f瀽鍝嶅簲鏁版嵁
-     */
-    private List<ThiedInhospInfo> parseResponseData(String result) {
-        try {
-            Gson gson = new Gson();
-            JsonObject jsonObject = gson.fromJson(result, JsonObject.class);
-            JsonArray resultArray = jsonObject.getAsJsonObject("data").getAsJsonArray("result");
-            Type resultType = new TypeToken<List<ThiedInhospInfo>>() {}.getType();
-            return gson.fromJson(resultArray, resultType);
-        } catch (Exception e) {
-            log.error("銆恜arseResponseData銆戣В鏋愬搷搴旀暟鎹紓甯革紝鍘熷鏁版嵁锛歿}", result, e);
-            throw e;
-        }
-    }
-    
-    /**
-     * 绗簩姝ワ細淇濆瓨鍘熷鏁版嵁鍒版枃浠�
-     */
-    private void saveRawDataToFile(String cry, List<ThiedInhospInfo> dataList) {
-        try {
-            String typeName = "0".equals(cry) ? "鍏ラ櫌淇℃伅" : "鍑洪櫌淇℃伅";
-            String filename = typeName + "_" + System.currentTimeMillis() + ".json";
-            String filePath = "D:\\public\\HIS鏁版嵁閲囬泦\\" + filename;
-            
-            File file = new File(filePath);
-            File parentDir = file.getParentFile();
-            if (!parentDir.exists()) {
-                parentDir.mkdirs();
-            }
-            
-            if (!file.exists()) {
-                file.createNewFile();
-            }
-            
-            // 灏嗘暟鎹啓鍏ユ枃浠�
-            try (FileWriter writer = new FileWriter(file)) {
-                writer.write(new Gson().toJson(dataList));
-            }
-            
-            log.info("銆恠aveRawDataToFile銆戝師濮嬫暟鎹凡淇濆瓨鍒版枃浠讹細{}", filePath);
-            
-        } catch (Exception e) {
-            log.error("銆恠aveRawDataToFile銆戜繚瀛樺師濮嬫暟鎹埌鏂囦欢寮傚父", e);
-            // 鏂囦欢淇濆瓨澶辫触涓嶅奖鍝嶄富娴佺▼锛屽彧璁板綍鏃ュ織
-        }
-    }
-    
-    /**
-     * 绗笁姝ワ細澶勭悊鎮h�呮暟鎹�
-     */
-    private void processPatientData(List<ThiedInhospInfo> thiedInhospInfoList, String cry) {
-        int successCount = 0;
-        int skipCount = 0;
-        int errorCount = 0;
-        
-        for (ThiedInhospInfo thiedInhospInfo : thiedInhospInfoList) {
-            try {
-                if (processSinglePatient(thiedInhospInfo, cry)) {
-                    successCount++;
-                } else {
-                    skipCount++;
-                }
-            } catch (Exception e) {
-                errorCount++;
-                log.error("銆恜rocessPatientData銆戝鐞嗘偅鑰呮暟鎹紓甯革紝鎮h�匢D锛歿}", 
-                    thiedInhospInfo.getPatiMediaNo(), e);
-            }
-        }
-        
-        log.info("銆恜rocessPatientData銆戞偅鑰呮暟鎹鐞嗗畬鎴愶紝鎴愬姛锛歿}锛岃烦杩囷細{}锛屽け璐ワ細{}", 
-            successCount, skipCount, errorCount);
-    }
-    
-    /**
-     * 澶勭悊鍗曚釜鎮h�呮暟鎹�
-     */
-    private boolean processSinglePatient(ThiedInhospInfo thiedInhospInfo, String cry) {
-        // 楠岃瘉韬唤璇佸彿
-        if (StringUtils.isEmpty(thiedInhospInfo.getPatiIdCardNo())) {
-            log.warn("銆恜rocessSinglePatient銆戞偅鑰呰韩浠借瘉鍙蜂负绌猴紝璺宠繃澶勭悊锛屾偅鑰呯紪鍙凤細{}", 
-                thiedInhospInfo.getPatiMediaNo());
-            return false;
-        }
-        
-        // 澶勭悊鎮h�呮。妗堜俊鎭�
-        PatArchive patArchive = processPatientArchive(thiedInhospInfo, cry);
-        
-        // 澶勭悊鎮h�呬綇闄俊鎭�
-        processPatientInhospInfo(thiedInhospInfo, patArchive, cry);
-        
-        return true;
-    }
-    
-    /**
-     * 澶勭悊鎮h�呮。妗堜俊鎭�
-     */
-    private PatArchive processPatientArchive(ThiedInhospInfo thiedInhospInfo, String cry) {
-        // 鏌ヨ鎮h�呮槸鍚﹀凡瀛樺湪
-        PatArchive queryArchive = new PatArchive();
-        queryArchive.setIdcardno(thiedInhospInfo.getPatiIdCardNo().trim());
-        List<PatArchive> existingArchives = patArchiveService.selectPatArchiveList(queryArchive);
-        
-        // 鏋勫缓鎮h�呮。妗堜俊鎭�
-        PatArchive patArchive = buildPatientArchive(thiedInhospInfo, cry);
-        
-        // 淇濆瓨鎴栨洿鏂版偅鑰呮。妗�
-        if (CollectionUtils.isEmpty(existingArchives)) {
-            patArchiveService.insertPatArchive(patArchive);
-            log.debug("銆恜rocessPatientArchive銆戞柊澧炴偅鑰呮。妗堬紝鎮h�呯紪鍙凤細{}", patArchive.getPatientno());
-        } else {
-            patArchive.setId(existingArchives.get(0).getId());
-            patArchiveService.updateArchive(patArchive);
-            log.debug("銆恜rocessPatientArchive銆戞洿鏂版偅鑰呮。妗堬紝鎮h�呯紪鍙凤細{}", patArchive.getPatientno());
-        }
-        
-        return patArchive;
-    }
-    
-    /**
-     * 鏋勫缓鎮h�呮。妗堜俊鎭�
-     */
-    private PatArchive buildPatientArchive(ThiedInhospInfo thiedInhospInfo, String cry) {
-        PatArchive patArchive = new PatArchive();
-        
-        // 鍩烘湰淇℃伅
-        patArchive.setPatientno(thiedInhospInfo.getPatiMediaNo());
-        patArchive.setIdcardno(thiedInhospInfo.getPatiIdCardNo().trim());
-        patArchive.setName(thiedInhospInfo.getPatiRecordName());
-        patArchive.setSourcefrom(2);
-        patArchive.setPattype("2");
-        
-        // 鎬у埆
-        patArchive.setSex("鐢�".equals(thiedInhospInfo.getPatiRecordGender()) ? 1L : 2L);
-        
-        // 姘戞棌鍜岀睄璐�
-        patArchive.setNation(thiedInhospInfo.getPatiNation());
-        patArchive.setNativePlace(thiedInhospInfo.getPatiNationality());
-        
-        // 灞呬綇鍦板潃
-        String homeAddr = thiedInhospInfo.getPatiHomeAddr();
-        patArchive.setPlaceOfResidence(StringUtils.isNotEmpty(homeAddr) ? homeAddr.replace("null", "") : "");
-        
-        // 鍑虹敓鏃ユ湡
-        if (StringUtils.isNotEmpty(thiedInhospInfo.getPatiBirthday())) {
-            try {
-                patArchive.setBirthdate(new SimpleDateFormat("yyyy-MM-dd").parse(thiedInhospInfo.getPatiBirthday()));
-            } catch (ParseException e) {
-                log.warn("銆恇uildPatientArchive銆戣В鏋愬嚭鐢熸棩鏈熷け璐ワ細{}", thiedInhospInfo.getPatiBirthday(), e);
-            }
-        }
-        
-        // 骞撮緞
-        if (thiedInhospInfo.getTreateAge() != null) {
-            patArchive.setAge(Long.valueOf(thiedInhospInfo.getTreateAge()));
-        }
-        patArchive.setAgeUnit(thiedInhospInfo.getTreatAgeunit());
-        
-        // 鑱旂郴鏂瑰紡
-        patArchive.setTelcode(thiedInhospInfo.getCompanyTelNum());
-        patArchive.setRelativetelcode(thiedInhospInfo.getContactPersonPhone());
-        
-        // 鍑洪櫌鏂瑰紡澶勭悊锛堟浜$瓑鐗规畩鎯呭喌锛�
-        if (StringUtils.isNotEmpty(thiedInhospInfo.getOutWayId()) && "4".equals(thiedInhospInfo.getOutWayId())) {
-            patArchive.setNotrequiredFlag("1");
-            patArchive.setNotrequiredreason(thiedInhospInfo.getOutWayName());
-        }
-        if ("1".equals(cry) && StringUtils.isEmpty(thiedInhospInfo.getOutWayId())) {
-            patArchive.setNotrequiredFlag("1");
-            patArchive.setNotrequiredreason("鍑洪櫌鏂瑰紡涓虹┖");
-        }
-        
-        // 绯荤粺瀛楁
-        patArchive.setDelFlag("0");
-        patArchive.setCreateTime(new Date());
-        patArchive.setUpdateTime(new Date());
-        
-        return patArchive;
-    }
-    
-    /**
-     * 澶勭悊鎮h�呬綇闄俊鎭�
-     */
-    private void processPatientInhospInfo(ThiedInhospInfo thiedInhospInfo, PatArchive patArchive, String cry) {
-        // 鏋勫缓浣忛櫌淇℃伅
-        PatMedInhosp patMedInhosp = buildPatientInhospInfo(thiedInhospInfo, patArchive, cry);
-        
-        // 鏌ヨ鏄惁宸插瓨鍦ㄤ綇闄㈣褰�
-        PatMedInhosp queryInhosp = new PatMedInhosp();
-        queryInhosp.setPatno(patArchive.getPatientno());
-        queryInhosp.setSerialnum(patMedInhosp.getSerialnum());
-        List<PatMedInhosp> existingInhosps = patMedInhospService.selectPatMedInhospList(queryInhosp);
-        
-        // 淇濆瓨鎴栨洿鏂颁綇闄俊鎭�
-        if (CollectionUtils.isNotEmpty(existingInhosps)) {
-            patMedInhosp.setInhospid(existingInhosps.get(0).getInhospid());
-            patMedInhospService.updatePatMedInhosp(patMedInhosp);
-            log.debug("銆恜rocessPatientInhospInfo銆戞洿鏂颁綇闄俊鎭紝鎮h�呯紪鍙凤細{}锛屾祦姘村彿锛歿}", 
-                patArchive.getPatientno(), patMedInhosp.getSerialnum());
-        } else {
-            patMedInhospService.insertPatMedInhosp(patMedInhosp);
-            log.debug("銆恜rocessPatientInhospInfo銆戞柊澧炰綇闄俊鎭紝鎮h�呯紪鍙凤細{}锛屾祦姘村彿锛歿}", 
-                patArchive.getPatientno(), patMedInhosp.getSerialnum());
-        }
-    }
-    
-    /**
-     * 鏋勫缓鎮h�呬綇闄俊鎭�
-     */
-    private PatMedInhosp buildPatientInhospInfo(ThiedInhospInfo thiedInhospInfo, PatArchive patArchive, String cry) {
-        PatMedInhosp patMedInhosp = new PatMedInhosp();
-        
-        // 鎮h�呭熀鏈俊鎭�
-        patMedInhosp.setPatid(patArchive.getId());
-        patMedInhosp.setPatno(patArchive.getPatientno());
-        patMedInhosp.setPatname(patArchive.getName());
-        
-        // 鎶ょ悊淇℃伅
-        patMedInhosp.setNurseId(thiedInhospInfo.getNurseId());
-        patMedInhosp.setNurseName(thiedInhospInfo.getNurseName());
-        
-        // 浣忛櫌淇℃伅
-        patMedInhosp.setSerialnum(thiedInhospInfo.getInpatientId());
-        patMedInhosp.setFuflag("1");
-        patMedInhosp.setInhospstate("0".equals(cry) ? "0" : "1");
-        
-        // 鍖婚櫌鍜岀瀹や俊鎭�
-        patMedInhosp.setHospitalcode(thiedInhospInfo.getAreaId());
-        patMedInhosp.setDeptcode(thiedInhospInfo.getAdmissDeptId());
-        patMedInhosp.setDeptid(thiedInhospInfo.getAdmissDeptId());
-        patMedInhosp.setDeptname(thiedInhospInfo.getAdmissDeptName());
-        patMedInhosp.setBedNo(thiedInhospInfo.getAdmissBedNo());
-        
-        // 璇婃柇淇℃伅
-        patMedInhosp.setIcd10code(thiedInhospInfo.getDiagIcd10());
-        patMedInhosp.setDiagname(thiedInhospInfo.getDiagName());
-        
-        // 鏃堕棿淇℃伅
-        if (StringUtils.isNotEmpty(thiedInhospInfo.getAdmissDate())) {
-            try {
-                patMedInhosp.setStarttime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(thiedInhospInfo.getAdmissDate()));
-            } catch (ParseException e) {
-                log.warn("銆恇uildPatientInhospInfo銆戣В鏋愬叆闄㈡椂闂村け璐ワ細{}", thiedInhospInfo.getAdmissDate(), e);
-            }
-        }
-        
-        if (StringUtils.isNotEmpty(thiedInhospInfo.getOutDate())) {
-            try {
-                patMedInhosp.setEndtime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(thiedInhospInfo.getOutDate()));
-            } catch (ParseException e) {
-                log.warn("銆恇uildPatientInhospInfo銆戣В鏋愬嚭闄㈡椂闂村け璐ワ細{}", thiedInhospInfo.getOutDate(), e);
-            }
-        }
-        
-        // 鍑洪櫌淇℃伅
-        patMedInhosp.setLeaveldeptcode(thiedInhospInfo.getCurrDeptId());
-        patMedInhosp.setLeaveldeptname(thiedInhospInfo.getCurrDeptName());
-        patMedInhosp.setLeavediagname(thiedInhospInfo.getDiagName());
-        patMedInhosp.setLeaveicd10code(thiedInhospInfo.getDiagIcd10());
-        patMedInhosp.setOutWayId(thiedInhospInfo.getOutWayId());
-        patMedInhosp.setOutWayName(thiedInhospInfo.getOutWayName());
-        
-        // 鍖荤敓淇℃伅
-        patMedInhosp.setDrname(thiedInhospInfo.getDoctName());
-        patMedInhosp.setDrcode(thiedInhospInfo.getDoctId());
-        
-        // 鐥呭尯淇℃伅
-        patMedInhosp.setLeavehospitaldistrictid(thiedInhospInfo.getCurrWardCode());
-        patMedInhosp.setLeavehospitaldistrictcode(thiedInhospInfo.getCurrWardId());
-        patMedInhosp.setLeavehospitaldistrictname(thiedInhospInfo.getCurrWardName());
-        patMedInhosp.setLeaveldeptid(thiedInhospInfo.getCurrDeptCode());
-        
-        // 鐘舵�佷俊鎭�
-        patMedInhosp.setSchemestatus("0".equals(cry) ? 1L : 2L);
-        
-        // 绯荤粺瀛楁
-        patMedInhosp.setDelFlag("0");
-        patMedInhosp.setOrgid("1");
-        
-        return patMedInhosp;
-    }
-
 
     private String getKey() {
         Map<String, String> map = new HashMap<>();

--
Gitblit v1.9.3