Browse Source

Merge branch 'master' of http://git.dayaedu.com/yonge/edu-saas

zouxuan 5 năm trước cách đây
mục cha
commit
1a0ab87804

+ 5 - 1
edu-im/edu-im-server/src/main/java/com/keao/edu/im/config/ResourceServerConfig.java

@@ -10,6 +10,10 @@ import org.springframework.security.oauth2.config.annotation.web.configuration.R
 public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
     @Override
     public void configure(HttpSecurity http) throws Exception {
-        http.authorizeRequests().antMatchers("/v2/api-docs","/user/register","/group/join","/group/create","/room/leave","/room/statusSync","/group/batchDismiss","/private/send").permitAll().anyRequest().authenticated().and().csrf().disable();
+        http.authorizeRequests()
+                .antMatchers("/v2/api-docs","/user/register","/group/join","/group/create","/room/leave","/room/statusSync","/group/batchDismiss","/private/send","/room/**")
+                .permitAll().anyRequest()
+                .authenticated()
+                .and().csrf().disable();
     }
 }

+ 9 - 0
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/dao/ExamReviewDao.java

@@ -37,4 +37,13 @@ public interface ExamReviewDao extends BaseDAO<Long, ExamReview> {
     List<ExamReviewRecordDto> queryExamReviewRecordList(Map<String, Object> params);
 
     ExamReview findByRegistrationId(@Param("examRegistrationId") Long examRegistrationId, @Param("teacherId") Integer teacherId);
+
+    /**
+     * @describe 获取考场中学员的评审记录
+     * @author Joburgess
+     * @date 2020.07.30
+     * @param examRoomId:
+     * @return java.util.List<com.keao.edu.user.entity.ExamReview>
+     */
+    List<ExamReview> getWithExamRoom(@Param("examRoomId") Long examRoomId);
 }

+ 9 - 0
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/dao/StudentExamResultDao.java

@@ -87,4 +87,13 @@ public interface StudentExamResultDao extends BaseDAO<Long, StudentExamResult> {
      * @param userId
      */
     StudentExamResult findByRoomIdAndUserId(@Param("roomId") String roomId, @Param("userId") String userId);
+
+    /**
+     * @describe 批量修改考试结果
+     * @author Joburgess
+     * @date 2020.07.30
+     * @param results:
+     * @return int
+     */
+    int updateRegistAvgScore(@Param("results") List<StudentExamResult> results);
 }

+ 9 - 0
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/service/StudentExamResultService.java

@@ -37,6 +37,15 @@ public interface StudentExamResultService extends BaseService<Long, StudentExamR
      */
     void examResultConfirmPush(Long examId);
 
