|
@@ -41,6 +41,7 @@ import org.springframework.cache.annotation.CachePut;
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
@@ -51,7 +52,6 @@ import java.math.BigDecimal;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
import java.util.regex.Pattern;
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* @Description: 考试批次 服务实现类
|
|
* @Description: 考试批次 服务实现类
|
|
@@ -154,46 +154,24 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public List<TEExamWaitDto> getWaitingExam(Long studentId, Long examId, Long orgId) {
|
|
public List<TEExamWaitDto> getWaitingExam(Long studentId, Long examId, Long orgId) {
|
|
- List<TEExamWaitDto> list = teExamMapper.getWaitingExam(studentId, examId, orgId);
|
|
|
|
- if (Objects.nonNull(list) && list.size() > 0) {
|
|
|
|
- Set<String> examActivityIdsTemp = new LinkedHashSet<>();
|
|
|
|
- Map<Long, TEExamWaitDto> setMap = new LinkedHashMap<>();
|
|
|
|
- for (TEExamWaitDto t : list) {
|
|
|
|
- setMap.put(t.getId(), t);
|
|
|
|
- if (t.getExamActivityId().indexOf(",") != -1) {
|
|
|
|
- examActivityIdsTemp.addAll(Arrays.asList(t.getExamActivityId().split(",")));
|
|
|
|
- } else {
|
|
|
|
- examActivityIdsTemp.add(t.getExamActivityId());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- Set<Long> examActivityIds = examActivityIdsTemp.stream().map(s -> Long.parseLong(s))
|
|
|
|
- .collect(Collectors.toSet());
|
|
|
|
- List<TEExamActivityWaitDto> teExamActivityWaitList = teExamActivityService
|
|
|
|
- .getWaitingExam(studentId, examActivityIds, null);
|
|
|
|
- Map<Long, Set<TEExamActivityWaitDto>> map = new HashMap<>();
|
|
|
|
- teExamActivityWaitList.forEach(v -> {
|
|
|
|
- Set<TEExamActivityWaitDto> teExamActivityWaitDtos = null;
|
|
|
|
- if (Objects.isNull(map.get(v.getExamId()))) {
|
|
|
|
- teExamActivityWaitDtos = new HashSet<>();
|
|
|
|
- } else {
|
|
|
|
- teExamActivityWaitDtos = map.get(v.getExamId());
|
|
|
|
- }
|
|
|
|
- teExamActivityWaitDtos.add(v);
|
|
|
|
- map.put(v.getExamId(), teExamActivityWaitDtos);
|
|
|
|
- ExamCacheBean examCache = getExamCacheBeanNative(v.getExamId());
|
|
|
|
- ExamStudentCacheBean examStudentCacheBean = teExamStudentService
|
|
|
|
- .getExamStudentCacheBean(v.getExamStudentId());
|
|
|
|
- v.setLeftExamCount(
|
|
|
|
- (examCache.getExamCount().intValue() - (examStudentCacheBean.getAlreadyExamCount().intValue())
|
|
|
|
- < 0 ?
|
|
|
|
- 0 :
|
|
|
|
- examCache.getExamCount().intValue() - (examStudentCacheBean.getAlreadyExamCount()
|
|
|
|
- .intValue())));
|
|
|
|
- });
|
|
|
|
- list.clear();
|
|
|
|
- setMap.forEach((k, v) -> {
|
|
|
|
- v.setActivities(new ArrayList<>(map.get(k)));
|
|
|
|
- list.add(v);
|
|
|
|
|
|
+ List<TEExamWaitDto> list = new ArrayList<>();
|
|
|
|
+ Map<String, List<Long>> examActivityIdMap = themisCacheService.getExamListCache(examId.toString());
|
|
|
|
+ if (!CollectionUtils.isEmpty(examActivityIdMap)) {
|
|
|
|
+ examActivityIdMap.forEach((k, v) -> {
|
|
|
|
+ ExamCacheBean examCache = getExamCacheBeanNative(examId);
|
|
|
|
+ TEExamWaitDto teExamWaitDto = new TEExamWaitDto(examId, Long.parseLong(k), examCache.getName(), examCache.getCode());
|
|
|
|
+ List<TEExamActivityWaitDto> teExamActivityWaitList = teExamActivityService.getWaitingExam(studentId, new HashSet<>(v));
|
|
|
|
+ Map<Long, Set<TEExamActivityWaitDto>> map = new HashMap<>();
|
|
|
|
+ teExamActivityWaitList.forEach(i -> {
|
|
|
|
+ Set<TEExamActivityWaitDto> teExamActivityWaitDtos = Objects.nonNull(map.get(examId)) ? map.get(examId) : new LinkedHashSet<>();
|
|
|
|
+ teExamActivityWaitDtos.add(i);
|
|
|
|
+ map.put(examId, teExamActivityWaitDtos);
|
|
|
|
+ ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(i.getExamStudentId());
|
|
|
|
+ Integer leftExamCount = examCache.getExamCount().intValue() - examStudentCacheBean.getAlreadyExamCount().intValue() < 0 ? 0 : examCache.getExamCount().intValue() - examStudentCacheBean.getAlreadyExamCount().intValue();
|
|
|
|
+ i.setLeftExamCount(leftExamCount);
|
|
|
|
+ });
|
|
|
|
+ teExamWaitDto.setActivities(new ArrayList<>(map.get(k)));
|
|
|
|
+ list.add(teExamWaitDto);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
return list;
|
|
return list;
|