Skip to content

Commit

Permalink
修复考试列表的解析错误
Browse files Browse the repository at this point in the history
  • Loading branch information
nano71 committed Nov 18, 2024
1 parent 8f3700b commit 697842e
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 19 deletions.
2 changes: 1 addition & 1 deletion android/local.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sdk.dir=C:\\sdk\\android-sdk
flutter.sdk=C:\\sdk\\flutter
flutter.buildMode=release
flutter.buildMode=debug
flutter.versionName=1.6.241114
flutter.versionCode=70
60 changes: 43 additions & 17 deletions lib/common/get.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import '/common/parser.dart';
import '../config.dart';
import '../data.dart';
import '../pages/update.dart';
import 'day.dart';

Future getRecentExam() async {
print("getRecentExam");
Expand Down Expand Up @@ -140,7 +139,9 @@ Future<dynamic> getSchedule() async {

String remark(int i, int j) => tableRows(i)[j].text.trim().replaceAll(" ", ";");

int listLength = document.querySelectorAll(".infolist_common").length - 23;
int listLength = document
.querySelectorAll(".infolist_common")
.length - 23;
if (listLength > 1) {
_schedule = emptySchedule();
}
Expand Down Expand Up @@ -181,7 +182,9 @@ Future<dynamic> getSchedule() async {
if (weekInterval.indexOf("-") != -1) {
List<String> cache = weekInterval.split(",");
for (int i = 0; i < cache.length; i++) {
if (cache[i].split("-").length == 1) {
if (cache[i]
.split("-")
.length == 1) {
weekList.add(cache[i]);
continue;
}
Expand Down Expand Up @@ -344,7 +347,8 @@ Future<Map> getScheduleChanges(String id, Map schedule) async {
List<String> _addTime = teachTimeParser(cellList[8]);
//教室
String _addRoom = teachLocation(innerHtmlTrim(cellList[9]));
String remark1 = "第" + _addWeek.replaceAll("第", "").replaceAll("周", "") + "周;" + innerHtmlTrim(cellList[7]) + ";" + innerHtmlTrim(cellList[8]) + " - 调课/补课;$_addRoom";
String remark1 = "第" + _addWeek.replaceAll("第", "").replaceAll("周", "") + "周;" + innerHtmlTrim(cellList[7]) + ";" + innerHtmlTrim(cellList[8]) +
" - 调课/补课;$_addRoom";
print(remark1);
if (_delWeek != "&nbsp;") {
for (int i = int.parse(_delTime[0]); i <= int.parse(_delTime[1]); i++) {
Expand All @@ -371,7 +375,9 @@ Future<void> getName() async {
}

List getSemester() {
int y = DateTime.now().year;
int y = DateTime
.now()
.year;
return [
(y - 1980).toString(),
];
Expand Down Expand Up @@ -439,21 +445,28 @@ Future<dynamic> getExam() async {
for (int i = 1; i < _row.length; i++) {
List<String> _list = [];
String time = _row[i].querySelectorAll("td")[2].text;
List timeList = time.split("-");
List<String> timeList = time.split("-");
_list.add(_row[i].querySelectorAll("td")[1].text);
_list.add(time);
_list.add(_row[i].querySelectorAll("td")[3].text.replaceAll("空港校区", "").replaceAll("教", "").trim().substring(1).trim());
_list.add(_row[i].querySelectorAll("td")[4].text);

DateTime startDate = DateTime.now();
DateTime endDate = DateTime(int.parse(timeList[0]), int.parse(timeList[1]), int.parse(timeList[2].toString().substring(0, 2)));
int days = endDate.difference(startDate).inDays;
if (days < 0) {
examListC.add(true);
examListA++;
} else {
if (timeList.length == 1) {
examListB++;
examListC.add(false);
} else {
DateTime startDate = DateTime.now();
DateTime endDate = DateTime(int.parse(timeList[0]), int.parse(timeList[1]), int.parse(timeList[2].substring(0, 2)));
int days = endDate
.difference(startDate)
.inDays;
if (days < 0) {
examListC.add(true);
examListA++;
} else {
examListB++;
examListC.add(false);
}
}

examList.add(_list);
Expand All @@ -469,7 +482,7 @@ Future getCareer() async {
Response response;
try {
response =
await request("get", Uri.http(AppConfig.jwUrl, "/academic/manager/studyschedule/studentScheduleShowByTerm.do", {"z": "z", "studentId": url[0], "classId": url[1]}));
await request("get", Uri.http(AppConfig.jwUrl, "/academic/manager/studyschedule/studentScheduleShowByTerm.do", {"z": "z", "studentId": url[0], "classId": url[1]}));
} on TimeoutException catch (e) {
return timeOutError(e);
} on SocketException catch (e) {
Expand Down Expand Up @@ -547,7 +560,8 @@ Future getCareer() async {

Document document = parse(html);
String url = document.querySelectorAll("a")[3].parent!.innerHtml.trim();
String urlA = url.substring(url.indexOf('修读顺序:按照课组及学年学期的顺序,用二维表方式显示教学计划课组及课程"></a>') + '修读顺序:按照课组及学年学期的顺序,用二维表方式显示教学计划课组及课程"></a>'.length);
String urlA = url.substring(url.indexOf('修读顺序:按照课组及学年学期的顺序,用二维表方式显示教学计划课组及课程"></a>') +
'修读顺序:按照课组及学年学期的顺序,用二维表方式显示教学计划课组及课程"></a>'.length);
String urlB = urlA
.replaceAll('<a href="', "")
.replaceAll('" target="_blank"><img src="/academic/styles/images/Sort_Ascending.png" title="学期模式:按照学年学期的顺序,显示教学计划课程"></a>', "")
Expand Down Expand Up @@ -683,7 +697,13 @@ Future<dynamic> getUpdate({bool isRetry = false}) async {

Future getUpdateForEveryday() async {
print("getUpdateForEveryday");
if (true || "${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day}" != AppData.persistentData["newTime"]) {
if (true || "${DateTime
.now()
.year}-${DateTime
.now()
.month}-${DateTime
.now()
.day}" != AppData.persistentData["newTime"]) {
Response response;
try {
response = await get(AppConfig.getUpdateUrl);
Expand All @@ -701,7 +721,13 @@ Future getUpdateForEveryday() async {
list.add(jsonDecode(response.body)["body"]);
AppData.persistentData["newVersion"] = list[1];
AppData.persistentData["newBody"] = list[3];
AppData.persistentData["newTime"] = "${DateTime.now().year}-${DateTime.now().month}-${DateTime.now().day}";
AppData.persistentData["newTime"] = "${DateTime
.now()
.year}-${DateTime
.now()
.month}-${DateTime
.now()
.day}";
writeConfig();
checkNewVersion();
if (AppData.hasNewVersion && AppData.canCheckImportantUpdate) {
Expand Down
1 change: 0 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:async';
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
Expand Down

0 comments on commit 697842e

Please sign in to comment.