xiatian 4 săptămâni în urmă
părinte
comite
a5e38f7580

+ 25 - 1
src/main/java/cn/com/qmth/archive/dao/MarkingDao.java

@@ -8,4 +8,28 @@ import org.apache.ibatis.annotations.Param;
 public interface MarkingDao {
 
     List<Map<String, Object>> getWork(@Param("cols") List<String> cols, @Param("workids") List<Long> workids);
-}
+
+    List<Map<String, Object>> getWorkExam(@Param("cols") List<String> cols, @Param("workids") List<Long> workids);
+
+    List<Map<String, Object>> getStudentPaper(@Param("cols") List<String> cols, @Param("workids") List<Long> workids);
+
+    List<Map<String, Object>> getMarkRange(@Param("cols") List<String> cols, @Param("workids") List<Long> workids);
+
+    List<Map<String, Object>> getMarkResult(@Param("cols") List<String> cols, @Param("workids") List<Long> workids);
+
+    List<Map<String, Object>> getMarkTask(@Param("cols") List<String> cols, @Param("workids") List<Long> workids);
+
+    List<Map<String, Object>> getMarkTaskLimit(@Param("cols") List<String> cols, @Param("workids") List<Long> workids);
+
+    List<Map<String, Object>> getMarkItem(@Param("cols") List<String> cols, @Param("workids") List<Long> workids);
+
+    List<Map<String, Object>> getResultItem(@Param("cols") List<String> cols, @Param("workids") List<Long> workids);
+
+    List<Map<String, Object>> getRandomResultItem(@Param("cols") List<String> cols,
+            @Param("workids") List<Long> workids);
+
+    List<Map<String, Object>> getScoreStep(@Param("cols") List<String> cols, @Param("workids") List<Long> workids);
+
+    List<Map<String, Object>> getRejectResult(@Param("cols") List<String> cols, @Param("workids") List<Long> workids);
+
+}

+ 128 - 15
src/main/java/cn/com/qmth/archive/service/impl/MarkingServiceImpl.java

@@ -72,14 +72,125 @@ public class MarkingServiceImpl implements MarkingService {
 
         log.warn("*********************开始处理,workid:" + StringUtils.join(workids, ","));
         try {
-            Map<String, List<String>> clos = getCols();
-            getWork(clos, dir, workids);
+            Map<String, List<String>> cols = getCols();
+            getWork(cols, dir, workids);
+            getWorkExam(cols, dir, workids);
+            getStudentPaper(cols, dir, workids);
+            getMarkRange(cols, dir, workids);
+            getMarkResult(cols, dir, workids);
+            getMarkTask(cols, dir, workids);
+            getMarkTaskLimit(cols, dir, workids);
+            getMarkItem(cols, dir, workids);
+            getResultItem(cols, dir, workids);
+            getRandomResultItem(cols, dir, workids);
+            getScoreStep(cols, dir, workids);
+            getRejectResult(cols, dir, workids);
             log.warn("*********************处理结束,成功");
         } catch (Exception e) {
             throw new StatusException("*********************处理结束,失败", e);
         }
     }
 
