|
@@ -173,6 +173,72 @@ public class ExamOrganizationRelationServiceImpl extends BaseServiceImpl<Long, E
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void addExamOrganizations(List<ExamOrganizationRelation> organizationRelations) {
|
|
|
+ if(CollectionUtils.isEmpty(organizationRelations)){
|
|
|
+ throw new BizException("请指定考级项目");
|
|
|
+ }
|
|
|
+ if(Objects.isNull(organizationRelations.get(0).getExaminationBasicId())){
|
|
|
+ throw new BizException("请指定考级项目");
|
|
|
+ }
|
|
|
+ ExaminationBasic examinationBasic = examinationBasicDao.get(organizationRelations.get(0).getExaminationBasicId().longValue());
|
|
|
+ if(Objects.isNull(examinationBasic)){
|
|
|
+ throw new BizException("考级项目不存在");
|
|
|
+ }
|
|
|
+ if(!EDIT_ABLE_EXAM_STATUS.contains(examinationBasic.getStatus())){
|
|
|
+ throw new BizException("当前状态暂不可添加合作单位");
|
|
|
+ }
|
|
|
+
|
|
|
+ Set<Integer> organIdsWithExam = examOrganizationRelationDao.getOrganIdsWithExam(examinationBasic.getId().intValue());
|
|
|
+ List<Integer> organIds = organizationRelations.stream().filter(e->Objects.nonNull(e.getOrganId())).map(ExamOrganizationRelation::getOrganId).collect(Collectors.toList());
|
|
|
+ if(organIds.size()!=organizationRelations.size()){
|
|
|
+ throw new BizException("参数错误");
|
|
|
+ }
|
|
|
+ List<Organization> organs = organizationDao.getOrgans(organIds);
|
|
|
+ if(organs.size()!=organIds.size()){
|
|
|
+ throw new BizException("合作单位信息错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ SysConfig baseUrlConfig = sysConfigService.findByParamName(SysConfigService.BASE_API_URL);
|
|
|
+ String baseUrl="";
|
|
|
+ if(Objects.nonNull(baseUrlConfig)){
|
|
|
+ baseUrl=baseUrlConfig.getParanValue();
|
|
|
+ }
|
|
|
+ baseUrl = baseUrl+"/#/signUp?";
|
|
|
+
|
|
|
+ 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("合作单位冲突");
|
|
|
+ }
|
|
|
+ if(Objects.isNull(og.getIsAllowArrangeExam())){
|
|
|
+ throw new BizException("参数错误");
|
|
|
+ }
|
|
|
+ if(Objects.isNull(og.getSettlementType())){
|
|
|
+ throw new BizException("参数错误");
|
|
|
+ }
|
|
|
+ if(Objects.isNull(og.getShareProfitAmount())){
|
|
|
+ throw new BizException("参数错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ og.setTenantId(TenantContextHolder.getTenantId());
|
|
|
+ og.setExaminationBasicId(examinationBasic.getId().intValue());
|
|
|
+
|
|
|
+ og.setSendUrlFlag(0);
|
|
|
+ og.setTotalRegistrationStudentNum(BigDecimal.ZERO.intValue());
|
|
|
+ og.setTotalPaymentAmount(BigDecimal.ZERO);
|
|
|
+ og.setTotalTransAmount(BigDecimal.ZERO);
|
|
|
+ og.setSelfRegistrationStudentNum(BigDecimal.ZERO.intValue());
|
|
|
+ og.setSelfPaymentAmount(BigDecimal.ZERO);
|
|
|
+ String registrationUrl = baseUrl + "examId=" + examinationBasic.getId() + "&organId=" + og.getOrganId();
|
|
|
+ String registShortUrl = shortUrlService.createShortUrl(registrationUrl);
|
|
|
+ og.setUrl(registShortUrl);
|
|
|
+ organizationRelations.add(og);
|
|
|
+ }
|
|
|
+ examOrganizationRelationDao.batchInsert(organizationRelations);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
|
|
|
public void updateExamOrganizationRelation(ExamOrganizationRelation examOrganizationRelation) {
|
|
|
if(Objects.isNull(examOrganizationRelation.getId())){
|