package com.gkhy.exam.institutionalaccess.service.serviceImpl; import cn.hutool.core.util.IdUtil; import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.TypeReference; import com.gkhy.exam.institutionalaccess.entity.*; import com.gkhy.exam.institutionalaccess.enums.*; import com.gkhy.exam.institutionalaccess.model.req.*; import com.gkhy.exam.institutionalaccess.model.resp.ThErrorDataRespDTO; import com.gkhy.exam.institutionalaccess.model.vo.ThCourseChapterVO; import com.gkhy.exam.institutionalaccess.service.*; import com.ruoyi.common.constant.ResultConstants; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.model.InstitutionUser; import com.ruoyi.common.enums.coalmineEnums.DeleteStatusEnum; import com.ruoyi.common.exception.BusinessException; import com.ruoyi.common.signature.AESUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.bean.BeanUtils; import com.ruoyi.common.utils.uuid.UUID; import com.ruoyi.framework.security.context.ThreeInContextHolder; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @Service("TripartiteInterfaceService") public class TripartiteInterfaceServiceImpl implements TripartiteInterfaceService { @Autowired private ThQuestionBankService questionBankService; @Autowired private ThCourseService courseService; @Autowired private ThCourseChapterService courseChapterService; @Autowired private ThStudentService studentService; @Autowired private ThBatchService batchService; @Autowired private ThBatchCourseService batchCourseService; @Autowired private ThStudentCourseService studentCourseService; @Autowired private ThStudyAuthService studyAuthService; @Autowired private ThStudyTrackService studyTrackService; @Autowired private ThStudyDetailService studyDetailService; @Autowired private ThExamRecordService examRecordService; @Override public boolean receiveQuestionBank(JSONObject jsonObject) { InstitutionUser institutionUser = ThreeInContextHolder.getContext(); String data = jsonObject.getString("data"); if(StringUtils.isEmpty(data)){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL); } //解密 String decrypt = ""; try { decrypt = AESUtils.decrypt(data); }catch (Exception e){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL); } //反序列化 ThQuestionBankReqDTO questionBankReqDTO = JSONObject.parseObject(decrypt, new TypeReference() {}); //参数校验 validateQuestion(questionBankReqDTO); //根据uuid查询数据 ThQuestionBank qb = questionBankService.getQuestionInfoByUuid(questionBankReqDTO.getUuid()); boolean i = true; if(qb == null){ //新增 qb = new ThQuestionBank(); BeanUtils.copyProperties(questionBankReqDTO, qb); qb.setUuid(questionBankReqDTO.getUuid()); qb.setInstitutionId(institutionUser.getId()); qb.setInstitutionName(institutionUser.getInstitutionalName()); qb.setCreateTime(LocalDateTime.now()); qb.setUpdateTime(LocalDateTime.now()); qb.setCreateBy(institutionUser.getInstitutionalName()); qb.setUpdateBy(institutionUser.getInstitutionalName()); qb.setDelFlag(DeleteStatusEnum.NO.getStatus()); i = questionBankService.save(qb); }else { //修改 BeanUtils.copyProperties(questionBankReqDTO, qb); i = questionBankService.updateById(qb); } return i; } @Transactional @Override public AjaxResult receiveCourse(JSONObject jsonObject) { InstitutionUser institutionUser = ThreeInContextHolder.getContext(); String data = jsonObject.getString("data"); if(StringUtils.isEmpty(data)){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL); } //解密 String decrypt = ""; try { decrypt = AESUtils.decrypt(data); }catch (Exception e){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL); } //反序列化 ThCourseReqDTO courseReqDTO = JSONObject.parseObject(decrypt, new TypeReference() {}); //校验 validateCourse(courseReqDTO); //获取数据 ThCourse course= courseService.getByUuid(courseReqDTO.getUuid()); if(course == null){ //新增 //课程 course = new ThCourse(); BeanUtils.copyProperties(courseReqDTO, course); course.setId(IdUtil.getSnowflake(0,0).nextId()); course.setCreateTime(LocalDateTime.now()); course.setUpdateTime(LocalDateTime.now()); course.setCreateBy(institutionUser.getInstitutionalName()); course.setUpdateBy(institutionUser.getInstitutionalName()); course.setInstitutionId(institutionUser.getId()); course.setDelFlag(DeleteStatusEnum.NO.getStatus()); course.setInstitutionName(institutionUser.getInstitutionalName()); //章节(章) List chapterList = new ArrayList<>(); for (ThCourseChapterReqDTO chapterReqDTO : courseReqDTO.getChapters()) { ThCourseChapter chapter = new ThCourseChapter(); BeanUtils.copyProperties(chapterReqDTO, chapter); chapter.setCourseUuid(course.getUuid()); chapter.setId(IdUtil.getSnowflake(0,0).nextId()); chapter.setParentUuid("0"); chapter.setInstitutionId(institutionUser.getId()); chapter.setCreateTime(LocalDateTime.now()); chapter.setUpdateTime(LocalDateTime.now()); chapter.setDelFlag(DeleteStatusEnum.NO.getStatus()); chapter.setCreateBy(institutionUser.getInstitutionalName()); chapter.setUpdateBy(institutionUser.getInstitutionalName()); chapterList.add(chapter); //章节(节) for (ThCourseChapterReqDTO child : chapterReqDTO.getChildren()) { ThCourseChapter section = new ThCourseChapter(); BeanUtils.copyProperties(child, section); section.setCourseUuid(course.getUuid()); section.setId(IdUtil.getSnowflake(0,0).nextId()); section.setParentUuid(chapter.getUuid()); section.setInstitutionId(institutionUser.getId()); section.setCreateTime(LocalDateTime.now()); section.setUpdateTime(LocalDateTime.now()); section.setDelFlag(DeleteStatusEnum.NO.getStatus()); section.setCreateBy(institutionUser.getInstitutionalName()); section.setUpdateBy(institutionUser.getInstitutionalName()); chapterList.add(section); } } courseService.save(course); if(chapterList.size() > 0){ courseChapterService.saveBatch(chapterList); } }else { //获取所有章节 List courseChapterVOS = courseChapterService.listByCourseUuid(course.getUuid()); //修改 //章 List saveChapterList = new ArrayList<>(); List updateChapterList = new ArrayList<>(); //章 for (ThCourseChapterReqDTO chapterReqDTO : courseReqDTO.getChapters()) { List chapterSelectList = courseChapterVOS.stream().filter(cc -> cc.getUuid().equals(chapterReqDTO.getUuid())).collect(Collectors.toList()); if(chapterSelectList.size() > 0){ ThCourseChapterVO courseChapterVO = chapterSelectList.get(0); //修改 ThCourseChapter chapter = new ThCourseChapter(); BeanUtils.copyProperties(chapterReqDTO, chapter); chapter.setId(courseChapterVO.getId()); chapter.setUpdateBy(institutionUser.getInstitutionalName()); chapter.setUpdateTime(LocalDateTime.now()); updateChapterList.add(chapter); for (ThCourseChapterReqDTO child : chapterReqDTO.getChildren()) { List sectionSelectList = courseChapterVOS.stream().filter(cc -> cc.getUuid().equals(child.getUuid()) && cc.getParentUuid().equals(courseChapterVO.getUuid())).collect(Collectors.toList()); if(sectionSelectList.size() > 0){ //修改 ThCourseChapterVO sectionChapterVO = sectionSelectList.get(0); ThCourseChapter section = new ThCourseChapter(); BeanUtils.copyProperties(child, section); section.setId(sectionChapterVO.getId()); section.setUpdateBy(institutionUser.getInstitutionalName()); section.setUpdateTime(LocalDateTime.now()); updateChapterList.add(section); }else { //新增 ThCourseChapter sectionChapter= new ThCourseChapter(); BeanUtils.copyProperties(child, sectionChapter); sectionChapter.setId(IdUtil.getSnowflake(0,0).nextId()); sectionChapter.setCourseUuid(course.getUuid()); sectionChapter.setParentUuid(courseChapterVO.getUuid()); sectionChapter.setInstitutionId(institutionUser.getId()); sectionChapter.setDelFlag(DeleteStatusEnum.NO.getStatus()); sectionChapter.setUpdateBy(institutionUser.getInstitutionalName()); sectionChapter.setUpdateTime(LocalDateTime.now()); sectionChapter.setCreateBy(institutionUser.getInstitutionalName()); sectionChapter.setCreateTime(LocalDateTime.now()); saveChapterList.add(sectionChapter); } } }else { //新增 ThCourseChapter chapter = new ThCourseChapter(); BeanUtils.copyProperties(chapterReqDTO, chapter); chapter.setId(IdUtil.getSnowflake(0,0).nextId()); chapter.setParentUuid("0"); chapter.setCourseUuid(course.getUuid()); chapter.setInstitutionId(institutionUser.getId()); chapter.setDelFlag(DeleteStatusEnum.NO.getStatus()); chapter.setCreateTime(LocalDateTime.now()); chapter.setUpdateTime(LocalDateTime.now()); chapter.setCreateBy(institutionUser.getInstitutionalName()); chapter.setUpdateBy(institutionUser.getInstitutionalName()); saveChapterList.add(chapter); //章节(节) for (ThCourseChapterReqDTO child : chapterReqDTO.getChildren()) { ThCourseChapter section = new ThCourseChapter(); BeanUtils.copyProperties(child, section); section.setId(IdUtil.getSnowflake(0,0).nextId()); section.setParentUuid(chapter.getUuid()); section.setCourseUuid(course.getUuid()); section.setDelFlag(DeleteStatusEnum.NO.getStatus()); section.setInstitutionId(institutionUser.getId()); section.setCreateTime(LocalDateTime.now()); section.setUpdateTime(LocalDateTime.now()); section.setCreateBy(institutionUser.getInstitutionalName()); section.setUpdateBy(institutionUser.getInstitutionalName()); saveChapterList.add(section); } } } //课程 course.setCourseCode(courseReqDTO.getCourseCode()); course.setCourseName(courseReqDTO.getCourseName()); course.setLessonNum(courseReqDTO.getLessonNum()); course.setDelFlag(DeleteStatusEnum.NO.getStatus()); course.setUpdateBy(institutionUser.getInstitutionalName()); course.setUpdateTime(LocalDateTime.now()); courseService.updateById(course); //新增章节 if(saveChapterList.size() > 0){ courseChapterService.saveBatch(saveChapterList); } //修改章节 if(updateChapterList.size() > 0){ courseChapterService.updateBatchById(updateChapterList); } } return AjaxResult.success(); } @Transactional @Override public AjaxResult receiveStudent(JSONObject jsonObject) { InstitutionUser institutionUser = ThreeInContextHolder.getContext(); String data = jsonObject.getString("data"); if(StringUtils.isEmpty(data)){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL); } //解密 String decrypt = ""; try { decrypt = AESUtils.decrypt(data); }catch (Exception e){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL); } //反序列化 List studentReqDTOs = JSONObject.parseObject(decrypt, new TypeReference>() {}); //获取批次课程 List batchCourseList = batchCourseService.listByInstitutionId(institutionUser.getId()); //获取批次学生 List studentCourseList = studentCourseService.listByInstitutionId(institutionUser.getId()); //参数校验 if(CollectionUtils.isEmpty(studentReqDTOs)){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"学生信息不可为空"); } //错误 List errorDataRespDTOS = new ArrayList<>(); List studentReqDTOList = new ArrayList<>(); for (ThStudentReqDTO studentReqDTO : studentReqDTOs) { if(StringUtils.isEmpty(studentReqDTO.getIdcard())){ errorDataRespDTOS.add(new ThErrorDataRespDTO(studentReqDTO.getIdcard(),"身份证不可为空")); continue; } if(StringUtils.isEmpty(studentReqDTO.getName())){ errorDataRespDTOS.add(new ThErrorDataRespDTO(studentReqDTO.getIdcard(),"姓名不可为空")); continue; } if(StringUtils.isEmpty(studentReqDTO.getPhone())){ errorDataRespDTOS.add(new ThErrorDataRespDTO(studentReqDTO.getIdcard(),"手机号不可为空")); continue; } if(studentReqDTO.getSex() == null || StudentSex.get(studentReqDTO.getSex()) == null){ errorDataRespDTOS.add(new ThErrorDataRespDTO(studentReqDTO.getIdcard(),"性别不可为空")); continue; } if(StringUtils.isEmpty(studentReqDTO.getAuthPhoto())){ errorDataRespDTOS.add(new ThErrorDataRespDTO(studentReqDTO.getIdcard(),"实名认证照不可为空")); continue; } if (StringUtils.isEmpty(studentReqDTO.getTrainOrgName())){ errorDataRespDTOS.add(new ThErrorDataRespDTO(studentReqDTO.getIdcard(),"培训机构名称不可为空")); continue; } if(StringUtils.isEmpty(studentReqDTO.getBatchUuid())){ errorDataRespDTOS.add(new ThErrorDataRespDTO(studentReqDTO.getIdcard(),"关联批次(班级)不可为空")); continue; } List collect = batchCourseList.stream().filter(batchCourse -> batchCourse.getBatchUuid().equals(studentReqDTO.getBatchUuid())).collect(Collectors.toList()); if (CollectionUtils.isEmpty(collect)) { errorDataRespDTOS.add(new ThErrorDataRespDTO(studentReqDTO.getIdcard(), "批次(班级)不存在,请先添加批次(班级)")); continue; } List collect1 = studentCourseList.stream().filter(student -> student.getBatchUuid().equals(studentReqDTO.getBatchUuid()) && student.getIdcard().equals(studentReqDTO.getIdcard())).collect(Collectors.toList()); if (!CollectionUtils.isEmpty(collect1)) { errorDataRespDTOS.add(new ThErrorDataRespDTO(studentReqDTO.getIdcard(), "学生不可重复加入批次(班级)")); continue; } studentReqDTOList.add(studentReqDTO); } if(CollectionUtils.isEmpty(studentReqDTOList)){ return AjaxResult.success(errorDataRespDTOS); } //根据idcards查询 List idcards = studentReqDTOList.stream().map(ThStudentReqDTO::getIdcard).collect(Collectors.toList()); List students = studentService.getByIdcards(idcards); //List thStudentCourseList = studentCourseService.getByIdCards(idcards); List saveSudentList = new ArrayList<>(); List saveThStudentCourseList = new ArrayList<>(); List updateStudentList = new ArrayList<>(); for (ThStudentReqDTO studentReqDTO : studentReqDTOList) { List collect = students.stream().filter(s -> s.getIdcard().equals(studentReqDTO.getIdcard())).collect(Collectors.toList()); if(collect.size() > 0){ //修改 ThStudent student = collect.get(0); BeanUtils.copyProperties(studentReqDTO, student); student.setUpdateBy(institutionUser.getInstitutionalName()); student.setUpdateTime(LocalDateTime.now()); student.setInstitutionId(institutionUser.getId()); student.setInstitutionName(institutionUser.getInstitutionalName()); updateStudentList.add(student); List scSelectList = batchCourseList.stream().filter(batchCourse -> batchCourse.getBatchUuid().equals(studentReqDTO.getBatchUuid())).collect(Collectors.toList()); for (ThBatchCourse thStudentCourse : scSelectList) { //新增 ThStudentCourse sc = new ThStudentCourse(); BeanUtils.copyProperties(student, sc); sc.setId(IdUtil.getSnowflake(0,0).nextId()); sc.setCourseUuid(thStudentCourse.getCourseUuid()); sc.setBatchUuid(thStudentCourse.getBatchUuid()); sc.setFinishStatus(FinishStatus.NO.getStatus()); saveThStudentCourseList.add(sc); } }else { //新增 ThStudent student = new ThStudent(); BeanUtils.copyProperties(studentReqDTO, student); student.setId(IdUtil.getSnowflake(0,0).nextId()); student.setUpdateBy(institutionUser.getInstitutionalName()); student.setUpdateTime(LocalDateTime.now()); student.setCreateBy(institutionUser.getInstitutionalName()); student.setCreateTime(LocalDateTime.now()); student.setInstitutionId(institutionUser.getId()); student.setInstitutionName(institutionUser.getInstitutionalName()); student.setDelFlag(DeleteStatusEnum.NO.getStatus()); saveSudentList.add(student); List scSelectList = batchCourseList.stream().filter(batchCourse -> batchCourse.getBatchUuid().equals(studentReqDTO.getBatchUuid())).collect(Collectors.toList()); for (ThBatchCourse batchCourse : scSelectList) { ThStudentCourse thStudentCourse = new ThStudentCourse(); BeanUtils.copyProperties(student, thStudentCourse); thStudentCourse.setId(IdUtil.getSnowflake(0,0).nextId()); thStudentCourse.setCourseUuid(batchCourse.getCourseUuid()); thStudentCourse.setBatchUuid(batchCourse.getBatchUuid()); thStudentCourse.setFinishStatus(FinishStatus.NO.getStatus()); saveThStudentCourseList.add(thStudentCourse); } } } if(saveSudentList.size() > 0){ studentService.saveBatch(saveSudentList); } if(updateStudentList.size() > 0){ studentService.updateByIdcard(updateStudentList); } if(saveThStudentCourseList.size() > 0){ studentCourseService.saveBatch(saveThStudentCourseList); } return AjaxResult.success(errorDataRespDTOS); } /** * 班次 * @param jsonObject * @return */ @Transactional @Override public AjaxResult receiveBatch(JSONObject jsonObject) { InstitutionUser institutionUser = ThreeInContextHolder.getContext(); String data = jsonObject.getString("data"); if(StringUtils.isEmpty(data)){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL); } //解密 String decrypt = ""; try { decrypt = AESUtils.decrypt(data); }catch (Exception e){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL); } //反序列化 ThBatchReqDTO batchReqDTO = JSONObject.parseObject(decrypt, new TypeReference() {}); //参数校验 validateBatch(batchReqDTO); //获取数据 ThBatch batch = batchService.getByUuid(batchReqDTO.getUuid()); if(batch != null){ //修改 List oldCourseUuids = batchCourseService.getCourseUuisByBatchUuid(batch.getUuid()); BeanUtils.copyProperties(batchReqDTO, batch); batch.setUpdateBy(institutionUser.getInstitutionalName()); batch.setUpdateTime(LocalDateTime.now()); batch.setInstitutionId(institutionUser.getId()); batch.setInstitutionName(institutionUser.getInstitutionalName()); batchService.updateById(batch); //关联课程 //差集(old-new)| 删除 List deleteBatchCourseList = oldCourseUuids .stream() .filter(item -> !batchReqDTO.getCourseUuidList().contains(item)) .map(item -> { ThBatchCourse batchCourse = new ThBatchCourse(); batchCourse.setBatchUuid(batchReqDTO.getUuid()); batchCourse.setCourseUuid(item); batchCourse.setDelFlag(DeleteStatusEnum.YES.getStatus()); return batchCourse; }) .collect(Collectors.toList()); //差集(new-old) | 新增 List saveBatchCourseList = batchReqDTO.getCourseUuidList().stream() .filter(item -> !oldCourseUuids.contains(item)) .map(item -> { ThBatchCourse batchCourse = new ThBatchCourse(); batchCourse.setBatchUuid(batchReqDTO.getUuid()); batchCourse.setCourseUuid(item); batchCourse.setDelFlag(DeleteStatusEnum.NO.getStatus()); batchCourse.setInstitutionId(institutionUser.getId()); return batchCourse; }).collect(Collectors.toList()); if(saveBatchCourseList.size() > 0){ batchCourseService.saveBatch(saveBatchCourseList); } if (deleteBatchCourseList.size() > 0){ batchCourseService.deleteByBatchUuidAndCourseUuid(deleteBatchCourseList); } }else { //新增 //班次新增 batch = new ThBatch(); BeanUtils.copyProperties(batchReqDTO, batch); batch.setUpdateBy(institutionUser.getInstitutionalName()); batch.setUpdateTime(LocalDateTime.now()); batch.setDelFlag(DeleteStatusEnum.NO.getStatus()); batch.setCreateBy(institutionUser.getInstitutionalName()); batch.setCreateTime(LocalDateTime.now()); batch.setInstitutionId(institutionUser.getId()); batch.setInstitutionName(institutionUser.getInstitutionalName()); //batch.setFinishStatus(FinishStatus.NO.getStatus()); batchService.save(batch); //关联课程 List batchCourseList = new ArrayList<>(); for (String uuid : batchReqDTO.getCourseUuidList()) { ThBatchCourse batchCourse = new ThBatchCourse(); batchCourse.setBatchUuid(batch.getUuid()); batchCourse.setCourseUuid(uuid); batchCourse.setDelFlag(DeleteStatusEnum.NO.getStatus()); batchCourse.setInstitutionId(institutionUser.getId()); batchCourseList.add(batchCourse); } if(batchCourseList.size() > 0){ batchCourseService.saveBatch(batchCourseList); } } return AjaxResult.success(); } @Transactional @Override public AjaxResult receiveStudyDetail(JSONObject jsonObject) { InstitutionUser institutionUser = ThreeInContextHolder.getContext(); String data = jsonObject.getString("data"); if(StringUtils.isEmpty(data)){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL); } //解密 String decrypt = ""; try { decrypt = AESUtils.decrypt(data); }catch (Exception e){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL); } //反序列化 ThStudyDetailReqDTO studyDetailReqDTO = JSONObject.parseObject(decrypt, new TypeReference() {}); //参数校验 validateStudyDetail(studyDetailReqDTO); ThStudyDetail thStudyDetail = studyDetailService.getByUuid(studyDetailReqDTO.getUuid()); if(thStudyDetail == null){ //新增学习清单 thStudyDetail = new ThStudyDetail(); BeanUtils.copyProperties(studyDetailReqDTO, thStudyDetail); thStudyDetail.setUpdateBy(institutionUser.getInstitutionalName()); thStudyDetail.setUpdateTime(LocalDateTime.now()); thStudyDetail.setCreateBy(institutionUser.getInstitutionalName()); thStudyDetail.setCreateTime(LocalDateTime.now()); thStudyDetail.setInstitutionId(institutionUser.getId()); thStudyDetail.setInstitutionName(institutionUser.getInstitutionalName()); thStudyDetail.setDelFlag(DeleteStatusEnum.NO.getStatus()); thStudyDetail.setSerialNum(generateSerialNum()); //新增认证记录 List thStudyAuthList = studyDetailReqDTO.getAuthList().stream().map(sa -> { ThStudyAuth thStudyAuth = new ThStudyAuth(); BeanUtils.copyProperties(sa, thStudyAuth); thStudyAuth.setStudyDetailUuid(studyDetailReqDTO.getUuid()); return thStudyAuth; }).collect(Collectors.toList()); //新增学习轨迹 List thStudyTrackList = studyDetailReqDTO.getTrackList().stream().map(track -> { ThStudyTrack thStudyTrack = new ThStudyTrack(); BeanUtils.copyProperties(track, thStudyTrack); thStudyTrack.setStudyDetailUuid(studyDetailReqDTO.getUuid()); return thStudyTrack; }).collect(Collectors.toList()); studyDetailService.save(thStudyDetail); if(thStudyAuthList.size() > 0){ studyAuthService.saveBatch(thStudyAuthList); } if(thStudyTrackList.size() > 0){ studyTrackService.saveBatch(thStudyTrackList); } }else { //获取轨迹数据 //获取认证数据 List oldAuthIdList = studyAuthService.getUuidByStudyDetaiId(thStudyDetail.getUuid()); List oldTrackIdList = studyTrackService.getUuidByStudyDetaiId(thStudyDetail.getUuid()); //修改 BeanUtils.copyProperties(studyDetailReqDTO, thStudyDetail); thStudyDetail.setUpdateBy(institutionUser.getInstitutionalName()); thStudyDetail.setUpdateTime(LocalDateTime.now()); List saveAuthList = studyDetailReqDTO.getAuthList().stream() .filter(a -> oldAuthIdList.contains(a.getUuid())) .map(a -> { ThStudyAuth thStudyAuth = new ThStudyAuth(); BeanUtils.copyProperties(a, thStudyAuth); thStudyAuth.setStudyDetailUuid(studyDetailReqDTO.getUuid()); return thStudyAuth; }) .collect(Collectors.toList()); List saveTrackList = studyDetailReqDTO.getTrackList().stream() .filter(t -> oldTrackIdList.contains(t.getUuid())) .map(t -> { ThStudyTrack thStudyTrack = new ThStudyTrack(); BeanUtils.copyProperties(t, thStudyTrack); thStudyTrack.setStudyDetailUuid(studyDetailReqDTO.getUuid()); return thStudyTrack; }).collect(Collectors.toList()); studyDetailService.updateById(thStudyDetail); studyAuthService.saveBatch(saveAuthList); studyTrackService.saveBatch(saveTrackList); } return AjaxResult.success(); } @Transactional @Override public AjaxResult receiveExamRecord(JSONObject jsonObject) { InstitutionUser institutionUser = ThreeInContextHolder.getContext(); String data = jsonObject.getString("data"); if(StringUtils.isEmpty(data)){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL); } //解密 String decrypt = ""; try { decrypt = AESUtils.decrypt(data); }catch (Exception e){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL); } //反序列化 List examRecordReqDTOS = JSONObject.parseObject(decrypt, new TypeReference>() {}); //参数校验 //获取该平台课程 List studentCourseList = studentCourseService.listByInstitutionId(institutionUser.getId()); List oldExamRecordList = examRecordService.listByInstitutionId(institutionUser.getId()); List errorDataRespDTOS = new ArrayList<>(); List saveExamRecordList = new ArrayList<>(); List updateExamRecordList = new ArrayList<>(); if (CollectionUtils.isEmpty(examRecordReqDTOS)) { throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"考试记录不可为空"); } for (ThExamRecordReqDTO examRecordReqDTO : examRecordReqDTOS) { if(StringUtils.isEmpty(examRecordReqDTO.getUuid()) || !UUID.checkIsUuid(examRecordReqDTO.getUuid())){ errorDataRespDTOS.add(new ThErrorDataRespDTO(examRecordReqDTO.getUuid(),"考试记录uuid不符合规范")); continue; } if(StringUtils.isEmpty(examRecordReqDTO.getIdcard())){ errorDataRespDTOS.add(new ThErrorDataRespDTO(examRecordReqDTO.getUuid(),"身份证不可为空")); continue; } if(StringUtils.isEmpty(examRecordReqDTO.getCourseUuid())){ errorDataRespDTOS.add(new ThErrorDataRespDTO(examRecordReqDTO.getUuid(),"课程不可为空")); continue; } if(StringUtils.isEmpty(examRecordReqDTO.getBatchUuid())){ errorDataRespDTOS.add(new ThErrorDataRespDTO(examRecordReqDTO.getUuid(),"批次不可为空")); continue; } List thStudentCourses = studentCourseList.stream().filter(sc -> sc.getCourseUuid().equals(examRecordReqDTO.getCourseUuid()) && sc.getBatchUuid().equals(examRecordReqDTO.getBatchUuid()) && sc.getIdcard().equals(examRecordReqDTO.getIdcard())).collect(Collectors.toList()); if(thStudentCourses.size() == 0){ errorDataRespDTOS.add(new ThErrorDataRespDTO(examRecordReqDTO.getUuid(),"无该学生培训信息")); continue; } if(StringUtils.isEmpty(examRecordReqDTO.getTrainOrgName())){ errorDataRespDTOS.add(new ThErrorDataRespDTO(examRecordReqDTO.getUuid(),"培训机构名称不可为空")); continue; } if(StringUtils.isEmpty(examRecordReqDTO.getExamName())){ errorDataRespDTOS.add(new ThErrorDataRespDTO(examRecordReqDTO.getUuid(),"考试名称不可为空")); continue; } if(examRecordReqDTO.getExamStartTime() == null){ errorDataRespDTOS.add(new ThErrorDataRespDTO(examRecordReqDTO.getUuid(),"开考时间不可为空")); continue; } if(examRecordReqDTO.getExamSubmitTime() == null){ errorDataRespDTOS.add(new ThErrorDataRespDTO(examRecordReqDTO.getUuid(),"结束时间不可为空")); continue; } if(examRecordReqDTO.getExamUserScore() == null){ errorDataRespDTOS.add(new ThErrorDataRespDTO(examRecordReqDTO.getUuid(),"学习成绩不可为空")); continue; } if(examRecordReqDTO.getExamTotalScore() == null){ errorDataRespDTOS.add(new ThErrorDataRespDTO(examRecordReqDTO.getUuid(),"试卷总分不可为空")); continue; } if(examRecordReqDTO.getExamPassScore() == null){ errorDataRespDTOS.add(new ThErrorDataRespDTO(examRecordReqDTO.getUuid(),"合格分数不可为空")); continue; } if(examRecordReqDTO.getExamIsPass() == null || ExamIsPass.get(examRecordReqDTO.getExamIsPass()) == null){ errorDataRespDTOS.add(new ThErrorDataRespDTO(examRecordReqDTO.getUuid(),"是否通过考试状态不规范")); continue; } if(examRecordReqDTO.getExamNum() == null){ errorDataRespDTOS.add(new ThErrorDataRespDTO(examRecordReqDTO.getUuid(),"考试次数不可为空")); continue; } List examRecordSelectList = oldExamRecordList.stream().filter(e -> e.getUuid().equals(examRecordReqDTO.getUuid())).collect(Collectors.toList()); if(examRecordSelectList.size() > 0){ ThExamRecord thExamRecord = examRecordSelectList.get(0); BeanUtils.copyProperties(examRecordReqDTO,thExamRecord); thExamRecord.setUpdateTime(LocalDateTime.now()); thExamRecord.setUpdateBy(institutionUser.getInstitutionalName()); updateExamRecordList.add(thExamRecord); }else { //新增 ThExamRecord thExamRecord = new ThExamRecord(); BeanUtils.copyProperties(examRecordReqDTO,thExamRecord); thExamRecord.setInstitutionId(institutionUser.getId()); thExamRecord.setInstitutionName(institutionUser.getInstitutionalName()); thExamRecord.setCreateTime(LocalDateTime.now()); thExamRecord.setUpdateTime(LocalDateTime.now()); thExamRecord.setCreateBy(institutionUser.getInstitutionalName()); thExamRecord.setUpdateBy(institutionUser.getInstitutionalName()); thExamRecord.setDelFlag(DeleteStatusEnum.NO.getStatus()); saveExamRecordList.add(thExamRecord); } } if(saveExamRecordList.size() > 0){ examRecordService.saveBatch(saveExamRecordList); } if(updateExamRecordList.size() > 0){ examRecordService.updateBatchById(updateExamRecordList); } return AjaxResult.success(errorDataRespDTOS); } @Transactional @Override public AjaxResult receiveCourseDelete(JSONObject jsonObject) { InstitutionUser institutionUser = ThreeInContextHolder.getContext(); String data = jsonObject.getString("data"); if(StringUtils.isEmpty(data)){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL); } //解密 String decrypt = ""; try { decrypt = AESUtils.decrypt(data); }catch (Exception e){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL); } //反序列化 ThCourseDeleteReqDTO thCourseDeleteReqDTO = JSONObject.parseObject(decrypt, new TypeReference() {}); if(StringUtils.isEmpty(thCourseDeleteReqDTO.getCourseUuid())){ throw new BusinessException(ResultConstants.THREE_INSTITUTION_PARAMM_NULL); } ThCourse thCourse = courseService.getByUuid(thCourseDeleteReqDTO.getCourseUuid()); List thCourseChapterVOS = courseChapterService.listByCourseUuid(thCourseDeleteReqDTO.getCourseUuid()); if(thCourse == null){ throw new BusinessException(ResultConstants.COURSE_IS_NOT_EXIST); } boolean exsit = batchCourseService.isExsit(thCourseDeleteReqDTO.getCourseUuid()); if(exsit){ throw new BusinessException(ResultConstants.BATCH_COURSE_EXIST); } thCourse.setDelFlag(DeleteStatusEnum.YES.getStatus()); thCourse.setUpdateTime(LocalDateTime.now()); thCourse.setUpdateBy(institutionUser.getInstitutionalName()); List thCourseChapters = thCourseChapterVOS.stream().map(cc -> { ThCourseChapter thCourseChapter = new ThCourseChapter(); BeanUtils.copyProperties(cc, thCourseChapter); thCourseChapter.setUpdateTime(LocalDateTime.now()); thCourseChapter.setUpdateBy(institutionUser.getInstitutionalName()); thCourseChapter.setDelFlag(DeleteStatusEnum.YES.getStatus()); return thCourseChapter; }).collect(Collectors.toList()); //删除章节 if(thCourseChapters.size() > 0){ courseChapterService.updateBatchById(thCourseChapters); } return AjaxResult.success(); } @Override public AjaxResult receiveBatchOpen(JSONObject jsonObject) { InstitutionUser institutionUser = ThreeInContextHolder.getContext(); String data = jsonObject.getString("data"); if(StringUtils.isEmpty(data)){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL); } //解密 String decrypt = ""; try { decrypt = AESUtils.decrypt(data); }catch (Exception e){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL); } //反序列化 ThBatchOpenReqDTO thBatchOpenReqDTO = JSONObject.parseObject(decrypt, new TypeReference() {}); if(StringUtils.isEmpty(thBatchOpenReqDTO.getBatchUuid())){ throw new BusinessException(this.getClass(),ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"批次(班级)不可为空"); } ThBatch thBatch = batchService.getByUuid(thBatchOpenReqDTO.getBatchUuid()); if(thBatch == null){ throw new BusinessException(ResultConstants.BATCH_IS_NOT_EXIST); } thBatch.setOpenStatus(OpenStatus.YES.getStatus()); thBatch.setUpdateTime(LocalDateTime.now()); thBatch.setUpdateBy(institutionUser.getInstitutionalName()); batchService.updateById(thBatch); return AjaxResult.success(); } @Transactional @Override public AjaxResult receiveBarchEnd(JSONObject jsonObject) { InstitutionUser institutionUser = ThreeInContextHolder.getContext(); String data = jsonObject.getString("data"); if(StringUtils.isEmpty(data)){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL); } //解密 String decrypt = ""; try { decrypt = AESUtils.decrypt(data); }catch (Exception e){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL); } //反序列化 ThBatchEndReqDTO thBatchEndReqDTO = JSONObject.parseObject(decrypt, new TypeReference() {}); if(StringUtils.isEmpty(thBatchEndReqDTO.getBatchUuid())){ throw new BusinessException(this.getClass(),ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"批次(班级)不可为空"); } if(StringUtils.isEmpty(thBatchEndReqDTO.getIdcard())){ throw new BusinessException(this.getClass(),ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"学生身份证不可为空"); } List thStudentCourses = studentCourseService.getByIdcardAndBatchUuid(thBatchEndReqDTO.getIdcard(), thBatchEndReqDTO.getBatchUuid()); if(CollectionUtils.isEmpty(thStudentCourses)){ throw new BusinessException(ResultConstants.BATCH_STUDENT_IS_NOT_EXIST); } thStudentCourses.stream().forEach(sc -> { sc.setFinishStatus(FinishStatus.YES.getStatus()); }); studentCourseService.updateBatchById(thStudentCourses); return AjaxResult.success(); } private void validateStudyDetail(ThStudyDetailReqDTO studentDetailReqDTO) { //获取该平台课程 ThCourse course = courseService.getByUuid(studentDetailReqDTO.getCourseUuid()); ThBatch batch = batchService.getByUuid(studentDetailReqDTO.getBatchUuid()); ThCourseChapter chapter = courseChapterService.getByUuid(studentDetailReqDTO.getChapterUuid()); if (studentDetailReqDTO == null) { throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"学习记录清单不可为空"); } if(StringUtils.isEmpty(studentDetailReqDTO.getUuid()) || !UUID.checkIsUuid(studentDetailReqDTO.getUuid())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"学习记录uuid不符合规范"); } if(StringUtils.isEmpty(studentDetailReqDTO.getIdcard())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"身份证不可为空"); } if(StringUtils.isEmpty(studentDetailReqDTO.getCourseUuid())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"课程不可为空"); } if(course == null){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"课程不存在"); } if(StringUtils.isEmpty(studentDetailReqDTO.getBatchUuid())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"批次不可为空"); } if(batch == null){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"批次不存在"); } if(StringUtils.isEmpty(studentDetailReqDTO.getChapterUuid())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"章节不可为空"); } if(chapter == null){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"章节不存在"); } if(StringUtils.isEmpty(studentDetailReqDTO.getTrainOrgName())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"培训机构名称不可为空"); } if(studentDetailReqDTO.getFinishStatus() == null || FinishStatus.get(studentDetailReqDTO.getFinishStatus()) == null){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"完成状态不规范"); } if(studentDetailReqDTO.getDuration() == null){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"学习时长(秒)不可为空"); } if(studentDetailReqDTO.getStartTime() == null){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"开始时间不可为空"); } if(studentDetailReqDTO.getFinishTime() == null){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"结束时间不可为空"); } if(studentDetailReqDTO.getStartPosition() == null){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"开始位置不可为空"); } if(studentDetailReqDTO.getFinishPosition() == null){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"结束位置不可为空"); } if(StringUtils.isEmpty(studentDetailReqDTO.getLessonReportUrl())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"学时报告不可为空"); } //认证记录集合 if(CollectionUtils.isEmpty(studentDetailReqDTO.getAuthList())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"认证记录集合不可为空"); } studentDetailReqDTO.getAuthList().forEach(item -> { if(StringUtils.isEmpty(item.getUuid()) || !UUID.checkIsUuid(item.getUuid())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,item.getUuid() + ",认证记录uuid不符合规范"); } if(StringUtils.isEmpty(item.getApprovePhoto())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,item.getUuid() + ",认证照片不可为空"); } if(item.getAuthPosition() == null){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,item.getUuid() + ",认证位置不可为空"); } if(item.getAuthTime() == null){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,item.getUuid() + ",认证时间不可为空"); } if(item.getFaceType() == null || FaceType.get(item.getFaceType()) == null){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,item.getUuid() + ",认证类型不规范"); } }); //学习轨迹集合 if(CollectionUtils.isEmpty(studentDetailReqDTO.getTrackList())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"学习轨迹集合不可为空"); } studentDetailReqDTO.getTrackList().forEach(item -> { if(StringUtils.isEmpty(item.getUuid()) || !UUID.checkIsUuid(item.getUuid())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,item.getUuid() + ",认证记录uuid不符合规范"); } if(item.getStartTime() == null){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,item.getUuid() + ",轨迹开始时间不可为空"); } if(item.getEndTime() == null){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,item.getUuid() + ",轨迹结束时间不可为空"); } if(item.getTimeInterval() == null) { throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,item.getUuid() + ",时间间隔(秒)不可为空"); } }); } /** * 校验班次信息 * @param batchReqDTO */ private void validateBatch(ThBatchReqDTO batchReqDTO) { if(StringUtils.isEmpty(batchReqDTO.getUuid()) || !UUID.checkIsUuid(batchReqDTO.getUuid())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"uuid不符合规范"); } if(StringUtils.isEmpty(batchReqDTO.getBatchName())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"班次名称不可为空"); } if(StringUtils.isEmpty(batchReqDTO.getTrainOrgName())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"培训机构名称不可为空"); } if(batchReqDTO.getHaveExam() == null || HaveExam.get(batchReqDTO.getHaveExam()) == null){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"有无考试不规范"); } if(batchReqDTO.getOpenStatus() == null || OpenStatus.get(batchReqDTO.getOpenStatus()) == null ){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"开班标识不符合规范"); } // if(batchReqDTO.getDelFlag() == null || DeleteStatusEnum.getDeleteStatusEnum(batchReqDTO.getDelFlag()) == null ){ // throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"删除标识不符合规范"); // } if(CollectionUtils.isEmpty(batchReqDTO.getCourseUuidList())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"关联课程不可为空"); } List courseList = courseService.selectByUuid(batchReqDTO.getCourseUuidList()); if(courseList.size() != batchReqDTO.getCourseUuidList().size()){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"关联课程不存在,请先上报课程"); } } /** * 校验学生信息 * @param studentReqDTOS */ private void validateStudent(List studentReqDTOS, Long institutionId) { if(CollectionUtils.isEmpty(studentReqDTOS)){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"学生信息不可为空"); } //获取所有该机构所有课程 List courseList = courseService.listByInstitutionId(institutionId); for (ThStudentReqDTO studentReqDTO : studentReqDTOS) { if(StringUtils.isEmpty(studentReqDTO.getIdcard())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"身份证不可为空"); } if(StringUtils.isEmpty(studentReqDTO.getName())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"姓名不可为空"); } if(StringUtils.isEmpty(studentReqDTO.getPhone())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"手机号不可为空"); } if(studentReqDTO.getSex() == null || StudentSex.get(studentReqDTO.getSex()) == null){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"性别不可为空"); } if(StringUtils.isEmpty(studentReqDTO.getAuthPhoto())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"实名认证照不可为空"); } if (StringUtils.isEmpty(studentReqDTO.getTrainOrgName())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"培训机构名称不可为空"); } /*if(CollectionUtils.isEmpty(studentReqDTO.getBatchUuids())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"关联课程uuidd不可为空"); }*/ /*for (String batchaUuid : studentReqDTO.getBatchUuids()) { List collect = courseList.stream().filter(course -> course.getUuid().equals(courseReqDTO.getCourseUuid())).collect(Collectors.toList()); if(CollectionUtils.isEmpty(collect)){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"课程uuid不存在,请先添加课程"); } }*/ } } /** * 校验课程 * @param courseReqDTO */ private void validateCourse(ThCourseReqDTO courseReqDTO) { if(courseReqDTO == null){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_ERROR); } if(StringUtils.isEmpty(courseReqDTO.getUuid()) || !UUID.checkIsUuid(courseReqDTO.getUuid())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"uuid不符合规范"); } if(StringUtils.isEmpty(courseReqDTO.getCourseCode())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"课程标识不可为空"); } if(StringUtils.isEmpty(courseReqDTO.getCourseName())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"课程名称不可为空"); } if(StringUtils.isEmpty(courseReqDTO.getTrainOrgName())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"培训机构名称不可为空"); } if(courseReqDTO.getLessonNum() == null){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"总课时不可为空"); } /* if(courseReqDTO.getDelFlag() == null || DeleteStatusEnum.getDeleteStatusEnum(courseReqDTO.getDelFlag()) == null ){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"删除标识不符合规范"); }*/ if(CollectionUtils.isEmpty(courseReqDTO.getChapters())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"课程大纲(大章)不可为空"); } for (ThCourseChapterReqDTO chapter : courseReqDTO.getChapters()) { if(StringUtils.isEmpty(chapter.getChapterCode())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"章节(大章)标识不可为空"); } if(StringUtils.isEmpty(chapter.getChapterName())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"章节(大章)名称不可为空"); } /*if(chapter.getDelFlag() == null || DeleteStatusEnum.getDeleteStatusEnum(chapter.getDelFlag()) == null ){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"章节(大章)删除标识不符合规范"); } if (chapter.getLessonNum() == null){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"章节(大章)课时(保留1位小数)不可为空"); }*/ if(chapter.getHaveResource() == null || CourseHaveResourse.get(chapter.getHaveResource()) == null){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"是否有资源不符合规范"); } if(CollectionUtils.isEmpty(chapter.getChildren())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"章节(小节)列表不可为空"); } for (ThCourseChapterReqDTO child : chapter.getChildren()) { if(StringUtils.isEmpty(child.getChapterCode())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"章节(小节)标识不可为空"); } if(StringUtils.isEmpty(child.getChapterName())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"章节(小节)名称不可为空"); } if(child.getDuration() == null){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"章节(小节)视频时长(秒)不可为空"); } if (child.getLessonNum() == null){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"章节(小节)课时(保留1位小数)不可为空"); } if(child.getResourceType() == null || CourseResourceType.get(child.getResourceType()) == null){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"资源类型不规范"); } /*if(child.getDelFlag() == null || DeleteStatusEnum.getDeleteStatusEnum(child.getDelFlag()) == null ){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"章节(小节)删除标识不符合规范"); }*/ if(child.getHaveResource() == null || CourseHaveResourse.get(child.getHaveResource()) == null){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"是否有资源不符合规范"); } } } } /** * 校验题库组卷数据 * @param questionBankReqDTO */ private void validateQuestion(ThQuestionBankReqDTO questionBankReqDTO){ if(questionBankReqDTO == null){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_ERROR); } if(StringUtils.isEmpty(questionBankReqDTO.getUuid()) || !UUID.checkIsUuid(questionBankReqDTO.getUuid())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"题库组卷uuid不符合规范"); } if(StringUtils.isEmpty(questionBankReqDTO.getUrl())){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"题库组卷预览路径不可为空"); } if(questionBankReqDTO.getLastMonthCount() == null){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"上月题库总题目数不可为空"); } if(questionBankReqDTO.getAddCount() == null){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"新增题目数不可为空"); } if(questionBankReqDTO.getReduceCount() == null){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"减少题目数不可为空"); } if(questionBankReqDTO.getBrushRate() == null){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"刷题应用率不可为空"); } if(questionBankReqDTO.getAssemblyRate() == null){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"组卷应用率不可为空"); } if(questionBankReqDTO.getMonth() == null){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"年月不可为空"); } /* if(questionBankReqDTO.getDelFlag() == null || DeleteStatusEnum.getDeleteStatusEnum(questionBankReqDTO.getDelFlag()) == null ){ throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"删除标识不符合规范"); }*/ } private String generateSerialNum() { Long count = studyDetailService.getCount(); String strCount = count.toString(); while (strCount.length() < 5){ strCount = "0" + strCount; } return strCount; } }