package com.gkhy.exam.institutionalaccess.service.serviceImpl;
|
|
|
import cn.hutool.core.collection.ListUtil;
|
import cn.hutool.core.util.IdUtil;
|
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.TypeReference;
|
import com.gkhy.exam.institutionalaccess.config.ExecutorConfig;
|
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.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
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 {
|
private Logger logger = LoggerFactory.getLogger(TripartiteInterfaceServiceImpl.class);
|
|
@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 ThStudentBatchService studentBatchService;
|
@Autowired
|
private ThStudyAuthService studyAuthService;
|
@Autowired
|
private ThStudyTrackService studyTrackService;
|
@Autowired
|
private ThStudyDetailService studyDetailService;
|
@Autowired
|
private ThExamRecordService examRecordService;
|
|
@Autowired
|
private ThBatchCourseChapterService batchCourseChapterService;
|
|
@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 = null;
|
try {
|
questionBankReqDTO = JSONObject.parseObject(decrypt, new TypeReference<ThQuestionBankReqDTO>() {});
|
|
}catch (Exception e){
|
logger.error("组卷反序列化失败!");
|
throw new BusinessException(this.getClass(), ResultConstants.SERIALIZE_ERROR);
|
|
}
|
|
//参数校验
|
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);
|
}
|
List<ThCourseReqDTO> courseReqDTOList = new ArrayList<>();
|
//反序列化
|
try {
|
courseReqDTOList = JSONObject.parseObject(decrypt, new TypeReference<List<ThCourseReqDTO>>() {});
|
|
}catch (Exception e){
|
logger.error("课程反序列化失败!");
|
throw new BusinessException(this.getClass(), ResultConstants.SERIALIZE_ERROR);
|
|
}
|
|
if(CollectionUtils.isEmpty(courseReqDTOList)){
|
throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_ERROR,"数据推送不可以为空");
|
}
|
//暂时不限制不能超过1000条
|
List<String> reqAllCourseIds = new ArrayList<>();
|
List<String> reqAllChapterIds = new ArrayList<>();
|
List<ThErrorDataRespDTO> errorDataRespDTOS = new ArrayList<>();
|
List<ThCourseReqDTO> saveCourseReqDTOList = new ArrayList<>();
|
for (ThCourseReqDTO courseReqDTO : courseReqDTOList) {
|
if(StringUtils.isEmpty(courseReqDTO.getUuid()) || !UUID.checkIsUuid(courseReqDTO.getUuid())){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(courseReqDTO.getUuid(),"课程uuid不符合规范"));
|
continue;
|
}
|
if(StringUtils.isEmpty(courseReqDTO.getCourseCode())){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(courseReqDTO.getUuid(),"课程标识不可为空"));
|
continue;
|
}
|
if(StringUtils.isEmpty(courseReqDTO.getCourseName())){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(courseReqDTO.getUuid(),"课程名称不可为空"));
|
continue;
|
}
|
if(StringUtils.isEmpty(courseReqDTO.getTrainOrgName())){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(courseReqDTO.getUuid(),"培训机构名称不可为空"));
|
continue;
|
}
|
if(courseReqDTO.getLessonNum() == null){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(courseReqDTO.getUuid(),"课程总课时不可为空"));
|
continue;
|
}
|
if(CollectionUtils.isEmpty(courseReqDTO.getChapters())){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(courseReqDTO.getUuid(),"课程大纲(大章)不可为空"));
|
continue;
|
}
|
//章
|
boolean errorflag = false;
|
List<String> chapterIds = new ArrayList<>();
|
for (ThCourseChapterReqDTO chapter : courseReqDTO.getChapters()) {
|
|
if(StringUtils.isEmpty(chapter.getUuid()) || !UUID.checkIsUuid(chapter.getUuid())){
|
errorflag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(courseReqDTO.getUuid(),"章uuid("+chapter.getUuid()+")不符合规范"));
|
break;
|
}
|
if(StringUtils.isEmpty(chapter.getChapterCode())){
|
errorflag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(courseReqDTO.getUuid(),"章节(大章)("+chapter.getUuid()+")标识不可为空"));
|
break;
|
}
|
if(StringUtils.isEmpty(chapter.getChapterName())){
|
errorflag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(courseReqDTO.getUuid(),"章节(大章)("+chapter.getUuid()+")名称不可为空"));
|
break;
|
}
|
if(chapter.getDelFlag() == null || DeleteStatusEnum.getDeleteStatusEnum(chapter.getDelFlag()) == null ){
|
errorflag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(courseReqDTO.getUuid(),"章节(大章)("+chapter.getUuid()+")删除标识不符合规范"));
|
break;
|
}
|
if (chapter.getLessonNum() == null){
|
errorflag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(courseReqDTO.getUuid(),"章节(大章)("+chapter.getUuid()+")课时(保留1位小数)不可为空"));
|
break;
|
}
|
if (chapter.getSerialno() == null){
|
errorflag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(courseReqDTO.getUuid(),"章节(大章)("+chapter.getUuid()+")序号不可为空"));
|
break;
|
}
|
if(chapter.getHaveResource() == null || CourseHaveResourse.get(chapter.getHaveResource()) == null){
|
errorflag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(courseReqDTO.getUuid(),"章节(大章)("+chapter.getUuid()+")是否有资源不符合规范"));
|
break;
|
}
|
if(CollectionUtils.isEmpty(chapter.getChildren())){
|
errorflag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(courseReqDTO.getUuid(),"章节(大章)("+chapter.getUuid()+")包含的章节(小节)列表不可为空"));
|
break;
|
}
|
List<String> sectionIds = new ArrayList<>();
|
for (ThCourseChapterReqDTO child : chapter.getChildren()) {
|
if(StringUtils.isEmpty(child.getUuid()) || !UUID.checkIsUuid(child.getUuid())){
|
errorflag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(courseReqDTO.getUuid(),"章节(小节)uuid("+child.getUuid()+")不符合规范"));
|
break;
|
}
|
if(StringUtils.isEmpty(child.getChapterCode())){
|
errorflag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(courseReqDTO.getUuid(),"章节(小节)("+child.getUuid()+")标识不可为空"));
|
break;
|
}
|
if(StringUtils.isEmpty(child.getChapterName())){
|
errorflag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(courseReqDTO.getUuid(),"章节(小节)("+child.getUuid()+")名称不可为空"));
|
break;
|
}
|
if(child.getDuration() == null){
|
errorflag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(courseReqDTO.getUuid(),"章节(小节)("+child.getUuid()+")视频时长(秒)不可为空"));
|
break;
|
}
|
if (chapter.getSerialno() == null){
|
errorflag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(courseReqDTO.getUuid(),"章节(小节)("+child.getUuid()+")序号不可为空"));
|
break;
|
}
|
if (child.getLessonNum() == null){
|
errorflag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(courseReqDTO.getUuid(),"章节(小节)("+child.getUuid()+")课时(保留1位小数)不可为空"));
|
break;
|
}
|
if(child.getResourceType() == null || CourseResourceType.get(child.getResourceType()) == null){
|
errorflag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(courseReqDTO.getUuid(),"章节(小节)"+child.getUuid()+"资源类型不规范"));
|
break;
|
}
|
if(child.getDelFlag() == null || DeleteStatusEnum.getDeleteStatusEnum(child.getDelFlag()) == null ){
|
errorflag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(courseReqDTO.getUuid(),"章节(小节)("+child.getUuid()+")删除标识不符合规范"));
|
break;
|
}
|
if(child.getHaveResource() == null || CourseHaveResourse.get(child.getHaveResource()) == null){
|
errorflag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(courseReqDTO.getUuid(),"章节(小节)("+chapter.getUuid()+")是否有资源不符合规范"));
|
break;
|
}
|
sectionIds.add(child.getUuid());
|
}
|
if(errorflag){
|
break;
|
}
|
//章
|
chapterIds.add(chapter.getUuid());
|
//节
|
chapterIds.addAll(sectionIds);
|
}
|
if(errorflag){
|
continue;
|
}
|
|
reqAllCourseIds.add(courseReqDTO.getUuid());
|
reqAllChapterIds.addAll(chapterIds);
|
saveCourseReqDTOList.add(courseReqDTO);
|
}
|
|
//获取课程数据
|
List<ThCourse> oldCourseList = courseService.getByUuidList(reqAllCourseIds);
|
//获取章节数据
|
List<ThCourseChapter> oldCourseChapterList = courseChapterService.getByUuids(reqAllChapterIds);
|
//变量
|
List<ThCourse> saveCourseList = new ArrayList<>();
|
List<ThCourse> updateCourseList = new ArrayList<>();
|
List<ThCourseChapter> updateCourseChapterList = new ArrayList<>();
|
List<ThCourseChapter> saveCourseChapterList = new ArrayList<>();
|
//获取数据
|
for (ThCourseReqDTO courseReqDTO : saveCourseReqDTOList){
|
List<ThCourse> oCourseSelectList = oldCourseList.stream().filter(oc -> oc.getUuid().equals(courseReqDTO.getUuid())).collect(Collectors.toList());
|
if(oCourseSelectList.size() == 0){
|
//新增
|
//课程
|
ThCourse 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());
|
saveCourseList.add(course);
|
//章节(章)
|
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());
|
saveCourseChapterList.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());
|
saveCourseChapterList.add(section);
|
}
|
}
|
}else {
|
ThCourse course = oCourseSelectList.get(0);
|
//课程
|
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());
|
updateCourseList.add(course);
|
//过滤该课程所有章节
|
List<ThCourseChapter> oldCourseChapterSelectList = oldCourseChapterList.stream().filter(occ -> occ.getCourseUuid().equals(course.getUuid())).collect(Collectors.toList());
|
//修改
|
//章
|
/* List<ThCourseChapter> saveChapterList = new ArrayList<>();
|
List<ThCourseChapter> updateChapterList = new ArrayList<>();*/
|
//章
|
for (ThCourseChapterReqDTO chapterReqDTO : courseReqDTO.getChapters()) {
|
List<ThCourseChapter> chapterSelectList = oldCourseChapterSelectList.stream().filter(cc -> cc.getUuid().equals(chapterReqDTO.getUuid())).collect(Collectors.toList());
|
if(chapterSelectList.size() > 0){
|
//存在,修改
|
ThCourseChapter chapter = chapterSelectList.get(0);
|
BeanUtils.copyProperties(chapterReqDTO, chapter);
|
chapter.setUpdateBy(institutionUser.getInstitutionalName());
|
chapter.setUpdateTime(LocalDateTime.now());
|
updateCourseChapterList.add(chapter);
|
|
if(chapterReqDTO.getDelFlag().equals(DeleteStatusEnum.NO.getStatus())){
|
//非删除(章)
|
for (ThCourseChapterReqDTO child : chapterReqDTO.getChildren()) {
|
List<ThCourseChapter> sectionSelectList = oldCourseChapterSelectList.stream().filter(cc -> cc.getUuid().equals(child.getUuid()) && cc.getParentUuid().equals(chapter.getUuid())).collect(Collectors.toList());
|
if(sectionSelectList.size() > 0){
|
//修改
|
ThCourseChapter section = sectionSelectList.get(0);
|
BeanUtils.copyProperties(child, section);
|
section.setUpdateBy(institutionUser.getInstitutionalName());
|
section.setUpdateTime(LocalDateTime.now());
|
updateCourseChapterList.add(section);
|
}else {
|
//新增
|
ThCourseChapter section= new ThCourseChapter();
|
BeanUtils.copyProperties(child, section);
|
section.setId(IdUtil.getSnowflake(0,0).nextId());
|
section.setCourseUuid(course.getUuid());
|
section.setParentUuid(chapter.getUuid());
|
section.setInstitutionId(institutionUser.getId());
|
//section.setDelFlag(DeleteStatusEnum.NO.getStatus());
|
section.setUpdateBy(institutionUser.getInstitutionalName());
|
section.setUpdateTime(LocalDateTime.now());
|
section.setCreateBy(institutionUser.getInstitutionalName());
|
section.setCreateTime(LocalDateTime.now());
|
saveCourseChapterList.add(section);
|
}
|
}
|
}else{
|
//删除(章)
|
List<ThCourseChapter> sectionSelectList = oldCourseChapterSelectList
|
.stream()
|
.filter(cc -> cc.getParentUuid().equals(chapter.getUuid()))
|
.collect(Collectors.toList());
|
sectionSelectList.forEach(section ->{
|
section.setUpdateBy(institutionUser.getInstitutionalName());
|
section.setUpdateTime(LocalDateTime.now());
|
section.setDelFlag(DeleteStatusEnum.YES.getStatus());
|
});
|
updateCourseChapterList.addAll(sectionSelectList);
|
}
|
|
}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(chapter.getDelFlag());
|
chapter.setCreateTime(LocalDateTime.now());
|
chapter.setUpdateTime(LocalDateTime.now());
|
chapter.setCreateBy(institutionUser.getInstitutionalName());
|
chapter.setUpdateBy(institutionUser.getInstitutionalName());
|
saveCourseChapterList.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(child.getDelFlag());
|
section.setInstitutionId(institutionUser.getId());
|
section.setCreateTime(LocalDateTime.now());
|
section.setUpdateTime(LocalDateTime.now());
|
section.setCreateBy(institutionUser.getInstitutionalName());
|
section.setUpdateBy(institutionUser.getInstitutionalName());
|
saveCourseChapterList.add(section);
|
}
|
}
|
}
|
}
|
}
|
//数据插入
|
//课程插入
|
List<List<ThCourse>> splitSaveCourseList = ListUtil.split(saveCourseList, 500);
|
for(List<ThCourse> courseList : splitSaveCourseList){
|
courseService.insertBatch(courseList);
|
}
|
//修改课程
|
List<List<ThCourse>> splitUpdateCourseList = ListUtil.split(updateCourseList, 500);
|
for(List<ThCourse> courseList : splitUpdateCourseList){
|
courseService.updateBatch(courseList);
|
}
|
//插入章节
|
List<List<ThCourseChapter>> splitSaveChapterList = ListUtil.split(saveCourseChapterList, 500);
|
for(List<ThCourseChapter> chapterList : splitSaveChapterList){
|
courseChapterService.insertBatch(chapterList);
|
}
|
//修改章节
|
List<List<ThCourseChapter>> splitUpdateChapterList = ListUtil.split(updateCourseChapterList, 500);
|
for(List<ThCourseChapter> chapterList : splitUpdateChapterList){
|
courseChapterService.updateBatch(chapterList);
|
}
|
return AjaxResult.success(errorDataRespDTOS);
|
}
|
|
@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<ThStudentReqDTO> studentReqDTOs = new ArrayList<>();
|
try {
|
studentReqDTOs = JSONObject.parseObject(decrypt, new TypeReference<List<ThStudentReqDTO>>() {});
|
}catch (Exception e){
|
logger.error("学员序列化失败!");
|
throw new BusinessException(this.getClass(), ResultConstants.SERIALIZE_ERROR);
|
}
|
//参数校验
|
if(CollectionUtils.isEmpty(studentReqDTOs)){
|
throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"学生信息不可为空");
|
}
|
|
List<String> idcardList = new ArrayList<>();
|
List<String> batchUuidList = new ArrayList<>();
|
for(ThStudentReqDTO studentReqDTO : studentReqDTOs){
|
//去重
|
if(!idcardList.contains(studentReqDTO.getIdcard()) && StringUtils.isNotEmpty(studentReqDTO.getIdcard())){
|
idcardList.add(studentReqDTO.getIdcard());
|
}
|
if(!batchUuidList.contains(studentReqDTO.getBatchUuid()) && StringUtils.isNotEmpty(studentReqDTO.getBatchUuid())){
|
batchUuidList.add(studentReqDTO.getBatchUuid());
|
}
|
|
}
|
//获取批次
|
List<ThBatch> batchList = batchService.getByUuids(batchUuidList);
|
//获取批次学生
|
List<ThStudentBatch> studentBatchList = studentBatchService.getByIdCards(idcardList);
|
//获取学生表学生
|
List<ThStudent> students = studentService.getByIdcards(idcardList);
|
//错误
|
List<ThErrorDataRespDTO> errorDataRespDTOS = new ArrayList<>();
|
List<ThStudentReqDTO> saveStudentReqDTOList = new ArrayList<>();
|
for (ThStudentReqDTO studentReqDTO : studentReqDTOs) {
|
if(StringUtils.isEmpty(studentReqDTO.getUuid()) || !UUID.checkIsUuid(studentReqDTO.getUuid())){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentReqDTO.getUuid(),"学生uuid不符合规范"));
|
continue;
|
}
|
if(StringUtils.isEmpty(studentReqDTO.getIdcard())){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentReqDTO.getUuid(),"身份证不可为空"));
|
continue;
|
}
|
if(StringUtils.isEmpty(studentReqDTO.getName())){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentReqDTO.getUuid(),"姓名不可为空"));
|
continue;
|
}
|
if(StringUtils.isEmpty(studentReqDTO.getPhone())){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentReqDTO.getUuid(),"手机号不可为空"));
|
continue;
|
}
|
if(studentReqDTO.getSex() == null || StudentSex.get(studentReqDTO.getSex()) == null){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentReqDTO.getUuid(),"性别不可为空"));
|
continue;
|
}
|
if(StringUtils.isEmpty(studentReqDTO.getAuthPhoto())){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentReqDTO.getUuid(),"实名认证照不可为空"));
|
continue;
|
}
|
if(studentReqDTO.getDelFlag() == null || DeleteStatusEnum.getDeleteStatusEnum(studentReqDTO.getDelFlag()) == null ){
|
throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"学生删除标识不符合规范");
|
}
|
if (StringUtils.isEmpty(studentReqDTO.getTrainOrgName())){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentReqDTO.getUuid(),"培训机构名称不可为空"));
|
continue;
|
}
|
if(StringUtils.isEmpty(studentReqDTO.getBatchUuid())){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentReqDTO.getUuid(),"关联批次(班级)不可为空"));
|
continue;
|
}
|
List<ThBatch> collect = batchList.stream().filter(batchCourse -> batchCourse.getUuid().equals(studentReqDTO.getBatchUuid())).collect(Collectors.toList());
|
if (CollectionUtils.isEmpty(collect)) {
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentReqDTO.getUuid(), "批次(班级)不存在,请先添加批次(班级)"));
|
continue;
|
}
|
saveStudentReqDTOList.add(studentReqDTO);
|
}
|
|
List<ThStudent> saveSudentList = new ArrayList<>();
|
List<ThStudent> updateStudentList = new ArrayList<>();
|
List<ThStudentBatch> saveThStudentBatchList = new ArrayList<>();
|
List<ThStudentBatch> updateThStudentBatchList = new ArrayList<>();
|
for (ThStudentReqDTO studentReqDTO : saveStudentReqDTOList) {
|
//学生表中过滤
|
List<ThStudent> 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);
|
}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<ThStudentBatch> selectBatchStudentList = studentBatchList.stream()
|
.filter(sb -> sb.getBatchUuid().equals(studentReqDTO.getBatchUuid())
|
&& sb.getIdcard().equals(studentReqDTO.getIdcard()))
|
.collect(Collectors.toList());
|
//判断是否存在(已经加入过该班级)
|
if(selectBatchStudentList.size() > 0){
|
ThStudentBatch thStudentBatch = selectBatchStudentList.get(0);
|
//存在
|
if(studentReqDTO.getDelFlag().equals(DeleteStatusEnum.YES.getStatus())){
|
//删除(学生退出班级)
|
thStudentBatch.setDelFlag(DeleteStatusEnum.YES.getStatus());
|
updateThStudentBatchList.add(thStudentBatch);
|
}else {
|
//修改
|
BeanUtils.copyProperties(studentReqDTO, thStudentBatch);
|
thStudentBatch.setUpdateBy(institutionUser.getInstitutionalName());
|
thStudentBatch.setUpdateTime(LocalDateTime.now());
|
updateThStudentBatchList.add(thStudentBatch);
|
}
|
|
}else {
|
//不存在,新增
|
ThStudentBatch thStudentBatch = new ThStudentBatch();
|
BeanUtils.copyProperties(studentReqDTO, thStudentBatch);
|
thStudentBatch.setId(IdUtil.getSnowflake(0,0).nextId());
|
thStudentBatch.setUpdateBy(institutionUser.getInstitutionalName());
|
thStudentBatch.setUpdateTime(LocalDateTime.now());
|
thStudentBatch.setCreateBy(institutionUser.getInstitutionalName());
|
thStudentBatch.setCreateTime(LocalDateTime.now());
|
thStudentBatch.setInstitutionId(institutionUser.getId());
|
thStudentBatch.setInstitutionName(institutionUser.getInstitutionalName());
|
thStudentBatch.setFinishStatus(FinishStatus.NO.getStatus());
|
thStudentBatch.setDelFlag(DeleteStatusEnum.NO.getStatus());
|
saveThStudentBatchList.add(thStudentBatch);
|
}
|
}
|
//学生表新增
|
List<List<ThStudent>> splitSaveStudentList = ListUtil.split(saveSudentList, 500);
|
for (List<ThStudent> studentList : splitSaveStudentList) {
|
studentService.insertBatch(studentList);
|
}
|
//学生表更新
|
List<List<ThStudent>> splitUpdateStudentList = ListUtil.split(updateStudentList, 500);
|
for (List<ThStudent> studentList : splitUpdateStudentList) {
|
studentService.updateBatch(studentList);
|
}
|
//学生关联班级表
|
List<List<ThStudentBatch>> splitSaveThStudentBatchList = ListUtil.split(saveThStudentBatchList, 500);
|
for (List<ThStudentBatch> studentBatcheList : splitSaveThStudentBatchList) {
|
studentBatchService.insertBatch(studentBatcheList);
|
}
|
|
//学生关联班级表修改
|
List<List<ThStudentBatch>> splitUpdateThStudentBatchList = ListUtil.split(updateThStudentBatchList, 500);
|
for (List<ThStudentBatch> studentBatcheList : splitUpdateThStudentBatchList) {
|
studentBatchService.updateBatch(studentBatcheList);
|
}
|
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);
|
}
|
//反序列化
|
List<ThBatchReqDTO> batchReqDTOList = new ArrayList<>();
|
try {
|
batchReqDTOList = JSONObject.parseObject(decrypt, new TypeReference<List<ThBatchReqDTO>>() {});
|
|
}catch (Exception e){
|
logger.error("班级序列化失败!");
|
throw new BusinessException(this.getClass(), ResultConstants.SERIALIZE_ERROR);
|
|
}
|
if(CollectionUtils.isEmpty(batchReqDTOList)){
|
throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"批次(班级)集合不可为空");
|
}
|
//过滤出本次请求所有班级课程章节
|
List<String> reqAllBatchUuids = new ArrayList<>();
|
List<String> reqCourseUuids = new ArrayList<>();
|
List<String> reqChapterUuids = new ArrayList<>();
|
for(ThBatchReqDTO batchReqDTO : batchReqDTOList){
|
if(!reqAllBatchUuids.contains(batchReqDTO.getUuid()) && StringUtils.isNotEmpty(batchReqDTO.getUuid())){
|
reqAllBatchUuids.add(batchReqDTO.getUuid());
|
}
|
if(!CollectionUtils.isEmpty(batchReqDTO.getCourseList())){
|
for (ThBatchCourseReqDTO thCourseReqDTO : batchReqDTO.getCourseList()){
|
if(!reqCourseUuids.contains(thCourseReqDTO.getCourseUuid()) && StringUtils.isNotEmpty(thCourseReqDTO.getCourseUuid())){
|
reqCourseUuids.add(thCourseReqDTO.getCourseUuid());
|
}
|
if(!CollectionUtils.isEmpty(thCourseReqDTO.getChapterList())){
|
for (ThBatchCourseChapterReqDTO chapter : thCourseReqDTO.getChapterList()){
|
//去重
|
if(!reqChapterUuids.contains(chapter.getChapterUuid()) && StringUtils.isNotEmpty(chapter.getChapterUuid())){
|
reqChapterUuids.add(chapter.getChapterUuid());
|
}
|
if(!CollectionUtils.isEmpty(chapter.getChildren())){
|
for (ThBatchCourseChapterReqDTO section : chapter.getChildren()){
|
//去重
|
if(!reqChapterUuids.contains(section.getChapterUuid()) && StringUtils.isNotEmpty(section.getChapterUuid())){
|
reqChapterUuids.add(section.getChapterUuid());
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
//获取已存在班级
|
List<ThBatch> oldBatchList = batchService.getByUuids(reqAllBatchUuids);
|
//获取已存在班级课程
|
List<ThBatchCourse> oldbatchCourseList = batchCourseService.getListByBatchUuids(reqAllBatchUuids);
|
//获取已存在班级课程章节
|
List<ThBatchCourseChapter> oldbatchCourseChapterList = batchCourseChapterService.getListByBatchUuids(reqAllBatchUuids);
|
//获取课程
|
List<ThCourse> thCourseList = courseService.getByUuidList(reqCourseUuids);
|
//获取章节
|
List<ThCourseChapter> thCourseChapterList = courseChapterService.getByUuids(reqChapterUuids);
|
//校验
|
List<ThErrorDataRespDTO> errorDataRespDTOS = new ArrayList<>();
|
List<ThBatchReqDTO> saveBatchReqDTOList = new ArrayList<>();
|
for (ThBatchReqDTO batchReqDTO : batchReqDTOList) {
|
//获取该机构所有课程和章节
|
//参数校验
|
if(StringUtils.isEmpty(batchReqDTO.getUuid()) || !UUID.checkIsUuid(batchReqDTO.getUuid())){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(batchReqDTO.getUuid(),"批次(班级)uuid不符合规范"));
|
continue;
|
}
|
if(StringUtils.isEmpty(batchReqDTO.getBatchName())){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(batchReqDTO.getUuid(),"班次(班级)名称不可为空"));
|
continue;
|
}
|
if(StringUtils.isEmpty(batchReqDTO.getTrainOrgName())){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(batchReqDTO.getUuid(),"培训机构名称不可为空"));
|
continue;
|
}
|
if(batchReqDTO.getHaveExam() == null || HaveExam.get(batchReqDTO.getHaveExam()) == null){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(batchReqDTO.getUuid(),"有无考试不规范"));
|
continue;
|
}
|
if(batchReqDTO.getStatus() == null || OpenStatus.get(batchReqDTO.getStatus()) == null ){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(batchReqDTO.getUuid(),"批次(班级)状态标识不符合规范"));
|
continue;
|
}
|
if(batchReqDTO.getBatchLessonNum() == null){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(batchReqDTO.getUuid(),"批次(班级)课时不可为空"));
|
continue;
|
}
|
if(batchReqDTO.getDelFlag() == null || DeleteStatusEnum.getDeleteStatusEnum(batchReqDTO.getDelFlag()) == null ){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(batchReqDTO.getUuid(),"批次(班级)删除标识不符合规范"));
|
continue;
|
}
|
if(CollectionUtils.isEmpty(batchReqDTO.getCourseList())){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(batchReqDTO.getUuid(),"关联课程不可为空"));
|
continue;
|
}
|
boolean errorFlag = false;
|
//校验课程
|
for (ThBatchCourseReqDTO thBatchCourseReqDTO : batchReqDTO.getCourseList()) {
|
if(StringUtils.isEmpty(thBatchCourseReqDTO.getCourseUuid()) || !UUID.checkIsUuid(thBatchCourseReqDTO.getCourseUuid())){
|
errorFlag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(batchReqDTO.getUuid(),"课程uuid("+thBatchCourseReqDTO.getCourseUuid()+")不符合规范"));
|
break;
|
}
|
if(thBatchCourseReqDTO.getCourseLessonNum() == null){
|
errorFlag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(batchReqDTO.getUuid(),"课程("+thBatchCourseReqDTO.getCourseUuid()+")课时不可为空"));
|
break;
|
}
|
List<ThCourse> selectCourseList = thCourseList.stream().filter(c -> c.getUuid().equals(thBatchCourseReqDTO.getCourseUuid())).collect(Collectors.toList());
|
if(selectCourseList.size() == 0){
|
errorFlag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(batchReqDTO.getUuid(),"课程("+thBatchCourseReqDTO.getCourseUuid()+")不存在"));
|
break;
|
}
|
if(thBatchCourseReqDTO.getDelFlag() == null || DeleteStatusEnum.getDeleteStatusEnum(thBatchCourseReqDTO.getDelFlag()) == null ){
|
errorFlag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(batchReqDTO.getUuid(),"课程("+thBatchCourseReqDTO.getCourseUuid()+")删除标识不符合规范"));
|
break;
|
}
|
if(CollectionUtils.isEmpty(thBatchCourseReqDTO.getChapterList())){
|
errorFlag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(batchReqDTO.getUuid(),"课程("+thBatchCourseReqDTO.getCourseUuid()+")章节(大章)不可为空"));
|
break;
|
}
|
//校验章节(大)
|
for (ThBatchCourseChapterReqDTO chapter : thBatchCourseReqDTO.getChapterList()) {
|
if(StringUtils.isEmpty(chapter.getChapterUuid()) || !UUID.checkIsUuid(chapter.getChapterUuid())){
|
errorFlag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(batchReqDTO.getUuid(),"章节(大章)uuid("+chapter.getChapterUuid()+")不符合规范"));
|
break;
|
}
|
if(chapter.getChapterLessonNum() == null){
|
errorFlag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(batchReqDTO.getUuid(),"章节(大章)("+chapter.getChapterUuid()+")课时不可为空"));
|
break;
|
}
|
if(chapter.getDelFlag() == null || DeleteStatusEnum.getDeleteStatusEnum(chapter.getDelFlag()) == null ){
|
errorFlag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(batchReqDTO.getUuid(),"章节(大章)("+chapter.getChapterUuid()+")删除标识不符合规范"));
|
break;
|
}
|
//校验章节存在否
|
List<ThCourseChapter> chapterSelectList = thCourseChapterList
|
.stream()
|
.filter(courseChapter -> courseChapter.getUuid().equals(chapter.getChapterUuid())
|
&& courseChapter.getCourseUuid().equals(thBatchCourseReqDTO.getCourseUuid())
|
&& courseChapter.getParentUuid().equals("0")
|
).collect(Collectors.toList());
|
if(chapterSelectList.size() == 0){
|
errorFlag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(batchReqDTO.getUuid(),"章节(大章)("+chapter.getChapterUuid()+")不存在"));
|
break;
|
}
|
if(CollectionUtils.isEmpty(chapter.getChildren())){
|
errorFlag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(batchReqDTO.getUuid(),"大章("+chapter.getChapterUuid()+")包含章节(小节)不可为空"));
|
break;
|
}
|
for (ThBatchCourseChapterReqDTO child : chapter.getChildren()) {
|
|
if(StringUtils.isEmpty(child.getChapterUuid()) || !UUID.checkIsUuid(child.getChapterUuid())){
|
errorFlag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(batchReqDTO.getUuid(),"章节(小节)uuid("+child.getChapterUuid()+")不符合规范"));
|
break;
|
}
|
if(child.getDelFlag() == null || DeleteStatusEnum.getDeleteStatusEnum(child.getDelFlag()) == null ){
|
errorFlag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(batchReqDTO.getUuid(),"章节(小节)("+child.getChapterUuid()+")删除标识不符合规范"));
|
break;
|
}
|
List<ThCourseChapter> sectionSelectList = thCourseChapterList
|
.stream()
|
.filter(courseChapter -> courseChapter.getUuid().equals(child.getChapterUuid())
|
&& courseChapter.getCourseUuid().equals(thBatchCourseReqDTO.getCourseUuid())
|
&& courseChapter.getParentUuid().equals(chapter.getChapterUuid())
|
).collect(Collectors.toList());
|
if(sectionSelectList.size() == 0){
|
errorFlag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(batchReqDTO.getUuid(),"章节(小节)("+child.getChapterUuid()+")不存在"));
|
break;
|
}
|
}
|
if(errorFlag){
|
break;
|
}
|
}
|
if(errorFlag){
|
break;
|
}
|
}
|
if(errorFlag){
|
continue;
|
}
|
saveBatchReqDTOList.add(batchReqDTO);
|
}
|
|
//数据填充
|
List<ThBatch> saveBatchList = new ArrayList<>();
|
List<ThBatch> updateBatchList = new ArrayList<>();
|
List<ThBatchCourse> saveBatchCourseList = new ArrayList<>();
|
List<ThBatchCourse> updateBatchCourseList = new ArrayList<>();
|
List<ThBatchCourseChapter> saveBatchCourseChapterList = new ArrayList<>();
|
List<ThBatchCourseChapter> updateBatchCourseChapterList = new ArrayList<>();
|
for (ThBatchReqDTO batchReqDTO : saveBatchReqDTOList) {
|
List<ThBatch> oldBatchSelectList = oldBatchList.stream().filter(ob -> ob.getUuid().equals(batchReqDTO.getUuid())).collect(Collectors.toList());
|
if(!CollectionUtils.isEmpty(oldBatchSelectList)){
|
ThBatch batch = oldBatchSelectList.get(0);
|
if(batchReqDTO.getDelFlag().equals(DeleteStatusEnum.YES.getStatus())){
|
|
//删除班级
|
batch.setDelFlag(batchReqDTO.getDelFlag());
|
batch.setUpdateBy(institutionUser.getInstitutionalName());
|
batch.setUpdateTime(LocalDateTime.now());
|
updateBatchList.add(batch);
|
List<ThBatchCourse> delectBatchCourseList = oldbatchCourseList
|
.stream()
|
.filter(obc -> obc.getBatchUuid().equals(batch.getUuid()))
|
.collect(Collectors.toList());
|
delectBatchCourseList.forEach(item -> {
|
item.setDelFlag(DeleteStatusEnum.YES.getStatus());
|
item.setUpdateBy(institutionUser.getInstitutionalName());
|
item.setUpdateTime(LocalDateTime.now());
|
});
|
updateBatchCourseList.addAll(delectBatchCourseList);
|
List<ThBatchCourseChapter> deleteBatchCourseChapterList = oldbatchCourseChapterList
|
.stream()
|
.filter(obcc -> obcc.getBatchUuid().equals(batch.getUuid()))
|
.collect(Collectors.toList());
|
deleteBatchCourseChapterList.forEach(item -> {
|
item.setDelFlag(DeleteStatusEnum.YES.getStatus());
|
item.setUpdateBy(institutionUser.getInstitutionalName());
|
item.setUpdateTime(LocalDateTime.now());
|
});
|
updateBatchCourseChapterList.addAll(deleteBatchCourseChapterList);
|
}else {
|
//非删除
|
|
BeanUtils.copyProperties(batchReqDTO,batch);
|
batch.setUpdateBy(institutionUser.getInstitutionalName());
|
batch.setUpdateTime(LocalDateTime.now());
|
updateBatchList.add(batch);
|
|
//修改课程
|
for(ThBatchCourseReqDTO courseReqDTO : batchReqDTO.getCourseList()){
|
List<ThBatchCourse> oldBatchCourseSelectList = oldbatchCourseList.stream().filter(c -> c.getCourseUuid().equals(courseReqDTO.getCourseUuid())).collect(Collectors.toList());
|
if(CollectionUtils.isEmpty(oldBatchCourseSelectList)){
|
//获取该课程信息
|
List<ThCourse> courseInfoList = thCourseList.stream().filter(c -> c.getUuid().equals(courseReqDTO.getCourseUuid())).collect(Collectors.toList());
|
|
//插入课程
|
ThBatchCourse batchCourse = new ThBatchCourse();
|
BeanUtils.copyProperties(courseReqDTO,batchCourse);
|
batchCourse.setCourseName(courseInfoList.get(0).getCourseName());
|
batchCourse.setBatchUuid(batch.getUuid());
|
//batchCourse.setCourseUuid(courseReqDTO.getCouserUuid());
|
batchCourse.setInstitutionId(institutionUser.getId());
|
batchCourse.setCreateBy(institutionUser.getInstitutionalName());
|
batchCourse.setCreateTime(LocalDateTime.now());
|
batchCourse.setUpdateBy(institutionUser.getInstitutionalName());
|
batchCourse.setUpdateTime(LocalDateTime.now());
|
if(batchReqDTO.getDelFlag().equals(DeleteStatusEnum.YES.getStatus())){
|
batchCourse.setDelFlag(DeleteStatusEnum.YES.getStatus());
|
}
|
saveBatchCourseList.add(batchCourse);
|
|
//插入章
|
for(ThBatchCourseChapterReqDTO chapterReqDTO : courseReqDTO.getChapterList()){
|
//获取其章
|
List<ThCourseChapter> chapterInfoList = thCourseChapterList.stream().filter(cc -> cc.getCourseUuid().equals(batchCourse.getCourseUuid())
|
&& cc.getUuid().equals(chapterReqDTO.getChapterUuid())).collect(Collectors.toList());
|
|
ThBatchCourseChapter chapter = new ThBatchCourseChapter();
|
BeanUtils.copyProperties(chapterInfoList.get(0),chapter);
|
chapter.setBatchUuid(batch.getUuid());
|
chapter.setLessonNum(chapterReqDTO.getChapterLessonNum());
|
chapter.setId(IdUtil.getSnowflake(0,0).nextId());
|
if(batchReqDTO.getDelFlag().equals(DeleteStatusEnum.YES.getStatus())
|
|| courseReqDTO.getDelFlag().equals(DeleteStatusEnum.YES.getStatus())){
|
chapter.setDelFlag(DeleteStatusEnum.YES.getStatus());
|
}else {
|
chapter.setDelFlag(chapterReqDTO.getDelFlag());
|
}
|
chapter.setDelFlag(DeleteStatusEnum.YES.getStatus());
|
chapter.setChapterUuid(chapterReqDTO.getChapterUuid());
|
chapter.setCreateBy(institutionUser.getInstitutionalName());
|
chapter.setCreateTime(LocalDateTime.now());
|
chapter.setUpdateBy(institutionUser.getInstitutionalName());
|
chapter.setUpdateTime(LocalDateTime.now());
|
saveBatchCourseChapterList.add(chapter);
|
|
//插入节
|
for(ThBatchCourseChapterReqDTO sectionReqDTO : chapterReqDTO.getChildren()){
|
//获取节
|
List<ThCourseChapter> sectionInfoList = thCourseChapterList.stream()
|
.filter(cc -> cc.getCourseUuid().equals(batchCourse.getCourseUuid())
|
&& cc.getUuid().equals(sectionReqDTO.getChapterUuid())).collect(Collectors.toList());
|
|
ThBatchCourseChapter section = new ThBatchCourseChapter();
|
BeanUtils.copyProperties(sectionInfoList.get(0),section);
|
section.setBatchUuid(batch.getUuid());
|
section.setLessonNum(sectionReqDTO.getChapterLessonNum());
|
section.setId(IdUtil.getSnowflake(0,0).nextId());
|
if(batchReqDTO.getDelFlag().equals(DeleteStatusEnum.YES.getStatus())
|
|| courseReqDTO.getDelFlag().equals(DeleteStatusEnum.YES.getStatus())
|
|| chapterReqDTO.getDelFlag().equals(DeleteStatusEnum.YES.getStatus())){
|
section.setDelFlag(DeleteStatusEnum.YES.getStatus());
|
}else {
|
section.setDelFlag(sectionReqDTO.getDelFlag());
|
}
|
section.setChapterUuid(sectionReqDTO.getChapterUuid());
|
section.setCreateBy(institutionUser.getInstitutionalName());
|
section.setCreateTime(LocalDateTime.now());
|
section.setUpdateBy(institutionUser.getInstitutionalName());
|
section.setUpdateTime(LocalDateTime.now());
|
saveBatchCourseChapterList.add(section);
|
}
|
}
|
|
}else {
|
//修改
|
ThBatchCourse batchCourse = oldBatchCourseSelectList.get(0);
|
batchCourse.setDelFlag(courseReqDTO.getDelFlag());
|
batchCourse.setCourseLessonNum(courseReqDTO.getCourseLessonNum());
|
batchCourse.setUpdateBy(institutionUser.getInstitutionalName());
|
batchCourse.setUpdateTime(LocalDateTime.now());
|
if(batchReqDTO.getDelFlag().equals(DeleteStatusEnum.YES.getStatus())){
|
batchCourse.setDelFlag(DeleteStatusEnum.YES.getStatus());
|
}
|
updateBatchCourseList.add(batchCourse);
|
|
//章
|
for(ThBatchCourseChapterReqDTO chapterReqDTO : courseReqDTO.getChapterList()){
|
List<ThBatchCourseChapter> oldChapterInfoList = oldbatchCourseChapterList.stream().filter(ochapter -> ochapter.getCourseUuid().equals(batchCourse.getCourseUuid())
|
&& ochapter.getChapterUuid().equals(chapterReqDTO.getChapterUuid())).collect(Collectors.toList());
|
//章是否存在
|
if(!CollectionUtils.isEmpty(oldChapterInfoList)){
|
//存在修改
|
ThBatchCourseChapter chapter = oldChapterInfoList.get(0);
|
BeanUtils.copyProperties(chapterReqDTO,chapter);
|
chapter.setLessonNum(chapterReqDTO.getChapterLessonNum());
|
chapter.setUpdateBy(institutionUser.getInstitutionalName());
|
chapter.setUpdateTime(LocalDateTime.now());
|
if(batchReqDTO.getDelFlag().equals(DeleteStatusEnum.YES.getStatus())
|
|| courseReqDTO.getDelFlag().equals(DeleteStatusEnum.YES.getStatus())){
|
chapter.setDelFlag(DeleteStatusEnum.YES.getStatus());
|
}
|
updateBatchCourseChapterList.add(chapter);
|
for(ThBatchCourseChapterReqDTO sectionReqDTO : chapterReqDTO.getChildren()){
|
List<ThBatchCourseChapter> oldsectionInfoList = oldbatchCourseChapterList.stream().filter(section -> section.getCourseUuid().equals(batchCourse.getCourseUuid())
|
&& section.getChapterUuid().equals(sectionReqDTO.getChapterUuid())).collect(Collectors.toList());
|
if(!CollectionUtils.isEmpty(oldsectionInfoList)){
|
//存在,修改
|
ThBatchCourseChapter section = oldsectionInfoList.get(0);
|
BeanUtils.copyProperties(sectionReqDTO,section);
|
section.setLessonNum(sectionReqDTO.getChapterLessonNum());
|
section.setUpdateBy(institutionUser.getInstitutionalName());
|
section.setUpdateTime(LocalDateTime.now());
|
if(batchReqDTO.getDelFlag().equals(DeleteStatusEnum.YES.getStatus())
|
|| courseReqDTO.getDelFlag().equals(DeleteStatusEnum.YES.getStatus())
|
|| chapterReqDTO.getDelFlag().equals(DeleteStatusEnum.YES.getStatus())){
|
section.setDelFlag(DeleteStatusEnum.YES.getStatus());
|
}
|
updateBatchCourseChapterList.add(section);
|
}else {
|
//不存在,新增
|
//获取节
|
List<ThCourseChapter> sectionInfoList = thCourseChapterList.stream()
|
.filter(cc -> cc.getCourseUuid().equals(batchCourse.getCourseUuid())
|
&& cc.getUuid().equals(sectionReqDTO.getChapterUuid())).collect(Collectors.toList());
|
|
ThBatchCourseChapter section = new ThBatchCourseChapter();
|
BeanUtils.copyProperties(sectionInfoList.get(0),section);
|
section.setBatchUuid(batch.getUuid());
|
section.setChapterUuid(sectionInfoList.get(0).getUuid());
|
section.setLessonNum(sectionReqDTO.getChapterLessonNum());
|
section.setId(IdUtil.getSnowflake(0,0).nextId());
|
section.setDelFlag(sectionReqDTO.getDelFlag());
|
if(batchReqDTO.getDelFlag().equals(DeleteStatusEnum.YES.getStatus())
|
|| courseReqDTO.getDelFlag().equals(DeleteStatusEnum.YES.getStatus())
|
|| chapterReqDTO.getDelFlag().equals(DeleteStatusEnum.YES.getStatus())){
|
section.setDelFlag(DeleteStatusEnum.YES.getStatus());
|
}
|
section.setCreateBy(institutionUser.getInstitutionalName());
|
section.setCreateTime(LocalDateTime.now());
|
section.setUpdateBy(institutionUser.getInstitutionalName());
|
section.setUpdateTime(LocalDateTime.now());
|
saveBatchCourseChapterList.add(section);
|
}
|
}
|
|
}else {
|
//不存在,新增
|
//获取其章
|
List<ThCourseChapter> chapterInfoList = thCourseChapterList.stream().filter(cc -> cc.getCourseUuid().equals(batchCourse.getCourseUuid())
|
&& cc.getUuid().equals(chapterReqDTO.getChapterUuid())).collect(Collectors.toList());
|
|
ThBatchCourseChapter chapter = new ThBatchCourseChapter();
|
BeanUtils.copyProperties(chapterInfoList.get(0),chapter);
|
chapter.setChapterUuid(chapterInfoList.get(0).getUuid());
|
chapter.setBatchUuid(batch.getUuid());
|
chapter.setLessonNum(chapterReqDTO.getChapterLessonNum());
|
chapter.setId(IdUtil.getSnowflake(0,0).nextId());
|
chapter.setDelFlag(chapterReqDTO.getDelFlag());
|
chapter.setCreateBy(institutionUser.getInstitutionalName());
|
chapter.setCreateTime(LocalDateTime.now());
|
chapter.setUpdateBy(institutionUser.getInstitutionalName());
|
chapter.setUpdateTime(LocalDateTime.now());
|
if(batchReqDTO.getDelFlag().equals(DeleteStatusEnum.YES.getStatus())
|
|| courseReqDTO.getDelFlag().equals(DeleteStatusEnum.YES.getStatus())){
|
chapter.setDelFlag(DeleteStatusEnum.YES.getStatus());
|
}
|
saveBatchCourseChapterList.add(chapter);
|
|
//插入节
|
for(ThBatchCourseChapterReqDTO sectionReqDTO : chapterReqDTO.getChildren()){
|
//获取节
|
List<ThCourseChapter> sectionInfoList = thCourseChapterList.stream()
|
.filter(cc -> cc.getCourseUuid().equals(batchCourse.getCourseUuid())
|
&& cc.getUuid().equals(sectionReqDTO.getChapterUuid())).collect(Collectors.toList());
|
|
ThBatchCourseChapter section = new ThBatchCourseChapter();
|
BeanUtils.copyProperties(sectionInfoList.get(0),section);
|
section.setChapterUuid(sectionInfoList.get(0).getUuid());
|
section.setBatchUuid(batch.getUuid());
|
section.setLessonNum(sectionReqDTO.getChapterLessonNum());
|
section.setId(IdUtil.getSnowflake(0,0).nextId());
|
section.setDelFlag(sectionReqDTO.getDelFlag());
|
section.setCreateBy(institutionUser.getInstitutionalName());
|
section.setCreateTime(LocalDateTime.now());
|
section.setUpdateBy(institutionUser.getInstitutionalName());
|
section.setUpdateTime(LocalDateTime.now());
|
if(batchReqDTO.getDelFlag().equals(DeleteStatusEnum.YES.getStatus())
|
|| courseReqDTO.getDelFlag().equals(DeleteStatusEnum.YES.getStatus())
|
|| chapterReqDTO.getDelFlag().equals(DeleteStatusEnum.YES.getStatus())){
|
section.setDelFlag(DeleteStatusEnum.YES.getStatus());
|
}
|
saveBatchCourseChapterList.add(section);
|
}
|
}
|
|
}
|
}
|
}
|
}
|
}else {
|
//新增
|
//班次新增
|
ThBatch batch = new ThBatch();
|
BeanUtils.copyProperties(batchReqDTO, batch);
|
batch.setUpdateBy(institutionUser.getInstitutionalName());
|
batch.setUpdateTime(LocalDateTime.now());
|
batch.setCreateBy(institutionUser.getInstitutionalName());
|
batch.setCreateTime(LocalDateTime.now());
|
batch.setInstitutionId(institutionUser.getId());
|
batch.setInstitutionName(institutionUser.getInstitutionalName());
|
saveBatchList.add(batch);
|
|
for(ThBatchCourseReqDTO courseReqDTO : batchReqDTO.getCourseList()) {
|
//获取该课程信息
|
List<ThCourse> courseInfoList = thCourseList.stream().filter(c -> c.getUuid().equals(courseReqDTO.getCourseUuid())).collect(Collectors.toList());
|
|
//插入课程
|
ThBatchCourse batchCourse = new ThBatchCourse();
|
BeanUtils.copyProperties(courseReqDTO, batchCourse);
|
batchCourse.setCourseName(courseInfoList.get(0).getCourseName());
|
batchCourse.setBatchUuid(batch.getUuid());
|
//batchCourse.setCourseUuid(courseReqDTO.getCouserUuid());
|
batchCourse.setInstitutionId(institutionUser.getId());
|
batchCourse.setCreateBy(institutionUser.getInstitutionalName());
|
batchCourse.setCreateTime(LocalDateTime.now());
|
batchCourse.setUpdateBy(institutionUser.getInstitutionalName());
|
batchCourse.setUpdateTime(LocalDateTime.now());
|
if(batchReqDTO.getDelFlag().equals(DeleteStatusEnum.YES.getStatus())
|
|| courseReqDTO.getDelFlag().equals(DeleteStatusEnum.YES.getStatus())){
|
batchCourse.setDelFlag(DeleteStatusEnum.YES.getStatus());
|
}else {
|
batchCourse.setDelFlag(DeleteStatusEnum.NO.getStatus());
|
}
|
saveBatchCourseList.add(batchCourse);
|
|
//插入章
|
for (ThBatchCourseChapterReqDTO chapterReqDTO : courseReqDTO.getChapterList()) {
|
//获取其章
|
List<ThCourseChapter> chapterInfoList = thCourseChapterList.stream().filter(cc -> cc.getCourseUuid().equals(batchCourse.getCourseUuid())
|
&& cc.getUuid().equals(chapterReqDTO.getChapterUuid())).collect(Collectors.toList());
|
|
ThBatchCourseChapter chapter = new ThBatchCourseChapter();
|
BeanUtils.copyProperties(chapterInfoList.get(0), chapter);
|
chapter.setBatchUuid(batch.getUuid());
|
chapter.setLessonNum(chapterReqDTO.getChapterLessonNum());
|
chapter.setId(IdUtil.getSnowflake(0, 0).nextId());
|
if(batchReqDTO.getDelFlag().equals(DeleteStatusEnum.YES.getStatus())
|
|| courseReqDTO.getDelFlag().equals(DeleteStatusEnum.YES.getStatus())
|
|| chapterReqDTO.getDelFlag().equals(DeleteStatusEnum.YES.getStatus())){
|
chapter.setDelFlag(DeleteStatusEnum.YES.getStatus());
|
}else {
|
chapter.setDelFlag(DeleteStatusEnum.NO.getStatus());
|
}
|
chapter.setChapterUuid(chapterReqDTO.getChapterUuid());
|
chapter.setChapterUuid(chapterReqDTO.getChapterUuid());
|
saveBatchCourseChapterList.add(chapter);
|
|
//插入节
|
for (ThBatchCourseChapterReqDTO sectionReqDTO : chapterReqDTO.getChildren()) {
|
//获取节
|
List<ThCourseChapter> sectionInfoList = thCourseChapterList.stream()
|
.filter(cc -> cc.getCourseUuid().equals(batchCourse.getCourseUuid())
|
&& cc.getUuid().equals(sectionReqDTO.getChapterUuid())).collect(Collectors.toList());
|
|
ThBatchCourseChapter section = new ThBatchCourseChapter();
|
BeanUtils.copyProperties(sectionInfoList.get(0), section);
|
section.setBatchUuid(batch.getUuid());
|
section.setLessonNum(sectionReqDTO.getChapterLessonNum());
|
section.setId(IdUtil.getSnowflake(0, 0).nextId());
|
if(batchReqDTO.getDelFlag().equals(DeleteStatusEnum.YES.getStatus())
|
|| courseReqDTO.getDelFlag().equals(DeleteStatusEnum.YES.getStatus())
|
|| chapterReqDTO.getDelFlag().equals(DeleteStatusEnum.YES.getStatus())
|
|| sectionReqDTO.getDelFlag().equals(DeleteStatusEnum.YES.getStatus())){
|
section.setDelFlag(DeleteStatusEnum.YES.getStatus());
|
}else {
|
section.setDelFlag(DeleteStatusEnum.NO.getStatus());
|
}
|
section.setChapterUuid(sectionReqDTO.getChapterUuid());
|
section.setCreateBy(institutionUser.getInstitutionalName());
|
section.setCreateTime(LocalDateTime.now());
|
section.setUpdateBy(institutionUser.getInstitutionalName());
|
section.setUpdateTime(LocalDateTime.now());
|
section.setBatchUuid(batch.getUuid());
|
section.setChapterUuid(sectionReqDTO.getChapterUuid());
|
saveBatchCourseChapterList.add(section);
|
}
|
}
|
}
|
}
|
|
}
|
|
//插入班级数据
|
List<List<ThBatch>> splitSaveBatchList = ListUtil.split(saveBatchList, 500);
|
for (List<ThBatch> batchList : splitSaveBatchList) {
|
batchService.insertBatch(batchList);
|
}
|
//修改班级数据
|
List<List<ThBatch>> splitUpdateBatchList = ListUtil.split(updateBatchList, 500);
|
for (List<ThBatch> batchList : splitUpdateBatchList) {
|
batchService.updateBatch(batchList);
|
}
|
//插入课程
|
List<List<ThBatchCourse>> splitSaveBatchCourseList = ListUtil.split(saveBatchCourseList, 500);
|
for (List<ThBatchCourse> courseList : splitSaveBatchCourseList) {
|
batchCourseService.insertBatch(courseList);
|
}
|
//修改课程
|
List<List<ThBatchCourse>> splitUpdateBatchCourseList = ListUtil.split(updateBatchCourseList, 500);
|
for (List<ThBatchCourse> courseList : splitUpdateBatchCourseList) {
|
batchCourseService.updateBatch(courseList);
|
}
|
|
//插入章节
|
List<List<ThBatchCourseChapter>> splitSaveBatchCourseChapterList = ListUtil.split(saveBatchCourseChapterList, 500);
|
for (List<ThBatchCourseChapter> chapterList : splitSaveBatchCourseChapterList) {
|
batchCourseChapterService.insertBatch(chapterList);
|
}
|
//修改章节
|
List<List<ThBatchCourseChapter>> splitUpdateBatchCourseChapterList = ListUtil.split(updateBatchCourseChapterList, 500);
|
for (List<ThBatchCourseChapter> chapterList : splitUpdateBatchCourseChapterList) {
|
batchCourseChapterService.updateBatch(chapterList);
|
}
|
|
return AjaxResult.success(errorDataRespDTOS);
|
}
|
|
@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);
|
}
|
//反序列化
|
List<ThStudyDetailReqDTO> thStudyDetailReqDTOS = new ArrayList<>();
|
try {
|
thStudyDetailReqDTOS = JSONObject.parseObject(decrypt, new TypeReference<List<ThStudyDetailReqDTO>>() {});
|
}catch (Exception e){
|
logger.error("学习记录序列化失败!");
|
throw new BusinessException(this.getClass(), ResultConstants.SERIALIZE_ERROR);
|
}
|
//参数校验
|
if(CollectionUtils.isEmpty(thStudyDetailReqDTOS)){
|
throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"学习记录清单不可为空");
|
}
|
//获取班级学生以及章节
|
List<String> chapterUuids = new ArrayList<>();
|
List<String> idcards = new ArrayList<>();
|
List<String> studyUuids = new ArrayList<>();
|
for (ThStudyDetailReqDTO studentDetailReqDTO : thStudyDetailReqDTOS) {
|
if(!idcards.contains(studentDetailReqDTO.getIdcard()) && StringUtils.isNotEmpty(studentDetailReqDTO.getIdcard())){
|
idcards.add(studentDetailReqDTO.getIdcard());
|
}
|
if(!chapterUuids.contains(studentDetailReqDTO.getChapterUuid()) && StringUtils.isNotEmpty(studentDetailReqDTO.getChapterUuid())){
|
chapterUuids.add(studentDetailReqDTO.getChapterUuid());
|
}
|
studyUuids.add(studentDetailReqDTO.getUuid());
|
}
|
List<ThStudentBatch> thStudentBatches = studentBatchService.getByIdCards(idcards);
|
List<ThBatchCourseChapter> batchCourseChapters = batchCourseChapterService.getByChapterUuids(chapterUuids);
|
//校验
|
List<ThErrorDataRespDTO> errorDataRespDTOS = new ArrayList<>();
|
List<ThStudyDetailReqDTO> saveStudyDetailReqDTOS = new ArrayList<>();
|
for (ThStudyDetailReqDTO studentDetailReqDTO : thStudyDetailReqDTOS) {
|
if(StringUtils.isEmpty(studentDetailReqDTO.getUuid()) || !UUID.checkIsUuid(studentDetailReqDTO.getUuid())){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentDetailReqDTO.getUuid(),"学习记录uuid标识不规范"));
|
continue;
|
}
|
if(StringUtils.isEmpty(studentDetailReqDTO.getIdcard())){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentDetailReqDTO.getUuid(),"学生身份证不可为空"));
|
continue;
|
}
|
if(StringUtils.isEmpty(studentDetailReqDTO.getCourseUuid())){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentDetailReqDTO.getUuid(),"课程不可为空"));
|
continue;
|
}
|
if(StringUtils.isEmpty(studentDetailReqDTO.getBatchUuid())){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentDetailReqDTO.getUuid(),"批次不可为空"));
|
continue;
|
}
|
if(StringUtils.isEmpty(studentDetailReqDTO.getChapterUuid())){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentDetailReqDTO.getUuid(),"章节不可为空"));
|
continue;
|
}
|
//获取该平台课程
|
List<ThStudentBatch> StudentBatchSelectList = thStudentBatches.stream().filter(sb -> sb.getIdcard().equals(studentDetailReqDTO.getIdcard()) &&
|
sb.getBatchUuid().equals(studentDetailReqDTO.getBatchUuid())).collect(Collectors.toList());
|
studentBatchService.getByIdcardAndBatchUuid(studentDetailReqDTO.getIdcard(),studentDetailReqDTO.getBatchUuid());
|
List<ThBatchCourseChapter> chapterSelectList = batchCourseChapters.stream().filter(bcc -> bcc.getChapterUuid().equals(studentDetailReqDTO.getChapterUuid())
|
&& bcc.getCourseUuid().equals(studentDetailReqDTO.getCourseUuid()) && bcc.getBatchUuid().equals(studentDetailReqDTO.getBatchUuid())).collect(Collectors.toList());
|
if(StudentBatchSelectList.size() == 0){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentDetailReqDTO.getUuid(),"批次(班级)中学生信息不存在"));
|
continue;
|
}
|
if(chapterSelectList.size() == 0){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentDetailReqDTO.getUuid(),"课程章节不存在"));
|
continue;
|
}
|
if(StringUtils.isEmpty(studentDetailReqDTO.getTrainOrgName())){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentDetailReqDTO.getUuid(),"培训机构名称不可为空"));
|
continue;
|
}
|
if(studentDetailReqDTO.getFinishStatus() == null || FinishStatus.get(studentDetailReqDTO.getFinishStatus()) == null){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentDetailReqDTO.getUuid(),"完成状态不规范"));
|
continue;
|
}
|
if(studentDetailReqDTO.getDuration() == null){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentDetailReqDTO.getUuid(),"学习时长(秒)不可为空"));
|
continue;
|
}
|
if(studentDetailReqDTO.getStartTime() == null){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentDetailReqDTO.getUuid(),"开始时间不可为空"));
|
continue;
|
}
|
if(studentDetailReqDTO.getFinishTime() == null){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentDetailReqDTO.getUuid(),"结束时间不可为空"));
|
continue;
|
}
|
if(studentDetailReqDTO.getStartPosition() == null){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentDetailReqDTO.getUuid(),"开始位置不可为空"));
|
continue;
|
}
|
if(studentDetailReqDTO.getFinishPosition() == null){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentDetailReqDTO.getUuid(),"结束位置不可为空"));
|
continue;
|
}
|
if(StringUtils.isEmpty(studentDetailReqDTO.getLessonReportUrl())){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentDetailReqDTO.getUuid(),"学时报告不可为空"));
|
continue;
|
}
|
//认证记录集合
|
// if(CollectionUtils.isEmpty(studentDetailReqDTO.getAuthList())){
|
// errorDataRespDTOS.add(new ThErrorDataRespDTO(studentDetailReqDTO.getUuid(),"认证记录集合不可为空"));
|
// continue;
|
// }
|
//学习轨迹集合
|
if(CollectionUtils.isEmpty(studentDetailReqDTO.getTrackList())){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentDetailReqDTO.getUuid(),"学习轨迹集合不可为空"));
|
continue;
|
}
|
|
/*boolean authFlag = false;
|
for(ThStudytAuthReqDTO item : studentDetailReqDTO.getAuthList()){
|
if(StringUtils.isEmpty(item.getUuid()) || !UUID.checkIsUuid(item.getUuid())){
|
authFlag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentDetailReqDTO.getUuid(),"认证记录uuid("+item.getUuid()+")不符合规范"));
|
break;
|
}
|
if(StringUtils.isEmpty(item.getApprovePhoto())){
|
authFlag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentDetailReqDTO.getUuid(),"认证记录uuid("+item.getUuid()+"),认证照片不可为空"));
|
break;
|
}
|
if(item.getAuthPosition() == null){
|
authFlag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentDetailReqDTO.getUuid(),"认证记录uuid("+item.getUuid()+"),认证位置不可为空"));
|
break;
|
}
|
if(item.getAuthTime() == null){
|
authFlag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentDetailReqDTO.getUuid(),"认证记录uuid("+item.getUuid()+"),认证时间不可为空"));
|
break;
|
}
|
if(item.getFaceType() == null || FaceType.get(item.getFaceType()) == null){
|
authFlag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentDetailReqDTO.getUuid(),"认证记录uuid("+item.getUuid()+"),认证类型不规范"));
|
break;
|
}
|
}
|
if(authFlag){
|
continue;
|
}*/
|
boolean trackFlag = false;
|
for(ThStudyTrackReqDTO item : studentDetailReqDTO.getTrackList()){
|
if(StringUtils.isEmpty(item.getUuid()) || !UUID.checkIsUuid(item.getUuid())){
|
trackFlag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentDetailReqDTO.getUuid(),"学习轨迹uuid("+item.getUuid()+")不符合规范"));
|
break;
|
}
|
if(item.getStartTime() == null){
|
trackFlag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentDetailReqDTO.getUuid(),"学习轨迹uuid("+item.getUuid()+"),轨迹开始时间不可为空"));
|
break;
|
}
|
if(item.getEndTime() == null){
|
trackFlag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentDetailReqDTO.getUuid(),"学习轨迹uuid("+item.getUuid()+"),轨迹结束时间不可为空"));
|
break;
|
}
|
if(item.getTimeInterval() == null) {
|
trackFlag = true;
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(studentDetailReqDTO.getUuid(),"学习轨迹uuid("+item.getUuid()+"),时间间隔(秒)不可为空"));
|
break;
|
}
|
}
|
if(trackFlag){
|
continue;
|
}
|
saveStudyDetailReqDTOS.add(studentDetailReqDTO);
|
}
|
|
//获取历史记录
|
List<ThStudyDetail> oldThStudyDetails = studyDetailService.getByUuids(studyUuids);
|
List<ThStudyAuth> oldStudyAuthList = studyAuthService.getByStudyDetaiUuids(studyUuids);
|
List<ThStudyTrack> oldStudyTrackList = studyTrackService.getByStudyDetailUuids(studyUuids);
|
List<ThStudyDetail> saveStudyDetailList = new ArrayList<>();
|
List<ThStudyDetail> updateStudyDetailList = new ArrayList<>();
|
List<ThStudyAuth> saveStudyAuthList = new ArrayList<>();
|
List<ThStudyTrack> saveStudyTrackList = new ArrayList<>();
|
|
for(ThStudyDetailReqDTO studyDetailReqDTO : saveStudyDetailReqDTOS){
|
List<ThStudyDetail> oldStudyDetailList = oldThStudyDetails
|
.stream()
|
.filter(sd -> sd.getUuid().equals(studyDetailReqDTO.getUuid()))
|
.collect(Collectors.toList());
|
if(oldStudyDetailList.size() == 0){
|
//新增学习清单
|
ThStudyDetail 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());
|
saveStudyDetailList.add(thStudyDetail);
|
//新增认证记录
|
List<ThStudyAuth> thStudyAuthList = studyDetailReqDTO.getAuthList().stream().map(sa -> {
|
ThStudyAuth thStudyAuth = new ThStudyAuth();
|
BeanUtils.copyProperties(sa, thStudyAuth);
|
thStudyAuth.setStudyDetailUuid(studyDetailReqDTO.getUuid());
|
return thStudyAuth;
|
}).collect(Collectors.toList());
|
saveStudyAuthList.addAll(thStudyAuthList);
|
|
//新增学习轨迹
|
List<ThStudyTrack> thStudyTrackList = studyDetailReqDTO.getTrackList().stream().map(track -> {
|
ThStudyTrack thStudyTrack = new ThStudyTrack();
|
BeanUtils.copyProperties(track, thStudyTrack);
|
thStudyTrack.setStudyDetailUuid(studyDetailReqDTO.getUuid());
|
return thStudyTrack;
|
}).collect(Collectors.toList());
|
saveStudyTrackList.addAll(thStudyTrackList);
|
|
}else {
|
ThStudyDetail thStudyDetail = oldStudyDetailList.get(0);
|
//修改
|
BeanUtils.copyProperties(studyDetailReqDTO, thStudyDetail);
|
thStudyDetail.setUpdateBy(institutionUser.getInstitutionalName());
|
thStudyDetail.setUpdateTime(LocalDateTime.now());
|
updateStudyDetailList.add(thStudyDetail);
|
|
//过滤该记录的认证记录
|
List<String> authUuids = oldStudyAuthList
|
.stream()
|
.filter(a -> a.getStudyDetailUuid().equals(thStudyDetail.getUuid()))
|
.map(ThStudyAuth::getUuid).collect(Collectors.toList());
|
//过滤出记录的轨迹记录
|
List<String> trackUuids = oldStudyTrackList
|
.stream()
|
.filter(t -> t.getStudyDetailUuid().equals(thStudyDetail.getUuid()))
|
.map(ThStudyTrack::getUuid).collect(Collectors.toList());
|
List<ThStudyAuth> saveAuthList = studyDetailReqDTO.getAuthList().stream()
|
.filter(a -> !authUuids.contains(a.getUuid()))
|
.map(a -> {
|
ThStudyAuth thStudyAuth = new ThStudyAuth();
|
BeanUtils.copyProperties(a, thStudyAuth);
|
thStudyAuth.setStudyDetailUuid(studyDetailReqDTO.getUuid());
|
return thStudyAuth;
|
})
|
.collect(Collectors.toList());
|
saveStudyAuthList.addAll(saveAuthList);
|
|
List<ThStudyTrack> saveTrackList = studyDetailReqDTO.getTrackList().stream()
|
.filter(t -> !trackUuids.contains(t.getUuid()))
|
.map(t -> {
|
ThStudyTrack thStudyTrack = new ThStudyTrack();
|
BeanUtils.copyProperties(t, thStudyTrack);
|
thStudyTrack.setStudyDetailUuid(studyDetailReqDTO.getUuid());
|
return thStudyTrack;
|
}).collect(Collectors.toList());
|
saveStudyTrackList.addAll(saveTrackList);
|
}
|
}
|
//插入学习记录
|
List<List<ThStudyDetail>> splitSaveDetailList = ListUtil.split(saveStudyDetailList, 500);
|
for (List<ThStudyDetail> thStudyDetails : splitSaveDetailList) {
|
studyDetailService.insertBatch(thStudyDetails);
|
}
|
//修改学习记录
|
List<List<ThStudyDetail>> splitUpdateDetailList = ListUtil.split(updateStudyDetailList, 500);
|
for (List<ThStudyDetail> thStudyDetails : splitUpdateDetailList) {
|
studyDetailService.updateBatch(thStudyDetails);
|
}
|
//插入认证记录
|
List<List<ThStudyAuth>> splitSaveAuthList = ListUtil.split(saveStudyAuthList, 500);
|
for (List<ThStudyAuth> thStudyAuths : splitSaveAuthList) {
|
studyAuthService.insetBatch(thStudyAuths);
|
}
|
//插入学习轨迹
|
List<List<ThStudyTrack>> splitSaveTrackList = ListUtil.split(saveStudyTrackList, 500);
|
for (List<ThStudyTrack> thStudyTracks : splitSaveTrackList) {
|
studyTrackService.insertBatch(thStudyTracks);
|
}
|
return AjaxResult.success(errorDataRespDTOS);
|
}
|
|
@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<ThExamRecordReqDTO> examRecordReqDTOS = new ArrayList<>();
|
try {
|
examRecordReqDTOS = JSONObject.parseObject(decrypt, new TypeReference<List<ThExamRecordReqDTO>>() {});
|
}catch (Exception e){
|
logger.error("考试记录序列化失败!");
|
throw new BusinessException(this.getClass(), ResultConstants.SERIALIZE_ERROR);
|
}
|
if (CollectionUtils.isEmpty(examRecordReqDTOS)) {
|
throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"考试记录不可为空");
|
}
|
List<String> idcards = new ArrayList<>();
|
//List<String> batchUuids = new ArrayList<>();
|
List<String> examUuids = new ArrayList<>();
|
for (ThExamRecordReqDTO examRecordReqDTO : examRecordReqDTOS) {
|
if(!idcards.contains(examRecordReqDTO.getIdcard())){
|
idcards.add(examRecordReqDTO.getIdcard());
|
}
|
/*if(!batchUuids.contains(examRecordReqDTO.getBatchUuid())){
|
batchUuids.add(examRecordReqDTO.getBatchUuid());
|
}*/
|
examUuids.add(examRecordReqDTO.getUuid());
|
}
|
//参数校验
|
List<ThStudentBatch> studentBatchList = studentBatchService.getByIdCards(idcards);
|
List<ThExamRecord> oldExamRecordList = examRecordService.getByUuids(examUuids);
|
List<ThErrorDataRespDTO> errorDataRespDTOS = new ArrayList<>();
|
List<ThExamRecord> saveExamRecordList = new ArrayList<>();
|
|
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.getBatchUuid())){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(examRecordReqDTO.getUuid(),"批次(班级)不可为空"));
|
continue;
|
}
|
|
List<ThStudentBatch> thStudentCourses = studentBatchList.stream().filter(sc -> sc.getBatchUuid().equals(examRecordReqDTO.getBatchUuid())
|
&& sc.getIdcard().equals(examRecordReqDTO.getIdcard())).collect(Collectors.toList());
|
if(thStudentCourses.size() == 0){
|
errorDataRespDTOS.add(new ThErrorDataRespDTO(examRecordReqDTO.getUuid(),"无学生"+examRecordReqDTO.getIdcard()+"培训信息"));
|
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;
|
}
|
|
List<ThExamRecord> examRecordSelectList = oldExamRecordList.stream().filter(e -> e.getUuid().equals(examRecordReqDTO.getUuid())).collect(Collectors.toList());
|
if(examRecordSelectList.size() == 0){
|
//新增
|
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);
|
}
|
}
|
List<List<ThExamRecord>> splitSaveExamList = ListUtil.split(saveExamRecordList, 500);
|
for (List<ThExamRecord> list : splitSaveExamList) {
|
examRecordService.saveBatch(list);
|
}
|
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 = null;
|
try {
|
thCourseDeleteReqDTO = JSONObject.parseObject(decrypt, new TypeReference<ThCourseDeleteReqDTO>() {});
|
|
}catch (Exception e){
|
logger.error("课程删除反序列化失败!");
|
throw new BusinessException(this.getClass(), ResultConstants.SERIALIZE_ERROR);
|
|
}
|
if(thCourseDeleteReqDTO == null){
|
throw new BusinessException(ResultConstants.THREE_INSTITUTION_PARAMM_NULL);
|
}
|
if(StringUtils.isEmpty(thCourseDeleteReqDTO.getCourseUuid())){
|
throw new BusinessException(ResultConstants.THREE_INSTITUTION_PARAMM_NULL);
|
}
|
ThCourse thCourse = courseService.getByUuid(thCourseDeleteReqDTO.getCourseUuid());
|
List<ThCourseChapterVO> 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<ThCourseChapter> 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());
|
courseService.updateById(thCourse);
|
//删除章节
|
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 = null;
|
try {
|
thBatchOpenReqDTO = JSONObject.parseObject(decrypt, new TypeReference<ThBatchOpenReqDTO>() {});
|
}catch (Exception e){
|
logger.error("班级开始反序列化失败!");
|
throw new BusinessException(this.getClass(), ResultConstants.SERIALIZE_ERROR);
|
}
|
if(thBatchOpenReqDTO == null){
|
throw new BusinessException(this.getClass(),ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"批次(班级)不可为空");
|
}
|
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);
|
}
|
if(!thBatch.getStatus().equals(OpenStatus.NO.getStatus())){
|
throw new BusinessException(this.getClass(),ResultConstants.THREE_INSTITUTION_OTHER_ERROR,"已开班或已结束不可重新开班");
|
}
|
thBatch.setStatus(OpenStatus.START.getStatus());
|
thBatch.setUpdateTime(LocalDateTime.now());
|
thBatch.setUpdateBy(institutionUser.getInstitutionalName());
|
batchService.updateById(thBatch);
|
return AjaxResult.success();
|
}
|
@Transactional
|
@Override
|
public AjaxResult receiveBatchEnd(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 = null;
|
try {
|
thBatchEndReqDTO = JSONObject.parseObject(decrypt, new TypeReference<ThBatchEndReqDTO>() {});
|
}catch (Exception e){
|
logger.error("班级结束反序列化失败!");
|
throw new BusinessException(this.getClass(), ResultConstants.SERIALIZE_ERROR);
|
}
|
if(thBatchEndReqDTO == null){
|
throw new BusinessException(this.getClass(),ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"批次(班级)不可为空");
|
}
|
|
if(StringUtils.isEmpty(thBatchEndReqDTO.getBatchUuid())){
|
throw new BusinessException(this.getClass(),ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"批次(班级)不可为空");
|
}
|
ThBatch thBatch = batchService.getByUuid(thBatchEndReqDTO.getBatchUuid());
|
if(thBatch == null){
|
throw new BusinessException(ResultConstants.BATCH_IS_NOT_EXIST);
|
}
|
thBatch.setStatus(OpenStatus.END.getStatus());
|
thBatch.setUpdateTime(LocalDateTime.now());
|
thBatch.setUpdateBy(institutionUser.getInstitutionalName());
|
batchService.updateById(thBatch);
|
studentBatchService.updateFinishStatusByBatchUuid(thBatchEndReqDTO.getBatchUuid());
|
return AjaxResult.success();
|
}
|
|
|
private void validateStudyDetail(ThStudyDetailReqDTO studentDetailReqDTO) {
|
|
|
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(StringUtils.isEmpty(studentDetailReqDTO.getBatchUuid())){
|
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,"章节不可为空");
|
}
|
//获取该平台课程
|
ThStudentBatch thStudentBatch = studentBatchService.getByIdcardAndBatchUuid(studentDetailReqDTO.getIdcard(),studentDetailReqDTO.getBatchUuid());
|
ThBatchCourseChapter chapter = batchCourseChapterService.getByUuid(studentDetailReqDTO.getBatchUuid(),studentDetailReqDTO.getCourseUuid(),studentDetailReqDTO.getChapterUuid());
|
if(thStudentBatch == null){
|
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) {
|
|
}
|
|
/**
|
* 校验学生信息
|
* @param studentReqDTOS
|
*/
|
private void validateStudent(List<ThStudentReqDTO> studentReqDTOS, Long institutionId) {
|
if(CollectionUtils.isEmpty(studentReqDTOS)){
|
throw new BusinessException(this.getClass(), ResultConstants.THREE_INSTITUTION_PARAMM_NULL,"学生信息不可为空");
|
}
|
//获取所有该机构所有课程
|
List<ThCourse> 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<ThCourse> 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;
|
}
|
}
|