|
@@ -12,11 +12,9 @@ import com.qmth.themis.business.cache.bean.ExamStudentAnswerCacheBean;
|
|
|
import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
|
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
|
import com.qmth.themis.business.dto.AuthDto;
|
|
|
-import com.qmth.themis.business.dto.cache.TEStudentCacheDto;
|
|
|
import com.qmth.themis.business.entity.TBSession;
|
|
|
-import com.qmth.themis.business.enums.ExamRecordStatusEnum;
|
|
|
-import com.qmth.themis.business.enums.MobileModeEnum;
|
|
|
-import com.qmth.themis.business.enums.RoleEnum;
|
|
|
+import com.qmth.themis.business.enums.*;
|
|
|
+import com.qmth.themis.business.service.MqDtoService;
|
|
|
import com.qmth.themis.business.service.TEExamStudentService;
|
|
|
import com.qmth.themis.business.service.TEMobileService;
|
|
|
import com.qmth.themis.business.util.RedisUtil;
|
|
@@ -49,6 +47,9 @@ public class TEMobileServiceImpl implements TEMobileService {
|
|
|
@Resource
|
|
|
TencentYunUtil tencentYunUtil;
|
|
|
|
|
|
+ @Resource
|
|
|
+ MqDtoService mqDtoService;
|
|
|
+
|
|
|
@Override
|
|
|
public MobileAuthorizationBean authorization(MobileAuthorizationParamBean param) throws NoSuchAlgorithmException {
|
|
|
MobileModeEnum mode = MobileModeEnum.valueOf(param.getMode().toUpperCase());
|
|
@@ -68,9 +69,6 @@ public class TEMobileServiceImpl implements TEMobileService {
|
|
|
throw new BusinessException("未找到考生");
|
|
|
}
|
|
|
ExamRecordStatusEnum sta = ExamRecordCacheUtil.getStatus(ret.getRecordId());
|
|
|
-// if (ExamRecordStatusEnum.FIRST_PREPARE.equals(sta)) {
|
|
|
-// throw new BusinessException("该考试未开始答题");
|
|
|
-// }
|
|
|
if (ExamRecordStatusEnum.FINISHED.equals(sta) || ExamRecordStatusEnum.PERSISTED.equals(sta)) {
|
|
|
throw new BusinessException("该考试已结束");
|
|
|
}
|
|
@@ -79,20 +77,14 @@ public class TEMobileServiceImpl implements TEMobileService {
|
|
|
AuthDto authDto = (AuthDto) redisUtil.get(SystemConstant.studentOauth + "::" + es.getStudentId());
|
|
|
// 生成token
|
|
|
String token = RandomStringUtils.randomAlphanumeric(32);
|
|
|
- TEStudentCacheDto teStudentCacheDto = (TEStudentCacheDto) redisUtil.getStudent(es.getStudentId());
|
|
|
String source = null;
|
|
|
- if (Objects.equals(platform.name(), Platform.WIN.name())
|
|
|
- || Objects.equals(platform.name(), Platform.MAC.name())) {
|
|
|
- source = platform.getSource().split(",")[1];
|
|
|
- } else if (Objects.equals(platform.name(), Platform.WXAPP.name())
|
|
|
- || Objects.equals(platform.name(), Platform.WEB.name())) {
|
|
|
- source = platform.getSource();
|
|
|
- } else if (Objects.equals(platform.name(), Platform.IOS.name())
|
|
|
- || Objects.equals(platform.name(), Platform.ANDROID.name())) {
|
|
|
- source = platform.getSource().split(",")[2];
|
|
|
+ if (mode.equals(MobileModeEnum.MOBILE_MONITOR)) {
|
|
|
+ Source sourceEnum = MobileAuthCacheUtil.getSource(mode, code);
|
|
|
+ source = sourceEnum.name();
|
|
|
+ } else if (mode.equals(MobileModeEnum.PHOTO_UPLOAD) || mode.equals(MobileModeEnum.AUDIO_UPLOAD)) {
|
|
|
+ source = Source.OE_ANSWER.name();
|
|
|
}
|
|
|
- String sessionId = SessionUtil.digest(teStudentCacheDto.getIdentity(),
|
|
|
- Math.abs(authDto.getRoleCodes().toString().hashCode()), source);
|
|
|
+ String sessionId = MobileAuthCacheUtil.getSessionId(mode, code);
|
|
|
Map<String, Object> expireMap = SystemConstant.getExpireTime(platform);
|
|
|
Date expire = (Date) expireMap.get("date");
|
|
|
Long redisExpire = Long.parseLong(String.valueOf(expireMap.get("redisExpire")));
|
|
@@ -103,13 +95,17 @@ public class TEMobileServiceImpl implements TEMobileService {
|
|
|
ret.setSessionId(sessionId);
|
|
|
ret.setTime(System.currentTimeMillis());
|
|
|
ret.setMode(mode);
|
|
|
+ //mq发送消息start
|
|
|
+ mqDtoService.assembleSendOneWayMsg(MqTopicEnum.themisTopic.getCode(), platform.name(), tbSession, platform.name(), tbSession.getId(), es.getIdentity());
|
|
|
+ mqDtoService.assembleSendOneWayMsg(MqTopicEnum.themisTopic.getCode(), MqTagEnum.STUDENT.name(), SystemOperationEnum.LOGIN, MqTagEnum.STUDENT.name(), es.getStudentId(), es.getIdentity());
|
|
|
+ //mq发送消息end
|
|
|
//测试
|
|
|
String test = SignatureInfo.build(SignatureType.TOKEN, sessionId, token);
|
|
|
ret.setAccessToken(test);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
- private MobileAuthorizationBean monitorAuthorization(MobileModeEnum mode, String code) {
|
|
|
+ private MobileAuthorizationBean monitorAuthorization(MobileModeEnum mode, String code) throws NoSuchAlgorithmException {
|
|
|
Long recordId = MobileAuthCacheUtil.getRecordId(mode, code);
|
|
|
String monitorKey = MobileAuthCacheUtil.getMonitorKey(mode, code);
|
|
|
Source monitorVideoSource = MobileAuthCacheUtil.getMonitorVideoSource(mode, code);
|
|
@@ -123,8 +119,20 @@ public class TEMobileServiceImpl implements TEMobileService {
|
|
|
ret.setMonitorVideoSource(monitorVideoSource);
|
|
|
ret.setMonitorAudioEnable(monitorAudioEnable);
|
|
|
Map<String, Object> objectMap = redisUtil.getHashEntries(RedisKeyHelper.mobileAuthCacheKey(mode, code));
|
|
|
+ ExamStudentCacheBean es = examStudentService
|
|
|
+ .getExamStudentCacheBean(ExamRecordCacheUtil.getExamStudentId(ret.getRecordId()));
|
|
|
+ String source = null;
|
|
|
+ if (mode.equals(MobileModeEnum.MOBILE_MONITOR)) {
|
|
|
+ Source sourceEnum = MobileAuthCacheUtil.getSource(mode, code);
|
|
|
+ source = sourceEnum.name();
|
|
|
+ } else if (mode.equals(MobileModeEnum.PHOTO_UPLOAD) || mode.equals(MobileModeEnum.AUDIO_UPLOAD)) {
|
|
|
+ source = Source.OE_ANSWER.name();
|
|
|
+ }
|
|
|
String userType = String.valueOf(objectMap.get("userType"));
|
|
|
- String sessionId = String.valueOf(objectMap.get("sessionId"));
|
|
|
+ AuthDto authDto = (AuthDto) redisUtil.get(SystemConstant.studentOauth + "::" + es.getStudentId());
|
|
|
+ String sessionId = SessionUtil.digest(es.getIdentity(), Math.abs(authDto.getRoleCodes().toString().hashCode()), source);
|
|
|
+ objectMap.put("sessionId", sessionId);
|
|
|
+ redisUtil.setForHash(RedisKeyHelper.mobileAuthCacheKey(mode, code), objectMap);
|
|
|
if (Objects.nonNull(userType) && userType.contains(RoleEnum.STUDENT.name())) {
|
|
|
ret.setMonitorUserId("s_" + sessionId);
|
|
|
} else {
|