From 3c49f1e5c375801f546eb7e0736280693f7187cf Mon Sep 17 00:00:00 2001
From: niying <132>
Date: 星期三, 24 一月 2024 17:17:06 +0800
Subject: [PATCH] 主数据计量单位分发初始化

---
 src/main/java/com/itstyle/mdm/utils/MdmUtils.java |   97 +++++++++++++++++++++++-------------------------
 1 files changed, 46 insertions(+), 51 deletions(-)

diff --git a/src/main/java/com/itstyle/mdm/utils/MdmUtils.java b/src/main/java/com/itstyle/mdm/utils/MdmUtils.java
index 6fd29c9..e71cd99 100644
--- a/src/main/java/com/itstyle/mdm/utils/MdmUtils.java
+++ b/src/main/java/com/itstyle/mdm/utils/MdmUtils.java
@@ -23,7 +23,7 @@
 public class MdmUtils {
 
     @Value("${MDM_ADRESS}")
-    private static String MDM_ADRESS;
+    private String MDM_ADRESS;
 
     @Autowired
     private MdmService mdmService;
@@ -48,56 +48,6 @@
             if(200 == code){
                 //鎴愬姛
                 String records = httpClientResult.getContent();
-                /*String records = "{\n" +
-                        "    \"current\": 1,\n" +
-                        "    \"orders\": [],\n" +
-                        "    \"pages\": 303,\n" +
-                        "    \"records\": [\n" +
-                        "        {\n" +
-                        "            \"aliascode\": \"000\",\n" +
-                        "            \"appfrom\": \"1\",\n" +
-                        "            \"applicationaccountid\": \"D15600005811650001\",\n" +
-                        "            \"applicationname\": \"瀹℃牳绠$悊鍛榎",\n" +
-                        "            \"attri1\": \"\",\n" +
-                        "            \"attri10\": \"\",\n" +
-                        "            \"attri11\": \"\",\n" +
-                        "            \"attri12\": \"浜у搧\",\n" +
-                        "            \"attri13\": \"1667957805944\",\n" +
-                        "            \"attri14\": \"\",\n" +
-                        "            \"attri15\": \"0003.000\",\n" +
-                        "            \"attri2\": \"\",\n" +
-                        "            \"attri3\": \"\",\n" +
-                        "            \"attri4\": \"\",\n" +
-                        "            \"attri5\": \"\",\n" +
-                        "            \"attri6\": \"\",\n" +
-                        "            \"attri7\": \"\",\n" +
-                        "            \"attri8\": \"\",\n" +
-                        "            \"attri9\": \"\",\n" +
-                        "            \"companyid\": \"1560000581165\",\n" +
-                        "            \"employeeid\": \"\",\n" +
-                        "            \"globtgccode\": \"\",\n" +
-                        "            \"id\": 1668994782539,\n" +
-                        "            \"industrycode\": \"517\",\n" +
-                        "            \"industryname\": \"鍖昏嵂鍗敓淇濆仴鍖栧鍝佷笟\",\n" +
-                        "            \"name\": \"鎰熷啋鑽痋",\n" +
-                        "            \"nameen\": \"abc\",\n" +
-                        "            \"note\": \"\",\n" +
-                        "            \"ontologynamecode\": \"9000000003\",\n" +
-                        "            \"pym\": \"gmy\",\n" +
-                        "            \"rebacklockflag\": \"\",\n" +
-                        "            \"regioncode\": \"\",\n" +
-                        "            \"regionlevel\": \"\",\n" +
-                        "            \"repeatflag\": \"\",\n" +
-                        "            \"status\": \"200\",\n" +
-                        "            \"tgcoriginalcode\": \"9000000003.000\",\n" +
-                        "            \"updatedat\": 1668995367562,\n" +
-                        "            \"updatetime\": 1668995367562\n" +
-                        "        }\n" +
-                        "    ],\n" +
-                        "    \"searchCount\": true,\n" +
-                        "    \"size\": 1,\n" +
-                        "    \"total\": 303\n" +
-                        "}";*/
                 records = records.replaceAll("\\p{Z}", "");
                 JSONObject jsonObj = JSON.parseObject(records);
                 records = jsonObj.getString("records");
@@ -130,6 +80,51 @@
     }
 
     /**
+     * MDM璁¢噺鍗曚綅鏁版嵁鑾峰彇
+     * @return
+     */
+    public String queryUnit(){
+        MdmEnum anEnum = MdmEnum.getMdmEnumByAddress("璁¢噺鍗曚綅涓氬姟鍩虹鏁版嵁缂栫爜鑾峰彇");
+        StringBuffer returnJson = new StringBuffer();
+        Map<String,String> params = new HashMap<>();
+        params.put("code","1560000581165.1560000576507.a94a779e9e6d3ecbb646e39477dad6ec");//鎺堟潈鐮�
+        params.put("type",anEnum.getType());//绫诲瀷
+        String address = anEnum.getAddress();
+        try {
+            HttpClientResult httpClientResult = MdmApiUtils.doPost(MDM_ADRESS+address, null, params);
+            int code = httpClientResult.getCode();
+            if(200 == code){
+                //鎴愬姛
+                String records = httpClientResult.getContent();
+                records = records.replaceAll("\\p{Z}", "");
+                JSONObject jsonObj = JSON.parseObject(records);
+                records = jsonObj.getString("records");
+                JSONArray recordArray = JSON.parseArray(records);//鐗╂枡鏁版嵁淇℃伅
+                //灏嗘暟鎹繚瀛樿嚦鏁版嵁搴�
+                JSONArray newJson = mdmService.saveMdmData(recordArray);
+                if(newJson.size()!=0){
+                    //瀹氫箟杩斿洖json鏍煎紡
+                    returnJson.append("{\n" +
+                            "  \"code\": 200,\n" +
+                            "  \"data\":"+newJson.toJSONString());
+                    returnJson.append(",\n" +
+                            "  \"message\": \"璇锋眰鎴愬姛\",\n" +
+                            "  \"success\": true\n" +
+                            "}");
+                    //杩斿洖json鏍煎紡鍙傛暟
+                    String toString = returnJson.toString();
+                    System.out.println(toString);
+                    //鍒嗗彂澧為噺鏁版嵁鑷冲紓鏋勭郴缁�
+                    distributeDataToSys(toString,"璁¢噺鍗曚綅涓氬姟鍩虹鏁版嵁缂栫爜鑾峰彇");
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return "";
+    }
+
+    /**
      * 鍒嗗彂涓绘暟鎹暟鎹嚦寮傛瀯绯荤粺
      * @param jsonParam
      */

--
Gitblit v1.8.0