|
@@ -1398,53 +1398,78 @@ public class ExtractConfigServiceImpl implements ExtractConfigService {
|
|
|
|
|
|
@Transactional
|
|
@Transactional
|
|
@Override
|
|
@Override
|
|
- public String saveExtractConfigForRandomPaperByOuter(SaveRandomPaperExtractConfigReq req) {
|
|
|
|
- if(req.getRootOrgId()==null) {
|
|
|
|
|
|
+ public void saveExtractConfigForRandomPaperByOuter(SaveRandomPaperExtractConfigReq param) {
|
|
|
|
+ if(param.getRootOrgId()==null) {
|
|
throw new StatusException("rootOrgId不能为空");
|
|
throw new StatusException("rootOrgId不能为空");
|
|
}
|
|
}
|
|
GetExamReq examReq=new GetExamReq();
|
|
GetExamReq examReq=new GetExamReq();
|
|
- examReq.setRootOrgId(req.getRootOrgId());
|
|
|
|
- examReq.setName(req.getExamName());
|
|
|
|
- examReq.setCode(req.getExamCode());
|
|
|
|
|
|
+ examReq.setRootOrgId(param.getRootOrgId());
|
|
|
|
+ examReq.setName(param.getExamName());
|
|
|
|
+ examReq.setCode(param.getExamCode());
|
|
GetExamResp examRes=examCloudService.getExam(examReq);
|
|
GetExamResp examRes=examCloudService.getExam(examReq);
|
|
if(!CallType.RANDOM_PAPER.equals(examRes.getExamBean().getCallType())) {
|
|
if(!CallType.RANDOM_PAPER.equals(examRes.getExamBean().getCallType())) {
|
|
throw new StatusException("只能对随机抽题的考试创建调卷规则");
|
|
throw new StatusException("只能对随机抽题的考试创建调卷规则");
|
|
}
|
|
}
|
|
- Course course = courseService.getCourse(req.getRootOrgId(), req.getCourseCode());
|
|
|
|
- GetExamCourseReq settingReq = new GetExamCourseReq();
|
|
|
|
- settingReq.setExamId(examRes.getExamBean().getId());
|
|
|
|
- settingReq.setCourseId(Long.valueOf(course.getId()));
|
|
|
|
- GetExamCourseResp settingResp = examCloudService.getExamCourseSetting(settingReq);
|
|
|
|
- if(settingResp.getBean()==null) {
|
|
|
|
- throw new StatusException("请先同步考生后再创建相应课程的调卷规则");
|
|
|
|
|
|
+ // 从考务查询改考试下的所有课程
|
|
|
|
+ List<ExamCourseRelationBean> courseInfoList = new ArrayList<>();
|
|
|
|
+ GetExamCourseListReq req = new GetExamCourseListReq();
|
|
|
|
+ req.setExamId(examRes.getExamBean().getId());
|
|
|
|
+ Long start = 1l;
|
|
|
|
+ for(;;) {
|
|
|
|
+ req.setStart(start);
|
|
|
|
+ GetExamCourseListResp resp = examCloudService.getExamCourseList(req);
|
|
|
|
+ courseInfoList.addAll(resp.getRelationList());
|
|
|
|
+ if (start.equals(resp.getNext())) {
|
|
|
|
+ break;
|
|
|
|
+ } else {
|
|
|
|
+ start = resp.getNext();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (CollectionUtils.isEmpty(courseInfoList)) {
|
|
|
|
+ throw new StatusException("请先同步考生再创建调卷规则");
|
|
|
|
+ }
|
|
|
|
+ for(ExamCourseRelationBean course:courseInfoList) {
|
|
|
|
+ createByCourse(req.getRootOrgId(), examRes.getExamBean(), course);
|
|
}
|
|
}
|
|
- List<RandomPaperListVo> rps=randomPaperService.getList(req.getRootOrgId(), Long.valueOf(course.getId()));
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void createByCourse(Long rootOrgId,ExamBean examBean,ExamCourseRelationBean course) {
|
|
|
|
+ List<RandomPaperListVo> rps=randomPaperService.getList(rootOrgId,course.getCourseId());
|
|
if(CollectionUtils.isEmpty(rps)) {
|
|
if(CollectionUtils.isEmpty(rps)) {
|
|
throw new StatusException("没有启用的随机抽题模板");
|
|
throw new StatusException("没有启用的随机抽题模板");
|
|
}
|
|
}
|
|
if(rps.size()>1) {
|
|
if(rps.size()>1) {
|
|
throw new StatusException("存在多个启用的随机抽题模板");
|
|
throw new StatusException("存在多个启用的随机抽题模板");
|
|
}
|
|
}
|
|
- ExtractConfig extractConfig=findConfig(examRes.getExamBean().getId(), req.getCourseCode());
|
|
|
|
|
|
+ ExtractConfig extractConfig=findConfig(examBean.getId(), course.getCourseCode());
|
|
if(extractConfig!=null) {
|
|
if(extractConfig!=null) {
|
|
extractConfig.setRandomPaperId(rps.get(0).getId());
|
|
extractConfig.setRandomPaperId(rps.get(0).getId());
|
|
}else {
|
|
}else {
|
|
extractConfig=new ExtractConfig();
|
|
extractConfig=new ExtractConfig();
|
|
- extractConfig.setExamId(examRes.getExamBean().getId());
|
|
|
|
|
|
+ extractConfig.setExamId(examBean.getId());
|
|
extractConfig.setCallType(CallType.RANDOM_PAPER);
|
|
extractConfig.setCallType(CallType.RANDOM_PAPER);
|
|
- extractConfig.setOrgId(req.getRootOrgId().toString());
|
|
|
|
- extractConfig.setExamName(examRes.getExamBean().getName());
|
|
|
|
- extractConfig.setExamType(examRes.getExamBean().getExamType());
|
|
|
|
- extractConfig.setCourseCode(course.getCode());
|
|
|
|
- extractConfig.setCourse(course);
|
|
|
|
- extractConfig.setCourseName(course.getName());
|
|
|
|
|
|
+ extractConfig.setOrgId(rootOrgId.toString());
|
|
|
|
+ extractConfig.setExamName(examBean.getName());
|
|
|
|
+ extractConfig.setExamType(examBean.getExamType());
|
|
|
|
+ extractConfig.setCourseCode(course.getCourseCode());
|
|
|
|
+ extractConfig.setCourse(of(course,rootOrgId));
|
|
|
|
+ extractConfig.setCourseName(course.getCourseName());
|
|
extractConfig.setRandomPaperId(rps.get(0).getId());
|
|
extractConfig.setRandomPaperId(rps.get(0).getId());
|
|
extractConfig.setPlayTime(1);
|
|
extractConfig.setPlayTime(1);
|
|
}
|
|
}
|
|
extractConfigRepo.save(extractConfig);
|
|
extractConfigRepo.save(extractConfig);
|
|
// 清除缓存
|
|
// 清除缓存
|
|
extractConfigCache.remove(extractConfig.getExamId(), extractConfig.getCourseCode());
|
|
extractConfigCache.remove(extractConfig.getExamId(), extractConfig.getCourseCode());
|
|
- return extractConfig.getId();
|
|
|
|
|
|
+ }
|
|
|
|
+ private Course of(ExamCourseRelationBean course,Long rootOrgId) {
|
|
|
|
+ Course c=new Course();
|
|
|
|
+ c.setCode(course.getCourseCode());
|
|
|
|
+ c.setId(course.getCourseId().toString());
|
|
|
|
+ c.setEnable(course.getCourseEnable()==null?"false":course.getCourseEnable().toString());
|
|
|
|
+ c.setName(course.getCourseName());
|
|
|
|
+ c.setLevel(course.getCourseLevel());
|
|
|
|
+ c.setOrgId(rootOrgId.toString());
|
|
|
|
+ return c;
|
|
}
|
|
}
|
|
private ExtractConfig findConfig(Long examId,String courseCode) {
|
|
private ExtractConfig findConfig(Long examId,String courseCode) {
|
|
if (examId == null) {
|
|
if (examId == null) {
|