Joburgess 5 anni fa
parent
commit
eb5d901e53

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

@@ -136,4 +136,13 @@ public interface ExamOrganizationRelationDao extends BaseDAO<Long, ExamOrganizat
      */
     List<ExamOrganizationRelation> getExamOrganizationRelations(@Param("examId") Long examId, @Param("organIds") List<Integer> organIds);
 
+    /**
+     * @describe 统计指定考级项目下已发送报名链接的分部数量
+     * @author Joburgess
+     * @date 2020.08.06
+     * @param examId:
+     * @return int
+     */
+    int countExamIsSendUrlOrgans(@Param("examId") Long examId);
+
 }

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

@@ -168,4 +168,13 @@ public interface ExamRegistrationDao extends BaseDAO<Long, ExamRegistration> {
      * @return
      */
     StuRecordDetailDto getStuRecordDetail(Long examRegistrationId);
+
+    /**
+     * @describe 获取未排考的报名学员
+     * @author Joburgess
+     * @date 2020.08.06
+     * @param examId:
+     * @return java.util.List<com.keao.edu.user.entity.ExamRegistration>
+     */
+    List<ExamRegistration> getNotInRoomStudents(@Param("examId") Long examId);
 }

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

@@ -100,4 +100,13 @@ public interface ExamRoomDao extends BaseDAO<Long, ExamRoom> {
      * @return java.util.List<com.keao.edu.user.api.entity.ExamRoom>
      */
     List<ExamRoom> getHistoryOpenExamRoom();
+
+    /**
+     * @describe 统计已发送考场数量
+     * @author Joburgess
+     * @date 2020.08.06
+     * @param examId:
+     * @return int
+     */
+    int countSendExamPlanRooms(@Param("examId") Long examId);
 }

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

@@ -114,4 +114,13 @@ public interface StudentExamResultDao extends BaseDAO<Long, StudentExamResult> {
      * @return int
      */
     int countExamNoResultStudentNum(@Param("examId") Long examId);
+
+    /**
+     * @describe 统计考级项目结果记录数量
+     * @author Joburgess
+     * @date 2020.08.06
+     * @param examId:
+     * @return int
+     */
+    int countExamResultRecordNum(@Param("examId") Long examId);
 }

+ 11 - 2
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/service/ExamRoomStudentRelationService.java

@@ -3,10 +3,9 @@ package com.keao.edu.user.service;
 import com.keao.edu.common.page.PageInfo;
 import com.keao.edu.common.service.BaseService;
 import com.keao.edu.im.api.entity.PublishMessageDto;
-import com.keao.edu.user.dto.ExamRoomStudentRelationDto;
 import com.keao.edu.user.api.entity.ExamRoomStudentRelation;
+import com.keao.edu.user.dto.ExamRoomStudentRelationDto;
 import com.keao.edu.user.dto.NeedCheckingDetailDto;
-import com.keao.edu.user.dto.RoomStudentListDto;
 import com.keao.edu.user.dto.StuRecordDetailDto;
 import com.keao.edu.user.page.ExamRoomStudentRelationQueryInfo;
 
