|
@@ -1,5 +1,8 @@
|
|
|
package com.book.server.controller;
|
|
|
|
|
|
+import com.book.dao.utils.TimeUtil;
|
|
|
+import com.book.server.utils.HttpUtils;
|
|
|
+import com.book.server.utils.JsonUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.junit.Test;
|
|
|
import org.junit.runner.RunWith;
|
|
@@ -14,6 +17,11 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
|
|
import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
|
|
|
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
|
|
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
+import java.util.Calendar;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
|
|
|
|
|
/**
|
|
@@ -46,4 +54,51 @@ public class SunControllerTest {
|
|
|
|
|
|
log.info(mvcResult.getResponse().getContentAsString());
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public void loadData(String from,String to) throws Exception{
|
|
|
+
|
|
|
+ Calendar start = Calendar.getInstance();
|
|
|
+ start.setTime(TimeUtil.dateFromStr(from,TimeUtil.YYYY_MM_DD_HH_MM_SS));
|
|
|
+ Calendar end = Calendar.getInstance();
|
|
|
+ end.setTime(TimeUtil.dateFromStr(to,TimeUtil.YYYY_MM_DD_HH_MM_SS));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
+ map.put("start_time",from);
|
|
|
+ map.put("end_time",to);
|
|
|
+ String jsonStr = JsonUtils.toJsonStr(map);
|
|
|
+ System.out.println(jsonStr);
|
|
|
+ Map he = new HashMap();
|
|
|
+ he.put("Content-Type","application/json");
|
|
|
+ HttpUtils.sendPost("http://api.griacxv.cn/api/sun/getData/user_collect",he,jsonStr.getBytes(StandardCharsets.UTF_8));
|
|
|
+
|
|
|
+
|
|
|
+ start.add(Calendar.HOUR_OF_DAY,1);
|
|
|
+ end.add(Calendar.HOUR_OF_DAY,1);
|
|
|
+ if ("2021-09-30 12:00:00".equals(TimeUtil.dateToStr(start.getTime(),TimeUtil.YYYY_MM_DD_HH_MM_SS))){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Thread.sleep(1000);
|
|
|
+ loadData(TimeUtil.dateToStr(start.getTime(),TimeUtil.YYYY_MM_DD_HH_MM_SS),TimeUtil.dateToStr(end.getTime(),TimeUtil.YYYY_MM_DD_HH_MM_SS));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void load() throws Exception {
|
|
|
+ loadData("2021-09-25 00:00:00","2021-09-25 01:00:00");
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|