From 381dce5805f804530ca2e2eaf38b81fb0505f820 Mon Sep 17 00:00:00 2001 From: GCS-ZHN Date: Thu, 5 Aug 2021 11:06:59 +0800 Subject: [PATCH] =?UTF-8?q?=E9=92=88=E5=AF=B9=E5=AD=A6=E6=A0=A1=E6=89=93?= =?UTF-8?q?=E5=8D=A1=E5=8D=87=E7=BA=A7=E7=9A=84=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gcszhn/autocard/service/ClockinService.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/gcszhn/autocard/service/ClockinService.java b/src/main/java/org/gcszhn/autocard/service/ClockinService.java index 7e3b075..cf8b80a 100644 --- a/src/main/java/org/gcszhn/autocard/service/ClockinService.java +++ b/src/main/java/org/gcszhn/autocard/service/ClockinService.java @@ -74,9 +74,10 @@ public ArrayList getOldInfo(String username, String password) { String page = getPage(username, password); if (page==null) return null; ArrayList 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)); @@ -93,8 +94,8 @@ public ArrayList 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)); @@ -106,14 +107,11 @@ public ArrayList 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); } @@ -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;}