package com.yuntable.sheep.reptile.service.module.baiyun.service.impl;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.util.EntityUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yuntable.sheep.common.entity.Result;
import com.yuntable.sheep.common.entity.TwoString;
import com.yuntable.sheep.common.util.MD5Util;
import com.yuntable.sheep.reptile.remote.entity.Attendance;
import com.yuntable.sheep.reptile.remote.entity.Constant;
import com.yuntable.sheep.reptile.remote.entity.Course;
import com.yuntable.sheep.reptile.remote.entity.CourseTime;
import com.yuntable.sheep.reptile.remote.entity.Score;
import com.yuntable.sheep.reptile.remote.entity.StudentInfo;
import com.yuntable.sheep.reptile.service.global.service.impl.HttpClientServiceImpl;
import com.yuntable.sheep.reptile.service.global.service.impl.ReptileServiceImpl;
import com.yuntable.sheep.reptile.service.global.util.HttpClientUtil;
import com.yuntable.sheep.reptile.service.module.baiyun.util.BaiYunJsMethods;
import com.yuntable.sheep.reptile.service.module.baiyun.util.BaiYunJsUtil;
@Service
public class BaiYunServiceImpl extends ReptileServiceImpl {
@Autowired
private HttpClientServiceImpl httpClientService;
// 初始化地址
private static final String initUrl = "http://jwgl.baiyunu.edu.cn/_data/login_home.aspx";
// 验证码地址
private static final String loginValiCodeUrl = "http://jwgl.baiyunu.edu.cn/sys/ValidateCode.aspx";
// 登录地址
private static final String loginUrl = "http://jwgl.baiyunu.edu.cn/_data/login_home.aspx";
// 课程地址前准备地址
private static final String coursePreUrl = "http://jwgl.baiyunu.edu.cn/znpk/Pri_StuSel.aspx";
// 课程地址
private static final String courseUrl = "http://jwgl.baiyunu.edu.cn/znpk/Pri_StuSel_rpt.aspx?m=";
// 个人信息地址
private static final String stuInfoUrl = "http://jwgl.baiyunu.edu.cn/xsxj/Stu_MyInfo_RPT.aspx";
// 课程成绩地址
private static final String scoreUrl = "http://jwgl.baiyunu.edu.cn/xscj/Stu_MyScore_rpt.aspx";
// 考勤记录地址
private static final String attendanceUrl = "http://jwgl.baiyunu.edu.cn/JXKQ/Stu_kqjg_rpt.aspx";
private static BaiYunJsMethods jsMethods = BaiYunJsUtil.getInstance();
private static Map<String, Integer> dayOfWeekMap;
private static Map<String, Integer> requiredTypeMap;
private static Map<String, Integer> contentTypeMap;
private static Map<String, Integer> teachTypeMap;
private static Map<String, Integer> examMethodMap;
private static Map<TwoString, String> termCourseCodeMap;
private static Map<String, Integer> studyNation;
private static Map<String, Integer> attendanceReasonMap;
static {
// 星期
dayOfWeekMap = new HashMap<String, Integer>();
dayOfWeekMap.put("一", 1);
dayOfWeekMap.put("二", 2);
dayOfWeekMap.put("三", 3);
dayOfWeekMap.put("四", 4);
dayOfWeekMap.put("五", 5);
// 课程要求类型
requiredTypeMap = new HashMap<String, Integer>();
requiredTypeMap.put("必修课", Constant.REQUIREDTYPE_REQUIRED);
requiredTypeMap.put("选修课", Constant.REQUIREDTYPE_ELECTIVE);
requiredTypeMap.put("任选课", Constant.REQUIREDTYPE_FREE_ELECTIVE);
requiredTypeMap.put("其它", Constant.REQUIREDTYPE_OTHER);
// 课程内容类型
contentTypeMap = new HashMap<String, Integer>();
contentTypeMap.put("专业课", Constant.CONTENTTYPE_PROFESSION);
contentTypeMap.put("公共课", Constant.CONTENTTYPE_PUBLIC);
contentTypeMap.put("课程设计", Constant.CONTENTTYPE_CURRICULUM_DESIGN);
contentTypeMap.put("其它", Constant.CONTENTTYPE_OTHER);
// 授课方式
teachTypeMap = new HashMap<String, Integer>();
teachTypeMap.put("讲授", Constant.TEACHTYPE_FACE);
// 考核方式
examMethodMap = new HashMap<String, Integer>();
examMethodMap.put("统考", Constant.EXAMMETHOD_GENERAL);
examMethodMap.put("非统考", Constant.EXAMMETHOD_NOGENERAL);
examMethodMap.put("考查", Constant.EXAMMETHOD_NORMAL);
// 课表的学期代码
studyNation = new HashMap<String, Integer>();
studyNation.put("初修", Constant.STUDYNATION_FIRST);
// 课表的学期代码
termCourseCodeMap = new HashMap<TwoString, String>();
termCourseCodeMap.put(new TwoString("2018", "2"), "20181");
termCourseCodeMap.put(new TwoString("2019", "1"), "20190");
// 缺勤原因
attendanceReasonMap = new HashMap<String, Integer>();
attendanceReasonMap.put("请假", Constant.ATTENDANCEREASON_LEAVE);
attendanceReasonMap.put("旷课", Constant.ATTENDANCEREASON_TRUANCY);
attendanceReasonMap.put("早退", Constant.ATTENDANCEREASON_EARLYLEAVE);
}
// 外部方法获取初始化cookie
public Result<Map<String, String>> getInitCookie() {
Map<String, String> cookieMap = getInitCookie(null, initUrl);
if (cookieMap == null || cookieMap.size() <= 0) {
return Result.fail();
}
return Result.ok(cookieMap);
}
public Result<byte[]> getLoginValiCode(Map<String, String> cookieMap) {
// 获取并设置请求头
Map<String, String> headerMap = getInitCookie(cookieMap, initUrl);
headerMap.put("User-Agent",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36");
headerMap.put("Origin", "http://jwgl.baiyunu.edu.cn");
headerMap.put("Host", "jwgl.baiyunu.edu.cn");
headerMap.put("Accept-Encoding", "gzip, deflate, sdch");
headerMap.put("Content-Type", "application/x-www-form-urlencoded");
headerMap.put("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8");
headerMap.put("Connection", "keep-alive");
headerMap.put("Referer", "http://jwgl.baiyunu.edu.cn/_data/login_home.aspx");
try {
CloseableHttpResponse response = httpClientService.postToResp(headerMap, loginValiCodeUrl, null);
if (response != null) {
HttpEntity entity = response.getEntity();
if (entity != null) {
return Result.ok(EntityUtils.toByteArray(entity));
}
}
} catch (Exception e) {
e.printStackTrace();
}
return Result.fail();
}
/*
* 登录
*/
public Result<Object> login(Map<String, String> cookieMap, String stuId, String password, String valiCode) {
// 获取并设置请求头
Map<String, String> headerMap = getInitCookie(cookieMap, initUrl);
headerMap.put("User-Agent",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36");
headerMap.put("Origin", "http://jwgl.baiyunu.edu.cn");
headerMap.put("Host", "jwgl.baiyunu.edu.cn");
headerMap.put("Accept-Encoding", "gzip, deflate, sdch");
headerMap.put("Content-Type", "application/x-www-form-urlencoded");
headerMap.put("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8");
headerMap.put("Connection", "keep-alive");
headerMap.put("Referer", "http://jwgl.baiyunu.edu.cn/_data/login_home.aspx");
// 设置参数
Map<String, String> params = new HashMap<String, String>();
params.put("__VIEWSTATE",
"dDwtNDU3MzUyODE0O3Q8O2w8aTwwPjtpPDE+O2k8Mj47PjtsPHQ8cDxsPFRleHQ7PjtsPOW5v+S4nOeZveS6keWtpumZojs+Pjs7Pjt0PHA8bDxUZXh0Oz47bDxcPHNjcmlwdCB0eXBlPSJ0ZXh0L2phdmFzY3JpcHQiXD4KZnVuY3Rpb24gQ2hrVmFsdWUoKXsKIHZhciB2VT0kKCdVSUQnKS5pbm5lckhUTUxcOwogdlU9dlUuc3Vic3RyaW5nKDAsMSkrdlUuc3Vic3RyaW5nKDIsMylcOwogdmFyIHZjRmxhZyA9ICJZRVMiXDsgaWYgKCQoJ3R4dF9hc21jZGVmc2Rkc2QnKS52YWx1ZT09JycpewogYWxlcnQoJ+mhu+W9leWFpScrdlUrJ++8gScpXDskKCd0eHRfYXNtY2RlZnNkZHNkJykuZm9jdXMoKVw7cmV0dXJuIGZhbHNlXDsKfQogZWxzZSBpZiAoJCgndHh0X3Bld2Vyd2Vkc2Rmc2RmZicpLnZhbHVlPT0nJyl7CiBhbGVydCgn6aG75b2V5YWl5a+G56CB77yBJylcOyQoJ3R4dF9wZXdl
没有合适的资源?快使用搜索试试~ 我知道了~
青果教育系统登录+查课表+查成绩+查考勤(SpringBoot+Dubbo).zip
共24个文件
java:21个
xml:1个
properties:1个
需积分: 1 0 下载量 107 浏览量
2023-08-20
20:46:56
上传
评论
收藏 27KB ZIP 举报
温馨提示
springboot、Dubbo、MySQL,源码web系统,框架,代码均经过严格测试,可直接运行,有需要可自取
资源推荐
资源详情
资源评论
收起资源包目录
青果教育系统登录+查课表+查成绩+查考勤(SpringBoot+Dubbo).zip (24个子文件)
content_code
pom.xml 2KB
src
test
java
com
yuntable
test
Test.java 2KB
main
resources
application.properties 587B
java
com
yuntable
sheep
reptile
service
global
thread
IdleConnectionEvictor.java 832B
service
impl
HttpClientServiceImpl.java 4KB
ReptileServiceImpl.java 3KB
ReptileEntranceServiceImpl.java 3KB
entity
HttpResult.java 310B
util
HttpClientUtil.java 318B
SpringUtil.java 1KB
config
HttpClientConfig.java 4KB
App.java 398B
module
baiyun
resource
baiyun.js 8KB
service
impl
BaiYunServiceImpl.java 27KB
util
BaiYunJsMethods.java 469B
BaiYunJsUtil.java 1008B
remote
service
IReptileService.java 1KB
IReptileEntranceService.java 1KB
entity
Score.java 561B
Attendance.java 496B
StudentInfo.java 347B
Course.java 622B
Constant.java 1012B
CourseTime.java 299B
共 24 条
- 1
资源评论
白话机器学习
- 粉丝: 9163
- 资源: 7681
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功