|
@@ -0,0 +1,207 @@
|
|
|
+package com.qmth.distributed.print.business.service.impl;
|
|
|
+
|
|
|
+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.qmth.distributed.print.business.bean.params.BasicExamStudentParam;
|
|
|
+import com.qmth.distributed.print.business.bean.result.BasicExamStudentResult;
|
|
|
+import com.qmth.distributed.print.business.entity.BasicExamStudent;
|
|
|
+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.bean.dto.DataPermissionRule;
|
|
|
+import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
+import com.qmth.teachcloud.common.entity.BasicCourse;
|
|
|
+import com.qmth.teachcloud.common.entity.SysUser;
|
|
|
+import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
+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.ServletUtil;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+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;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 考生字典表 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author CaoZixuan
|
|
|
+ * @since 2024-02-22
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMapper, BasicExamStudent> implements BasicExamStudentService {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private BasicRoleDataPermissionService basicRoleDataPermissionService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private BasicCourseService basicCourseService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private BasicTeachClazzService basicTeachClazzService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private SysUserService sysUserService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IPage<BasicExamStudentResult> page(SysUser requestUser, Long semesterId, Long examId, String courseCode,
|
|
|
+ String teacher, String college, String major, Long teachClazzId, String examStudentInfo, int pageNumber,
|
|
|
+ int pageSize) {
|
|
|
+ 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());
|
|
|
+ IPage<BasicExamStudentResult> page = this.baseMapper.findBasicExamStudentPage(new Page<>(pageNumber, pageSize),
|
|
|
+ schoolId, semesterId, examId, courseCode, teacher, college, major, teachClazzId, examStudentInfo, dpr);
|
|
|
+ for (BasicExamStudentResult record : page.getRecords()) {
|
|
|
+ Long examStartTime = record.getExamStartTime();
|
|
|
+ Long examEndTime = record.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"));
|
|
|
+ record.setExamDate(date);
|
|
|
+ record.setExamTime(time);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public Long edit(BasicExamStudentParam basicExamStudentParam, SysUser requestUser) {
|
|
|
+ List<String> errorMsgList = new ArrayList<>();
|
|
|
+ Long schoolId = requestUser.getSchoolId();
|
|
|
+ Long requestUserId = requestUser.getId();
|
|
|
+
|
|
|
+ Long id = basicExamStudentParam.getId();
|
|
|
+ Long semesterId = basicExamStudentParam.getSemesterId();
|
|
|
+ Long examId = basicExamStudentParam.getExamId();
|
|
|
+ String courseCode = basicExamStudentParam.getCourseCode();
|
|
|
+ String studentName = basicExamStudentParam.getStudentName();
|
|
|
+ String studentCode = basicExamStudentParam.getStudentCode();
|
|
|
+ String college = basicExamStudentParam.getCollege();
|
|
|
+ String major = basicExamStudentParam.getMajor();
|
|
|
+ String teachClazz = basicExamStudentParam.getTeachClazz();
|
|
|
+ String paperNumber = basicExamStudentParam.getPaperNumber();
|
|
|
+ String teacherName = basicExamStudentParam.getTeacherName();
|
|
|
+ String teacherCode = basicExamStudentParam.getTeacherCode();
|
|
|
+ Long examStartTime = basicExamStudentParam.getExamStartTime();
|
|
|
+ Long examEndTime = basicExamStudentParam.getExamEndTime();
|
|
|
+ String examPlace = basicExamStudentParam.getExamPlace();
|
|
|
+ String examRoom = basicExamStudentParam.getExamRoom();
|
|
|
+
|
|
|
+ // 校验1 学期、考试、课程为下拉框,姓名、学号、教学班为文本框,均必填;
|
|
|
+ if (SystemConstant.longNotNull(semesterId)) {
|
|
|
+ errorMsgList.add("缺少学期id");
|
|
|
+ }
|
|
|
+ if (SystemConstant.longNotNull(examId)) {
|
|
|
+ errorMsgList.add("缺少考试id");
|
|
|
+ }
|
|
|
+ if (SystemConstant.strNotNull(courseCode)) {
|
|
|
+ errorMsgList.add("缺少课程编号");
|
|
|
+ }
|
|
|
+ BasicCourse basicCourse = basicCourseService.findByCourseCode(courseCode, schoolId);
|
|
|
+ if (Objects.isNull(basicCourse)) {
|
|
|
+ errorMsgList.add(String.format("缺少课程编号为[%s]", courseCode));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (SystemConstant.strNotNull(studentName)) {
|
|
|
+ errorMsgList.add("缺少学生姓名");
|
|
|
+ }
|
|
|
+ if (SystemConstant.strNotNull(studentCode)) {
|
|
|
+ errorMsgList.add("缺少学号");
|
|
|
+ }
|
|
|
+ if (SystemConstant.strNotNull(teachClazz)) {
|
|
|
+ errorMsgList.add("缺少教学班名称");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 校验2 试卷编号存在时,任课教师,考试时间,考点考场均必填;
|
|
|
+ if (SystemConstant.strNotNull(paperNumber)) {
|
|
|
+ String hasPaperNumberError = "存在试卷编号时: ";
|
|
|
+ if (!SystemConstant.strNotNull(teacherCode) || !SystemConstant.strNotNull(teacherName)) {
|
|
|
+ errorMsgList.add(hasPaperNumberError + "缺少任课教师信息");
|
|
|
+ } else {
|
|
|
+ // 存在教师信息,根据工号查询,不存在报错(缺少机构信息没法直接创建教师),存在更新姓名
|
|
|
+ SysUser teacher = sysUserService.getOne(
|
|
|
+ new QueryWrapper<SysUser>().lambda().eq(SysUser::getSchoolId, schoolId)
|
|
|
+ .eq(SysUser::getCode, teacherCode).last(SystemConstant.LIMIT1));
|
|
|
+ if (Objects.isNull(teacher)) {
|
|
|
+ errorMsgList.add(String.format("工号为[%s]的教师不存在,请先创建", teacherCode));
|
|
|
+ } else {
|
|
|
+ String dbTeacherName = teacher.getRealName();
|
|
|
+ if (!dbTeacherName.equals(teacherName)) {
|
|
|
+ teacher.setRealName(teacherName);
|
|
|
+ teacher.updateInfo(requestUserId);
|
|
|
+ sysUserService.updateById(teacher);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!SystemConstant.longNotNull(examStartTime) || !SystemConstant.longNotNull(examEndTime)) {
|
|
|
+ errorMsgList.add(hasPaperNumberError + "缺少考试时间");
|
|
|
+ }
|
|
|
+ if (!SystemConstant.strNotNull(examPlace)) {
|
|
|
+ errorMsgList.add(hasPaperNumberError + "缺少考点信息");
|
|
|
+ }
|
|
|
+ if (!SystemConstant.strNotNull(examRoom)) {
|
|
|
+ errorMsgList.add(hasPaperNumberError + "缺少考场信息");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(errorMsgList)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(String.join(";", errorMsgList));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 若教学班不存在则新建一个
|
|
|
+ BasicTeachClazz basicTeachClazz = basicTeachClazzService.findOrCreateBasicTeachClazz(requestUser, examId,
|
|
|
+ courseCode, teachClazz);
|
|
|
+
|
|
|
+ BasicExamStudent basicExamStudent = new BasicExamStudent();
|
|
|
+
|
|
|
+ if (SystemConstant.longNotNull(id)) {
|
|
|
+ // 编辑
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ 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) {
|
|
|
+
|
|
|
+ }
|
|
|
+}
|