DINGYL 3 недель назад
Родитель
Сommit
659c8d98a7

+ 9 - 0
src/main/java/com/uas/eis/controller/SERESController.java

@@ -54,4 +54,13 @@ public class SERESController {
         Map<String, Object> modelMap =seresService.getERPStock(param);
         return modelMap;
     }
+
+    @PostMapping("/erp/ZHJK/test")
+    @ResponseBody
+    public Map<String, Object> test() throws Exception {
+        SpObserver.putSp("AW_ZHJK");
+        Map<String, Object> modelMap = seresService.test();
+        return modelMap;
+    }
+
 }

+ 1 - 0
src/main/java/com/uas/eis/service/SERESService.java

@@ -9,4 +9,5 @@ public interface SERESService {
     Map<String,Object> getERPStock(String param) ;
     void getToken() throws IOException;
     Map<String,Object> saveAlert(String data) ;
+    Map<String,Object> test() throws Exception;
 }

+ 38 - 0
src/main/java/com/uas/eis/serviceImpl/SERESServiceImpl.java

@@ -125,6 +125,7 @@ public class SERESServiceImpl implements SERESService {
         }
         try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
             String respStr = EntityUtils.toString(response.getEntity(), "UTF-8");
+            logger.info("respStr {}",respStr);
             return JSON.parseObject(respStr);
         } finally {
             httpClient.close();
@@ -233,4 +234,41 @@ public class SERESServiceImpl implements SERESService {
 
         return modelMap;
     }
+
+    @Override
+    public Map<String, Object> test() throws Exception {
+        Map<String, Object> modelMap = new HashMap<String, Object>();
+        String token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE3ODM5OTcxODUsImlhdCI6MTc4Mzk5NzE4NiwiaXNzIjoiMDAwMDAwMjQ0Ni1KVFRLSE9ONCIsImV4cCI6MTc4NDAwMDc4NC4xNX0.psofo-i31lnsM9d9mHIpEG4atJv1uY6lZmZr8jBtzJE";
+        String apiPath="/aito/DIS/INV_STOCK_STS/1.0.0";
+        String fullUrl =  seresConfig.getUrl()  + apiPath;
+
+        CloseableHttpClient httpClient = HttpClients.createDefault();
+        HttpPost httpPost = new HttpPost(fullUrl);
+        // 鉴权头
+        httpPost.setHeader("Authorization", "Bearer " + token);
+        httpPost.setHeader("Content-Type", "application/json");
+        JSONObject reqBody = new JSONObject();
+        //供应商编码
+        reqBody.put("SupplierCode", seresConfig.getClientCode());
+        //工厂编码
+        //reqBody.put("FactoryCode", seresConfig.getClient_code());
+        //物料编码
+        //reqBody.put("MaterialCode", seresConfig.getClient_code());
+        //页码
+        //reqBody.put("Skip", seresConfig.getClient_code());
+        //分页大小
+        //reqBody.put("Take", seresConfig.getClient_code());
+        if (reqBody != null) {
+            StringEntity entity = new StringEntity(JSON.toJSONString(reqBody), "UTF-8");
+            httpPost.setEntity(entity);
+        }
+        try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
+            String respStr = EntityUtils.toString(response.getEntity(), "UTF-8");
+            logger.info("respStr {}",respStr);
+            return JSON.parseObject(respStr);
+        } finally {
+            httpClient.close();
+            return modelMap;
+        }
+    }
 }