Explorar o código

replace System.out.println..

deason %!s(int64=5) %!d(string=hai) anos
pai
achega
07c6159649
Modificáronse 14 ficheiros con 460 adicións e 138 borrados
  1. 6 1
      examcloud-core-questions-api-provider/src/test/java/org/examcloud/core/questions/api/provider/AppTest.java
  2. 0 1
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/CombinationUtils.java
  3. 3 10
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/CommonUtils.java
  4. 1 10
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/FileDisposeUtil.java
  5. 7 4
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/ImageUtils.java
  6. 1 20
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/StringSimilarityUtils.java
  7. 0 1
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/converter/utils/Cryptogram.java
  8. 0 12
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/word/DocxProcessUtil.java
  9. 0 18
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/ImportPaperService.java
  10. 10 7
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/PaperDetailUnitServiceImpl.java
  11. 10 10
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/CqdxService.java
  12. 380 7
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/DdCollegeUtilService.java
  13. 37 35
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/DdExcelService.java
  14. 5 2
      examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/UpdatePaperStruct.java

+ 6 - 1
examcloud-core-questions-api-provider/src/test/java/org/examcloud/core/questions/api/provider/AppTest.java

@@ -1,12 +1,17 @@
 package org.examcloud.core.questions.api.provider;
 
+import org.junit.Assert;
 import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class AppTest {
+    private static final Logger log = LoggerFactory.getLogger(AppTest.class);
 
     @Test
     public void test() throws Exception {
-        System.out.println("todo");
+        log.debug("into..");
+        Assert.assertTrue(true);
     }
 
 }

+ 0 - 1
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/CombinationUtils.java

