|
@@ -1,14 +1,13 @@
|
|
package cn.com.qmth.scancentral.service.impl;
|
|
package cn.com.qmth.scancentral.service.impl;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.HashSet;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
-import java.util.Set;
|
|
|
|
-import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
-import java.util.regex.Pattern;
|
|
|
|
-
|
|
|
|
|
|
+import cn.com.qmth.scancentral.bean.ImportStudentDomain;
|
|
import cn.com.qmth.scancentral.enums.AsyncTaskStatus;
|
|
import cn.com.qmth.scancentral.enums.AsyncTaskStatus;
|
|
|
|
+import cn.com.qmth.scancentral.service.StudentImportService;
|
|
|
|
+import cn.com.qmth.scancentral.service.StudentService;
|
|
|
|
+import cn.com.qmth.scancentral.service.SubjectService;
|
|
|
|
+import cn.com.qmth.scancentral.vo.studentimport.ImportTaskVo;
|
|
|
|
+import cn.com.qmth.scancentral.vo.studentimport.StudentImportInfo;
|
|
|
|
+import com.qmth.boot.core.exception.ParameterException;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -16,14 +15,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
-import com.qmth.boot.core.exception.ParameterException;
|
|
|
|
-
|
|
|
|
-import cn.com.qmth.scancentral.bean.ImportStudentDomain;
|
|
|
|
-import cn.com.qmth.scancentral.service.StudentImportService;
|
|
|
|
-import cn.com.qmth.scancentral.service.StudentService;
|
|
|
|
-import cn.com.qmth.scancentral.service.SubjectService;
|
|
|
|
-import cn.com.qmth.scancentral.vo.studentimport.ImportTaskVo;
|
|
|
|
-import cn.com.qmth.scancentral.vo.studentimport.StudentImportInfo;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
@Component
|
|
@Component
|
|
public class StudentImportServiceImpl implements StudentImportService {
|
|
public class StudentImportServiceImpl implements StudentImportService {
|
|
@@ -59,8 +53,8 @@ public class StudentImportServiceImpl implements StudentImportService {
|
|
|
|
|
|
@Async
|
|
@Async
|
|
@Override
|
|
@Override
|
|
- public void studentImport(String taskId, List<String> lines, Long examId, Integer yearConfig,
|
|
|
|
- Integer yearHalfConfig) {
|
|
|
|
|
|
+ public void studentImport(String taskId, List<String> lines, Long examId, String subjectCode, Integer yearConfig,
|
|
|
|
+ Integer yearHalfConfig) {
|
|
ImportTaskVo task = new ImportTaskVo();
|
|
ImportTaskVo task = new ImportTaskVo();
|
|
task.setTaskId(taskId);
|
|
task.setTaskId(taskId);
|
|
task.setProgress(0d);
|
|
task.setProgress(0d);
|
|
@@ -69,7 +63,7 @@ public class StudentImportServiceImpl implements StudentImportService {
|
|
|
|
|
|
List<StudentImportInfo> list = new ArrayList<>();
|
|
List<StudentImportInfo> list = new ArrayList<>();
|
|
try {
|
|
try {
|
|
- this.parseValues(lines, list, examId, yearConfig, yearHalfConfig);
|
|
|
|
|
|
+ this.parseValues(lines, list, examId, subjectCode, yearConfig, yearHalfConfig);
|
|
log.warn("【考生导入】解析考生数据,有效共{}条! taskId:{}", list.size(), taskId);
|
|
log.warn("【考生导入】解析考生数据,有效共{}条! taskId:{}", list.size(), taskId);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("【考生导入】解析考生数据错误! taskId:{} {}", taskId, e.getMessage());
|
|
log.error("【考生导入】解析考生数据错误! taskId:{} {}", taskId, e.getMessage());
|
|
@@ -135,8 +129,8 @@ public class StudentImportServiceImpl implements StudentImportService {
|
|
return data;
|
|
return data;
|
|
}
|
|
}
|
|
|
|
|
|
- private void parseValues(List<String> lines, List<StudentImportInfo> list, Long examId, Integer yearConfig,
|
|
|
|
- Integer yearHalfConfig) {
|
|
|
|
|
|
+ private void parseValues(List<String> lines, List<StudentImportInfo> list, Long examId, String subjectCodeConfig,
|
|
|
|
+ Integer yearConfig, Integer yearHalfConfig) {
|
|
Set<String> subjectCodes = new HashSet<>();
|
|
Set<String> subjectCodes = new HashSet<>();
|
|
Set<String> examNumbers = new HashSet<>();
|
|
Set<String> examNumbers = new HashSet<>();
|
|
Pattern examNumberPattern = Pattern.compile("^[0-9]{15}$");
|
|
Pattern examNumberPattern = Pattern.compile("^[0-9]{15}$");
|
|
@@ -186,8 +180,12 @@ public class StudentImportServiceImpl implements StudentImportService {
|
|
throw new RuntimeException(String.format("【第%s行】考次不正确", n + 1));
|
|
throw new RuntimeException(String.format("【第%s行】考次不正确", n + 1));
|
|
}
|
|
}
|
|
|
|
|
|
- String province = examNumber.substring(0, 3);
|
|
|
|
String subjectCode = examNumber.substring(9, 10);
|
|
String subjectCode = examNumber.substring(9, 10);
|
|
|
|
+ if (StringUtils.isNotBlank(subjectCodeConfig) && !subjectCodeConfig.equals(subjectCode)) {
|
|
|
|
+ throw new RuntimeException(String.format("【第%s行】科目代码不正确", n + 1));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String province = examNumber.substring(0, 3);
|
|
String examSite = examNumber.substring(0, 5);
|
|
String examSite = examNumber.substring(0, 5);
|
|
String campusCode = examNumber.substring(5, 6);
|
|
String campusCode = examNumber.substring(5, 6);
|
|
String examRoom = examNumber.substring(10, 13);
|
|
String examRoom = examNumber.substring(10, 13);
|
|
@@ -220,15 +218,4 @@ public class StudentImportServiceImpl implements StudentImportService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- // private void writeLogFile(File logFile, String content) {
|
|
|
|
- // if (StringUtils.isEmpty(content)) {
|
|
|
|
- // return;
|
|
|
|
- // }
|
|
|
|
- // try {
|
|
|
|
- // FileUtils.writeStringToFile(logFile, "\n" + content, "UTF-8", true);
|
|
|
|
- // } catch (IOException e) {
|
|
|
|
- // log.error(e.getMessage(), e);
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
}
|
|
}
|