Quellcode durchsuchen

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

zxl vor 1 Jahr
Ursprung
Commit
93f259e1ff

+ 2 - 3
src/main/java/com/uas/eis/controller/STKController.java

@@ -404,9 +404,8 @@ public class STKController {
         dto.setSize("500");
         dto.setSize("500");
         QueryCashFlowItemsDto dtoParam = new QueryCashFlowItemsDto();
         QueryCashFlowItemsDto dtoParam = new QueryCashFlowItemsDto();
         dto.setParam(dtoParam);
         dto.setParam(dtoParam);
-        HttpResultResponse cashFlowItemsVo = requestSTKService.buildPostParam();
-        log.info("返回结果:{}",cashFlowItemsVo);
-        return JSONObject.parseObject(cashFlowItemsVo.getBody(),CashFlowItemsVo.class);
+        CashFlowItemsVo cashFlowItemsVo = requestSTKService.getCashFlowItems(dto);
+        return cashFlowItemsVo;
     }
     }
 
 
 
 

+ 48 - 1
src/main/java/com/uas/eis/service/Impl/RequestSTKServiceImpl.java

@@ -135,7 +135,7 @@ public class RequestSTKServiceImpl implements RequestSTKService {
         //头部请求参数
         //头部请求参数
         Map<String,String> headerMap = null;
         Map<String,String> headerMap = null;
         try {
         try {
-            headerMap = getHeaderMap(dto);
+            headerMap = getHeaderMap(dto.getPage(),dto.getSize(),dto);
         } catch (Exception e) {
         } catch (Exception e) {
             log.error("STK加密异常:{}",e.getMessage());
             log.error("STK加密异常:{}",e.getMessage());
         }
         }
@@ -321,5 +321,52 @@ public class RequestSTKServiceImpl implements RequestSTKService {
         return STKSignUtil.HMACSHA256(signBuilder.toString(),STK_APP_KEY);
         return STKSignUtil.HMACSHA256(signBuilder.toString(),STK_APP_KEY);
     }
     }
 
 
+    /**
+     * POST请求头部参数封装
+     * */
+    public Map<String,String> getHeaderMap(String page,String size, Object dto) throws Exception {
+
+        log.info("STK,加密前参数:{}",JSONObject.toJSONString(dto));
+
+        //获取签名
+        String sign = getSignToSTK(page,size,dto);
+        log.info("STK,加密后的签名:"+sign);
+
+        //时间戳
+        String timestamp = Long.toString(System.currentTimeMillis());
+
+        Map<String,String> headerMap = new HashMap<>();
+        headerMap.put("appid",STK_APP_ID);
+        headerMap.put("timestamp",timestamp);
+        headerMap.put("sign",sign);
+        headerMap.put("Content-Type","application/json");
+        return headerMap;
+    }
+
+    /**
+     * 获取深投控加密参数
+     * */
+    public String getSignToSTK(String page,String size, Object dto) throws Exception {
+
+        //时间戳
+        String timestamp = Long.toString(System.currentTimeMillis());
+
+        JSONObject object = new JSONObject();
+        object.put("size",size);
+        object.put("page",page);
+        object.put("param",dto);
+
+        String content = object.toJSONString();
+
+        //加签方法第一个参数
+        StringBuilder signBuilder = new StringBuilder("appid").append("=").append(STK_APP_ID).append("&")
+                .append(content).append("&")
+                .append("timestamp").append("=").append(timestamp).append("&")
+                .append("key").append("=").append(STK_APP_KEY);
+        log.info("STK,加密前参数:"+signBuilder.toString());
+        //加签
+        return STKSignUtil.HMACSHA256(signBuilder.toString(),STK_APP_KEY);
+    }
+
 
 
 }
 }