소스 검색

[深爱]科目客商变更测试

zxl 1 년 전
부모
커밋
c27d99e9cd
1개의 변경된 파일69개의 추가작업 그리고 0개의 파일을 삭제
  1. 69 0
      src/main/java/com/uas/eis/controller/STKController.java

+ 69 - 0
src/main/java/com/uas/eis/controller/STKController.java

@@ -445,4 +445,73 @@ public class STKController {
 
 
 
+
+    //应用id
+    static String appid = "bc81efc8_b2c6_4670_818e_e2710a45";
+
+    //应用key
+    static String appkey = "9a1ae28bc9104deb86f74575acc1c2d6";
+
+    //接口代码
+    static String apiCode = "18c60d85eb0646a080341b64310109f1";
+
+    @GetMapping("insertPost")
+    public static String insertPost() throws Exception {
+        //时间戳
+        String timestamp = Long.toString(System.currentTimeMillis());
+
+        //每一条数据在这里构造,根据实际情况修改
+        JSONObject request=new JSONObject(4);
+        request.put("NAME","紫光展讯通信惠州有限公司");
+        request.put("S_CODE","2024-07-04 17:11:43");
+        request.put("UID_TYPE","01");
+        request.put("UID","91441300MA4WY7CN2T");
+        request.put("CUSTOMER_TYPE","C0201");
+        request.put("IS_VALID","1");
+        request.put("CREATED_ORG","HRORGI0000000001");
+        request.put("CREATED_SYSTEM","ZHONGTAI");
+        request.put("ISTEMPORARY","0");
+        request.put("MDM_CODE",null);
+        request.put("CREAT_AT","2024-07-04 17:11:43");
+        request.put("UPDATE_AT","2024-07-04 17:11:43");
+        request.put("SERIAL","23468156486151");
+
+
+        //param参数构造 并传入你构造的每一条数据参数,此处例:1条
+        JSONObject requestparam=new JSONObject(4);
+        requestparam.put("param",request);
+
+
+        String content = requestparam.toString();
+
+        //加签方法第一个参数
+        StringBuilder signBuilder = new StringBuilder("appid").append("=").append(appid).append("&")
+                .append(content).append("&")
+                .append("timestamp").append("=").append(timestamp).append("&")
+                .append("key").append("=").append(appkey);
+
+        //加签
+        String sign = STKSignUtil.HMACSHA256(signBuilder.toString(),appkey);
+
+        System.out.println("原始:"+signBuilder);
+        System.out.println("签名:"+sign);
+        System.out.println("content:"+content);
+
+        //请求数据(接口地址根据测试环境与正式环境变更)
+        String body = HttpRequest.post("http://10.67.2.187/api/oapigw/api/oapisvc/automicUpsertApi/"+apiCode)
+                .header("appid",appid)  //请求头
+                .header("timestamp", timestamp)
+                .header("sign", sign)
+                .header("Content-Type", "application/json")
+                .body(content)  //请求参数
+                .timeout(20000)  //超时时间
+                .execute().body();
+
+        System.out.println("返回结果:"+body);
+        return (body);  //返回结果
+    }
+
+
+
+
 }