Просмотр исходного кода

[深爱]科目基础资料对接测试

zxl 1 год назад
Родитель
Сommit
ba67855b63

+ 64 - 4
src/main/java/com/uas/eis/service/Impl/RequestSTKServiceImpl.java

@@ -308,17 +308,17 @@ public class RequestSTKServiceImpl implements RequestSTKService {
     public SaveOrChangeCustomerDataVo updateKSPostParam(SaveOrChangeCustomerDetailDto dto) throws Exception {
 
         //时间戳
-        String timestamp = Long.toString(System.currentTimeMillis());
+        /*String timestamp = Long.toString(System.currentTimeMillis());
 
         //每一条数据在这里构造,根据实际情况修改
         JSONObject request=new JSONObject(4);
 
-        /*Field[] fields = dto.getClass().getDeclaredFields();
+        *//*Field[] fields = dto.getClass().getDeclaredFields();
         for(Field field : fields){
             String fieldName =  field.getName();
             if(getValueByFieldName(fieldName,dto)!=null)
                 request.put(fieldName,  getValueByFieldName(fieldName,dto));
-        }*/
+        }*//*
         request.put("NAME","紫光展讯通信惠州有限公司");
         request.put("S_CODE","2024-07-04 17:11:43");
         request.put("UID_TYPE","01");
@@ -363,7 +363,67 @@ public class RequestSTKServiceImpl implements RequestSTKService {
                 .body(content)  //请求参数
                 .timeout(20000)  //超时时间
                 .execute().body();
-        log.info("修改客商返回信息:{}",body);
+        log.info("修改客商返回信息:{}",body);*/
+        //时间戳
+        String timestamp = Long.toString(System.currentTimeMillis());
+
+        //应用id
+        String appid = "bc81efc8_b2c6_4670_818e_e2710a45";
+
+        //应用key
+        String appkey = "9a1ae28bc9104deb86f74575acc1c2d6";
+
+        //接口代码
+        String apiCode = "18c60d85eb0646a080341b64310109f1";
+
+        //每一条数据在这里构造,根据实际情况修改
+        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 JSONObject.parseObject(body,SaveOrChangeCustomerDataVo.class);
     }
 

+ 3 - 3
src/main/java/com/uas/eis/service/Impl/STKServiceImpl.java

@@ -187,12 +187,12 @@ public class STKServiceImpl implements STKService {
                 sourceDataList.add(sourcedao);
             }
         }
-        List<SaveOrChangeCustomerVo> changeCustomerVos = new ArrayList<>();
+        List<SaveOrChangeCustomerDataVo> changeCustomerVos = new ArrayList<>();
         //调用深投控api接口
         for(SaveOrChangeCustomerDetailDto detailDto : sourceDataList){
-            SaveOrChangeCustomerVo saveOrChangeCustomerVo = null;
+            SaveOrChangeCustomerDataVo saveOrChangeCustomerVo = null;
             try {
-                SaveOrChangeCustomerDataVo saveOrChangeCustomerDataVo= requestSTKService.updateKSPostParam(detailDto);
+                saveOrChangeCustomerVo = requestSTKService.updateKSPostParam(detailDto);
             } catch (Exception e) {
                 e.printStackTrace();
             }