|
@@ -7,11 +7,14 @@ import com.google.common.collect.Lists;
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
import com.qmth.themis.business.constant.SpringContextHolder;
|
|
import com.qmth.themis.business.constant.SpringContextHolder;
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
-import com.qmth.themis.business.dto.ExamStudentDtoImport;
|
|
|
|
|
|
+import com.qmth.themis.business.dto.ExamStudentImportDto;
|
|
import com.qmth.themis.business.entity.*;
|
|
import com.qmth.themis.business.entity.*;
|
|
import com.qmth.themis.business.enums.ExamModeEnum;
|
|
import com.qmth.themis.business.enums.ExamModeEnum;
|
|
import com.qmth.themis.business.enums.RoleEnum;
|
|
import com.qmth.themis.business.enums.RoleEnum;
|
|
-import com.qmth.themis.business.service.*;
|
|
|
|
|
|
+import com.qmth.themis.business.service.TBExamInvigilateUserService;
|
|
|
|
+import com.qmth.themis.business.service.TBUserRoleService;
|
|
|
|
+import com.qmth.themis.business.service.TEExamStudentService;
|
|
|
|
+import com.qmth.themis.business.service.TEStudentService;
|
|
import com.qmth.themis.business.templete.TaskImportCommon;
|
|
import com.qmth.themis.business.templete.TaskImportCommon;
|
|
import com.qmth.themis.business.templete.TaskImportTemplete;
|
|
import com.qmth.themis.business.templete.TaskImportTemplete;
|
|
import com.qmth.themis.business.util.ExcelCallback;
|
|
import com.qmth.themis.business.util.ExcelCallback;
|
|
@@ -57,26 +60,33 @@ public class TaskExamStudentImportTemplete implements TaskImportTemplete {
|
|
TaskImportCommon taskImportCommon = new TaskImportCommon(map);
|
|
TaskImportCommon taskImportCommon = new TaskImportCommon(map);
|
|
taskImportCommon.init();
|
|
taskImportCommon.init();
|
|
File file = taskImportCommon.getUploadFile();
|
|
File file = taskImportCommon.getUploadFile();
|
|
- List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(new FileInputStream(file), Lists.newArrayList(ExamStudentDtoImport.class), new ExcelCallback() {
|
|
|
|
|
|
+ List<String> txtList = new ArrayList();
|
|
|
|
+ String timeFormat = taskImportCommon.getTimeFormat();
|
|
|
|
+ txtList.add(DateUtil.format(new Date(), timeFormat) + "->开始准备处理导入的考生数据");
|
|
|
|
+ List<String> finalTxtList = txtList;
|
|
|
|
+ List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(new FileInputStream(file), Lists.newArrayList(ExamStudentImportDto.class), new ExcelCallback() {
|
|
@Override
|
|
@Override
|
|
- public List<LinkedMultiValueMap<Integer, Object>> callback(List<LinkedMultiValueMap<Integer, Object>> finalList, List<LinkedMultiValueMap<Integer, String>> finalColumnNameList) throws IllegalAccessException {
|
|
|
|
|
|
+ public List<LinkedMultiValueMap<Integer, Object>> callback(List<LinkedMultiValueMap<Integer, Object>> finalList, List<LinkedMultiValueMap<Integer, String>> finalColumnNameList) throws IllegalAccessException, IOException {
|
|
List<ExcelError> excelErrorList = new ArrayList<>();
|
|
List<ExcelError> excelErrorList = new ArrayList<>();
|
|
for (int i = 0; i < finalList.size(); i++) {
|
|
for (int i = 0; i < finalList.size(); i++) {
|
|
LinkedMultiValueMap<Integer, Object> map = finalList.get(i);
|
|
LinkedMultiValueMap<Integer, Object> map = finalList.get(i);
|
|
- List<Object> examStudentDtoImportList = map.get(i);
|
|
|
|
- for (int y = 0; y < examStudentDtoImportList.size(); y++) {
|
|
|
|
- ExamStudentDtoImport examStudentDtoImport = (ExamStudentDtoImport) examStudentDtoImportList.get(y);
|
|
|
|
- List<ExcelError> excelErrorTemp = ExcelUtil.checkExcelField(examStudentDtoImport, y, i);
|
|
|
|
|
|
+ List<Object> examStudentImportDtoList = map.get(i);
|
|
|
|
+ for (int y = 0; y < examStudentImportDtoList.size(); y++) {
|
|
|
|
+ ExamStudentImportDto examStudentImportDto = (ExamStudentImportDto) examStudentImportDtoList.get(y);
|
|
|
|
+ List<ExcelError> excelErrorTemp = ExcelUtil.checkExcelField(examStudentImportDto, y, i);
|
|
if (excelErrorTemp.size() > 0) {
|
|
if (excelErrorTemp.size() > 0) {
|
|
excelErrorList.addAll(excelErrorTemp);
|
|
excelErrorList.addAll(excelErrorTemp);
|
|
}
|
|
}
|
|
//校验考试模式,如果是集中统一,则需填写考试场次
|
|
//校验考试模式,如果是集中统一,则需填写考试场次
|
|
- if (taskImportCommon.getMode().intValue() == ExamModeEnum.together.ordinal() && Objects.isNull(examStudentDtoImport.getExamActivityCode())) {
|
|
|
|
- excelErrorList.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行考场为空"));
|
|
|
|
|
|
+ if (taskImportCommon.getMode().intValue() == ExamModeEnum.together.ordinal() && Objects.isNull(examStudentImportDto.getExamActivityCode())) {
|
|
|
|
+ excelErrorList.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[考场]为空"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (excelErrorList.size() > 0) {
|
|
if (excelErrorList.size() > 0) {
|
|
|
|
+ finalTxtList.add(DateUtil.format(new Date(), timeFormat) + "->数据校验异常:" + JSONObject.toJSONString(excelErrorList));
|
|
|
|
+ taskImportCommon.setException(true);
|
|
|
|
+ taskImportCommon.writeImportResultTxt(finalTxtList.toString());
|
|
throw new BusinessException(JSONObject.toJSONString(excelErrorList));
|
|
throw new BusinessException(JSONObject.toJSONString(excelErrorList));
|
|
}
|
|
}
|
|
return finalList;
|
|
return finalList;
|
|
@@ -91,14 +101,11 @@ public class TaskExamStudentImportTemplete implements TaskImportTemplete {
|
|
TEStudentService teStudentService = SpringContextHolder.getBean(TEStudentService.class);
|
|
TEStudentService teStudentService = SpringContextHolder.getBean(TEStudentService.class);
|
|
TBUserRoleService tbUserRoleService = SpringContextHolder.getBean(TBUserRoleService.class);
|
|
TBUserRoleService tbUserRoleService = SpringContextHolder.getBean(TBUserRoleService.class);
|
|
TBExamInvigilateUserService tbExamInvigilateUserService = SpringContextHolder.getBean(TBExamInvigilateUserService.class);
|
|
TBExamInvigilateUserService tbExamInvigilateUserService = SpringContextHolder.getBean(TBExamInvigilateUserService.class);
|
|
- String timeFormat = taskImportCommon.getTimeFormat();
|
|
|
|
|
|
|
|
List<TEExamStudent> teExamStudentList = new ArrayList<>();
|
|
List<TEExamStudent> teExamStudentList = new ArrayList<>();
|
|
List<TEStudent> teStudentList = new ArrayList<>();
|
|
List<TEStudent> teStudentList = new ArrayList<>();
|
|
List<TBUserRole> tbUserRoleList = new ArrayList<>();
|
|
List<TBUserRole> tbUserRoleList = new ArrayList<>();
|
|
List<TBExamInvigilateUser> tbExamInvigilateUserList = new ArrayList<>();
|
|
List<TBExamInvigilateUser> tbExamInvigilateUserList = new ArrayList<>();
|
|
- List<String> txtList = new ArrayList();
|
|
|
|
- txtList.add(DateUtil.format(new Date(), timeFormat) + "->开始准备处理导入的考生数据");
|
|
|
|
int y = 0, min = 0;
|
|
int y = 0, min = 0;
|
|
try {
|
|
try {
|
|
Gson gson = new Gson();
|
|
Gson gson = new Gson();
|
|
@@ -107,27 +114,27 @@ public class TaskExamStudentImportTemplete implements TaskImportTemplete {
|
|
//保存用户
|
|
//保存用户
|
|
for (int i = 0; i < finalList.size(); i++) {
|
|
for (int i = 0; i < finalList.size(); i++) {
|
|
LinkedMultiValueMap<Integer, Object> finalMap = finalList.get(i);
|
|
LinkedMultiValueMap<Integer, Object> finalMap = finalList.get(i);
|
|
- List<Object> examStudentDtoImportList = finalMap.get(i);
|
|
|
|
|
|
+ List<Object> examStudentImportDtoList = finalMap.get(i);
|
|
min = 0;
|
|
min = 0;
|
|
- int max = SystemConstant.MAX_IMPORT_SIZE, size = examStudentDtoImportList.size();
|
|
|
|
|
|
+ int max = SystemConstant.MAX_IMPORT_SIZE, size = examStudentImportDtoList.size();
|
|
if (max >= size) {
|
|
if (max >= size) {
|
|
max = size;
|
|
max = size;
|
|
}
|
|
}
|
|
while (max <= size) {
|
|
while (max <= size) {
|
|
- List subList = examStudentDtoImportList.subList(min, max);
|
|
|
|
|
|
+ List subList = examStudentImportDtoList.subList(min, max);
|
|
for (y = 0; y < subList.size(); y++) {
|
|
for (y = 0; y < subList.size(); y++) {
|
|
- ExamStudentDtoImport examStudentDtoImport = (ExamStudentDtoImport) subList.get(y);
|
|
|
|
- Map m = (Map) teExamActivityMap.get(examStudentDtoImport.getExamActivityCode());
|
|
|
|
|
|
+ ExamStudentImportDto examStudentImportDto = (ExamStudentImportDto) subList.get(y);
|
|
|
|
+ Map m = (Map) teExamActivityMap.get(examStudentImportDto.getExamActivityCode());
|
|
m = SystemConstant.timeTransform(m);
|
|
m = SystemConstant.timeTransform(m);
|
|
TEExamActivity teExamActivity = gson.fromJson(gson.toJson(m), TEExamActivity.class);
|
|
TEExamActivity teExamActivity = gson.fromJson(gson.toJson(m), TEExamActivity.class);
|
|
//先根据证件号+科目代码查询考生是否存在,存在则更新,不存在则插入
|
|
//先根据证件号+科目代码查询考生是否存在,存在则更新,不存在则插入
|
|
QueryWrapper<TEExamStudent> teExamStudentQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<TEExamStudent> teExamStudentQueryWrapper = new QueryWrapper<>();
|
|
- teExamStudentQueryWrapper.lambda().eq(TEExamStudent::getIdentity, examStudentDtoImport.getIdentity()).eq(TEExamStudent::getCourseCode, examStudentDtoImport.getCourseCode());
|
|
|
|
|
|
+ teExamStudentQueryWrapper.lambda().eq(TEExamStudent::getIdentity, examStudentImportDto.getIdentity()).eq(TEExamStudent::getCourseCode, examStudentImportDto.getCourseCode());
|
|
TEExamStudent teExamStudent = teExamStudentService.getOne(teExamStudentQueryWrapper);
|
|
TEExamStudent teExamStudent = teExamStudentService.getOne(teExamStudentQueryWrapper);
|
|
//如果为空则插入考生数据,插入考生前先插入学生档案数据
|
|
//如果为空则插入考生数据,插入考生前先插入学生档案数据
|
|
if (Objects.isNull(teExamStudent)) {
|
|
if (Objects.isNull(teExamStudent)) {
|
|
//先插入学生档案数据
|
|
//先插入学生档案数据
|
|
- TEStudent teStudent = new TEStudent(taskImportCommon.getOrgId(), examStudentDtoImport.getIdentity(), examStudentDtoImport.getName(), taskImportCommon.getCreateId());
|
|
|
|
|
|
+ TEStudent teStudent = new TEStudent(taskImportCommon.getOrgId(), examStudentImportDto.getIdentity(), examStudentImportDto.getName(), taskImportCommon.getCreateId());
|
|
teStudentService.save(teStudent);
|
|
teStudentService.save(teStudent);
|
|
teStudentList.add(teStudent);
|
|
teStudentList.add(teStudent);
|
|
|
|
|
|
@@ -136,19 +143,19 @@ public class TaskExamStudentImportTemplete implements TaskImportTemplete {
|
|
tbUserRoleService.save(tbUserRole);
|
|
tbUserRoleService.save(tbUserRole);
|
|
tbUserRoleList.add(tbUserRole);
|
|
tbUserRoleList.add(tbUserRole);
|
|
|
|
|
|
- teExamStudent = gson.fromJson(gson.toJson(examStudentDtoImport), TEExamStudent.class);
|
|
|
|
|
|
+ teExamStudent = gson.fromJson(gson.toJson(examStudentImportDto), TEExamStudent.class);
|
|
teExamStudent.setExamId(taskImportCommon.getExamId());
|
|
teExamStudent.setExamId(taskImportCommon.getExamId());
|
|
teExamStudent.setExamActivityId(teExamActivity.getId());
|
|
teExamStudent.setExamActivityId(teExamActivity.getId());
|
|
teExamStudent.setStudentId(teStudent.getId());
|
|
teExamStudent.setStudentId(teStudent.getId());
|
|
teExamStudent.setCreateId(taskImportCommon.getCreateId());
|
|
teExamStudent.setCreateId(taskImportCommon.getCreateId());
|
|
} else {
|
|
} else {
|
|
teExamStudent.setUpdateId(taskImportCommon.getCreateId());
|
|
teExamStudent.setUpdateId(taskImportCommon.getCreateId());
|
|
- teExamStudent.setName(examStudentDtoImport.getName());
|
|
|
|
- teExamStudent.setCourseName(examStudentDtoImport.getCourseName());
|
|
|
|
- teExamStudent.setGrade(examStudentDtoImport.getGrade());
|
|
|
|
- teExamStudent.setClassNo(examStudentDtoImport.getClassNo());
|
|
|
|
- teExamStudent.setRoomCode(examStudentDtoImport.getRoomCode());
|
|
|
|
- teExamStudent.setRoomName(examStudentDtoImport.getRoomName());
|
|
|
|
|
|
+ teExamStudent.setName(examStudentImportDto.getName());
|
|
|
|
+ teExamStudent.setCourseName(examStudentImportDto.getCourseName());
|
|
|
|
+ teExamStudent.setGrade(examStudentImportDto.getGrade());
|
|
|
|
+ teExamStudent.setClassNo(examStudentImportDto.getClassNo());
|
|
|
|
+ teExamStudent.setRoomCode(examStudentImportDto.getRoomCode());
|
|
|
|
+ teExamStudent.setRoomName(examStudentImportDto.getRoomName());
|
|
teExamStudent.setExamActivityId(teExamActivity.getId());
|
|
teExamStudent.setExamActivityId(teExamActivity.getId());
|
|
}
|
|
}
|
|
teExamStudentService.saveOrUpdate(teExamStudent);
|
|
teExamStudentService.saveOrUpdate(teExamStudent);
|