Skip to content
This repository has been archived by the owner on Dec 4, 2023. It is now read-only.

Commit

Permalink
针对学校打卡升级的更新
Browse files Browse the repository at this point in the history
  • Loading branch information
GCS-ZHN committed Aug 5, 2021
1 parent d944019 commit 381dce5
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/main/java/org/gcszhn/autocard/service/ClockinService.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ public ArrayList<NameValuePair> getOldInfo(String username, String password) {
String page = getPage(username, password);
if (page==null) return null;
ArrayList<NameValuePair> res = new ArrayList<>();
// 该部分模拟网页JS代码进行信息合并
try {
Pattern def = Pattern.compile("var def = (\\{.+\\});");
Matcher matcher = def.matcher(page);
Pattern defPattern = Pattern.compile("var def = (\\{.+\\});");
Matcher matcher = defPattern.matcher(page);
JSONObject defJsonObject = null;
if (matcher.find()) {
defJsonObject = JSONObject.parseObject(matcher.group(1));
Expand All @@ -93,8 +94,8 @@ public ArrayList<NameValuePair> getOldInfo(String username, String password) {
} else {
return null;
}
Pattern pattern = Pattern.compile("oldInfo: (\\{.+\\})");
matcher = pattern.matcher(page);
Pattern oldInfoPattern = Pattern.compile("oldInfo: (\\{.+\\})");
matcher = oldInfoPattern.matcher(page);
JSONObject oldInfoJson = null;
if (matcher.find()) {
oldInfoJson = JSONObject.parseObject(matcher.group(1));
Expand All @@ -106,14 +107,11 @@ public ArrayList<NameValuePair> getOldInfo(String username, String password) {
infoJsonObject1.putAll(oldInfoJson);
infoJsonObject1.forEach((String name, Object value)->{
switch (name) {
//case "sfzx":value="1";break;
case "date":value=sdf.format(new Date());break;
}
if (name.equals("jrdqtlqk")) return;
if (value.toString().equals("[]")) return; //空数组不上报
res.add(new BasicNameValuePair(name, String.valueOf(value)));
});

System.out.println(infoJsonObject1.toJSONString());
} catch (Exception e) {
LogUtils.printMessage(null, e, LogUtils.Level.ERROR);
}
Expand All @@ -140,7 +138,6 @@ public StatusCode submit(String username, String password) {
}
JSONObject resp = JSONObject.parseObject(client.doPostText(submitUrl, info));
int status = resp.getIntValue("e");
System.out.println(resp.get("m"));
LogUtils.Level level = null;
switch(status) {
case 0:{level= LogUtils.Level.INFO;break;}
Expand Down

0 comments on commit 381dce5

Please sign in to comment.