Przeglądaj źródła

Merge remote-tracking branch 'origin/master'

Joburgess 5 lat temu
rodzic
commit
28f9b830be

+ 8 - 0
edu-im/edu-im-api/src/main/java/com/keao/edu/im/api/client/ImFeignService.java

@@ -135,4 +135,12 @@ public interface ImFeignService {
 	 */
 	@PostMapping(value = "room/publishMessage")
 	void publishMessage(@RequestBody PublishMessageDto publishMessageDto);
+
+	/**
+	 * 销毁房间
+	 * @param roomId
+	 * @return
+	 */
+	@PostMapping(value = "room/destroyRoom")
+	void destroyRoom(@RequestParam("roomId") Long roomId);
 }

+ 5 - 0
edu-im/edu-im-api/src/main/java/com/keao/edu/im/api/client/callback/ImFeignServiceFallback.java

@@ -84,6 +84,11 @@ public class ImFeignServiceFallback implements ImFeignService {
     public void publishMessage(PublishMessageDto publishMessageDto) {
 
     }
+
+    @Override
+    public void destroyRoom(Long roomId) {
+
+    }
 /*
     @Override
     public Object privateSendCustom(ImGroupMessage groupMessage) {

+ 5 - 0
edu-im/edu-im-server/src/main/java/com/keao/edu/im/controller/RoomController.java

@@ -119,6 +119,11 @@ public class RoomController{
         return new BaseResponse<>(result);
     }
 
+    @RequestMapping(value = "/destroyRoom", method = RequestMethod.POST)
+    public void kickMember(Long roomId){
+        roomService.destroyRoom(roomId);
+    }
+
     @RequestMapping(value = "/kick", method = RequestMethod.POST)
     public Object kickMember(@RequestBody ReqUserData data)
             throws ApiException, Exception {

+ 24 - 3
edu-im/edu-im-server/src/main/java/com/keao/edu/im/service/Impl/RoomServiceImpl.java

@@ -2,7 +2,6 @@ package com.keao.edu.im.service.Impl;
 
 import com.keao.edu.auth.api.client.SysUserFeignService;
 import com.keao.edu.auth.api.entity.SysUser;
-import com.keao.edu.common.enums.YesOrNoEnum;
 import com.keao.edu.common.exception.BizException;
 import com.keao.edu.im.api.entity.MemberChangedMessage;
 import com.keao.edu.im.api.entity.PublishMessageDto;
@@ -733,6 +732,28 @@ public class RoomServiceImpl implements RoomService {
         return result;
     }
 
+    public void destroyRoom(Long roomId){
+        CheckUtils.checkArgument(roomId != null, "destroyRoom roomId must't be null");
+        List<RoomMember> roomMembers = roomMemberDao.findByRid(roomId.toString());
+        if(roomMembers != null && roomMembers.size() > 0){
+            roomMembers.forEach(e->{
+                MemberChangedMessage msg = new MemberChangedMessage(MemberChangedMessage.Action_Kick, e.getUid(), e.getRole());
+                List<UserInfo> userInfoList = userDao.findByUid(e.getUid());
+                if (!userInfoList.isEmpty()) {
+                    msg.setUserName(userInfoList.get(0).getName());
+                }
+                try {
+                    imHelper.publishMessage(e.getUid(), e.getRid(), msg, 1);
+                } catch (Exception e1) {
+                    e1.printStackTrace();
+                }
+                roomMemberDao.deleteUserByRidAndUid(e.getRid(), e.getUid());
+                userDao.deleteByUid(e.getUid());
+            });
+            roomDao.deleteByRid(roomId.toString());
+        }
+    }
+
     @Override
     public Boolean kickMember(ReqUserData data) throws ApiException, Exception {
         StudentExamResultApiDto examResult = eduUserFeignService.getExamResult(data.getRegistrationId());
@@ -753,10 +774,10 @@ public class RoomServiceImpl implements RoomService {
             List<UserInfo> userInfoList = userDao.findByUid(userId);
             if (!userInfoList.isEmpty()) {
                 msg.setUserName(userInfoList.get(0).getName());
-            }
+            }/*
             if("recorded".equals(data.getType())){
                 msg.setRoomId("recorded" + roomId);
-            }
+            }*/
             IMApiResultInfo apiResultInfo = imHelper.publishMessage(userId, roomId, msg, 1);
             if (!apiResultInfo.isSuccess()) {
                 throw new ApiException(ErrorEnum.ERR_MESSAGE_ERROR);

+ 6 - 0
edu-im/edu-im-server/src/main/java/com/keao/edu/im/service/RoomService.java

@@ -29,6 +29,12 @@ public interface RoomService {
     //only host
     public Boolean downgrade(String roomId, List<ReqChangeUserRoleData.ChangedUser> users) throws ApiException, Exception;
 
+    /**
+     * 销毁房间
+     * @param roomId
+     */
+    public void destroyRoom(Long roomId);
+
     public Boolean kickMember(ReqUserData data) throws ApiException, Exception;
 
 

+ 2 - 2
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamCertificationController.java

@@ -30,8 +30,8 @@ public class ExamCertificationController extends BaseController {
 
     @ApiOperation("学生端获取学员准考证列表")
     @GetMapping(value = "queryCertificationPage")
-    public HttpResponseResult<List<ExamCertificationDto>> queryCertification() {
-        return succeed(examCertificationService.queryCertificationPage());
+    public HttpResponseResult<List<ExamCertificationDto>> queryCertification(Long examRegistrationId) {
+        return succeed(examCertificationService.queryCertificationPage(examRegistrationId));
     }
 
     @ApiOperation("学生端待考详情")

+ 1 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/dao/ExamCertificationDao.java

@@ -28,7 +28,7 @@ public interface ExamCertificationDao extends BaseDAO<Long, ExamCertification> {
      * @param studentId
      * @return
      */
-    List<ExamCertificationDto> queryExamCertificationDtoPage(Integer studentId);
+    List<ExamCertificationDto> queryExamCertificationDtoPage(@Param("studentId") Integer studentId, @Param("examRegistrationId") Long examRegistrationId);
     /**
      * COUNT学员准考证列表
      * @param params

+ 1 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/ExamCertificationService.java

@@ -25,7 +25,7 @@ public interface ExamCertificationService extends BaseService<Long, ExamCertific
      * 获取学员的准考证列表
      * @return
      */
-    List<ExamCertificationDto> queryCertificationPage();
+    List<ExamCertificationDto> queryCertificationPage(Long examRegistrationId);
 
     /**
      * 学生端待考详情

+ 2 - 2
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamCertificationServiceImpl.java

@@ -48,9 +48,9 @@ public class ExamCertificationServiceImpl extends BaseServiceImpl<Long, ExamCert
 	}
 
 	@Override
-	public List<ExamCertificationDto> queryCertificationPage() {
+	public List<ExamCertificationDto> queryCertificationPage(Long examRegistrationId) {
 		SysUser sysUser = sysUserFeignService.queryUserInfo();
-		List<ExamCertificationDto> dataList = examCertificationDao.queryExamCertificationDtoPage(sysUser.getId());
+		List<ExamCertificationDto> dataList = examCertificationDao.queryExamCertificationDtoPage(sysUser.getId(),examRegistrationId);
 		if(dataList == null || dataList.size() < 0){
 			return dataList;
 		}

+ 20 - 9
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamRoomServiceImpl.java

@@ -13,6 +13,8 @@ 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.im.api.client.ImFeignService;
+import com.keao.edu.im.api.entity.MemberChangedMessage;
+import com.keao.edu.im.api.entity.PublishMessageDto;
 import com.keao.edu.thirdparty.message.provider.JiguangPushPlugin;
 import com.keao.edu.thirdparty.message.provider.YimeiSmsPlugin;
 import com.keao.edu.user.api.entity.ExamRoom;
@@ -29,10 +31,7 @@ import com.keao.edu.user.entity.ExamRegistration;
 import com.keao.edu.user.entity.ExaminationBasic;
 import com.keao.edu.user.page.ExamRoomListQueryInfo;
 import com.keao.edu.user.page.ExamRoomQueryInfo;
-import com.keao.edu.user.service.ExamRoomService;
-import com.keao.edu.user.service.ExamRoomStudentRelationService;
-import com.keao.edu.user.service.ExamTeacherSalaryService;
-import com.keao.edu.user.service.OrganizationService;
+import com.keao.edu.user.service.*;
 import com.keao.edu.util.collection.MapUtil;
 import com.keao.edu.util.date.DateUtil;
 import org.apache.commons.beanutils.BeanUtils;
@@ -66,7 +65,7 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
 	@Autowired
 	private ExamTeacherSalaryService examTeacherSalaryService;
 	@Autowired
-	private ExamCertificationDao examCertificationDao;
+	private ExamCertificationService examCertificationService;
 	@Autowired
 	private StudentExamResultDao studentExamResultDao;
 	@Autowired
@@ -361,7 +360,7 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
 		examRoomStudentRelationService.deleteWithExamRooms(examRoomIds);
 
 		if(!CollectionUtils.isEmpty(registIds)){
-			examCertificationDao.deleteWithRegist(registIds);
+			examCertificationService.deleteWithRegist(registIds);
 			studentExamResultDao.deleteWithRegists(registIds);
 		}
 
@@ -685,6 +684,7 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
 		examRoom.setId(examRoomId);
 		examRoom.setOpenFlag(openFlag);
 		examRoomDao.update(examRoom);
+		SysUser sysUser = sysUserFeignService.queryUserInfo();
 		//加群退群
 		if(openFlag == 1){
 			String studentIds = examRoomStudentRelationService.getStudentIds(examRoomId);
@@ -693,7 +693,7 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
 			if(StringUtils.isNotEmpty(studentIds)){
 				stringBuffer.append(",").append(studentIds);
 				//推送消息
-				String[] split = studentIds.split(",");
+				/*String[] split = studentIds.split(",");
 				Map<Integer, String> userPhoneMap = new HashMap<>(split.length);
 //				Map<Integer, String> map = MapUtil.convertMybatisMap(examRoomStudentRelationService.getStuRegistrationMap(examRoomId), Integer.class, String.class);
 
@@ -703,16 +703,27 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
 //				String notifyUrl = "?examRegistrationId=" + studentExtraExercise.getId() + "&studentCourseHomeworkId=" + studentExtraExercise.getId() + "&extra=1";
 //				String extra = "dayaedu" + notifyUrl + "&userId=" + studentId;
 				sysMessageService.batchSendMessage(MessageTypeEnum.ACTION_EXAM_SIGN_PUSH,
-						userPhoneMap, null, 0, null, JiguangPushPlugin.PLUGIN_NAME);
+						userPhoneMap, null, 0, null, JiguangPushPlugin.PLUGIN_NAME);*/
 			}
 			if(StringUtils.isNotEmpty(examRoom.getAssistantTeacherUserIdList())){
 				stringBuffer.append(",").append(examRoom.getAssistantTeacherUserIdList());
 			}
 			imFeignService.joinGroup(stringBuffer.toString(),examRoomId.toString(),examRoomId.toString());
 
+			PublishMessageDto publishMessageDto = new PublishMessageDto();
+			publishMessageDto.setUserId(sysUser.getId().toString());
+			publishMessageDto.setRoomId(examRoomId.toString());
+			MemberChangedMessage msg = new MemberChangedMessage(5, sysUser.getId().toString(),3);
+			msg.setWaitNum(0);
+			msg.setClassroomSwitch(1);
+			Map<String,Object> paramMap = new HashMap<>(1);
+			paramMap.put("studentQueue",examRoomStudentRelationService.queryNeedCheckingList(examRoomId));
+			msg.setWebParamJson(JSONObject.toJSONString(paramMap));
+			publishMessageDto.setMemberChangedMessage(msg);
+			imFeignService.publishMessage(publishMessageDto);
 		}else {
-			SysUser sysUser = sysUserFeignService.queryUserInfo();
 			imFeignService.dismissGroup(sysUser.getId().toString(),examRoomId.toString());
+			imFeignService.destroyRoom(examRoomId);
 		}
 	}
 }

+ 2 - 2
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamRoomStudentRelationServiceImpl.java

@@ -458,7 +458,7 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
 		ExamRoomStudentRelation examRoomStudentRelation = examRoomStudentRelationDao.get(examRoomStudentRelationId);
 		//将当前学员退出教室并添加参考状态,如果考试未完成,清除签到时间,重新签到
 		imFeignService.leaveRoom(new ReqUserData(examRoomStudentRelation.getExamRegistrationId()));
-		if(examStatus == 0){
+		if(examStatus != null && examStatus == 0){
 			//未完成
 			examRoomStudentRelationDao.cleanSignInTime(examRoomStudentRelation.getExamRegistrationId());
 			studentExamResultDao.updateFinishedExam(examRoomStudentRelation.getExamRegistrationId(),2);
@@ -498,7 +498,7 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
 		msg.setClassroomSwitch(needCheckingDetailDto.getClassroomSwitch());
 //		msg.setAppParamJson(jsonString);
 		Map<String,Object> paramMap = new HashMap<>(2);
-		this.queryNeedCheckingList(examRoomStudentRelation.getExamRoomId());
+
 		paramMap.put("studentQueue",this.queryNeedCheckingList(examRoomStudentRelation.getExamRoomId()));
 		paramMap.put("examCertification",examCertificationService.findDetailByStudentId(examRoomStudentRelation.getExamRegistrationId()));
 		msg.setWebParamJson(JSONObject.toJSONString(paramMap));

+ 4 - 1
edu-user/edu-user-server/src/main/resources/config/mybatis/ExamCertificationMapper.xml

@@ -135,7 +135,10 @@
 		FROM exam_room_student_relation ersr
 		LEFT JOIN exam_certification ec ON ec.exam_registration_id_ = ersr.exam_registration_id_
 		LEFT JOIN student_exam_result ser ON ser.exam_registration_id_ = ersr.exam_registration_id_
-		WHERE ersr.student_id_ = #{studentId} AND ser.is_finished_exam_ = 0
+		WHERE ersr.student_id_ = #{studentId}
+		<if test="examRegistrationId != null">
+			AND ersr.exam_registration_id_ = #{examRegistrationId}
+		</if>
 		ORDER BY ec.exam_start_time_
 	</select>
 	<select id="countExamCertificationDtoPage" resultType="java.lang.Integer">

+ 6 - 2
edu-user/edu-user-server/src/main/resources/config/mybatis/ExamRegistrationMapper.xml

@@ -466,18 +466,22 @@
 		<result property="practiceSongIdList" column="practice_song_id_list_"/>
 	</resultMap>
     <select id="countStudentList" resultType="java.lang.Integer">
-		SELECT COUNT(er.id_) FROM exam_registration er
+		SELECT COUNT(er.id_)
+		FROM exam_registration er
+		LEFT JOIN examination_basic eb ON er.examination_basic_id_ = eb.id_
+		LEFT JOIN exam_subject_song ess ON er.examination_basic_id_ = ess.examination_basic_id_
 		<include refid="queryStudentListSql"/>
 	</select>
 	<sql id="queryStudentListSql">
 		<where>
+			er.subject_id_ = ess.exam_subject_id_ AND er.level_ = ess.level_
 			<if test="studentId != null">
 				AND er.student_id_ = #{studentId}
 			</if>
 			<if test="examRegistrationId != null">
 				AND er.id_ = #{examRegistrationId}
 			</if>
-			<if test="paymentStatus != null and paymentStatus == 1">
+			<if test="paymentStatus != null">
 				<if test="paymentStatus == 1">
 					AND er.status_ IN ('AUDIT_PASS','AUDIT_WAIT','AUDIT_REJECT')
 				</if>