|
@@ -8,9 +8,10 @@ import com.keao.edu.common.page.PageInfo;
|
|
|
import com.keao.edu.common.service.SysMessageService;
|
|
|
import com.keao.edu.common.service.impl.BaseServiceImpl;
|
|
|
import com.keao.edu.common.tenant.TenantContextHolder;
|
|
|
-import com.keao.edu.thirdparty.message.provider.JiguangPushPlugin;
|
|
|
+import com.keao.edu.thirdparty.message.provider.YimeiSmsPlugin;
|
|
|
import com.keao.edu.user.api.enums.ExamModeEnum;
|
|
|
import com.keao.edu.user.dao.*;
|
|
|
+import com.keao.edu.user.dto.ExamRoomExamTimeDto;
|
|
|
import com.keao.edu.user.dto.ExaminationBasicDto;
|
|
|
import com.keao.edu.user.entity.*;
|
|
|
import com.keao.edu.user.enums.ExamStatusEnum;
|
|
@@ -29,6 +30,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -57,6 +59,10 @@ public class ExaminationBasicServiceImpl extends BaseServiceImpl<Long, Examinati
|
|
|
private SysMessageService sysMessageService;
|
|
|
@Autowired
|
|
|
private StudentExamResultService studentExamResultService;
|
|
|
+ @Autowired
|
|
|
+ private ExamRoomDao examRoomDao;
|
|
|
+ @Autowired
|
|
|
+ private TenantInfoDao tenantInfoDao;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Long, ExaminationBasic> getDAO() {
|
|
@@ -76,7 +82,10 @@ public class ExaminationBasicServiceImpl extends BaseServiceImpl<Long, Examinati
|
|
|
throw new BizException("请指定考试地点");
|
|
|
}
|
|
|
if (Objects.isNull(examinationBasic.getEnrollStartTime()) || Objects.isNull(examinationBasic.getEnrollEndTime())) {
|
|
|
- throw new BizException("请指定考试开始与结束时间");
|
|
|
+ throw new BizException("请指定报名开始与结束时间");
|
|
|
+ }
|
|
|
+ if(examinationBasic.getEnrollStartTime().compareTo(examinationBasic.getEnrollEndTime())>=0){
|
|
|
+ throw new BizException("报名时间异常");
|
|
|
}
|
|
|
|
|
|
if(ExamModeEnum.ONLINE.equals(examinationBasic.getExamMode())){
|
|
@@ -153,6 +162,38 @@ public class ExaminationBasicServiceImpl extends BaseServiceImpl<Long, Examinati
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public void examEndRemind() {
|
|
|
+ LocalDate today = LocalDate.now();
|
|
|
+ List<ExaminationBasic> endExams = examinationBasicDao.getEndExamsWithDayAndStatus(today.plusDays(-1).toString());
|
|
|
+ if(CollectionUtils.isEmpty(endExams)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Set<Integer> tenantIds = endExams.stream().map(e->Integer.valueOf(e.getTenantId())).collect(Collectors.toSet());
|
|
|
+ List<TenantInfo> tenants = tenantInfoDao.getTenants(new ArrayList<>(tenantIds));
|
|
|
+ List<String> phones = tenants.stream().map(TenantInfo::getContactPhone).collect(Collectors.toList());
|
|
|
+ Map<Integer, TenantInfo> idTenantMap = tenants.stream().collect(Collectors.toMap(TenantInfo::getId, e -> e));
|
|
|
+ List<SysUser> tenantUsers = sysUserDao.getWithPones(phones);
|
|
|
+ Map<String, SysUser> phoneUserMap = tenantUsers.stream().collect(Collectors.toMap(SysUser::getPhone, t -> t));
|
|
|
+
|
|
|
+ for (ExaminationBasic endExam : endExams) {
|
|
|
+ TenantInfo tenantInfo = idTenantMap.get(Integer.valueOf(endExam.getTenantId()));
|
|
|
+ if(Objects.isNull(tenantInfo)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ SysUser sysUser = phoneUserMap.get(tenantInfo.getContactPhone());
|
|
|
+ if(Objects.isNull(sysUser)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Map<Integer, String> userPhoneMap = new HashMap<>();
|
|
|
+ userPhoneMap.put(sysUser.getId(), sysUser.getPhone());
|
|
|
+
|
|
|
+ sysMessageService.batchSendMessage(MessageTypeEnum.EXAM_END_REMIND,
|
|
|
+ userPhoneMap, null, 0, null, YimeiSmsPlugin.PLUGIN_NAME,
|
|
|
+ tenantInfo.getName(), endExam.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void updateExamBasicStatus(Long examId, ExamStatusEnum statusEnum, Integer operatorId) {
|
|
|
if(Objects.isNull(examId)){
|
|
@@ -302,6 +343,10 @@ public class ExaminationBasicServiceImpl extends BaseServiceImpl<Long, Examinati
|
|
|
ExamStatusEnum.EXAM_END.equals(existsExam.getStatus())){
|
|
|
throw new BizException("无法修改");
|
|
|
}
|
|
|
+ ExamRoomExamTimeDto examRoomExamTime = examRoomDao.getExamRoomExamTime(examinationBasic.getId());
|
|
|
+ if(Objects.nonNull(examRoomExamTime)&&examinationBasic.getEnrollEndTime().compareTo(examRoomExamTime.getExamStartTime())>0){
|
|
|
+ throw new BizException("报名结束时间不得在考试开始时间之后");
|
|
|
+ }
|
|
|
examLifecycleLogDao.insert(new ExamLifecycleLog(existsExam.getId().intValue(), "修改报名时间", operatorId));
|
|
|
examRegistIsChange=true;
|
|
|
}
|
|
@@ -319,6 +364,9 @@ public class ExaminationBasicServiceImpl extends BaseServiceImpl<Long, Examinati
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ examinationBasic.setActualExamStartTime(existsExam.getActualExamStartTime());
|
|
|
+ examinationBasic.setActualExamEndTime(existsExam.getActualExamEndTime());
|
|
|
+
|
|
|
examinationBasicDao.update(examinationBasic);
|
|
|
if(examRegistIsChange){
|
|
|
examOrganizationRelationService.examDateChangePush(examinationBasic.getId());
|