From 9526971c403417c1c007804f24884c443b9e6cd7 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期三, 04 九月 2024 00:34:40 +0800
Subject: [PATCH] 代码提交

---
 ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java |  157 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 150 insertions(+), 7 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 a28df21..b5cd718 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
@@ -1,21 +1,34 @@
 package com.ruoyi.quartz.task;
 
 import com.alibaba.fastjson2.JSON;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.reflect.TypeToken;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonArray;
+import com.google.gson.Gson;
 import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.enums.ServiceFromEnum;
 import com.ruoyi.common.utils.RSAPublicKeyExample;
 import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.http.HttpUtils;
 import com.smartor.common.SendService;
 import com.smartor.domain.*;
-import com.smartor.mapper.ServiceSubtaskMapper;
 import com.smartor.mapper.ServiceTaskMapper;
 import com.smartor.service.*;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.math.NumberUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
+import java.lang.reflect.Type;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.*;
 
 /**
@@ -64,6 +77,18 @@
     @Autowired
     IBaseSmsaccountService baseSmsaccountService;
 
+    @Autowired
+    IPatArchiveService patArchiveService;
+
+    @Autowired
+    IPatMedInhospService patMedInhospService;
+
+    @Autowired
+    IPatMedOuthospService patMedOuthospService;
+
+    @Value("${hosp_info_url}")
+    private String hospInfoUrl;
+
     public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) {
         System.out.println(StringUtils.format("鎵ц澶氬弬鏂规硶锛� 瀛楃涓茬被鍨媨}锛屽竷灏旂被鍨媨}锛岄暱鏁村瀷{}锛屾诞鐐瑰瀷{}锛屾暣褰}", s, b, l, d, i));
     }
@@ -100,7 +125,8 @@
      */
     public void dealHisData() {
         //灏嗘偅鑰呬俊鎭�佸嚭闄€�侀棬璇婃暟鎹叏閮ㄩ噰闆�
-
+        getInHospInfo("0");
+        getInHospInfo("1");
 
         //璋冪敤dealOupHospInfo鏁版嵁澶勭悊鏂规硶锛屽鐞嗗畬鍚庯紝灏嗏�滃嚭闄㈣〃鐨刢heck_flag=1鈥�
         //鑾峰彇褰撳墠鏃ユ湡 锛堢簿纭埌澶╋級寰�鍓嶆帹鐩稿簲澶╂暟锛堝湪鎸囧畾鐨勫熀纭�妯℃澘涓壘瀵瑰簲鐨勫ぉ鏁帮級锛�
@@ -115,13 +141,13 @@
      */
     public void longTaskSend() {
         //鑾峰彇浠诲姟淇℃伅
-        ServiceTask st =new ServiceTask();
+        ServiceTask st = new ServiceTask();
         st.setDelFlag("0");
         st.setLongTask(1);
         List<ServiceTask> serviceTasks = serviceTaskMapper.selectServiceTaskList(st);
         for (ServiceTask serviceTask : serviceTasks) {
             //閫氳繃taskId,鑾峰彇鏈墽琛岀殑瀛愪换鍔′俊鎭�
-            ServiceSubtask serviceSubtask = new ServiceSubtask();
+            ServiceSubtaskVO serviceSubtask = new ServiceSubtaskVO();
             serviceSubtask.setTaskid(serviceTask.getTaskid());
             serviceSubtask.setSendstate(2L);
             List<ServiceSubtask> selectServiceSubtaskList = iServiceSubtaskService.selectServiceSubtaskList(serviceSubtask);
@@ -177,7 +203,7 @@
                 String descByCode = ServiceFromEnum.getDescByCode(Integer.valueOf(serviceFrom));
                 //杩欓噷鍙互鑰冭檻鐢ㄧ瓥鐣ユā寮忎紭鍖栦竴涓嬶紝涓嶇劧澶毦鐪嬩簡
                 //閫氳繃浠诲姟ID鎷垮埌鎮h�呬俊鎭�
-                ServiceSubtask ivrTaskcall = new ServiceSubtask();
+                ServiceSubtaskVO ivrTaskcall = new ServiceSubtaskVO();
                 ivrTaskcall.setTaskid(commonTaskcallMQ.getTaskid());
                 List<ServiceSubtask> selectServiceSubtaskList = iServiceSubtaskService.selectServiceSubtaskList(ivrTaskcall);
                 if (descByCode.equals("鐢佃瘽")) {
@@ -192,7 +218,7 @@
                         if (commonTaskcallMQ.getSendType().equals("2")) {
                             //璇存槑鏄珛鍗冲彂閫�
                             String value = redisCache.getCacheObject("cache-0");
-                            ServiceSubtask serviceSubtask1 = new ServiceSubtask();
+                            ServiceSubtaskVO serviceSubtask1 = new ServiceSubtaskVO();
                             serviceSubtask1.setTaskid(commonTaskcallMQ.getTaskid());
                             List<ServiceSubtask> selectServiceSubtaskList1 = iServiceSubtaskService.selectServiceSubtaskList(serviceSubtask1);
                             for (ServiceSubtask serviceSubtask2 : selectServiceSubtaskList1) {
@@ -206,7 +232,7 @@
                         } else {
                             //闈炵珛鍗冲彂閫�
                             String value = redisCache.getCacheObject(key);
-                            ServiceSubtask serviceSubtask1 = new ServiceSubtask();
+                            ServiceSubtaskVO serviceSubtask1 = new ServiceSubtaskVO();
                             serviceSubtask1.setTaskid(commonTaskcallMQ.getTaskid());
                             List<ServiceSubtask> selectServiceSubtaskList1 = iServiceSubtaskService.selectServiceSubtaskList(serviceSubtask1);
                             for (ServiceSubtask serviceSubtask2 : selectServiceSubtaskList1) {
@@ -297,6 +323,123 @@
         }
     }
 
+    /**
+     * 鑾峰嚭闄㈡偅鑰呬俊鎭�
+     * cry    鍑哄叆闄細 0 鍏ラ櫌   1 鍑洪櫌
+     */
+    private void getInHospInfo(String cry) {
+        // 鑾峰彇褰撳墠鏃ユ湡鍜屾椂闂�
+        LocalDateTime currentDateTime = LocalDateTime.now();
+        // 鑾峰彇鍓嶄竴澶╃殑鏃ユ湡鍜屾椂闂�
+        LocalDateTime previousDateTime = currentDateTime.minusDays(1);
+        // 瀹氫箟鏃ユ湡鏃堕棿鏍煎紡
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.S");
+        Map<String, String> req = new HashMap<>();
+        if (cry.equals("1")) {
+            req.put("startTime", previousDateTime.format(formatter));
+            req.put("endTime", currentDateTime.format(formatter));
+            req.put("currStatus", "4");
+        } else if (cry.equals("0")) {
+            req.put("admissStartDate", previousDateTime.format(formatter));
+            req.put("admissEndDate", currentDateTime.format(formatter));
+            req.put("currStatus", "2");
+        }
+        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", currentDateTime.format(formatter));
+        String result = HttpUtils.sendPostByHeader(hospInfoUrl, new Gson().toJson(req), header);
+        //鏁版嵁瑙f瀽
+        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();
+        List<ThiedInhospInfo> thiedInhospInfoList = gson.fromJson(resultArray, resultType);
+        if (CollectionUtils.isNotEmpty(thiedInhospInfoList)) {
+            for (ThiedInhospInfo thiedInhospInfo : thiedInhospInfoList) {
+                //閫氳繃韬唤璇佸彿鏌ヨ璇ユ偅鑰呭湪鎮h�呰〃鏄惁瀛樺湪
+                PatArchive patArchive = new PatArchive();
+                patArchive.setIdcardno(thiedInhospInfo.getPatiIdCardNo());
+                List<PatArchive> patArchives = patArchiveService.selectPatArchiveList(patArchive);
+                if (CollectionUtils.isEmpty(patArchives)) {
+                    patArchive.setPatientno(thiedInhospInfo.getPatiMediaNo());
+                    patArchive.setSourcefrom(2);
+                    patArchive.setPattype("2");
+                    patArchive.setSex(thiedInhospInfo.getPatiRecordGender().equals("鐢�") ? 1L : 2L);
+                    patArchive.setNation(thiedInhospInfo.getPatiNation());
+                    patArchive.setNativePlace(thiedInhospInfo.getPatiNationality());
+                    patArchive.setPlaceOfResidence(thiedInhospInfo.getPatiHomeAddr());
+                    try {
+                        if (StringUtils.isNotEmpty(thiedInhospInfo.getPatiBirthday()))
+                            patArchive.setBirthdate(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(thiedInhospInfo.getPatiBirthday()));
+                    } catch (ParseException e) {
+                        e.printStackTrace();
+                    }
+                    String age = thiedInhospInfo.getAge().replaceAll("宀�", "");
+                    boolean creatable = NumberUtils.isCreatable(age);
+                    if (creatable) patArchive.setAge(StringUtils.isNotEmpty(age) ? Long.valueOf(age) : null);
+                    patArchive.setTelcode(thiedInhospInfo.getCompanyTelNum());
+                    patArchive.setRelativetelcode(thiedInhospInfo.getContactPersonPhone());
+                    patArchive.setDelFlag("0");
+                    patArchive.setCreateTime(new Date());
+                    patArchive.setUpdateTime(new Date());
+                    patArchive.setName(thiedInhospInfo.getPatiRecordName());
+                    patArchiveService.insertPatArchive(patArchive);
+                }
+                PatMedInhosp patMedInhosp = new PatMedInhosp();
+                patMedInhosp.setPatid(patArchive.getId());
+                patMedInhosp.setPatno(patArchive.getPatientno());
+                patMedInhosp.setPatname(patArchive.getName());
+                patMedInhosp.setSerialnum(thiedInhospInfo.getInpatientId());
+                if (cry.equals("0")) {
+                    patMedInhosp.setInhospstate("0");
+                } else if (cry.equals("1")) {
+                    patMedInhosp.setInhospstate("1");
+                }
+                patMedInhosp.setHospitalcode(thiedInhospInfo.getAreaId());
+                patMedInhosp.setIcd10code(thiedInhospInfo.getDiagIcd10());
+                patMedInhosp.setDiagname(thiedInhospInfo.getDiagName());
+                try {
+                    if (StringUtils.isNotEmpty(thiedInhospInfo.getAdmissDate()))
+                        patMedInhosp.setStarttime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(thiedInhospInfo.getAdmissDate()));
+                } catch (ParseException e) {
+                    e.printStackTrace();
+                }
+                try {
+                    if (StringUtils.isNotEmpty(thiedInhospInfo.getOutDate()))
+                        patMedInhosp.setEndtime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(thiedInhospInfo.getOutDate()));
+                } catch (ParseException e) {
+                    e.printStackTrace();
+                }
+                patMedInhosp.setDeptcode(thiedInhospInfo.getAdmissDeptId());
+                patMedInhosp.setDeptid(thiedInhospInfo.getAdmissDeptId());
+                patMedInhosp.setDeptname(thiedInhospInfo.getAdmissDeptName());
+                patMedInhosp.setBedNo(thiedInhospInfo.getAdmissBedNo());
+                patMedInhosp.setDelFlag("0");
+                patMedInhosp.setLeaveldeptcode(thiedInhospInfo.getCurrWardId());
+                patMedInhosp.setLeaveldeptname(thiedInhospInfo.getCurrWardName());
+                patMedInhosp.setLeavediagname(thiedInhospInfo.getDiagName());
+                patMedInhosp.setLeaveicd10code(thiedInhospInfo.getDiagIcd10());
+                patMedInhosp.setDrname(thiedInhospInfo.getDoctName());
+                if (cry.equals("0")) {
+                    patMedInhosp.setSchemestatus(1L);
+                } else if (cry.equals("1")) {
+                    patMedInhosp.setSchemestatus(2L);
+                }
+                patMedInhosp.setLeavehospitaldistrictcode(thiedInhospInfo.getCurrWardId());
+                patMedInhosp.setLeavehospitaldistrictid(thiedInhospInfo.getCurrWardId());
+                patMedInhosp.setLeavehospitaldistrictname(thiedInhospInfo.getCurrWardName());
+                patMedInhosp.setLeaveldeptid(thiedInhospInfo.getCurrDeptId());
+                patMedInhospService.insertPatMedInhosp(patMedInhosp);
+
+            }
+        }
+    }
+
+
     private String getKey() {
         Map<String, String> map = new HashMap<>();
         for (int i = 0; i < 6; i++) {

--
Gitblit v1.9.3