Kaynağa Gözat

Merge remote-tracking branch 'origin/master'

周箭河 5 yıl önce
ebeveyn
işleme
3c686c1d38

+ 15 - 5
edu-im/edu-im-server/src/main/java/com/keao/edu/im/service/Impl/RoomServiceImpl.java

@@ -35,8 +35,10 @@ import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Transactional;
+
 import java.util.*;
 import java.util.stream.Collectors;
+
 import static com.keao.edu.im.pojo.RoleEnum.Student;
 
 /**
@@ -102,18 +104,25 @@ public class RoomServiceImpl implements RoomService {
     @Override
     public BaseResponse joinRoom(Long registrationId, boolean isAudience, boolean isDisableCamera, boolean isMusicMode, String roomId) throws ApiException, Exception {
         StudentExamResultApiDto examResult = null;
+        log.info("joinRoom: roomId={}, isAudience={}, isDisableCamera={},isMusicMode={}", roomId, isAudience, isDisableCamera,isMusicMode);
+
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        String userId = sysUser.getId().toString();
+        String realName = sysUser.getRealName();
         if(registrationId != null){
             examResult = eduUserFeignService.getExamResult(registrationId);
             roomId = examResult.getRoomId();
+            List<RoomMember> byRidAndRole = roomMemberDao.findByRidAndRole(roomId, 3);
+            if(byRidAndRole != null && byRidAndRole.size() > 0){
+                log.info("学员加入时,将其他学员退出房间 byRidAndRole{}",byRidAndRole);
+                for (RoomMember e: byRidAndRole) {
+                    leaveRoom(e.getExamRegistrationId(),roomId,userId);
+                }
+            }
         }
 
         CheckUtils.checkArgument(roomId != null, "roomId must't be null");
 
-        log.info("joinRoom: roomId={}, isAudience={}, isDisableCamera={},isMusicMode={}", roomId, isAudience, isDisableCamera,isMusicMode);
-
-        SysUser sysUser = sysUserFeignService.queryUserInfo();
-        String userId = sysUser.getId().toString();
-        String realName = sysUser.getRealName();
         ExamRoom examRoom = eduUserFeignService.getExamRoom(Integer.parseInt(roomId));
         boolean isAssistant = false;
         if (StringUtils.isNotEmpty(examRoom.getAssistantTeacherUserIdList())){
@@ -209,6 +218,7 @@ public class RoomServiceImpl implements RoomService {
             roomResult.setRegistrationId(registrationId);
         }
         roomResult.setExamFlag(examRoom.getExamFlag());
+
         List<RoomMember> roomMembers = roomMemberDao.findByRid(roomId);
         roomResult.setMembers(roomMembers,examRoom.getShieldUserId());
         log.info("join success: roomId = {}, userId = {}, userName={}, role = {}", roomId, userId, roleEnum);

+ 17 - 0
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/dao/ExamRoomStudentRelationDao.java

@@ -39,6 +39,14 @@ public interface ExamRoomStudentRelationDao extends BaseDAO<Long, ExamRoomStuden
     List<ExamRoomStudentRelation> findStudentsWithExamRooms(@Param("examRoomIds") List<Long> examRoomIds);
 
     /**
+     * @describe 获取考场中未完成考试的报名编号
+     * @author Joburgess
+     * @date 2020.08.18
+     * @return java.util.List<java.lang.Long>
+     */
+    List<Long> findNoFinishedExamRegistIdsWIthExamRooms();
+
+    /**
      * @describe 删除指定教室的学员
      * @author Joburgess
      * @date 2020.06.24
@@ -50,6 +58,15 @@ public interface ExamRoomStudentRelationDao extends BaseDAO<Long, ExamRoomStuden
                                     @Param("registIds") List<Long> registIds);
 
     /**
+     * @describe 删除指定报名学员的考场关联记录
+     * @author Joburgess
+     * @date 2020.08.18
+     * @param registIds:
+     * @return int
+     */
+    int deleteStudentRoomRegistRelations(@Param("registIds") List<Long> registIds);
+
+    /**
      * @describe 根据班级删除记录
      * @author Joburgess
      * @date 2020.06.24

+ 22 - 0
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/dao/StudentDao.java

@@ -34,4 +34,26 @@ public interface StudentDao extends BaseDAO<Integer, Student> {
      * @return
      */
     Student getStudent(@Param("userId") Integer userId);
+
+    /**
+     * @describe 人员管理--学员管理列表
+     * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
+     * @author zouxuan
+     * @date 2020/8/18
+     * @time 14:59
+     * @param params:
+     * @return int
+     */
+    int countRegistrationList(Map<String, Object> params);
+
+    /**
+     * @describe 人员管理--学员管理列表
+     * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
+     * @author zouxuan
+     * @date 2020/8/18
+     * @time 14:59
+     * @param params:
+     * @return int
+     */
+    List<Student> queryRegistrationList(Map<String, Object> params);
 }

