瀏覽代碼

委外订单调整

zengtx 3 年之前
父節點
當前提交
4e407668aa

+ 7 - 11
jeecg-boot-module-system/src/main/java/org/jeecg/modules/openApi/controller/MOMainController.java

@@ -176,16 +176,14 @@ public class MOMainController implements ApplicationContextAware {
                     //调用doPost
                     InterfaceConnUtils interfaceConnUtils = new InterfaceConnUtils();
                     //处理返回信息
-                    String  informationJson = interfaceConnUtils.doPostToBearer(result, url,tokenUrl, "委外订单接口-");
-                    String jsonString = StringEscapeUtils.unescapeJava(informationJson);
-                    JSONObject jsonArr = JSONObject.parseObject(jsonString);
-                    JSONArray jsonArray = jsonArr.getJSONArray("payload");
-                    if (jsonArray.size() != 0) {
+                    JSONObject  informationJson = interfaceConnUtils.doPostToBearer(result, url,tokenUrl, "采购订单接口-");
+                    JSONObject jsonArray = informationJson.getJSONObject("payload");
+
                         //获取4个账套值
                         String yi = "";
                         String er = "";
                         String san = "";
-                        String si = "";
+                   
                         for (String str : pkorgSplit) {
                             String pkorgStr = str;
                             String pkorgValue[] = pkorgStr.split(":");
@@ -200,9 +198,8 @@ public class MOMainController implements ApplicationContextAware {
                             }
                         }
                         //回写U8物料信息表是否同步成功字段
-                        Iterator<Object> it = jsonArray.iterator();
-                        while (it.hasNext()) {
-                            JSONObject jo = (JSONObject) it.next();
+
+                            JSONObject jo = jsonArray;
                             //获取是否成功
                             String code = jo.getString("code");
                             //获取返回消息
@@ -248,8 +245,7 @@ public class MOMainController implements ApplicationContextAware {
 
 
                         }
-                    }
-                }
+
 
                 //回写委外订单接口最后时间
                 Date datetome = sf.parse(beginTime);

+ 8 - 14
jeecg-boot-module-system/src/main/java/org/jeecg/modules/openApi/controller/POPomainController.java

@@ -167,20 +167,16 @@ public class POPomainController implements ApplicationContextAware {
                     //调用doPost
                     InterfaceConnUtils interfaceConnUtils = new InterfaceConnUtils();
                     //处理返回信息
-                    String  informationJson = interfaceConnUtils.doPostToBearer(result, url,tokenUrl, "采购订单接口-");
-                    String jsonString = StringEscapeUtils.unescapeJava(informationJson);
-                    JSONObject jsonArr = JSONObject.parseObject(jsonString);
-                    JSONArray jsonArray = jsonArr.getJSONArray("payload");
+                    JSONObject  informationJson = interfaceConnUtils.doPostToBearer(result, url,tokenUrl, "采购订单接口-");
+                    JSONObject jsonArray = informationJson.getJSONObject("payload");
+//                    String jsonString = StringEscapeUtils.unescapeJava(jsonArray1.toJSONString());
+//                    JSONObject jsonArr = JSONObject.parseObject(jsonString);
 
-                    log.info("payload数据:" + jsonArray);
-
-
-                    if (jsonArray.size() != 0) {
                         //获取4个账套值
                         String yi = "";
                         String er = "";
                         String san = "";
-                        String si = "";
+
                         for (String str : pkorgSplit) {
                             String pkorgStr = str;
                             String pkorgValue[] = pkorgStr.split(":");
@@ -195,9 +191,7 @@ public class POPomainController implements ApplicationContextAware {
                             }
                         }
                         //回写U8物料信息表是否同步成功字段
-                        Iterator<Object> it = jsonArray.iterator();
-                        while (it.hasNext()) {
-                            JSONObject jo = (JSONObject) it.next();
+                            JSONObject jo = jsonArray;
                             //获取是否成功
                             String code = jo.getString("code");
                             //获取返回消息
@@ -247,8 +241,8 @@ public class POPomainController implements ApplicationContextAware {
                                 }
                             }
                         }
-                    }
-                }
+
+
                 //回写委外订单接口最后时间
                 Date datetome = sf.parse(beginTime);
                 dxpDataPlanService.updateLastTime(datetome, "senYu_poMain");

+ 4 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/openApi/controller/RdrecordController.java

@@ -99,11 +99,13 @@ public class RdrecordController implements ApplicationContextAware {
             //调用doPost
             InterfaceConnUtils interfaceConnUtils = new InterfaceConnUtils();
             //处理返回信息
-            String  informationJson = interfaceConnUtils.doPostToBearer(result, url,tokenUrl, "材料出库接口-");
-            String jsonString = StringEscapeUtils.unescapeJava(informationJson);
+            JSONObject  informationJson = interfaceConnUtils.doPostToBearer(result, url,tokenUrl, "采购订单接口-");
+            JSONArray jsonArray1 = informationJson.getJSONArray("payload");
+            String jsonString = StringEscapeUtils.unescapeJava(jsonArray1.toJSONString());
             JSONObject jsonArr = JSONObject.parseObject(jsonString);
             JSONArray jsonArray = jsonArr.getJSONArray("payload");
 
+
             if (jsonArray.size() != 0) {
                 //获取4个账套值
                 String yi = "";

+ 5 - 5
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/util/InterfaceConnUtils.java

@@ -64,9 +64,9 @@ public class InterfaceConnUtils {
      * post请求-推数据,Token认证:Bearer Token
      * @throws Exception
      */
-    public static String doPostToBearer(JSONObject json, String url,String tokenIp,String type) throws Exception {
+    public static JSONObject doPostToBearer(JSONObject json, String url,String tokenIp,String type) throws Exception {
         //定义返回JSON
-        String jsonString = "";
+        JSONObject onejb = new JSONObject();
         String token=null;
         HttpClient httpClient = new DefaultHttpClient();
         //获取token的Url
@@ -97,12 +97,12 @@ public class InterfaceConnUtils {
             HttpResponse response = httpClient.execute(httpPost);
             //返回信息
             String resultStr = EntityUtils.toString(response.getEntity());
-            jsonString =resultStr;
-            System.out.println(type+"返回信息:"+jsonString);
+            onejb=JSONObject.parseObject(resultStr);
+            System.out.println(type+"返回信息:"+onejb);
 
         } catch (Exception e) {
             e.printStackTrace();
         }
-        return jsonString;
+        return onejb;
     }
 }