|
@@ -9,17 +9,17 @@ import com.qmth.teachcloud.common.base.BaseEntity;
|
|
|
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.BasicCollegeParams;
|
|
|
-import com.qmth.teachcloud.common.bean.params.BasicMajorParams;
|
|
|
-import com.qmth.teachcloud.common.bean.params.BasicStudentParams;
|
|
|
+import com.qmth.teachcloud.common.bean.params.*;
|
|
|
import com.qmth.teachcloud.common.bean.result.BasicStudentResult;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
import com.qmth.teachcloud.common.entity.*;
|
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
import com.qmth.teachcloud.common.enums.TeachBasicEnum;
|
|
|
import com.qmth.teachcloud.common.mapper.BasicStudentMapper;
|
|
|
-import com.qmth.teachcloud.common.service.*;
|
|
|
+import com.qmth.teachcloud.common.service.BasicClazzService;
|
|
|
+import com.qmth.teachcloud.common.service.BasicCollegeService;
|
|
|
+import com.qmth.teachcloud.common.service.BasicMajorService;
|
|
|
+import com.qmth.teachcloud.common.service.BasicStudentService;
|
|
|
import com.qmth.teachcloud.common.util.ServletUtil;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -29,6 +29,7 @@ import org.springframework.util.LinkedMultiValueMap;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -75,7 +76,9 @@ public class BasicStudentServiceImpl extends ServiceImpl<BasicStudentMapper, Bas
|
|
|
public IPage<BasicStudent> listPage(Page<BasicStudent> page, String classId) {
|
|
|
List<String> classIds = Arrays.asList(classId.split(","));
|
|
|
QueryWrapper<BasicStudent> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.lambda().in(BasicStudent::getClazzId, classIds).orderByAsc(BasicStudent::getClazzId, BasicStudent::getStudentCode);
|
|
|
+ queryWrapper.lambda().in(BasicStudent::getClazzId, classIds)
|
|
|
+ .orderByAsc(BasicStudent::getClazzId)
|
|
|
+ .orderByAsc(BasicStudent::getStudentCode);
|
|
|
return this.baseMapper.selectPage(page, queryWrapper);
|
|
|
}
|
|
|
|
|
@@ -102,6 +105,134 @@ public class BasicStudentServiceImpl extends ServiceImpl<BasicStudentMapper, Bas
|
|
|
this.saveOrUpdateBatch(this.editEntityHelp(basicStudentParamsList, requestUser));
|
|
|
}
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public void saveBasicStudentWithExtrasList(List<BasicStudentExtrasParam> basicStudentExtrasParamList, SysUser requestUser) throws IllegalAccessException {
|
|
|
+ Long schoolId = requestUser.getSchoolId();
|
|
|
+ final String link = "-";
|
|
|
+ // key = collegeName
|
|
|
+ Map<String, Long> collegeMap = new HashMap<>();
|
|
|
+ // key = schoolId + "-" + majorName
|
|
|
+ Map<String, Long> majorMap = new HashMap<>();
|
|
|
+ // key = schoolId + "-" + clazzName
|
|
|
+ Map<String, Long> clazzMap = new HashMap<>();
|
|
|
+
|
|
|
+ List<BasicStudentParams> addBasicStudentParamsList = new ArrayList<>();
|
|
|
+ for (BasicStudentExtrasParam basicStudentExtrasParam : basicStudentExtrasParamList) {
|
|
|
+ // 取值
|
|
|
+ String studentName = basicStudentExtrasParam.getStudentName();
|
|
|
+ String studentCode = basicStudentExtrasParam.getStudentCode();
|
|
|
+ String phoneNumber = basicStudentExtrasParam.getPhoneNumber();
|
|
|
+ String collegeName = basicStudentExtrasParam.getCollegeName();
|
|
|
+ String majorName = basicStudentExtrasParam.getMajorName();
|
|
|
+ String clazzName = basicStudentExtrasParam.getClazzName();
|
|
|
+
|
|
|
+ // 学院
|
|
|
+ Long collegeId = null;
|
|
|
+ if (SystemConstant.strNotNull(collegeName)) {
|
|
|
+ BasicCollege basicCollege;
|
|
|
+ if (collegeMap.containsKey(collegeName)) {
|
|
|
+ collegeId = collegeMap.get(collegeName);
|
|
|
+ } else {
|
|
|
+ basicCollege = basicCollegeService.getOne(new QueryWrapper<BasicCollege>().lambda()
|
|
|
+ .eq(BasicCollege::getSchoolId, schoolId)
|
|
|
+ .eq(BasicCollege::getCollegeName, collegeName));
|
|
|
+ if (Objects.isNull(basicCollege)) {
|
|
|
+ // 新增一个basicCollege
|
|
|
+ BasicCollegeParams basicCollegeParams = new BasicCollegeParams();
|
|
|
+ basicCollegeParams.setCollegeName(collegeName);
|
|
|
+ collegeId = basicCollegeService.saveBasicCollege(basicCollegeParams, requestUser);
|
|
|
+ } else {
|
|
|
+ collegeId = basicCollege.getId();
|
|
|
+ }
|
|
|
+ collegeMap.put(collegeName, collegeId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 专业
|
|
|
+ Long majorId = null;
|
|
|
+ if (SystemConstant.strNotNull(majorName)) {
|
|
|
+ if (!SystemConstant.longNotNull(collegeId)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("学生专业信息缺失学院信息异常");
|
|
|
+ }
|
|
|
+ String majorKey = schoolId + 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::getName, majorName));
|
|
|
+ if (Objects.isNull(basicMajor)) {
|
|
|
+ // 新增一个major
|
|
|
+ BasicMajorParams basicMajorParams = new BasicMajorParams();
|
|
|
+ basicMajorParams.setMajorName(majorName);
|
|
|
+ basicMajorParams.setCollegeId(collegeId);
|
|
|
+ majorId = basicMajorService.saveBasicMajor(basicMajorParams, requestUser);
|
|
|
+ } else {
|
|
|
+ majorId = basicMajor.getId();
|
|
|
+ }
|
|
|
+ majorMap.put(majorKey, majorId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 班级
|
|
|
+ Long clazzId = null;
|
|
|
+ if (SystemConstant.strNotNull(clazzName)) {
|
|
|
+ if (!SystemConstant.longNotNull(collegeId)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("学生班级信息缺失学院信息异常");
|
|
|
+ }
|
|
|
+ if (!SystemConstant.longNotNull(majorId)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("学生班级信息缺失专业信息异常");
|
|
|
+ }
|
|
|
+
|
|
|
+ String clazzKey = schoolId + link + clazzName;
|
|
|
+ if (clazzMap.containsKey(clazzKey)) {
|
|
|
+ clazzId = clazzMap.get(clazzKey);
|
|
|
+ } else {
|
|
|
+ // 2022-03-30 字典班级在全校唯一
|
|
|
+ BasicClazz basicClazz = basicClazzService.getOne(new QueryWrapper<BasicClazz>().lambda()
|
|
|
+ .eq(BasicClazz::getSchoolId, schoolId)
|
|
|
+ .eq(BasicClazz::getClazzName, clazzName));
|
|
|
+ if (Objects.isNull(basicClazz)) {
|
|
|
+ // 新增一个clazz
|
|
|
+ BasicClazzParams basicClazzParams = new BasicClazzParams();
|
|
|
+ basicClazzParams.setMajorId(majorId);
|
|
|
+ basicClazzParams.setClazzName(clazzName);
|
|
|
+ clazzId = basicClazzService.saveBasicClazz(basicClazzParams, requestUser);
|
|
|
+ } else {
|
|
|
+ clazzId = basicClazz.getId();
|
|
|
+ }
|
|
|
+ clazzMap.put(clazzKey, clazzId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 学生信息组装
|
|
|
+ BasicStudentParams basicStudentParams = new BasicStudentParams();
|
|
|
+ basicStudentParams.setStudentName(studentName);
|
|
|
+ basicStudentParams.setStudentCode(studentCode);
|
|
|
+ basicStudentParams.setPhoneNumber(phoneNumber);
|
|
|
+ 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, requestUser.getSchoolId())
|
|
|
+ .eq(BasicStudent::getEnable, true)
|
|
|
+ .eq(BasicStudent::getStudentCode, studentCode));
|
|
|
+ if (Objects.nonNull(tmp)) {
|
|
|
+ basicStudentParams.setId(tmp.getId());
|
|
|
+ }
|
|
|
+ addBasicStudentParamsList.add(basicStudentParams);
|
|
|
+ }
|
|
|
+ List<BasicStudent> basicStudentList = this.editEntityHelp(addBasicStudentParamsList, requestUser);
|
|
|
+ this.saveOrUpdateBatch(basicStudentList);
|
|
|
+ }
|
|
|
+
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
public Boolean removeBasicStudentBatch(List<Long> idList) {
|
|
@@ -148,16 +279,6 @@ public class BasicStudentServiceImpl extends ServiceImpl<BasicStudentMapper, Bas
|
|
|
@Override
|
|
|
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 = collegeName
|
|
|
- Map<String, Long> collegeMap = new HashMap<>();
|
|
|
- // key = schoolId + "-" + majorName
|
|
|
- Map<String, Long> majorMap = new HashMap<>();
|
|
|
- // key = schoolId + "-" + clazzName
|
|
|
- Map<String, Long> clazzMap = new HashMap<>();
|
|
|
-
|
|
|
- List<BasicStudentParams> addBasicStudentParamsList = new ArrayList<>();
|
|
|
for (int i = 0; i < finalList.size(); i++) {
|
|
|
LinkedMultiValueMap<Integer, Object> excelMap = finalList.get(i);
|
|
|
List<Object> basicStudentImportDtoList = excelMap.get(i);
|
|
@@ -171,124 +292,19 @@ public class BasicStudentServiceImpl extends ServiceImpl<BasicStudentMapper, Bas
|
|
|
BeanUtils.copyProperties(e, basicStudentImportDto);
|
|
|
return basicStudentImportDto;
|
|
|
}).collect(Collectors.toList());
|
|
|
- map.put("dataCount", datasource.size());
|
|
|
-
|
|
|
- for (int y = 0; y < Objects.requireNonNull(basicStudentImportDtoList).size(); y++) {
|
|
|
- BasicStudentImportDto basicStudentImportDto = (BasicStudentImportDto) basicStudentImportDtoList.get(y);
|
|
|
-
|
|
|
- // 取值
|
|
|
- String studentName = basicStudentImportDto.getStudentName();
|
|
|
- String studentCode = basicStudentImportDto.getStudentCode();
|
|
|
- String phoneNumber = basicStudentImportDto.getPhoneNumber();
|
|
|
- String collegeName = basicStudentImportDto.getCollegeName();
|
|
|
- String majorName = basicStudentImportDto.getMajorName();
|
|
|
- String clazzName = basicStudentImportDto.getClazzName();
|
|
|
-
|
|
|
- // 学院
|
|
|
- Long collegeId = null;
|
|
|
- if (SystemConstant.strNotNull(collegeName)) {
|
|
|
- BasicCollege basicCollege;
|
|
|
- if (collegeMap.containsKey(collegeName)) {
|
|
|
- collegeId = collegeMap.get(collegeName);
|
|
|
- } else {
|
|
|
- basicCollege = basicCollegeService.getOne(new QueryWrapper<BasicCollege>().lambda()
|
|
|
- .eq(BasicCollege::getSchoolId, schoolId)
|
|
|
- .eq(BasicCollege::getCollegeName, collegeName));
|
|
|
- if (Objects.isNull(basicCollege)) {
|
|
|
- // 新增一个basicCollege
|
|
|
- BasicCollegeParams basicCollegeParams = new BasicCollegeParams();
|
|
|
- basicCollegeParams.setCollegeName(collegeName);
|
|
|
- collegeId = basicCollegeService.saveBasicCollege(basicCollegeParams, sysUser);
|
|
|
- } else {
|
|
|
- collegeId = basicCollege.getId();
|
|
|
- }
|
|
|
- collegeMap.put(collegeName, collegeId);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 专业
|
|
|
- Long majorId = null;
|
|
|
- if (SystemConstant.strNotNull(majorName)) {
|
|
|
- if (!SystemConstant.longNotNull(collegeId)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("学生专业信息缺失学院信息异常");
|
|
|
- }
|
|
|
- String majorKey = schoolId + 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::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(collegeId)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("学生班级信息缺失学院信息异常");
|
|
|
- }
|
|
|
- if (!SystemConstant.longNotNull(majorId)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("学生班级信息缺失专业信息异常");
|
|
|
- }
|
|
|
|
|
|
- String clazzKey = schoolId + link + clazzName;
|
|
|
- if (clazzMap.containsKey(clazzKey)) {
|
|
|
- clazzId = clazzMap.get(clazzKey);
|
|
|
- } else {
|
|
|
- // 2022-03-30 字典班级在全校唯一
|
|
|
- BasicClazz basicClazz = basicClazzService.getOne(new QueryWrapper<BasicClazz>().lambda()
|
|
|
- .eq(BasicClazz::getSchoolId, schoolId)
|
|
|
- .eq(BasicClazz::getClazzName, clazzName));
|
|
|
- if (Objects.isNull(basicClazz)) {
|
|
|
- // 新增一个clazz
|
|
|
- BasicClazzParams basicClazzParams = new BasicClazzParams();
|
|
|
- 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);
|
|
|
- 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())
|
|
|
- .eq(BasicStudent::getEnable, true)
|
|
|
- .eq(BasicStudent::getStudentCode, studentCode));
|
|
|
- if (Objects.nonNull(tmp)) {
|
|
|
- basicStudentParams.setId(tmp.getId());
|
|
|
- }
|
|
|
- addBasicStudentParamsList.add(basicStudentParams);
|
|
|
- }
|
|
|
-
|
|
|
- List<BasicStudent> basicStudentList = this.editEntityHelp(addBasicStudentParamsList, sysUser);
|
|
|
- this.saveOrUpdateBatch(basicStudentList);
|
|
|
+ List<BasicStudentExtrasParam> basicStudentExtrasParamList = datasource.stream().flatMap(e -> {
|
|
|
+ BasicStudentExtrasParam basicStudentExtrasParam = new BasicStudentExtrasParam();
|
|
|
+ basicStudentExtrasParam.setStudentName(e.getStudentName());
|
|
|
+ basicStudentExtrasParam.setStudentCode(e.getStudentCode());
|
|
|
+ basicStudentExtrasParam.setPhoneNumber(e.getPhoneNumber());
|
|
|
+ basicStudentExtrasParam.setCollegeName(e.getCollegeName());
|
|
|
+ basicStudentExtrasParam.setMajorName(e.getMajorName());
|
|
|
+ basicStudentExtrasParam.setClazzName(e.getClazzName());
|
|
|
+ return Stream.of(basicStudentExtrasParam);
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ this.saveBasicStudentWithExtrasList(basicStudentExtrasParamList, sysUser);
|
|
|
+ map.put("dataCount", datasource.size());
|
|
|
}
|
|
|
return map;
|
|
|
}
|