|
@@ -41,6 +41,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.FileCopyUtils;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
@@ -50,6 +51,7 @@ import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @Description: 公共服务service impl
|
|
@@ -1010,31 +1012,32 @@ public class PrintCommonServiceServiceImpl implements PrintCommonService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public int saveBatchStudent(Long schoolId, String extendFields, List<String> classIds, Long examDetailCourseId, SysUser sysUser) {
|
|
|
- QueryWrapper<BasicStudent> queryWrapper1 = new QueryWrapper<>();
|
|
|
- queryWrapper1.lambda().eq(BasicStudent::getSchoolId, schoolId).in(BasicStudent::getClazzId, classIds);
|
|
|
- List<BasicStudent> basicStudents = basicStudentService.list(queryWrapper1);
|
|
|
+ public List<ExamStudent> createBatchStudent(Long schoolId, String extendFields, List<String> classIds, Long examDetailCourseId, SysUser sysUser) {
|
|
|
AtomicInteger atomicInteger = new AtomicInteger(1);
|
|
|
- List<ExamStudent> examStudents = new ArrayList<>();
|
|
|
+ List<ExamStudent> examStudentAll = new ArrayList<>();
|
|
|
SerialNumberParams ticketNumberParams = new SerialNumberParams("ticketNumber-" + schoolId, DateUtil.format(new Date(), "yyyyMM"), 6);
|
|
|
- for (BasicStudent basicStudent : basicStudents) {
|
|
|
- ExamStudent examStudent = new ExamStudent();
|
|
|
- examStudent.setId(SystemConstant.getDbUuid());
|
|
|
- examStudent.setSchoolId(schoolId);
|
|
|
- examStudent.setOrgId(sysUser.getOrgId());
|
|
|
- examStudent.setExamDetailCourseId(examDetailCourseId);
|
|
|
- examStudent.setStudentName(basicStudent.getStudentName());
|
|
|
- examStudent.setStudentCode(basicStudent.getStudentCode());
|
|
|
- // 准考证号(年月+000001)
|
|
|
- examStudent.setTicketNumber(createTempNumber(ticketNumberParams));
|
|
|
- examStudent.setExtendFields(extendFields);
|
|
|
- examStudent.setSiteNumber(String.valueOf(atomicInteger.getAndIncrement()));
|
|
|
- examStudent.setClazzId(String.valueOf(basicStudent.getClazzId()));
|
|
|
- examStudent.setCreateId(sysUser.getId());
|
|
|
- examStudents.add(examStudent);
|
|
|
+
|
|
|
+ for (String classId : classIds) {
|
|
|
+ List<ExamStudent> basicStudents = examStudentService.listExamStudentBySchoolIdAndClazzId(schoolId, classId);
|
|
|
+
|
|
|
+ basicStudents = basicStudents.stream().map(examStudent->{
|
|
|
+ examStudent.setId(SystemConstant.getDbUuid());
|
|
|
+ examStudent.setSchoolId(schoolId);
|
|
|
+ examStudent.setOrgId(sysUser.getOrgId());
|
|
|
+ examStudent.setExamDetailCourseId(examDetailCourseId);
|
|
|
+ // 准考证号(年月+000001)
|
|
|
+ examStudent.setTicketNumber(createTempNumber(ticketNumberParams));
|
|
|
+ examStudent.setExtendFields(extendFields);
|
|
|
+ examStudent.setSiteNumber(String.valueOf(atomicInteger.getAndIncrement()));
|
|
|
+ examStudent.setCreateId(sysUser.getId());
|
|
|
+ return examStudent;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ if(!CollectionUtils.isEmpty(basicStudents)) {
|
|
|
+ examStudentAll.addAll(basicStudents);
|
|
|
+ }
|
|
|
}
|
|
|
- examStudentService.saveBatch(examStudents);
|
|
|
- return examStudents.size();
|
|
|
+
|
|
|
+ return examStudentAll;
|
|
|
}
|
|
|
|
|
|
public String createTempNumber(SerialNumberParams serialNumberParams) {
|