|
@@ -18,17 +18,20 @@ import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
import com.qmth.teachcloud.common.entity.*;
|
|
import com.qmth.teachcloud.common.entity.*;
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
import com.qmth.teachcloud.common.enums.TeachBasicEnum;
|
|
import com.qmth.teachcloud.common.enums.TeachBasicEnum;
|
|
|
|
+import com.qmth.teachcloud.common.enums.paperGroup.MarkModeEnum;
|
|
import com.qmth.teachcloud.common.mapper.BasicStudentMapper;
|
|
import com.qmth.teachcloud.common.mapper.BasicStudentMapper;
|
|
import com.qmth.teachcloud.common.service.*;
|
|
import com.qmth.teachcloud.common.service.*;
|
|
import com.qmth.teachcloud.common.util.ExcelUtil;
|
|
import com.qmth.teachcloud.common.util.ExcelUtil;
|
|
import com.qmth.teachcloud.common.util.ResultUtil;
|
|
import com.qmth.teachcloud.common.util.ResultUtil;
|
|
import com.qmth.teachcloud.common.util.ServletUtil;
|
|
import com.qmth.teachcloud.common.util.ServletUtil;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.dao.DataIntegrityViolationException;
|
|
import org.springframework.dao.DataIntegrityViolationException;
|
|
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.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
|
|
+import sun.swing.StringUIClientPropertyKey;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
@@ -54,17 +57,20 @@ public class BasicStudentServiceImpl extends ServiceImpl<BasicStudentMapper, Bas
|
|
private BasicMajorService basicMajorService;
|
|
private BasicMajorService basicMajorService;
|
|
@Resource
|
|
@Resource
|
|
private BasicCollegeService basicCollegeService;
|
|
private BasicCollegeService basicCollegeService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private SysOrgService sysOrgService;
|
|
@Resource
|
|
@Resource
|
|
private BasicRoleDataPermissionService basicRoleDataPermissionService;
|
|
private BasicRoleDataPermissionService basicRoleDataPermissionService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public IPage<BasicStudentResult> basicStudentPage(String queryParams, Long collegeId, Long majorId, Set<Long> clazzIdList, int pageNumber, int pageSize) {
|
|
|
|
|
|
+ public IPage<BasicStudentResult> basicStudentPage(String queryParams, Long collegeId, Long majorId, Long clazzId, int pageNumber, int pageSize) {
|
|
Long schoolId = SystemConstant.convertIdToLong(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
Long schoolId = SystemConstant.convertIdToLong(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
|
|
SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
|
|
DataPermissionRule dpr = basicRoleDataPermissionService.findDataPermission(schoolId, requestUser.getId(), ServletUtil.getRequest().getServletPath());
|
|
DataPermissionRule dpr = basicRoleDataPermissionService.findDataPermission(schoolId, requestUser.getId(), ServletUtil.getRequest().getServletPath());
|
|
queryParams = SystemConstant.translateSpecificSign(queryParams);
|
|
queryParams = SystemConstant.translateSpecificSign(queryParams);
|
|
- return basicStudentMapper.findBasicStudentPage(new Page<>(pageNumber, pageSize), queryParams, schoolId, collegeId, majorId, clazzIdList, dpr);
|
|
|
|
|
|
+ return basicStudentMapper.findBasicStudentPage(new Page<>(pageNumber, pageSize), queryParams, schoolId, collegeId, majorId, clazzId, dpr);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -100,30 +106,27 @@ public class BasicStudentServiceImpl extends ServiceImpl<BasicStudentMapper, Bas
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Override
|
|
@Override
|
|
- public Long saveBasicStudent(BasicStudentParams basicStudentParams, SysUser requestUser) {
|
|
|
|
- List<BasicStudentParams> basicStudentParamsList = new ArrayList<>();
|
|
|
|
- basicStudentParamsList.add(basicStudentParams);
|
|
|
|
- BasicStudent basicStudent = this.editEntityHelp(basicStudentParamsList, requestUser).get(0);
|
|
|
|
|
|
+ public Long saveBasicStudent(BasicStudentParams basicStudentParams) {
|
|
|
|
+ SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
|
+ BasicStudent basicStudent = this.editEntityHelp(basicStudentParams, sysUser);
|
|
this.saveOrUpdate(basicStudent);
|
|
this.saveOrUpdate(basicStudent);
|
|
return basicStudent.getId();
|
|
return basicStudent.getId();
|
|
}
|
|
}
|
|
|
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
|
- @Override
|
|
|
|
- public void saveOrUpdateBasicStudentBatch(List<BasicStudentParams> basicStudentParamsList, SysUser requestUser) {
|
|
|
|
- this.saveOrUpdateBatch(this.editEntityHelp(basicStudentParamsList, requestUser));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Override
|
|
@Override
|
|
public void saveBasicStudentWithExtrasList(List<BasicStudentExtrasParam> basicStudentExtrasParamList, SysUser requestUser, boolean saveBasicStudent) throws IllegalAccessException {
|
|
public void saveBasicStudentWithExtrasList(List<BasicStudentExtrasParam> basicStudentExtrasParamList, SysUser requestUser, boolean saveBasicStudent) throws IllegalAccessException {
|
|
Long schoolId = requestUser.getSchoolId();
|
|
Long schoolId = requestUser.getSchoolId();
|
|
- // 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<>();
|
|
|
|
|
|
+
|
|
|
|
+ // 查询所有学院map
|
|
|
|
+ List<SysOrg> sysOrgList = sysOrgService.findCollegeLevelOrgList(schoolId);
|
|
|
|
+ Map<String, Long> collegeMap = CollectionUtils.isEmpty(sysOrgList) ? new HashMap<>() : sysOrgList.stream().collect(Collectors.toMap(SysOrg::getName, SysOrg::getId));
|
|
|
|
+ // 查询所有专业map
|
|
|
|
+ List<BasicMajor> basicMajorList = basicMajorService.list(new QueryWrapper<BasicMajor>().lambda().eq(BasicMajor::getSchoolId, schoolId));
|
|
|
|
+ Map<String, Long> majorMap = CollectionUtils.isEmpty(basicMajorList) ? new HashMap<>() : basicMajorList.stream().collect(Collectors.toMap(k -> k.getOrgId() + SystemConstant.HYPHEN + k.getName(), v -> v.getId()));
|
|
|
|
+ // 查询所有班级map
|
|
|
|
+ List<BasicClazz> basicClazzList = basicClazzService.list(new QueryWrapper<BasicClazz>().lambda().eq(BasicClazz::getSchoolId, schoolId));
|
|
|
|
+ Map<String, Long> clazzMap = CollectionUtils.isEmpty(basicClazzList) ? new HashMap<>() : basicClazzList.stream().collect(Collectors.toMap(k -> k.getMajorId() + SystemConstant.HYPHEN + k.getClazzName(), v -> v.getId()));
|
|
|
|
|
|
List<BasicStudentParams> addBasicStudentParamsList = new ArrayList<>();
|
|
List<BasicStudentParams> addBasicStudentParamsList = new ArrayList<>();
|
|
for (BasicStudentExtrasParam basicStudentExtrasParam : basicStudentExtrasParamList) {
|
|
for (BasicStudentExtrasParam basicStudentExtrasParam : basicStudentExtrasParamList) {
|
|
@@ -136,113 +139,78 @@ public class BasicStudentServiceImpl extends ServiceImpl<BasicStudentMapper, Bas
|
|
String clazzName = basicStudentExtrasParam.getClazzName();
|
|
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);
|
|
|
|
- }
|
|
|
|
|
|
+ if (StringUtils.isBlank(collegeName)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("学号[" + studentCode + "]的数据,学院必填");
|
|
|
|
+ }
|
|
|
|
+ if (!collegeMap.containsKey(collegeName)) {
|
|
|
|
+ SysOrg sysOrg = new SysOrg();
|
|
|
|
+ sysOrg.setSchoolId(schoolId);
|
|
|
|
+ sysOrg.setName(collegeName);
|
|
|
|
+ sysOrg.setParentId(sysOrgService.findRootOrg(schoolId).getId());
|
|
|
|
+ sysOrgService.saveOrg(sysOrg, requestUser);
|
|
|
|
+ collegeMap.put(collegeName, sysOrg.getId());
|
|
|
|
+ }
|
|
|
|
+ Long collegeId = collegeMap.get(collegeName);
|
|
|
|
+ if (collegeId == null) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("学号[" + studentCode + "]的数据,学院查询失败");
|
|
}
|
|
}
|
|
|
|
|
|
// 专业
|
|
// 专业
|
|
- Long majorId = null;
|
|
|
|
- if (SystemConstant.strNotNull(majorName)) {
|
|
|
|
- if (!SystemConstant.longNotNull(collegeId)) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("学生专业信息缺失学院信息异常");
|
|
|
|
- }
|
|
|
|
- String majorKey = schoolId + SystemConstant.HYPHEN + 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);
|
|
|
|
- }
|
|
|
|
|
|
+ if (StringUtils.isBlank(majorName)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("学号[" + studentCode + "]的数据,专业必填");
|
|
|
|
+ }
|
|
|
|
+ String majorKey = collegeId + SystemConstant.HYPHEN + majorName;
|
|
|
|
+ if (!majorMap.containsKey(majorKey)) {
|
|
|
|
+ // 新增一个major
|
|
|
|
+ BasicMajorParams basicMajorParams = new BasicMajorParams();
|
|
|
|
+ basicMajorParams.setMajorName(majorName);
|
|
|
|
+ basicMajorParams.setCollegeId(collegeId);
|
|
|
|
+ Long majorId = basicMajorService.saveBasicMajor(basicMajorParams, requestUser);
|
|
|
|
+ majorMap.put(majorKey, majorId);
|
|
|
|
+ }
|
|
|
|
+ Long majorId = majorMap.get(majorKey);
|
|
|
|
+ if (majorId == null) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("学号[" + studentCode + "]的数据,专业查询失败");
|
|
}
|
|
}
|
|
|
|
|
|
// 班级
|
|
// 班级
|
|
- 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 + SystemConstant.HYPHEN + 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);
|
|
|
|
- }
|
|
|
|
|
|
+ if (StringUtils.isBlank(clazzName)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("学号[" + studentCode + "]的数据,班级必填");
|
|
}
|
|
}
|
|
|
|
+ String clazzKey = majorId + SystemConstant.HYPHEN + clazzName;
|
|
|
|
+ if (!clazzMap.containsKey(clazzKey)) {
|
|
|
|
+ // 新增一个clazz
|
|
|
|
+ BasicClazzParams basicClazzParams = new BasicClazzParams();
|
|
|
|
+ basicClazzParams.setMajorId(majorId);
|
|
|
|
+ basicClazzParams.setClazzName(clazzName);
|
|
|
|
+ Long clazzId = basicClazzService.saveBasicClazz(basicClazzParams, requestUser);
|
|
|
|
+ clazzMap.put(clazzKey, clazzId);
|
|
|
|
+ }
|
|
|
|
+ Long clazzId = clazzMap.get(clazzKey);
|
|
|
|
+ if (majorId == null) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("学号[" + studentCode + "]的数据,班级查询失败");
|
|
|
|
+ }
|
|
|
|
+
|
|
if (saveBasicStudent) {
|
|
if (saveBasicStudent) {
|
|
// 学生信息组装
|
|
// 学生信息组装
|
|
BasicStudentParams basicStudentParams = new BasicStudentParams();
|
|
BasicStudentParams basicStudentParams = new BasicStudentParams();
|
|
basicStudentParams.setStudentName(studentName);
|
|
basicStudentParams.setStudentName(studentName);
|
|
basicStudentParams.setStudentCode(studentCode);
|
|
basicStudentParams.setStudentCode(studentCode);
|
|
basicStudentParams.setPhoneNumber(phoneNumber);
|
|
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());
|
|
|
|
- }
|
|
|
|
|
|
+ basicStudentParams.setCollegeId(collegeId);
|
|
|
|
+ basicStudentParams.setMajorId(majorId);
|
|
|
|
+ basicStudentParams.setClazzId(clazzId);
|
|
addBasicStudentParamsList.add(basicStudentParams);
|
|
addBasicStudentParamsList.add(basicStudentParams);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (!CollectionUtils.isEmpty(addBasicStudentParamsList)) {
|
|
if (!CollectionUtils.isEmpty(addBasicStudentParamsList)) {
|
|
- List<BasicStudent> basicStudentList = this.editEntityHelp(addBasicStudentParamsList, requestUser);
|
|
|
|
|
|
+ List<BasicStudent> editEntityList = new ArrayList<>();
|
|
|
|
+ for (BasicStudentParams basicStudentParams : addBasicStudentParamsList) {
|
|
|
|
+ BasicStudent basicStudent = this.editEntityHelp(basicStudentParams, requestUser);
|
|
|
|
+ editEntityList.add(basicStudent);
|
|
|
|
+ }
|
|
try {
|
|
try {
|
|
- this.saveOrUpdateBatch(basicStudentList);
|
|
|
|
|
|
+ this.saveOrUpdateBatch(editEntityList);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
if (e instanceof DataIntegrityViolationException) {
|
|
if (e instanceof DataIntegrityViolationException) {
|
|
String error = e.getCause().toString();
|
|
String error = e.getCause().toString();
|
|
@@ -321,7 +289,6 @@ public class BasicStudentServiceImpl extends ServiceImpl<BasicStudentMapper, Bas
|
|
LinkedMultiValueMap<Integer, Object> excelMap = finalList.get(i);
|
|
LinkedMultiValueMap<Integer, Object> excelMap = finalList.get(i);
|
|
List<Object> basicStudentImportDtoList = excelMap.get(i);
|
|
List<Object> basicStudentImportDtoList = excelMap.get(i);
|
|
|
|
|
|
-// assert !basicStudentImportDtoList.isEmpty();
|
|
|
|
if (basicStudentImportDtoList.isEmpty() || basicStudentImportDtoList.get(0) instanceof DescribeImportDto) {
|
|
if (basicStudentImportDtoList.isEmpty() || basicStudentImportDtoList.get(0) instanceof DescribeImportDto) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
@@ -333,16 +300,15 @@ public class BasicStudentServiceImpl extends ServiceImpl<BasicStudentMapper, Bas
|
|
|
|
|
|
List<BasicStudentExtrasParam> basicStudentExtrasParamList = datasource.stream().flatMap(e -> {
|
|
List<BasicStudentExtrasParam> basicStudentExtrasParamList = datasource.stream().flatMap(e -> {
|
|
BasicStudentExtrasParam basicStudentExtrasParam = new BasicStudentExtrasParam();
|
|
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());
|
|
|
|
|
|
+ basicStudentExtrasParam.setStudentName(StringUtils.isNotBlank(e.getStudentName()) ? e.getStudentName().trim() : null);
|
|
|
|
+ basicStudentExtrasParam.setStudentCode(StringUtils.isNotBlank(e.getStudentCode()) ? e.getStudentCode().trim() : null);
|
|
|
|
+ basicStudentExtrasParam.setPhoneNumber(StringUtils.isNotBlank(e.getPhoneNumber()) ? e.getPhoneNumber().trim() : null);
|
|
|
|
+ basicStudentExtrasParam.setCollegeName(StringUtils.isNotBlank(e.getCollegeName()) ? e.getCollegeName().trim() : null);
|
|
|
|
+ basicStudentExtrasParam.setMajorName(StringUtils.isNotBlank(e.getMajorName()) ? e.getMajorName().trim() : null);
|
|
|
|
+ basicStudentExtrasParam.setClazzName(StringUtils.isNotBlank(e.getClazzName()) ? e.getClazzName().trim() : null);
|
|
return Stream.of(basicStudentExtrasParam);
|
|
return Stream.of(basicStudentExtrasParam);
|
|
}).collect(Collectors.toList());
|
|
}).collect(Collectors.toList());
|
|
this.saveBasicStudentWithExtrasList(basicStudentExtrasParamList, sysUser, true);
|
|
this.saveBasicStudentWithExtrasList(basicStudentExtrasParamList, sysUser, true);
|
|
- map.put("dataCount", datasource.size());
|
|
|
|
}
|
|
}
|
|
return map;
|
|
return map;
|
|
}
|
|
}
|
|
@@ -363,136 +329,54 @@ public class BasicStudentServiceImpl extends ServiceImpl<BasicStudentMapper, Bas
|
|
/**
|
|
/**
|
|
* 学生保存助手方法(应对学生保存和导入批量保存)
|
|
* 学生保存助手方法(应对学生保存和导入批量保存)
|
|
*
|
|
*
|
|
- * @param basicStudentParamsList 学生参数
|
|
|
|
- * @param sysUser 操作人
|
|
|
|
|
|
+ * @param basicStudentParams 学生参数
|
|
|
|
+ * @param sysUser 操作人
|
|
* @return 结果
|
|
* @return 结果
|
|
*/
|
|
*/
|
|
- private List<BasicStudent> editEntityHelp(List<BasicStudentParams> basicStudentParamsList, SysUser sysUser) {
|
|
|
|
-
|
|
|
|
|
|
+ private BasicStudent editEntityHelp(BasicStudentParams basicStudentParams, SysUser sysUser) {
|
|
Long schoolId = sysUser.getSchoolId();
|
|
Long schoolId = sysUser.getSchoolId();
|
|
- List<BasicStudent> editEntityList = new ArrayList<>();
|
|
|
|
- Map<String, BasicStudentParams> checkRepeatMap = new HashMap<>();
|
|
|
|
- for (BasicStudentParams basicStudentParams : basicStudentParamsList) {
|
|
|
|
- // 普通参数
|
|
|
|
- String studentName = basicStudentParams.getStudentName();
|
|
|
|
- String studentCode = basicStudentParams.getStudentCode();
|
|
|
|
- String phoneNumber = basicStudentParams.getPhoneNumber();
|
|
|
|
- Long clazzId = basicStudentParams.getClazzId();
|
|
|
|
- Long majorId = basicStudentParams.getMajorId();
|
|
|
|
- Long collegeId = basicStudentParams.getCollegeId();
|
|
|
|
- if (checkRepeatMap.containsKey(studentCode)) {
|
|
|
|
- // 校验整个导入批次是否有重复数据
|
|
|
|
- BasicStudentParams check = checkRepeatMap.get(studentCode);
|
|
|
|
- if (!Objects.equals(studentName, check.getStudentName())) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("导入批次学号为【" + studentCode + "】的学生,存在不同姓名");
|
|
|
|
- }
|
|
|
|
- if (!Objects.equals(phoneNumber, check.getPhoneNumber())) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("导入批次学号为【" + studentCode + "】的学生,存在不同电话");
|
|
|
|
- }
|
|
|
|
- if (!Objects.equals(clazzId, check.getClazzId())) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("导入批次学号为【" + studentCode + "】的学生,存在不同班级");
|
|
|
|
- }
|
|
|
|
- if (!Objects.equals(majorId, check.getMajorId())) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("导入批次学号为【" + studentCode + "】的学生,存在不同专业");
|
|
|
|
- }
|
|
|
|
- if (!Objects.equals(collegeId, check.getCollegeId())) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("导入批次学号为【" + studentCode + "】的学生,存在不同学院");
|
|
|
|
- }
|
|
|
|
- continue;
|
|
|
|
- } else {
|
|
|
|
- checkRepeatMap.put(studentCode, basicStudentParams);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 班级验证
|
|
|
|
- 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())) {
|
|
|
|
- String exception = "学生信息【" + studentName + "(" + studentCode + ")" + SystemConstant.HYPHEN + basicMajorService.getById(majorId).getName() + "】中的专业和学生所属班级信息【" + basicClazz.getClazzName() + "-" + basicMajorService.getById(basicClazz.getMajorId()).getName() + "】中的专业不对应";
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception(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())) {
|
|
|
|
- String exception = "学生信息【" + studentName + "(" + studentCode + ")" + SystemConstant.HYPHEN + basicCollegeService.getById(collegeId).getCollegeName() +
|
|
|
|
- "】中的学院和学生所属专业信息【" +
|
|
|
|
- basicMajor.getName() + SystemConstant.HYPHEN + basicCollegeService.getById(basicMajor.getBelongOrgId()).getCollegeName() + "】中的学院不对应";
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception(exception);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- Long id = basicStudentParams.getId();
|
|
|
|
- // 检验学号在学校的唯一性
|
|
|
|
- BasicStudent checkCode = this.getOne(new QueryWrapper<BasicStudent>().lambda()
|
|
|
|
|
|
+ // 普通参数
|
|
|
|
+ String studentName = basicStudentParams.getStudentName();
|
|
|
|
+ String studentCode = basicStudentParams.getStudentCode();
|
|
|
|
+ String phoneNumber = basicStudentParams.getPhoneNumber();
|
|
|
|
+ Long clazzId = basicStudentParams.getClazzId();
|
|
|
|
+ Long majorId = basicStudentParams.getMajorId();
|
|
|
|
+ Long collegeId = basicStudentParams.getCollegeId();
|
|
|
|
+
|
|
|
|
+ // 检验有值的电话在学校的唯一性
|
|
|
|
+ if (SystemConstant.strNotNull(phoneNumber)) {
|
|
|
|
+ BasicStudent checkPhone = this.getOne(new QueryWrapper<BasicStudent>().lambda()
|
|
.eq(BasicStudent::getSchoolId, schoolId)
|
|
.eq(BasicStudent::getSchoolId, schoolId)
|
|
- .eq(BasicStudent::getStudentCode, studentCode)
|
|
|
|
- .eq(BasicStudent::getEnable, true));
|
|
|
|
- if (Objects.nonNull(checkCode)) {
|
|
|
|
- if (!checkCode.getId().equals(id)) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("学生编号【" + studentCode + "】重复");
|
|
|
|
|
|
+ .eq(BasicStudent::getPhoneNumber, phoneNumber));
|
|
|
|
+ if (Objects.nonNull(checkPhone)) {
|
|
|
|
+ if (!checkPhone.getStudentCode().equals(studentCode)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("电话[" + phoneNumber + "]绑定了不同学号");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
|
|
- // 检验有值的电话在学校的唯一性
|
|
|
|
- if (SystemConstant.strNotNull(phoneNumber)) {
|
|
|
|
- BasicStudent checkPhone = this.getOne(new QueryWrapper<BasicStudent>().lambda()
|
|
|
|
- .eq(BasicStudent::getSchoolId, schoolId)
|
|
|
|
- .eq(BasicStudent::getPhoneNumber, phoneNumber)
|
|
|
|
- .eq(BasicStudent::getEnable, true));
|
|
|
|
- if (Objects.nonNull(checkPhone)) {
|
|
|
|
- if (!checkPhone.getId().equals(id)) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("学生电话【" + phoneNumber + "】重复");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 组装基础参数
|
|
|
|
- Long orgId;
|
|
|
|
- BasicStudent basicStudent = new BasicStudent();
|
|
|
|
- basicStudent.setStudentCode(studentCode);
|
|
|
|
- basicStudent.setStudentName(studentName);
|
|
|
|
- basicStudent.setPhoneNumber(phoneNumber);
|
|
|
|
- basicStudent.setBelongOrgId(collegeId);
|
|
|
|
- basicStudent.setMajorId(majorId);
|
|
|
|
- basicStudent.setClazzId(clazzId);
|
|
|
|
- basicStudent.setSchoolId(schoolId);
|
|
|
|
-
|
|
|
|
- // 保存
|
|
|
|
- if (!SystemConstant.longNotNull(id)) {
|
|
|
|
- // id为空 -> 新增
|
|
|
|
- // 获取分布式id
|
|
|
|
- orgId = sysUser.getOrgId();
|
|
|
|
- id = SystemConstant.getDbUuid();
|
|
|
|
- basicStudent.setId(id);
|
|
|
|
-
|
|
|
|
- basicStudent.setCreateId(sysUser.getId());
|
|
|
|
- } else {
|
|
|
|
- // id不为空 -> 更新
|
|
|
|
- BasicStudent old = this.getById(id);
|
|
|
|
- if (Objects.isNull(old) || old.getEnable().equals(false)) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("学生主键不存在或被禁用");
|
|
|
|
- }
|
|
|
|
- orgId = old.getOrgId();
|
|
|
|
- basicStudent.setId(id);
|
|
|
|
- basicStudent.setUpdateId(sysUser.getId());
|
|
|
|
- }
|
|
|
|
- basicStudent.setOrgId(orgId);
|
|
|
|
- editEntityList.add(basicStudent);
|
|
|
|
|
|
+ // 组装基础参数
|
|
|
|
+ BasicStudent basicStudent = new BasicStudent();
|
|
|
|
+ basicStudent.setStudentCode(studentCode);
|
|
|
|
+ basicStudent.setStudentName(studentName);
|
|
|
|
+ basicStudent.setPhoneNumber(phoneNumber);
|
|
|
|
+ basicStudent.setBelongOrgId(collegeId);
|
|
|
|
+ basicStudent.setMajorId(majorId);
|
|
|
|
+ basicStudent.setClazzId(clazzId);
|
|
|
|
+ basicStudent.setSchoolId(schoolId);
|
|
|
|
+
|
|
|
|
+ BasicStudent checkCode = this.getOne(new QueryWrapper<BasicStudent>().lambda()
|
|
|
|
+ .eq(BasicStudent::getSchoolId, schoolId)
|
|
|
|
+ .eq(BasicStudent::getStudentCode, studentCode));
|
|
|
|
+ if (checkCode != null) {
|
|
|
|
+ basicStudent.setId(checkCode.getId());
|
|
|
|
+ // 禁用的学生,此时启用
|
|
|
|
+ basicStudent.setEnable(true);
|
|
|
|
+ basicStudent.updateInfo(sysUser.getId());
|
|
|
|
+ } else {
|
|
|
|
+ basicStudent.setId(SystemConstant.getDbUuid());
|
|
|
|
+ basicStudent.insertInfo(sysUser.getId());
|
|
}
|
|
}
|
|
- return editEntityList;
|
|
|
|
|
|
+ return basicStudent;
|
|
}
|
|
}
|
|
}
|
|
}
|