+    /**
+     * @describe 计算考场中学员平均分
+     * @author Joburgess
+     * @date 2020.07.30
+     * @param examRoomId:
+     * @return void
+     */
+    void calculateStudentExamAvgScore(Long examRoomId);
+
     StudentExamResultStatisticsDto getStudentExamResultStatisticsInfo(Integer organId, Integer examId);
 
     /**

+ 6 - 1
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/service/impl/ExamRoomServiceImpl.java

@@ -91,6 +91,8 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
 	private IdGeneratorService idGeneratorService;
 	@Autowired
 	private SysConfigService sysConfigService;
+	@Autowired
+	private StudentExamResultService studentExamResultService;
 
 	@Override
 	public BaseDAO<Long, ExamRoom> getDAO() {
@@ -852,6 +854,7 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
 			}
 			imFeignService.dismissGroup(sysUser.getId().toString(),examRoomId.toString());
 			imFeignService.destroyRoom(examRoomId);
+			studentExamResultService.calculateStudentExamAvgScore(examRoomId);
 		}
 	}
 
@@ -866,9 +869,10 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
 			throw new BizException("考场不存在");
 		}
 		examRoom.setOpenFlag(0);
-		examRoomDao.update(examRoom);
 		imFeignService.dismissGroup(examRoom.getMainTeacherUserId().toString(),examRoomId.toString());
 		imFeignService.destroyRoom(examRoomId);
+		examRoomDao.update(examRoom);
+		studentExamResultService.calculateStudentExamAvgScore(examRoomId);
 		return BaseController.succeed();
 	}
 
@@ -883,6 +887,7 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
 			examRoom.setOpenFlag(0);
 			imFeignService.dismissGroup(examRoom.getMainTeacherUserId().toString(),examRoom.getId().toString());
 			imFeignService.destroyRoom(examRoom.getId());
+			studentExamResultService.calculateStudentExamAvgScore(examRoom.getId());
 		}
 		examRoomDao.batchUpdate(examRooms);
 	}

+ 27 - 4
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/service/impl/StudentExamResultServiceImpl.java

@@ -17,15 +17,13 @@ import com.keao.edu.user.api.entity.ExamRoom;
 import com.keao.edu.user.api.entity.ExamRoomStudentRelation;
 import com.keao.edu.user.api.entity.Student;
 import com.keao.edu.user.api.enums.StudentExamResultApiDto;
+import com.keao.edu.user.dao.ExamReviewDao;
 import com.keao.edu.user.dao.ExaminationBasicDao;
 import com.keao.edu.user.dao.StudentExamResultDao;
 import com.keao.edu.user.dto.ExaminationBasicDto;
 import com.keao.edu.user.dto.RecordNotify;
 import com.keao.edu.user.dto.StudentExamResultStatisticsDto;
-import com.keao.edu.user.entity.ExaminationBasic;
-import com.keao.edu.user.entity.Organization;
-import com.keao.edu.user.entity.StudentExamResult;
-import com.keao.edu.user.entity.Subject;
+import com.keao.edu.user.entity.*;
 import com.keao.edu.user.enums.ExamStatusEnum;
 import com.keao.edu.user.enums.LevelEnum;
 import com.keao.edu.user.page.StudentExamResultQueryInfo;
@@ -41,7 +39,9 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 
+import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -66,6 +66,8 @@ public class StudentExamResultServiceImpl extends BaseServiceImpl<Long, StudentE
 	private ExamRoomService examRoomService;
 	@Autowired
 	private RedisTemplate<String,String> redisTemplate;
+	@Autowired
+	private ExamReviewDao examReviewDao;
 
 	private final static Logger logger = LoggerFactory.getLogger(StudentExamResultServiceImpl.class);
 
@@ -163,6 +165,27 @@ public class StudentExamResultServiceImpl extends BaseServiceImpl<Long, StudentE
 	}
 
 	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void calculateStudentExamAvgScore(Long examRoomId) {
+		List<ExamReview> examReviews = examReviewDao.getWithExamRoom(examRoomId);
+		if(CollectionUtils.isEmpty(examReviews)){
+			return;
+		}
+		Map<Long, List<ExamReview>> registReviewMap = examReviews.stream().collect(Collectors.groupingBy(ExamReview::getExamRegistrationId));
+		List<StudentExamResult> needUpdateStudentExamResult = new ArrayList<>();
+		for (Map.Entry<Long, List<ExamReview>> registReviewEntry : registReviewMap.entrySet()) {
+			StudentExamResult studentExamResult=new StudentExamResult();
+			studentExamResult.setExamRegistrationId(registReviewEntry.getKey());
+			List<ExamReview> reviews = registReviewEntry.getValue();
+			long totalScore = reviews.stream().mapToLong(ExamReview::getEvaluationResult).sum();
+			BigDecimal avgScore = new BigDecimal(totalScore).divide(new BigDecimal(reviews.size()), 2, BigDecimal.ROUND_CEILING);
+			studentExamResult.setAvgScore(avgScore.floatValue());
+			needUpdateStudentExamResult.add(studentExamResult);
+		}
+		studentExamResultDao.updateRegistAvgScore(needUpdateStudentExamResult);
+	}
+
+	@Override
 	public StudentExamResultStatisticsDto getStudentExamResultStatisticsInfo(Integer organId, Integer examId) {
 		if(Objects.isNull(examId)){
 			throw new BizException("请指定考级项目");

+ 4 - 0
edu-user/edu-user-biz/src/main/resources/config/mybatis/ExamReviewMapper.xml

@@ -226,4 +226,8 @@
 	<select id="findByRegistrationId" resultMap="ExamReviewRecordDtoMap">
 		SELECT * FROM exam_review WHERE exam_registration_id_ = #{examRegistrationId} AND teacher_id_ = #{teacherId} LIMIT 1
 	</select>
+
+    <select id="getWithExamRoom" resultMap="ExamReview">
+		SELECT * FROM exam_review WHERE exam_room_id_=#{examRoomId}
+	</select>
 </mapper>

+ 8 - 1
edu-user/edu-user-biz/src/main/resources/config/mybatis/StudentExamResultMapper.xml

@@ -114,7 +114,14 @@
 		WHERE exam_registration_id_ = #{examRegistrationId}
 	</update>
 
-    <!-- 根据主键删除一条记录 -->
+	<update id="updateRegistAvgScore" parameterType="com.keao.edu.user.entity.StudentExamResult">
+		<foreach collection="results" item="result" separator=";">
+			UPDATE student_exam_result SET avg_score_=#{result.avgScore},update_time_=NOW()
+			WHERE exam_registration_id_ = #{result.examRegistrationId}
+		</foreach>
+	</update>
+
+	<!-- 根据主键删除一条记录 -->
 	<delete id="delete" >
 		DELETE FROM student_exam_result WHERE id_ = #{id} 
 	</delete>

+ 3 - 3
edu-user/edu-user-biz/src/main/resources/config/mybatis/TeacherAttendanceMapper.xml

@@ -9,7 +9,7 @@
 	<resultMap type="com.keao.edu.user.api.entity.TeacherAttendance" id="TeacherAttendance">
 		<result column="id_" property="id" />
 		<result column="teacher_id_" property="teacherId" />
-		<result column="examination_basic_id" property="examinationBasicId" />
+		<result column="examination_basic_id_" property="examinationBasicId" />
 		<result column="exam_room_id_" property="examRoomId" />
 		<result column="sign_in_time_" property="signInTime" />
 		<result column="create_time_" property="createTime" />
@@ -28,7 +28,7 @@
 	
 	<!-- 向数据库增加一条记录 -->
 	<insert id="insert" parameterType="com.keao.edu.user.api.entity.TeacherAttendance" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
-		INSERT INTO teacher_attendance (id_,teacher_id_,exam_room_id_,sign_in_time_,examination_basic_id,create_time_,sign_out_time_)
+		INSERT INTO teacher_attendance (id_,teacher_id_,exam_room_id_,sign_in_time_,examination_basic_id_,create_time_,sign_out_time_)
 		VALUES(#{id},#{teacherId},#{examRoomId},#{signInTime},#{examinationBasicId},NOW(),#{signOutTime})
 	</insert>
 	
@@ -36,7 +36,7 @@
 	<update id="update" parameterType="com.keao.edu.user.api.entity.TeacherAttendance">
 		UPDATE teacher_attendance <set>
 			<if test="examinationBasicId != null">
-				examination_basic_id = #{examinationBasicId},
+				examination_basic_id_ = #{examinationBasicId},
 			</if>
 			<if test="signInTime != null">
 			sign_in_time_ = #{signInTime},

+ 3 - 3
edu-user/edu-user-client-api/src/main/java/com/keao/edu/user/api/client/TaskRemoteService.java

@@ -27,7 +27,7 @@ public interface TaskRemoteService {
 	 * @date 2020.07.23
 	 * @return void
 	 */
-	@GetMapping("/tomorrowExamPlanRemind")
+	@GetMapping("task/tomorrowExamPlanRemind")
 	void tomorrowExamPlanRemind();
 
 	/**
@@ -36,7 +36,7 @@ public interface TaskRemoteService {
 	 * @date 2020.07.27
 	 * @return void
 	 */
-	@GetMapping("/examEndRemind")
+	@GetMapping("task/examEndRemind")
 	void examEndRemind();
 
 	/**
@@ -45,7 +45,7 @@ public interface TaskRemoteService {
 	 * @date 2020.07.30
 	 * @return void
 	 */
-	@GetMapping("/cleanExamRoom")
+	@GetMapping("task/cleanExamRoom")
 	void cleanExamRoom();
 
 }

+ 1 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamRoomController.java

@@ -172,7 +172,7 @@ public class ExamRoomController extends BaseController {
     }
 
     @ApiOperation("强制关闭考场")
-    @GetMapping(value = "/forceCloseExamRoom")
+    @PostMapping(value = "/forceCloseExamRoom")
     public HttpResponseResult forceCloseExamRoom(Long examRoomId){
         return examRoomService.forceCloseExamRoom(examRoomId);
     }