+    private void getWork(Map<String, List<String>> cols, File dir, List<Long> workids) throws IOException {
+        String tableName = "ec_m_mark_work";
+        log.warn("*********************处理" + tableName);
+        List<String> col = getCol(cols, tableName);
+        List<Map<String, Object>> data = markingDao.getWork(col, workids);
+        if (CollectionUtils.isEmpty(data)) {
+            throw new StatusException(tableName + "表没有数据");
+        }
+        getSql(dir, col, tableName, data);
+    }
+
+    private void getWorkExam(Map<String, List<String>> cols, File dir, List<Long> workids) throws IOException {
+        String tableName = "ec_m_mark_work_exam";
+        log.warn("*********************处理" + tableName);
+        List<String> col = getCol(cols, tableName);
+        List<Map<String, Object>> data = markingDao.getWorkExam(col, workids);
+
+        getSql(dir, col, tableName, data);
+    }
+
+    private void getStudentPaper(Map<String, List<String>> cols, File dir, List<Long> workids) throws IOException {
+        String tableName = "ec_m_student_paper";
+        log.warn("*********************处理" + tableName);
+        List<String> col = getCol(cols, tableName);
+        List<Map<String, Object>> data = markingDao.getStudentPaper(col, workids);
+        getSql(dir, col, tableName, data);
+    }
+
+    private void getMarkRange(Map<String, List<String>> cols, File dir, List<Long> workids) throws IOException {
+        String tableName = "ec_m_mark_range";
+        log.warn("*********************处理" + tableName);
+        List<String> col = getCol(cols, tableName);
+        List<Map<String, Object>> data = markingDao.getMarkRange(col, workids);
+        getSql(dir, col, tableName, data);
+    }
+
+    private void getMarkResult(Map<String, List<String>> cols, File dir, List<Long> workids) throws IOException {
+        String tableName = "ec_m_mark_result";
+        log.warn("*********************处理" + tableName);
+        List<String> col = getCol(cols, tableName);
+        List<Map<String, Object>> data = markingDao.getMarkResult(col, workids);
+        getSql(dir, col, tableName, data);
+    }
+
+    private void getMarkTask(Map<String, List<String>> cols, File dir, List<Long> workids) throws IOException {
+        String tableName = "ec_m_mark_task";
+        log.warn("*********************处理" + tableName);
+        List<String> col = getCol(cols, tableName);
+        List<Map<String, Object>> data = markingDao.getMarkTask(col, workids);
+        getSql(dir, col, tableName, data);
+    }
+
+    private void getMarkTaskLimit(Map<String, List<String>> cols, File dir, List<Long> workids) throws IOException {
+        String tableName = "ec_m_mark_task_limit";
+        log.warn("*********************处理" + tableName);
+        List<String> col = getCol(cols, tableName);
+        List<Map<String, Object>> data = markingDao.getMarkTaskLimit(col, workids);
+        getSql(dir, col, tableName, data);
+    }
+
+    private void getMarkItem(Map<String, List<String>> cols, File dir, List<Long> workids) throws IOException {
+        String tableName = "ec_m_mark_item";
+        log.warn("*********************处理" + tableName);
+        List<String> col = getCol(cols, tableName);
+        List<Map<String, Object>> data = markingDao.getMarkItem(col, workids);
+        getSql(dir, col, tableName, data);
+    }
+
+    private void getResultItem(Map<String, List<String>> cols, File dir, List<Long> workids) throws IOException {
+        String tableName = "ec_m_result_item";
+        log.warn("*********************处理" + tableName);
+        List<String> col = getCol(cols, tableName);
+        List<Map<String, Object>> data = markingDao.getResultItem(col, workids);
+        getSql(dir, col, tableName, data);
+    }
+
+    private void getRandomResultItem(Map<String, List<String>> cols, File dir, List<Long> workids) throws IOException {
+        String tableName = "ec_m_random_result_item";
+        log.warn("*********************处理" + tableName);
+        List<String> col = getCol(cols, tableName);
+        List<Map<String, Object>> data = markingDao.getRandomResultItem(col, workids);
+        getSql(dir, col, tableName, data);
+    }
+
+    private void getScoreStep(Map<String, List<String>> cols, File dir, List<Long> workids) throws IOException {
+        String tableName = "ec_m_mark_score_step";
+        log.warn("*********************处理" + tableName);
+        List<String> col = getCol(cols, tableName);
+        List<Map<String, Object>> data = markingDao.getScoreStep(col, workids);
+        getSql(dir, col, tableName, data);
+    }
+
+    private void getRejectResult(Map<String, List<String>> cols, File dir, List<Long> workids) throws IOException {
+        String tableName = "ec_m_reject_result";
+        log.warn("*********************处理" + tableName);
+        List<String> col = getCol(cols, tableName);
+        List<Map<String, Object>> data = markingDao.getRejectResult(col, workids);
+        getSql(dir, col, tableName, data);
+    }
+
     private String trimAndNullIfBlank(String s) {
         if (StringUtils.isBlank(s)) {
             return null;
@@ -87,6 +198,14 @@ public class MarkingServiceImpl implements MarkingService {
         return s.trim();
     }
 
+    private List<String> getCol(Map<String, List<String>> cols, String tableName) {
+        List<String> col = cols.get(tableName);
+        if (CollectionUtils.isEmpty(col)) {
+            throw new StatusException(tableName + "表没有字段信息");
+        }
+        return col;
+    }
+
     @SuppressWarnings("deprecation")
     private Map<String, List<String>> getCols() throws FileNotFoundException {
         File file = new File("./columns/columns.xlsx");
@@ -139,21 +258,15 @@ public class MarkingServiceImpl implements MarkingService {
 
     }
 
-    private void getWork(Map<String, List<String>> clos, File dir, List<Long> workids) throws IOException {
-        log.warn("*********************处理work");
-        String tableName = "ec_m_mark_work";
-        List<String> col = clos.get(tableName);
-        if (CollectionUtils.isEmpty(col)) {
-            throw new StatusException("ec_m_mark_work表没有字段信息");
-        }
-        List<Map<String, Object>> work = markingDao.getWork(col, workids);
-        if (CollectionUtils.isEmpty(work)) {
-            throw new StatusException("work表没有数据");
-        }
-        File sql = new File(dir.getAbsolutePath() + "/work.sql");
+    private void getSql(File dir, List<String> col, String tableName, List<Map<String, Object>> data)
+            throws IOException {
+        File sql = new File(dir.getAbsolutePath() + "/" + tableName + ".sql");
         sql.createNewFile();
+        if (CollectionUtils.isEmpty(data)) {
+            return;
+        }
         List<String> ret = new ArrayList<>();
-        for (Map<String, Object> map : work) {
+        for (Map<String, Object> map : data) {
             ret.add(getLine(tableName, col, map));
         }
         FileUtils.writeLines(sql, "utf-8", ret, false);

+ 170 - 9
src/main/resources/mapper/MarkingMapper.xml

@@ -1,16 +1,177 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.qmth.archive.dao.MarkingDao">
-	<select id="getWork"
-		resultType="map">
-		SELECT <foreach collection="cols" item="val" separator=",">
-				w.${val}
-			</foreach>
+	<select id="getWork" resultType="map">
+		SELECT
+		<foreach collection="cols" item="val" separator=",">
+			w.${val}
+		</foreach>
 		from ec_m_mark_work w
 		where w.id in (
-			<foreach collection="workids" item="val" separator=",">
-				#{val}
-			</foreach>
-			)
+		<foreach collection="workids" item="val" separator=",">
+			#{val}
+		</foreach>
+		)
 	</select>
+
+	<select id="getWorkExam" resultType="map">
+		SELECT
+		<foreach collection="cols" item="val" separator=",">
+			t.${val}
+		</foreach>
+		from ec_m_mark_work_exam t
+		inner join ec_m_mark_work w on w.id =
+		t.work_id
+		where w.id in (
+		<foreach collection="workids" item="val" separator=",">
+			#{val}
+		</foreach>
+		)
+	</select>
+
+	<select id="getStudentPaper" resultType="map">
+		SELECT
+		<foreach collection="cols" item="val" separator=",">
+			t.${val}
+		</foreach>
+		from ec_m_student_paper t
+		inner join ec_m_mark_work w on w.id =
+		t.work_id
+		where w.id in (
+		<foreach collection="workids" item="val" separator=",">
+			#{val}
+		</foreach>
+		)
+	</select>
+
+	<select id="getMarkRange" resultType="map">
+		SELECT
+		<foreach collection="cols" item="val" separator=",">
+			t.${val}
+		</foreach>
+		from ec_m_mark_range t
+		inner join ec_m_mark_work w on w.id = t.work_id
+		where w.id in (
+		<foreach collection="workids" item="val" separator=",">
+			#{val}
+		</foreach>
+		)
+	</select>
+
+	<select id="getMarkResult" resultType="map">
+		SELECT
+		<foreach collection="cols" item="val" separator=",">
+			t.${val}
+		</foreach>
+		from ec_m_mark_result t
+		inner join ec_m_mark_range r on r.id =
+		t.mark_range_id
+		inner join ec_m_mark_work w on w.id = r.work_id
+		where
+		w.id in (
+		<foreach collection="workids" item="val" separator=",">
+			#{val}
+		</foreach>
+		)
+	</select>
+
+	<select id="getMarkTask" resultType="map">
+		SELECT
+		<foreach collection="cols" item="val" separator=",">
+			t.${val}
+		</foreach>
+		from ec_m_mark_task t
+		inner join ec_m_mark_work w on w.id = t.work_id
+		where w.id in (
+		<foreach collection="workids" item="val" separator=",">
+			#{val}
+		</foreach>
+		)
+	</select>
+	<select id="getMarkTaskLimit" resultType="map">
+		SELECT
+		<foreach collection="cols" item="val" separator=",">
+			t.${val}
+		</foreach>
+		from ec_m_mark_task_limit t
+		inner join ec_m_mark_work w on w.id =
+		t.work_id
+		where w.id in (
+		<foreach collection="workids" item="val" separator=",">
+			#{val}
+		</foreach>
+		)
+	</select>
+	<select id="getMarkItem" resultType="map">
+		SELECT
+		<foreach collection="cols" item="val" separator=",">
+			t.${val}
+		</foreach>
+		from ec_m_mark_item t
+		inner join ec_m_mark_work w on w.id = t.work_id
+		where w.id in (
+		<foreach collection="workids" item="val" separator=",">
+			#{val}
+		</foreach>
+		)
+	</select>
+	<select id="getResultItem" resultType="map">
+		SELECT
+		<foreach collection="cols" item="val" separator=",">
+			t.${val}
+		</foreach>
+		from ec_m_result_item t
+		inner join ec_m_mark_item tt on tt.id =
+		t.mark_item_id
+		inner join ec_m_mark_work w on w.id = tt.work_id
+		where
+		w.id in (
+		<foreach collection="workids" item="val" separator=",">
+			#{val}
+		</foreach>
+		)
+	</select>
+	<select id="getRandomResultItem" resultType="map">
+		SELECT
+		<foreach collection="cols" item="val" separator=",">
+			t.${val}
+		</foreach>
+		from ec_m_random_result_item t
+		inner join ec_m_mark_work w on w.id =
+		t.work_id
+		where w.id in (
+		<foreach collection="workids" item="val" separator=",">
+			#{val}
+		</foreach>
+		)
+	</select>
+	<select id="getScoreStep" resultType="map">
+		SELECT
+		<foreach collection="cols" item="val" separator=",">
+			t.${val}
+		</foreach>
+		from ec_m_mark_score_step t
+		inner join ec_m_mark_work w on w.id =
+		t.work_id
+		where w.id in (
+		<foreach collection="workids" item="val" separator=",">
+			#{val}
+		</foreach>
+		)
+	</select>
+	<select id="getRejectResult" resultType="map">
+		SELECT
+		<foreach collection="cols" item="val" separator=",">
+			t.${val}
+		</foreach>
+		from ec_m_reject_result t
+		inner join ec_m_mark_range r on r.id = t.mark_range_id
+		inner join ec_m_mark_work w on w.id = r.work_id
+		where w.id in (
+		<foreach collection="workids" item="val" separator=",">
+			#{val}
+		</foreach>
+		)
+	</select>
+
 </mapper>