From 1e91dc33009cfdc951b2642877f40280b51c3089 Mon Sep 17 00:00:00 2001
From: zjh <1084500556@qq.com>
Date: 星期五, 28 二月 2025 15:17:01 +0800
Subject: [PATCH] zjh20250228

---
 ltkj-admin/src/main/java/com/ltkj/web/controller/his/HisApiGetMethodService.java |   96 ++++++++++++++++++++++++++---------------------
 1 files changed, 53 insertions(+), 43 deletions(-)

diff --git a/ltkj-admin/src/main/java/com/ltkj/web/controller/his/HisApiGetMethodService.java b/ltkj-admin/src/main/java/com/ltkj/web/controller/his/HisApiGetMethodService.java
index f2adb3a..9aa67d2 100644
--- a/ltkj-admin/src/main/java/com/ltkj/web/controller/his/HisApiGetMethodService.java
+++ b/ltkj-admin/src/main/java/com/ltkj/web/controller/his/HisApiGetMethodService.java
@@ -217,36 +217,42 @@
 
 //    @Transactional
     public AjaxResult getHISDataNew(String type, Map<String, Object> params){
-        LambdaQueryWrapper<HisApiConfig> lambdaQueryWrapper = new LambdaQueryWrapper<>();
-        lambdaQueryWrapper.eq(HisApiConfig::getApiMethod, type);
-        HisApiConfig hisApiConfig = hisApiConfigService.getOne(lambdaQueryWrapper);
-        String responseJson = HttpClientUtils.sendPost(HIS_URL + hisApiConfig.getApiUrl(), params);
-        Integer isResponse = hisApiConfig.getIsResponse();
-        JSONObject response = null;
-        if (isResponse == 1) {
-            response = JSONUtil.parseObj(responseJson).getJSONObject("Response");
-        } else{
-            response = JSONUtil.parseObj(responseJson);
-        }
-        if (response.getStr(hisApiConfig.getResultCodeKey()).equals("0")) {
-            AjaxResult ajaxResult = AjaxResult.success();
-            JSONArray resultData = response.getJSONArray(hisApiConfig.getResultDataKey());
-            List<Map<String, String>> list = new ArrayList<>();
-            for (Object resultDatum : resultData) {
-                JSONObject object = (JSONObject) resultDatum;
-                ajaxResult = save(object, type,hisApiConfig,JSONUtil.toJsonStr(params));
-                Map<String, String> map = new HashMap<>();
-                for (String key : object.keySet()) {
-                    String defaultVal = object.get(key).toString();
-                    String val = defaultVal.trim().replaceAll("\\s+", "");
-                    map.put(key, val);
-                }
-                list.add(map);
+        try {
+            LambdaQueryWrapper<HisApiConfig> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+            lambdaQueryWrapper.eq(HisApiConfig::getApiMethod, type);
+            HisApiConfig hisApiConfig = hisApiConfigService.getOne(lambdaQueryWrapper);
+            String responseJson = HttpClientUtils.sendPost(HIS_URL + hisApiConfig.getApiUrl(), params);
+            Integer isResponse = hisApiConfig.getIsResponse();
+            JSONObject response = null;
+            if (isResponse == 1) {
+                response = JSONUtil.parseObj(responseJson).getJSONObject("Response");
+            } else{
+                response = JSONUtil.parseObj(responseJson);
             }
-            ajaxResult.put("data", list);
-            return ajaxResult;
-        } else {
-            return AjaxResult.error().put("result", JSONUtil.parseObj(responseJson));
+            if (response.getStr(hisApiConfig.getResultCodeKey()).equals("0")) {
+                AjaxResult ajaxResult = AjaxResult.success();
+                JSONArray resultData = response.getJSONArray(hisApiConfig.getResultDataKey());
+                List<Map<String, String>> list = new ArrayList<>();
+                for (Object resultDatum : resultData) {
+                    JSONObject object = (JSONObject) resultDatum;
+                    ajaxResult = save(object, type,hisApiConfig,JSONUtil.toJsonStr(params));
+                    Map<String, String> map = new HashMap<>();
+                    for (String key : object.keySet()) {
+                        String defaultVal = object.get(key).toString();
+                        String val = defaultVal.trim().replaceAll("\\s+", "");
+                        map.put(key, val);
+                    }
+                    list.add(map);
+                }
+                ajaxResult.put("data", list);
+                return ajaxResult;
+            } else {
+                return AjaxResult.error().put("result", JSONUtil.parseObj(responseJson));
+            }
+        } catch (Exception e) {
+//            throw new RuntimeException(e);
+            log.error(String.valueOf(e));
+            return AjaxResult.error();
         }
     }
 
@@ -282,22 +288,26 @@
         } else{
             response = JSONUtil.parseObj(responseJson);
         }
-        if (response.getStr(apiConfig.getResultCodeKey()).equals("0")) {
+        if (response.getStr(apiConfig.getResultCodeKey()).equals("1")) {
             AjaxResult ajaxResult = AjaxResult.success();
-            JSONArray resultData = response.getJSONArray(apiConfig.getResultDataKey());
-            List<Map<String, String>> list = new ArrayList<>();
-            for (Object resultDatum : resultData) {
-                JSONObject object = (JSONObject) resultDatum;
-                ajaxResult = save(object, type,apiConfig,JSONUtil.toJsonStr(params));
-                Map<String, String> map = new HashMap<>();
-                for (String key : object.keySet()) {
-                    String defaultVal = object.get(key).toString();
-                    String val = defaultVal.trim().replaceAll("\\s+", "");
-                    map.put(key, val);
+            if (response.getStr(apiConfig.getResultDataKey()) != null && StrUtil.isNotBlank(response.getStr(apiConfig.getResultDataKey()))){
+                JSONArray resultData = response.getJSONArray(apiConfig.getResultDataKey());
+                List<Map<String, String>> list = new ArrayList<>();
+                for (Object resultDatum : resultData) {
+                    JSONObject object = (JSONObject) resultDatum;
+                    ajaxResult = save(object, type,apiConfig,JSONUtil.toJsonStr(params));
+                    Map<String, String> map = new HashMap<>();
+                    for (String key : object.keySet()) {
+                        String defaultVal = object.get(key).toString();
+                        String val = defaultVal.trim().replaceAll("\\s+", "");
+                        map.put(key, val);
+                    }
+                    list.add(map);
                 }
-                list.add(map);
+                ajaxResult.put("data", list);
+            }else {
+                ajaxResult.put("data",response);
             }
-            ajaxResult.put("data", list);
             return ajaxResult;
         } else {
             return AjaxResult.error().put("result", JSONUtil.parseObj(responseJson));
@@ -450,7 +460,7 @@
      * @throws SQLException
      */
     @Transactional
-    private void insertDataNew(Connection connection, JSONObject jsonObject,Object hisApiConfig,String paramsJson,String code) throws SQLException {
+    public void insertDataNew(Connection connection, JSONObject jsonObject, Object hisApiConfig, String paramsJson, String code) throws SQLException {
         String tabName = "";
         List<String> primaryKesList;
         if (code.equals("lis") || code.equals("pacs")) {

--
Gitblit v1.8.0