修改支持模块,获得更大通融性能
This commit is contained in:
parent
913004abde
commit
8fc5ee3816
@ -13,7 +13,10 @@ import org.springframework.scheduling.annotation.Scheduled;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@ -56,13 +59,13 @@ public class DayScheduleService {
|
|||||||
}
|
}
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
DrcomLoginEntity drocm = objectMapper.readValue(data, DrcomLoginEntity.class);
|
DrcomLoginEntity drocm = objectMapper.readValue(data, DrcomLoginEntity.class);
|
||||||
System.out.println("[INFO] " + drocm.getMessage());
|
System.out.println(new Date().getTime() + " [INFO] " + drocm.getMessage());
|
||||||
}
|
}
|
||||||
} catch (IOException ignoredSecond) {
|
} catch (IOException ignoredSecond) {
|
||||||
System.out.println("[WARNING] 无法登录");
|
System.out.println(new SimpleDateFormat().format("yyyy-mm-dd HH:ii:ss") + " [WARNING] be unable to log in");
|
||||||
}
|
}
|
||||||
} catch (IOException ignoredFirst) {
|
} catch (IOException ignoredFirst) {
|
||||||
System.out.println("[WARNING] 不处于校园网内,请手动管理网络");
|
System.out.println(new SimpleDateFormat().format("yyyy-mm-dd HH:ii:ss") + " [WARNING] Not in the campus network, please manually manage the network");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,60 +74,72 @@ public class DayScheduleService {
|
|||||||
UserEntity[] userEntities = userMapper.getAllUser();
|
UserEntity[] userEntities = userMapper.getAllUser();
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
int getLong = random.nextInt(userEntities.length);
|
int getLong = random.nextInt(userEntities.length);
|
||||||
this.login = new Request.Builder()
|
LocalTime localTime = LocalTime.now(ZoneId.systemDefault());
|
||||||
.url("http://10.1.99.100:801/eportal/portal/login?callback=dr1003&login_method=1&user_account=,0," + userEntities[getLong].getUid() + "@" + userEntities[getLong].getType() + "&user_password=" + userEntities[getLong].getPassword() + "&jsVersion=4.1.3&terminal_type=1&lang=zh-cn&v=8101&lang=zh")
|
if (localTime.isAfter(LocalTime.of(7, 0, 0)) && localTime.isBefore(LocalTime.of(23, 59, 59))) {
|
||||||
.build();
|
this.login = new Request.Builder()
|
||||||
|
.url("http://10.1.99.100:801/eportal/portal/login?callback=dr1003&login_method=1&user_account=,0," + userEntities[getLong].getUid() + "@" + userEntities[getLong].getType() + "&user_password=" + userEntities[getLong].getPassword() + "&jsVersion=4.1.3&terminal_type=1&lang=zh-cn&v=8101&lang=zh")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
this.loginBody = new Request.Builder()
|
this.loginBody = new Request.Builder()
|
||||||
.url("http://10.1.99.100/drcom/chkstatus?callback=dr1002&jsVersion=4.X&v=1117&lang=zh")
|
.url("http://10.1.99.100/drcom/chkstatus?callback=dr1002&jsVersion=4.X&v=1117&lang=zh")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Start
|
// Start
|
||||||
LocalTime localTime = LocalTime.now();
|
if (localTime.isAfter(LocalTime.of(7, 0, 0))) {
|
||||||
if (localTime.isAfter(LocalTime.of(7, 0)) && localTime.isBefore(LocalTime.of(23, 0))) {
|
if (localTime.isBefore(LocalTime.of(23, 59, 59))) {
|
||||||
OkHttpClient client = new OkHttpClient();
|
OkHttpClient client = new OkHttpClient();
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.url("https://suggestion.baidu.com/su?wd=201%E4%BA%AC%E6%B5%B7%E5%B8%82%E5%AE%BF%E8%88%8D")
|
.url("https://suggestion.baidu.com/su?wd=201%E4%BA%AC%E6%B5%B7%E5%B8%82%E5%AE%BF%E8%88%8D")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try (Response response = client.newCall(request).execute()) {
|
try (Response response = client.newCall(request).execute()) {
|
||||||
// 检查是否可以获取外网内容
|
// 检查是否可以获取外网内容
|
||||||
if (response.body() != null) {
|
if (response.body() != null) {
|
||||||
System.out.println("[INFO] 已登录");
|
System.out.println(new Date().getTime() + " [INFO] already logged in");
|
||||||
}
|
}
|
||||||
} catch (IOException ignoreFirst) {
|
} catch (IOException ignoreFirst) {
|
||||||
// 检查是否可以访问内网
|
// 检查是否可以访问内网
|
||||||
try (Response ignored = client.newCall(loginBody).execute()) {
|
try (Response ignored = client.newCall(loginBody).execute()) {
|
||||||
// 处理登录
|
// 处理登录
|
||||||
try (Response responseLogin = client.newCall(login).execute()) {
|
try (Response responseLogin = client.newCall(login).execute()) {
|
||||||
if (responseLogin.body() != null) {
|
if (responseLogin.body() != null) {
|
||||||
String getData = responseLogin.body().string();
|
String getData = responseLogin.body().string();
|
||||||
Matcher matcher = Pattern.compile("dr1003\\(([^)]+)\\)").matcher(getData);
|
Matcher matcher = Pattern.compile("dr1003\\(([^)]+)\\)").matcher(getData);
|
||||||
String data = null;
|
String data = null;
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
data = matcher.group(1);
|
data = matcher.group(1);
|
||||||
}
|
}
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
DrcomLoginEntity drocm = objectMapper.readValue(data, DrcomLoginEntity.class);
|
DrcomLoginEntity drocm = objectMapper.readValue(data, DrcomLoginEntity.class);
|
||||||
System.out.println("[INFO] " + drocm.getMessage());
|
System.out.println(new Date().getTime() + " [INFO] " + drocm.getMessage());
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
} catch (IOException ignoreSecond) {
|
||||||
|
System.out.println(new Date().getTime() + " [WARNING] Not in the campus network, please manually manage the network");
|
||||||
}
|
}
|
||||||
} catch (IOException ignoreSecond) {
|
|
||||||
System.out.println("[WARNING] 不处于校园网内,请手动管理网络");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Scheduled(cron = "0 0 23 * * 0-4")
|
@Scheduled(cron = "0 0 23 * * 0-4")
|
||||||
|
public void theWorkDay() {
|
||||||
|
this.theDayChangeNetwork();
|
||||||
|
}
|
||||||
|
|
||||||
@Scheduled(cron = "0 30 23 * * 5-6")
|
@Scheduled(cron = "0 30 23 * * 5-6")
|
||||||
|
public void theWeekendDay() {
|
||||||
|
this.theDayChangeNetwork();
|
||||||
|
}
|
||||||
|
|
||||||
public void theDayChangeNetwork() {
|
public void theDayChangeNetwork() {
|
||||||
UserEntity[] userEntities = userMapper.getAllUser();
|
UserEntity[] userEntities = userMapper.getAllUser();
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
int getLong = random.nextInt(userEntities.length);
|
int getLong = random.nextInt(userEntities.length);
|
||||||
this.login = new Request.Builder()
|
this.login = new Request.Builder()
|
||||||
.url("http://10.1.99.100:801/eportal/portal/login?callback=dr1003&login_method=1&user_account=,0," + userEntities[getLong].getUid() + "@" + userEntities[getLong].getType() + "&user_password=" + userEntities[getLong].getPassword() + "&jsVersion=4.1.3&terminal_type=1&lang=zh-cn&v=8101&lang=zh")
|
.url("http://10.1.99.100:801/eportal/portal/login?callback=dr1003&login_method=1&user_account=,0," + userEntities[getLong].getUid() + "&user_password=061823zcw&jsVersion=4.1.3&terminal_type=1&lang=zh-cn&v=6795&lang=zh")
|
||||||
.build();
|
.build();
|
||||||
this.loginBody = new Request.Builder()
|
this.loginBody = new Request.Builder()
|
||||||
.url("http://10.1.99.100/drcom/chkstatus?callback=dr1002&jsVersion=4.X&v=1117&lang=zh")
|
.url("http://10.1.99.100/drcom/chkstatus?callback=dr1002&jsVersion=4.X&v=1117&lang=zh")
|
||||||
@ -153,10 +168,7 @@ public class DayScheduleService {
|
|||||||
try (Response responseRemoveLogin = client.newCall(removeLogin).execute()) {
|
try (Response responseRemoveLogin = client.newCall(removeLogin).execute()) {
|
||||||
if (responseRemoveLogin.body() != null) {
|
if (responseRemoveLogin.body() != null) {
|
||||||
// 处理无锡学院登录
|
// 处理无锡学院登录
|
||||||
Request loginDefault = new Request.Builder()
|
try (Response responseDefault = client.newCall(login).execute()) {
|
||||||
.url("http://10.1.99.100:801/eportal/portal/login?callback=dr1003&login_method=1&user_account=,0,22344233&user_password=061823zcw&jsVersion=4.1.3&terminal_type=1&lang=zh-cn&v=6795&lang=zh")
|
|
||||||
.build();
|
|
||||||
try (Response responseDefault = client.newCall(loginDefault).execute()) {
|
|
||||||
if (responseDefault.body() != null) {
|
if (responseDefault.body() != null) {
|
||||||
String getDataDefault = responseDefault.body().string();
|
String getDataDefault = responseDefault.body().string();
|
||||||
Matcher matcherDefault = Pattern.compile("dr1003\\(([^)]+)\\)").matcher(getDataDefault);
|
Matcher matcherDefault = Pattern.compile("dr1003\\(([^)]+)\\)").matcher(getDataDefault);
|
||||||
@ -166,22 +178,22 @@ public class DayScheduleService {
|
|||||||
}
|
}
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
DrcomLoginEntity drocm = objectMapper.readValue(dataDefault, DrcomLoginEntity.class);
|
DrcomLoginEntity drocm = objectMapper.readValue(dataDefault, DrcomLoginEntity.class);
|
||||||
System.out.println("[INFO] " + drocm.getMessage());
|
System.out.println(new Date().getTime() + "[INFO] " + drocm.getMessage());
|
||||||
}
|
}
|
||||||
} catch (IOException ignored) {
|
} catch (IOException ignored) {
|
||||||
System.out.println("[WARNING] 不处于校园网内,请手动管理网络");
|
System.out.println(new SimpleDateFormat().format("yyyy-mm-dd HH:ii:ss") + " [WARNING] Not in the campus network, please manually manage the network");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
System.out.println("[ERROR] 对象服务器异常");
|
System.out.println("[ERROR] Object server exception");
|
||||||
}
|
}
|
||||||
} catch (IOException ignored) {
|
} catch (IOException ignored) {
|
||||||
System.out.println("[WARNING] 不处于校园网内,请手动管理网络");
|
System.out.println(new SimpleDateFormat().format("yyyy-mm-dd HH:ii:ss") + " [WARNING] Not in the campus network, please manually manage the network");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
System.out.println("[ERROR] 对象服务器异常");
|
System.out.println("[ERROR] Object server exception");
|
||||||
}
|
}
|
||||||
} catch (IOException ignored) {
|
} catch (IOException ignored) {
|
||||||
System.out.println("[WARNING] 不处于校园网内,请手动管理网络");
|
System.out.println(new SimpleDateFormat().format("yyyy-mm-dd HH:ii:ss") + " [WARNING] Not in the campus network, please manually manage the network");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import com.xiaolfeng.dormstar.entities.DrcomEntity;
|
|||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
import org.apache.ibatis.jdbc.Null;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
|
|
||||||
@ -21,9 +20,7 @@ public class GetWxxyNetworkInfo {
|
|||||||
|
|
||||||
public void getWxxyNetWork(Model model) {
|
public void getWxxyNetWork(Model model) {
|
||||||
OkHttpClient client = new OkHttpClient();
|
OkHttpClient client = new OkHttpClient();
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder().url("http://10.1.99.100/drcom/chkstatus?callback=dr1002&jsVersion=4.X&v=1117&lang=zh").build();
|
||||||
.url("http://10.1.99.100/drcom/chkstatus?callback=dr1002&jsVersion=4.X&v=1117&lang=zh")
|
|
||||||
.build();
|
|
||||||
|
|
||||||
try (Response response = client.newCall(request).execute()) {
|
try (Response response = client.newCall(request).execute()) {
|
||||||
if (response.body() != null) {
|
if (response.body() != null) {
|
||||||
@ -55,10 +52,10 @@ public class GetWxxyNetworkInfo {
|
|||||||
model.addAttribute("getServiceProvider", "无锡学院");
|
model.addAttribute("getServiceProvider", "无锡学院");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
model.addAttribute("getServiceProvider", "未知");
|
model.addAttribute("getServiceProvider", "无锡学院");
|
||||||
}
|
}
|
||||||
model.addAttribute("getLogin", "已登录");
|
model.addAttribute("getLogin", "已登录");
|
||||||
} else {
|
} else {
|
||||||
model.addAttribute("getLogin", "未登录");
|
model.addAttribute("getLogin", "未登录");
|
||||||
System.out.println("未登录");
|
System.out.println("未登录");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user