@@ -34,6 +33,16 @@ public interface ExamRoomStudentRelationService extends BaseService<Long, ExamRo
     void addStudentForRoom(Long examRoomId, String registIds, Integer organId);
 
     /**
+     * @describe 自动分配学员到考场
+     * @author Joburgess
+     * @date 2020.08.06
+     * @param examRoomId:
+     * @param selfOrganId:
+     * @return void
+     */
+    void autoSplitStudentToRoom(Long examRoomId, Integer selfOrganId);
+
+    /**
      * @describe 更换学员考场
      * @author Joburgess
      * @date 2020.07.08

+ 2 - 9
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/service/impl/ExamOrganizationRelationServiceImpl.java

@@ -1,6 +1,5 @@
 package com.keao.edu.user.service.impl;
 
-import cfca.sadk.org.bouncycastle.apache.bzip2.BZip2Constants;
 import com.keao.edu.auth.api.client.SysUserFeignService;
 import com.keao.edu.auth.api.entity.SysUser;
 import com.keao.edu.common.dal.BaseDAO;
@@ -11,7 +10,6 @@ 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.dao.*;
 import com.keao.edu.user.dto.ExamOrganStatisticsDto;
@@ -27,7 +25,6 @@ import com.keao.edu.user.service.ShortUrlService;
 import com.keao.edu.user.service.SysConfigService;
 import com.keao.edu.util.collection.MapUtil;
 import com.keao.edu.util.date.DateUtil;
-import org.apache.commons.beanutils.BeanUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -35,7 +32,6 @@ import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
-import java.lang.reflect.InvocationTargetException;
 import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.util.*;
@@ -204,7 +200,6 @@ public class ExamOrganizationRelationServiceImpl extends BaseServiceImpl<Long, E
 			throw new BizException("合作单位信息错误");
 		}
 
-		Map<Integer, Organization> idOrganMap = organs.stream().collect(Collectors.toMap(Organization::getId, o -> o));
 		for (ExamOrganizationRelation og : organizationRelations) {
 			if(organIdsWithExam.contains(og.getOrganId())){
 				throw new BizException("合作单位冲突");
@@ -234,6 +229,7 @@ public class ExamOrganizationRelationServiceImpl extends BaseServiceImpl<Long, E
 			og.setSelfPaymentAmount(BigDecimal.ZERO);
 		}
 		examOrganizationRelationDao.batchInsert(organizationRelations);
+		sendUrl(examOrganizationRelation.getId().intValue(), selfOrganId);
 	}
 
 	@Override
@@ -286,8 +282,6 @@ public class ExamOrganizationRelationServiceImpl extends BaseServiceImpl<Long, E
 			throw new BizException("请指定考级项目");
 		}
 
-		List<Integer> childOrganIds = organizationService.getNextLevelOrganIds(selfOrganId, false);
-
 		ExamOrganStatisticsDto examOrganizationRelation = examOrganizationRelationDao.getExamOrganizationRelation(examId.longValue(), selfOrganId);
 		if(Objects.isNull(examOrganizationRelation)){
 			throw new BizException("数据异常");
@@ -296,8 +290,7 @@ public class ExamOrganizationRelationServiceImpl extends BaseServiceImpl<Long, E
 			throw new BizException("发送失败");
 		}
 
-		List<ExamOrganizationRelation> examOrgans = examOrganizationRelationDao.getExamOrganizationRelations(examId.longValue(), childOrganIds);
-		Set<Integer> existOrganizationIds = examOrgans.stream().map(ExamOrganizationRelation::getOrganId).collect(Collectors.toSet());
+		List<ExamOrganizationRelation> examOrgans = examOrganizationRelationDao.getExamOrganizationRelations(examId.longValue(), null);
 
 		ExaminationBasic examinationBasic = examinationBasicDao.get(examId.longValue());
 		if(Objects.isNull(examinationBasic)){

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

@@ -28,7 +28,6 @@ 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.*;
@@ -552,7 +551,9 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
 						examName, examDayStr, examTimeStr, locationName, downloadUrl + student.getExamRegistrationId());
 			}
 
-			needUpdateExamRooms.add(new ExamRoom(examRoom.getId(), 1));
+            ExamRoom newExamRoom = new ExamRoom(examRoom.getId(), 1);
+			newExamRoom.setExamLocationId(examRoom.getExamLocationId());
+            needUpdateExamRooms.add(newExamRoom);
 
 			if(!teacherExamRoomsMap.containsKey(examRoom.getMainTeacherUserId())){
 				teacherExamRoomsMap.put(examRoom.getMainTeacherUserId(), new ArrayList<>());
@@ -572,8 +573,8 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
 		Map<Integer, String> idTeacherPhoneMap = this.getMap("sys_user", "id_", "phone_", new ArrayList(teacherExamRoomsMap.keySet()), Integer.class, String.class);
 		for (Map.Entry<Integer, List<ExamRoom>> teacherRoomEntry : teacherExamRoomsMap.entrySet()) {
 			String teacherPhone = idTeacherPhoneMap.get(teacherRoomEntry.getKey());
-			Date examStartTime = teacherRoomEntry.getValue().stream().min(Comparator.comparing(ExamRoom::getExamStartTime)).get().getExamStartTime();
-			String examStartTimeStr = DateUtil.dateToString(examStartTime, "MM月dd日 HH时mm分");
+			List<String> examStartTimes = teacherRoomEntry.getValue().stream().map(e-> DateUtil.dateToString(e.getExamStartTime(), "MM月dd日 HH点mm分")).collect(Collectors.toList());
+			String examStartTimeStr = StringUtils.join(examStartTimes, " ");
 			int examRoomNum = teacherRoomEntry.getValue().size();
 			Map<Integer, String> phoneMap = new HashMap<>();
 			phoneMap.put(teacherRoomEntry.getKey(), teacherPhone);
@@ -594,7 +595,7 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
 		if(!CollectionUtils.isEmpty(studentExamResults)){
 			studentExamResultDao.batchInsert(studentExamResults);
 		}
-		return BaseController.succeed("发送成功");
+		return BaseController.succeedMsg("发送成功");
 	}
 
 	@Override

+ 17 - 1
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/service/impl/ExamRoomStudentRelationServiceImpl.java

@@ -113,7 +113,10 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
 			throw new BizException("考级结果已确认");
 		}
 		Date now=new Date();
-		if(now.compareTo(examRoom.getExamStartTime())>0||DateUtil.isSameDay(now, examRoom.getExamStartTime())){
+		if(DateUtil.isSameDay(now, examRoom.getExamStartTime())){
+			throw new BizException("考试当天不可添加学员");
+		}
+		if(now.compareTo(examRoom.getExamStartTime())>0){
 			throw new BizException("无法添加学员");
 		}
 
@@ -252,6 +255,19 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
 	}
 
 	@Override
+	public void autoSplitStudentToRoom(Long examRoomId, Integer selfOrganId) {
+		ExaminationBasic examinationBasic = examinationBasicDao.get(examRoomId);
+		if(Objects.isNull(examinationBasic)){
+			throw new BizException("考级项目不存在");
+		}
+		int sendExamPlanRooms = examRoomDao.countSendExamPlanRooms(examRoomId);
+		if(sendExamPlanRooms>0){
+			throw new BizException("已发送考试安排,请手动处理未排考学员");
+		}
+//		examRegistrationDao.getStuRecordDetail()
+	}
+
+	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public void changeStudentExamRoom(Long registId, Long examRoomId, Integer organId) {
 		if(Objects.isNull(registId)){

+ 16 - 4
edu-user/edu-user-biz/src/main/resources/config/mybatis/ExamOrganizationRelationMapper.xml

@@ -373,10 +373,13 @@
 		SELECT * FROM exam_organization_relation WHERE examination_basic_id_=#{examId} AND organ_id_=#{OrganId} FOR UPDATE
 	</select>
 	<select id="getExamOrganizationRelations" resultMap="ExamOrganizationRelation">
-		SELECT * FROM exam_organization_relation WHERE examination_basic_id_=#{examId} AND organ_id_ IN
-		<foreach collection="organIds" item="organId" separator="," open="(" close=")">
-			#{organId}
-		</foreach>
+		SELECT * FROM exam_organization_relation WHERE examination_basic_id_=#{examId}
+		<if test="organIds != null">
+			AND organ_id_ IN
+			<foreach collection="organIds" item="organId" separator="," open="(" close=")">
+				#{organId}
+			</foreach>
+		</if>
 	</select>
 
 	<select id="getExamChildOrgans" resultMap="ExamOrganizationRelationExtraDto">
@@ -394,5 +397,14 @@
 			</foreach>
 		</if>
 	</select>
+    <select id="countExamIsSendUrlOrgans" resultType="int">
+		SELECT
+			COUNT( organ_id_ )
+		FROM
+			exam_organization_relation
+		WHERE
+			examination_basic_id_ = #{examId}
+			AND send_url_flag_ = 1;
+	</select>
 
 </mapper>

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

@@ -634,4 +634,8 @@
 		LEFT JOIN student_exam_result ser ON ser.exam_registration_id_ = er.id_
 		WHERE er.id_ = #{examRegistrationId} LIMIT 1
 	</select>
+
+    <select id="getNotInRoomStudents" resultMap="ExamRegistration">
+
+	</select>
 </mapper>

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

@@ -444,4 +444,7 @@
 			exam_start_time_ &lt; NOW( )
 			AND open_flag_ =1
 	</select>
+    <select id="countSendExamPlanRooms" resultType="int">
+		SELECT COUNT(id_) FROM exam_room WHERE examination_basic_id_=#{examId} AND exam_plan_push_flag_=1
+	</select>
 </mapper>

+ 5 - 0
edu-user/edu-user-biz/src/main/resources/config/mybatis/StudentExamResultMapper.xml

@@ -297,4 +297,9 @@
 		SELECT COUNT(exam_registration_id_) FROM student_exam_result
 		WHERE examination_basic_id_=#{examId} AND is_finished_exam_=5 AND result_ IS NULL
 	</select>
+
+    <select id="countExamResultRecordNum" resultType="java.lang.Integer">
+		SELECT COUNT(exam_registration_id_) FROM student_exam_result
+		WHERE examination_basic_id_=#{examId}
+	</select>
 </mapper>

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

@@ -5,6 +5,7 @@ import com.keao.edu.auth.api.entity.SysUser;
 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.user.dao.ExamOrganizationRelationDao;
 import com.keao.edu.user.dto.ExamOrganizationRelationExtraDto;
 import com.keao.edu.user.entity.Employee;
 import com.keao.edu.user.entity.ExamOrganizationRelation;
@@ -35,6 +36,8 @@ public class ExamOrganizationRelationController extends BaseController {
     private SysUserFeignService sysUserFeignService;
     @Autowired
     private EmployeeService employeeService;
+    @Autowired
+    private ExamOrganizationRelationDao examOrganizationRelationDao;
 
     @ApiOperation("分页查询")
     @GetMapping(value = "/list")
@@ -110,6 +113,10 @@ public class ExamOrganizationRelationController extends BaseController {
         if(Objects.isNull(employee)){
             return failed("用户异常");
         }
+        int sendUrlOrgans = examOrganizationRelationDao.countExamIsSendUrlOrgans(examId.longValue());
+        if(sendUrlOrgans>0){
+            return failed("已发送过报名链接");
+        }
         examOrganizationRelationService.sendUrl(examId,employee.getOrganId());
         return succeed();
     }