Browse Source

just format code styles.

deason 6 years ago
parent
commit
9fab5e2cc8
39 changed files with 1346 additions and 1292 deletions
  1. 8 3
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/BeanCopierUtil.java
  2. 17 15
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/CommonUtils.java
  3. 221 220
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/FileDisposeUtil.java
  4. 15 11
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/SpringContextUtils.java
  5. 8 8
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/StringSimilarityUtils.java
  6. 12 11
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/ZipUtils.java
  7. 67 67
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/core/CourseSpeciatly.java
  8. 57 57
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/core/CourseSync.java
  9. 56 46
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/core/ExamCourseDto.java
  10. 52 52
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/core/enums/CourseLevel.java
  11. 12 11
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/enums/AudioPositionType.java
  12. 28 27
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/enums/ExportType.java
  13. 19 19
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/enums/ExportWay.java
  14. 32 30
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/enums/ExtractPolicy.java
  15. 31 30
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/enums/GenPaperExpression.java
  16. 28 24
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/enums/GenPaperFunction.java
  17. 28 28
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/enums/GenPaperType.java
  18. 8 6
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/enums/PaperStatus.java
  19. 38 38
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/enums/PaperStructType.java
  20. 11 10
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/enums/PaperType.java
  21. 45 45
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/enums/PropertyDifficulty.java
  22. 7 6
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/enums/QuesUnit.java
  23. 32 31
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/enums/RandomGenPaperPolicy.java
  24. 6 5
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/enums/Switch.java
  25. 10 10
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/excel/ColumnSetting.java
  26. 40 39
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/excel/ExcelError.java
  27. 12 10
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/excel/ExcelProperty.java
  28. 114 118
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/excel/ExcelReader.java
  29. 2 2
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/excel/ExcelReaderHandle.java
  30. 31 30
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/excel/ExcelUtils.java
  31. 1 1
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/excel/ExcelWriter.java
  32. 5 5
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/excel/ExportUtils.java
  33. 4 2
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/exception/PaperException.java
  34. 4 2
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/exception/QuesException.java
  35. 144 134
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/print/CoursePaperDto.java
  36. 15 15
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/question/PaperDetailUnitDto.java
  37. 31 31
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/question/PaperDto.java
  38. 94 92
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/question/enums/QuesStructType.java
  39. 1 1
      examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/word/DocxProcessUtil.java

+ 8 - 3
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/BeanCopierUtil.java

