Browse Source

课程代码和考试id改为从文件中读取

lideyin 5 years ago
parent
commit
4666bd3f86

+ 9 - 2
src/main/java/cn/com/qmth/dp/examcloud/oe/Task.java

@@ -1,6 +1,6 @@
 package cn.com.qmth.dp.examcloud.oe;
 
-import java.io.File;
+import java.io.*;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -8,8 +8,12 @@ import java.util.Map;
 
 import cn.com.qmth.dp.examcloud.oe.modules.get_student_answer_detail.GetStduentAnswerDetailService;
 import cn.com.qmth.dp.examcloud.oe.modules.update_correct_answer.FixCorrectAnswerAndResetScoreService;
+import cn.com.qmth.examcloud.commons.util.FileUtil;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.ClassPathUtils;
 import org.apache.commons.lang3.RandomUtils;
 import org.bson.Document;
+import org.springframework.core.io.ClassPathResource;
 import org.springframework.data.mongodb.core.MongoTemplate;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.stereotype.Component;
@@ -46,8 +50,10 @@ public class Task {
      */
     public void start() {
         try {
+
+
             FixCorrectAnswerAndResetScoreService bean = SpringContextHolder.getBean(FixCorrectAnswerAndResetScoreService.class);
-            bean.start(19,"03013750");
+            bean.start();
 
 /*//			ExportData bean = SpringContextHolder.getBean(ExportData.class);
             GetStduentAnswerDetailService bean = SpringContextHolder.getBean(GetStduentAnswerDetailService.class);
@@ -101,4 +107,5 @@ public class Task {
             System.out.println(JsonUtil.toPrettyJson(next));
         }
     }
+
 }

+ 50 - 1
src/main/java/cn/com/qmth/dp/examcloud/oe/modules/update_correct_answer/FixCorrectAnswerAndResetScoreService.java

@@ -11,6 +11,7 @@ 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;
@@ -19,6 +20,10 @@ import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 
+import java.io.BufferedInputStream;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
 import java.text.DecimalFormat;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -39,7 +44,51 @@ public class FixCorrectAnswerAndResetScoreService {
     MongoTemplate mongoTemplate;
 
     @Async
-    public void start(long examId, String courseCode) {
+    public void start() {
+        ClassPathResource classPathResource = new ClassPathResource("temp1.txt");
+        InputStreamReader isr = null;
+        BufferedReader br = null;
+
+        try {
+            isr = new InputStreamReader(classPathResource.getInputStream());
+            br = new BufferedReader(isr);
+            String strExamIdAndCourseCode = "";
+            while ((strExamIdAndCourseCode = br.readLine()) != null) {
+                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);
+                Thread.sleep(10);
+                //19,"03013750"
+            }
+
+        } catch (IOException e) {
+            e.printStackTrace();
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        } finally {
+            if (br != null) {
+                try {
+                    br.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+
+            if (isr != null) {
+                try {
+                    isr.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+
+        }
+
+
+    }
+
+    public void run(long examId, String courseCode) {
         List<ExamRecordDataEntity> examRecordDataList = queryExamRecordDataList(examId, courseCode);
 
         if (examRecordDataList.isEmpty()) {

+ 315 - 0
src/main/resources/temp1.txt

@@ -0,0 +1,315 @@
+1225,80000012
+1225,80000006
+1225,80000011
+1225,80000001
+1225,90000003
+1225,80003030
+1225,82721003
+1225,82721002
+1225,82721005
+1225,82722006
+1225,82722008
+1225,82722007
+1225,82721004
+1225,82722005
+1225,81422003
+1225,81422006
+1225,81422005
+1225,82721001
+1225,81921001
+1225,81421002
+1225,81422001
+1225,81921002
+1225,81421004
+1225,81421001
+1225,81422004
+1225,81421005
+1225,81421003
+1225,81422002
+1225,81921003
+1225,81922001
+1225,81922015
+1225,81921004
+1225,81921005
+1225,81922005
+1225,81922002
+1225,81922008
+1225,81922014
+1225,90000004
+1225,82622007
+1225,82622009
+1225,90522003
+1225,91323003
+1225,91322004
+1225,91322001
+1225,82621003
+1225,90522001
+1225,81411001
+1225,82621005
+1225,81412005
+1225,82622001
+1225,81411003
+1225,91323007
+1225,81411004
+1225,91323005
+1225,81411002
+1225,90522005
+1225,82621002
+1225,91322005
+1225,82621006
+1225,82621004
+1225,82621001
+1225,81511002
+1225,81511003
+1225,81511001
+1225,81411005
+1225,80311005
+1225,81412001
+1225,80311002
+1225,91923005
+1225,80311003
+1225,80311001
+1225,80922006
+1225,91922005
+1225,80311004
+1225,80911001
+1225,80912001
+1225,91922002
+1225,80911003
+1225,80911002
+1225,80921002
+1225,81512002
+1225,80921001
+1225,81512004
+1225,81511004
+1225,81511005
+1225,80921003
+1225,91722001
+1225,91722005
+1225,81911003
+1225,81911002
+1225,91722002
+1225,81911004
+1225,81911005
+1225,81912011
+1225,91722004
+1225,90822004
+1225,80811004
+1225,91723002
+1225,81111002
+1225,80211002
+1225,81111003
+1225,90822005
+1225,80811003
+1225,80211003
+1225,80211004
+1225,80212006
+1225,80211001
+1225,80921004
+1225,80911005
+1225,80911004
+1225,91313005
+1225,80811002
+1225,81111001
+1225,80912003
+1225,92223007
+1225,91312005
+1225,90822001
+1225,80811001
+1225,91312002
+1225,82011001
+1225,80921005
+1225,92523009
+1225,91312001
+1225,91312003
+1225,91313002
+1225,91312004
+1225,80811005
+1225,91313003
+1225,80411003
+1225,80812005
+1225,81911001
+1225,81912010
+1225,92223002
+1225,92223006
+1225,81912001
+1225,81912004
+1225,100108
+1225,80411001
+1225,80812009
+1225,80411002
+1225,80412002
+1225,80412006
+1225,80412009
+1225,80412007
+1225,80411004
+1225,300101
+1225,80411005
+1225,81111005
+1225,81111004
+1225,91122005
+1225,90512004
+1225,210301
+1225,92523004
+1225,90512001
+1225,81912016
+1225,80212003
+1225,80211006
+1225,80212007
+1225,92223008
+1225,80211005
+1225,91713007
+1225,81711001
+1225,92222006
+1225,82012002
+1225,90512002
+1225,91213005
+1225,90412005
+1225,81711002
+1225,81811001
+1225,81811003
+1225,81611001
+1225,81711004
+1225,81112008
+1225,90412004
+1225,81711003
+1225,90422005
+1225,90412001
+1225,92222007
+1225,91712002
+1225,91212004
+1225,91212005
+1225,90412003
+1225,82011003
+1225,82011002
+1225,91712003
+1225,92222003
+1225,90422004
+1225,91212003
+1225,91712001
+1225,91212001
+1225,81811006
+1225,90813009
+1225,90422003
+1225,81811005
+1225,81712007
+1225,92522003
+1225,81712006
+1225,81712001
+1225,90122006
+1225,82011005
+1225,82011004
+1225,92222005
+1225,90213006
+1225,81711005
+1225,90122004
+1225,81811004
+1225,90213004
+1225,81712002
+1225,90212005
+1225,90212001
+1225,90122005
+1225,90312006
+1225,80611004
+1225,81712005
+1225,81711006
+1225,90122001
+1225,81712004
+1225,90222003
+1225,80611001
+1225,90212004
+1225,90222005
+1225,80611005
+1225,91412005
+1225,90812004
+1225,91412004
+1225,90812002
+1225,80612001
+1225,90812003
+1225,90112002
+1225,90312003
+1225,90312005
+1225,90223004
+1225,90812005
+1225,91413001
+1225,80612003
+1225,92922004
+1225,90312004
+1225,90313002
+1225,90222002
+1225,80611003
+1225,90112004
+1225,90122009
+1225,80611002
+1225,82012003
+1225,90222001
+1225,90313001
+1225,90112003
+1225,90112005
+1225,92922001
+1225,91412002
+1225,92213003
+1225,90122008
+1225,92213005
+1225,90112006
+1225,90122007
+1225,90112001
+1225,92212002
+1225,92213006
+1225,92212005
+1225,92922005
+1225,82411001
+1225,90112007
+1225,80711002
+1225,91413006
+1225,80612006
+1225,82411002
+1225,80111001
+1225,82411003
+1225,91022006
+1225,82412001
+1225,80711001
+1225,82412005
+1225,81612002
+1225,80711003
+1225,82211005
+1225,81611005
+1225,90912007
+1225,81612004
+1225,81611004
+1225,90912006
+1225,92922002
+1225,80712009
+1225,91623003
+1225,80111004
+1225,80111005
+1225,80712003
+1225,82411005
+1225,80111002
+1225,80111003
+1225,80711005
+1225,81611003
+1225,82411004
+1225,80111006
+1225,81611002
+1225,80711004
+1225,91622005
+1225,82412003
+1225,82412002
+1225,80712002
+1225,91112002
+1225,91112005
+1225,80512001
+1225,91112003
+1225,90912009
+1225,80511004
+1225,80511005
+1225,82211001
+1225,82211002
+1225,82412008
+1225,82412007
+1225,91112001
+1225,82311004
+1225,82311005
+1225,82311002
+1225,82312008