|
@@ -3,22 +3,20 @@ package cn.com.qmth.dp.examcloud.oe.modules.update_correct_answer;
|
|
|
import cn.com.qmth.dp.examcloud.oe.modules.update_correct_answer.entity.*;
|
|
|
import cn.com.qmth.dp.examcloud.oe.modules.update_correct_answer.util.OKHttpUtil;
|
|
|
import cn.com.qmth.dp.examcloud.oe.modules.update_correct_answer.util.QmthUtil;
|
|
|
+import cn.com.qmth.dp.examcloud.oe.util.PropertiesUtil;
|
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.commons.util.HttpMethod;
|
|
|
import cn.com.qmth.examcloud.commons.util.JsonUtil;
|
|
|
-import cn.com.qmth.dp.examcloud.oe.util.PropertiesUtil;
|
|
|
import com.mongodb.client.result.UpdateResult;
|
|
|
import com.mysql.cj.util.StringUtils;
|
|
|
import okhttp3.Response;
|
|
|
import org.apache.commons.io.IOUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.core.io.ClassPathResource;
|
|
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
import org.springframework.data.mongodb.core.query.Criteria;
|
|
|
import org.springframework.data.mongodb.core.query.Query;
|
|
|
import org.springframework.data.mongodb.core.query.Update;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
-import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.*;
|
|
@@ -43,9 +41,9 @@ public class FixCorrectAnswerAndResetScoreService {
|
|
|
|
|
|
// @Async
|
|
|
public void start() {
|
|
|
- String absolutePath= PropertiesUtil.getString("fixAnswer.data.path");
|
|
|
-// ClassPathResource classPathResource = new ClassPathResource("temp1.txt");
|
|
|
- FileInputStream fis=null;
|
|
|
+ String absolutePath = PropertiesUtil.getString("fixAnswer.data.path");
|
|
|
+ // ClassPathResource classPathResource = new ClassPathResource("temp1.txt");
|
|
|
+ FileInputStream fis = null;
|
|
|
InputStreamReader isr = null;
|
|
|
BufferedReader br = null;
|
|
|
|
|
@@ -58,7 +56,7 @@ public class FixCorrectAnswerAndResetScoreService {
|
|
|
Long examId = Long.valueOf(strExamIdAndCourseCode.split(",")[0]);
|
|
|
String courseCode = strExamIdAndCourseCode.split(",")[1];
|
|
|
System.out.println(String.format("examId:%s,courseCode:%s", examId, courseCode));
|
|
|
- run(examId,courseCode);
|
|
|
+ run(examId, courseCode);
|
|
|
Thread.sleep(10);
|
|
|
//19,"03013750"
|
|
|
}
|
|
@@ -103,13 +101,15 @@ public class FixCorrectAnswerAndResetScoreService {
|
|
|
throw new StatusException("100001", "找不到对应的考试记录");
|
|
|
}
|
|
|
|
|
|
+ System.out.println(String.format("total size is %s, start...", examRecordDataList.size()));
|
|
|
+
|
|
|
//首先更新mongo中的作答记录
|
|
|
modifyMongoQuestionAnswer(examRecordDataList);
|
|
|
|
|
|
//重新计算分数并保存
|
|
|
modifyDbScore(examRecordDataList);
|
|
|
|
|
|
- System.out.println("999.all is over.....");
|
|
|
+ System.out.println("finished...");
|
|
|
}
|
|
|
|
|
|
private void modifyDbScore(List<ExamRecordDataEntity> examRecordDataList) {
|
|
@@ -239,7 +239,7 @@ public class FixCorrectAnswerAndResetScoreService {
|
|
|
for (int i = 0; i < questionUnitList.size(); i++) {
|
|
|
String rightAnswer = rightAnswerList.get(i);
|
|
|
ExamQuestionEntity curQues = questionUnitList.get(i);
|
|
|
- String curCorrectAnswer =curQues.getCorrectAnswer();
|
|
|
+ String curCorrectAnswer = curQues.getCorrectAnswer();
|
|
|
|
|
|
//只有无答案,或者有答案,答案不一致的才更新
|
|
|
if (StringUtils.isNullOrEmpty(curCorrectAnswer)
|
|
@@ -283,16 +283,16 @@ public class FixCorrectAnswerAndResetScoreService {
|
|
|
* @return
|
|
|
*/
|
|
|
private List<String> getRightAnswerList(String quesId) {
|
|
|
-// if (1 == 1) {
|
|
|
-// List<String> list = new ArrayList<>();
|
|
|
-// list.add("2");
|
|
|
-// list.add("2");
|
|
|
-// list.add("2");
|
|
|
-// list.add("2");
|
|
|
-// list.add("2");
|
|
|
-// list.add("2");
|
|
|
-// return list;
|
|
|
-// }
|
|
|
+ // if (1 == 1) {
|
|
|
+ // List<String> list = new ArrayList<>();
|
|
|
+ // list.add("2");
|
|
|
+ // list.add("2");
|
|
|
+ // list.add("2");
|
|
|
+ // list.add("2");
|
|
|
+ // list.add("2");
|
|
|
+ // list.add("2");
|
|
|
+ // return list;
|
|
|
+ // }
|
|
|
|
|
|
OuterGetQuestionAnswerReq reqBody = new OuterGetQuestionAnswerReq();
|
|
|
reqBody.setQuestionId(quesId);
|