|
@@ -1,118 +1,118 @@
|
|
|
-package history;
|
|
|
-
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
-import com.alibaba.fastjson.JSONException;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.dayou.BaseApplication;
|
|
|
-import com.dayou.dto.history.HisMajorOrder;
|
|
|
-import com.dayou.dyoa.IDyoaHistoryService;
|
|
|
-import com.dayou.utils.HttpKit;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.http.HttpEntity;
|
|
|
-import org.apache.http.HttpResponse;
|
|
|
-import org.apache.http.client.HttpClient;
|
|
|
-import org.apache.http.client.methods.HttpGet;
|
|
|
-import org.apache.http.client.methods.HttpPost;
|
|
|
-import org.apache.http.impl.client.DefaultHttpClient;
|
|
|
-import org.junit.Test;
|
|
|
-import org.junit.runner.RunWith;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.boot.test.context.SpringBootTest;
|
|
|
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
|
-
|
|
|
-import java.io.BufferedReader;
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.InputStreamReader;
|
|
|
-import java.io.PrintWriter;
|
|
|
-import java.net.HttpURLConnection;
|
|
|
-import java.net.URL;
|
|
|
-import java.net.URLConnection;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.regex.Matcher;
|
|
|
-import java.util.regex.Pattern;
|
|
|
-
|
|
|
-/**
|
|
|
- * 类说明:
|
|
|
- *
|
|
|
- * @author: wucl
|
|
|
- * @since: 2024/5/7
|
|
|
- * created with IntelliJ IDEA.
|
|
|
- */
|
|
|
-@Slf4j
|
|
|
-@SpringBootTest(classes = BaseApplication.class)
|
|
|
-@RunWith(value = SpringJUnit4ClassRunner.class)
|
|
|
-public class SyncHistoryTest {
|
|
|
-
|
|
|
- private static final String HISTORY_MAJOR_ORDER_URL = "http://noa.scdayou.com/dyoa/order/pageQuery";
|
|
|
-
|
|
|
- private static final String HISTORY_LOGIN_URL = "http://noa.scdayou.com/login";
|
|
|
-
|
|
|
- private static String COOKIE ;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IDyoaHistoryService dyoaHistoryService;
|
|
|
-
|
|
|
-
|
|
|
- public static void main(String[] args) {
|
|
|
- COOKIE = historySystemLogin();
|
|
|
- syncMajorOrderTest();
|
|
|
+//package history;
|
|
|
+//
|
|
|
+//import com.alibaba.fastjson.JSON;
|
|
|
+//import com.alibaba.fastjson.JSONArray;
|
|
|
+//import com.alibaba.fastjson.JSONException;
|
|
|
+//import com.alibaba.fastjson.JSONObject;
|
|
|
+//import com.dayou.BaseApplication;
|
|
|
+//import com.dayou.dto.history.HisMajorOrder;
|
|
|
+//import com.dayou.dyoa.IDyoaHistoryService;
|
|
|
+//import com.dayou.utils.HttpKit;
|
|
|
+//import lombok.extern.slf4j.Slf4j;
|
|
|
+//import org.apache.http.HttpEntity;
|
|
|
+//import org.apache.http.HttpResponse;
|
|
|
+//import org.apache.http.client.HttpClient;
|
|
|
+//import org.apache.http.client.methods.HttpGet;
|
|
|
+//import org.apache.http.client.methods.HttpPost;
|
|
|
+//import org.apache.http.impl.client.DefaultHttpClient;
|
|
|
+//import org.junit.Test;
|
|
|
+//import org.junit.runner.RunWith;
|
|
|
+//import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+//import org.springframework.boot.test.context.SpringBootTest;
|
|
|
+//import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
|
+//
|
|
|
+//import java.io.BufferedReader;
|
|
|
+//import java.io.IOException;
|
|
|
+//import java.io.InputStreamReader;
|
|
|
+//import java.io.PrintWriter;
|
|
|
+//import java.net.HttpURLConnection;
|
|
|
+//import java.net.URL;
|
|
|
+//import java.net.URLConnection;
|
|
|
+//import java.util.Arrays;
|
|
|
+//import java.util.HashMap;
|
|
|
+//import java.util.List;
|
|
|
+//import java.util.Map;
|
|
|
+//import java.util.regex.Matcher;
|
|
|
+//import java.util.regex.Pattern;
|
|
|
+//
|
|
|
+///**
|
|
|
+// * 类说明:
|
|
|
+// *
|
|
|
+// * @author: wucl
|
|
|
+// * @since: 2024/5/7
|
|
|
+// * created with IntelliJ IDEA.
|
|
|
+// */
|
|
|
+//@Slf4j
|
|
|
+//@SpringBootTest(classes = BaseApplication.class)
|
|
|
+//@RunWith(value = SpringJUnit4ClassRunner.class)
|
|
|
+//public class SyncHistoryTest {
|
|
|
+//
|
|
|
+// private static final String HISTORY_MAJOR_ORDER_URL = "http://noa.scdayou.com/dyoa/order/pageQuery";
|
|
|
+//
|
|
|
+// private static final String HISTORY_LOGIN_URL = "http://noa.scdayou.com/login";
|
|
|
+//
|
|
|
+// private static String COOKIE ;
|
|
|
+//
|
|
|
+// @Autowired
|
|
|
+// private IDyoaHistoryService dyoaHistoryService;
|
|
|
+//
|
|
|
+//
|
|
|
+// public static void main(String[] args) {
|
|
|
+// COOKIE = historySystemLogin();
|
|
|
+// syncMajorOrderTest();
|
|
|
+//// try {
|
|
|
+//// JSONObject jsonObject = JSON.parseObject("<!DOCTYPE html>\n" +"<html>");
|
|
|
+//// } catch (JSONException e) {
|
|
|
+//// log.error("JSONException");
|
|
|
+//// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// public static void syncMajorOrderTest(){
|
|
|
+// Map<String,Object> params = new HashMap<>();
|
|
|
+// params.put("limit","15");
|
|
|
+// params.put("orderBy","-createdDatetime");
|
|
|
+// params.put("start","0");
|
|
|
+// String respond = HttpKit.sendPost(HISTORY_MAJOR_ORDER_URL, params,COOKIE);
|
|
|
+// JSONObject jsonObject = JSON.parseObject(respond);
|
|
|
+// JSONObject data = jsonObject.getJSONObject("data");
|
|
|
+// JSONArray data1 = data.getJSONArray("data");
|
|
|
+// List<HisMajorOrder> hisMajorOrders = data1.toJavaList(HisMajorOrder.class);
|
|
|
+// log.info(hisMajorOrders.toString());
|
|
|
+// }
|
|
|
+//
|
|
|
+// public static String historySystemLogin(){
|
|
|
+//
|
|
|
// try {
|
|
|
-// JSONObject jsonObject = JSON.parseObject("<!DOCTYPE html>\n" +"<html>");
|
|
|
-// } catch (JSONException e) {
|
|
|
-// log.error("JSONException");
|
|
|
+// // 创建HttpClient对象
|
|
|
+// HttpClient httpClient = new DefaultHttpClient();
|
|
|
+//
|
|
|
+// // 创建HttpGet请求对象
|
|
|
+// HttpPost httpPost = new HttpPost(HISTORY_LOGIN_URL+"?loginName=admin&password=ABC666000");
|
|
|
+//
|
|
|
+// // 发送请求并获取响应
|
|
|
+// HttpResponse response = httpClient.execute(httpPost);
|
|
|
+//
|
|
|
+// // 获取cookie
|
|
|
+// String cookies = Arrays.toString(response.getHeaders("Set-Cookie"));
|
|
|
+// if (cookies != null) {
|
|
|
+// String pattern = "(JSESSIONID)(.*?)( )";
|
|
|
+// Pattern r = Pattern.compile(pattern);
|
|
|
+// // 创建 matcher 对象
|
|
|
+// Matcher m = r.matcher(cookies);
|
|
|
+// if (m.find()) {
|
|
|
+// return m.group(0);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// // 关闭连接
|
|
|
+// httpClient.getConnectionManager().shutdown();
|
|
|
+// } catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
// }
|
|
|
- }
|
|
|
-
|
|
|
- public static void syncMajorOrderTest(){
|
|
|
- Map<String,Object> params = new HashMap<>();
|
|
|
- params.put("limit","15");
|
|
|
- params.put("orderBy","-createdDatetime");
|
|
|
- params.put("start","0");
|
|
|
- String respond = HttpKit.sendPost(HISTORY_MAJOR_ORDER_URL, params,COOKIE);
|
|
|
- JSONObject jsonObject = JSON.parseObject(respond);
|
|
|
- JSONObject data = jsonObject.getJSONObject("data");
|
|
|
- JSONArray data1 = data.getJSONArray("data");
|
|
|
- List<HisMajorOrder> hisMajorOrders = data1.toJavaList(HisMajorOrder.class);
|
|
|
- log.info(hisMajorOrders.toString());
|
|
|
- }
|
|
|
-
|
|
|
- public static String historySystemLogin(){
|
|
|
-
|
|
|
- try {
|
|
|
- // 创建HttpClient对象
|
|
|
- HttpClient httpClient = new DefaultHttpClient();
|
|
|
-
|
|
|
- // 创建HttpGet请求对象
|
|
|
- HttpPost httpPost = new HttpPost(HISTORY_LOGIN_URL+"?loginName=admin&password=ABC666000");
|
|
|
-
|
|
|
- // 发送请求并获取响应
|
|
|
- HttpResponse response = httpClient.execute(httpPost);
|
|
|
-
|
|
|
- // 获取cookie
|
|
|
- String cookies = Arrays.toString(response.getHeaders("Set-Cookie"));
|
|
|
- if (cookies != null) {
|
|
|
- String pattern = "(JSESSIONID)(.*?)( )";
|
|
|
- Pattern r = Pattern.compile(pattern);
|
|
|
- // 创建 matcher 对象
|
|
|
- Matcher m = r.matcher(cookies);
|
|
|
- if (m.find()) {
|
|
|
- return m.group(0);
|
|
|
- }
|
|
|
- }
|
|
|
- // 关闭连接
|
|
|
- httpClient.getConnectionManager().shutdown();
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void getLandTargetMajorTest() throws NoSuchFieldException, IllegalAccessException {
|
|
|
- dyoaHistoryService.fetchRealAmount();
|
|
|
- }
|
|
|
-}
|
|
|
+// return null;
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void getLandTargetMajorTest() throws NoSuchFieldException, IllegalAccessException {
|
|
|
+// dyoaHistoryService.fetchRealAmount();
|
|
|
+// }
|
|
|
+//}
|