@@ -46,7 +46,6 @@ public class CombinationUtils {
         // list.add(4);
         // list.add(5);
         // combiantion(list);
-        // System.out.println(combineList.toString());
     }
 
     private static List<Integer> sum(String str, int needNum, int needNestNum) {

+ 3 - 10
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/CommonUtils.java

@@ -26,6 +26,7 @@ import java.util.stream.Stream;
  * Created by songyue on 16/12/27.
  */
 public final class CommonUtils {
+    private static final Logger log = LoggerFactory.getLogger(CommonUtils.class);
 
     public static final String QUESTION_VERSION = "1.0";
 
@@ -242,8 +243,6 @@ public final class CommonUtils {
 
     private static final String[][] BASIC_UNESCAPE = invert(BASIC_ESCAPE);
 
-    private static final Logger log = LoggerFactory.getLogger(CommonUtils.class);
-
     /**
      * 加载properties配置文件
      *
@@ -515,12 +514,6 @@ public final class CommonUtils {
         return list;
     }
 
-    public static void main(String[] args) {
-        String htmlString = "<p><a id=\"111\" name=\"1-1-1\"></a><a id=\"222\" name=\"1_1_1.mp3\"></a></p>";
-        System.out.println(getTagANames(htmlString));
-        System.out.println(getTagANames2(htmlString));
-    }
-
     /**
      * 保留两位小数
      *
@@ -703,7 +696,7 @@ public final class CommonUtils {
         try {
             Pattern pattern = Pattern.compile("\\\\u[a-f0-9A-F]{1,4}");
             Matcher matcher = pattern.matcher(content);
-            Map<String, String> unicodeMap = new HashMap<String, String>();
+            Map<String, String> unicodeMap = new HashMap<>();
             while (matcher.find()) {
                 String unicodeStr = matcher.group();
                 byte[] unicodeStrByte = unicodeStr.getBytes();
@@ -711,7 +704,7 @@ public final class CommonUtils {
                 String escapeStr = StringEscapeUtils.unescapeHtml4(StringEscapeUtils.unescapeEcmaScript(resultByte));
                 unicodeMap.put(unicodeStr, escapeStr);
             }
-            System.out.println(unicodeMap);
+
             if (unicodeMap.size() > 0) {
                 for (String key : unicodeMap.keySet()) {
                     //replace函数替换时忽略正则表达式符号,replaceAll和replaceFirst函数替换时是使用正则表达式匹配的。

+ 1 - 10
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/FileDisposeUtil.java

@@ -238,13 +238,4 @@ public class FileDisposeUtil {
         }
     }
 
-    public static void main(String[] args) throws UnsupportedEncodingException {
-//		System.out.println(System.getProperty("sun.jnu.encoding"));
-//		System.out.println(System.getProperty("file.encoding"));
-        String fileName = "梦想(2)";
-
-        System.out.println(URLEncoder.encode(fileName, "UTF-8")
-                .replace("%28", "(")
-                .replace("%29", ")"));
-    }
-}
+}

+ 7 - 4
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/ImageUtils.java

@@ -11,11 +11,14 @@ import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
 import org.jsoup.select.Elements;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.util.HashMap;
 import java.util.Map;
 
 public class ImageUtils {
+    private static final Logger log = LoggerFactory.getLogger(ImageUtils.class);
     private static final String TAG_IMG = "img";
     private static final String UNIT = "px";
     private static final int MAX_WIDTH = 350;
@@ -36,7 +39,7 @@ public class ImageUtils {
         for (Element element : elements) {
             int width = ImageUtils.parseValue(element.attr("style"), "width");
             int height = ImageUtils.parseValue(element.attr("style"), "height");
-            //System.out.println(width + " - " + height);
+            //log.debug(width + " - " + height);
             element.removeAttr("width");
             element.removeAttr("height");
             String widthStr = "";
@@ -60,7 +63,7 @@ public class ImageUtils {
             element.attr("style", widthStr + heightStr);
         }
         String bodyHtml = document.body().html();
-        //System.out.println(bodyHtml);
+        //log.debug(bodyHtml);
         return bodyHtml;
     }
 
@@ -131,10 +134,10 @@ public class ImageUtils {
 
     public static void mainTest(String[] args) {
         String html = "<p><IMG src=\"abc\" width=\"800px\" height=\"400px\" style=\"width: 600PX; height:300PX;\"/><img src=\"xyz\" style=\"width:300px;\"/></p>";
-        System.out.println(ImageUtils.reSizeImg(html));
+        log.debug(ImageUtils.reSizeImg(html));
 
         Map<String, Integer> data = parseImageWidthAndHeight(html);
-        System.out.println(data.get(ATTR_WIDTH) + " - " + data.get(ATTR_HEIGHT));
+        log.debug(data.get(ATTR_WIDTH) + " - " + data.get(ATTR_HEIGHT));
     }
 
 }

+ 1 - 20
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/StringSimilarityUtils.java

@@ -273,23 +273,4 @@ public class StringSimilarityUtils {
         return str.replaceAll(regEx, "").trim();
     }
 
-    public static void main(String[] args) {
-        String str1 = "秦汉以i am filter he is hehe abc来的公文程式构成有\n<><>_________________ !!!!!&nbsp;&copy;&lt;&gt;&nbsp;&nbsp;";
-        String str2 = "More roads than one lead to the mountain village.";
-        // System.out.println(StringSimilarityUtils.stringFilter(str1));
-        // System.out.println(StringSimilarityUtils.stringFilter(str2));
-        // //double similarity1 =
-        // StringSimilarityUtils.getSimilarityWithCosinesBySeg(str1, str2);
-        // double similarity_cos =
-        // StringSimilarityUtils.getSimilarityWithCosinesByWords(str1, str2);
-        // double similarity_dice =
-        // StringSimilarityUtils.getSimilarityWithDiceByWords(str1, str2);
-        // double similarity_diceopt =
-        // StringSimilarityUtils.getSimilarityWithDiceOptByWords(str1, str2);
-        // System.out.println(similarity_cos);
-        // System.out.println(similarity_dice);
-        // System.out.println(similarity_diceopt);
-        System.out.println(stringFilter(str1));
-        System.out.println(segmentText(stringFilter(str1)));
-    }
-}
+}

+ 0 - 1
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/converter/utils/Cryptogram.java

@@ -189,7 +189,6 @@ public class Cryptogram {
         }
         try {
             String md5 = md5Encrypt(password);
-            //System.out.println(md5 + " - " + md5.length());
             //MD5后字符串长度默认32位
             String start = md5.substring(0, 8);
             String end = md5.substring(md5.length() - 8, md5.length());

+ 0 - 12
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/word/DocxProcessUtil.java

@@ -1023,16 +1023,4 @@ public final class DocxProcessUtil {
         return false;
     }
 
-    public static void main(String[] args) throws Exception {
-        StringBuilder str = new StringBuilder();
-//        str.append("abc");
-//        str.append("<span>abc</span>");
-        str.append("<span></span>");
-
-        WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
-        String html = CommonUtils.formatHtml(str.toString());
-        String wordXml = DocxProcessUtil.html2Docx(wordMLPackage, html);
-        System.out.println(wordXml);
-    }
-
 }

+ 0 - 18
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/ImportPaperService.java

@@ -1874,24 +1874,6 @@ public class ImportPaperService {
         paperDetailUnit.setQuestion(newQuestion);
     }
 
-    public static void main(String[] args) {
-        try {
-            String copyAudioPath = "H:" + File.separator + "audio";
-            String newAudioFileName = "111_2.mp3";
-            UpYun upyun = new UpYun("exam-cloud-test", "examcloud", "examcloud123456");
-            //下载音频
-            File audioFile = new File(copyAudioPath + File.separator + newAudioFileName);
-            upyun.readFile("/comm-ques-bank/dev/audio/5b387c9f80a362313ce94162_503_1_1_1.mp3", audioFile);
-            //重新上传新的音频文件
-            File audioFileNew = new File(copyAudioPath + File.separator + newAudioFileName);
-            upyun.writeFile("/comm-ques-bank/dev/audio/" + newAudioFileName, audioFileNew, true);
-            //audioFile.delete();
-        } catch (Exception e) {
-            log.error(e.getMessage(), e);
-        }
-        log.debug("OK");
-    }
-
     //克隆原试卷所有属性
     private Paper cloneOldPaper(Paper oldPaper, String paperName, Course course, User user) {
         Paper newPaper = BeanCopierUtil.copyProperties(oldPaper, Paper.class);

+ 10 - 7
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/PaperDetailUnitServiceImpl.java

@@ -15,6 +15,8 @@ import cn.com.qmth.examcloud.core.questions.service.QuesService;
 import cn.com.qmth.examcloud.core.questions.service.bean.dto.PaperDetailUnitExp;
 import org.apache.commons.collections.CollectionUtils;
 import org.bson.types.ObjectId;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Sort;
 import org.springframework.data.domain.Sort.Direction;
@@ -39,6 +41,7 @@ import static cn.com.qmth.examcloud.core.questions.service.cache.Constants.CACHE
  */
 @Service("paperDetailUnitService")
 public class PaperDetailUnitServiceImpl implements PaperDetailUnitService {
+    private static final Logger log = LoggerFactory.getLogger(PaperDetailUnitServiceImpl.class);
 
     @Autowired
     PaperDetailUnitRepo paperDetailUnitRepo;
@@ -202,7 +205,7 @@ public class PaperDetailUnitServiceImpl implements PaperDetailUnitService {
      * @param paperDetails
      */
     public void deleteUnitsByPaperDetails(List<PaperDetail> paperDetails) {
-        List<PaperDetailUnit> units = new ArrayList<PaperDetailUnit>();
+        List<PaperDetailUnit> units = new ArrayList<>();
         for (PaperDetail pd : paperDetails) {
             units.addAll(getUnitsByPaperDetail(pd));
         }
@@ -256,7 +259,7 @@ public class PaperDetailUnitServiceImpl implements PaperDetailUnitService {
 
     @Override
     public List<PaperDetailUnit> findByQuestionsAndPaperType(List<String> ids, PaperType paperType) {
-        List<ObjectId> objectIds = new ArrayList<ObjectId>();
+        List<ObjectId> objectIds = new ArrayList<>();
         for (String id : ids) {
             objectIds.add(new ObjectId(id));
         }
@@ -269,7 +272,7 @@ public class PaperDetailUnitServiceImpl implements PaperDetailUnitService {
 
     @Override
     public List<PaperDetailUnit> findByDDQuestionsAndPaperType(List<String> ids, PaperType paperType, List<Question> questionList) {
-        List<ObjectId> objectIds = new ArrayList<ObjectId>();
+        List<ObjectId> objectIds = new ArrayList<>();
         for (String id : ids) {
             objectIds.add(new ObjectId(id));
         }
@@ -292,7 +295,7 @@ public class PaperDetailUnitServiceImpl implements PaperDetailUnitService {
 		DBCursor dbCursor = mongoTemplate.getCollection("paperDetailUnit").find(query1);
 		while (dbCursor.hasNext()){
 			DBObject object=dbCursor.next();
-			System.out.println("打印游标---------------"+object);
+			log.debug("打印游标---------------"+object);
 		}
 
 		//第二种查询,quesion.$id  id
@@ -305,7 +308,7 @@ public class PaperDetailUnitServiceImpl implements PaperDetailUnitService {
 		DBCursor dbCursor2 = mongoTemplate.getCollection("paperDetailUnit").find(query1);
 		while (dbCursor2.hasNext()){
 			DBObject object=dbCursor2.next();
-			System.out.println("打印游标2---------------"+object);
+			log.debug("打印游标2---------------"+object);
 		}
 
 		//第三种查询,quesion.$id  ObjectId
@@ -318,14 +321,14 @@ public class PaperDetailUnitServiceImpl implements PaperDetailUnitService {
 		DBCursor dbCursor3 = mongoTemplate.getCollection("paperDetailUnit").find(query1);
 		while (dbCursor3.hasNext()){
 			DBObject object=dbCursor3.next();
-			System.out.println("打印游标3---------------"+object);
+			log.debug("打印游标3---------------"+object);
 		}
 		return null;
 	}*/
 
     @Override
     public List<PaperDetailUnit> findByPaperIds(List<String> ids) {
-        List<ObjectId> objectIds = new ArrayList<ObjectId>();
+        List<ObjectId> objectIds = new ArrayList<>();
         for (String id : ids) {
             objectIds.add(new ObjectId(id));
         }

+ 10 - 10
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/CqdxService.java

@@ -55,9 +55,9 @@ public class CqdxService {
         final String paperNameSuffix = "192";
 
         int i = 0;
-        System.out.println("XML的文件数:" + files.size());
+        log.debug("XML的文件数:" + files.size());
         for (String filePath : files) {
-            System.out.println("第" + (++i) + "个xml文件开始处理,文件名为:" + filePath);
+            log.debug("第" + (++i) + "个xml文件开始处理,文件名为:" + filePath);
 
 //            if (i < 30) {
 //                continue;
@@ -78,11 +78,11 @@ public class CqdxService {
             try {
                 paperDetailUnits = initpaperDetailUnits(paper, paperDetails, questionMaps, paperInfoMap, course);
                 if (paperDetailUnits == null) {
-                    System.out.println("-->有错误的XML:" + filePath);
+                    log.debug("-->有错误的XML:" + filePath);
                     break;
                 }
             } catch (Exception e) {
-                System.out.println("==>有错误的XML:" + filePath + " Error:" + e.getMessage());
+                log.debug("==>有错误的XML:" + filePath + " Error:" + e.getMessage());
                 break;
             }
 
@@ -102,9 +102,9 @@ public class CqdxService {
             File newFile = new File(newFilePath);
             okFile.renameTo(newFile);*/
 
-            System.out.println("第" + i + "个xml文件已经处理完,文件名为:" + filePath);
+            log.debug("第" + i + "个xml文件已经处理完,文件名为:" + filePath);
         }
-        System.out.println("处理完成...");
+        log.debug("处理完成...");
     }
 
     // 初始化试卷
@@ -375,7 +375,7 @@ public class CqdxService {
                 try {
                     question.setQuesBodyWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(question.getQuesBody())));
                 } catch (Exception e) {
-                    System.out.println("错误题干信息:" + question.getQuesBody());
+                    log.debug("错误题干信息:" + question.getQuesBody());
                     throw new IllegalArgumentException("题干信息错误!");
                 }
                 if (question.getQuestionType() == QuesStructType.BOOL_ANSWER_QUESTION) {
@@ -386,7 +386,7 @@ public class CqdxService {
                     try {
                         question.setQuesAnswerWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(question.getQuesAnswer())));
                     } catch (Exception e) {
-                        System.out.println("错误答案信息:" + question.getQuesAnswer());
+                        log.debug("错误答案信息:" + question.getQuesAnswer());
                         throw new IllegalArgumentException("答案信息错误!");
                     }
                 }
@@ -410,7 +410,7 @@ public class CqdxService {
                         try {
                             quesOption.setOptionBodyWord(DocxProcessUtil.html2Docx(wordMLPackage, CommonUtils.formatHtml(quesOption.getOptionBody())));
                         } catch (Exception e) {
-                            System.out.println("错误的选项:" + quesOption.getOptionBody());
+                            log.debug("错误的选项:" + quesOption.getOptionBody());
                             throw new IllegalArgumentException("选项信息错误!");
                         }
                         if (question.getQuesAnswer().contains(String.valueOf(k + 1))) {
@@ -616,7 +616,7 @@ public class CqdxService {
             if (file.getName().endsWith(".xml")) {
                 paths.add(path);
             } else {
-                System.out.println("无效文件:" + path);
+                log.debug("无效文件:" + path);
             }
         }
     }

+ 380 - 7
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/DdCollegeUtilService.java

@@ -310,6 +310,384 @@ import cn.com.qmth.examcloud.core.questions.service.temp.vo.TestQuestionInfo;
  * @param str
  * @return
  * @throws UnsupportedEncodingException
+ * <p>
+ * 根据课程代码查询所有试卷
+ * @param codeName
+ * @return
+ * @throws UnsupportedEncodingException
+ * <p>
+ * 根据考试id查询所有试题
+ * @param testPaperContentId
+ * @return 根据父ID查询子题
+ * @param parentId
+ * @return 初始化试卷对象
+ * @param paper
+ * @param paperName
+ * @param user
+ * <p>
+ * 初始化大题对象
+ * @param testQuestion
+ * @return 初始化试题对象
+ * @param testQuestionInfo
+ * @param testQuestion
+ * @param course
+ * @param map
+ * @return
+ * @throws Exception
+ * <p>
+ * 初始化题干,答案,选项,资源
+ * @param question
+ * @param testQuestionInfo
+ * @param map
+ * @throws Exception
+ * <p>
+ * 初始化选项
+ * @param testOption
+ * @param number
+ * @param isCorrect
+ * @param wordMLPackage
+ * @return
+ * @throws Exception
+ * <p>
+ * 完形填空初始化所有子题
+ * @param blanks
+ * @param wordMLPackage
+ * @return
+ * @throws Exception
+ * <p>
+ * 初始化小题对象
+ * @param question
+ * @return 将大题和小题分类
+ * @param questions
+ * @return 去除图片中有下划线的图片,并补全图片下载地址
+ * @param str
+ * @return
+ * @throws Exception
+ * <p>
+ * 去除<span>标签中lang=EN-US
+ * @param str
+ * @return 替换img标签,补全图片
+ * @param imgList
+ * @param str
+ * @return 將url路徑中的中文转码
+ * @param str
+ * @return
+ * @throws UnsupportedEncodingException
+ * <p>
+ * 根据课程代码查询所有试卷
+ * @param codeName
+ * @return
+ * @throws UnsupportedEncodingException
+ * <p>
+ * 根据考试id查询所有试题
+ * @param testPaperContentId
+ * @return 根据父ID查询子题
+ * @param parentId
+ * @return 初始化试卷对象
+ * @param paper
+ * @param paperName
+ * @param user
+ * <p>
+ * 初始化大题对象
+ * @param testQuestion
+ * @return 初始化试题对象
+ * @param testQuestionInfo
+ * @param testQuestion
+ * @param course
+ * @param map
+ * @return
+ * @throws Exception
+ * <p>
+ * 初始化题干,答案,选项,资源
+ * @param question
+ * @param testQuestionInfo
+ * @param map
+ * @throws Exception
+ * <p>
+ * 初始化选项
+ * @param testOption
+ * @param number
+ * @param isCorrect
+ * @param wordMLPackage
+ * @return
+ * @throws Exception
+ * <p>
+ * 完形填空初始化所有子题
+ * @param blanks
+ * @param wordMLPackage
+ * @return
+ * @throws Exception
+ * <p>
+ * 初始化小题对象
+ * @param question
+ * @return 将大题和小题分类
+ * @param questions
+ * @return 去除图片中有下划线的图片,并补全图片下载地址
+ * @param str
+ * @return
+ * @throws Exception
+ * <p>
+ * 去除<span>标签中lang=EN-US
+ * @param str
+ * @return 替换img标签,补全图片
+ * @param imgList
+ * @param str
+ * @return 將url路徑中的中文转码
+ * @param str
+ * @return
+ * @throws UnsupportedEncodingException
+ * <p>
+ * 根据课程代码查询所有试卷
+ * @param codeName
+ * @return
+ * @throws UnsupportedEncodingException
+ * <p>
+ * 根据考试id查询所有试题
+ * @param testPaperContentId
+ * @return 根据父ID查询子题
+ * @param parentId
+ * @return 初始化试卷对象
+ * @param paper
+ * @param paperName
+ * @param user
+ * <p>
+ * 初始化大题对象
+ * @param testQuestion
+ * @return 初始化试题对象
+ * @param testQuestionInfo
+ * @param testQuestion
+ * @param course
+ * @param map
+ * @return
+ * @throws Exception
+ * <p>
+ * 初始化题干,答案,选项,资源
+ * @param question
+ * @param testQuestionInfo
+ * @param map
+ * @throws Exception
+ * <p>
+ * 初始化选项
+ * @param testOption
+ * @param number
+ * @param isCorrect
+ * @param wordMLPackage
+ * @return
+ * @throws Exception
+ * <p>
+ * 完形填空初始化所有子题
+ * @param blanks
+ * @param wordMLPackage
+ * @return
+ * @throws Exception
+ * <p>
+ * 初始化小题对象
+ * @param question
+ * @return 将大题和小题分类
+ * @param questions
+ * @return 去除图片中有下划线的图片,并补全图片下载地址
+ * @param str
+ * @return
+ * @throws Exception
+ * <p>
+ * 去除<span>标签中lang=EN-US
+ * @param str
+ * @return 替换img标签,补全图片
+ * @param imgList
+ * @param str
+ * @return 將url路徑中的中文转码
+ * @param str
+ * @return
+ * @throws UnsupportedEncodingException
+ * <p>
+ * 根据课程代码查询所有试卷
+ * @param codeName
+ * @return
+ * @throws UnsupportedEncodingException
+ * <p>
+ * 根据考试id查询所有试题
+ * @param testPaperContentId
+ * @return 根据父ID查询子题
+ * @param parentId
+ * @return 初始化试卷对象
+ * @param paper
+ * @param paperName
+ * @param user
+ * <p>
+ * 初始化大题对象
+ * @param testQuestion
+ * @return 初始化试题对象
+ * @param testQuestionInfo
+ * @param testQuestion
+ * @param course
+ * @param map
+ * @return
+ * @throws Exception
+ * <p>
+ * 初始化题干,答案,选项,资源
+ * @param question
+ * @param testQuestionInfo
+ * @param map
+ * @throws Exception
+ * <p>
+ * 初始化选项
+ * @param testOption
+ * @param number
+ * @param isCorrect
+ * @param wordMLPackage
+ * @return
+ * @throws Exception
+ * <p>
+ * 完形填空初始化所有子题
+ * @param blanks
+ * @param wordMLPackage
+ * @return
+ * @throws Exception
+ * <p>
+ * 初始化小题对象
+ * @param question
+ * @return 将大题和小题分类
+ * @param questions
+ * @return 去除图片中有下划线的图片,并补全图片下载地址
+ * @param str
+ * @return
+ * @throws Exception
+ * <p>
+ * 去除<span>标签中lang=EN-US
+ * @param str
+ * @return 替换img标签,补全图片
+ * @param imgList
+ * @param str
+ * @return 將url路徑中的中文转码
+ * @param str
+ * @return
+ * @throws UnsupportedEncodingException
+ * <p>
+ * 根据课程代码查询所有试卷
+ * @param codeName
+ * @return
+ * @throws UnsupportedEncodingException
+ * <p>
+ * 根据考试id查询所有试题
+ * @param testPaperContentId
+ * @return 根据父ID查询子题
+ * @param parentId
+ * @return 初始化试卷对象
+ * @param paper
+ * @param paperName
+ * @param user
+ * <p>
+ * 初始化大题对象
+ * @param testQuestion
+ * @return 初始化试题对象
+ * @param testQuestionInfo
+ * @param testQuestion
+ * @param course
+ * @param map
+ * @return
+ * @throws Exception
+ * <p>
+ * 初始化题干,答案,选项,资源
+ * @param question
+ * @param testQuestionInfo
+ * @param map
+ * @throws Exception
+ * <p>
+ * 初始化选项
+ * @param testOption
+ * @param number
+ * @param isCorrect
+ * @param wordMLPackage
+ * @return
+ * @throws Exception
+ * <p>
+ * 完形填空初始化所有子题
+ * @param blanks
+ * @param wordMLPackage
+ * @return
+ * @throws Exception
+ * <p>
+ * 初始化小题对象
+ * @param question
+ * @return 将大题和小题分类
+ * @param questions
+ * @return 去除图片中有下划线的图片,并补全图片下载地址
+ * @param str
+ * @return
+ * @throws Exception
+ * <p>
+ * 去除<span>标签中lang=EN-US
+ * @param str
+ * @return 替换img标签,补全图片
+ * @param imgList
+ * @param str
+ * @return 將url路徑中的中文转码
+ * @param str
+ * @return
+ * @throws UnsupportedEncodingException
+ * <p>
+ * 根据课程代码查询所有试卷
+ * @param codeName
+ * @return
+ * @throws UnsupportedEncodingException
+ * <p>
+ * 根据考试id查询所有试题
+ * @param testPaperContentId
+ * @return 根据父ID查询子题
+ * @param parentId
+ * @return 初始化试卷对象
+ * @param paper
+ * @param paperName
+ * @param user
+ * <p>
+ * 初始化大题对象
+ * @param testQuestion
+ * @return 初始化试题对象
+ * @param testQuestionInfo
+ * @param testQuestion
+ * @param course
+ * @param map
+ * @return
+ * @throws Exception
+ * <p>
+ * 初始化题干,答案,选项,资源
+ * @param question
+ * @param testQuestionInfo
+ * @param map
+ * @throws Exception
+ * <p>
+ * 初始化选项
+ * @param testOption
+ * @param number
+ * @param isCorrect
+ * @param wordMLPackage
+ * @return
+ * @throws Exception
+ * <p>
+ * 完形填空初始化所有子题
+ * @param blanks
+ * @param wordMLPackage
+ * @return
+ * @throws Exception
+ * <p>
+ * 初始化小题对象
+ * @param question
+ * @return 将大题和小题分类
+ * @param questions
+ * @return 去除图片中有下划线的图片,并补全图片下载地址
+ * @param str
+ * @return
+ * @throws Exception
+ * <p>
+ * 去除<span>标签中lang=EN-US
+ * @param str
+ * @return 替换img标签,补全图片
+ * @param imgList
+ * @param str
+ * @return 將url路徑中的中文转码
+ * @param str
+ * @return
+ * @throws UnsupportedEncodingException
  *//*
 @Service("ddCollegeUtilService")
 public class DdCollegeUtilService {
@@ -384,7 +762,7 @@ public class DdCollegeUtilService {
 									question = initQuestion(testQuestionInfo,testQuestion,course,map2,difficulty);
 								} catch (Exception e) {
 									log.error(e.getMessage(), e);
-									System.out.println("错误题号:"+ error);
+									log.debug("错误题号:"+ error);
 								}
 								//初始化小题对象
 								PaperDetailUnit paperDetailUnit = initPaperDetailUnit(paper, paperDetail, question, testQuestion);
@@ -1118,11 +1496,6 @@ public class DdCollegeUtilService {
         String url =  java.net.URLEncoder.encode(s.toString(), "utf-8");
     	return str.replace(s.toString(), url);
     }
-    
-    public static void main(String[] args) throws UnsupportedEncodingException{
-    	String ssString = "/UploadFiles/刘昌辉/Images/OnlineExam20140923161629.jpg";
-    	//String ss = regexCH(ssString);
-    	//System.out.println(ss);
-    }
+
 }
 */

+ 37 - 35
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/DdExcelService.java

@@ -15,6 +15,8 @@ import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.mongodb.core.MongoTemplate;
 import org.springframework.data.mongodb.core.query.Criteria;
@@ -28,6 +30,7 @@ import java.util.*;
 
 @Service("ddExcelService")
 public class DdExcelService {
+    private static final Logger log = LoggerFactory.getLogger(DdExcelService.class);
     private final String exportExcelPath = "D:/exportExcel.xlsx";
     private final String xianExcelPath = "D:/xianExcelNew.xlsx";
     private final String paperExcelPath = "D:/paperExcel.xlsx";
@@ -59,7 +62,7 @@ public class DdExcelService {
         //List<Course> courses = courseRepo.findByOrgId(orgId);
         List<Course> courses = new ArrayList<Course>();
         long endCourseTime = System.currentTimeMillis();
-        System.out.println("查询课程耗时:" + (endCourseTime - startCourseTime) + "ms");
+        log.debug("查询课程耗时:" + (endCourseTime - startCourseTime) + "ms");
         if (courses != null && courses.size() > 0) {
             int i = 1;
             int j = 1;
@@ -68,7 +71,7 @@ public class DdExcelService {
                 long startPaperTime = System.currentTimeMillis();
                 List<Paper> papers = paperRepo.findByCourseNoAndOrgId(course.getCode(), orgId);
                 long endPaperTime = System.currentTimeMillis();
-                System.out.println("查询第" + i + "个课程下所有试卷耗时耗时:" + (endPaperTime - startPaperTime) + "ms,课程代码为:" + course.getCode());
+                log.debug("查询第" + i + "个课程下所有试卷耗时耗时:" + (endPaperTime - startPaperTime) + "ms,课程代码为:" + course.getCode());
                 if (papers != null && papers.size() > 0) {
                     //生成所有试卷的试题集合
                     List<PaperDetailUnit> allUnits = new ArrayList<>();
@@ -77,14 +80,14 @@ public class DdExcelService {
                         long startUnitTime = System.currentTimeMillis();
                         List<PaperDetailUnit> paperDetailUnits = paperDetailUnitRepo.findByPaper(paper);
                         long endUnitTime = System.currentTimeMillis();
-                        System.out.println("查询" + paper.getName() + "个试卷下所有试题耗时耗时:" + (endUnitTime - startUnitTime) + "ms");
+                        log.debug("查询" + paper.getName() + "个试卷下所有试题耗时耗时:" + (endUnitTime - startUnitTime) + "ms");
                         if (paperDetailUnits != null && paperDetailUnits.size() > 0) {
                             for (PaperDetailUnit unit : paperDetailUnits) {
                                 allUnits.add(unit);
                             }
                         }
                     }
-                    System.out.println("开始生成对象...总题数量:" + allUnits.size());
+                    log.debug("开始生成对象...总题数量:" + allUnits.size());
                     //生成需要保存的大题来源集合
                     List<QuesTypeName> quesTypeNames = new ArrayList<>();
                     Map<QuesStructType, List<String>> map = buildQuesTypeName(allUnits);
@@ -95,18 +98,18 @@ public class DdExcelService {
                         quesTypeName.setQuestionType(entry.getKey());
                         quesTypeName.setQuesNames(entry.getValue());
                         quesTypeNames.add(quesTypeName);
-                        System.out.println("生成完第" + j + "个对象");
+                        log.debug("生成完第" + j + "个对象");
                         j++;
                     }
                     long endTime = System.currentTimeMillis();
-                    System.out.println("所有试题耗时耗时:" + (endTime - endPaperTime) + "ms");
+                    log.debug("所有试题耗时耗时:" + (endTime - endPaperTime) + "ms");
                     quesTypeRepo.saveAll(quesTypeNames);
                     long ends = System.currentTimeMillis();
-                    System.out.println("第" + i + "个课程保存所有来源大题耗时:" + (ends - endTime) + "ms");
+                    log.debug("第" + i + "个课程保存所有来源大题耗时:" + (ends - endTime) + "ms");
                 }
                 i++;
             }
-            System.out.println("对象生成完");
+            log.debug("对象生成完");
         }
     }
 
@@ -145,7 +148,7 @@ public class DdExcelService {
         //List<Course> courses = courseRepo.findByOrgId(orgId);
         List<Course> courses = new ArrayList<>();
         long endCourseTime = System.currentTimeMillis();
-        System.out.println("查询课程耗时:" + (endCourseTime - startCourseTime) + "ms");
+        log.debug("查询课程耗时:" + (endCourseTime - startCourseTime) + "ms");
         if (courses != null && courses.size() > 0) {
             int i = 0;
             for (Course course : courses) {
@@ -153,7 +156,7 @@ public class DdExcelService {
                 long startQuestionTime = System.currentTimeMillis();
                 List<Question> questions = quesRepo.findByCourseAndOrgId(course, orgId);
                 long endQuestionTime = System.currentTimeMillis();
-                System.out.println("查询第" + i + "个课程试题耗时:" + (endQuestionTime - startQuestionTime) + "ms");
+                log.debug("查询第" + i + "个课程试题耗时:" + (endQuestionTime - startQuestionTime) + "ms");
                 List<String> oIds = new ArrayList<>();
                 for (Question question : questions) {
                     oIds.add(question.getId());
@@ -162,7 +165,7 @@ public class DdExcelService {
                 long startUnitTime = System.currentTimeMillis();
                 List<PaperDetailUnit> oDetailUnits = paperDetailUnitService.findByDDQuestionsAndPaperType(oIds, PaperType.IMPORT, questions);
                 long endUnitTime = System.currentTimeMillis();
-                System.out.println("查询第" + i + "个课程试题耗时:" + (endUnitTime - startUnitTime) + "ms");
+                log.debug("查询第" + i + "个课程试题耗时:" + (endUnitTime - startUnitTime) + "ms");
                 Map<String, Long> map = new HashMap<>();
                 if (oDetailUnits != null && oDetailUnits.size() > 0) {
                     for (PaperDetailUnit unit : oDetailUnits) {
@@ -179,7 +182,7 @@ public class DdExcelService {
                 }
                 DdExcelDto ddExcelDto = new DdExcelDto(course.getName(), course.getCode(), map);
                 ddExcelDtos.add(ddExcelDto);
-                System.out.println("已经处理完:" + i + "个课程...");
+                log.debug("已经处理完:" + i + "个课程...");
                 i++;
             }
         }
@@ -189,7 +192,7 @@ public class DdExcelService {
         Workbook workBook = new XSSFWorkbook(ddExcelFile);
         //获取第一个工作页
         Sheet sheet = workBook.getSheetAt(0);
-        System.out.println(sheet.getSheetName());
+        log.debug(sheet.getSheetName());
         //向Excle中写入数据,从第2行开始
         for (int i = 0; i < ddExcelDtos.size(); i++) {
             //创建一行:从第1行开始,跳过表头
@@ -369,15 +372,14 @@ public class DdExcelService {
                 }
 
             } else {
-                System.out.println("课程:" + ddExcelDto.getCourseName());
+                log.debug("课程:" + ddExcelDto.getCourseName());
             }
         }
         File file = new File(xianExcelPath);
         OutputStream out = new FileOutputStream(file);
         workBook.write(out);
         out.close();
-        System.out.println("结束...");
-        System.out.println(otherMap);
+        log.debug("结束...");
     }
 
     /**
@@ -385,7 +387,7 @@ public class DdExcelService {
      */
     @SuppressWarnings("resource")
     public void exportPaperExcel(String orgId) throws Exception {
-        System.out.println("开始导出试卷具体信息。。。。");
+        log.debug("开始导出试卷具体信息。。。。");
         //导出Excel对象集合
         List<DdPaperDto> excelDtoList = new ArrayList<DdPaperDto>();
         //根据课程查询试卷
@@ -409,14 +411,14 @@ public class DdExcelService {
                         excelDtoList.add(ddPaperDto);
                     }
                 }
-                System.out.println("处理完第" + j + "套试卷。。。");
+                log.debug("处理完第" + j + "套试卷。。。");
                 j++;
             }
         }
         //查询所有课程
         //List<Course> courses = courseRepo.findByOrgId(orgId);
         //List<Course> courses = new ArrayList<Course>();
-        //System.out.println("查询课程总数:"+ courses.size());
+        //log.debug("查询课程总数:"+ courses.size());
 		/*if(courses != null && courses.size()>0){
 			int i = 1;
 			for(Course course : courses){
@@ -427,7 +429,7 @@ public class DdExcelService {
 		        query.addCriteria(Criteria.where("course.enable").is("true"));
 		        query.addCriteria(Criteria.where("course.code").is(course.getCode()));
 		        List<Paper> paperList = this.mongoTemplate.find(query, Paper.class);
-		        System.out.println(course.getCode() + "课程下的组卷试卷数量:" + paperList.size());
+		        log.debug(course.getCode() + "课程下的组卷试卷数量:" + paperList.size());
 		        if(paperList != null && paperList.size()>0){
 		        	int j = 1;
 		        	for(Paper paper : paperList){
@@ -444,11 +446,11 @@ public class DdExcelService {
 			        			excelDtoList.add(ddPaperDto);
 		        			}
 		        		}
-		        		System.out.println("处理完第"+ j + "套试卷。。。");
+		        		log.debug("处理完第"+ j + "套试卷。。。");
 		        		j++;
 		        	}
 		        }
-		        System.out.println("处理完第"+ i + "个课程。。。");
+		        log.debug("处理完第"+ i + "个课程。。。");
         		i++;
 			}
 		}*/
@@ -473,7 +475,7 @@ public class DdExcelService {
         OutputStream out = new FileOutputStream(file);
         workBook.write(out);
         out.close();
-        System.out.println("结束...");
+        log.debug("结束...");
     }
 
     /**
@@ -481,13 +483,13 @@ public class DdExcelService {
      */
     @SuppressWarnings("resource")
     public void exportPaperStructExcel(String orgId) throws Exception {
-        System.out.println("开始导出试卷结构");
+        log.debug("开始导出试卷结构");
         //导出Excel对象集合
         List<DdPaperStructDto> excelDtoList = new ArrayList<>();
         //查询所有课程
         List<Course> courses = courseRepo.findByOrgId(orgId);
         //List<Course> courses = new ArrayList<Course>();
-        System.out.println("查询课程总数:" + courses.size());
+        log.debug("查询课程总数:" + courses.size());
 
         if (courses != null && courses.size() > 0) {
             int i = 1;
@@ -497,7 +499,7 @@ public class DdExcelService {
                 query.addCriteria(Criteria.where("type").is("EXACT"));
                 query.addCriteria(Criteria.where("courseNo").is(course.getCode()));
                 List<PaperStruct> paperStructList = this.mongoTemplate.find(query, PaperStruct.class);
-                System.out.println(course.getCode() + "课程下的试卷结构数量:" + paperStructList.size());
+                log.debug(course.getCode() + "课程下的试卷结构数量:" + paperStructList.size());
                 if (paperStructList != null && paperStructList.size() > 0) {
                     for (PaperStruct paperStruct : paperStructList) {
                         //得到大题集合
@@ -522,8 +524,8 @@ public class DdExcelService {
                         }
                     }
                 }
-                System.out.println("处理完第:" + i + "个课程。");
-                System.out.println("生成对象个数:" + excelDtoList.size());
+                log.debug("处理完第:" + i + "个课程。");
+                log.debug("生成对象个数:" + excelDtoList.size());
                 i++;
             }
         }
@@ -549,7 +551,7 @@ public class DdExcelService {
         OutputStream out = new FileOutputStream(file);
         workBook.write(out);
         out.close();
-        System.out.println("结束...");
+        log.debug("结束...");
     }
 
     /**
@@ -557,12 +559,12 @@ public class DdExcelService {
      */
     @SuppressWarnings("resource")
     public void exportSubQues(String orgId, Long examId, List<String> codes) throws Exception {
-        System.out.println(String.format("共%s门课程的调卷规则", codes.size()));
+        log.debug(String.format("共%s门课程的调卷规则", codes.size()));
 
         int index = 1;
         List<SubQuestionDto> subjectQuestions = new ArrayList<>();
         for (String code : codes) {
-            System.out.println("开始处理第" + index + "门课程的调卷规则");
+            log.debug("开始处理第" + index + "门课程的调卷规则");
             index++;
 
             Query query = new Query();
@@ -571,7 +573,7 @@ public class DdExcelService {
             query.addCriteria(Criteria.where("courseCode").is(code));
             ExtractConfig tempConfig = this.mongoTemplate.findOne(query, ExtractConfig.class);
             if (tempConfig == null) {
-                System.out.println(String.format("课程-%s:没有调卷规则", code));
+                log.debug(String.format("课程-%s:没有调卷规则", code));
                 continue;
             }
 
@@ -580,12 +582,12 @@ public class DdExcelService {
 
             //获取试卷
             List<ExamPaper> examPaperList = tempConfig.getExamPaperList();
-            System.out.println("原试卷数量:" + examPaperList.size());
+            log.debug("原试卷数量:" + examPaperList.size());
 
             for (ExamPaper examPaper : examPaperList) {
                 ids.add(examPaper.getPaper().getId());
             }
-            System.out.println("去重后的试卷数量:" + ids.size());
+            log.debug("去重后的试卷数量:" + ids.size());
 
             //循环去重后的试卷
             for (String id : ids) {
@@ -669,7 +671,7 @@ public class DdExcelService {
         OutputStream out = new FileOutputStream(file);
         workBook.write(out);
         out.close();
-        System.out.println("结束...");
+        log.debug("结束...");
     }
 
 }

+ 5 - 2
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/temp/UpdatePaperStruct.java

@@ -6,6 +6,8 @@ import cn.com.qmth.examcloud.core.questions.dao.entity.PaperDetailStruct;
 import cn.com.qmth.examcloud.core.questions.dao.entity.PaperDetailUnitStruct;
 import cn.com.qmth.examcloud.core.questions.dao.entity.PaperStruct;
 import cn.com.qmth.examcloud.core.questions.dao.entity.dto.PaperDetailUnitStructDto;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.mongodb.core.MongoTemplate;
 import org.springframework.stereotype.Service;
@@ -22,6 +24,7 @@ import java.util.List;
 
 @Service("updatePaperStructService")
 public class UpdatePaperStruct {
+    private static final Logger log = LoggerFactory.getLogger(UpdatePaperStruct.class);
 
     @Autowired
     PaperStructRepo paperStructRepo;
@@ -64,9 +67,9 @@ public class UpdatePaperStruct {
                 i++;
             }
         }
-        System.out.println("更新精确试卷结构的数量为:" + i + "------个");
+        log.debug("更新精确试卷结构的数量为:" + i + "------个");
         paperStructRepo.saveAll(paperStructList);
-        System.out.println("更新成功!----");
+        log.debug("更新成功!----");
     }
 
     /**