Browse Source

Merge branch 'dev_200331_openapi' of http://git.qmth.com.cn/luoshi/stmms-ft into dev_200331_openapi

luoshi 4 years ago
parent
commit
ff787de6da

+ 1 - 1
stmms-biz/src/main/java/cn/com/qmth/stmms/biz/exam/dao/ExamDao.java

@@ -38,7 +38,7 @@ public interface ExamDao extends PagingAndSortingRepository<Exam, Integer>, JpaS
 
     public Exam findFirstBySchoolIdAndCode(Integer schoolId, String code);
 
-    @Query(value = "select * from eb_exam e where e.id in (select m.exam_id from eb_marker m where m.user_id=?1) and e.create_time >?2 "
+    @Query(value = "select * from eb_exam e where e.id in (select DISTINCT m.exam_id from eb_marker m where m.user_id=?1) and e.create_time >?2 "
             + "order by e.id", nativeQuery = true)
     public List<Exam> findByMarkerUserId(Integer userId, Date time);
 

+ 2 - 0
stmms-web/src/main/java/cn/com/qmth/stmms/admin/thread/DataSyncThread.java

@@ -239,10 +239,12 @@ public class DataSyncThread implements Runnable {
         subject.setCode(subjectCode);
         subject.setName(subjectName);
         subject.setPaperFileType(FormatType.JSON);
+        subject.setAnswerFileType(FormatType.JSON);
         subject.setObjectiveScore(0d);
         subject.setSubjectiveScore(0d);
         subject.setTotalScore(0d);
         subject.setUploadCount(0);
+        subjectService.save(subject);
     }
 
 }

+ 30 - 11
stmms-web/src/main/java/cn/com/qmth/stmms/admin/utils/HttpUtil.java

@@ -1,12 +1,17 @@
 package cn.com.qmth.stmms.admin.utils;
 
 import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.net.HttpURLConnection;
 import java.net.URL;
+import java.nio.charset.StandardCharsets;
 import java.security.cert.CertificateException;
 import java.security.cert.X509Certificate;
 import java.util.Map;
@@ -19,6 +24,8 @@ import javax.net.ssl.X509TrustManager;
 
 import net.sf.json.JSONObject;
 
