Browse Source

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

zxl 1 year ago
parent
commit
c15be54c56

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

@@ -403,9 +403,8 @@ public class STKController {
         dto.setPage(String.valueOf(pageXjl));
         dto.setSize("500");
         QueryCashFlowItemsDto dtoParam = new QueryCashFlowItemsDto();
-        dto.setParam(dtoParam);
-        CashFlowItemsVo cashFlowItemsVo = requestSTKService.getCashFlowItems(dto);
-        return cashFlowItemsVo;
+        HttpResultResponse cashFlowItemsVo = requestSTKService.buildPostParam(1,500,dtoParam);
+        return JSONObject.parseObject(cashFlowItemsVo.getBody(),CashFlowItemsVo.class);
     }
 
 

+ 8 - 59
src/main/java/com/uas/eis/service/Impl/RequestSTKServiceImpl.java

@@ -135,7 +135,7 @@ public class RequestSTKServiceImpl implements RequestSTKService {
         //头部请求参数
         Map<String,String> headerMap = null;
         try {
-            headerMap = getHeaderMap(dto.getPage(),dto.getSize(),dto.getParam());
+            headerMap = getHeaderMap(dto);
         } catch (Exception e) {
             log.error("STK加密异常:{}",e.getMessage());
         }
@@ -189,7 +189,7 @@ public class RequestSTKServiceImpl implements RequestSTKService {
     }
 
     @Override
-    public HttpResultResponse buildPostParam() throws Exception {
+    public HttpResultResponse buildPostParam(Integer page,Integer size,QueryCashFlowItemsDto dtoParam) throws Exception {
         /*String appid = "bf00be8b_0387_44f4_b073_50c3c2d6";
 
         //应用key
@@ -202,9 +202,9 @@ public class RequestSTKServiceImpl implements RequestSTKService {
         String timestamp = Long.toString(System.currentTimeMillis());
 
         //分页内容 自行调整
-        String page = "1";
+       /* String page = "1";
         String pageSize = "500";
-
+*/
         //支持  时间字段_start  时间字段_end  的传值  例:UPDATE_TIME
         DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
         LocalDateTime begin = LocalDateTime.of(LocalDate.now(), LocalTime.MIN).with(TemporalAdjusters.firstDayOfYear());
@@ -214,17 +214,17 @@ public class RequestSTKServiceImpl implements RequestSTKService {
         JSONObject request=new JSONObject(4);
         //request.put("code","MJ3ahZ9f");
         request.put("page",page);
-        request.put("size",pageSize);
+        request.put("size",size);
 
         //传入参数  此处案例仅放置了时间,可自行添加
-        JSONObject param=new JSONObject();
+        //JSONObject param=new JSONObject();
         //param.put("UPDATE_TIME_start","2024-05-09 14:24:06");
         //param.put("UPDATE_TIME_end","2024-05-09 15:01:28");
         //param.put("TASKNO","P2022032200000041");
         //param.put("TASKCODE","202409");
 
 
-        request.put("param",param);
+        request.put("param",JSONObject.toJSONString(dtoParam));
 
         String content = request.toString();
 
@@ -237,11 +237,8 @@ public class RequestSTKServiceImpl implements RequestSTKService {
         //加签
         String sign = STKSignUtil.HMACSHA256(signBuilder.toString(),STK_APP_KEY);
 
-        System.out.println("原始:"+signBuilder);
         log.info("STK,原始签名:"+signBuilder.toString());
-        System.out.println("签名:"+sign);
         log.info("STK,加密签名:"+sign);
-        System.out.println("content:"+content);
 
 
         //请求数据 (接口地址根据测试环境与正式环境变更)
@@ -261,7 +258,7 @@ public class RequestSTKServiceImpl implements RequestSTKService {
         header.put("timestamp", timestamp);
         header.put("sign", sign);
         header.put("Content-Type", "application/json");
-        HttpResultResponse resultResponse = HuToolUtils.post("https://192.168.2.179/api/oapigw/api/oapisvc/automicApi/"+CASH_FLOW_ITEMS_REQUEST_CODE
+        HttpResultResponse resultResponse = HuToolUtils.post(QUERY_URL+CASH_FLOW_ITEMS_REQUEST_CODE
                 ,request, header);
 
         log.info("示例返回:{}",JSONObject.toJSONString(resultResponse));
@@ -321,52 +318,4 @@ public class RequestSTKServiceImpl implements RequestSTKService {
         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);
-    }
-
-
 }

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

@@ -45,7 +45,7 @@ public interface RequestSTKService {
     /**
      * post请求
      * */
-    HttpResultResponse buildPostParam() throws Exception;
+    HttpResultResponse buildPostParam(Integer page,Integer size,QueryCashFlowItemsDto dtoParam) throws Exception;