|
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import com.qmth.distributed.print.business.bean.dto.BasicExamStudentDto;
|
|
|
import com.qmth.distributed.print.business.bean.params.BasicExamStudentParam;
|
|
|
import com.qmth.distributed.print.business.bean.result.BasicExamStudentResult;
|
|
|
import com.qmth.distributed.print.business.entity.BasicExamStudent;
|
|
@@ -11,6 +13,7 @@ import com.qmth.distributed.print.business.entity.BasicTeachClazz;
|
|
|
import com.qmth.distributed.print.business.mapper.BasicExamStudentMapper;
|
|
|
import com.qmth.distributed.print.business.service.BasicExamStudentService;
|
|
|
import com.qmth.distributed.print.business.service.BasicTeachClazzService;
|
|
|
+import com.qmth.teachcloud.common.base.BaseEntity;
|
|
|
import com.qmth.teachcloud.common.bean.dto.DataPermissionRule;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
import com.qmth.teachcloud.common.entity.BasicCourse;
|
|
@@ -20,18 +23,23 @@ import com.qmth.teachcloud.common.service.BasicCourseService;
|
|
|
import com.qmth.teachcloud.common.service.BasicRoleDataPermissionService;
|
|
|
import com.qmth.teachcloud.common.service.SysUserService;
|
|
|
import com.qmth.teachcloud.common.util.ConvertUtil;
|
|
|
+import com.qmth.teachcloud.common.util.ExcelUtil;
|
|
|
import com.qmth.teachcloud.common.util.ServletUtil;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springframework.web.multipart.MultipartFile;
|
|
|
+import org.springframework.util.LinkedMultiValueMap;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.util.*;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -86,9 +94,81 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
|
|
|
return page;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<BasicExamStudentResult> list(SysUser requestUser, Long semesterId, Long examId, String courseCode,
|
|
|
+ String teacher, String college, String major, Long teachClazzId, String examStudentInfo) {
|
|
|
+ Long schoolId = requestUser.getSchoolId();
|
|
|
+
|
|
|
+ courseCode = SystemConstant.translateSpecificSign(courseCode);
|
|
|
+ teacher = SystemConstant.translateSpecificSign(teacher);
|
|
|
+ college = SystemConstant.translateSpecificSign(college);
|
|
|
+ major = SystemConstant.translateSpecificSign(major);
|
|
|
+ examStudentInfo = SystemConstant.translateSpecificSign(examStudentInfo);
|
|
|
+
|
|
|
+ DataPermissionRule dpr = basicRoleDataPermissionService.findDataPermission(schoolId, requestUser.getId(),
|
|
|
+ ServletUtil.getRequest().getServletPath());
|
|
|
+ List<BasicExamStudentResult> list = this.baseMapper.findBasicExamStudentList(schoolId, semesterId, examId,
|
|
|
+ courseCode, teacher, college, major, teachClazzId, examStudentInfo, dpr);
|
|
|
+ for (BasicExamStudentResult basicExamStudentResult : list) {
|
|
|
+ Long examStartTime = basicExamStudentResult.getExamStartTime();
|
|
|
+ Long examEndTime = basicExamStudentResult.getExamEndTime();
|
|
|
+ if (SystemConstant.longNotNull(examStartTime) && SystemConstant.longNotNull(examEndTime)) {
|
|
|
+ Map<String, Object> dateMap = ConvertUtil.analyzeDateAndTime(examStartTime, examEndTime);
|
|
|
+ String date = String.valueOf(dateMap.get("date"));
|
|
|
+ String time = String.valueOf(dateMap.get("time"));
|
|
|
+ basicExamStudentResult.setExamDate(date);
|
|
|
+ basicExamStudentResult.setExamTime(time);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public Long save(BasicExamStudentParam basicExamStudentParam, SysUser requestUser) {
|
|
|
+ BasicExamStudent basicExamStudent = this.editEntityHelp(basicExamStudentParam, requestUser);
|
|
|
+ this.saveOrUpdate(basicExamStudent);
|
|
|
+ return basicExamStudent.getId();
|
|
|
+ }
|
|
|
+
|
|
|
@Transactional
|
|
|
@Override
|
|
|
- public Long edit(BasicExamStudentParam basicExamStudentParam, SysUser requestUser) {
|
|
|
+ public void buildImportObjects(Map<String, Object> map) throws IOException, NoSuchFieldException {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void exportLogic(HttpServletResponse response, Long semesterId, Long examId,
|
|
|
+ String courseCode, String teacher, String college, String major, Long teachClazzId, String examStudentInfo)
|
|
|
+ throws Exception {
|
|
|
+ SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
+ List<BasicExamStudentResult> list = this.list(requestUser, semesterId, examId, courseCode, teacher, college,
|
|
|
+ major, teachClazzId, examStudentInfo);
|
|
|
+ List<BasicExamStudentDto> exportDto = list.stream().flatMap(e -> {
|
|
|
+ BasicExamStudentDto basicExamStudentDto = new BasicExamStudentDto();
|
|
|
+ BeanUtils.copyProperties(e, basicExamStudentDto);
|
|
|
+ return Stream.of(basicExamStudentDto);
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 生成excel文件
|
|
|
+ ExcelUtil.excelExport("考生字典数据", BasicExamStudentDto.class, exportDto, response);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public void deleteBatch(List<Long> idList) {
|
|
|
+ this.removeByIds(idList);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 构造考生新增/编辑对象
|
|
|
+ *
|
|
|
+ * @param basicExamStudentParam 考生参数
|
|
|
+ * @param requestUser 请求人
|
|
|
+ * @return 考生对象
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public BasicExamStudent editEntityHelp(BasicExamStudentParam basicExamStudentParam, SysUser requestUser) {
|
|
|
List<String> errorMsgList = new ArrayList<>();
|
|
|
Long schoolId = requestUser.getSchoolId();
|
|
|
Long requestUserId = requestUser.getId();
|
|
@@ -136,6 +216,7 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
|
|
|
}
|
|
|
|
|
|
// 校验2 试卷编号存在时,任课教师,考试时间,考点考场均必填;
|
|
|
+ Long teacherId = null;
|
|
|
if (SystemConstant.strNotNull(paperNumber)) {
|
|
|
String hasPaperNumberError = "存在试卷编号时: ";
|
|
|
if (!SystemConstant.strNotNull(teacherCode) || !SystemConstant.strNotNull(teacherName)) {
|
|
@@ -155,6 +236,7 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
|
|
|
sysUserService.updateById(teacher);
|
|
|
}
|
|
|
}
|
|
|
+ teacherId = teacher.getId();
|
|
|
}
|
|
|
|
|
|
if (!SystemConstant.longNotNull(examStartTime) || !SystemConstant.longNotNull(examEndTime)) {
|
|
@@ -177,31 +259,44 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
|
|
|
courseCode, teachClazz);
|
|
|
|
|
|
BasicExamStudent basicExamStudent = new BasicExamStudent();
|
|
|
+ basicExamStudent.setSchoolId(schoolId);
|
|
|
+ basicExamStudent.setSemesterId(semesterId);
|
|
|
+ basicExamStudent.setExamId(examId);
|
|
|
+ basicExamStudent.setCourseCode(courseCode);
|
|
|
+ basicExamStudent.setClazzId(basicTeachClazz.getId());
|
|
|
+ basicExamStudent.setStudentName(studentName);
|
|
|
+ basicExamStudent.setStudentCode(studentCode);
|
|
|
+ basicExamStudent.setCollege(college);
|
|
|
+ basicExamStudent.setMajor(major);
|
|
|
+ if (SystemConstant.strNotNull(paperNumber)) {
|
|
|
+ basicExamStudent.setPaperNumber(paperNumber);
|
|
|
+ basicExamStudent.setTeacherId(teacherId);
|
|
|
+ basicExamStudent.setExamStartTime(examStartTime);
|
|
|
+ basicExamStudent.setExamEndTime(examEndTime);
|
|
|
+ basicExamStudent.setExamPlace(examPlace);
|
|
|
+ basicExamStudent.setExamRoom(examRoom);
|
|
|
+ }
|
|
|
|
|
|
if (SystemConstant.longNotNull(id)) {
|
|
|
- // 编辑
|
|
|
-
|
|
|
+ // 编辑 (学号不可更改)
|
|
|
+ BasicExamStudent dbBasicExamStudent = this.getById(id);
|
|
|
+ if (Objects.isNull(dbBasicExamStudent)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("考生不存在");
|
|
|
+ }
|
|
|
+ if (!studentCode.equals(dbBasicExamStudent.getStudentCode())) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("编辑考生时,学号不可更改");
|
|
|
+ }
|
|
|
+ basicExamStudent.updateInfo(requestUserId);
|
|
|
+ } else {
|
|
|
+ // 新增 (学号在考试课程下唯一)
|
|
|
+ if (this.count(new QueryWrapper<BasicExamStudent>().lambda().eq(BasicExamStudent::getSchoolId, schoolId)
|
|
|
+ .eq(BasicExamStudent::getExamId, examId).eq(BasicExamStudent::getCourseCode, courseCode)
|
|
|
+ .eq(BasicExamStudent::getStudentCode, studentCode)) > 0) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(String.format("学号[%s]重复", studentCode));
|
|
|
+ }
|
|
|
+ basicExamStudent.insertInfo(requestUserId);
|
|
|
}
|
|
|
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- @Transactional
|
|
|
- @Override
|
|
|
- public void importLogic(MultipartFile file) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void exportLogic(HttpServletResponse response, Long schoolId, Long semesterId, Long examId,
|
|
|
- String courseCode, String teacher, String college, String major, String teachClazz,
|
|
|
- String examStudentInfo) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Transactional
|
|
|
- @Override
|
|
|
- public void deleteBatch(List<Long> idList) {
|
|
|
-
|
|
|
+ return basicExamStudent;
|
|
|
}
|
|
|
}
|