|
@@ -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);
|