فهرست منبع

修复一些问题

ting.yin 4 سال پیش
والد
کامیت
a7790925df

+ 30 - 6
stmms-web/src/main/java/cn/com/qmth/stmms/admin/thread/DataSyncThread.java

@@ -75,6 +75,8 @@ public class DataSyncThread implements Runnable {
 
     public static final String SIZE = "size";
 
+    public static final String ERROR_CODE = "EX-101444";
+
     public DataSyncThread(DataSync dataSync, Integer pageSize, LockService lockService,
             DataSyncService dataSyncService, ExamService examService, ExamStudentService studentService,
             ExamSubjectService subjectService, FileService fileService) {
@@ -98,6 +100,16 @@ public class DataSyncThread implements Runnable {
     public void run() {
         log.info("start data sync for examId=" + dataSync.getExamId());
         try {
+            JSONObject datas = new JSONObject();
+            datas.accumulate("examId", dataSync.getCloudExamId());
+            String subjectResult = subjectHttp.httpAction(null, datas.toString());
+            JSONObject subjectJson = JSONObject.fromObject(subjectResult);
+            // 考试返回错误,无法创建阅卷
+            if (ERROR_CODE.equals(subjectJson.getString("code"))) {
+                log.error("data sync exception for cloud examId=" + dataSync.getCloudExamId(),
+                        subjectJson.getString("desc"));
+                return;
+            }
             // 获取考试信息
             Exam exam = examService.findById(dataSync.getExamId());
             dataSync.setSchoolId(exam.getSchoolId());
@@ -107,10 +119,7 @@ public class DataSyncThread implements Runnable {
                 sync.setCreateTime(new Date());
                 dataSyncService.save(sync);
             }
-            JSONObject datas = new JSONObject();
-            datas.accumulate("examId", sync.getCloudExamId());
-            String subjectResult = subjectHttp.httpAction(null, datas.toString());
-            JSONObject subjectJson = JSONObject.fromObject(subjectResult);
+
             JSONArray subjectArray = subjectJson.getJSONArray(PAPER_STRUCT);
             for (int i = 0; i < subjectArray.size(); i++) {
                 JSONObject subject = subjectArray.getJSONObject(i);
@@ -124,12 +133,15 @@ public class DataSyncThread implements Runnable {
                 byte[] paperData = paper.getBytes(StandardCharsets.UTF_8);
                 fileService.uploadPaper(new ByteArrayInputStream(paperData), BinaryUtil.encodeMD5(paperData),
                         exam.getId(), subjectCode, FormatType.JSON);
-                // 获取考生
-                Long startId = 0L;
+
                 ExamSubject examSubject = subjectService.find(exam.getId(), subjectCode);
                 if (examSubject != null && !subjectCode.equals(sync.getSubjectCode())) {
                     continue;
                 }
+                // 创建科目
+                this.saveSubject(exam.getId(), subjectCode, subjectName);
+                // 获取考生
+                Long startId = 0L;
                 if (null != sync.getNextId()) {
                     startId = sync.getNextId();
                 }
@@ -221,4 +233,16 @@ public class DataSyncThread implements Runnable {
         }
     }
 
+    private void saveSubject(Integer examId, String subjectCode, String subjectName) {
+        ExamSubject subject = new ExamSubject();
+        subject.setExamId(examId);
+        subject.setCode(subjectCode);
+        subject.setName(subjectName);
+        subject.setPaperFileType(FormatType.JSON);
+        subject.setObjectiveScore(0d);
+        subject.setSubjectiveScore(0d);
+        subject.setTotalScore(0d);
+        subject.setUploadCount(0);
+    }
+
 }

+ 15 - 9
stmms-web/src/main/java/cn/com/qmth/stmms/admin/utils/HttpUtil.java

@@ -32,6 +32,8 @@ public class HttpUtil {
 
     public static final String APP_ID = "appId";
 
+    public static final String ERROR_CODE = "EX-101444";
+
     // 请求地址
     protected String uri = null;
 
@@ -107,9 +109,13 @@ public class HttpUtil {
 
             result = getResult(conn);
         } catch (IOException e) {
+            // 操作失败
             // log.error("Http connection error!", e);
             e.printStackTrace();
-            // 操作失败
+            JSONObject message = JSONObject.fromObject(e.getMessage());
+            if (ERROR_CODE.equals(message.getString("code"))) {
+                return e.getMessage();
+            }
             return null;
         } finally {
             try {
@@ -194,18 +200,18 @@ public class HttpUtil {
         // String subjectJson = subjectHttp.httpAction(null, json.toString());
         // System.out.println(subjectJson);
 
-        HttpUtil paperHttp = new HttpUtil(
-                "http://ecs-dev.qmth.com.cn:80/api/exchange/outer/question/getSubjectivePaper", "123456", "11", "0");
-        String paper = paperHttp.httpAction(null, json.toString());
-        System.out.println(paper);
+        // HttpUtil paperHttp = new
+        // HttpUtil("http://192.168.10.39:8007/api/exchange/outer/question/getSubjectivePaper",
+        // "123456", "11", "0");
+        // String paper = paperHttp.httpAction(null, json.toString());
+        // System.out.println(paper);
 
         // long start = System.currentTimeMillis();
         // HttpUtil studentHttp = new HttpUtil(
-        // "http://iepcc-ps.ecs.qmth.com.cn:80/api/exchange/outer/question/getSubjectiveQuestion",
-        // "Fu234234CK!fsd9f0", "EPCC", "16923");
-        // json.accumulate("subjectCode", "B149");
+        // "http://192.168.10.39:8007/api/exchange/outer/question/getSubjectiveQuestion",
+        // "123456", "11", "0");
         // json.accumulate("startId", 0);
-        // json.accumulate("size", 2);
+        // json.accumulate("size", 10);
         // String studentJson = studentHttp.httpAction(null, json.toString());
         // long end = System.currentTimeMillis();
         // System.out.println(end - start + ":" + studentJson);

+ 1 - 1
stmms-web/src/main/java/cn/com/qmth/stmms/admin/utils/SessionExamUtils.java

@@ -44,7 +44,7 @@ public class SessionExamUtils {
     public static void setExamId(HttpServletRequest request, Exam exam) {
         StmmsSession session = RequestUtils.getSession(request);
         session.setParameter(EXAM_ID_KEY, String.valueOf(exam.getId()));
-        session.setParameter(EXAM_NAME_KEY, exam.getName());
+        session.setParameter(EXAM_NAME_KEY, exam.getId() + "-" + exam.getName());
         session.setParameter(FORBIDDEN_INFO_KEY, String.valueOf(exam.isForbiddenInfo()));
     }
 }

+ 12 - 10
stmms-web/src/main/webapp/WEB-INF/application.properties

@@ -1,29 +1,31 @@
-#\u6570\u636E\u5E93\u914D\u7F6E
+#\u6570\u636e\u5e93\u914d\u7f6e
 jdbc.driver=com.mysql.jdbc.Driver
 jdbc.url=jdbc:mysql://localhost:3306/stmms_ft_new?useUnicode=true&characterEncoding=UTF-8
 jdbc.username=root
 jdbc.password=root
 jdbc.maxActive=50
 jdbc.initSize=5
-##\u6587\u4EF6\u5B58\u50A8\u914D\u7F6E
+##\u6587\u4ef6\u5b58\u50a8\u914d\u7f6e
 file.server=http://localhost:9000/stmms-ft/
 file.store=/Users/luoshi/develop/data/stmms-ft
-##\u88C1\u5207\u56FE\u9ED8\u8BA4\u5207\u5272\u89C4\u5219
+##\u88c1\u5207\u56fe\u9ed8\u8ba4\u5207\u5272\u89c4\u5219
 slice.split.config=0,0.55,0.45,0.55
-##\u9ED8\u8BA4\u95EE\u9898\u5377\u7C7B\u578B
-exam.problem.type1=\u7B54\u9519\u4F4D\u7F6E
-exam.problem.type2=\u8BD5\u5377\u6A21\u7CCA
-##\u8BC4\u5377\u76F8\u5173\u5B9A\u65F6\u4EFB\u52A1
+##\u9ed8\u8ba4\u95ee\u9898\u5377\u7c7b\u578b
+exam.problem.type1=\u7b54\u9519\u4f4d\u7f6e
+exam.problem.type2=\u8bd5\u5377\u6a21\u7cca
+#exam.problem.type1=\u767d\u7d19
+#exam.problem.type2=\u4e0d\u6b63\u884c\u70ba\u53ef\u80fd\u6027\u3042\u308a
+##\u8bc4\u5377\u76f8\u5173\u5b9a\u65f6\u4efb\u52a1
 mark.cleanTimeoutMinute=20
 mark.activeExpireMinute=30
 mark.cleanTaskSchedule=0 0/10 6-23 * * ?
 mark.cleanLockSchedule=0 0 3 * * ?
-##\u8BC4\u5377\u5458\u63A7\u5236
+##\u8bc4\u5377\u5458\u63a7\u5236
 marker.showBtnImportAndBtnUpdateImport=false
 marker.forceMode=
-##\u9996\u9875\u53EF\u9009\u7684logo\u6587\u4EF6
+##\u9996\u9875\u53ef\u9009\u7684logo\u6587\u4ef6
 index.logo=
-##\u4E91\u5E73\u53F0\u5BF9\u63A5\u914D\u7F6E
+##\u4e91\u5e73\u53f0\u5bf9\u63a5\u914d\u7f6e
 qmth.examcloud.host=iepcc-ps.ecs.qmth.com.cn
 qmth.examcloud.port=80
 qmth.examcloud.rootOrgId=16923

+ 1 - 1
stmms-web/src/main/webapp/WEB-INF/views/modules/exam/examIndex.jsp

@@ -97,7 +97,7 @@
                         <script type="text/javascript">$('#themeSwitch').hide();</script><![endif]-->
                     </li>
                     <li class="dropdown">
-                        <a class="dropdown-toggle" data-toggle="dropdown" href="#">考试:${examId}-${examName}</a>
+                        <a class="dropdown-toggle" data-toggle="dropdown" href="#">考试:${examName}</a>
                         <ul class="dropdown-menu">
                             <li><a href="#" target="mainFrame" id="exam-select">返回选择考试</a></li>
                         </ul>

+ 1 - 1
stmms-web/src/main/webapp/static/rich-text/js/render.js

@@ -7,7 +7,7 @@ function renderRichText(body) {
             nodes.push(renderRichText(part))
         })
     } else {
-        let sections = Array.isArray(body.sections) ? body.selectNode() : []
+        let sections = Array.isArray(body.sections) ? body.sections : []
         sections.forEach(section => {
             nodes.push(renderSection(section))
         })