|
@@ -2,10 +2,10 @@ package cn.com.qmth.examcloud.core.oe.admin.service.impl.pushscore.cup;
|
|
|
|
|
|
import cn.com.qmth.examcloud.commons.util.JsonUtil;
|
|
import cn.com.qmth.examcloud.commons.util.JsonUtil;
|
|
import cn.com.qmth.examcloud.core.basic.api.bean.CourseBean;
|
|
import cn.com.qmth.examcloud.core.basic.api.bean.CourseBean;
|
|
-import cn.com.qmth.examcloud.core.oe.admin.service.ExamCacheTransferHelper;
|
|
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.ExamScorePushService;
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.ExamScorePushService;
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.ExamScoreQueueService;
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.ExamScoreQueueService;
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.impl.pushscore.bean.ExamScorePushInfo;
|
|
import cn.com.qmth.examcloud.core.oe.admin.service.impl.pushscore.bean.ExamScorePushInfo;
|
|
|
|
+import cn.com.qmth.examcloud.core.oe.common.base.helper.ExamCacheTransferHelper;
|
|
import cn.com.qmth.examcloud.core.oe.common.entity.ExamRecordDataEntity;
|
|
import cn.com.qmth.examcloud.core.oe.common.entity.ExamRecordDataEntity;
|
|
import cn.com.qmth.examcloud.core.oe.common.entity.ExamScoreEntity;
|
|
import cn.com.qmth.examcloud.core.oe.common.entity.ExamScoreEntity;
|
|
import cn.com.qmth.examcloud.core.oe.common.entity.ExamScorePushQueue;
|
|
import cn.com.qmth.examcloud.core.oe.common.entity.ExamScorePushQueue;
|
|
@@ -38,61 +38,57 @@ import java.io.InputStreamReader;
|
|
import java.net.URI;
|
|
import java.net.URI;
|
|
|
|
|
|
/**
|
|
/**
|
|
- *
|
|
|
|
- * @author chenken
|
|
|
|
- * @date 2018年10月18日 下午4:09:26
|
|
|
|
- * @company QMTH
|
|
|
|
|
|
+ * @author chenken
|
|
|
|
+ * @date 2018年10月18日 下午4:09:26
|
|
|
|
+ * @company QMTH
|
|
* @description 石油大学 orgCode:cup.ecs.qmth.com.cn
|
|
* @description 石油大学 orgCode:cup.ecs.qmth.com.cn
|
|
*/
|
|
*/
|
|
@Service("cupExamScorePushServiceImpl")
|
|
@Service("cupExamScorePushServiceImpl")
|
|
-public class CupExamScorePushServiceImpl implements ExamScorePushService{
|
|
|
|
-
|
|
|
|
- private static final Logger log = LoggerFactory.getLogger(CupExamScorePushServiceImpl.class);
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private ExamScoreRepo examScoreRepo;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private ExamRecordDataRepo examRecordDataRepo;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private ExamStudentRepo examStudentRepo;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private ExamScorePushQueueRepo examScorePushQueueRepo;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private ExamScoreQueueService examScoreQueueService;
|
|
|
|
-
|
|
|
|
|
|
+public class CupExamScorePushServiceImpl implements ExamScorePushService {
|
|
|
|
+
|
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(CupExamScorePushServiceImpl.class);
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ExamScoreRepo examScoreRepo;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ExamRecordDataRepo examRecordDataRepo;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ExamStudentRepo examStudentRepo;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ExamScorePushQueueRepo examScorePushQueueRepo;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
- private GainBaseDataService gainBaseDataService;
|
|
|
|
-
|
|
|
|
|
|
+ private ExamScoreQueueService examScoreQueueService;
|
|
|
|
+
|
|
private String pushUrlSchema = "http";
|
|
private String pushUrlSchema = "http";
|
|
|
|
|
|
private String pushUrlHost = "www.cupde.cn";
|
|
private String pushUrlHost = "www.cupde.cn";
|
|
|
|
|
|
private String pushUrlPort = "80";
|
|
private String pushUrlPort = "80";
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void scorePush(ExamScorePushQueue examScorePushQueue) {
|
|
|
|
- log.info("开始推送石油大学成绩:"+examScorePushQueue.getId());
|
|
|
|
- Long scoreId = examScorePushQueue.getExamScoreId();
|
|
|
|
- ExamScoreEntity examScore = GlobalHelper.getEntity(examScoreRepo,scoreId,ExamScoreEntity.class);
|
|
|
|
- ExamRecordDataEntity examRecordData = GlobalHelper.getEntity(examRecordDataRepo,examScore.getExamRecordDataId(),ExamRecordDataEntity.class);
|
|
|
|
-
|
|
|
|
- ExamStudentEntity examStudent = examStudentRepo.findByExamStudentId(examRecordData.getExamStudentId());
|
|
|
|
- if(examScore == null || examRecordData == null || examStudent == null){
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- ExamScorePushInfo examScorePushInfo = buildexamScorePushInfo(examScore,examRecordData,examStudent);
|
|
|
|
- String courseCode = examScorePushInfo.getCourseCode();
|
|
|
|
- //将Z000001变成000001
|
|
|
|
- if(courseCode.startsWith("Z")||courseCode.startsWith("Q")||courseCode.startsWith("S")){
|
|
|
|
- examScorePushInfo.setCourseCode(courseCode.substring(1, courseCode.length()));
|
|
|
|
- }else{
|
|
|
|
- examScorePushInfo.setCourseCode(courseCode);
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void scorePush(ExamScorePushQueue examScorePushQueue) {
|
|
|
|
+ log.info("开始推送石油大学成绩:" + examScorePushQueue.getId());
|
|
|
|
+ Long scoreId = examScorePushQueue.getExamScoreId();
|
|
|
|
+ ExamScoreEntity examScore = GlobalHelper.getEntity(examScoreRepo, scoreId, ExamScoreEntity.class);
|
|
|
|
+ ExamRecordDataEntity examRecordData = GlobalHelper.getEntity(examRecordDataRepo, examScore.getExamRecordDataId(), ExamRecordDataEntity.class);
|
|
|
|
+
|
|
|
|
+ ExamStudentEntity examStudent = examStudentRepo.findByExamStudentId(examRecordData.getExamStudentId());
|
|
|
|
+ if (examScore == null || examRecordData == null || examStudent == null) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ExamScorePushInfo examScorePushInfo = buildexamScorePushInfo(examScore, examRecordData, examStudent);
|
|
|
|
+ String courseCode = examScorePushInfo.getCourseCode();
|
|
|
|
+ //将Z000001变成000001
|
|
|
|
+ if (courseCode.startsWith("Z") || courseCode.startsWith("Q") || courseCode.startsWith("S")) {
|
|
|
|
+ examScorePushInfo.setCourseCode(courseCode.substring(1, courseCode.length()));
|
|
|
|
+ } else {
|
|
|
|
+ examScorePushInfo.setCourseCode(courseCode);
|
|
|
|
+ }
|
|
CloseableHttpResponse httpResponse = null;
|
|
CloseableHttpResponse httpResponse = null;
|
|
CloseableHttpClient httpClient = null;
|
|
CloseableHttpClient httpClient = null;
|
|
try {
|
|
try {
|
|
@@ -114,8 +110,8 @@ public class CupExamScorePushServiceImpl implements ExamScorePushService{
|
|
.setPath("/entity/learning/interface/stuHomeworkScore_syncFinalExamScore.action")
|
|
.setPath("/entity/learning/interface/stuHomeworkScore_syncFinalExamScore.action")
|
|
.setParameter("loginId", "bjsy")
|
|
.setParameter("loginId", "bjsy")
|
|
.setParameter("password", "1111")
|
|
.setParameter("password", "1111")
|
|
- .setParameter("examRemark",examScorePushInfo.getExamName())
|
|
|
|
- .setParameter("examStuRemark","recruit")
|
|
|
|
|
|
+ .setParameter("examRemark", examScorePushInfo.getExamName())
|
|
|
|
+ .setParameter("examStuRemark", "recruit")
|
|
.setParameter("scoreJsonStr", scoreStr)//通过查询参数的方式传递
|
|
.setParameter("scoreJsonStr", scoreStr)//通过查询参数的方式传递
|
|
.build();
|
|
.build();
|
|
HttpPost httpPost = new HttpPost(uri);
|
|
HttpPost httpPost = new HttpPost(uri);
|
|
@@ -123,25 +119,25 @@ public class CupExamScorePushServiceImpl implements ExamScorePushService{
|
|
HttpEntity responseEntity = httpResponse.getEntity();
|
|
HttpEntity responseEntity = httpResponse.getEntity();
|
|
String result = "";
|
|
String result = "";
|
|
int statusCode = httpResponse.getStatusLine().getStatusCode();
|
|
int statusCode = httpResponse.getStatusLine().getStatusCode();
|
|
- if(statusCode == 200){
|
|
|
|
|
|
+ if (statusCode == 200) {
|
|
BufferedReader reader = new BufferedReader(new InputStreamReader(responseEntity.getContent()));
|
|
BufferedReader reader = new BufferedReader(new InputStreamReader(responseEntity.getContent()));
|
|
StringBuffer buffer = new StringBuffer();
|
|
StringBuffer buffer = new StringBuffer();
|
|
String str = "";
|
|
String str = "";
|
|
- while(StringUtils.isNoneBlank((str = reader.readLine()))) {
|
|
|
|
|
|
+ while (StringUtils.isNoneBlank((str = reader.readLine()))) {
|
|
buffer.append(str);
|
|
buffer.append(str);
|
|
}
|
|
}
|
|
result = buffer.toString();
|
|
result = buffer.toString();
|
|
}
|
|
}
|
|
- log.info("推送石油大学成绩:"+examScorePushQueue.getId()+"结果:"+result);
|
|
|
|
- JSONObject jsonObject = new JSONObject(result);
|
|
|
|
- //推送成功
|
|
|
|
- if(jsonObject.has("success")&&"true".equals(jsonObject.getString("success"))){
|
|
|
|
- examScoreQueueService.saveExamScorePushQueue(result, examScorePushQueue, ExamScoreQueueStatus.PROCESS_SUCCESS);
|
|
|
|
- }else{
|
|
|
|
- examScoreQueueService.saveExamScorePushQueue(result, examScorePushQueue, ExamScoreQueueStatus.PROCESS_FAILED);
|
|
|
|
- }
|
|
|
|
|
|
+ log.info("推送石油大学成绩:" + examScorePushQueue.getId() + "结果:" + result);
|
|
|
|
+ JSONObject jsonObject = new JSONObject(result);
|
|
|
|
+ //推送成功
|
|
|
|
+ if (jsonObject.has("success") && "true".equals(jsonObject.getString("success"))) {
|
|
|
|
+ examScoreQueueService.saveExamScorePushQueue(result, examScorePushQueue, ExamScoreQueueStatus.PROCESS_SUCCESS);
|
|
|
|
+ } else {
|
|
|
|
+ examScoreQueueService.saveExamScorePushQueue(result, examScorePushQueue, ExamScoreQueueStatus.PROCESS_FAILED);
|
|
|
|
+ }
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- log.error(examScorePushQueue.getId() + "成绩推送失败", e);
|
|
|
|
|
|
+ log.error(examScorePushQueue.getId() + "成绩推送失败", e);
|
|
examScoreQueueService.saveExamScorePushQueue(e.getMessage(), examScorePushQueue, ExamScoreQueueStatus.PROCESS_FAILED);
|
|
examScoreQueueService.saveExamScorePushQueue(e.getMessage(), examScorePushQueue, ExamScoreQueueStatus.PROCESS_FAILED);
|
|
} finally {
|
|
} finally {
|
|
if (httpResponse != null) {
|
|
if (httpResponse != null) {
|
|
@@ -162,33 +158,35 @@ public class CupExamScorePushServiceImpl implements ExamScorePushService{
|
|
httpClient = null;
|
|
httpClient = null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private ExamScorePushInfo buildexamScorePushInfo(ExamScoreEntity examScore,ExamRecordDataEntity examRecordDataEntity,ExamStudentEntity examStudentEntity){
|
|
|
|
- ExamScorePushInfo examScorePushInfo = new ExamScorePushInfo();
|
|
|
|
- examScorePushInfo.setExamId(examStudentEntity.getExamId());
|
|
|
|
- ExamBean examBean = ExamCacheTransferHelper.getCachedExam(examStudentEntity.getExamId(),
|
|
|
|
- examStudentEntity.getOrgId());
|
|
|
|
-
|
|
|
|
- examScorePushInfo.setExamName(examBean.getName());
|
|
|
|
- examScorePushInfo.setStudentName(examStudentEntity.getStudentName());
|
|
|
|
- examScorePushInfo.setStudentCode(examStudentEntity.getStudentCode());
|
|
|
|
- examScorePushInfo.setIdentityNumber(examStudentEntity.getIdentityNumber());
|
|
|
|
-
|
|
|
|
- CourseBean courseBean = ExamCacheTransferHelper.getCachedCourse(examStudentEntity.getCourseId());
|
|
|
|
-
|
|
|
|
- examScorePushInfo.setCourseName(courseBean.getName());
|
|
|
|
- examScorePushInfo.setCourseCode(examStudentEntity.getCourseCode());
|
|
|
|
- examScorePushInfo.setStartTime(examRecordDataEntity.getStartTime());
|
|
|
|
- examScorePushInfo.setEndTime(examRecordDataEntity.getEndTime());
|
|
|
|
- examScorePushInfo.setSuccPercent(examRecordDataEntity.getFaceSuccessPercent());
|
|
|
|
- examScorePushInfo.setIsIllegality(examRecordDataEntity.getIsIllegality());
|
|
|
|
- examScorePushInfo.setScoreId(examScore.getId());
|
|
|
|
- examScorePushInfo.setTotalScore(examScore.getTotalScore());
|
|
|
|
- examScorePushInfo.setObjectiveScore(examScore.getObjectiveScore());
|
|
|
|
- examScorePushInfo.setSubjectiveScore(examScore.getSubjectiveScore());
|
|
|
|
- return examScorePushInfo;
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private ExamScorePushInfo buildexamScorePushInfo(ExamScoreEntity examScore,
|
|
|
|
+ ExamRecordDataEntity examRecordDataEntity,
|
|
|
|
+ ExamStudentEntity examStudentEntity) {
|
|
|
|
+ ExamScorePushInfo examScorePushInfo = new ExamScorePushInfo();
|
|
|
|
+ examScorePushInfo.setExamId(examStudentEntity.getExamId());
|
|
|
|
+ ExamBean examBean = ExamCacheTransferHelper.getCachedExam(examStudentEntity.getExamId(),
|
|
|
|
+ examStudentEntity.getOrgId(),examStudentEntity.getStudentId());
|
|
|
|
+
|
|
|
|
+ examScorePushInfo.setExamName(examBean.getName());
|
|
|
|
+ examScorePushInfo.setStudentName(examStudentEntity.getStudentName());
|
|
|
|
+ examScorePushInfo.setStudentCode(examStudentEntity.getStudentCode());
|
|
|
|
+ examScorePushInfo.setIdentityNumber(examStudentEntity.getIdentityNumber());
|
|
|
|
+
|
|
|
|
+ CourseBean courseBean = ExamCacheTransferHelper.getCachedCourse(examStudentEntity.getCourseId());
|
|
|
|
+
|
|
|
|
+ examScorePushInfo.setCourseName(courseBean.getName());
|
|
|
|
+ examScorePushInfo.setCourseCode(examStudentEntity.getCourseCode());
|
|
|
|
+ examScorePushInfo.setStartTime(examRecordDataEntity.getStartTime());
|
|
|
|
+ examScorePushInfo.setEndTime(examRecordDataEntity.getEndTime());
|
|
|
|
+ examScorePushInfo.setSuccPercent(examRecordDataEntity.getFaceSuccessPercent());
|
|
|
|
+ examScorePushInfo.setIsIllegality(examRecordDataEntity.getIsIllegality());
|
|
|
|
+ examScorePushInfo.setScoreId(examScore.getId());
|
|
|
|
+ examScorePushInfo.setTotalScore(examScore.getTotalScore());
|
|
|
|
+ examScorePushInfo.setObjectiveScore(examScore.getObjectiveScore());
|
|
|
|
+ examScorePushInfo.setSubjectiveScore(examScore.getSubjectiveScore());
|
|
|
|
+ return examScorePushInfo;
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|