Browse Source

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

zxl 1 year ago
parent
commit
9b2e0a9290

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

@@ -393,7 +393,7 @@ public class STKController {
         QueryCashFlowItemsDto dtoParam = new QueryCashFlowItemsDto();
         dto.setParam(dtoParam);
         CashFlowItemsVo cashFlowItemsVo = new CashFlowItemsVo();
-        cashFlowItemsVo = requestSTKService.getCashFlowItems(dto);
+        cashFlowItemsVo = requestSTKService.getCashFlowItems2(dto);
         return cashFlowItemsVo;
     }
 

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

@@ -1,5 +1,6 @@
 package com.uas.eis.service.Impl;
 
+import cn.hutool.http.HttpRequest;
 import com.alibaba.fastjson.JSONObject;
 import com.uas.eis.dao.BaseDao;
 import com.uas.eis.dao.SqlRowList;
@@ -133,7 +134,71 @@ public class RequestSTKServiceImpl implements RequestSTKService {
             log.error("STK加密异常:{}",e.getMessage());
         }
 
-        HttpResultResponse resultResponse = HuToolUtils.post("https://192.168.2.179/api/oapigw/api/oapisvc/automicApi/89edb885a8cf4412b870233fc89fb381",dto,headerMap);
+        HttpResultResponse resultResponse = HuToolUtils.post(QUERY_URL+CASH_FLOW_ITEMS_REQUEST_CODE,dto,headerMap);
+        log.info("深投控,现金流项目,返回结果数据{}",JSONObject.toJSONString(resultResponse));
+        if(!resultResponse.getSuccess()){
+            log.info("深投控,现金流项目数据异常:{}",resultResponse.getMessage());
+        }
+        return JSONObject.parseObject(resultResponse.getBody(), CashFlowItemsVo.class);
+    }
+
+    @Override
+    public CashFlowItemsVo getCashFlowItems2(StkCommonDto dto) throws Exception {
+        /*StkCommonDto stkCommonDto = new StkCommonDto();
+        stkCommonDto.setParam(dto);*/
+
+        //头部请求参数
+        Map<String,String> headerMap = null;
+        try {
+            headerMap = getHeaderMap(dto);
+        } catch (Exception e) {
+            log.error("STK加密异常:{}",e.getMessage());
+        }
+
+
+        //应用id
+        String appid = "bf00be8b_0387_44f4_b073_50c3c2d6";
+        //应用key
+        String appkey = "eb1b6053bdda437c98a93d93013d9fae";
+        //接口代码 每个接口的接口代码都不同
+        String apiCode = "89edb885a8cf4412b870233fc89fb381";
+        //时间戳
+        String timestamp = Long.toString(System.currentTimeMillis());
+        //分页内容 自行调整
+        String page = "1";
+        String pageSize = "500";
+        //加签方法的重要参数
+        JSONObject request=new JSONObject(4);
+        request.put("page",page);
+        request.put("size",pageSize);
+        //传入参数  此处案例仅放置了时间,可自行添加
+        JSONObject param=new JSONObject();
+        request.put("param",param);
+        String content = request.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);
+        log.info("STK,原始签名测试:"+signBuilder.toString());
+        System.out.println("签名:"+sign);
+        log.info("STK,加密签名测试:"+sign);
+        System.out.println("content:"+content);
+        //请求数据 (接口地址根据测试环境与正式环境变更)
+        String body = HttpRequest.post("https://192.168.2.179/api/oapigw/api/oapisvc/automicApi/"+apiCode)
+                .header("appid",appid)  //请求头
+                .header("timestamp", timestamp)
+                .header("sign", sign)
+                .header("Content-Type", "application/json")
+                .body(content)  //请求参数
+                .timeout(20000)  //超时时间
+                .execute().body();
+
+
+        HttpResultResponse resultResponse = HuToolUtils.post(QUERY_URL+CASH_FLOW_ITEMS_REQUEST_CODE,dto,headerMap);
         log.info("深投控,现金流项目,返回结果数据{}",JSONObject.toJSONString(resultResponse));
         if(!resultResponse.getSuccess()){
             log.info("深投控,现金流项目数据异常:{}",resultResponse.getMessage());

+ 5 - 0
src/main/java/com/uas/eis/service/RequestSTKService.java

@@ -31,6 +31,11 @@ public interface RequestSTKService {
      * */
     CashFlowItemsVo getCashFlowItems(StkCommonDto dto);
 
+    /**
+     * 查询现金流项目
+     * */
+    CashFlowItemsVo getCashFlowItems2(StkCommonDto dto) throws Exception;
+
     /**
      * 获取会计科目
      * */