|
@@ -3,9 +3,16 @@ package com.zhongzheng.modules.course.service.impl;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.lang.Validator;
|
|
import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.zhongzheng.common.core.redis.RedisCache;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
import com.zhongzheng.common.utils.ServletUtils;
|
|
import com.zhongzheng.common.utils.ServletUtils;
|
|
|
|
|
+import com.zhongzheng.modules.bank.bo.QuestionAddBo;
|
|
|
|
|
+import com.zhongzheng.modules.bank.bo.QuestionBusinessAddBo;
|
|
|
|
|
+import com.zhongzheng.modules.bank.domain.Question;
|
|
|
|
|
+import com.zhongzheng.modules.bank.domain.QuestionBusiness;
|
|
|
|
|
+import com.zhongzheng.modules.bank.vo.QuestionImport;
|
|
|
import com.zhongzheng.modules.course.bo.CourseSectionAddBo;
|
|
import com.zhongzheng.modules.course.bo.CourseSectionAddBo;
|
|
|
import com.zhongzheng.modules.course.bo.CourseSectionBusinessAddBo;
|
|
import com.zhongzheng.modules.course.bo.CourseSectionBusinessAddBo;
|
|
|
import com.zhongzheng.modules.course.bo.CourseSectionEditBo;
|
|
import com.zhongzheng.modules.course.bo.CourseSectionEditBo;
|
|
@@ -13,6 +20,7 @@ import com.zhongzheng.modules.course.bo.CourseSectionQueryBo;
|
|
|
import com.zhongzheng.modules.course.domain.*;
|
|
import com.zhongzheng.modules.course.domain.*;
|
|
|
import com.zhongzheng.modules.course.mapper.CourseSectionMapper;
|
|
import com.zhongzheng.modules.course.mapper.CourseSectionMapper;
|
|
|
import com.zhongzheng.modules.course.service.*;
|
|
import com.zhongzheng.modules.course.service.*;
|
|
|
|
|
+import com.zhongzheng.modules.course.vo.CourseSectionImport;
|
|
|
import com.zhongzheng.modules.course.vo.CourseSectionVo;
|
|
import com.zhongzheng.modules.course.vo.CourseSectionVo;
|
|
|
import com.zhongzheng.modules.system.domain.SysRoleMenu;
|
|
import com.zhongzheng.modules.system.domain.SysRoleMenu;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -21,10 +29,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.pagehelper.Page;
|
|
import com.github.pagehelper.Page;
|
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
-import java.util.Collection;
|
|
|
|
|
-import java.util.Collections;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
|
|
+import java.text.ParseException;
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -48,6 +58,20 @@ public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, C
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ICourseChapterSectionService iCourseChapterSectionService;
|
|
private ICourseChapterSectionService iCourseChapterSectionService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private RedisCache redisCache;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ICourseEducationTypeService iCourseEducationTypeService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ICourseProjectTypeService iCourseProjectTypeService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ICourseBusinessService iCourseBusinessService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ICourseSubjectService iCourseSubjectService;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public CourseSectionVo queryById(Long sectionId){
|
|
public CourseSectionVo queryById(Long sectionId){
|
|
|
CourseSection db = this.baseMapper.selectById(sectionId);
|
|
CourseSection db = this.baseMapper.selectById(sectionId);
|
|
@@ -160,6 +184,109 @@ public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, C
|
|
|
return this.removeByIds(ids);
|
|
return this.removeByIds(ids);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String importSection(List<CourseSectionImport> sectionList, Boolean isUpdateSupport, String operName) throws ParseException {
|
|
|
|
|
+ if (Validator.isNull(sectionList) || sectionList.size() == 0) {
|
|
|
|
|
+ throw new CustomException("导入数据不能为空!");
|
|
|
|
|
+ }
|
|
|
|
|
+ String errorLog = "";
|
|
|
|
|
+ String importNo = ServletUtils.getEncoded("IMPORT");
|
|
|
|
|
+ int i=10;
|
|
|
|
|
+ for (CourseSectionImport sectionImport : sectionList) {
|
|
|
|
|
+ CourseSectionAddBo bo = new CourseSectionAddBo();
|
|
|
|
|
+ if(!Validator.isNotEmpty(sectionImport.getName())){
|
|
|
|
|
+ errorLog+="节标题空白\n";
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(!Validator.isNotEmpty(sectionImport.getPrefixName())){
|
|
|
|
|
+ errorLog+="标题前缀空白\n";
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(!Validator.isNotEmpty(sectionImport.getPrefixName())){
|
|
|
|
|
+ errorLog+="标题前缀空白\n";
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ System.out.println(sectionImport);
|
|
|
|
|
+ if(!Validator.isNotEmpty(sectionImport.getPublishStatus())){
|
|
|
|
|
+ errorLog+="发布状态空白\n";
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ //业务层次,导入每条只有一条业务层次
|
|
|
|
|
+ List<CourseSectionBusinessAddBo> businessList = new ArrayList<>();
|
|
|
|
|
+ CourseSectionBusinessAddBo addBo = new CourseSectionBusinessAddBo();
|
|
|
|
|
+ Long eduId = findEduId(sectionImport.getEducationType());
|
|
|
|
|
+ if(!Validator.isNotEmpty(eduId)){
|
|
|
|
|
+ errorLog+=sectionImport.getEducationType()+"-该教育类型不存在\n";
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ Long projectId = findProjectId(sectionImport.getProject());
|
|
|
|
|
+ if(!Validator.isNotEmpty(projectId)){
|
|
|
|
|
+ errorLog+=sectionImport.getProject()+"-该项目类型不存在\n";
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ Long businessId = findBusinessId(sectionImport.getBusiness());
|
|
|
|
|
+ if(!Validator.isNotEmpty(businessId)){
|
|
|
|
|
+ errorLog+=sectionImport.getBusiness()+"-该业务层次不存在\n";
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ Long subjectId = findSubjectId(sectionImport.getSubject());
|
|
|
|
|
+ if(!Validator.isNotEmpty(subjectId)){
|
|
|
|
|
+ errorLog+=sectionImport.getSubject()+"-该科目不存在\n";
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ addBo.setEducationTypeId(eduId);
|
|
|
|
|
+ addBo.setProjectId(projectId);
|
|
|
|
|
+ addBo.setBusinessId(businessId);
|
|
|
|
|
+ addBo.setSubjectId(subjectId);
|
|
|
|
|
+ businessList.add(addBo);
|
|
|
|
|
+
|
|
|
|
|
+ bo.setPrefixName(sectionImport.getPrefixName());
|
|
|
|
|
+ bo.setName(sectionImport.getName());
|
|
|
|
|
+ bo.setName(sectionImport.getName());
|
|
|
|
|
+ bo.setBusinessList(businessList);
|
|
|
|
|
+ bo.setImportBy(operName);
|
|
|
|
|
+ bo.setImportNo(importNo);
|
|
|
|
|
+ bo.setSectionType(findType(sectionImport.getSectionType()));
|
|
|
|
|
+ bo.setDurationTime(sectionImport.getDurationTime());
|
|
|
|
|
+ bo.setRecordingUrl(sectionImport.getRecordingUrl());
|
|
|
|
|
+ bo.setLiveUrl(sectionImport.getLiveUrl());
|
|
|
|
|
+ bo.setPublishStatus(sectionImport.getPublishStatus().equals("发布")?1:0);
|
|
|
|
|
+ bo.setStatus(1);
|
|
|
|
|
+ bo.setCoverUrl("oss/images/avatar/20211013/1634097664410_1397766697");
|
|
|
|
|
+ if(Validator.isNotEmpty(sectionImport.getLiveStartTime())){
|
|
|
|
|
+ Long startTime = sectionImport.getLiveStartTime().getTime()/1000;
|
|
|
|
|
+ bo.setLiveStartTime(startTime);
|
|
|
|
|
+ }
|
|
|
|
|
+ if(Validator.isNotEmpty(sectionImport.getLiveEndTime())){
|
|
|
|
|
+ Long endTime = sectionImport.getLiveEndTime().getTime()/1000;
|
|
|
|
|
+ bo.setLiveEndTime(endTime);
|
|
|
|
|
+ }
|
|
|
|
|
+ errorLog = insertByAddBoImport(bo,errorLog,i);
|
|
|
|
|
+ i++;
|
|
|
|
|
+ }
|
|
|
|
|
+ return errorLog;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public String insertByAddBoImport(CourseSectionAddBo bo, String errorLog, Integer no) {
|
|
|
|
|
+ CourseSection add = BeanUtil.toBean(bo, CourseSection.class);
|
|
|
|
|
+ add.setCode(ServletUtils.getEncoded("J"));
|
|
|
|
|
+ validEntityBeforeSave(add);
|
|
|
|
|
+ add.setCreateTime(DateUtils.getNowTime());
|
|
|
|
|
+ add.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
|
+ boolean result = this.save(add);
|
|
|
|
|
+ if(bo.getBusinessList()!=null){
|
|
|
|
|
+ Collection<QuestionBusiness> coll = new HashSet<>();
|
|
|
|
|
+ for(int i=0;i<bo.getBusinessList().size();i++){
|
|
|
|
|
+ CourseSectionBusinessAddBo item = bo.getBusinessList().get(i);
|
|
|
|
|
+ CourseSectionBusiness addItem = BeanUtil.toBean(item, CourseSectionBusiness.class);
|
|
|
|
|
+ item.setSectionId(add.getSectionId());
|
|
|
|
|
+ iCourseSectionBusinessService.insertByAddBo(item);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return errorLog;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private boolean checkNameUnique(CourseSection entity) {
|
|
private boolean checkNameUnique(CourseSection entity) {
|
|
|
CourseSection info = getOne(new LambdaQueryWrapper<CourseSection>()
|
|
CourseSection info = getOne(new LambdaQueryWrapper<CourseSection>()
|
|
|
.eq(CourseSection::getPrefixName,entity.getPrefixName()).eq(CourseSection::getName,entity.getName()).ne(CourseSection::getStatus,-1).last("limit 1"));
|
|
.eq(CourseSection::getPrefixName,entity.getPrefixName()).eq(CourseSection::getName,entity.getName()).ne(CourseSection::getStatus,-1).last("limit 1"));
|
|
@@ -174,4 +301,105 @@ public class CourseSectionServiceImpl extends ServiceImpl<CourseSectionMapper, C
|
|
|
}
|
|
}
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public Integer findType(String type){
|
|
|
|
|
+ if("录播".equals(type)){
|
|
|
|
|
+ return 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ else if("直播".equals(type)){
|
|
|
|
|
+ return 2;
|
|
|
|
|
+ }
|
|
|
|
|
+ else if("回放".equals(type)){
|
|
|
|
|
+ return 3;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public Long findEduId(String edu){
|
|
|
|
|
+ if(edu!=null){
|
|
|
|
|
+ String key = "EDU_"+edu;
|
|
|
|
|
+ Long value = redisCache.getCacheObject(key);
|
|
|
|
|
+ if(value!=null){
|
|
|
|
|
+ if(value==0L){
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ return value;
|
|
|
|
|
+ }
|
|
|
|
|
+ CourseEducationType info = iCourseEducationTypeService.getOne(new LambdaQueryWrapper<CourseEducationType>()
|
|
|
|
|
+ .eq(CourseEducationType::getEducationName,edu));
|
|
|
|
|
+ if(info!=null){
|
|
|
|
|
+ redisCache.setCacheObject(key,info.getId(),3, TimeUnit.MINUTES);//3分钟
|
|
|
|
|
+ return info.getId();
|
|
|
|
|
+ }else{
|
|
|
|
|
+ redisCache.setCacheObject(key,0L,3, TimeUnit.MINUTES);//3分钟
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public Long findProjectId(String project){
|
|
|
|
|
+ if(project!=null){
|
|
|
|
|
+ String key = "PROJ_"+project;
|
|
|
|
|
+ Long value = redisCache.getCacheObject(key);
|
|
|
|
|
+ if(value!=null){
|
|
|
|
|
+ if(value==0L){
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ return value;
|
|
|
|
|
+ }
|
|
|
|
|
+ CourseProjectType info = iCourseProjectTypeService.getOne(new LambdaQueryWrapper<CourseProjectType>()
|
|
|
|
|
+ .eq(CourseProjectType::getProjectName,project).eq(CourseProjectType::getStatus,1).last("limit 1"));
|
|
|
|
|
+ if(info!=null){
|
|
|
|
|
+ redisCache.setCacheObject(key,info.getId(),3, TimeUnit.MINUTES);//3分钟
|
|
|
|
|
+ return info.getId();
|
|
|
|
|
+ }else{
|
|
|
|
|
+ redisCache.setCacheObject(key,0L,3, TimeUnit.MINUTES);//3分钟
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public Long findBusinessId(String business){
|
|
|
|
|
+ if(business!=null){
|
|
|
|
|
+ String key = "BUS_"+business;
|
|
|
|
|
+ Long value = redisCache.getCacheObject(key);
|
|
|
|
|
+ if(value!=null){
|
|
|
|
|
+ if(value==0L){
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ return value;
|
|
|
|
|
+ }
|
|
|
|
|
+ CourseBusiness info = iCourseBusinessService.getOne(new LambdaQueryWrapper<CourseBusiness>()
|
|
|
|
|
+ .eq(CourseBusiness::getBusinessName,business).eq(CourseBusiness::getStatus,1).last("limit 1"));
|
|
|
|
|
+ if(info!=null){
|
|
|
|
|
+ redisCache.setCacheObject(key,info.getId(),3, TimeUnit.MINUTES);//3分钟
|
|
|
|
|
+ return info.getId();
|
|
|
|
|
+ }else{
|
|
|
|
|
+ redisCache.setCacheObject(key,0L,3, TimeUnit.MINUTES);//3分钟
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public Long findSubjectId(String subject){
|
|
|
|
|
+ if(subject!=null){
|
|
|
|
|
+ String key = "SUB_"+subject;
|
|
|
|
|
+ Long value = redisCache.getCacheObject(key);
|
|
|
|
|
+ if(value!=null){
|
|
|
|
|
+ if(value==0L){
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ return value;
|
|
|
|
|
+ }
|
|
|
|
|
+ CourseSubject info = iCourseSubjectService.getOne(new LambdaQueryWrapper<CourseSubject>()
|
|
|
|
|
+ .eq(CourseSubject::getSubjectName,subject).eq(CourseSubject::getStatus,1).last("limit 1"));
|
|
|
|
|
+ if(info!=null){
|
|
|
|
|
+ redisCache.setCacheObject(key,info.getId(),3, TimeUnit.MINUTES);//3分钟
|
|
|
|
|
+ return info.getId();
|
|
|
|
|
+ }else{
|
|
|
|
|
+ redisCache.setCacheObject(key,0L,3, TimeUnit.MINUTES);//3分钟
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|