+ 11 - 0
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/service/StudentService.java

@@ -58,4 +58,15 @@ public interface StudentService extends BaseService<Integer, Student> {
      * @return
      */
     Student updateInfo(Student student);
+
+    /**
+     * @describe 人员管理--学员管理列表
+     * @apiNote 时光荏苒,认真工作的时间总是过得很快,而我、享受这一刻!
+     * @author zouxuan
+     * @date 2020/8/18
+     * @time 14:54
+     * @param queryInfo:
+     * @return java.lang.Object
+     */
+    PageInfo<Student> queryRegistrationList(QueryInfo queryInfo);
 }

+ 3 - 0
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/service/impl/ExamRegistrationServiceImpl.java

@@ -139,6 +139,9 @@ public class ExamRegistrationServiceImpl extends BaseServiceImpl<Long, ExamRegis
             amount = amount.add(theoryLevelFee);
         }
 
+        if(Objects.isNull(examRegistration.getSubjectId())){
+            examRegistration.setSubjectId(0);
+        }
         examRegistration.setTenantId(organization.getTenantId());
         examRegistration.setStatus(StudentRegistrationStatusEnum.PAY_WAIT);
         examRegistration.setLevelFee(registrationFee);

+ 13 - 2
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/service/impl/ExamRoomServiceImpl.java

@@ -28,6 +28,7 @@ import com.keao.edu.user.api.enums.ExamModeEnum;
 import com.keao.edu.user.dao.*;
 import com.keao.edu.user.dto.*;
 import com.keao.edu.user.entity.*;
+import com.keao.edu.user.enums.ExamStatusEnum;
 import com.keao.edu.user.page.ExamRoomListQueryInfo;
 import com.keao.edu.user.page.ExamRoomQueryInfo;
 import com.keao.edu.user.service.*;
@@ -172,7 +173,7 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
 			throw new BizException("线下考试请指定考试地址");
 		}
 		if(StringUtils.isBlank(examRoom.getSubjectIdList())){
-			throw new BizException("请指定考试专业");
+			examRoom.setSubjectIdList("0");
 		}
 		if(Objects.isNull(examRoom.getMainTeacherUserId())){
 			throw new BizException("请指定主考老师");
@@ -430,6 +431,10 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
 			throw new BizException("考级项目不存在");
 		}
 
+		if(exam.getStatus().getOrder()< ExamStatusEnum.APPLIED.getOrder()){
+			throw new BizException("项目报名中,不能发送考试安排");
+		}
+
 		ExamOrganizationRelation examOrganizationRelation = examOrganizationRelationDao.getExamOrganizationRelation(exam.getId(), organId);
 		if(Objects.isNull(examOrganizationRelation)||examOrganizationRelation.getIsAllowArrangeExam()==0){
 			throw new BizException("无权操作");
@@ -901,10 +906,16 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
 		}
 		for (ExamRoom examRoom : examRooms) {
 			examRoom.setOpenFlag(0);
-//			imFeignService.dismissGroup(examRoom.getMainTeacherUserId().toString(),examRoom.getId().toString());
 			imFeignService.destroyRoom(examRoom.getId(),examRoom.getMainTeacherUserId().toString());
 			studentExamResultService.calculateStudentExamAvgScore(examRoom.getId());
 		}
 		examRoomDao.batchUpdate(examRooms);
+
+		List<Long> registIds = examRoomStudentRelationDao.findNoFinishedExamRegistIdsWIthExamRooms();
+		if(!CollectionUtils.isEmpty(registIds)){
+			examRoomStudentRelationDao.deleteStudentRoomRegistRelations(registIds);
+			examCertificationDao.deleteWithRegist(registIds);
+			studentExamResultDao.deleteWithRegists(registIds);
+		}
 	}
 }

+ 37 - 4
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/service/impl/StudentServiceImpl.java

@@ -10,13 +10,11 @@ import com.keao.edu.im.api.client.ImFeignService;
 import com.keao.edu.im.api.entity.ImResult;
 import com.keao.edu.im.api.entity.ImUserModel;
 import com.keao.edu.user.api.entity.Student;
-import com.keao.edu.user.dao.EmployeeDao;
-import com.keao.edu.user.dao.StudentDao;
-import com.keao.edu.user.dao.StudentExamResultDao;
-import com.keao.edu.user.dao.SysUserDao;
+import com.keao.edu.user.dao.*;
 import com.keao.edu.user.dto.StudentExamPaymentDto;
 import com.keao.edu.user.entity.Employee;
 import com.keao.edu.user.page.StudentApplyQueryInfo;
