From dd45098812d61999f588bb34b483d236470a1067 Mon Sep 17 00:00:00 2001
From: zhaowenxuan <chacca165@163.com>
Date: 星期一, 30 十二月 2024 11:48:58 +0800
Subject: [PATCH] 调整西安煤机医院字典同步类

---
 src/main/java/com/example/utils/synczd/DictionaryUtilShanXiXiAnMeiJiYy.java |   47 +++++++++++++++++++++++++++++++----------------
 1 files changed, 31 insertions(+), 16 deletions(-)

diff --git a/src/main/java/com/example/utils/synczd/DictionaryUtilShanXiXiAnMeiJiYy.java b/src/main/java/com/example/utils/synczd/DictionaryUtilShanXiXiAnMeiJiYy.java
index 1931744..d244e5b 100644
--- a/src/main/java/com/example/utils/synczd/DictionaryUtilShanXiXiAnMeiJiYy.java
+++ b/src/main/java/com/example/utils/synczd/DictionaryUtilShanXiXiAnMeiJiYy.java
@@ -85,7 +85,11 @@
             return;
         for (HisSyncDict hisSyncDict : hisSyncDicts) {
             boolean isFormatJson = false;
-            if (hisSyncDict.getDictName().equals("getKeShizd") || hisSyncDict.getDictName().equals("getKeShiByConditionszd")|| hisSyncDict.getDictName().equals("getShouFeiXmzd"))
+            if (hisSyncDict.getDictName().equals("getKeShizd")
+                    || hisSyncDict.getDictName().equals("getKeShiByConditionszd")
+                    || hisSyncDict.getDictName().equals("getShouFeiXmzd")
+                    || hisSyncDict.getDictName().equals("getListYiShengZd")
+            )
                 isFormatJson = true;
             hisSyncDict.setDictName(hisSyncDict.getHospId()+"_"+hisSyncDict.getDictName());
             extracted(NAME, connection, hisSyncDict,token,isFormatJson);
@@ -115,7 +119,7 @@
         JSONObject entries = execRequest(object.toString(),hisSyncDict,token);
         log.info("璇锋眰杩斿洖 ->{}", entries.toString());
         if (isFormatJson){
-            if (entries != null && "1".equals(entries.getStr("returnCode"))) {
+            if ("1".equals(entries.getStr("returnCode"))) {
                 JSONObject response = entries.getJSONObject("returnData");
                 try {
                     dropTable(tabName, connection);
@@ -151,18 +155,30 @@
                 }
             }
         }else {
-            if (entries != null && "1".equals(entries.getStr("returnCode"))) {
-                JSONArray response = entries.getJSONArray("returnData");
-                try {
-                    dropTable(tabName, connection);
-                    List<JSONObject> list = JSONUtil.toList(response, JSONObject.class);
-                    for (JSONObject jsonObject : list) {
-                        editDataBase(connection, tabName, jsonObject, name);
+            if ("1".equals(entries.getStr("returnCode"))) {
+                Object returnData = entries.get("returnData");
+                if (returnData instanceof JSONObject){
+                    JSONObject response = entries.getJSONObject("returnData");
+                    try {
+                        dropTable(tabName, connection);
+                    } catch (SQLException e) {
+                        log.error("鍒犻櫎琛ㄥ紓甯� ->{}", e.getMessage());
                     }
-                } catch (SQLException e) {
-                    log.error("鍒犻櫎琛ㄥ紓甯� ->{}", e.getMessage());
+                    editDataBase(connection, tabName, response, name);
+                }else {
+                    JSONArray response = entries.getJSONArray("returnData");
+                    try {
+                        dropTable(tabName, connection);
+                        List<JSONObject> list = JSONUtil.toList(response, JSONObject.class);
+                        for (JSONObject jsonObject : list) {
+                            editDataBase(connection, tabName, jsonObject, name);
+                        }
+                    } catch (SQLException e) {
+                        log.error("鍒犻櫎琛ㄥ紓甯� ->{}", e.getMessage());
+                    }
                 }
                 if (isLimit) {
+                    JSONArray response = entries.getJSONArray("returnData");
                     if (tabName.contains("_getjianchaxmzd")) maxPage = 10000;
                     log.info("璁$畻椤电爜涓� ->{}", maxPage);
                     if (maxPage > 1) {
@@ -184,15 +200,12 @@
                         }
                     }
                 } else {
+                    JSONArray response = entries.getJSONArray("returnData");
                     List<JSONObject> list = JSONUtil.toList(response, JSONObject.class);
                     for (JSONObject jsonObject : list) {
                         editDataBase(connection, tabName, jsonObject, name);
                     }
                 }
-
-
-
-
             }
         }
 
@@ -248,6 +261,7 @@
             log.error("瀵规瘮瀛楁鎻掑叆鏁版嵁寮傚父");
             log.error(e.getSQLState());
             log.error(e.getMessage());
+            e.printStackTrace();
         }
     }
 
@@ -269,7 +283,8 @@
             connection.setRequestMethod("POST");
             connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
             connection.setRequestProperty("Authorization", token);
-            if (hisSyncDict.getUrl().equals("/zhuShuJu/getListYiShengZd") || hisSyncDict.getUrl().equals("/zhuShuJu/getJianChaXm")){
+            log.info("璇锋眰鎺ュ彛 ->{}", hisSyncDict.getUrl());
+            if (hisSyncDict.getUrl().equals("/zhuShuJu/getListYiShengZd") || hisSyncDict.getUrl().equals("/zhuShuJu/getZhiGongPage") || hisSyncDict.getUrl().equals("/zhuShuJu/getJianChaXm")){
                 connection.setRequestProperty("dangQianYhId","DBA");
                 if (hisSyncDict.getUrl().equals("/zhuShuJu/getJianChaXm"))
                     connection.setRequestProperty("yuanQuId","1");

--
Gitblit v1.8.0