|
|
@@ -16,6 +16,11 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.LocalTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.time.temporal.TemporalAdjusters;
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
@@ -225,5 +230,147 @@ public class STKController {
|
|
|
return (body); //返回结果
|
|
|
}
|
|
|
|
|
|
+ //现金流测试
|
|
|
+ @GetMapping("apiPostxjl")
|
|
|
+ public String apiPostxjl() throws Exception {
|
|
|
+ //应用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 = "100";
|
|
|
+
|
|
|
+ //支持 时间字段_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());
|
|
|
+ LocalDateTime end = LocalDateTime.now();
|
|
|
+
|
|
|
+ //加签方法的重要参数
|
|
|
+ JSONObject request=new JSONObject(4);
|
|
|
+ //request.put("code","MJ3ahZ9f");
|
|
|
+ request.put("page",page);
|
|
|
+ request.put("size",pageSize);
|
|
|
+
|
|
|
+ //传入参数 此处案例仅放置了时间,可自行添加
|
|
|
+ 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);
|
|
|
+
|
|
|
+ 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);
|
|
|
+ System.out.println("签名:"+sign);
|
|
|
+ System.out.println("content:"+content);
|
|
|
+
|
|
|
+
|
|
|
+ //请求数据 (接口地址根据测试环境与正式环境变更)
|
|
|
+ String body = HttpRequest.post("http://10.67.2.187/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();
|
|
|
+
|
|
|
+ // System.out.println("返回结果:"+body);
|
|
|
+ System.out.println(body);
|
|
|
+ return (body); //返回结果
|
|
|
+ }
|
|
|
+
|
|
|
+ //科目测试
|
|
|
+ @GetMapping("apiPostkm")
|
|
|
+ public String apiPostkm() throws Exception {
|
|
|
+ //应用id
|
|
|
+ String appid = "bf00be8b_0387_44f4_b073_50c3c2d6";
|
|
|
+
|
|
|
+ //应用key
|
|
|
+ String appkey = "eb1b6053bdda437c98a93d93013d9fae";
|
|
|
+
|
|
|
+ //接口代码 每个接口的接口代码都不同
|
|
|
+ String apiCode = "11e72229359a4fdeb038dd6713dc9330";
|
|
|
+
|
|
|
+ //时间戳
|
|
|
+ String timestamp = Long.toString(System.currentTimeMillis());
|
|
|
+
|
|
|
+ //分页内容 自行调整
|
|
|
+ String page = "1";
|
|
|
+ String pageSize = "100";
|
|
|
+
|
|
|
+ //支持 时间字段_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());
|
|
|
+ LocalDateTime end = LocalDateTime.now();
|
|
|
+
|
|
|
+ //加签方法的重要参数
|
|
|
+ JSONObject request=new JSONObject(4);
|
|
|
+ //request.put("code","MJ3ahZ9f");
|
|
|
+ request.put("page",page);
|
|
|
+ request.put("size",pageSize);
|
|
|
+
|
|
|
+ //传入参数 此处案例仅放置了时间,可自行添加
|
|
|
+ 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);
|
|
|
+
|
|
|
+ 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);
|
|
|
+ System.out.println("签名:"+sign);
|
|
|
+ System.out.println("content:"+content);
|
|
|
+
|
|
|
+
|
|
|
+ //请求数据 (接口地址根据测试环境与正式环境变更)
|
|
|
+ String body = HttpRequest.post("http://10.67.2.187/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();
|
|
|
+
|
|
|
+ // System.out.println("返回结果:"+body);
|
|
|
+ System.out.println(body);
|
|
|
+ return (body); //返回结果
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|