+import com.keao.edu.user.service.OrganizationService;
 import com.keao.edu.user.service.StudentService;
 import com.keao.edu.util.collection.MapUtil;
 import org.apache.commons.lang3.StringUtils;
@@ -45,6 +43,8 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
     private StudentExamResultDao studentExamResultDao;
     @Autowired
     private ImFeignService imFeignService;
+    @Autowired
+    private OrganizationService organizationService;
 
     @Override
     public BaseDAO<Integer, Student> getDAO() {
@@ -160,4 +160,37 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
         }
         return student;
     }
+
+    @Override
+    public PageInfo<Student> queryRegistrationList(QueryInfo queryInfo) {
+        PageInfo<Student> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
+        Map<String, Object> params = new HashMap<>();
+        MapUtil.populateMap(params, queryInfo);
+        Integer organId = queryInfo.getOrganId();
+        if(organId != null){
+            List<Integer> childOrganIds = organizationService.getChildOrganIds(organId,true);
+            if(childOrganIds == null || childOrganIds.size() == 0){
+                return pageInfo;
+            }
+            params.put("organIds", childOrganIds);
+        }
+        List<Student> dataList = null;
+        int count = studentDao.countRegistrationList(params);
+        if (count > 0) {
+            pageInfo.setTotal(count);
+            params.put("offset", pageInfo.getOffset());
+            dataList = studentDao.queryRegistrationList(params);
+            List<Integer> studentIds = dataList.stream().map(e -> e.getUserId()).collect(Collectors.toList());
+            //获取考试次数
+            Map<Integer, Integer> examNumMap = MapUtil.convertMybatisMap(studentExamResultDao.countExamNum(studentIds, queryInfo.getTenantId()),Integer.class,Integer.class);
+            dataList.forEach(e -> {
+                e.setExamNum(examNumMap.get(e.getUserId()));
+            });
+        }
+        if (count == 0) {
+            dataList = new ArrayList<>();
+        }
+        pageInfo.setRows(dataList);
+        return pageInfo;
+    }
 }

+ 18 - 0
edu-user/edu-user-biz/src/main/resources/config/mybatis/ExamRoomStudentRelationMapper.xml

@@ -111,6 +111,13 @@
 		</foreach>
 	</delete>
 
+	<delete id="deleteStudentRoomRegistRelations">
+		DELETE FROM exam_room_student_relation WHERE exam_registration_id_ IN
+		<foreach collection="registIds" item="registId" separator="," open="(" close=")">
+			#{registId}
+		</foreach>
+	</delete>
+
 	<!-- 分页查询 -->
 	<select id="queryPage" resultMap="ExamRoomStudentRelation" parameterType="map">
 		SELECT * FROM exam_room_student_relation ORDER BY id_ <include refid="global.limit"/>
@@ -319,4 +326,15 @@
 				#{examRoomId}
 			</foreach>
 	</select>
+
+    <select id="findNoFinishedExamRegistIdsWIthExamRooms" resultType="long">
+		SELECT
+			ser.exam_registration_id_
+		FROM
+			student_exam_result ser
+			LEFT JOIN exam_room er ON ser.exam_room_id_ = er.id_
+		WHERE
+			ser.is_finished_exam_ != 5
+			AND er.exam_end_time_&lt;NOW()
+	</select>
 </mapper>

+ 29 - 0
edu-user/edu-user-biz/src/main/resources/config/mybatis/StudentMapper.xml

@@ -102,4 +102,33 @@
 		LEFT JOIN sys_user su ON s.user_id_ = su.id_
 		WHERE user_id_ = #{userId}
 	</select>
