|  | @@ -17,6 +17,7 @@ import com.keao.edu.user.dao.ExamOrganizationRelationDao;
 | 
	
		
			
				|  |  |  import com.keao.edu.user.dao.ExaminationBasicDao;
 | 
	
		
			
				|  |  |  import com.keao.edu.user.dao.OrganizationDao;
 | 
	
		
			
				|  |  |  import com.keao.edu.user.dao.TeacherDao;
 | 
	
		
			
				|  |  | +import com.keao.edu.user.dto.ExamOrganizationRelationExtraDto;
 | 
	
		
			
				|  |  |  import com.keao.edu.user.entity.ExamOrganizationRelation;
 | 
	
		
			
				|  |  |  import com.keao.edu.user.entity.ExaminationBasic;
 | 
	
		
			
				|  |  |  import com.keao.edu.user.entity.Organization;
 | 
	
	
		
			
				|  | @@ -69,29 +70,32 @@ public class ExamOrganizationRelationServiceImpl extends BaseServiceImpl<Long, E
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	@Override
 | 
	
		
			
				|  |  | -	public PageInfo<ExamOrganizationRelation> queryExamOrgans(ExamOrganizationRelationQueryInfo queryInfo) {
 | 
	
		
			
				|  |  | -		PageInfo<ExamOrganizationRelation> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
 | 
	
		
			
				|  |  | +	public PageInfo<ExamOrganizationRelationExtraDto> queryExamOrgans(ExamOrganizationRelationQueryInfo queryInfo) {
 | 
	
		
			
				|  |  | +		PageInfo<ExamOrganizationRelationExtraDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
 | 
	
		
			
				|  |  |  		Map<String, Object> params = new HashMap<String, Object>();
 | 
	
		
			
				|  |  |  		MapUtil.populateMap(params, queryInfo);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		List<Integer> nextLevelOrganIds = organizationService.getChildOrganIds(queryInfo.getOrganId(), true);
 | 
	
		
			
				|  |  |  		params.put("organIds", nextLevelOrganIds);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		List<ExamOrganizationRelation> dataList = new ArrayList<>();
 | 
	
		
			
				|  |  | -		int count = this.findCount(params);
 | 
	
		
			
				|  |  | +		List<ExamOrganizationRelationExtraDto> dataList = new ArrayList<>();
 | 
	
		
			
				|  |  | +		int count = examOrganizationRelationDao.countExamOrgans(params);
 | 
	
		
			
				|  |  |  		if (count > 0) {
 | 
	
		
			
				|  |  |  			pageInfo.setTotal(count);
 | 
	
		
			
				|  |  |  			params.put("offset", pageInfo.getOffset());
 | 
	
		
			
				|  |  | -			dataList = this.getDAO().queryPage(params);
 | 
	
		
			
				|  |  | +			dataList = examOrganizationRelationDao.queryExamOrgans(params);
 | 
	
		
			
				|  |  |  			List<Integer> organIds = dataList.stream().map(ExamOrganizationRelation::getOrganId).collect(Collectors.toList());
 | 
	
		
			
				|  |  |  			List<ExamOrganizationRelation> countInfos = examOrganizationRelationDao.countExamOrganStudentAndPayment(queryInfo.getExamId(), organIds);
 | 
	
		
			
				|  |  |  			Map<Integer, ExamOrganizationRelation> organCountInfoMap = countInfos.stream().collect(Collectors.toMap(ExamOrganizationRelation::getOrganId, e -> e));
 | 
	
		
			
				|  |  | -			for (ExamOrganizationRelation examOrganizationRelation : dataList) {
 | 
	
		
			
				|  |  | +			for (ExamOrganizationRelationExtraDto examOrganizationRelation : dataList) {
 | 
	
		
			
				|  |  |  				ExamOrganizationRelation countInfo = organCountInfoMap.get(examOrganizationRelation.getOrganId());
 | 
	
		
			
				|  |  |  				if(Objects.nonNull(countInfo)){
 | 
	
		
			
				|  |  |  					examOrganizationRelation.setTotalRegistrationStudentNum(countInfo.getTotalRegistrationStudentNum());
 | 
	
		
			
				|  |  |  					examOrganizationRelation.setTotalPaymentAmount(countInfo.getTotalPaymentAmount());
 | 
	
		
			
				|  |  |  				}
 | 
	
		
			
				|  |  | +				if(examOrganizationRelation.getOrganId().equals(queryInfo.getOrganId())){
 | 
	
		
			
				|  |  | +					examOrganizationRelation.setSelfOrgan(1);
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  		pageInfo.setRows(dataList);
 | 
	
	
		
			
				|  | @@ -158,21 +162,12 @@ public class ExamOrganizationRelationServiceImpl extends BaseServiceImpl<Long, E
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	@Override
 | 
	
		
			
				|  |  |  	@Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  | -	public void sendUrl(Integer examId, String organIdStrs) {
 | 
	
		
			
				|  |  | +	public void sendUrl(Integer examId) {
 | 
	
		
			
				|  |  |  		if(Objects.isNull(examId)){
 | 
	
		
			
				|  |  |  			throw new BizException("请指定考级项目");
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  | -		if(StringUtils.isBlank(organIdStrs)){
 | 
	
		
			
				|  |  | -			throw new BizException("请指定合作单位");
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  |  		List<ExamOrganizationRelation> examOrgans = examOrganizationRelationDao.getWithExam(examId);
 | 
	
		
			
				|  |  |  		Set<Integer> existOrganizationIds = examOrgans.stream().map(ExamOrganizationRelation::getOrganId).collect(Collectors.toSet());
 | 
	
		
			
				|  |  | -		List<Integer> organIds = Arrays.asList(organIdStrs.split(",")).stream().map(e -> Integer.valueOf(e)).collect(Collectors.toList());
 | 
	
		
			
				|  |  | -		for (Integer organId : organIds) {
 | 
	
		
			
				|  |  | -			if(!existOrganizationIds.contains(organId)){
 | 
	
		
			
				|  |  | -				throw new BizException("存在未关联到考级项目的合作单位");
 | 
	
		
			
				|  |  | -			}
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		ExaminationBasic examinationBasic = examinationBasicDao.get(examId.longValue());
 | 
	
		
			
				|  |  |  		if(Objects.isNull(examinationBasic)){
 | 
	
	
		
			
				|  | @@ -186,10 +181,12 @@ public class ExamOrganizationRelationServiceImpl extends BaseServiceImpl<Long, E
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  		baseUrl = baseUrl+"/#/signUp?";
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +		List<ExamOrganizationRelation> needUpdate=new ArrayList<>();
 | 
	
		
			
				|  |  |  		for (ExamOrganizationRelation examOrgan : examOrgans) {
 | 
	
		
			
				|  |  |  			if(YesOrNoEnum.YES.equals(examOrgan.getSendUrlFlag())){
 | 
	
		
			
				|  |  |  				continue;
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  | +			needUpdate.add(examOrgan);
 | 
	
		
			
				|  |  |  			String registrationUrl = baseUrl + "examId=" + examOrgan.getExaminationBasicId() + "&organId=" + examOrgan.getOrganId();
 | 
	
		
			
				|  |  |  			String registShortUrl = shortUrlService.createShortUrl(registrationUrl);
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -205,7 +202,9 @@ public class ExamOrganizationRelationServiceImpl extends BaseServiceImpl<Long, E
 | 
	
		
			
				|  |  |  			sysMessageFeignService.batchSendMessage(sysMessageParams);
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		examOrganizationRelationDao.batchUpdate(examOrgans);
 | 
	
		
			
				|  |  | +		if(!CollectionUtils.isEmpty(needUpdate)){
 | 
	
		
			
				|  |  | +			examOrganizationRelationDao.batchUpdate(needUpdate);
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		if(examinationBasic.getStatus().equals(ExamStatusEnum.SETTING)){
 | 
	
		
			
				|  |  |  			examinationBasic.setStatus(ExamStatusEnum.NOT_START);
 |