|
@@ -1,5 +1,7 @@
|
|
package com.qmth.exam.reserve.service.impl;
|
|
package com.qmth.exam.reserve.service.impl;
|
|
|
|
|
|
|
|
+import java.io.File;
|
|
|
|
+import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.io.InputStream;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
@@ -32,9 +34,11 @@ import com.qmth.boot.core.exception.StatusException;
|
|
import com.qmth.boot.tools.excel.ExcelReader;
|
|
import com.qmth.boot.tools.excel.ExcelReader;
|
|
import com.qmth.boot.tools.excel.enums.ExcelType;
|
|
import com.qmth.boot.tools.excel.enums.ExcelType;
|
|
import com.qmth.boot.tools.excel.model.DataMap;
|
|
import com.qmth.boot.tools.excel.model.DataMap;
|
|
|
|
+import com.qmth.boot.tools.io.ZipWriter;
|
|
import com.qmth.boot.tools.uuid.FastUUID;
|
|
import com.qmth.boot.tools.uuid.FastUUID;
|
|
import com.qmth.exam.reserve.bean.login.LoginUser;
|
|
import com.qmth.exam.reserve.bean.login.LoginUser;
|
|
import com.qmth.exam.reserve.bean.stdapply.AgentAndTimeVO;
|
|
import com.qmth.exam.reserve.bean.stdapply.AgentAndTimeVO;
|
|
|
|
+import com.qmth.exam.reserve.bean.stdapply.MaterialTitleInfo;
|
|
import com.qmth.exam.reserve.bean.stdapply.StudentApplyReq;
|
|
import com.qmth.exam.reserve.bean.stdapply.StudentApplyReq;
|
|
import com.qmth.exam.reserve.bean.stdapply.StudentApplyVO;
|
|
import com.qmth.exam.reserve.bean.stdapply.StudentApplyVO;
|
|
import com.qmth.exam.reserve.bean.stdapply.StudentImportVO;
|
|
import com.qmth.exam.reserve.bean.stdapply.StudentImportVO;
|
|
@@ -54,6 +58,7 @@ import com.qmth.exam.reserve.service.ApplyTaskService;
|
|
import com.qmth.exam.reserve.service.CategoryService;
|
|
import com.qmth.exam.reserve.service.CategoryService;
|
|
import com.qmth.exam.reserve.service.ExamRoomService;
|
|
import com.qmth.exam.reserve.service.ExamRoomService;
|
|
import com.qmth.exam.reserve.service.ExamSiteService;
|
|
import com.qmth.exam.reserve.service.ExamSiteService;
|
|
|
|
+import com.qmth.exam.reserve.service.MaterialGenerateService;
|
|
import com.qmth.exam.reserve.service.OperateLogService;
|
|
import com.qmth.exam.reserve.service.OperateLogService;
|
|
import com.qmth.exam.reserve.service.StudentApplyService;
|
|
import com.qmth.exam.reserve.service.StudentApplyService;
|
|
import com.qmth.exam.reserve.service.StudentService;
|
|
import com.qmth.exam.reserve.service.StudentService;
|
|
@@ -97,6 +102,9 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
|
|
@Autowired
|
|
@Autowired
|
|
private ExamRoomService examRoomService;
|
|
private ExamRoomService examRoomService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private MaterialGenerateService materialService;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public PageResult<StudentApplyVO> page(StudentApplyReq req) {
|
|
public PageResult<StudentApplyVO> page(StudentApplyReq req) {
|
|
IPage<StudentApplyVO> iPage = this.baseMapper
|
|
IPage<StudentApplyVO> iPage = this.baseMapper
|
|
@@ -463,7 +471,7 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
|
|
checkTeachingCapacity(map, timeList, taskId);
|
|
checkTeachingCapacity(map, timeList, taskId);
|
|
// 3、按照教学点安排考位。规则:不能和已预约的时间上有冲突
|
|
// 3、按照教学点安排考位。规则:不能和已预约的时间上有冲突
|
|
for (Long key : map.keySet()) {
|
|
for (Long key : map.keySet()) {
|
|
- List<ExamSiteEntity> siteList = listExamSite(key);
|
|
|
|
|
|
+ List<ExamSiteEntity> siteList = listExamSite(key, null);
|
|
List<StudentEntity> teachingStudentList = map.get(key);
|
|
List<StudentEntity> teachingStudentList = map.get(key);
|
|
for (TimePeriodEntity time : timeList) {
|
|
for (TimePeriodEntity time : timeList) {
|
|
for (ExamSiteEntity site : siteList) {
|
|
for (ExamSiteEntity site : siteList) {
|
|
@@ -544,7 +552,7 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
|
|
private void checkTeachingCapacity(Map<Long, List<StudentEntity>> map, List<TimePeriodEntity> timeList,
|
|
private void checkTeachingCapacity(Map<Long, List<StudentEntity>> map, List<TimePeriodEntity> timeList,
|
|
Long taskId) {
|
|
Long taskId) {
|
|
for (Long key : map.keySet()) {
|
|
for (Long key : map.keySet()) {
|
|
- List<ExamSiteEntity> siteList = listExamSite(key);
|
|
|
|
|
|
+ List<ExamSiteEntity> siteList = listExamSite(key, null);
|
|
// 总考位数量
|
|
// 总考位数量
|
|
Integer total = siteList.stream().collect(Collectors.summingInt(ExamSiteEntity::getCapacity))
|
|
Integer total = siteList.stream().collect(Collectors.summingInt(ExamSiteEntity::getCapacity))
|
|
* timeList.size();
|
|
* timeList.size();
|
|
@@ -592,9 +600,11 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
|
|
return timeList;
|
|
return timeList;
|
|
}
|
|
}
|
|
|
|
|
|
- private List<ExamSiteEntity> listExamSite(Long categoryId) {
|
|
|
|
|
|
+ private List<ExamSiteEntity> listExamSite(Long categoryId, Long examsiteId) {
|
|
LambdaQueryWrapper<ExamSiteEntity> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<ExamSiteEntity> wrapper = new LambdaQueryWrapper<>();
|
|
wrapper.eq(ExamSiteEntity::getCategoryId, categoryId);
|
|
wrapper.eq(ExamSiteEntity::getCategoryId, categoryId);
|
|
|
|
+ wrapper.eq(examsiteId != null, ExamSiteEntity::getId, examsiteId);
|
|
|
|
+ wrapper.eq(ExamSiteEntity::getEnable, Boolean.TRUE);
|
|
return examSiteService.list(wrapper);
|
|
return examSiteService.list(wrapper);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -723,4 +733,59 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
|
|
return DateUtil.addValues(Calendar.DAY_OF_MONTH, allowApplyCancelDays);
|
|
return DateUtil.addValues(Calendar.DAY_OF_MONTH, allowApplyCancelDays);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public File downloadSignIn(Long teachingId, Long agentId) {
|
|
|
|
+ ApplyTaskEntity applyTask = getApplyTask();
|
|
|
|
+ List<TimePeriodEntity> timePeriodList = listTimePeroid(applyTask.getId());
|
|
|
|
+ List<TimePeriodEntity> noCancelTimePeroidList = listNoCancelApplyTimePeroid(timePeriodList,
|
|
|
|
+ applyTask.getAllowApplyCancelDays());
|
|
|
|
+ if (noCancelTimePeroidList.isEmpty()) {
|
|
|
|
+ throw new StatusException("当前时间没有可下载的签到表");
|
|
|
|
+ }
|
|
|
|
+ List<ExamSiteEntity> siteList = listExamSite(teachingId, agentId);
|
|
|
|
+ if (siteList.isEmpty())
|
|
|
|
+ throw new StatusException("当前教学点下没有可用的考点");
|
|
|
|
+ CategoryEntity category = categoryService.getById(teachingId);
|
|
|
|
+ File tempFolder = new File("temp");
|
|
|
|
+ if (!tempFolder.exists()) {
|
|
|
|
+ tempFolder.mkdirs();
|
|
|
|
+ }
|
|
|
|
+ ZipWriter writer = null;
|
|
|
|
+ File zipFile = new File(tempFolder, category.getName() + "签到表.zip");
|
|
|
|
+ try {
|
|
|
|
+ writer = ZipWriter.create(zipFile);
|
|
|
|
+ for (ExamSiteEntity site : siteList) {
|
|
|
|
+ downloadByExamSite(writer, applyTask.getName(), site, noCancelTimePeroidList);
|
|
|
|
+ }
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ throw new StatusException("文件写入异常");
|
|
|
|
+ }
|
|
|
|
+ writer.close();
|
|
|
|
+ return zipFile;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public List<File> downloadByExamSite(ZipWriter writer, String taskName, ExamSiteEntity site,
|
|
|
|
+ List<TimePeriodEntity> timeList) throws IOException {
|
|
|
|
+ List<File> fileList = new ArrayList<>();
|
|
|
|
+ List<ExamRoomEntity> roomList = listExamRoom(site.getId());
|
|
|
|
+ MaterialTitleInfo title = new MaterialTitleInfo();
|
|
|
|
+ title.setTaskName(taskName);
|
|
|
|
+ title.setSiteName(site.getName());
|
|
|
|
+ for (TimePeriodEntity time : timeList) {
|
|
|
|
+ title.setTimePeriod(DateUtil.getStartAndEndTime(time.getStartTime(), time.getEndTime()));
|
|
|
|
+ for (ExamRoomEntity room : roomList) {
|
|
|
|
+ title.setAddress(room.getAddress());
|
|
|
|
+ title.setRoomCode(room.getCode());
|
|
|
|
+ List<StudentApplyVO> studentList = baseMapper.listStudentApply(time.getId(), room.getId());
|
|
|
|
+ if (!studentList.isEmpty()) {
|
|
|
|
+ File file = materialService.generateSignInForm(title, studentList);
|
|
|
|
+ writer.write(file, title.getSiteName(),
|
|
|
|
+ title.getTimePeriod() + " 第【" + title.getRoomCode() + "】考场" + ".pdf");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return fileList;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|