+	<select id="countRegistrationList" resultType="java.lang.Integer">
+		SELECT COUNT(DISTINCT su.id_) FROM exam_registration er
+		LEFT JOIN sys_user su ON er.student_id_ = su.id_
+		WHERE su.del_flag_ = 0 AND su.lock_flag_ = 0
+		<if test="search != null and search != ''">
+			AND (stu.user_id_ = #{search} OR su.real_name_ LIKE CONCAT ('%', #{search}, '%') OR su.phone_ LIKE CONCAT('%', #{search}, '%'))
+		</if>
+		<if test="organIds != null">
+			AND er.organ_id_ IN
+			<foreach collection="organIds" open="(" close=")" item="organId" separator=",">
+				#{organId}
+			</foreach>
+		</if>
+	</select>
+	<select id="queryRegistrationList" resultMap="Student">
+		SELECT su.* FROM exam_registration er
+		LEFT JOIN sys_user su ON er.student_id_ = su.id_
+		WHERE su.del_flag_ = 0 AND su.lock_flag_ = 0
+		<if test="search != null and search != ''">
+			AND (stu.user_id_ = #{search} OR su.real_name_ LIKE CONCAT ('%', #{search}, '%') OR su.phone_ LIKE CONCAT('%', #{search}, '%'))
+		</if>
+		<if test="organIds != null">
+			AND er.organ_id_ IN
+			<foreach collection="organIds" open="(" close=")" item="organId" separator=",">
+				#{organId}
+			</foreach>
+		</if>
+		GROUP BY su.id_
+	</select>
 </mapper>

+ 4 - 0
edu-user/edu-user-server/pom.xml

@@ -24,6 +24,10 @@
 			<groupId>org.springframework.boot</groupId>
 			<artifactId>spring-boot-starter-websocket</artifactId>
 		</dependency>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-amqp</artifactId>
+		</dependency>
 
 		<dependency>
 			<groupId>org.springframework.cloud</groupId>

+ 34 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/config/RabbitConfig.java

@@ -0,0 +1,34 @@
+package com.keao.edu.user.config;
+
+
+import org.springframework.amqp.core.*;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class RabbitConfig {
+    //交换机名称
+    public static final String ITEM_TOPIC_EXCHANGE = "item_topic_exchange";
+    //队列名称
+    public static final String ITEM_QUEUE = "item_queue";
+
+    //声明交换机
+    @Bean("itemTopicExchange")
+    public Exchange topicExchange(){
+        return ExchangeBuilder.topicExchange(ITEM_TOPIC_EXCHANGE).durable(true).build();
+    }
+
+    //声明队列
+    @Bean("itemQueue")
+    public Queue itemQueue(){
+        return QueueBuilder.durable(ITEM_QUEUE).build();
+    }
+
+    //绑定队列和交换机
+    @Bean
+    public Binding itemQueueExchange(@Qualifier("itemQueue") Queue queue,
+                                     @Qualifier("itemTopicExchange") Exchange exchange){
+        return BindingBuilder.bind(queue).to(exchange).with("item.#").noargs();
+    }
+}

+ 12 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/EmployeeController.java

@@ -7,12 +7,14 @@ import com.keao.edu.common.controller.BaseController;
 import com.keao.edu.common.entity.HttpResponseResult;
 import com.keao.edu.common.page.PageInfo;
 import com.keao.edu.common.tenant.TenantContextHolder;
+import com.keao.edu.user.config.RabbitConfig;
 import com.keao.edu.user.entity.Employee;
 import com.keao.edu.user.page.EmployeeQueryInfo;
 import com.keao.edu.user.service.EmployeeService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiOperation;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
@@ -26,6 +28,8 @@ public class EmployeeController extends BaseController {
 	private EmployeeService employeeService;
 	@Autowired
 	private SysUserFeignService sysUserFeignService;
+	@Autowired
+	private RabbitTemplate rabbitTemplate;
 	
 	@ApiOperation("员工服务分页查询")
 	@GetMapping(value = "/list")
@@ -88,4 +92,12 @@ public class EmployeeController extends BaseController {
 		return succeed();
 	}
 
+	@ApiOperation("删除")
+	@PostMapping(value = "/sendMsg")
+	@PreAuthorize("@pcs.hasPermissions('employee/sendMsg')")
+	public HttpResponseResult sendMsg() {
+		rabbitTemplate.convertAndSend(RabbitConfig.ITEM_TOPIC_EXCHANGE ,"item.springboot-rabbitmq" ,"springboot-rabbitmq-producer");
+		return succeed();
+	}
+
 }

+ 7 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/StudentController.java

@@ -41,6 +41,13 @@ public class StudentController extends BaseController {
         return succeed(studentService.queryStudentPage(queryInfo));
     }
 
+    @ApiOperation(value = "后台人员管理--学员列表")
+    @GetMapping(value = "registrationList")
+    @PreAuthorize("@pcs.hasPermissions('student/registrationList')")
+    public HttpResponseResult<PageInfo<Student>> queryRegistrationList(QueryInfo queryInfo) {
+        return succeed(studentService.queryRegistrationList(queryInfo));
+    }
+
     @ApiOperation(value = "学生端学员报考记录列表(包括详情)")
     @PostMapping(value = "applyList")
     @PreAuthorize("@pcs.hasPermissions('student/applyList')")

+ 6 - 0
edu-user/edu-user-server/src/main/resources/application.yml

@@ -74,6 +74,12 @@ spring:
         #连接池中的最小空闲连接
         min-idle: 1
 
+  rabbitmq:
+    host: 47.114.176.40
+    port: 5672
+    username: guest
+    password: guest
+
 mybatis:
   mapperLocations: classpath*:config/mybatis/*.xml
   typeAliasesPackage: com.keao.edu.*.entity