ExamCertificationServiceImpl.java 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. package com.keao.edu.user.service.impl;
  2. import com.keao.edu.auth.api.client.SysUserFeignService;
  3. import com.keao.edu.auth.api.entity.SysUser;
  4. import com.keao.edu.common.dal.BaseDAO;
  5. import com.keao.edu.common.service.impl.BaseServiceImpl;
  6. import com.keao.edu.user.api.entity.Student;
  7. import com.keao.edu.user.dao.*;
  8. import com.keao.edu.user.dto.ExamCertificationDto;
  9. import com.keao.edu.user.dto.NeedCheckingDetailDto;
  10. import com.keao.edu.user.entity.ExamCertification;
  11. import com.keao.edu.user.entity.StudentExamResult;
  12. import com.keao.edu.user.entity.Subject;
  13. import com.keao.edu.user.service.ExamCertificationService;
  14. import com.keao.edu.user.service.StudentService;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import org.springframework.stereotype.Service;
  17. import org.springframework.transaction.annotation.Transactional;
  18. import java.util.List;
  19. import java.util.Map;
  20. import java.util.stream.Collectors;
  21. @Service
  22. public class ExamCertificationServiceImpl extends BaseServiceImpl<Long, ExamCertification> implements ExamCertificationService {
  23. @Autowired
  24. private ExamCertificationDao examCertificationDao;
  25. @Autowired
  26. private ExamRoomStudentRelationDao examRoomStudentRelationDao;
  27. @Autowired
  28. private SubjectDao subjectDao;
  29. @Autowired
  30. private SysUserFeignService sysUserFeignService;
  31. @Autowired
  32. private StudentService studentService;
  33. @Autowired
  34. private StudentExamResultDao studentExamResultDao;
  35. @Autowired
  36. private SysConfigDao sysConfigDao;
  37. @Override
  38. public BaseDAO<Long, ExamCertification> getDAO() {
  39. return examCertificationDao;
  40. }
  41. @Override
  42. public ExamCertification findByStuAndBasicId(Integer studentId, Long examRegistrationId) {
  43. return examCertificationDao.findByStuAndBasicId(studentId,examRegistrationId);
  44. }
  45. @Override
  46. public List<ExamCertificationDto> queryCertificationPage(Long examRegistrationId) {
  47. SysUser sysUser = sysUserFeignService.queryUserInfo();
  48. List<ExamCertificationDto> dataList = examCertificationDao.queryExamCertificationDtoPage(sysUser.getId(),examRegistrationId);
  49. if(dataList == null || dataList.size() < 0){
  50. return dataList;
  51. }
  52. List<Integer> subjectIds = dataList.stream().map(e -> e.getSubjectId()).collect(Collectors.toList());
  53. Map<Integer, String> subjectNameMap = this.getMap("subject", "id_", "name_", subjectIds, Integer.class, String.class);
  54. Student student = studentService.get(sysUser.getId());
  55. dataList.forEach(e->{
  56. e.setSubjectName(subjectNameMap.get(e.getSubjectId()));
  57. e.setRealName(sysUser.getRealName());
  58. e.setGender(sysUser.getGender());
  59. e.setCertificatePhoto(student.getCertificatePhoto());
  60. });
  61. return dataList;
  62. }
  63. @Override
  64. @Transactional(rollbackFor = Exception.class)
  65. public NeedCheckingDetailDto needCheckingDetail(Long examRegistrationId) {
  66. NeedCheckingDetailDto needCheckingDetailDto = examCertificationDao.needCheckingDetail(examRegistrationId);
  67. //等待学员数
  68. String signInTime = needCheckingDetailDto.getSignInTime();
  69. SysUser sysUser = sysUserFeignService.queryUserInfo();
  70. Integer waitNum = examRoomStudentRelationDao.sumWaitNum(needCheckingDetailDto.getExamRoomId(),signInTime,sysUser.getId());
  71. needCheckingDetailDto.setWaitNum(waitNum);
  72. needCheckingDetailDto.setDesc(sysConfigDao.findConfigValue("exam_room_desc"));
  73. return needCheckingDetailDto;
  74. }
  75. @Override
  76. public ExamCertificationDto findDetailByStudentId(Long examRegistrationId) {
  77. ExamCertificationDto examCertificationDto = examCertificationDao.getExamCertificationDto(examRegistrationId);
  78. Subject subject = subjectDao.get(examCertificationDto.getSubjectId());
  79. examCertificationDto.setSubjectName(subject.getName());
  80. Student student = studentService.getStudent(examCertificationDto.getStudentId());
  81. examCertificationDto.setRealName(student.getRealName());
  82. examCertificationDto.setGender(student.getGender());
  83. examCertificationDto.setCertificatePhoto(student.getCertificatePhoto());
  84. StudentExamResult studentExamResult = studentExamResultDao.findByRegistrationId(examRegistrationId);
  85. examCertificationDto.setConfirmStatus(studentExamResult.getConfirmStatus());
  86. return examCertificationDto;
  87. }
  88. @Override
  89. public void batchInsert(List<ExamCertification> examCertifications) {
  90. examCertificationDao.batchInsert(examCertifications);
  91. }
  92. @Override
  93. public int deleteWithRegist(List<Long> registIds) {
  94. return examCertificationDao.deleteWithRegist(registIds);
  95. }
  96. }