+import org.apache.commons.io.IOUtils;
+
 public class HttpUtil {
 
     // private static Logger log = LoggerFactory.getLogger(HttpUtil.class);
@@ -139,6 +146,9 @@ public class HttpUtil {
             }
 
             result = getResult(conn);
+            JSONObject message = JSONObject.fromObject(result);
+            message.accumulate("code", "");
+            result = message.toString();
         } catch (Exception e) {
             // 操作失败
             // log.error("Http connection error!", e);
@@ -220,16 +230,27 @@ public class HttpUtil {
         return text.toString();
     }
 
-    public static void main(String[] args) {
+    public static void main(String[] args) throws IOException {
         JSONObject json = new JSONObject();
-        json.accumulate("examId", 5);
+        json.accumulate("examId", 240);
+        json.accumulate("subjectCode", "CJFX17");
         String test = "https://ecs-test.ea100.com.cn/api/exchange/outer/question/getSubjectivePaperStruct";
-        String dev = "https://dev.ea100.com.cn/api/exchange/outer/question/getSubjectivePaperStruct";
-        HttpUtil subjectHttp = new HttpUtil(dev, "123456", "11", "0");
+        // String dev =
+        // "https://dev.ea100.com.cn/api/exchange/outer/question/getSubjectivePaperStruct";
+        long start = System.currentTimeMillis();
+        HttpUtil subjectHttp = new HttpUtil(test, "123456", "11", "17128");
         String subjectJson = subjectHttp.httpAction(null, json.toString());
         System.out.println(subjectJson);
-
-        // json.accumulate("subjectCode", "ldyCos001");
+        // ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+        // IOUtils.copy(new
+        // ByteArrayInputStream(subjectJson.getBytes(StandardCharsets.UTF_8)),
+        // buffer);
+        // byte[] data = buffer.toByteArray();
+        // File target = new File("/Users/ting.yin/Desktop/test123.json");
+        // target.getParentFile().mkdirs();
+        // FileOutputStream ous = new FileOutputStream(target);
+        // ous.write(data);
+        // IOUtils.closeQuietly(ous);
         // HttpUtil subjectHttp = new HttpUtil(
         // "http://iepcc-ps.ecs.qmth.com.cn:80/api/exchange/outer/question/getSubjectivePaperStruct",
         // "Fu234234CK!fsd9f0", "EPCC", "16923");
@@ -237,19 +258,17 @@ public class HttpUtil {
         // System.out.println(subjectJson);
 
         // HttpUtil paperHttp = new
-        // HttpUtil("http://192.168.10.39:8007/api/exchange/outer/question/getSubjectivePaper",
-        // "123456", "11", "0");
+        // HttpUtil();
         // String paper = paperHttp.httpAction(null, json.toString());
         // System.out.println(paper);
 
-        // long start = System.currentTimeMillis();
         // HttpUtil studentHttp = new HttpUtil(
         // "https://192.168.10.39:8007/api/exchange/outer/question/getSubjectiveQuestion",
         // "123456", "11", "0");
         // json.accumulate("startId", 0);
         // json.accumulate("size", 10);
         // String studentJson = studentHttp.httpAction(null, json.toString());
-        // long end = System.currentTimeMillis();
-        // System.out.println(end - start + ":" + studentJson);
+        long end = System.currentTimeMillis();
+        System.out.println(end - start);
     }
 }

+ 3 - 0
stmms-web/src/main/java/cn/com/qmth/stmms/api/controller/CoreController.java

@@ -259,6 +259,9 @@ public class CoreController extends BaseApiController {
         if (examCode != null) {
             exam = examService.findBySchoolAndCode(user.getSchoolId(), examCode);
         }
+        if (exam == null) {
+            throw ApiException.QUERY_PARAM_ERROR.replaceMessage("exam unexists");
+        }
         if (!exam.getSchoolId().equals(user.getSchoolId())) {
             throw ApiException.EXAM_NOT_ACCESSIBLED;
         }

+ 3 - 3
stmms-web/src/main/webapp/WEB-INF/views/include/trialDetail.jsp

@@ -84,7 +84,7 @@
                             url: paperUrl,
                             dataType: "json",
                             success: function (data) {
-                                paperqQuestions = data.subjectives;
+                                paperqQuestions = data.questions;
                             }
                         })
                         $.ajax({
@@ -125,7 +125,7 @@
                                                     "italic": true,
                                                     "danger": true
                                                 },
-                                                "value": "(字数统计:" + textCount(question.studentAnswer) + ")"
+                                                "value": "(字数统计:" + textCount(question.answer) + ")"
                                             }]
                                         };
                                         let standardTitle = {
@@ -143,7 +143,7 @@
                                         }
                                         $(renderRichText(paperQuestion.body)).appendTo(this.holder);
                                         $(renderSection(answerTitle)).appendTo(this.holder);
-                                        $(renderRichText(question.studentAnswer)).appendTo(this.holder);
+                                        $(renderRichText(question.answer)).appendTo(this.holder);
                                         $(renderSection(standardTitle)).appendTo(this.holder);
                                         $(renderRichText(paperQuestion.answer)).appendTo(this.holder);
                                         trialDetailModal.setContent($('#trial-detail-content'));

+ 3 - 3
stmms-web/src/main/webapp/WEB-INF/views/modules/exam/jsonView.jsp

@@ -43,7 +43,7 @@
             url: paperUrl,
             dataType: "json",
             success: function (data) {
-            	paperqQuestions = data.subjectives;
+            	paperqQuestions = data.questions;
             }
         })
         $.ajax({
@@ -84,7 +84,7 @@
                                     "italic": true,
                                     "danger": true
                                 },
-                                "value": "(字数统计:" + textCount(question.studentAnswer) + ")"
+                                "value": "(字数统计:" + textCount(question.answer) + ")"
                             }]
                         };
                         let standardTitle = {
@@ -102,7 +102,7 @@
                         }
                         $(renderRichText(paperQuestion.body)).appendTo(this.holder);
                         $(renderSection(answerTitle)).appendTo(this.holder);
-                        $(renderRichText(question.studentAnswer)).appendTo(this.holder);
+                        $(renderRichText(question.answer)).appendTo(this.holder);
                         $(renderSection(standardTitle)).appendTo(this.holder);
                         $(renderRichText(paperQuestion.answer)).appendTo(this.holder);
                     }