diff --git a/src/main/java/cn/com/tenlion/pojo/vos/examcheck/ExamCheckVO.java b/src/main/java/cn/com/tenlion/pojo/vos/examcheck/ExamCheckVO.java index d291b20..00699f8 100644 --- a/src/main/java/cn/com/tenlion/pojo/vos/examcheck/ExamCheckVO.java +++ b/src/main/java/cn/com/tenlion/pojo/vos/examcheck/ExamCheckVO.java @@ -1,6 +1,5 @@ package cn.com.tenlion.pojo.vos.examcheck; -import ink.wgink.annotation.CheckEmptyAnnotation; import ink.wgink.annotation.CheckNumberAnnotation; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/src/main/java/cn/com/tenlion/service/examination/distribution/impl/DistributionServiceImpl.java b/src/main/java/cn/com/tenlion/service/examination/distribution/impl/DistributionServiceImpl.java index 94967d0..07cd238 100644 --- a/src/main/java/cn/com/tenlion/service/examination/distribution/impl/DistributionServiceImpl.java +++ b/src/main/java/cn/com/tenlion/service/examination/distribution/impl/DistributionServiceImpl.java @@ -146,9 +146,9 @@ public class DistributionServiceImpl extends DefaultBaseService implements IDist * 判断考试人数是否为空 * renpc2021-06-17注释掉此段内容 */ - /*if (dDistributionSaveVO.getDistributionNumber() == null || dDistributionSaveVO.getDistributionNumber() < 1) { + if (dDistributionSaveVO.getDistributionNumber() == null || dDistributionSaveVO.getDistributionNumber() < 1) { throw new SaveException("考试人数不合法"); - }*/ + } /** * 判断预计考试时间是否为空是否大于今天 */ @@ -169,9 +169,9 @@ public class DistributionServiceImpl extends DefaultBaseService implements IDist totalNumber = totalNumber + dto.getOrganizationUserNum(); } // renpc2021-06-17注释掉此段内容 - /*if(totalNumber < dDistributionSaveVO.getDistributionNumber()) { + if(totalNumber < dDistributionSaveVO.getDistributionNumber()) { throw new SaveException("该考点无法容纳本次考试的人数"); - }*/ + } Map save = HashMapUtil.beanToMap(dDistributionSaveVO); save.put("distributionAllotTime", ""); save.put("distributionFields", ""); @@ -222,218 +222,6 @@ public class DistributionServiceImpl extends DefaultBaseService implements IDist * @param distributionId * @param distributionVO */ -// @Override -// public void update(String token, String distributionId, DistributionVO distributionVO) { -// /** -// * 判断考试时间 -// */ -// if(StringUtils.isEmpty(distributionVO.getDistributionAllotTime())) { -// throw new UpdateException("请输入考试开始时间"); -// } -// if(StringUtils.isEmpty(distributionVO.getDistributionAllotEndTime())) { -// throw new UpdateException("请输入考试结束时间"); -// } -// try { -// DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); -// Date startTime = fmt.parse(distributionVO.getDistributionAllotTime()); -// Date endTime = fmt.parse(distributionVO.getDistributionAllotEndTime()); -// long timeDelta = (startTime.getTime() - endTime.getTime()) /1000;//单位是秒 -// if(timeDelta > (-1 * 60 * 60) ) { -// throw new UpdateException("考试时间范围错误"); -// } -// }catch(Exception e) { -// throw new UpdateException("考试时间范围格式错误"); -// } -// /** -// * 判断是否至少选择了一个考场 -// */ -// String[] fieldArray = distributionVO.getDistributionFields().split(","); -// if(StringUtils.isEmpty(distributionVO.getDistributionFields()) || fieldArray.length < 1) { -// throw new UpdateException("至少需要分配一个考场"); -// } -// /** -// * 计算考场可容纳的总人数 -// */ -// Map query = new HashMap(); -// int fieldTotalNumber = 0; -// for(String fieldId : fieldArray) { -// OrganizationDTO organizationDTO = iOrganizationService.get(fieldId); -// fieldTotalNumber = fieldTotalNumber + organizationDTO.getOrganizationUserNum(); -// } -// /** -// * 计算需要参加考试的总人数 -// */ -// String[] distributionIdArray = distributionId.split(","); -// int userTotalNumber = 0; -// for(String classPlanId : distributionIdArray) { -// // 查询出该考试报名实际人数 -// List userList = iApplyService.listByClassId(classPlanId); -// userTotalNumber = userTotalNumber + (userList == null ? 0 : userList.size()); -// } -// /** -// * 比较两个数,是否能够容纳的下所有参加考试的人 -// */ -// if(userTotalNumber > fieldTotalNumber ) { -// throw new UpdateException("当前分配的考场无法容纳考试人数"); -// } -// int index = 0; -// int subNumber = 0; -// int currentNumber = 0; -// String currentFieldId = ""; -// for(String classPlanId : distributionIdArray) { -// DistributionDTO distributionDTO = get(classPlanId); -// if(distributionDTO != null) { -// throw new UpdateException("非法操作."); -// } -// // 共分配的多个考场ID -// ArrayList fieldList = new ArrayList(); -// // 是否存在跨考点, 做记录 -// String stationId = ""; -// // 多个考场, 做记录 -// String fieldId = ""; -// // 考试申请 -// ClassPlanDTO classPlanDTO = iClassPlanService.get(classPlanId); -// // 查询出该考试报名实际人数 -// List userList = applyStudentsService.listByClssId(classPlanId); -// for(int i = 0 ; i < userList.size(); i++) { -// /** -// * 判断当前考场位置是否使用完, 使用完则获取下一个考场的数量 -// */ -// if(subNumber == 0) { -// // 获取考场可以容纳的人数 -// OrganizationDTO organizationDTO = iOrganizationService.get(fieldArray[index++]); -// fieldList.add(organizationDTO); -// // 记录是否跨考点 -// stationId = stationId.contains(organizationDTO.getOrganizationType()) ? stationId : stationId + "," + organizationDTO.getOrganizationType(); -// // 记录考场 -// fieldId = fieldId.contains(organizationDTO.getOrganizationId()) ? fieldId : fieldId + "," + organizationDTO.getOrganizationId(); -// // 记录当前考场ID -// currentFieldId = organizationDTO.getOrganizationId(); -// subNumber = organizationDTO.getOrganizationUserNum(); -// /** -// * 判断当前考点在当前考试时间段之间是否已经被占用 -// */ -// query.clear(); -// query.put("distributionAllotTime", distributionVO.getDistributionAllotTime()); -// query.put("distributionAllotEndTime", distributionVO.getDistributionAllotEndTime()); -// query.put("fieldId", organizationDTO.getOrganizationId()); -// List distributionDTOS = distributionDao.getListByFieldId(query); -// if(distributionDTOS != null && distributionDTOS.size() > 0) { -// throw new UpdateException(organizationDTO.getOrganizationName() + "该时段已被(" + distributionDTOS.get(0).getPlanName() + ")占用"); -// } -// currentNumber = 0; -// } -// /** -// * 保存card表 -// */ -// DistributionCardVO distributionCardVO = new DistributionCardVO(); -// distributionCardVO.setDistributionCardUserId(userList.get(i).getCreator()); -// distributionCardVO.setDistributionCardUserName(userList.get(i).getApplyName()); -// distributionCardVO.setDistributionCardNumber( (++currentNumber ) + "" ); -// distributionCardVO.setDistributionFieldId(currentFieldId); -// distributionCardVO.setClassPlanId(classPlanId); -// distributionCardVO.setDistributionId(classPlanId); -// distributionCardVO.setDistributionCardPictures(""); -// // 保存性别中文,又用中文差名称,暂时改为直接输出 -// // DataDTO dataDTO = dataDictionaryServiceImpl.get(userList.get(i).getApplySex()); -// // distributionCardVO.setDistributionCardUserSex(dataDTO.getDataName()); -// distributionCardVO.setDistributionCardUserSex(userList.get(i).getApplySex()); -// distributionCardVO.setDistributionCardUserIdentity(userList.get(i).getApplyCardNumber()); -// distributionCardVO.setDistributionCardUserResult(""); -// distributionCardVO.setDistributionCardUserStatus("0"); -// iDistributionCardService.saveById(userList.get(i).getApplyId(), distributionCardVO); -// subNumber--; -// } -// /** -// * 保存考试考场分配 -// */ -// for(OrganizationDTO field : fieldList) { -// DistributionFieldVO vo = new DistributionFieldVO(); -// vo.setDistributionId(classPlanId); -// vo.setFieldId(field.getOrganizationId()); -// vo.setFieldName(field.getOrganizationName()); -// vo.setFieldNumber(field.getOrganizationUserNum()); -// vo.setFieldStatus("0"); -// String distributionFieldId = iDistributionFieldService.saveReturnId(vo); -// /** -// * 更新card关联 -// */ -// Map update = new HashMap(); -// update.put("fieldId", field.getOrganizationId()); -// update.put("distributionFieldId", distributionFieldId); -// iDistributionCardService.updateFieldId(update); -// } -// /** -// * 保存考试申请 -// */ -// Map params = HashMapUtil.beanToMap(distributionVO); -// if (StringUtils.isBlank(token)) { -// setSaveInfo(params); -// } else { -// setAppSaveInfo(token, params); -// } -// params.put("stationId", stationId.length() > 0 ? stationId.substring(1, stationId.length()) : ""); -// params.put("planId", classPlanId); -// params.put("planName", classPlanDTO.getPlanName()); -// params.put("distributionTime", ""); -// params.put("distributionEndTime", ""); -// params.put("distributionFields", fieldId.length() > 0 ? fieldId.substring(1, fieldId.length()) : ""); -// params.put("distributionStatus", "1"); -// params.put("distributionNumber", userList == null ? 0 : userList.size()); -// params.put("distributionId", classPlanId); -// distributionDao.save(params); -// /** -// * 更新应急局的考试申请审核主表中的考试时间以及状态 -// */ -// ExamApplyVO vo = new ExamApplyVO(); -// vo.setExamId(distributionId); -// vo.setStatus(1); -// vo.setCheckStatus(1); -// vo.setPracticeExamStartTime(distributionVO.getDistributionAllotTime()); -// vo.setPracticeExamEndTime(distributionVO.getDistributionAllotEndTime()); -// iExamApplyService.updateStatus(distributionId, vo); -// -// /** -// * 更新考试人员信息(添加考场信息到考试人员表中) -// */ -// params = new HashMap<>(1); -// String examOrgId = ""; -// String examOrgName = ""; -// for(int i=0;i query = new HashMap(); - /** - * 获取考试信息 - */ - query.put("examPlanIdList", distributionId); - List examPlanDTOS = null; - try { - examPlanDTOS = examPlanService.list(query); - }catch (Exception e) { - e.printStackTrace(); - } - query.remove("examPlanIdList"); int fieldTotalNumber = 0; - for(ExamPlanDTO examPlanDTO : examPlanDTOS) { - fieldTotalNumber = fieldTotalNumber + Integer.valueOf(examPlanDTO.getExamCount()); + for(String fieldId : fieldArray) { + OrganizationDTO organizationDTO = iOrganizationService.get(fieldId); + fieldTotalNumber = fieldTotalNumber + organizationDTO.getOrganizationUserNum(); } /** * 计算需要参加考试的总人数 @@ -489,12 +267,8 @@ public class DistributionServiceImpl extends DefaultBaseService implements IDist int userTotalNumber = 0; for(String classPlanId : distributionIdArray) { // 查询出该考试报名实际人数 - query.put("checkStatus", 1); - query.put("classPlanId", classPlanId); - List applyStudentsNewDTOList = applyStudentsNewService.list(query); - userTotalNumber = userTotalNumber + (applyStudentsNewDTOList == null ? 0 : applyStudentsNewDTOList.size()); - query.remove("checkStatus"); - query.remove("classPlanId"); + List userList = iApplyService.listByClassId(classPlanId); + userTotalNumber = userTotalNumber + (userList == null ? 0 : userList.size()); } /** * 比较两个数,是否能够容纳的下所有参加考试的人 @@ -508,9 +282,9 @@ public class DistributionServiceImpl extends DefaultBaseService implements IDist String currentFieldId = ""; for(String classPlanId : distributionIdArray) { DistributionDTO distributionDTO = get(classPlanId); - /*if(distributionDTO != null) { + if(distributionDTO != null) { throw new UpdateException("非法操作."); - }*/ + } // 共分配的多个考场ID ArrayList fieldList = new ArrayList(); // 是否存在跨考点, 做记录 @@ -518,16 +292,9 @@ public class DistributionServiceImpl extends DefaultBaseService implements IDist // 多个考场, 做记录 String fieldId = ""; // 考试申请 - query.put("examPlanId", classPlanId); - ExamPlanDTO examPlanDTO = examPlanService.get(query); - query.remove("examPlanId"); + ClassPlanDTO classPlanDTO = iClassPlanService.get(classPlanId); // 查询出该考试报名实际人数 - // 查询出该考试报名实际人数 - query.put("checkStatus", 1); - query.put("classPlanId", classPlanId); - List userList = applyStudentsNewService.list(query); - query.remove("checkStatus"); - query.remove("classPlanId"); + List userList = applyStudentsService.listByClssId(classPlanId); for(int i = 0 ; i < userList.size(); i++) { /** * 判断当前考场位置是否使用完, 使用完则获取下一个考场的数量 @@ -560,8 +327,8 @@ public class DistributionServiceImpl extends DefaultBaseService implements IDist * 保存card表 */ DistributionCardVO distributionCardVO = new DistributionCardVO(); - distributionCardVO.setDistributionCardUserId(userList.get(i).getUserId()); - distributionCardVO.setDistributionCardUserName(userList.get(i).getName()); + distributionCardVO.setDistributionCardUserId(userList.get(i).getCreator()); + distributionCardVO.setDistributionCardUserName(userList.get(i).getApplyName()); distributionCardVO.setDistributionCardNumber( (++currentNumber ) + "" ); distributionCardVO.setDistributionFieldId(currentFieldId); distributionCardVO.setClassPlanId(classPlanId); @@ -570,11 +337,11 @@ public class DistributionServiceImpl extends DefaultBaseService implements IDist // 保存性别中文,又用中文差名称,暂时改为直接输出 // DataDTO dataDTO = dataDictionaryServiceImpl.get(userList.get(i).getApplySex()); // distributionCardVO.setDistributionCardUserSex(dataDTO.getDataName()); - distributionCardVO.setDistributionCardUserSex(userList.get(i).getSex()); - distributionCardVO.setDistributionCardUserIdentity(userList.get(i).getCardNumber()); + distributionCardVO.setDistributionCardUserSex(userList.get(i).getApplySex()); + distributionCardVO.setDistributionCardUserIdentity(userList.get(i).getApplyCardNumber()); distributionCardVO.setDistributionCardUserResult(""); distributionCardVO.setDistributionCardUserStatus("0"); - iDistributionCardService.saveById(userList.get(i).getClassPlanId(), distributionCardVO); + iDistributionCardService.saveById(userList.get(i).getApplyId(), distributionCardVO); subNumber--; } /** @@ -607,7 +374,7 @@ public class DistributionServiceImpl extends DefaultBaseService implements IDist } params.put("stationId", stationId.length() > 0 ? stationId.substring(1, stationId.length()) : ""); params.put("planId", classPlanId); - params.put("planName", examPlanDTO.getName()); + params.put("planName", classPlanDTO.getPlanName()); params.put("distributionTime", ""); params.put("distributionEndTime", ""); params.put("distributionFields", fieldId.length() > 0 ? fieldId.substring(1, fieldId.length()) : ""); @@ -659,6 +426,239 @@ public class DistributionServiceImpl extends DefaultBaseService implements IDist } } + + /** + * 分配考场/时间/生成准考证 + * 新复制方法(renpc) + * @param token + * @param distributionId + * @param distributionVO + */ + /* @Override + public void update(String token, String distributionId, DistributionVO distributionVO) { + *//** + * 判断考试时间 + *//* + if(StringUtils.isEmpty(distributionVO.getDistributionAllotTime())) { + throw new UpdateException("请输入考试开始时间"); + } + if(StringUtils.isEmpty(distributionVO.getDistributionAllotEndTime())) { + throw new UpdateException("请输入考试结束时间"); + } + try { + DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date startTime = fmt.parse(distributionVO.getDistributionAllotTime()); + Date endTime = fmt.parse(distributionVO.getDistributionAllotEndTime()); + long timeDelta = (startTime.getTime() - endTime.getTime()) /1000;//单位是秒 + if(timeDelta > (-1 * 60 * 60) ) { + throw new UpdateException("考试时间范围错误"); + } + }catch(Exception e) { + throw new UpdateException("考试时间范围格式错误"); + } + *//** + * 判断是否至少选择了一个考场 + *//* + String[] fieldArray = distributionVO.getDistributionFields().split(","); + if(StringUtils.isEmpty(distributionVO.getDistributionFields()) || fieldArray.length < 1) { + throw new UpdateException("至少需要分配一个考场"); + } + *//** + * 计算考场可容纳的总人数 + *//* + Map query = new HashMap(); + *//** + * 获取考试信息 + *//* + query.put("examPlanIdList", distributionId); + List examPlanDTOS = null; + try { + examPlanDTOS = examPlanService.list(query); + }catch (Exception e) { + e.printStackTrace(); + } + query.remove("examPlanIdList"); + int fieldTotalNumber = 0; + for(ExamPlanDTO examPlanDTO : examPlanDTOS) { + fieldTotalNumber = fieldTotalNumber + Integer.valueOf(examPlanDTO.getExamCount()); + } + *//** + * 计算需要参加考试的总人数 + *//* + String[] distributionIdArray = distributionId.split(","); + int userTotalNumber = 0; + for(String classPlanId : distributionIdArray) { + // 查询出该考试报名实际人数 + query.put("checkStatus", 1); + query.put("classPlanId", classPlanId); + List applyStudentsNewDTOList = applyStudentsNewService.list(query); + userTotalNumber = userTotalNumber + (applyStudentsNewDTOList == null ? 0 : applyStudentsNewDTOList.size()); + query.remove("checkStatus"); + query.remove("classPlanId"); + } + *//** + * 比较两个数,是否能够容纳的下所有参加考试的人 + *//* + if(userTotalNumber > fieldTotalNumber ) { + throw new UpdateException("当前分配的考场无法容纳考试人数"); + } + int index = 0; + int subNumber = 0; + int currentNumber = 0; + String currentFieldId = ""; + for(String classPlanId : distributionIdArray) { + DistributionDTO distributionDTO = get(classPlanId); + *//*if(distributionDTO != null) { + throw new UpdateException("非法操作."); + }*//* + // 共分配的多个考场ID + ArrayList fieldList = new ArrayList(); + // 是否存在跨考点, 做记录 + String stationId = ""; + // 多个考场, 做记录 + String fieldId = ""; + // 考试申请 + query.put("examPlanId", classPlanId); + ExamPlanDTO examPlanDTO = examPlanService.get(query); + query.remove("examPlanId"); + // 查询出该考试报名实际人数 + // 查询出该考试报名实际人数 + query.put("checkStatus", 1); + query.put("classPlanId", classPlanId); + List userList = applyStudentsNewService.list(query); + query.remove("checkStatus"); + query.remove("classPlanId"); + for(int i = 0 ; i < userList.size(); i++) { + *//** + * 判断当前考场位置是否使用完, 使用完则获取下一个考场的数量 + *//* + if(subNumber == 0) { + // 获取考场可以容纳的人数 + OrganizationDTO organizationDTO = iOrganizationService.get(fieldArray[index++]); + fieldList.add(organizationDTO); + // 记录是否跨考点 + stationId = stationId.contains(organizationDTO.getOrganizationType()) ? stationId : stationId + "," + organizationDTO.getOrganizationType(); + // 记录考场 + fieldId = fieldId.contains(organizationDTO.getOrganizationId()) ? fieldId : fieldId + "," + organizationDTO.getOrganizationId(); + // 记录当前考场ID + currentFieldId = organizationDTO.getOrganizationId(); + subNumber = organizationDTO.getOrganizationUserNum(); + *//** + * 判断当前考点在当前考试时间段之间是否已经被占用 + *//* + query.clear(); + query.put("distributionAllotTime", distributionVO.getDistributionAllotTime()); + query.put("distributionAllotEndTime", distributionVO.getDistributionAllotEndTime()); + query.put("fieldId", organizationDTO.getOrganizationId()); + List distributionDTOS = distributionDao.getListByFieldId(query); + if(distributionDTOS != null && distributionDTOS.size() > 0) { + throw new UpdateException(organizationDTO.getOrganizationName() + "该时段已被(" + distributionDTOS.get(0).getPlanName() + ")占用"); + } + currentNumber = 0; + } + *//** + * 保存card表 + *//* + DistributionCardVO distributionCardVO = new DistributionCardVO(); + distributionCardVO.setDistributionCardUserId(userList.get(i).getUserId()); + distributionCardVO.setDistributionCardUserName(userList.get(i).getName()); + distributionCardVO.setDistributionCardNumber( (++currentNumber ) + "" ); + distributionCardVO.setDistributionFieldId(currentFieldId); + distributionCardVO.setClassPlanId(classPlanId); + distributionCardVO.setDistributionId(classPlanId); + distributionCardVO.setDistributionCardPictures(""); + // 保存性别中文,又用中文差名称,暂时改为直接输出 + // DataDTO dataDTO = dataDictionaryServiceImpl.get(userList.get(i).getApplySex()); + // distributionCardVO.setDistributionCardUserSex(dataDTO.getDataName()); + distributionCardVO.setDistributionCardUserSex(userList.get(i).getSex()); + distributionCardVO.setDistributionCardUserIdentity(userList.get(i).getCardNumber()); + distributionCardVO.setDistributionCardUserResult(""); + distributionCardVO.setDistributionCardUserStatus("0"); + iDistributionCardService.saveById(userList.get(i).getClassPlanId(), distributionCardVO); + subNumber--; + } + *//** + * 保存考试考场分配 + *//* + for(OrganizationDTO field : fieldList) { + DistributionFieldVO vo = new DistributionFieldVO(); + vo.setDistributionId(classPlanId); + vo.setFieldId(field.getOrganizationId()); + vo.setFieldName(field.getOrganizationName()); + vo.setFieldNumber(field.getOrganizationUserNum()); + vo.setFieldStatus("0"); + String distributionFieldId = iDistributionFieldService.saveReturnId(vo); + *//** + * 更新card关联 + *//* + Map update = new HashMap(); + update.put("fieldId", field.getOrganizationId()); + update.put("distributionFieldId", distributionFieldId); + iDistributionCardService.updateFieldId(update); + } + *//** + * 保存考试申请 + *//* + Map params = HashMapUtil.beanToMap(distributionVO); + if (StringUtils.isBlank(token)) { + setSaveInfo(params); + } else { + setAppSaveInfo(token, params); + } + params.put("stationId", stationId.length() > 0 ? stationId.substring(1, stationId.length()) : ""); + params.put("planId", classPlanId); + params.put("planName", examPlanDTO.getName()); + params.put("distributionTime", ""); + params.put("distributionEndTime", ""); + params.put("distributionFields", fieldId.length() > 0 ? fieldId.substring(1, fieldId.length()) : ""); + params.put("distributionStatus", "1"); + params.put("distributionNumber", userList == null ? 0 : userList.size()); + params.put("distributionId", classPlanId); + distributionDao.save(params); + *//** + * 更新应急局的考试申请审核主表中的考试时间以及状态 + *//* + ExamApplyVO vo = new ExamApplyVO(); + vo.setExamId(distributionId); + vo.setStatus(1); + vo.setCheckStatus(1); + vo.setPracticeExamStartTime(distributionVO.getDistributionAllotTime()); + vo.setPracticeExamEndTime(distributionVO.getDistributionAllotEndTime()); + iExamApplyService.updateStatus(distributionId, vo); + + *//** + * 更新考试人员信息(添加考场信息到考试人员表中) + *//* + params = new HashMap<>(1); + String examOrgId = ""; + String examOrgName = ""; + for(int i=0;i params) { DistributionDTO dto = distributionDao.get(params);