Browse Source

bug update

haogh 1 year ago
parent
commit
1518f780e7

+ 19 - 4
src/main/java/com/qmth/exam/reserve/service/impl/StudentApplyServiceImpl.java

@@ -195,6 +195,7 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
         if (CollectionUtils.isEmpty(lineList)) {
             throw new StatusException("Excel无内容");
         }
+        ApplyTaskEntity task = getApplyTask();
         List<Map<String, Object>> failRecords = new ArrayList<Map<String, Object>>();
         Map<String, Long> teachingCache = getTeachingCache(level);
         Map<String, Long> agentCache = getAgentCache();
@@ -222,7 +223,7 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
             }
             StudentEntity student = null;
             try {
-                student = checkStd(studentCode, name, identityNumber);
+                student = checkStd(studentCode, name, identityNumber, task);
                 apply.setStudentId(student.getId());
                 apply.setApplyNumber(student.getApplyNumber());
             } catch (StatusException e) {
@@ -385,7 +386,8 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
             List<AgentAndTimeVO> tobeInsertTimeList = new ArrayList<>();
 
             // 考生已经完成预约-不做处理
-            if (studentApplyFinishCount == vo.getApplyNumber().intValue()) {
+            if (studentApplyFinishCount >= vo.getApplyNumber().intValue()) {
+                vo.setAgentTimeList(tobeInsertTimeList);
                 continue;
             }
 
@@ -560,7 +562,7 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
         return categoryList.stream().collect(Collectors.toMap(ExamSiteEntity::getName, ExamSiteEntity::getId));
     }
 
-    private StudentEntity checkStd(String studentCode, String name, String identityNumber) {
+    private StudentEntity checkStd(String studentCode, String name, String identityNumber, ApplyTaskEntity task) {
         LambdaQueryWrapper<StudentEntity> lm = new LambdaQueryWrapper<>();
         lm.eq(StudentEntity::getStudentCode, studentCode);
         lm.eq(StudentEntity::getName, name);
@@ -569,6 +571,9 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
         if (student == null) {
             throw new StatusException(" 考生信息填写错误");
         }
+        if (student.getApplyTaskId().equals(task.getId())) {
+            throw new StatusException(" 当前任务下不存在该考生");
+        }
         return student;
     }
 
@@ -602,6 +607,7 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
                     .collect(Collectors.groupingBy(StudentEntity::getCategoryId));
             // 2、考位是否充足
             List<TimePeriodEntity> timeList = listTimePeroid(taskId);
+            timeList = listNoCancelExamTimePeriod(timeList, taskId);
             checkTeachingCapacity(noFinishApplyMap, timeList, taskId);
             // 3、按照教学点安排考位。规则:不能和已预约的时间上有冲突
             for (Long key : noFinishApplyMap.keySet()) {
@@ -637,6 +643,15 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
 
     }
 
+    private List<TimePeriodEntity> listNoCancelExamTimePeriod(List<TimePeriodEntity> timeList, Long taskId) {
+        ApplyTaskEntity task = applyTaskService.getById(taskId);
+        Long longToday = DateUtil.getLongTimeByDate(DateUtil.formatShortSplitDateString(new Date()) + " 00:00:00");
+        Date today = new Date(longToday);
+        Date otherDay = DateUtil.addValues(today, Calendar.DAY_OF_MONTH, task.getAllowApplyCancelDays());
+        Long longOtherDay = DateUtil.getLongTimeByDate(DateUtil.formatShortSplitDateString(otherDay) + " 23:59:59");
+        return timeList.stream().filter(time -> time.getStartTime() > longOtherDay).collect(Collectors.toList());
+    }
+
     private List<StudentApplyEntity> assignStudentApply(Long userId, Long siteId, Long timeId,
             List<StudentEntity> teachingStudentList, Integer remainNum) {
         List<StudentApplyEntity> insertApplyList = new ArrayList<>();
@@ -1049,7 +1064,7 @@ public class StudentApplyServiceImpl extends ServiceImpl<StudentApplyDao, Studen
             Long longOtherDay = DateUtil.getLongTimeByDate(DateUtil.formatShortSplitDateString(otherDay) + " 00:00:00");
             if (longOtherDay >= startTime && longOtherDay <= endTime) {
                 SignInVO vo = new SignInVO();
-                vo.setExamDate(longToday);
+                vo.setExamDate(longOtherDay);
                 signInList.add(vo);
             }
         }

+ 2 - 1
src/main/java/com/qmth/exam/reserve/service/impl/StudentImportAsyncServiceImpl.java

@@ -156,7 +156,8 @@ public class StudentImportAsyncServiceImpl implements StudentImportAsyncService
 
     private void saveStudent(StudentEntity studentEntity) {
         LambdaQueryWrapper<StudentEntity> wrapper = new LambdaQueryWrapper<StudentEntity>()
-                .eq(StudentEntity::getStudentCode, studentEntity.getStudentCode());
+                .eq(StudentEntity::getStudentCode, studentEntity.getStudentCode())
+                .eq(StudentEntity::getApplyTaskId, studentEntity.getApplyTaskId());
         StudentEntity existStudent = studentService.getOne(wrapper);
         if (existStudent != null) {
             existStudent.setName(studentEntity.getName());

+ 1 - 1
src/main/resources/mapper/StudentApplyMapper.xml

@@ -39,7 +39,7 @@
         <if test="req.taskId != null and req.taskId !=''">
             and s.apply_task_id=#{req.taskId}
         </if>
-        order by a.id
+        order by a.update_time desc
     </select>
 
     <select id="getHaveApplyCount" resultType="int">