|
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.qmth.teachcloud.common.bean.dto.CourseInfoDto;
|
|
import com.qmth.teachcloud.common.bean.dto.CourseInfoDto;
|
|
|
|
+import com.qmth.teachcloud.common.bean.dto.excel.BasicCourseImportDto;
|
|
import com.qmth.teachcloud.common.bean.params.BasicCourseParams;
|
|
import com.qmth.teachcloud.common.bean.params.BasicCourseParams;
|
|
import com.qmth.teachcloud.common.bean.result.BasicCourseResult;
|
|
import com.qmth.teachcloud.common.bean.result.BasicCourseResult;
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
@@ -13,7 +14,6 @@ import com.qmth.teachcloud.common.entity.BasicCourse;
|
|
import com.qmth.teachcloud.common.entity.SysOrg;
|
|
import com.qmth.teachcloud.common.entity.SysOrg;
|
|
import com.qmth.teachcloud.common.entity.SysUser;
|
|
import com.qmth.teachcloud.common.entity.SysUser;
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
-import com.qmth.teachcloud.common.enums.OrgCenterTypeEnum;
|
|
|
|
import com.qmth.teachcloud.common.enums.OrgTypeEnum;
|
|
import com.qmth.teachcloud.common.enums.OrgTypeEnum;
|
|
import com.qmth.teachcloud.common.mapper.BasicCourseMapper;
|
|
import com.qmth.teachcloud.common.mapper.BasicCourseMapper;
|
|
import com.qmth.teachcloud.common.service.BasicCourseService;
|
|
import com.qmth.teachcloud.common.service.BasicCourseService;
|
|
@@ -21,15 +21,12 @@ import com.qmth.teachcloud.common.service.BasicUserCourseService;
|
|
import com.qmth.teachcloud.common.service.SysOrgService;
|
|
import com.qmth.teachcloud.common.service.SysOrgService;
|
|
import com.qmth.teachcloud.common.service.TeachcloudCommonService;
|
|
import com.qmth.teachcloud.common.service.TeachcloudCommonService;
|
|
import com.qmth.teachcloud.common.util.ServletUtil;
|
|
import com.qmth.teachcloud.common.util.ServletUtil;
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+import org.springframework.util.LinkedMultiValueMap;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
-import java.util.List;
|
|
|
|
-import java.util.Objects;
|
|
|
|
-import java.util.Set;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
@@ -126,63 +123,12 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Override
|
|
@Override
|
|
- public Long saveBasicCourse(BasicCourseParams basicCourseParams) {
|
|
|
|
- SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
|
- Long schoolId = sysUser.getSchoolId();
|
|
|
|
- Long id = basicCourseParams.getId();
|
|
|
|
- String courseName = basicCourseParams.getCourseName();
|
|
|
|
- // 校验课程编号
|
|
|
|
- String courseCode = basicCourseParams.getCourseCode();
|
|
|
|
- BasicCourse checkCode = this.getOne(new QueryWrapper<BasicCourse>().lambda()
|
|
|
|
- .eq(BasicCourse::getCode,courseCode)
|
|
|
|
- .eq(BasicCourse::getSchoolId,schoolId)
|
|
|
|
- .eq(BasicCourse::getEnable,true));
|
|
|
|
- if (Objects.nonNull(checkCode)){
|
|
|
|
- if (!checkCode.getId().equals(id)){
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("课程编号【" + courseCode +"】重复");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- // 校验教研室id
|
|
|
|
- Long teachingRoomId = basicCourseParams.getTeachingRoomId();
|
|
|
|
- if (Objects.isNull(sysOrgService.getOne(new QueryWrapper<SysOrg>().lambda()
|
|
|
|
- .eq(SysOrg::getId,teachingRoomId)
|
|
|
|
- .eq(SysOrg::getEnable,true)
|
|
|
|
- .eq(SysOrg::getType, OrgTypeEnum.TEACHING_ROOM)))){
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("所选教研室不存在");
|
|
|
|
- }
|
|
|
|
- // 校验班级
|
|
|
|
- List<String> clazzList = basicCourseParams.getClazzList();
|
|
|
|
- if (clazzList.size() != clazzList.stream().distinct().count()){
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("输入的班级重复");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //基础数据组装
|
|
|
|
- BasicCourse basicCourse = new BasicCourse();
|
|
|
|
- basicCourse.setName(courseName);
|
|
|
|
- basicCourse.setCode(courseCode);
|
|
|
|
- basicCourse.setTeachingRoomId(teachingRoomId);
|
|
|
|
- basicCourse.setSchoolId(schoolId);
|
|
|
|
-
|
|
|
|
- if (!SystemConstant.longNotNull(id)){
|
|
|
|
- // 没有id -》新增
|
|
|
|
- id = SystemConstant.getDbUuid();
|
|
|
|
- basicCourse.setId(id);
|
|
|
|
- basicCourse.setCreateId(sysUser.getId());
|
|
|
|
- basicCourse.setEnable(true);
|
|
|
|
- }else {
|
|
|
|
- // 有id -》 更新
|
|
|
|
- basicCourse.setId(id);
|
|
|
|
- basicCourse.setUpdateId(sysUser.getId());
|
|
|
|
- basicCourse.setOrgId(sysUser.getOrgId());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 根据课程id和授课班级集合更新'basic_user_course'表
|
|
|
|
- basicUserCourseService.updateByCourseIdAndClazzList(id,clazzList,sysUser);
|
|
|
|
-
|
|
|
|
- // 新增或更新基础课程表
|
|
|
|
- this.saveOrUpdate(basicCourse);
|
|
|
|
-
|
|
|
|
- return id;
|
|
|
|
|
|
+ public Long saveBasicCourse(BasicCourseParams basicCourseParams,SysUser sysUser) {
|
|
|
|
+ List<BasicCourseParams> basicCourseParamsList = new ArrayList<>();
|
|
|
|
+ basicCourseParamsList.add(basicCourseParams);
|
|
|
|
+ BasicCourse editBasicCourse = this.editEntityHelp(basicCourseParamsList,sysUser).get(0);
|
|
|
|
+ this.saveOrUpdate(editBasicCourse);
|
|
|
|
+ return editBasicCourse.getId();
|
|
}
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -202,4 +148,112 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
|
|
|
|
return this.update(updateWrapper);
|
|
return this.update(updateWrapper);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ @Override
|
|
|
|
+ public Map<String, Object> executeBasicCourseImportLogic(List<LinkedMultiValueMap<Integer, Object>> finalList, Map<String, Object> map) {
|
|
|
|
+ // 班级分割标志
|
|
|
|
+ final String clazzSplit = ",";
|
|
|
|
+
|
|
|
|
+ SysUser sysUser = (SysUser) map.get(SystemConstant.SYS_USER);
|
|
|
|
+ Long schoolId = sysUser.getSchoolId();
|
|
|
|
+ List<BasicCourseParams> addBasicCourseParamsList = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < finalList.size(); i++) {
|
|
|
|
+ LinkedMultiValueMap<Integer, Object> excelMap = finalList.get(i);
|
|
|
|
+ List<Object> basicCourseImportDtoList = excelMap.get(i);
|
|
|
|
+ List<BasicCourseImportDto> datasource = Collections.singletonList((BasicCourseImportDto) excelMap.get(i));
|
|
|
|
+ // TODO: 2021/7/16 校验datasource集合的正确性
|
|
|
|
+ map.put("dataCount", datasource.size());
|
|
|
|
+ System.out.println("datasource:\n" + datasource);
|
|
|
|
+
|
|
|
|
+ for (int y = 0; y < Objects.requireNonNull(basicCourseImportDtoList).size(); y++) {
|
|
|
|
+ BasicCourseImportDto basicCourseImportDto = (BasicCourseImportDto) basicCourseImportDtoList.get(y);
|
|
|
|
+ String courseName = basicCourseImportDto.getCourseName();
|
|
|
|
+ String courseCode = basicCourseImportDto.getCourseCode();
|
|
|
|
+ String teachingRoomName = basicCourseImportDto.getTeachingRoomName();
|
|
|
|
+ String clazz = basicCourseImportDto.getClazz();
|
|
|
|
+
|
|
|
|
+ SysOrg sysOrg = sysOrgService.getOne(new QueryWrapper<SysOrg>().lambda().eq(SysOrg::getSchoolId, schoolId).eq(SysOrg::getEnable, true).eq(SysOrg::getType, OrgTypeEnum.TEACHING_ROOM));
|
|
|
|
+ if (Objects.isNull(sysOrg)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("输入的教研室【" + teachingRoomName + "】不存在");
|
|
|
|
+ }
|
|
|
|
+ Long teachingRoomId = sysOrg.getId();
|
|
|
|
+ List<String> clazzList = Arrays.asList(clazz.split(clazzSplit));
|
|
|
|
+ BasicCourseParams basicCourseParams = new BasicCourseParams();
|
|
|
|
+ basicCourseParams.setCourseCode(courseCode);
|
|
|
|
+ basicCourseParams.setCourseName(courseName);
|
|
|
|
+ basicCourseParams.setTeachingRoomId(teachingRoomId);
|
|
|
|
+ basicCourseParams.setClazzList(clazzList);
|
|
|
|
+ BasicCourse old = this.getOne(new QueryWrapper<BasicCourse>().lambda().eq(BasicCourse::getSchoolId,schoolId).eq(BasicCourse::getEnable,true).eq(BasicCourse::getCode,courseCode));
|
|
|
|
+ if (Objects.nonNull(old)){
|
|
|
|
+ basicCourseParams.setId(old.getId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ addBasicCourseParamsList.add(basicCourseParams);
|
|
|
|
+ }
|
|
|
|
+ List<BasicCourse> editBasicCourse = this.editEntityHelp(addBasicCourseParamsList,sysUser);
|
|
|
|
+ this.saveOrUpdateBatch(editBasicCourse);
|
|
|
|
+ }
|
|
|
|
+ return map;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<BasicCourse> editEntityHelp(List<BasicCourseParams> basicCourseParamsList,SysUser sysUser){
|
|
|
|
+ Long schoolId = sysUser.getSchoolId();
|
|
|
|
+ List<BasicCourse> basicCourseList = new ArrayList<>();
|
|
|
|
+ for (BasicCourseParams basicCourseParams : basicCourseParamsList) {
|
|
|
|
+ Long id = basicCourseParams.getId();
|
|
|
|
+ String courseName = basicCourseParams.getCourseName();
|
|
|
|
+ // 校验课程编号
|
|
|
|
+ String courseCode = basicCourseParams.getCourseCode();
|
|
|
|
+ BasicCourse checkCode = this.getOne(new QueryWrapper<BasicCourse>().lambda()
|
|
|
|
+ .eq(BasicCourse::getCode,courseCode)
|
|
|
|
+ .eq(BasicCourse::getSchoolId,schoolId)
|
|
|
|
+ .eq(BasicCourse::getEnable,true));
|
|
|
|
+ if (Objects.nonNull(checkCode)){
|
|
|
|
+ if (!checkCode.getId().equals(id)){
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("课程编号【" + courseCode +"】重复");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 校验教研室id
|
|
|
|
+ Long teachingRoomId = basicCourseParams.getTeachingRoomId();
|
|
|
|
+ if (Objects.isNull(sysOrgService.getOne(new QueryWrapper<SysOrg>().lambda()
|
|
|
|
+ .eq(SysOrg::getId,teachingRoomId)
|
|
|
|
+ .eq(SysOrg::getEnable,true)
|
|
|
|
+ .eq(SysOrg::getType, OrgTypeEnum.TEACHING_ROOM)))){
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("所选教研室不存在");
|
|
|
|
+ }
|
|
|
|
+ // 校验班级
|
|
|
|
+ List<String> clazzList = basicCourseParams.getClazzList();
|
|
|
|
+ if (clazzList.size() != clazzList.stream().distinct().count()){
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("输入的班级重复");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //基础数据组装
|
|
|
|
+ BasicCourse basicCourse = new BasicCourse();
|
|
|
|
+ basicCourse.setName(courseName);
|
|
|
|
+ basicCourse.setCode(courseCode);
|
|
|
|
+ basicCourse.setTeachingRoomId(teachingRoomId);
|
|
|
|
+ basicCourse.setSchoolId(schoolId);
|
|
|
|
+
|
|
|
|
+ if (!SystemConstant.longNotNull(id)){
|
|
|
|
+ // 没有id -》新增
|
|
|
|
+ id = SystemConstant.getDbUuid();
|
|
|
|
+ basicCourse.setId(id);
|
|
|
|
+ basicCourse.setCreateId(sysUser.getId());
|
|
|
|
+ basicCourse.setEnable(true);
|
|
|
|
+ }else {
|
|
|
|
+ // 有id -》 更新
|
|
|
|
+ basicCourse.setId(id);
|
|
|
|
+ basicCourse.setUpdateId(sysUser.getId());
|
|
|
|
+ basicCourse.setOrgId(sysUser.getOrgId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 根据课程id和授课班级集合更新'basic_user_course'表
|
|
|
|
+ basicUserCourseService.updateByCourseIdAndClazzList(id,clazzList,sysUser);
|
|
|
|
+
|
|
|
|
+ basicCourseList.add(basicCourse);
|
|
|
|
+ }
|
|
|
|
+ return basicCourseList;
|
|
|
|
+ }
|
|
}
|
|
}
|