|
@@ -1,23 +1,21 @@
|
|
|
package com.qmth.teachcloud.common.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.qmth.teachcloud.common.bean.dto.TaskPrintClassDto;
|
|
|
import com.qmth.teachcloud.common.bean.dto.excel.BasicStudentImportDto;
|
|
|
+import com.qmth.teachcloud.common.bean.dto.excel.DescribeImportDto;
|
|
|
+import com.qmth.teachcloud.common.bean.params.BasicClazzParams;
|
|
|
+import com.qmth.teachcloud.common.bean.params.BasicMajorParams;
|
|
|
import com.qmth.teachcloud.common.bean.params.BasicStudentParams;
|
|
|
import com.qmth.teachcloud.common.bean.result.BasicStudentResult;
|
|
|
-import com.qmth.teachcloud.common.entity.BasicClazz;
|
|
|
-import com.qmth.teachcloud.common.entity.BasicMajor;
|
|
|
-import com.qmth.teachcloud.common.entity.BasicStudent;
|
|
|
-import com.qmth.teachcloud.common.mapper.BasicStudentMapper;
|
|
|
-import com.qmth.teachcloud.common.service.*;
|
|
|
-import com.qmth.teachcloud.common.bean.dto.excel.DescribeImportDto;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
-import com.qmth.teachcloud.common.entity.SysUser;
|
|
|
+import com.qmth.teachcloud.common.entity.*;
|
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
+import com.qmth.teachcloud.common.mapper.BasicStudentMapper;
|
|
|
+import com.qmth.teachcloud.common.service.*;
|
|
|
import com.qmth.teachcloud.common.util.ServletUtil;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -46,6 +44,8 @@ public class BasicStudentServiceImpl extends ServiceImpl<BasicStudentMapper, Bas
|
|
|
private BasicMajorService basicMajorService;
|
|
|
@Resource
|
|
|
private SysOrgService sysOrgService;
|
|
|
+ @Resource
|
|
|
+ private BasicCampusService basicCampusService;
|
|
|
|
|
|
@Override
|
|
|
public IPage<BasicStudentResult> basicStudentPage(String queryParams,Long campusId, Set<Long> clazzIdList,int pageNumber, int pageSize) {
|
|
@@ -90,9 +90,18 @@ public class BasicStudentServiceImpl extends ServiceImpl<BasicStudentMapper, Bas
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public Map<String, Object> executeBasicStudentImportLogic(List<LinkedMultiValueMap<Integer, Object>> finalList, Map<String, Object> map) {
|
|
|
+ public Map<String, Object> executeBasicStudentImportLogic(List<LinkedMultiValueMap<Integer, Object>> finalList, Map<String, Object> map) throws IllegalAccessException {
|
|
|
SysUser sysUser = (SysUser) map.get(SystemConstant.SYS_USER);
|
|
|
Long schoolId = sysUser.getSchoolId();
|
|
|
+ final String link = "-";
|
|
|
+ // key = campusName
|
|
|
+ Map<String,BasicCampus> campusMap = new HashMap<>();
|
|
|
+ // key = collegeName
|
|
|
+ Map<String,SysOrg> collegeMap = new HashMap<>();
|
|
|
+ // key = collegeId + "-" + majorName
|
|
|
+ Map<String,Long> majorMap = new HashMap<>();
|
|
|
+ // key = majorId + "-" + clazzName
|
|
|
+ Map<String,Long> clazzMap = new HashMap<>();
|
|
|
|
|
|
List<BasicStudentParams> addBasicStudentParamsList = new ArrayList<>();
|
|
|
for (int i = 0; i < finalList.size(); i++) {
|
|
@@ -117,21 +126,119 @@ public class BasicStudentServiceImpl extends ServiceImpl<BasicStudentMapper, Bas
|
|
|
String studentName = basicStudentImportDto.getStudentName();
|
|
|
String studentCode = basicStudentImportDto.getStudentCode();
|
|
|
String phoneNumber = basicStudentImportDto.getPhoneNumber();
|
|
|
- String clazz = basicStudentImportDto.getClazz();
|
|
|
- BasicClazz basicClazz = basicClazzService.getOne(new QueryWrapper<BasicClazz>().lambda()
|
|
|
- .eq(BasicClazz::getEnable,true)
|
|
|
- .eq(BasicClazz::getClazzName,clazz)
|
|
|
- .eq(BasicClazz::getSchoolId,schoolId));
|
|
|
- if (Objects.isNull(basicClazz)){
|
|
|
- throw ExceptionResultEnum.ERROR.exception("【班级】" + clazz + "还没有构建");
|
|
|
+ String campusName = basicStudentImportDto.getCampusName();
|
|
|
+ String collegeName = basicStudentImportDto.getCollegeName();
|
|
|
+ String majorName = basicStudentImportDto.getMajorName();
|
|
|
+ String clazzName = basicStudentImportDto.getClazzName();
|
|
|
+
|
|
|
+ // 校区
|
|
|
+ Long campusId = null;
|
|
|
+ if (SystemConstant.strNotNull(campusName)) {
|
|
|
+ BasicCampus basicCampus;
|
|
|
+ if (campusMap.containsKey(campusName)) {
|
|
|
+ basicCampus = campusMap.get(campusName);
|
|
|
+ } else {
|
|
|
+ basicCampus = basicCampusService.getOne(new QueryWrapper<BasicCampus>().lambda()
|
|
|
+ .eq(BasicCampus::getSchoolId, schoolId)
|
|
|
+ .eq(BasicCampus::getCampusName, campusName));
|
|
|
+ campusMap.put(campusName, basicCampus);
|
|
|
+ }
|
|
|
+ campusId = basicCampus.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 学院
|
|
|
+ Long collegeId = null;
|
|
|
+ if (SystemConstant.strNotNull(collegeName)){
|
|
|
+ SysOrg sysOrg;
|
|
|
+ if (collegeMap.containsKey(collegeName)) {
|
|
|
+ sysOrg = collegeMap.get(collegeName);
|
|
|
+ } else {
|
|
|
+ sysOrg = sysOrgService.getOne(new QueryWrapper<SysOrg>().lambda()
|
|
|
+ .eq(SysOrg::getSchoolId, schoolId)
|
|
|
+ .eq(SysOrg::getName, collegeName));
|
|
|
+ collegeMap.put(collegeName, sysOrg);
|
|
|
+ }
|
|
|
+ collegeId = sysOrg.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 专业
|
|
|
+ Long majorId = null;
|
|
|
+ if (SystemConstant.strNotNull(majorName)) {
|
|
|
+ if (!SystemConstant.longNotNull(collegeId)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("学生专业信息缺失学院信息异常");
|
|
|
+ }
|
|
|
+ String majorKey = collegeId + link + majorName;
|
|
|
+ if (majorMap.containsKey(majorKey)) {
|
|
|
+ majorId = majorMap.get(majorKey);
|
|
|
+ } else {
|
|
|
+ BasicMajor basicMajor = basicMajorService.getOne(new QueryWrapper<BasicMajor>().lambda()
|
|
|
+ .eq(BasicMajor::getSchoolId, schoolId)
|
|
|
+ .eq(BasicMajor::getBelongOrgId, collegeId)
|
|
|
+ .eq(BasicMajor::getName, majorName));
|
|
|
+ if (Objects.isNull(basicMajor)) {
|
|
|
+ // 新增一个major
|
|
|
+ BasicMajorParams basicMajorParams = new BasicMajorParams();
|
|
|
+ basicMajorParams.setMajorName(majorName);
|
|
|
+ basicMajorParams.setCollegeId(collegeId);
|
|
|
+ majorId = basicMajorService.saveBasicMajor(basicMajorParams, sysUser);
|
|
|
+ } else {
|
|
|
+ majorId = basicMajor.getId();
|
|
|
+ }
|
|
|
+ majorMap.put(majorKey, majorId);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ // 班级
|
|
|
+ Long clazzId = null;
|
|
|
+ if (SystemConstant.strNotNull(clazzName)){
|
|
|
+ if (!SystemConstant.longNotNull(campusId)){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("学生班级信息缺失校区信息异常");
|
|
|
+ }
|
|
|
+ if (!SystemConstant.longNotNull(collegeId)){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("学生班级信息缺失学院信息异常");
|
|
|
+ }
|
|
|
+ if (!SystemConstant.longNotNull(majorId)){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("学生班级信息缺失专业信息异常");
|
|
|
+ }
|
|
|
|
|
|
+ String clazzKey = majorId + link + clazzName;
|
|
|
+ if (clazzMap.containsKey(clazzKey)){
|
|
|
+ clazzId = clazzMap.get(clazzKey);
|
|
|
+ }else {
|
|
|
+ BasicClazz basicClazz = basicClazzService.getOne(new QueryWrapper<BasicClazz>().lambda()
|
|
|
+ .eq(BasicClazz::getSchoolId,schoolId)
|
|
|
+ .eq(BasicClazz::getMajorId,majorId)
|
|
|
+ .eq(BasicClazz::getClazzName,clazzName));
|
|
|
+ if (Objects.isNull(basicClazz)){
|
|
|
+ // 新增一个clazz
|
|
|
+ BasicClazzParams basicClazzParams = new BasicClazzParams();
|
|
|
+ basicClazzParams.setCampusId(campusId);
|
|
|
+ basicClazzParams.setMajorId(majorId);
|
|
|
+ basicClazzParams.setClazzName(clazzName);
|
|
|
+ clazzId = basicClazzService.saveBasicClazz(basicClazzParams,sysUser);
|
|
|
+ }else {
|
|
|
+ clazzId = basicClazz.getId();
|
|
|
+ }
|
|
|
+ clazzMap.put(clazzKey,clazzId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 学生信息组装
|
|
|
BasicStudentParams basicStudentParams = new BasicStudentParams();
|
|
|
basicStudentParams.setStudentName(studentName);
|
|
|
basicStudentParams.setStudentCode(studentCode);
|
|
|
basicStudentParams.setPhoneNumber(phoneNumber);
|
|
|
- basicStudentParams.setClazzId(basicClazz.getId());
|
|
|
+ if (SystemConstant.longNotNull(campusId)){
|
|
|
+ basicStudentParams.setCampusId(campusId);
|
|
|
+ }
|
|
|
+ if (SystemConstant.longNotNull(collegeId)){
|
|
|
+ basicStudentParams.setCollegeId(collegeId);
|
|
|
+ }
|
|
|
+ if (SystemConstant.longNotNull(majorId)){
|
|
|
+ basicStudentParams.setMajorId(majorId);
|
|
|
+ }
|
|
|
+ if (SystemConstant.longNotNull(clazzId)){
|
|
|
+ basicStudentParams.setClazzId(clazzId);
|
|
|
+ }
|
|
|
|
|
|
BasicStudent tmp = this.getOne(new QueryWrapper<BasicStudent>().lambda()
|
|
|
.eq(BasicStudent::getSchoolId, sysUser.getSchoolId())
|
|
@@ -146,7 +253,6 @@ public class BasicStudentServiceImpl extends ServiceImpl<BasicStudentMapper, Bas
|
|
|
List<BasicStudent> basicStudentList = this.editEntityHelp(addBasicStudentParamsList, sysUser);
|
|
|
this.saveOrUpdateBatch(basicStudentList);
|
|
|
}
|
|
|
-
|
|
|
return map;
|
|
|
}
|
|
|
|
|
@@ -171,33 +277,39 @@ public class BasicStudentServiceImpl extends ServiceImpl<BasicStudentMapper, Bas
|
|
|
Long collegeId = basicStudentParams.getCollegeId();
|
|
|
|
|
|
// 班级验证
|
|
|
- BasicClazz basicClazz = basicClazzService.getById(clazzId);
|
|
|
- if (Objects.isNull(basicClazz)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("所选班级不存在");
|
|
|
- }
|
|
|
- if (SystemConstant.longNotNull(campusId)){
|
|
|
- if (!campusId.equals(basicClazz.getCampusId())){
|
|
|
- throw ExceptionResultEnum.ERROR.exception("学生所属班级信息和学生信息中【校区】不对应");
|
|
|
+ if (SystemConstant.longNotNull(clazzId)){
|
|
|
+ // 如果有班级id 再验证
|
|
|
+ BasicClazz basicClazz = basicClazzService.getById(clazzId);
|
|
|
+ if (Objects.isNull(basicClazz)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("所选班级不存在");
|
|
|
}
|
|
|
- }
|
|
|
- if (SystemConstant.longNotNull(majorId)){
|
|
|
- if (!majorId.equals(basicClazz.getMajorId())){
|
|
|
- throw ExceptionResultEnum.ERROR.exception("学生所属班级信息和学生信息中【专业】不对应");
|
|
|
+ if (SystemConstant.longNotNull(campusId)){
|
|
|
+ if (!campusId.equals(basicClazz.getCampusId())){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("学生所属班级信息和学生信息中【校区】不对应");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (SystemConstant.longNotNull(majorId)){
|
|
|
+ if (!majorId.equals(basicClazz.getMajorId())){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("学生所属班级信息和学生信息中【专业】不对应");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
// 专业验证
|
|
|
- BasicMajor basicMajor = basicMajorService.getById(majorId);
|
|
|
- if (Objects.isNull(basicMajor)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("所选专业不存在");
|
|
|
- }
|
|
|
- if (SystemConstant.longNotNull(collegeId)){
|
|
|
- if (!collegeId.equals(basicMajor.getBelongOrgId())){
|
|
|
- throw ExceptionResultEnum.ERROR.exception("学生所属专业信息和学生信息中【学院】不对应");
|
|
|
+ if (SystemConstant.longNotNull(majorId)){
|
|
|
+ BasicMajor basicMajor = basicMajorService.getById(majorId);
|
|
|
+ if (Objects.isNull(basicMajor)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("所选专业不存在");
|
|
|
+ }
|
|
|
+ if (SystemConstant.longNotNull(collegeId)){
|
|
|
+ if (!collegeId.equals(basicMajor.getBelongOrgId())){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("学生所属专业信息和学生信息中【学院】不对应");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Long id = basicStudentParams.getId();
|
|
|
-
|
|
|
// 检验学号在学校的唯一性
|
|
|
BasicStudent checkCode = this.getOne(new QueryWrapper<BasicStudent>().lambda()
|
|
|
.eq(BasicStudent::getSchoolId, schoolId)
|