|
|
@@ -5,14 +5,15 @@ import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.http.HttpRequest;
|
|
|
import cn.hutool.http.HttpResponse;
|
|
|
-import cn.hutool.json.JSONObject;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.exception.user.UserPasswordNotMatchException;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
import com.zhongzheng.common.utils.SecurityUtils;
|
|
|
import com.zhongzheng.common.utils.ServletUtils;
|
|
|
+import com.zhongzheng.common.utils.http.HttpUtils;
|
|
|
import com.zhongzheng.modules.base.bo.ConsoleQueryBo;
|
|
|
import com.zhongzheng.modules.course.bo.CourseBusinessQueryBo;
|
|
|
import com.zhongzheng.modules.course.bo.CourseEducationTypeQueryBo;
|
|
|
@@ -56,6 +57,8 @@ import com.zhongzheng.modules.grade.mapper.ClassGradeMapper;
|
|
|
import com.zhongzheng.modules.grade.service.IClassGradeService;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.net.HttpCookie;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
@@ -524,103 +527,85 @@ public class ClassGradeServiceImpl extends ServiceImpl<ClassGradeMapper, ClassGr
|
|
|
// post 请求 传递json参数
|
|
|
String postLoginRequestUrl = "https://zjzyk.etledu.com/Account/GetLoginInfo";
|
|
|
// 参数
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
- jsonObject.put("userCode", "gdxiangyue");
|
|
|
- jsonObject.put("passWord", bo.getPassword());
|
|
|
- jsonObject.put("typeId", "2");
|
|
|
- jsonObject.put("yzm", bo.getYzm());
|
|
|
- jsonObject.put("phoneNum", "15602322262");
|
|
|
-
|
|
|
- // 设置请求头
|
|
|
- Map<String, String> loginHead = new HashMap<>();
|
|
|
- loginHead.put("Content-Type", "application/json;charset=UTF-8");
|
|
|
- // 纯请求 要结果的话 最后加 .body()
|
|
|
- HttpResponse loginHttpResponse = HttpRequest.post(postLoginRequestUrl) // url
|
|
|
- .headerMap(loginHead, false) // 请求头设置
|
|
|
- .body(jsonObject.toString()) // json参数
|
|
|
- .timeout(5 * 60 * 1000) // 超时
|
|
|
- .execute();
|
|
|
-
|
|
|
- if (loginHttpResponse.body().contains("{\"\"success\"\":true")) {
|
|
|
- HttpCookie cookie = loginHttpResponse.getCookie("jqb_cookies");
|
|
|
+ Map<String, String> paramMap =new HashMap<>();
|
|
|
+ paramMap.put("userCode", "gdxiangyue");
|
|
|
+ paramMap.put("passWord", bo.getPassword());
|
|
|
+ paramMap.put("typeId", "2");
|
|
|
+ paramMap.put("yzm", bo.getYzm());
|
|
|
+ paramMap.put("phoneNum", "15602322262");
|
|
|
+ String loginHttpResponse = "";
|
|
|
+ try {
|
|
|
+ String param = HttpUtils.appendUrl("", paramMap);
|
|
|
+ loginHttpResponse = HttpUtils.sendPost(postLoginRequestUrl, param.substring(1));
|
|
|
+ JSONObject ob = JSONObject.parseObject(loginHttpResponse);
|
|
|
+ }catch (UnsupportedEncodingException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (loginHttpResponse.contains("{\"\"success\"\":true")) {
|
|
|
List<StudyAccountStatusQueryBo> studyAccountStatusList = bo.getStudyAccountStatusQueryBos();
|
|
|
if (Validator.isNotEmpty(studyAccountStatusList)) {
|
|
|
List<Long> ids = new ArrayList<>();
|
|
|
for (StudyAccountStatusQueryBo studyAccountStatusQueryBo : studyAccountStatusList) {
|
|
|
//查询学员url
|
|
|
String getInfoRequestUrl = "https://zjzyk.etledu.com/Student/GetCertInfos";
|
|
|
- JSONObject getJsonObject = new JSONObject();
|
|
|
- getJsonObject.put("personalId", studyAccountStatusQueryBo.getIdCard());
|
|
|
- // 设置请求头
|
|
|
- Map<String, String> getInfoHead = new HashMap<>();
|
|
|
- getInfoHead.put("Content-Type", "application/json;charset=UTF-8");
|
|
|
- getInfoHead.put("Cookie", cookie.toString());
|
|
|
- // 纯请求 要结果的话 最后加 .body()
|
|
|
- HttpResponse getInfoHttpResponse = HttpRequest.post(getInfoRequestUrl) // url
|
|
|
- .headerMap(getInfoHead, false) // 请求头设置
|
|
|
- .body(getJsonObject.toString()) // json参数
|
|
|
- .timeout(5 * 60 * 1000) // 超时
|
|
|
- .execute();
|
|
|
- if (getInfoHttpResponse.body().contains("{\"\"success\"\":true")) {
|
|
|
- PersonRoot personRoot = com.alibaba.fastjson.JSONObject.parseObject(getInfoHttpResponse.toString(), PersonRoot.class);
|
|
|
+ paramMap.clear();
|
|
|
+ paramMap.put("personalId", studyAccountStatusQueryBo.getIdCard());
|
|
|
+ String getInfoHttpResponse = "";
|
|
|
+ try {
|
|
|
+ getInfoHttpResponse = HttpUtils.postFormBody(getInfoRequestUrl, paramMap);
|
|
|
+ }catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if (getInfoHttpResponse.contains("{\"\"success\"\":true")) {
|
|
|
+ PersonRoot personRoot = com.alibaba.fastjson.JSONObject.parseObject(getInfoHttpResponse, PersonRoot.class);
|
|
|
CertInfoListItem certInfoListItem = personRoot.getCertInfoList().get(0);
|
|
|
TrainInfosItem trainInfosItem = certInfoListItem.getTrainInfos().get(0);
|
|
|
- cookie = getInfoHttpResponse.getCookie("jqb_cookies");
|
|
|
//查询继教产品url
|
|
|
+ paramMap.clear();
|
|
|
String getProductUrl = "https://zjzyk.etledu.com/Student/GetProducts";
|
|
|
- JSONObject getProductObject = new JSONObject();
|
|
|
- getProductObject.put("workTypeCode", certInfoListItem.getWorkTypeCode());
|
|
|
- getProductObject.put("period", "0");
|
|
|
- getProductObject.put("trainYear", bo.getTrainYear());
|
|
|
- // 设置请求头
|
|
|
- Map<String, String> getProductHead = new HashMap<>();
|
|
|
- getProductHead.put("Content-Type", "application/json;charset=UTF-8");
|
|
|
- getProductHead.put("Cookie", cookie.toString());
|
|
|
- // 纯请求 要结果的话 最后加 .body()
|
|
|
- HttpResponse getProductHttpResponse = HttpRequest.post(getProductUrl) // url
|
|
|
- .headerMap(getProductHead, false) // 请求头设置
|
|
|
- .body(getJsonObject.toString()) // json参数
|
|
|
- .timeout(5 * 60 * 1000) // 超时
|
|
|
- .execute();
|
|
|
- if (getProductHttpResponse.body().contains("{\"\"success\"\":true")) {
|
|
|
- ProductRoot productRoot = com.alibaba.fastjson.JSONObject.parseObject(getProductHttpResponse.toString(), ProductRoot.class);
|
|
|
+ paramMap.put("workTypeCode", certInfoListItem.getWorkTypeCode());
|
|
|
+ paramMap.put("period", "0");
|
|
|
+ paramMap.put("trainYear", bo.getTrainYear());
|
|
|
+ String getProductHttpResponse = "";
|
|
|
+ try {
|
|
|
+ getProductHttpResponse = HttpUtils.postFormBody(getProductUrl, paramMap);
|
|
|
+ }catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if (getProductHttpResponse.contains("{\"\"success\"\":true")) {
|
|
|
+ ProductRoot productRoot = com.alibaba.fastjson.JSONObject.parseObject(getProductHttpResponse, ProductRoot.class);
|
|
|
if (Validator.isEmpty(productRoot)) {
|
|
|
throw new CustomException("未获取到相关继教商品信息");
|
|
|
}
|
|
|
ProductsItem productsItem = productRoot.getProducts().get(0);
|
|
|
- cookie = getProductHttpResponse.getCookie("jqb_cookies");
|
|
|
//学员开通url
|
|
|
String postOpenRequestUrl = "https://zjzyk.etledu.com/Student/SubmitProject";
|
|
|
- JSONObject sumitJsonObject = new JSONObject();
|
|
|
- sumitJsonObject.put("CertNumber", studyAccountStatusQueryBo.getIdCard());
|
|
|
- sumitJsonObject.put("CertState", certInfoListItem.getCertState());
|
|
|
- sumitJsonObject.put("CertTime", certInfoListItem.getCertTime());
|
|
|
- sumitJsonObject.put("Name", studyAccountStatusQueryBo.getRealname());
|
|
|
- sumitJsonObject.put("phoneNum", studyAccountStatusQueryBo.getTelphone());
|
|
|
- sumitJsonObject.put("PersonalId", certInfoListItem.getPersonalId());
|
|
|
- sumitJsonObject.put("ProvinceCode", certInfoListItem.getProvinceCode());
|
|
|
- sumitJsonObject.put("ProvinceName", certInfoListItem.getProvinceName());
|
|
|
- sumitJsonObject.put("WorkTypeCode", certInfoListItem.getWorkTypeCode());
|
|
|
- sumitJsonObject.put("WorkTypeName", certInfoListItem.getWorkTypeName());
|
|
|
- sumitJsonObject.put("productId", productsItem.getId());
|
|
|
- sumitJsonObject.put("trainPeriodDate", trainInfosItem.getTrainPeriodTime());
|
|
|
- sumitJsonObject.put("period", 0);
|
|
|
- sumitJsonObject.put("IsBuyBook", 1);
|
|
|
- sumitJsonObject.put("GetMethod", 1);
|
|
|
- // 设置请求头
|
|
|
- Map<String, String> sumitHead = new HashMap<>();
|
|
|
- sumitHead.put("Content-Type", "application/json;charset=UTF-8");
|
|
|
- sumitHead.put("Cookie", cookie.toString());
|
|
|
- // 纯请求 要结果的话 最后加 .body()
|
|
|
- HttpResponse sumitHttpResponse = HttpRequest.post(postOpenRequestUrl) // url
|
|
|
- .headerMap(sumitHead, false) // 请求头设置
|
|
|
- .body(sumitJsonObject.toString()) // json参数
|
|
|
- .timeout(5 * 60 * 1000) // 超时
|
|
|
- .execute();
|
|
|
- //.body(); // 请求
|
|
|
+ paramMap.clear();
|
|
|
+ paramMap.put("CertNumber", studyAccountStatusQueryBo.getIdCard());
|
|
|
+ paramMap.put("CertState", certInfoListItem.getCertState().toString());
|
|
|
+ paramMap.put("CertTime", certInfoListItem.getCertTime());
|
|
|
+ paramMap.put("Name", studyAccountStatusQueryBo.getRealname());
|
|
|
+ paramMap.put("phoneNum", studyAccountStatusQueryBo.getTelphone());
|
|
|
+ paramMap.put("PersonalId", certInfoListItem.getPersonalId());
|
|
|
+ paramMap.put("ProvinceCode", certInfoListItem.getProvinceCode());
|
|
|
+ paramMap.put("ProvinceName", certInfoListItem.getProvinceName());
|
|
|
+ paramMap.put("WorkTypeCode", certInfoListItem.getWorkTypeCode());
|
|
|
+ paramMap.put("WorkTypeName", certInfoListItem.getWorkTypeName());
|
|
|
+ paramMap.put("productId", productsItem.getId().toString());
|
|
|
+ paramMap.put("trainPeriodDate", trainInfosItem.getTrainPeriodTime());
|
|
|
+ paramMap.put("period", "0");
|
|
|
+ paramMap.put("IsBuyBook", "1");
|
|
|
+ paramMap.put("GetMethod", "1");
|
|
|
+ String sumitHttpResponse = "";
|
|
|
+ try {
|
|
|
+ sumitHttpResponse = HttpUtils.postFormBody(getProductUrl, paramMap);
|
|
|
+ }catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
com.alibaba.fastjson.JSONObject.parseObject(sumitHttpResponse.toString(), ClassGradeUserQueryBo.class);
|
|
|
//开通成功同步修改本地库learnStatus状态
|
|
|
- if (sumitHttpResponse.body().contains("{\"\"success\"\":true")) {
|
|
|
+ if (sumitHttpResponse.contains("{\"\"success\"\":true")) {
|
|
|
ids.add(studyAccountStatusQueryBo.getId());
|
|
|
} else {
|
|
|
falseCount++;
|