|
@@ -29,6 +29,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import javax.websocket.RemoteEndpoint;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -53,7 +54,6 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
|
private BasicUserCourseService basicUserCourseService;
|
|
|
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
public List<BasicCourse> listCoursesByUserId(Long userId) {
|
|
|
return this.baseMapper.listCoursesByUserId(userId);
|
|
@@ -97,7 +97,7 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
|
|
|
|
@Override
|
|
|
public BasicCourse findByCourseCode(String courseCode) {
|
|
|
- return this.getOne(new QueryWrapper<BasicCourse>().lambda().eq(BasicCourse::getCode,courseCode));
|
|
|
+ return this.getOne(new QueryWrapper<BasicCourse>().lambda().eq(BasicCourse::getCode, courseCode));
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -105,8 +105,8 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
|
public void createCourse(Long schoolId, String courseCode, String courseName) {
|
|
|
// 向'basic_course'表新增数据 - 教研分析用
|
|
|
List<BasicCourse> basicCourseList = this.list(new QueryWrapper<BasicCourse>().lambda()
|
|
|
- .eq(BasicCourse::getSchoolId,schoolId).eq(BasicCourse::getCode,courseCode));
|
|
|
- if (basicCourseList.size() > 0){
|
|
|
+ .eq(BasicCourse::getSchoolId, schoolId).eq(BasicCourse::getCode, courseCode));
|
|
|
+ if (basicCourseList.size() > 0) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("已存在学校id为【" + schoolId + "】,课程编号为【" + courseCode + "】的课程");
|
|
|
}
|
|
|
BasicCourse basicCourse = new BasicCourse();
|
|
@@ -122,15 +122,15 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
|
Long schoolId = SystemConstant.convertIdToLong(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
Set<Long> orgIds = teachcloudCommonService.listSubOrgIds(null);
|
|
|
courseName = SystemConstant.translateSpecificSign(courseName);
|
|
|
- return basicCourseMapper.findBasicCoursePage(new Page<>(pageNumber,pageSize),courseName,startCreateTime,endCreateTime,schoolId,orgIds);
|
|
|
+ return basicCourseMapper.findBasicCoursePage(new Page<>(pageNumber, pageSize), courseName, startCreateTime, endCreateTime, schoolId, orgIds);
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public Long saveBasicCourse(BasicCourseParams basicCourseParams,SysUser sysUser) {
|
|
|
+ public Long saveBasicCourse(BasicCourseParams basicCourseParams, SysUser sysUser) {
|
|
|
List<BasicCourseParams> basicCourseParamsList = new ArrayList<>();
|
|
|
basicCourseParamsList.add(basicCourseParams);
|
|
|
- BasicCourse editBasicCourse = this.editEntityHelp(basicCourseParamsList,sysUser).get(0);
|
|
|
+ BasicCourse editBasicCourse = this.editEntityHelp(basicCourseParamsList, sysUser).get(0);
|
|
|
this.saveOrUpdate(editBasicCourse);
|
|
|
return editBasicCourse.getId();
|
|
|
}
|
|
@@ -138,18 +138,18 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
public Boolean removeBasicCourseBatch(List<Long> idList) {
|
|
|
- if (idList.size() == 0){
|
|
|
+ if (idList.size() == 0) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("请选择要删除的目标");
|
|
|
}
|
|
|
SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
- basicUserCourseService.remove(new QueryWrapper<BasicUserCourse>().lambda().in(BasicUserCourse::getCourseId,idList).eq(BasicUserCourse::getSchoolId,sysUser.getSchoolId()));
|
|
|
+ basicUserCourseService.remove(new QueryWrapper<BasicUserCourse>().lambda().in(BasicUserCourse::getCourseId, idList).eq(BasicUserCourse::getSchoolId, sysUser.getSchoolId()));
|
|
|
|
|
|
UpdateWrapper<BasicCourse> updateWrapper = new UpdateWrapper<>();
|
|
|
updateWrapper.lambda()
|
|
|
- .set(BasicCourse::getEnable,false)
|
|
|
- .in(BasicCourse::getId,idList)
|
|
|
- .set(BasicCourse::getOrgId,sysUser.getOrgId())
|
|
|
- .set(BasicCourse::getUpdateId,sysUser.getId());
|
|
|
+ .set(BasicCourse::getEnable, false)
|
|
|
+ .in(BasicCourse::getId, idList)
|
|
|
+ .set(BasicCourse::getOrgId, sysUser.getOrgId())
|
|
|
+ .set(BasicCourse::getUpdateId, sysUser.getId());
|
|
|
|
|
|
return this.update(updateWrapper);
|
|
|
}
|
|
@@ -168,7 +168,7 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
|
LinkedMultiValueMap<Integer, Object> excelMap = finalList.get(i);
|
|
|
List<Object> basicCourseImportDtoList = excelMap.get(i);
|
|
|
assert basicCourseImportDtoList != null;
|
|
|
- if (basicCourseImportDtoList.get(0) instanceof DescribeImportDto){
|
|
|
+ if (basicCourseImportDtoList.get(0) instanceof DescribeImportDto) {
|
|
|
continue;
|
|
|
}
|
|
|
map.put("dataCount", basicCourseImportDtoList.size());
|
|
@@ -179,7 +179,7 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
|
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).eq(SysOrg::getName,teachingRoomName));
|
|
|
+ SysOrg sysOrg = sysOrgService.getOne(new QueryWrapper<SysOrg>().lambda().eq(SysOrg::getSchoolId, schoolId).eq(SysOrg::getEnable, true).eq(SysOrg::getType, OrgTypeEnum.TEACHING_ROOM).eq(SysOrg::getName, teachingRoomName));
|
|
|
if (Objects.isNull(sysOrg)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("输入的教研室【" + teachingRoomName + "】不存在");
|
|
|
}
|
|
@@ -190,20 +190,35 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
|
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)){
|
|
|
+ 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);
|
|
|
+ List<BasicCourse> editBasicCourse = this.editEntityHelp(addBasicCourseParamsList, sysUser);
|
|
|
this.saveOrUpdateBatch(editBasicCourse);
|
|
|
}
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
- private List<BasicCourse> editEntityHelp(List<BasicCourseParams> basicCourseParamsList,SysUser sysUser){
|
|
|
+ @Override
|
|
|
+ public Long getOrgIdBySchoolIdAndCourseCode(Long schoolId, String courseCode) {
|
|
|
+ if (Objects.isNull(schoolId)) {
|
|
|
+ schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
+ }
|
|
|
+ QueryWrapper<BasicCourse> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.lambda().eq(BasicCourse::getSchoolId, schoolId).eq(BasicCourse::getCode, courseCode);
|
|
|
+ BasicCourse basicCourse = this.getOne(queryWrapper);
|
|
|
+ if (Objects.isNull(basicCourse)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("课程不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ return basicCourse.getTeachingRoomId();
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<BasicCourse> editEntityHelp(List<BasicCourseParams> basicCourseParamsList, SysUser sysUser) {
|
|
|
Long schoolId = sysUser.getSchoolId();
|
|
|
List<BasicCourse> basicCourseList = new ArrayList<>();
|
|
|
for (BasicCourseParams basicCourseParams : basicCourseParamsList) {
|
|
@@ -212,25 +227,25 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
|
// 校验课程编号
|
|
|
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 +"】重复");
|
|
|
+ .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)))){
|
|
|
+ .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()){
|
|
|
+ if (clazzList.size() != clazzList.stream().distinct().count()) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("输入的班级重复");
|
|
|
}
|
|
|
|
|
@@ -242,17 +257,17 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
|
basicCourse.setTeachingRoomId(teachingRoomId);
|
|
|
basicCourse.setSchoolId(schoolId);
|
|
|
|
|
|
- if (!SystemConstant.longNotNull(id)){
|
|
|
+ if (!SystemConstant.longNotNull(id)) {
|
|
|
// 没有id -》新增
|
|
|
id = SystemConstant.getDbUuid();
|
|
|
basicCourse.setId(id);
|
|
|
basicCourse.setCreateId(sysUser.getId());
|
|
|
basicCourse.setEnable(true);
|
|
|
orgId = sysUser.getOrgId();
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
// 有id -》 更新
|
|
|
BasicCourse old = this.getById(id);
|
|
|
- if (Objects.isNull(old) || old.getEnable().equals(false)){
|
|
|
+ if (Objects.isNull(old) || old.getEnable().equals(false)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("课程主键不存在或被禁用");
|
|
|
}
|
|
|
orgId = old.getOrgId();
|
|
@@ -262,7 +277,7 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
|
|
|
basicCourse.setOrgId(orgId);
|
|
|
|
|
|
// 根据课程id和授课班级集合更新'basic_user_course'表
|
|
|
- basicUserCourseService.updateByCourseIdAndClazzList(id,clazzList,sysUser,orgId);
|
|
|
+ basicUserCourseService.updateByCourseIdAndClazzList(id, clazzList, sysUser, orgId);
|
|
|
|
|
|
basicCourseList.add(basicCourse);
|
|
|
}
|