@@ -14,7 +14,7 @@ import static java.lang.String.format;
  */
 public class BeanCopierUtil {
     private static final Map<String, BeanCopier> beanCopierCache = new ConcurrentHashMap<>();
-    private static final Map<String,ConstructorAccess> constructorAccessCache = new ConcurrentHashMap<>();
+    private static final Map<String, ConstructorAccess> constructorAccessCache = new ConcurrentHashMap<>();
 
     private static void copyProperties(Object source, Object target) {
         BeanCopier copier = getBeanCopier(source.getClass(), target.getClass());
@@ -23,6 +23,7 @@ public class BeanCopierUtil {
 
     /**
      * 获取BeanCopier实例
+     *
      * @param sourceClass
      * @param targetClass
      * @return
@@ -41,6 +42,7 @@ public class BeanCopierUtil {
 
     /**
      * 生成key
+     *
      * @param class1
      * @param class2
      * @return
@@ -51,6 +53,7 @@ public class BeanCopierUtil {
 
     /**
      * 拷贝对象
+     *
      * @param source
      * @param targetClass
      * @param <T>
@@ -69,6 +72,7 @@ public class BeanCopierUtil {
 
     /**
      * 拷贝List
+     *
      * @param sourceList
      * @param targetClass
      * @param <T>
@@ -95,19 +99,20 @@ public class BeanCopierUtil {
 
     /**
      * 获取集合包装类
+     *
      * @param targetClass
      * @param <T>
      * @return
      */
     private static <T> ConstructorAccess<T> getConstructorAccess(Class<T> targetClass) {
         ConstructorAccess<T> constructorAccess = constructorAccessCache.get(targetClass.toString());
-        if(constructorAccess != null) {
+        if (constructorAccess != null) {
             return constructorAccess;
         }
         try {
             constructorAccess = ConstructorAccess.get(targetClass);
             constructorAccess.newInstance();
-            constructorAccessCache.put(targetClass.toString(),constructorAccess);
+            constructorAccessCache.put(targetClass.toString(), constructorAccess);
         } catch (Exception e) {
             throw new RuntimeException(format("Create new instance of %s failed: %s", targetClass, e.getMessage()));
         }

+ 17 - 15
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/CommonUtils.java

@@ -27,8 +27,8 @@ import java.util.stream.Stream;
  */
 public final class CommonUtils {
 
-	public static final String QUESTION_VERSION = "1.0";
-	
+    public static final String QUESTION_VERSION = "1.0";
+
     private static final String COMMON_PROPERTIES = "common.properties";
 
     private static final String[] CN_SMALL_NUM = {"零", "一", "二", "三", "四", "五", "六", "七", "八", "九"};
@@ -788,14 +788,15 @@ public final class CommonUtils {
             return sb.toString();
         }
     }
-    
+
     /**
      * 去除字符串中所有的html标签
+     *
      * @param html
      * @return
      */
     public static String parseHtml(String html) {
-        if(html==null) {
+        if (html == null) {
             return null;
         }
         org.jsoup.nodes.Document document = Jsoup.parse(html);
@@ -804,19 +805,20 @@ public final class CommonUtils {
 
     /**
      * 正则表达是匹配特殊字符进行转义
+     *
      * @param keyword
      * @return
      */
-    public static String escapeExprSpecialWord(String keyword){
-    	if (StringUtils.isNotBlank(keyword)) {
-    		String[] fbsArr = { "\\", "$", "(", ")", "*", "+", ".", "[", "]", "?", "^", "{", "}", "|" };
-    		for (String key : fbsArr) {
-    			if (keyword.contains(key)) {
-    				keyword = keyword.replace(key, "\\" + key);
-    				return keyword;
-    			}
-    		}
-    	}
-    	return keyword;
+    public static String escapeExprSpecialWord(String keyword) {
+        if (StringUtils.isNotBlank(keyword)) {
+            String[] fbsArr = {"\\", "$", "(", ")", "*", "+", ".", "[", "]", "?", "^", "{", "}", "|"};
+            for (String key : fbsArr) {
+                if (keyword.contains(key)) {
+                    keyword = keyword.replace(key, "\\" + key);
+                    return keyword;
+                }
+            }
+        }
+        return keyword;
     }
 }

+ 221 - 220
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/FileDisposeUtil.java

@@ -37,227 +37,228 @@ import org.slf4j.LoggerFactory;
  * @description FileUtil.java
  */
 public class FileDisposeUtil {
-	
-	private static final Logger logger = LoggerFactory.getLogger(FileDisposeUtil.class);
-	
-	/**
-	 * 将网络文件保存到本地
-	 * @param fileUrl		   网络文件URL
-	 * @param localFilePath  例如D:/123.txt
-	 * @return
-	 */
-	public static boolean saveUrlAs(String fileUrl,String localFilePath) {
-		HttpURLConnection connection = null;
-		FileOutputStream fileOutputStream = null;
-		DataOutputStream dataOutputStream = null;
-		DataInputStream dataInputStream = null;
-		try {
-			URL url = new URL(fileUrl);
-			connection = (HttpURLConnection) url.openConnection();
-			dataInputStream = new DataInputStream(connection.getInputStream());
-			fileOutputStream = new FileOutputStream(localFilePath);
-			dataOutputStream = new DataOutputStream(fileOutputStream);
-			byte[] buffer = new byte[4096];
-			int count = 0;
-			while ((count = dataInputStream.read(buffer)) > 0) {
-				dataOutputStream.write(buffer, 0, count);
-			}
-			return true;
-		} catch (Exception e) {
-			return false;
-		}finally {
-			try {
-				if(fileOutputStream!=null){
-					fileOutputStream.flush();
-					fileOutputStream.close();
-					fileOutputStream = null;
-				}
-				if (dataOutputStream != null) {
-					dataOutputStream.flush();
-					dataOutputStream.close();
-					dataOutputStream = null;
-				}
-				if (dataInputStream != null) {
-					dataInputStream.close();
-					dataInputStream = null;
-				}
-			} catch (IOException e) {
-				e.printStackTrace();
-			}
-			if (connection != null) {
-				connection.disconnect();
-				connection = null;
-			}
-		}
-	}
-	
-	/**
-	 * 下载服务器上的文件
-	 * @param filename		文件名称
-	 * @param fullFilePath	文件全路径
-	 * @param response
-	 */
-	public static void downloadFile(String filename,String fullFilePath,HttpServletResponse response){
-		InputStream in = null;
-		OutputStream out = null;
-		try {
-			//设置编码
-			response.setCharacterEncoding("UTF-8");
-	        //设置文件MIME类型  
-			response.setContentType(getContentType(filename));
-	        //设置Content-Disposition,名称强制为UTF-8
-			//String fileEncode = System.getProperty("file.encoding");
-	        //response.setHeader("Content-Disposition", "attachment;filename="+new String(filename.getBytes(fileEncode),"UTF-8"));
-	        //response.setHeader("Content-Disposition", "attachment;filename="+URLEncoder.encode(filename,"UTF-8"));
-	        response.setHeader("Content-Disposition", "attachment;filename="+URLEncoder.encode(filename,"UTF-8")
-					.replace("%28", "(")
-					.replace("%29", ")"));
-	         // 设置强制下载不打开
-	         response.setContentType("application/octet-stream;charset=utf-8");
-	        //读取目标文件,通过response将目标文件写到客户端  
-	        //获取目标文件的绝对路径  
-	        //读取文件  
-			in = new FileInputStream(fullFilePath);
-			out = response.getOutputStream();
-	        //写文件  
-	        byte[] buffer = new byte[4096];
-			int count = 0;
-			while ((count = in.read(buffer)) > 0) {
-				out.write(buffer, 0, count);
-			} 
-	        response.flushBuffer();
-	        out.close(); 
-	        in.close();  
-		} catch (FileNotFoundException e) {
-			e.printStackTrace();
-		} catch (IOException e) {
-			e.printStackTrace();
-		}finally{
-			try{
-				if (null != out){
-					out.close();
-					out = null;
-				}
-				if (null != in){
-					in.close();
-					in = null;
-				}
-			} catch (IOException e) {
-				e.printStackTrace();
-				throw new RuntimeException(e);
-			}
-		}
-         
-	}
-	/**
-	 * 获得文件MIME类型
-	 * @param filename
-	 * @return
-	 */
-	public static String getContentType(String filename){
-		String type = null;
-		Path path = Paths.get(filename);
-		try {
-			type = Files.probeContentType(path);
-		} catch (IOException e) {
-			e.printStackTrace();
-		}
-		return type;
-	}
 
-	/**
-	 * 将存放在sourceFilePath目录下的源文件,打包成fileName名称的zip文件,并存放到zipFilePath路径下
-	 * 
-	 * @param sourceFilePath
-	 *            :待压缩的文件夹路径
-	 * @param zipFilePath
-	 *            :压缩后zip文件的存放路径
-	 * @param fileName
-	 *            :zip文件的名称
-	 * @return
-	 */
-	public static boolean fileToZip(String sourceFilePath, String zipFilePath,String fileName) {
-		logger.info("压缩"+sourceFilePath+"目录开始");
-		boolean flag = false;
-		File sourceFile = new File(sourceFilePath);
-		FileInputStream fis = null;
-		BufferedInputStream bis = null;
-		FileOutputStream fos = null;
-		ZipOutputStream zos = null;
-		if (sourceFile.exists() == false) {
-			logger.error("待压缩的文件目录:" + sourceFilePath + "不存在.");
-		} else {
-			try {
-				File zipFile = new File(zipFilePath+File.separator+fileName+".zip");
-				if (zipFile.exists()) {
-					logger.error(zipFilePath + "目录下存在名字为:"+fileName+".zip"+"打包文件.");
-				} else {
-					File[] sourceFiles = sourceFile.listFiles();
-					if (null == sourceFiles || sourceFiles.length < 1) {
-						logger.error("待压缩的文件目录:" + sourceFilePath+ "里面不存在文件,无需压缩.");
-					} else {
-						fos = new FileOutputStream(zipFile);
-						zos = new ZipOutputStream(new BufferedOutputStream(fos));
-						byte[] bufs = new byte[1024 * 10];
-						for (int i = 0; i < sourceFiles.length; i++) {
-							File file=sourceFiles[i];
-							if(!file.isFile()){
-								continue;
-							}
-							try{
-								//创建ZIP实体,并添加进压缩包
-								String fileEncode = System.getProperty("file.encoding");
-								String name = new String(file.getName().getBytes(fileEncode),"UTF-8");
-								ZipEntry zipEntry = new ZipEntry(name);
-								zos.putNextEntry(zipEntry);
-								//读取待压缩的文件并写进压缩包里
-								fis = new FileInputStream(file);
-								bis = new BufferedInputStream(fis, 1024 * 10);
-								int read = 0;
-								while ((read = bis.read(bufs, 0, 1024 * 10)) != -1) {
-									zos.write(bufs, 0, read);
-								}
-								zos.flush();
-							}catch(Exception e){
-								e.printStackTrace();
-							}finally{
-								IOUtils.closeQuietly(bis);
-								IOUtils.closeQuietly(fis);
-							}
-						}
-						flag = true;
-					}
-				}
-			} catch (Exception e) {
-				e.printStackTrace();
-			} finally {
-				IOUtils.closeQuietly(bis);
-				IOUtils.closeQuietly(fis);
-				IOUtils.closeQuietly(zos);
-				IOUtils.closeQuietly(fos);
-			}
-		}
-		logger.info("压缩"+sourceFilePath+"目录完成");
-		return flag;
-	}
-	
-	public static void createDirectory(String downloadDirectory) {
-		File directory = new File(downloadDirectory);
-		if(!directory.exists()){
-			directory.mkdirs();
-		}else{
-			FileUtils.deleteQuietly(directory);
-			directory.mkdirs();
-		}
-	}
-	
-	public static void main(String[] args) throws UnsupportedEncodingException {
+    private static final Logger logger = LoggerFactory.getLogger(FileDisposeUtil.class);
+
+    /**
+     * 将网络文件保存到本地
+     *
+     * @param fileUrl       网络文件URL
+     * @param localFilePath 例如D:/123.txt
+     * @return
+     */
+    public static boolean saveUrlAs(String fileUrl, String localFilePath) {
+        HttpURLConnection connection = null;
+        FileOutputStream fileOutputStream = null;
+        DataOutputStream dataOutputStream = null;
+        DataInputStream dataInputStream = null;
+        try {
+            URL url = new URL(fileUrl);
+            connection = (HttpURLConnection) url.openConnection();
+            dataInputStream = new DataInputStream(connection.getInputStream());
+            fileOutputStream = new FileOutputStream(localFilePath);
+            dataOutputStream = new DataOutputStream(fileOutputStream);
+            byte[] buffer = new byte[4096];
+            int count = 0;
+            while ((count = dataInputStream.read(buffer)) > 0) {
+                dataOutputStream.write(buffer, 0, count);
+            }
+            return true;
+        } catch (Exception e) {
+            return false;
+        } finally {
+            try {
+                if (fileOutputStream != null) {
+                    fileOutputStream.flush();
+                    fileOutputStream.close();
+                    fileOutputStream = null;
+                }
+                if (dataOutputStream != null) {
+                    dataOutputStream.flush();
+                    dataOutputStream.close();
+                    dataOutputStream = null;
+                }
+                if (dataInputStream != null) {
+                    dataInputStream.close();
+                    dataInputStream = null;
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+            if (connection != null) {
+                connection.disconnect();
+                connection = null;
+            }
+        }
+    }
+
+    /**
+     * 下载服务器上的文件
+     *
+     * @param filename     文件名称
+     * @param fullFilePath 文件全路径
+     * @param response
+     */
+    public static void downloadFile(String filename, String fullFilePath, HttpServletResponse response) {
+        InputStream in = null;
+        OutputStream out = null;
+        try {
+            //设置编码
+            response.setCharacterEncoding("UTF-8");
+            //设置文件MIME类型
+            response.setContentType(getContentType(filename));
+            //设置Content-Disposition,名称强制为UTF-8
+            //String fileEncode = System.getProperty("file.encoding");
+            //response.setHeader("Content-Disposition", "attachment;filename="+new String(filename.getBytes(fileEncode),"UTF-8"));
+            //response.setHeader("Content-Disposition", "attachment;filename="+URLEncoder.encode(filename,"UTF-8"));
+            response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8")
+                    .replace("%28", "(")
+                    .replace("%29", ")"));
+            // 设置强制下载不打开
+            response.setContentType("application/octet-stream;charset=utf-8");
+            //读取目标文件,通过response将目标文件写到客户端
+            //获取目标文件的绝对路径
+            //读取文件
+            in = new FileInputStream(fullFilePath);
+            out = response.getOutputStream();
+            //写文件
+            byte[] buffer = new byte[4096];
+            int count = 0;
+            while ((count = in.read(buffer)) > 0) {
+                out.write(buffer, 0, count);
+            }
+            response.flushBuffer();
+            out.close();
+            in.close();
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                if (null != out) {
+                    out.close();
+                    out = null;
+                }
+                if (null != in) {
+                    in.close();
+                    in = null;
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+                throw new RuntimeException(e);
+            }
+        }
+
+    }
+
+    /**
+     * 获得文件MIME类型
+     *
+     * @param filename
+     * @return
+     */
+    public static String getContentType(String filename) {
+        String type = null;
+        Path path = Paths.get(filename);
+        try {
+            type = Files.probeContentType(path);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return type;
+    }
+
+    /**
+     * 将存放在sourceFilePath目录下的源文件,打包成fileName名称的zip文件,并存放到zipFilePath路径下
+     *
+     * @param sourceFilePath :待压缩的文件夹路径
+     * @param zipFilePath    :压缩后zip文件的存放路径
+     * @param fileName       :zip文件的名称
+     * @return
+     */
+    public static boolean fileToZip(String sourceFilePath, String zipFilePath, String fileName) {
+        logger.info("压缩" + sourceFilePath + "目录开始");
+        boolean flag = false;
+        File sourceFile = new File(sourceFilePath);
+        FileInputStream fis = null;
+        BufferedInputStream bis = null;
+        FileOutputStream fos = null;
+        ZipOutputStream zos = null;
+        if (sourceFile.exists() == false) {
+            logger.error("待压缩的文件目录:" + sourceFilePath + "不存在.");
+        } else {
+            try {
+                File zipFile = new File(zipFilePath + File.separator + fileName + ".zip");
+                if (zipFile.exists()) {
+                    logger.error(zipFilePath + "目录下存在名字为:" + fileName + ".zip" + "打包文件.");
+                } else {
+                    File[] sourceFiles = sourceFile.listFiles();
+                    if (null == sourceFiles || sourceFiles.length < 1) {
+                        logger.error("待压缩的文件目录:" + sourceFilePath + "里面不存在文件,无需压缩.");
+                    } else {
+                        fos = new FileOutputStream(zipFile);
+                        zos = new ZipOutputStream(new BufferedOutputStream(fos));
+                        byte[] bufs = new byte[1024 * 10];
+                        for (int i = 0; i < sourceFiles.length; i++) {
+                            File file = sourceFiles[i];
+                            if (!file.isFile()) {
+                                continue;
+                            }
+                            try {
+                                //创建ZIP实体,并添加进压缩包
+                                String fileEncode = System.getProperty("file.encoding");
+                                String name = new String(file.getName().getBytes(fileEncode), "UTF-8");
+                                ZipEntry zipEntry = new ZipEntry(name);
+                                zos.putNextEntry(zipEntry);
+                                //读取待压缩的文件并写进压缩包里
+                                fis = new FileInputStream(file);
+                                bis = new BufferedInputStream(fis, 1024 * 10);
+                                int read = 0;
+                                while ((read = bis.read(bufs, 0, 1024 * 10)) != -1) {
+                                    zos.write(bufs, 0, read);
+                                }
+                                zos.flush();
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            } finally {
+                                IOUtils.closeQuietly(bis);
+                                IOUtils.closeQuietly(fis);
+                            }
+                        }
+                        flag = true;
+                    }
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            } finally {
+                IOUtils.closeQuietly(bis);
+                IOUtils.closeQuietly(fis);
+                IOUtils.closeQuietly(zos);
+                IOUtils.closeQuietly(fos);
+            }
+        }
+        logger.info("压缩" + sourceFilePath + "目录完成");
+        return flag;
+    }
+
+    public static void createDirectory(String downloadDirectory) {
+        File directory = new File(downloadDirectory);
+        if (!directory.exists()) {
+            directory.mkdirs();
+        } else {
+            FileUtils.deleteQuietly(directory);
+            directory.mkdirs();
+        }
+    }
+
+    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", ")"));
-	}
+        String fileName = "梦想(2)";
+
+        System.out.println(URLEncoder.encode(fileName, "UTF-8")
+                .replace("%28", "(")
+                .replace("%29", ")"));
+    }
 }

+ 15 - 11
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/SpringContextUtils.java

@@ -13,46 +13,50 @@ import org.springframework.stereotype.Component;
 @Component
 public class SpringContextUtils implements ApplicationContextAware {
     private static ApplicationContext applicationContext;
- 
+
     public void setApplicationContext(ApplicationContext arg0)
             throws BeansException {
         applicationContext = arg0;
     }
- 
+
     /**
      * 获取applicationContext对象
+     *
      * @return
      */
-    public static ApplicationContext getApplicationContext(){
+    public static ApplicationContext getApplicationContext() {
         return applicationContext;
     }
-     
+
     /**
      * 根据bean的id来查找对象
+     *
      * @param id
      * @return
      */
-    public static Object getBeanById(String id){
+    public static Object getBeanById(String id) {
         return applicationContext.getBean(id);
     }
-     
+
     /**
      * 根据bean的class来查找对象
+     *
      * @param c
      * @return
      */
-    @SuppressWarnings({ "unchecked", "rawtypes" })
-	public static Object getBeanByClass(Class c){
+    @SuppressWarnings({"unchecked", "rawtypes"})
+    public static Object getBeanByClass(Class c) {
         return applicationContext.getBean(c);
     }
-     
+
     /**
      * 根据bean的class来查找所有的对象(包括子类)
+     *
      * @param c
      * @return
      */
-    @SuppressWarnings({ "unchecked", "rawtypes" })
-	public static Map getBeansByClass(Class c){
+    @SuppressWarnings({"unchecked", "rawtypes"})
+    public static Map getBeansByClass(Class c) {
         return applicationContext.getBeansOfType(c);
     }
 }

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

@@ -16,7 +16,7 @@ import org.apache.commons.lang3.StringUtils;
 
 /**
  * 计算相似度工具包:
- * 
+ *
  * @author songyue
  * @date 2016-05-11
  */
@@ -24,7 +24,7 @@ public class StringSimilarityUtils {
 
     /**
      * 对输入字符串分词
-     * 
+     *
      * @param str
      * @return ArrayList
      * @author songyue
@@ -34,7 +34,7 @@ public class StringSimilarityUtils {
         Result result = ToAnalysis.parse(str);
         List<Term> terms = result.getTerms();
         for (Term term : terms) {
-            if(StringUtils.isNotEmpty(term.getName().trim())){
+            if (StringUtils.isNotEmpty(term.getName().trim())) {
                 segResult.add(term.getName());
             }
         }
@@ -43,7 +43,7 @@ public class StringSimilarityUtils {
 
     /**
      * 计算相似度(两个分词集合,分词匹配,算法为余弦定理)
-     * 
+     *
      * @param seg1
      * @param seg2
      * @return
@@ -108,7 +108,7 @@ public class StringSimilarityUtils {
 
     /**
      * 计算相似度(两个字符串,全字匹配,算法为余弦定理)
-     * 
+     *
      * @param w1
      * @param w2
      * @return
@@ -167,7 +167,7 @@ public class StringSimilarityUtils {
 
     /**
      * 计算相似度(两个字符串,采用优化Dice算法)
-     * 
+     *
      * @param w1
      * @param w2
      * @return
@@ -225,7 +225,7 @@ public class StringSimilarityUtils {
 
     /**
      * 计算相似度(两个字符串,采用一般Dice算法)
-     * 
+     *
      * @param w1
      * @param w2
      * @return
@@ -267,7 +267,7 @@ public class StringSimilarityUtils {
 
     /**
      * 过滤特殊字符
-     * 
+     *
      * @param str
      * @return
      */

+ 12 - 11
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/ZipUtils.java

@@ -8,37 +8,38 @@ import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
 
 public class ZipUtils {
-	public static void doCompress(String srcFile, String zipFile) throws Exception {
+    public static void doCompress(String srcFile, String zipFile) throws Exception {
         doCompress(new File(srcFile), new File(zipFile));
     }
-    
+
     /**
      * 文件压缩
+     *
      * @param srcFile  目录或者单个文件
      * @param destFile 压缩后的ZIP文件
      */
     public static void doCompress(File srcFile, File destFile) throws Exception {
         ZipOutputStream out = new ZipOutputStream(new FileOutputStream(destFile));
-        if(srcFile.isDirectory()){
+        if (srcFile.isDirectory()) {
             File[] files = srcFile.listFiles();
-            for(File file : files){
+            for (File file : files) {
                 doCompress(file, out);
             }
-        }else {
+        } else {
             doCompress(srcFile, out);
         }
     }
-    
-    public static void doCompress(String pathname, ZipOutputStream out) throws IOException{
+
+    public static void doCompress(String pathname, ZipOutputStream out) throws IOException {
         doCompress(new File(pathname), out);
     }
-    
-    public static void doCompress(File file, ZipOutputStream out) throws IOException{
-        if( file.exists() ){
+
+    public static void doCompress(File file, ZipOutputStream out) throws IOException {
+        if (file.exists()) {
             byte[] buffer = new byte[1024];
             FileInputStream fis = new FileInputStream(file);
             out.putNextEntry(new ZipEntry(file.getName()));
-            int len = 0 ;
+            int len = 0;
             // 读取文件的内容,打包到zip文件    
             while ((len = fis.read(buffer)) > 0) {
                 out.write(buffer, 0, len);

+ 67 - 67
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/core/CourseSpeciatly.java

@@ -4,71 +4,71 @@ import java.io.Serializable;
 import java.util.Date;
 
 
-public class CourseSpeciatly implements Serializable{
-
-	private static final long serialVersionUID = -250814769612993025L;
-	
-	private Long id;
-	
-	private Long courseId;
-	
-	private Long specialtyId;
-	
-	private Long creator;
-	
-	private Date createTime;
-
-	private Date updateTime;
-
-	public Long getId() {
-		return id;
-	}
-
-	public void setId(Long id) {
-		this.id = id;
-	}
-
-	public Long getCourseId() {
-		return courseId;
-	}
-
-	public void setCourseId(Long courseId) {
-		this.courseId = courseId;
-	}
-
-	public Long getSpecialtyId() {
-		return specialtyId;
-	}
-
-	public void setSpecialtyId(Long specialtyId) {
-		this.specialtyId = specialtyId;
-	}
-
-	public Date getCreateTime() {
-		return createTime;
-	}
-
-	public void setCreateTime(Date createTime) {
-		this.createTime = createTime;
-	}
-
-	public Date getUpdateTime() {
-		return updateTime;
-	}
-
-	public Long getCreator() {
-		return creator;
-	}
-
-	public void setCreator(Long creator) {
-		this.creator = creator;
-	}
-
-	public void setUpdateTime(Date updateTime) {
-		this.updateTime = updateTime;
-	}
-
-	public static long getSerialversionuid() {
-		return serialVersionUID;
-	}
+public class CourseSpeciatly implements Serializable {
+
+    private static final long serialVersionUID = -250814769612993025L;
+
+    private Long id;
+
+    private Long courseId;
+
+    private Long specialtyId;
+
+    private Long creator;
+
+    private Date createTime;
+
+    private Date updateTime;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getCourseId() {
+        return courseId;
+    }
+
+    public void setCourseId(Long courseId) {
+        this.courseId = courseId;
+    }
+
+    public Long getSpecialtyId() {
+        return specialtyId;
+    }
+
+    public void setSpecialtyId(Long specialtyId) {
+        this.specialtyId = specialtyId;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public Long getCreator() {
+        return creator;
+    }
+
+    public void setCreator(Long creator) {
+        this.creator = creator;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public static long getSerialversionuid() {
+        return serialVersionUID;
+    }
 }

+ 57 - 57
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/core/CourseSync.java

@@ -7,86 +7,86 @@ import java.io.Serializable;
  */
 public class CourseSync implements Serializable {
 
-	private static final long serialVersionUID = 8986880538637117108L;
+    private static final long serialVersionUID = 8986880538637117108L;
 
-	private Long id;
+    private Long id;
 
-	private String code;
+    private String code;
 
-	private String name;
+    private String name;
 
-	private Long orgId;
+    private Long orgId;
 
-	private String level;
+    private String level;
 
-	private String createTime;
+    private String createTime;
 
-	private String updateTime;
+    private String updateTime;
 
-	private Boolean enable;
+    private Boolean enable;
 
-	public Long getId() {
-		return id;
-	}
+    public Long getId() {
+        return id;
+    }
 
-	public void setId(Long id) {
-		this.id = id;
-	}
+    public void setId(Long id) {
+        this.id = id;
+    }
 
-	public String getCode() {
-		return code;
-	}
+    public String getCode() {
+        return code;
+    }
 
-	public void setCode(String code) {
-		this.code = code;
-	}
+    public void setCode(String code) {
+        this.code = code;
+    }
 
-	public String getName() {
-		return name;
-	}
+    public String getName() {
+        return name;
+    }
 
-	public void setName(String name) {
-		this.name = name;
-	}
+    public void setName(String name) {
+        this.name = name;
+    }
 
-	public Long getOrgId() {
-		return orgId;
-	}
+    public Long getOrgId() {
+        return orgId;
+    }
 
-	public void setOrgId(Long orgId) {
-		this.orgId = orgId;
-	}
+    public void setOrgId(Long orgId) {
+        this.orgId = orgId;
+    }
 
-	public String getLevel() {
-		return level;
-	}
+    public String getLevel() {
+        return level;
+    }
 
-	public void setLevel(String level) {
-		this.level = level;
-	}
+    public void setLevel(String level) {
+        this.level = level;
+    }
 
-	public String getCreateTime() {
-		return createTime;
-	}
+    public String getCreateTime() {
+        return createTime;
+    }
 
-	public void setCreateTime(String createTime) {
-		this.createTime = createTime;
-	}
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
 
-	public String getUpdateTime() {
-		return updateTime;
-	}
+    public String getUpdateTime() {
+        return updateTime;
+    }
 
-	public void setUpdateTime(String updateTime) {
-		this.updateTime = updateTime;
-	}
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
 
-	public Boolean getEnable() {
-		return enable;
-	}
+    public Boolean getEnable() {
+        return enable;
+    }
 
-	public void setEnable(Boolean enable) {
-		this.enable = enable;
-	}
+    public void setEnable(Boolean enable) {
+        this.enable = enable;
+    }
 
 }

+ 56 - 46
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/core/ExamCourseDto.java

@@ -3,58 +3,68 @@ package cn.com.qmth.examcloud.core.questions.base.core;
 import cn.com.qmth.examcloud.core.questions.base.em.enums.ExamType;
 
 /**
- * @author  	chenken
- * @date    	2017720日 上午9:49:03
- * @company 	QMTH
+ * @author chenken
+ * @date 2017720日 上午9:49:03
+ * @company QMTH
  * @description ExamCourseDto.java
  */
 public class ExamCourseDto {
-	private Long examId;
+    private Long examId;
     private String examName;
     private ExamType examType;
     private String courseName;
     private String courseCode;
-	private Long orgId;
-    
-    public ExamCourseDto(){}
-    
-	public Long getExamId() {
-		return examId;
-	}
-	public void setExamId(Long examId) {
-		this.examId = examId;
-	}
-	public String getExamName() {
-		return examName;
-	}
-	public void setExamName(String examName) {
-		this.examName = examName;
-	}
-	public ExamType getExamType() {
-		return examType;
-	}
-	public void setExamType(ExamType examType) {
-		this.examType = examType;
-	}
-	public String getCourseName() {
-		return courseName;
-	}
-	public void setCourseName(String courseName) {
-		this.courseName = courseName;
-	}
-	public String getCourseCode() {
-		return courseCode;
-	}
-	public void setCourseCode(String courseCode) {
-		this.courseCode = courseCode;
-	}
-
-	public Long getOrgId() {
-		return orgId;
-	}
-
-	public void setOrgId(Long orgId) {
-		this.orgId = orgId;
-	}
+    private Long orgId;
+
+    public ExamCourseDto() {
+    }
+
+    public Long getExamId() {
+        return examId;
+    }
+
+    public void setExamId(Long examId) {
+        this.examId = examId;
+    }
+
+    public String getExamName() {
+        return examName;
+    }
+
+    public void setExamName(String examName) {
+        this.examName = examName;
+    }
+
+    public ExamType getExamType() {
+        return examType;
+    }
+
+    public void setExamType(ExamType examType) {
+        this.examType = examType;
+    }
+
+    public String getCourseName() {
+        return courseName;
+    }
+
+    public void setCourseName(String courseName) {
+        this.courseName = courseName;
+    }
+
+    public String getCourseCode() {
+        return courseCode;
+    }
+
+    public void setCourseCode(String courseCode) {
+        this.courseCode = courseCode;
+    }
+
+    public Long getOrgId() {
+        return orgId;
+    }
+
+    public void setOrgId(Long orgId) {
+        this.orgId = orgId;
+    }
 }
 

+ 52 - 52
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/core/enums/CourseLevel.java

@@ -2,56 +2,56 @@ package cn.com.qmth.examcloud.core.questions.base.core.enums;
 
 public enum CourseLevel {
 
-	ZSB("专升本", "Z"),
-
-	GQZ("高起专", "Q"),
-
-	GQB("高起本", "S"),
-
-	ALL("不限", "");
-
-	/**
-	 * 名称
-	 */
-	private String name;
-
-	/**
-	 * 简写
-	 */
-	private String abbreviate;
-
-	private CourseLevel(String name, String abbreviate) {
-		this.name = name;
-		this.abbreviate = abbreviate;
-	}
-
-	public String getName() {
-		return this.name;
-	}
-
-	public String getAbbreviate() {
-		return abbreviate;
-	}
-
-	/**
-	 * 混合查询
-	 *
-	 * @author WANGWEI
-	 * @param name
-	 * @return
-	 */
-	public static CourseLevel getCourseLevel(String name) {
-		if (null == name) {
-			return CourseLevel.ALL;
-		}
-		for (CourseLevel cur : CourseLevel.values()) {
-			if (name.equals(cur.getName())) {
-				return cur;
-			}
-			if (name.equals(cur.name())) {
-				return cur;
-			}
-		}
-		return CourseLevel.ALL;
-	}
+    ZSB("专升本", "Z"),
+
+    GQZ("高起专", "Q"),
+
+    GQB("高起本", "S"),
+
+    ALL("不限", "");
+
+    /**
+     * 名称
+     */
+    private String name;
+
+    /**
+     * 简写
+     */
+    private String abbreviate;
+
+    private CourseLevel(String name, String abbreviate) {
+        this.name = name;
+        this.abbreviate = abbreviate;
+    }
+
+    public String getName() {
+        return this.name;
+    }
+
+    public String getAbbreviate() {
+        return abbreviate;
+    }
+
+    /**
+     * 混合查询
+     *
+     * @param name
+     * @return
+     * @author WANGWEI
+     */
+    public static CourseLevel getCourseLevel(String name) {
+        if (null == name) {
+            return CourseLevel.ALL;
+        }
+        for (CourseLevel cur : CourseLevel.values()) {
+            if (name.equals(cur.getName())) {
+                return cur;
+            }
+            if (name.equals(cur.name())) {
+                return cur;
+            }
+        }
+        return CourseLevel.ALL;
+    }
 }

+ 12 - 11
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/enums/AudioPositionType.java

@@ -1,18 +1,19 @@
 package cn.com.qmth.examcloud.core.questions.base.enums;
+
 /**
- * @author  	chenken
- * @date    	201782日 下午1:53:30
- * @company 	QMTH
+ * @author chenken
+ * @date 201782日 下午1:53:30
+ * @company QMTH
  * @description AudioPositionType.java
  */
 public enum AudioPositionType {
-	/**
-	 * 题干
-	 */
-	QUESTION_BODY,
-	/**
-	 * 选项
-	 */
-	QUESTION_OPTION
+    /**
+     * 题干
+     */
+    QUESTION_BODY,
+    /**
+     * 选项
+     */
+    QUESTION_OPTION
 }
 

+ 28 - 27
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/enums/ExportType.java

@@ -1,34 +1,35 @@
 package cn.com.qmth.examcloud.core.questions.base.enums;
+
 /**
- * @author  	chenken
- * @date    	2017718日 上午10:21:48
- * @company 	QMTH
+ * @author chenken
+ * @date 2017718日 上午10:21:48
+ * @company QMTH
  * @description 试卷导出类型
  */
 public enum ExportType {
-	
-	/**
-	 * 机考
-	 */
-	ONLINE("机考"),
-	
-	/**
-	 * 普通
-	 */
-	NORMAL("普通");
-	
-	private String name;
-
-	public String getName() {
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-	
-	private ExportType(String name){
-		this.name = name;
-	}
+
+    /**
+     * 机考
+     */
+    ONLINE("机考"),
+
+    /**
+     * 普通
+     */
+    NORMAL("普通");
+
+    private String name;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    private ExportType(String name) {
+        this.name = name;
+    }
 }
 

+ 19 - 19
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/enums/ExportWay.java

@@ -1,28 +1,28 @@
 package cn.com.qmth.examcloud.core.questions.base.enums;
 
 /**
- * @author  	chenken
- * @date    	2017720日 上午8:59:58
- * @company 	QMTH
+ * @author chenken
+ * @date 2017720日 上午8:59:58
+ * @company QMTH
  * @description ExportWay.java
  */
 public enum ExportWay {
-	/**
-	 * 批量导出
-	 */
-	BATCH,
-	/**
-	 * 单独导出
-	 */
-	SINGLE;
-	
-	public static ExportWay strToEnum(String str){
-    	for(ExportWay exportWay:ExportWay.values()){
-    		if(exportWay.name().equals(str)){
-    			return exportWay;
-    		}
-    	}
-    	return null;
+    /**
+     * 批量导出
+     */
+    BATCH,
+    /**
+     * 单独导出
+     */
+    SINGLE;
+
+    public static ExportWay strToEnum(String str) {
+        for (ExportWay exportWay : ExportWay.values()) {
+            if (exportWay.name().equals(str)) {
+                return exportWay;
+            }
+        }
+        return null;
     }
 }
 

+ 32 - 30
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/enums/ExtractPolicy.java

@@ -1,35 +1,37 @@
 package cn.com.qmth.examcloud.core.questions.base.enums;
 
 public enum ExtractPolicy {
-	
-	RANDOM_POLICY("RANDOM_PAPER","随机抽卷");
-	
-	private String key;
-	private String value;
-	
-	
-	
-	private ExtractPolicy(String key, String value) {
-		this.key = key;
-		this.value = value;
-	}
-	
-	private ExtractPolicy(){
-		
-	}
-	public String getKey() {
-		return key;
-	}
-	public void setKey(String key) {
-		this.key = key;
-	}
-	public String getValue() {
-		return value;
-	}
-	public void setValue(String value) {
-		this.value = value;
-	}
-	
-	
+
+    RANDOM_POLICY("RANDOM_PAPER", "随机抽卷");
+
+    private String key;
+    private String value;
+
+
+    private ExtractPolicy(String key, String value) {
+        this.key = key;
+        this.value = value;
+    }
+
+    private ExtractPolicy() {
+
+    }
+
+    public String getKey() {
+        return key;
+    }
+
+    public void setKey(String key) {
+        this.key = key;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
 
 }

+ 31 - 30
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/enums/GenPaperExpression.java

@@ -1,42 +1,43 @@
 package cn.com.qmth.examcloud.core.questions.base.enums;
 
 public enum GenPaperExpression {
-	EQUAL(1L,"等于"),
-	NOT_EQUAL(2L,"不等于"),
-	LESS(3L,"小于"),
-	LESS_EQUAL(4L,"小于等于"),
-	GREATER(5L,"大于"),
-	GREATER_EQUAL(6L,"大于等于");
-	
+    EQUAL(1L, "等于"),
+    NOT_EQUAL(2L, "不等于"),
+    LESS(3L, "小于"),
+    LESS_EQUAL(4L, "小于等于"),
+    GREATER(5L, "大于"),
+    GREATER_EQUAL(6L, "大于等于");
+
     private Long key;
     private String name;
-    
-    
+
+
     private GenPaperExpression(Long key, String name) {
-		this.key = key;
-		this.name = name;
-	}
-    
-    private  GenPaperExpression(){
-    	
+        this.key = key;
+        this.name = name;
+    }
+
+    private GenPaperExpression() {
+
+    }
+
+    public Long getKey() {
+        return key;
+    }
+
+
+    public void setKey(Long key) {
+        this.key = key;
     }
-    
-	public Long getKey() {
-		return key;
-	}
 
 
-	public void setKey(Long key) {
-		this.key = key;
-	}
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
 
 
-	public String getName() {
-		return name;
-	}
-	public void setName(String name) {
-		this.name = name;
-	}
-    
-    
 }

+ 28 - 24
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/enums/GenPaperFunction.java

@@ -1,29 +1,33 @@
 package cn.com.qmth.examcloud.core.questions.base.enums;
 
 public enum GenPaperFunction {
-	SUM(1L,"求和"),
-	RATIO(2L,"比例");
-	
-	private Long key;
+    SUM(1L, "求和"),
+    RATIO(2L, "比例");
+
+    private Long key;
     private String name;
-    
-    
-	private GenPaperFunction(Long key, String name) {
-		this.key = key;
-		this.name = name;
-	}
-	public Long getKey() {
-		return key;
-	}
-	public void setKey(Long key) {
-		this.key = key;
-	}
-	public String getName() {
-		return name;
-	}
-	public void setName(String name) {
-		this.name = name;
-	}
-
-    
+
+
+    private GenPaperFunction(Long key, String name) {
+        this.key = key;
+        this.name = name;
+    }
+
+    public Long getKey() {
+        return key;
+    }
+
+    public void setKey(Long key) {
+        this.key = key;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+
 }

+ 28 - 28
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/enums/GenPaperType.java

@@ -2,32 +2,32 @@ package cn.com.qmth.examcloud.core.questions.base.enums;
 
 public enum GenPaperType {
 
-	/**
-	 * 细节组卷
-	 */
-	SPECIFIC("细节"),
-	
-	/**
-	 * 宏观
-	 */
-	ENSEMBLE("宏观"),
-	
-	/**
-	 * 普通组卷
-	 */
-	COMMON("普通组卷");
-	
-	private String name;
-
-	public String getName() {
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-	
-	private GenPaperType(String name){
-		this.name = name;
-	}
+    /**
+     * 细节组卷
+     */
+    SPECIFIC("细节"),
+
+    /**
+     * 宏观
+     */
+    ENSEMBLE("宏观"),
+
+    /**
+     * 普通组卷
+     */
+    COMMON("普通组卷");
+
+    private String name;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    private GenPaperType(String name) {
+        this.name = name;
+    }
 }

+ 8 - 6
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/enums/PaperStatus.java

@@ -5,18 +5,20 @@ package cn.com.qmth.examcloud.core.questions.base.enums;
  */
 public enum PaperStatus {
 
-    DRAFT(1L,"待审核"),
-    PASS(2L,"通过"),
-    NOPASS(3L,"不通过");
+    DRAFT(1L, "待审核"),
+    PASS(2L, "通过"),
+    NOPASS(3L, "不通过");
 
     private Long id;
     private String name;
+
     private PaperStatus(Long id, String name) {
         this.id = id;
-        this.name = name;;
+        this.name = name;
+        ;
     }
 
-    private PaperStatus(){
+    private PaperStatus() {
 
     }
 
@@ -36,7 +38,7 @@ public enum PaperStatus {
         this.name = name;
     }
 
-    public String toString(){
+    public String toString() {
         return getName();
     }
 }

+ 38 - 38
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/enums/PaperStructType.java

@@ -3,47 +3,47 @@ package cn.com.qmth.examcloud.core.questions.base.enums;
 import org.omg.CORBA.PRIVATE_MEMBER;
 
 /**
- * @describle 试卷结构类型
  * @author weiwenhai
- * @date  2017.12.11
+ * @describle 试卷结构类型
+ * @date 2017.12.11
  */
 public enum PaperStructType {
 
-	/**
-	 * 简易组卷
-	 */
-	SIMPLE("简易组卷"),
-
-	/**
-	 * 精确组卷
-	 */
-	EXACT("精确组卷"),
-	
-	/**
-	 * 蓝图组卷
-	 */
-	BLUEPRINT("蓝图组卷");
-	
-	private String name;
-
-	public String getName() {
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-	
-	private PaperStructType(String name){
-		this.name = name;
-	}
-	
-	public static PaperStructType strToEnum(String str){
-    	for(PaperStructType paperStructType:PaperStructType.values()){
-    		if(paperStructType.name().equals(str)){
-    			return paperStructType;
-    		}
-    	}
-    	return null;
+    /**
+     * 简易组卷
+     */
+    SIMPLE("简易组卷"),
+
+    /**
+     * 精确组卷
+     */
+    EXACT("精确组卷"),
+
+    /**
+     * 蓝图组卷
+     */
+    BLUEPRINT("蓝图组卷");
+
+    private String name;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    private PaperStructType(String name) {
+        this.name = name;
+    }
+
+    public static PaperStructType strToEnum(String str) {
+        for (PaperStructType paperStructType : PaperStructType.values()) {
+            if (paperStructType.name().equals(str)) {
+                return paperStructType;
+            }
+        }
+        return null;
     }
 }

+ 11 - 10
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/enums/PaperType.java

@@ -4,22 +4,22 @@ package cn.com.qmth.examcloud.core.questions.base.enums;
  * Created by songyue on 17/3/15.
  */
 public enum PaperType {
-	/**
-	 * 导入
-	 */
-    IMPORT(1L,"导入"),
+    /**
+     * 导入
+     */
+    IMPORT(1L, "导入"),
     /**
      * 组卷
      */
-    GENERATE(2L,"组卷"),
+    GENERATE(2L, "组卷"),
     /**
      * 调卷规则预览卷
      */
-    PREVIEW(3L,"调卷规则预览卷"),
+    PREVIEW(3L, "调卷规则预览卷"),
     /**
      * 考生考卷
      */
-    STUDENT_EXAM(4L,"考生考卷");
+    STUDENT_EXAM(4L, "考生考卷");
 
 
     private Long id;
@@ -27,10 +27,11 @@ public enum PaperType {
 
     private PaperType(Long id, String name) {
         this.id = id;
-        this.name = name;;
+        this.name = name;
+        ;
     }
 
-    private PaperType(){
+    private PaperType() {
 
     }
 
@@ -50,7 +51,7 @@ public enum PaperType {
         this.name = name;
     }
 
-    public String toString(){
+    public String toString() {
         return getName();
     }
 }

+ 45 - 45
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/enums/PropertyDifficulty.java

@@ -2,51 +2,51 @@ package cn.com.qmth.examcloud.core.questions.base.enums;
 
 public enum PropertyDifficulty {
 
-	/*
-	 * 简单
-	 */
-	SIMPLE(1L,"简单"),
-	
-	/**
-	 * 中等
-	 */
-	MEDIUM(2L,"中等"),
-	
-	/**
-	 * 困难
-	 */
-	DIFFICULTY(3L,"困难");
-	
-	private Long id;
-	
-	private String name;
-	
-	private PropertyDifficulty(){
-		
-	}
-	
-	PropertyDifficulty(Long id, String name){
-		this.id = id;
-		this.name = name;
-	}
-
-	public Long getId() {
-		return id;
-	}
-
-	public void setId(Long id) {
-		this.id = id;
-	}
-
-	public String getName() {
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-	
-	public String toString(){
+    /*
+     * 简单
+     */
+    SIMPLE(1L, "简单"),
+
+    /**
+     * 中等
+     */
+    MEDIUM(2L, "中等"),
+
+    /**
+     * 困难
+     */
+    DIFFICULTY(3L, "困难");
+
+    private Long id;
+
+    private String name;
+
+    private PropertyDifficulty() {
+
+    }
+
+    PropertyDifficulty(Long id, String name) {
+        this.id = id;
+        this.name = name;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String toString() {
         return getName();
     }
 }

+ 7 - 6
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/enums/QuesUnit.java

@@ -5,9 +5,9 @@ package cn.com.qmth.examcloud.core.questions.base.enums;
  */
 public enum QuesUnit {
 
-    QUES_BODY(1L,"题干"),
-    QUES_OPTION(2L,"选项"),
-    QUES_ANSWER(3L,"答案");
+    QUES_BODY(1L, "题干"),
+    QUES_OPTION(2L, "选项"),
+    QUES_ANSWER(3L, "答案");
 
 
     private Long id;
@@ -15,10 +15,11 @@ public enum QuesUnit {
 
     private QuesUnit(Long id, String name) {
         this.id = id;
-        this.name = name;;
+        this.name = name;
+        ;
     }
 
-    private QuesUnit(){
+    private QuesUnit() {
 
     }
 
@@ -38,7 +39,7 @@ public enum QuesUnit {
         this.name = name;
     }
 
-    public String toString(){
+    public String toString() {
         return getName();
     }
 }

+ 32 - 31
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/enums/RandomGenPaperPolicy.java

@@ -1,35 +1,36 @@
 package cn.com.qmth.examcloud.core.questions.base.enums;
 
 public enum RandomGenPaperPolicy {
-	BY_QUESTIONNUM(1L,"按每套试卷需要抽取的试题数量来组卷"),
-	BY_SCORE(2L,"按每套试卷需要抽取的分数来组卷");
-	
-	private Long key;
-	private String value;
-	
-	
-	private RandomGenPaperPolicy(Long key, String value) {
-		this.key = key;
-		this.value = value;
-	}
-	
-	private RandomGenPaperPolicy(){
-		
-	}
-
-	public Long getKey() {
-		return key;
-	}
-
-	public void setKey(Long key) {
-		this.key = key;
-	}
-
-	public String getValue() {
-		return value;
-	}
-	public void setValue(String value) {
-		this.value = value;
-	}
-	
+    BY_QUESTIONNUM(1L, "按每套试卷需要抽取的试题数量来组卷"),
+    BY_SCORE(2L, "按每套试卷需要抽取的分数来组卷");
+
+    private Long key;
+    private String value;
+
+
+    private RandomGenPaperPolicy(Long key, String value) {
+        this.key = key;
+        this.value = value;
+    }
+
+    private RandomGenPaperPolicy() {
+
+    }
+
+    public Long getKey() {
+        return key;
+    }
+
+    public void setKey(Long key) {
+        this.key = key;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
 }

+ 6 - 5
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/enums/Switch.java

@@ -5,18 +5,19 @@ package cn.com.qmth.examcloud.core.questions.base.enums;
  */
 public enum Switch {
 
-    ON(1L,"开启"),
-    OFF(2L,"关闭");
+    ON(1L, "开启"),
+    OFF(2L, "关闭");
 
     private Long id;
     private String name;
 
     private Switch(Long id, String name) {
         this.id = id;
-        this.name = name;;
+        this.name = name;
+        ;
     }
 
-    private Switch(){
+    private Switch() {
 
     }
 
@@ -36,7 +37,7 @@ public enum Switch {
         this.name = name;
     }
 
-    public String toString(){
+    public String toString() {
         return getName();
     }
 }

+ 10 - 10
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/excel/ColumnSetting.java

@@ -9,7 +9,7 @@ public class ColumnSetting implements Comparable<ColumnSetting> {
     private int width;
     private int index;
 
-    public ColumnSetting(String header,String fieldName, int width, int index) {
+    public ColumnSetting(String header, String fieldName, int width, int index) {
         this.header = header;
         this.fieldName = fieldName;
         this.width = width;
@@ -41,19 +41,19 @@ public class ColumnSetting implements Comparable<ColumnSetting> {
     }
 
     public String getFieldName() {
-		return fieldName;
-	}
+        return fieldName;
+    }
 
-	public void setFieldName(String fieldName) {
-		this.fieldName = fieldName;
-	}
+    public void setFieldName(String fieldName) {
+        this.fieldName = fieldName;
+    }
 
-	@Override
+    @Override
     public int compareTo(ColumnSetting columnSetting) {
         if (index < columnSetting.getIndex())
-            return - 1 ;
+            return -1;
         if (index > columnSetting.getIndex())
-            return 1 ;
-        return 0 ;
+            return 1;
+        return 0;
     }
 }

+ 40 - 39
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/excel/ExcelError.java

@@ -1,48 +1,49 @@
 package cn.com.qmth.examcloud.core.questions.base.excel;
+
 /**
- * 
- * @Description: excel导入错误
  * @author ting.yin
+ * @Description: excel导入错误
  * @date 2016819
  */
 public class ExcelError {
 
-	/**
-	 * 错误行数
-	 */
-	private int row;
-
-	/**
-	 * 错误类型
-	 */
-	private String excelErrorType;
-
-	public ExcelError() {
-
-	}
-
-	public ExcelError(int row, String excelErrorType) {
-		this.row = row;
-		this.excelErrorType = excelErrorType;
-	}
-	
-	public ExcelError(String excelErrorType) {
-		this.excelErrorType = excelErrorType;
-	}
-	public int getRow() {
-		return row;
-	}
-
-	public void setRow(int row) {
-		this.row = row;
-	}
-
-	public String getExcelErrorType() {
-		return excelErrorType;
-	}
-
-	public void setExcelErrorType(String excelErrorType) {
-		this.excelErrorType = excelErrorType;
-	}
+    /**
+     * 错误行数
+     */
+    private int row;
+
+    /**
+     * 错误类型
+     */
+    private String excelErrorType;
+
+    public ExcelError() {
+
+    }
+
+    public ExcelError(int row, String excelErrorType) {
+        this.row = row;
+        this.excelErrorType = excelErrorType;
+    }
+
+    public ExcelError(String excelErrorType) {
+        this.excelErrorType = excelErrorType;
+    }
+
+    public int getRow() {
+        return row;
+    }
+
+    public void setRow(int row) {
+        this.row = row;
+    }
+
+    public String getExcelErrorType() {
+        return excelErrorType;
+    }
+
+    public void setExcelErrorType(String excelErrorType) {
+        this.excelErrorType = excelErrorType;
+    }
 
 }

+ 12 - 10
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/excel/ExcelProperty.java

@@ -8,19 +8,21 @@ import java.lang.annotation.Target;
 @Target(ElementType.FIELD)
 @Retention(RetentionPolicy.RUNTIME)
 public @interface ExcelProperty {
-	/**
-	 * 导出时列名
-	 */
+    /**
+     * 导出时列名
+     */
     String name() default "";
-    
-	/**
-	 * 导出时列宽
-	 */
+
+    /**
+     * 导出时列宽
+     */
     int width() default 0;
-	/**
-	 * 排序
-	 */
+
+    /**
+     * 排序
+     */
     int index();
+
     /**
      * 类型
      * 0:导入(读excel)

+ 114 - 118
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/excel/ExcelReader.java

@@ -24,153 +24,149 @@ import cn.com.qmth.examcloud.core.questions.base.excel.ExcelReaderHandle;
 import cn.com.qmth.examcloud.core.questions.base.excel.ExcelUtils;
 
 /**
- * 
- * @Description: 读取excel
  * @author ting.yin
+ * @Description: 读取excel
  * @date 2016819
  */
 public class ExcelReader extends ExcelUtils {
 
-	private static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-
-	public ExcelReader(Class<?> dataClass) {
-		super(dataClass, true);
-	}
-
-	/**
-	 * 
-	 * @param inputStream
-	 *            输入流
-	 * @param handle
-	 *            单个对象处理器
-	 * @return 错误信息集合
-	 */
-	public List<ExcelError> reader(InputStream inputStream, ExcelReaderHandle handle) {
-		List<ExcelError> excelErrors = new ArrayList<ExcelError>();
-		Workbook wb = null;
-		try {
-			wb = WorkbookFactory.create(inputStream);
-			Sheet sheet = wb.getSheetAt(0);
-			for (int i = 1; i <= sheet.getLastRowNum(); i++) {
-				Row row = sheet.getRow(i);
-				if (row == null) {
-					return excelErrors;
-				}
-				Object dto = getDataClass().newInstance();
-				for (int j = 0; j < this.getColumnSettings().size(); j++) {
-					ColumnSetting columnSetting = this.getColumnSettings().get(j);
-					Cell cell = row.getCell(columnSetting.getIndex());
-					Field field = getDataClass().getDeclaredField(columnSetting.getFieldName());
-					Object obj = convert(cell, field);
-					field.setAccessible(true);
-					field.set(dto, obj);
-				}
-				ExcelError error = handle.handle(dto);
-				if (error != null) {
-					error.setRow(i + 1);
-					excelErrors.add(error);
-				}
-			}
-		} catch (StatusException e) {
-			throw e;
-		} catch (Exception e) {
-			throw new StatusException("580", "EXCEL导入失败", e);
-		} finally {
-			IOUtils.closeQuietly(wb);
-			IOUtils.closeQuietly(inputStream);
-		}
-		return excelErrors;
-	}
+    private static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+    public ExcelReader(Class<?> dataClass) {
+        super(dataClass, true);
+    }
+
+    /**
+     * @param inputStream 输入流
+     * @param handle      单个对象处理器
+     * @return 错误信息集合
+     */
+    public List<ExcelError> reader(InputStream inputStream, ExcelReaderHandle handle) {
+        List<ExcelError> excelErrors = new ArrayList<ExcelError>();
+        Workbook wb = null;
+        try {
+            wb = WorkbookFactory.create(inputStream);
+            Sheet sheet = wb.getSheetAt(0);
+            for (int i = 1; i <= sheet.getLastRowNum(); i++) {
+                Row row = sheet.getRow(i);
+                if (row == null) {
+                    return excelErrors;
+                }
+                Object dto = getDataClass().newInstance();
+                for (int j = 0; j < this.getColumnSettings().size(); j++) {
+                    ColumnSetting columnSetting = this.getColumnSettings().get(j);
+                    Cell cell = row.getCell(columnSetting.getIndex());
+                    Field field = getDataClass().getDeclaredField(columnSetting.getFieldName());
+                    Object obj = convert(cell, field);
+                    field.setAccessible(true);
+                    field.set(dto, obj);
+                }
+                ExcelError error = handle.handle(dto);
+                if (error != null) {
+                    error.setRow(i + 1);
+                    excelErrors.add(error);
+                }
+            }
+        } catch (StatusException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new StatusException("580", "EXCEL导入失败", e);
+        } finally {
+            IOUtils.closeQuietly(wb);
+            IOUtils.closeQuietly(inputStream);
+        }
+        return excelErrors;
+    }
+
+    @SuppressWarnings("deprecation")
+    private Object convert(Cell cell, Field field) {
+        if (cell != null) {
+            switch (cell.getCellType()) {
+                case Cell.CELL_TYPE_STRING:
+                    return cell.getStringCellValue().toString();
+                case Cell.CELL_TYPE_BOOLEAN:
+                    return String.valueOf(cell.getBooleanCellValue());
+                case Cell.CELL_TYPE_NUMERIC:
+                    return processNumeric(cell, field);
+            }
+        }
+
+        return null;
+    }
+
+    private Object processNumeric(Cell cell, Field field) {
+
+        if (DateUtil.isCellDateFormatted(cell)) {
 
-	@SuppressWarnings("deprecation")
-	private Object convert(Cell cell, Field field) {
-		if (cell != null) {
-			switch (cell.getCellType()) {
-				case Cell.CELL_TYPE_STRING :
-					return cell.getStringCellValue().toString();
-				case Cell.CELL_TYPE_BOOLEAN :
-					return String.valueOf(cell.getBooleanCellValue());
-				case Cell.CELL_TYPE_NUMERIC :
-					return processNumeric(cell, field);
-			}
-		}
+            if (field.getType().isAssignableFrom(Date.class)) {
+                return cell.getDateCellValue();
+            } else {
+                return dateFormat.format(cell.getDateCellValue());
+            }
 
-		return null;
-	}
+        } else {
 
-	private Object processNumeric(Cell cell, Field field) {
+            if (field.getType().isAssignableFrom(Integer.class)) {
 
-		if (DateUtil.isCellDateFormatted(cell)) {
+                return (int) cell.getNumericCellValue();
 
-			if (field.getType().isAssignableFrom(Date.class)) {
-				return cell.getDateCellValue();
-			} else {
-				return dateFormat.format(cell.getDateCellValue());
-			}
+            } else if (field.getType().isPrimitive() && field.getType().getName().equals("int")) {
 
-		} else {
+                return (int) cell.getNumericCellValue();
 
-			if (field.getType().isAssignableFrom(Integer.class)) {
+            } else if (field.getType().isAssignableFrom(Long.class)) {
 
-				return (int) cell.getNumericCellValue();
+                return (long) cell.getNumericCellValue();
 
-			} else if (field.getType().isPrimitive() && field.getType().getName().equals("int")) {
+            } else if (field.getType().isPrimitive() && field.getType().getName().equals("long")) {
 
-				return (int) cell.getNumericCellValue();
+                return (long) cell.getNumericCellValue();
 
-			} else if (field.getType().isAssignableFrom(Long.class)) {
+            } else if (field.getType().isAssignableFrom(Short.class)) {
 
-				return (long) cell.getNumericCellValue();
+                return (short) cell.getNumericCellValue();
 
-			} else if (field.getType().isPrimitive() && field.getType().getName().equals("long")) {
+            } else if (field.getType().isPrimitive() && field.getType().getName().equals("short")) {
 
-				return (long) cell.getNumericCellValue();
+                return (short) cell.getNumericCellValue();
 
-			} else if (field.getType().isAssignableFrom(Short.class)) {
+            } else if (field.getType().isAssignableFrom(Float.class)) {
 
-				return (short) cell.getNumericCellValue();
+                return (float) cell.getNumericCellValue();
+
+            } else if (field.getType().isPrimitive() && field.getType().getName().equals("float")) {
 
-			} else if (field.getType().isPrimitive() && field.getType().getName().equals("short")) {
-
-				return (short) cell.getNumericCellValue();
-
-			} else if (field.getType().isAssignableFrom(Float.class)) {
-
-				return (float) cell.getNumericCellValue();
-
-			} else if (field.getType().isPrimitive() && field.getType().getName().equals("float")) {
-
-				return (float) cell.getNumericCellValue();
-
-			} else if (field.getType().isAssignableFrom(Byte.class)) {
+                return (float) cell.getNumericCellValue();
+
+            } else if (field.getType().isAssignableFrom(Byte.class)) {
 
-				return (byte) cell.getNumericCellValue();
+                return (byte) cell.getNumericCellValue();
 
-			} else if (field.getType().isPrimitive() && field.getType().getName().equals("byte")) {
+            } else if (field.getType().isPrimitive() && field.getType().getName().equals("byte")) {
 
-				return (byte) cell.getNumericCellValue();
+                return (byte) cell.getNumericCellValue();
 
-			} else if (field.getType().isAssignableFrom(Double.class)) {
+            } else if (field.getType().isAssignableFrom(Double.class)) {
 
-				return cell.getNumericCellValue();
+                return cell.getNumericCellValue();
 
-			} else if (field.getType().isPrimitive()
-					&& field.getType().getName().equals("double")) {
+            } else if (field.getType().isPrimitive()
+                    && field.getType().getName().equals("double")) {
 
-				return cell.getNumericCellValue();
+                return cell.getNumericCellValue();
 
-			} else if (field.getType().isAssignableFrom(String.class)) {
+            } else if (field.getType().isAssignableFrom(String.class)) {
 
-				String numStr = String.valueOf(cell.getNumericCellValue());
-				if (numStr.contains("E")) {
-					numStr = new BigDecimal(numStr.trim()).toPlainString();
-				}
-				if (numStr.endsWith(".0"))
-					numStr = numStr.substring(0, numStr.indexOf(".0"));
-				return numStr;
-			} else {
-				return cell.getNumericCellValue();
-			}
-		}
-	}
+                String numStr = String.valueOf(cell.getNumericCellValue());
+                if (numStr.contains("E")) {
+                    numStr = new BigDecimal(numStr.trim()).toPlainString();
+                }
+                if (numStr.endsWith(".0"))
+                    numStr = numStr.substring(0, numStr.indexOf(".0"));
+                return numStr;
+            } else {
+                return cell.getNumericCellValue();
+            }
+        }
+    }
 }

+ 2 - 2
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/excel/ExcelReaderHandle.java

@@ -3,7 +3,7 @@ package cn.com.qmth.examcloud.core.questions.base.excel;
 import cn.com.qmth.examcloud.core.questions.base.excel.ExcelError;
 
 public interface ExcelReaderHandle {
-	
-	ExcelError handle(Object dto);
+
+    ExcelError handle(Object dto);
 
 }

+ 31 - 30
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/excel/ExcelUtils.java

@@ -14,12 +14,12 @@ import cn.com.qmth.examcloud.core.questions.base.excel.ExcelProperty;
 @SuppressWarnings("rawtypes")
 public abstract class ExcelUtils {
 
-	private Class dataClass;
+    private Class dataClass;
     private List<ColumnSetting> columnSettings;
-    
-    public ExcelUtils(Class<?> dataClass , boolean isRead){
+
+    public ExcelUtils(Class<?> dataClass, boolean isRead) {
         this.dataClass = dataClass;
-        this.columnSettings = getColumnSettings(dataClass,isRead);
+        this.columnSettings = getColumnSettings(dataClass, isRead);
     }
 
     public Class getDataClass() {
@@ -40,34 +40,35 @@ public abstract class ExcelUtils {
 
     /**
      * 提取ExcelProperty注解类的字段信息
+     *
      * @param dataClass 需要解析excel的数据类型
      * @return
      */
-    protected List<ColumnSetting> getColumnSettings(Class<?> dataClass, boolean isRead){
-		List<ColumnSetting> columnSettings = new ArrayList<>();
-		Field[] fileds = dataClass.getDeclaredFields();
-		for (Field field : fileds) {
-			ExcelProperty exportProperty = field.getAnnotation(ExcelProperty.class);
-			if (exportProperty != null) {
-				if (isRead) {
-					if (exportProperty.type() == 0 || exportProperty.type() == 2) {
-						ColumnSetting columnSetting = new ColumnSetting(
-								exportProperty.name(),field.getName(),exportProperty.width(),
-								exportProperty.index());
-						columnSettings.add(columnSetting);
-					}
-				}else{
-					if (exportProperty.type() == 1 || exportProperty.type() == 2) {
-						ColumnSetting columnSetting = new ColumnSetting(
-								exportProperty.name(), field.getName(),exportProperty.width(),
-								exportProperty.index());
-						columnSettings.add(columnSetting);
-					}
-				}
-			}
-		}
-		Collections.sort(columnSettings);
-		return columnSettings;
+    protected List<ColumnSetting> getColumnSettings(Class<?> dataClass, boolean isRead) {
+        List<ColumnSetting> columnSettings = new ArrayList<>();
+        Field[] fileds = dataClass.getDeclaredFields();
+        for (Field field : fileds) {
+            ExcelProperty exportProperty = field.getAnnotation(ExcelProperty.class);
+            if (exportProperty != null) {
+                if (isRead) {
+                    if (exportProperty.type() == 0 || exportProperty.type() == 2) {
+                        ColumnSetting columnSetting = new ColumnSetting(
+                                exportProperty.name(), field.getName(), exportProperty.width(),
+                                exportProperty.index());
+                        columnSettings.add(columnSetting);
+                    }
+                } else {
+                    if (exportProperty.type() == 1 || exportProperty.type() == 2) {
+                        ColumnSetting columnSetting = new ColumnSetting(
+                                exportProperty.name(), field.getName(), exportProperty.width(),
+                                exportProperty.index());
+                        columnSettings.add(columnSetting);
+                    }
+                }
+            }
+        }
+        Collections.sort(columnSettings);
+        return columnSettings;
     }
-    
+
 }

+ 1 - 1
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/excel/ExcelWriter.java

@@ -33,7 +33,7 @@ public class ExcelWriter extends ExcelUtils {
      * @param out       输出流
      */
     @SuppressWarnings("resource")
-	public void write(String sheetName, Collection<?> dataset, OutputStream out) {
+    public void write(String sheetName, Collection<?> dataset, OutputStream out) {
         // 声明一个工作薄
         XSSFWorkbook workbook = new XSSFWorkbook();
         // 生成一个表格

+ 5 - 5
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/excel/ExportUtils.java

@@ -18,16 +18,16 @@ public class ExportUtils {
 
     private static final String DEFALUT_EXT = ".xlsx";
 
-    public static void exportEXCEL(String fileName,Class<?> dataClass,
-                             Collection<?> dataset,HttpServletResponse response) {
+    public static void exportEXCEL(String fileName, Class<?> dataClass,
+                                   Collection<?> dataset, HttpServletResponse response) {
         try {
-        	
+
             response.setHeader("Content-Disposition", "inline; filename="
-                    +URLEncoder.encode(fileName, "UTF-8") + DEFALUT_EXT);
+                    + URLEncoder.encode(fileName, "UTF-8") + DEFALUT_EXT);
             response.setContentType(DEFALUT_CONTENT_TYPE);
             ServletOutputStream outputStream = response.getOutputStream();
             ExcelWriter excelExporter = new ExcelWriter(dataClass);
-            excelExporter.write("sheet1",dataset,outputStream);
+            excelExporter.write("sheet1", dataset, outputStream);
             outputStream.flush();
             outputStream.close();
         } catch (Exception e) {

+ 4 - 2
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/exception/PaperException.java

@@ -3,10 +3,12 @@ package cn.com.qmth.examcloud.core.questions.base.exception;
 /**
  * Created by songyue on 17/5/2.
  */
-public class PaperException extends Exception{
+public class PaperException extends Exception {
     private static final long serialVersionUID = 8857929143713319678L;
 
-    public PaperException(){super();}
+    public PaperException() {
+        super();
+    }
 
     public PaperException(String message) {
         super(message);

+ 4 - 2
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/exception/QuesException.java

@@ -3,11 +3,13 @@ package cn.com.qmth.examcloud.core.questions.base.exception;
 /**
  * Created by songyue on 17/5/2.
  */
-public class QuesException extends Exception{
+public class QuesException extends Exception {
 
     private static final long serialVersionUID = -2651610766615418315L;
 
-    public QuesException(){super();}
+    public QuesException() {
+        super();
+    }
 
     public QuesException(String message) {
         super(message);

+ 144 - 134
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/print/CoursePaperDto.java

@@ -1,143 +1,153 @@
 package cn.com.qmth.examcloud.core.questions.base.print;
 
 import java.util.Date;
+
 /**
- * @author  	chenken
- * @date    	201836日 下午5:39:57
- * @company 	QMTH
+ * @author chenken
+ * @date 201836日 下午5:39:57
+ * @company QMTH
  * @description 课程试卷关联表
  */
 public class CoursePaperDto {
-	
-	private Long id;
-	/**
-	 * 机构ID
-	 */
-	private Long orgId;
-	/**
-	 * 考试ID
-	 */
-	private Long examId;
-	/**
-	 * 课程code
-	 */
-	private String courseCode;
-	/**
-	 * 课程名称
-	 */
-	private String courseName;
-	/**
-	 * 试卷ID
-	 */
-	private String paperId;
-	/**
-	 * 试卷名称
-	 */
-	private String paperName;
-	/**
-	 * 试卷P数
-	 */
-	private Integer pNum;
-	/**
-	 * 试卷htmlURL
-	 */
-	private String paperHtmlUrl;
-	/**
-	 * 答案htmlURL
-	 */
-	private String answerHtmlUrl;
-	/**
-	 * 创建时间
-	 */
-	private Date createTime;
-	
-	public CoursePaperDto(){}
-	
-	public CoursePaperDto(Long orgId, Long examId, String courseCode) {
-		this.orgId = orgId;
-		this.examId = examId;
-		this.courseCode = courseCode;
-	}
-
-	public Long getId() {
-		return id;
-	}
-	public void setId(Long id) {
-		this.id = id;
-	}
-	
-	public Long getOrgId() {
-		return orgId;
-	}
-
-	public void setOrgId(Long orgId) {
-		this.orgId = orgId;
-	}
-	
-	public Long getExamId() {
-		return examId;
-	}
-
-	public void setExamId(Long examId) {
-		this.examId = examId;
-	}
-
-	public String getCourseCode() {
-		return courseCode;
-	}
-	public void setCourseCode(String courseCode) {
-		this.courseCode = courseCode;
-	}
-	public String getCourseName() {
-		return courseName;
-	}
-	public void setCourseName(String courseName) {
-		this.courseName = courseName;
-	}
-	public String getPaperName() {
-		return paperName;
-	}
-	public void setPaperName(String paperName) {
-		this.paperName = paperName;
-	}
-	public Date getCreateTime() {
-		return createTime;
-	}
-	public void setCreateTime(Date createTime) {
-		this.createTime = createTime;
-	}
-
-	public Integer getpNum() {
-		return pNum;
-	}
-
-	public void setpNum(Integer pNum) {
-		this.pNum = pNum;
-	}
-
-	public String getPaperId() {
-		return paperId;
-	}
-
-	public void setPaperId(String paperId) {
-		this.paperId = paperId;
-	}
-
-	public String getPaperHtmlUrl() {
-		return paperHtmlUrl;
-	}
-
-	public void setPaperHtmlUrl(String paperHtmlUrl) {
-		this.paperHtmlUrl = paperHtmlUrl;
-	}
-
-	public String getAnswerHtmlUrl() {
-		return answerHtmlUrl;
-	}
-
-	public void setAnswerHtmlUrl(String answerHtmlUrl) {
-		this.answerHtmlUrl = answerHtmlUrl;
-	}
-	
+
+    private Long id;
+    /**
+     * 机构ID
+     */
+    private Long orgId;
+    /**
+     * 考试ID
+     */
+    private Long examId;
+    /**
+     * 课程code
+     */
+    private String courseCode;
+    /**
+     * 课程名称
+     */
+    private String courseName;
+    /**
+     * 试卷ID
+     */
+    private String paperId;
+    /**
+     * 试卷名称
+     */
+    private String paperName;
+    /**
+     * 试卷P数
+     */
+    private Integer pNum;
+    /**
+     * 试卷htmlURL
+     */
+    private String paperHtmlUrl;
+    /**
+     * 答案htmlURL
+     */
+    private String answerHtmlUrl;
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+    public CoursePaperDto() {
+    }
+
+    public CoursePaperDto(Long orgId, Long examId, String courseCode) {
+        this.orgId = orgId;
+        this.examId = examId;
+        this.courseCode = courseCode;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getOrgId() {
+        return orgId;
+    }
+
+    public void setOrgId(Long orgId) {
+        this.orgId = orgId;
+    }
+
+    public Long getExamId() {
+        return examId;
+    }
+
+    public void setExamId(Long examId) {
+        this.examId = examId;
+    }
+
+    public String getCourseCode() {
+        return courseCode;
+    }
+
+    public void setCourseCode(String courseCode) {
+        this.courseCode = courseCode;
+    }
+
+    public String getCourseName() {
+        return courseName;
+    }
+
+    public void setCourseName(String courseName) {
+        this.courseName = courseName;
+    }
+
+    public String getPaperName() {
+        return paperName;
+    }
+
+    public void setPaperName(String paperName) {
+        this.paperName = paperName;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Integer getpNum() {
+        return pNum;
+    }
+
+    public void setpNum(Integer pNum) {
+        this.pNum = pNum;
+    }
+
+    public String getPaperId() {
+        return paperId;
+    }
+
+    public void setPaperId(String paperId) {
+        this.paperId = paperId;
+    }
+
+    public String getPaperHtmlUrl() {
+        return paperHtmlUrl;
+    }
+
+    public void setPaperHtmlUrl(String paperHtmlUrl) {
+        this.paperHtmlUrl = paperHtmlUrl;
+    }
+
+    public String getAnswerHtmlUrl() {
+        return answerHtmlUrl;
+    }
+
+    public void setAnswerHtmlUrl(String answerHtmlUrl) {
+        this.answerHtmlUrl = answerHtmlUrl;
+    }
+
 }
 

+ 15 - 15
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/question/PaperDetailUnitDto.java

@@ -33,9 +33,9 @@ public class PaperDetailUnitDto implements Serializable {
      * 题与题之间按分号";"分隔
      */
     private String optionOrder;
-    
+
     private String quesBody;// 子题题干,默认为html
-    
+
     private List<QuesOptionDto> quesOptions;// 子题选项
 
     public static long getSerialVersionUID() {
@@ -114,19 +114,19 @@ public class PaperDetailUnitDto implements Serializable {
         this.optionOrder = optionOrder;
     }
 
-	public String getQuesBody() {
-		return quesBody;
-	}
+    public String getQuesBody() {
+        return quesBody;
+    }
 
-	public void setQuesBody(String quesBody) {
-		this.quesBody = quesBody;
-	}
-	
-	public List<QuesOptionDto> getQuesOptions() {
-		return quesOptions;
-	}
+    public void setQuesBody(String quesBody) {
+        this.quesBody = quesBody;
+    }
 
-	public void setQuesOptions(List<QuesOptionDto> quesOptions) {
-		this.quesOptions = quesOptions;
-	}
+    public List<QuesOptionDto> getQuesOptions() {
+        return quesOptions;
+    }
+
+    public void setQuesOptions(List<QuesOptionDto> quesOptions) {
+        this.quesOptions = quesOptions;
+    }
 }

+ 31 - 31
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/question/PaperDto.java

@@ -7,7 +7,7 @@ import java.util.Map;
 /**
  * Created by songyue on 17/3/15.
  */
-public class PaperDto implements Serializable{
+public class PaperDto implements Serializable {
     private static final long serialVersionUID = -4673013279766466337L;
 
     private String id;
@@ -23,23 +23,23 @@ public class PaperDto implements Serializable{
      * 否:false
      */
     private boolean isAllQbjectiveQuestion;
-    
+
     private List<PaperDetailDto> paperDetails;
 
-    private Map<String,String> params;//导入试卷属性
+    private Map<String, String> params;//导入试卷属性
 
     /**
      * 调卷规则原始试卷ID
      */
     private String basePaperId;
-    
+
     /**
      * 是否包含音频题
      */
     private Boolean hasAudio;
-    
+
     private String examRemark;//考试说明
-    
+
     public static long getSerialVersionUID() {
         return serialVersionUID;
     }
@@ -92,36 +92,36 @@ public class PaperDto implements Serializable{
         this.params = params;
     }
 
-	public String getBasePaperId() {
-		return basePaperId;
-	}
+    public String getBasePaperId() {
+        return basePaperId;
+    }
 
-	public void setBasePaperId(String basePaperId) {
-		this.basePaperId = basePaperId;
-	}
+    public void setBasePaperId(String basePaperId) {
+        this.basePaperId = basePaperId;
+    }
 
-	public boolean isAllQbjectiveQuestion() {
-		return isAllQbjectiveQuestion;
-	}
+    public boolean isAllQbjectiveQuestion() {
+        return isAllQbjectiveQuestion;
+    }
 
-	public void setAllQbjectiveQuestion(boolean isAllQbjectiveQuestion) {
-		this.isAllQbjectiveQuestion = isAllQbjectiveQuestion;
-	}
+    public void setAllQbjectiveQuestion(boolean isAllQbjectiveQuestion) {
+        this.isAllQbjectiveQuestion = isAllQbjectiveQuestion;
+    }
+
+    public Boolean getHasAudio() {
+        return hasAudio;
+    }
 
-	public Boolean getHasAudio() {
-		return hasAudio;
-	}
+    public void setHasAudio(Boolean hasAudio) {
+        this.hasAudio = hasAudio;
+    }
 
-	public void setHasAudio(Boolean hasAudio) {
-		this.hasAudio = hasAudio;
-	}
+    public String getExamRemark() {
+        return examRemark;
+    }
 
-	public String getExamRemark() {
-		return examRemark;
-	}
+    public void setExamRemark(String examRemark) {
+        this.examRemark = examRemark;
+    }
 
-	public void setExamRemark(String examRemark) {
-		this.examRemark = examRemark;
-	}
-    
 }

+ 94 - 92
examcloud-core-questions-base/src/main/java/cn/com/qmth/examcloud/core/questions/base/question/enums/QuesStructType.java

@@ -1,97 +1,99 @@
 package cn.com.qmth.examcloud.core.questions.base.question.enums;
 
 public enum QuesStructType {
-	
-	/**
-	 * 单选
-	 */
-	SINGLE_ANSWER_QUESTION(1L,"单选",true,false),
-	/**
-	 * 多选
-	 */
-	MULTIPLE_ANSWER_QUESTION(2L,"多选",true,false),
-	/**
-	 * 判断
-	 */
-	BOOL_ANSWER_QUESTION(3L,"判断",true,false),
-	/**
-	 * 填空
-	 */
-	FILL_BLANK_QUESTION(4L,"填空",false,false),
-	/**
-	 * 问答
-	 */
-	TEXT_ANSWER_QUESTION(5L,"问答",false,false),
-	/**
-	 * 套题
-	 */
-	NESTED_ANSWER_QUESTION(6L,"套题",false,true);
-	
-	private Long id;
-	private String name;
-	private boolean objective;//是否是客观题
-	private boolean combline;//是否是组合题
-		
-	private QuesStructType(Long id, String name, boolean objective, boolean combline) {
-		this.id = id;
-		this.name = name;;
-		this.objective = objective;
-		this.combline = combline;
-	}
-	
-	/**
-	 * 通过ID获取试题类型
-	 * @param id
-	 * @return
-	 */
-	public static QuesStructType getQuesStructTypeById(Long id){
-		for(QuesStructType type:QuesStructType.values()){
-			if(type.getId()==id){
-				return type;
-			}
-		}
-		return null;
-	}
-	
-	private QuesStructType(){
-		
-	}
-
-	public Long getId() {
-		return id;
-	}
-
-	public void setId(Long id) {
-		this.id = id;
-	}
-
-	public String getName() {
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-
-	public boolean isObjective() {
-		return objective;
-	}
-
-	public void setObjective(boolean objective) {
-		this.objective = objective;
-	}
-
-	public boolean isCombline() {
-		return combline;
-	}
-
-	public void setCombline(boolean combline) {
-		this.combline = combline;
-	}
-
-	public String toString(){
-		return getName();
-	}
-	
+
+    /**
+     * 单选
+     */
+    SINGLE_ANSWER_QUESTION(1L, "单选", true, false),
+    /**
+     * 多选
+     */
+    MULTIPLE_ANSWER_QUESTION(2L, "多选", true, false),
+    /**
+     * 判断
+     */
+    BOOL_ANSWER_QUESTION(3L, "判断", true, false),
+    /**
+     * 填空
+     */
+    FILL_BLANK_QUESTION(4L, "填空", false, false),
+    /**
+     * 问答
+     */
+    TEXT_ANSWER_QUESTION(5L, "问答", false, false),
+    /**
+     * 套题
+     */
+    NESTED_ANSWER_QUESTION(6L, "套题", false, true);
+
+    private Long id;
+    private String name;
+    private boolean objective;//是否是客观题
+    private boolean combline;//是否是组合题
+
+    private QuesStructType(Long id, String name, boolean objective, boolean combline) {
+        this.id = id;
+        this.name = name;
+        ;
+        this.objective = objective;
+        this.combline = combline;
+    }
+
+    /**
+     * 通过ID获取试题类型
+     *
+     * @param id
+     * @return
+     */
+    public static QuesStructType getQuesStructTypeById(Long id) {
+        for (QuesStructType type : QuesStructType.values()) {
+            if (type.getId() == id) {
+                return type;
+            }
+        }
+        return null;
+    }
+
+    private QuesStructType() {
+
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public boolean isObjective() {
+        return objective;
+    }
+
+    public void setObjective(boolean objective) {
+        this.objective = objective;
+    }
+
+    public boolean isCombline() {
+        return combline;
+    }
+
+    public void setCombline(boolean combline) {
+        this.combline = combline;
+    }
+
+    public String toString() {
+        return getName();
+    }
+
 }
 

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

@@ -592,7 +592,7 @@ public final class DocxProcessUtil {
                         Text text = (Text) rChild;
                         String tmpText = text.getValue();
                         if (quesUnit == QuesUnit.QUES_BODY) {
-                        	
+
                             // 过滤题干标题
                             if (tmpText.matches("^\\d{1,}\\.[\\s\\S]*")) {
                                 tmpText = tmpText.replaceFirst("\\d{1,}\\.", "");