|
@@ -12,8 +12,6 @@ import com.qmth.teachcloud.common.entity.MarkQuestion;
|
|
|
import com.qmth.teachcloud.common.entity.SysUser;
|
|
|
import com.qmth.teachcloud.common.enums.ExamModelEnum;
|
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
-import com.qmth.teachcloud.common.enums.ImportTemplateEnum;
|
|
|
-import com.qmth.teachcloud.common.util.FileUtil;
|
|
|
import com.qmth.teachcloud.mark.dto.mark.MarkQuestionAnswerVo;
|
|
|
import com.qmth.teachcloud.mark.dto.mark.manage.MarkerScoreDTO;
|
|
|
import com.qmth.teachcloud.mark.dto.mark.manage.TaskQuestion;
|
|
@@ -33,10 +31,6 @@ import org.springframework.jdbc.core.BatchPreparedStatementSetter;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
|
|
|
-import java.io.File;
|
|
|
-import java.io.FileInputStream;
|
|
|
-import java.io.FileNotFoundException;
|
|
|
-import java.io.InputStream;
|
|
|
import java.sql.PreparedStatement;
|
|
|
import java.sql.SQLException;
|
|
|
import java.sql.Types;
|
|
@@ -52,6 +46,8 @@ public class DataUpgrade_3_4_4 implements DataUpgradeService {
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(DataUpgrade_3_4_4.class);
|
|
|
|
|
|
+ private Set<String> md5Set = new HashSet<>();
|
|
|
+
|
|
|
// 一页1000条
|
|
|
private static int PAGE_SIZE = 500;
|
|
|
private static String DATE_PATTERN = "yyyy-MM-dd HH:mm:ss";
|
|
@@ -142,9 +138,13 @@ public class DataUpgrade_3_4_4 implements DataUpgradeService {
|
|
|
return null;
|
|
|
}
|
|
|
String md5 = this.md5String(cardContent);
|
|
|
+ if(md5Set.contains(md5)){
|
|
|
+ return md5;
|
|
|
+ }
|
|
|
int count = this.getMarkArchiveStudentCard(jdbcTemplate, md5);
|
|
|
if (count == 0) {
|
|
|
this.insertMarkArchiveStudentCard(jdbcTemplate, md5, cardContent);
|
|
|
+ md5Set.add(md5);
|
|
|
}
|
|
|
return md5;
|
|
|
}
|
|
@@ -390,9 +390,9 @@ public class DataUpgrade_3_4_4 implements DataUpgradeService {
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
- private int update(JdbcTemplate jdbcTemplate, String sql) {
|
|
|
+ private int update(JdbcTemplate jdbcTemplate, String sql, Object[] params) {
|
|
|
try {
|
|
|
- return jdbcTemplate.update(sql);
|
|
|
+ return jdbcTemplate.update(sql, params);
|
|
|
} catch (Exception e) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("更新失败:" + e.getMessage());
|
|
|
}
|
|
@@ -596,18 +596,21 @@ public class DataUpgrade_3_4_4 implements DataUpgradeService {
|
|
|
}
|
|
|
|
|
|
private int updateMarkPaperArchive(JdbcTemplate jdbcTemplate, Long id) {
|
|
|
- String sql = "update mark_paper set archive = 1 where id = " + id;
|
|
|
- return this.update(jdbcTemplate, sql);
|
|
|
+ String sql = "update mark_paper set archive = 1 where id = ?";
|
|
|
+ Object[] params = new Object[]{id};
|
|
|
+ return this.update(jdbcTemplate, sql, params);
|
|
|
}
|
|
|
|
|
|
private int insertMarkArchiveStudentCard(JdbcTemplate jdbcTemplate, String id, String cardContent) {
|
|
|
- String sql = "insert into mark_archive_student_card values ('" + id + "','" + cardContent + "')";
|
|
|
- return this.update(jdbcTemplate, sql);
|
|
|
+ String sql = "insert into mark_archive_student_card values (?,?)";
|
|
|
+ Object[] params = new Object[]{id, cardContent};
|
|
|
+ return this.update(jdbcTemplate, sql, params);
|
|
|
}
|
|
|
|
|
|
private int deleteMarkArchiveStudentByExamIdAndPaperNumber(JdbcTemplate jdbcTemplate, Long examId, String paperNumber) {
|
|
|
- String sql = "delete from mark_archive_student where exam_id = " + examId + " and paper_number = '" + paperNumber + "'";
|
|
|
- return this.update(jdbcTemplate, sql);
|
|
|
+ String sql = "delete from mark_archive_student where exam_id = ? and paper_number = ?";
|
|
|
+ Object[] params = new Object[]{examId, paperNumber};
|
|
|
+ return this.update(jdbcTemplate, sql, params);
|
|
|
}
|
|
|
|
|
|
private long batchInsert(JdbcTemplate jdbcTemplate, List<MarkArchiveStudent> markArchiveStudents) {
|