|
|
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
+import com.xjrsoft.common.enums.GenderDictionaryEnum;
|
|
|
import com.xjrsoft.common.enums.RoleEnum;
|
|
|
import com.xjrsoft.module.base.entity.BaseClass;
|
|
|
import com.xjrsoft.module.base.mapper.BaseClassMapper;
|
|
|
@@ -30,12 +31,19 @@ import com.xjrsoft.module.student.service.IStudentManagerService;
|
|
|
import com.xjrsoft.module.student.vo.BaseStudentClassVo;
|
|
|
import com.xjrsoft.module.student.vo.PersonalPortraitPersonalInfoVo;
|
|
|
import com.xjrsoft.module.student.vo.StudentPersonalInfoVo;
|
|
|
+import com.xjrsoft.module.system.entity.DictionaryDetail;
|
|
|
+import com.xjrsoft.module.system.entity.DictionaryItem;
|
|
|
+import com.xjrsoft.module.system.mapper.DictionarydetailMapper;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -53,6 +61,8 @@ public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUse
|
|
|
private final BaseStudentSubsidizeMapper studentbaseManagerBaseStudentSubsidizeMapper;
|
|
|
|
|
|
private final UserRoleRelationMapper userRoleRelationMapper;
|
|
|
+ private final BaseStudentMapper baseStudentMapper;
|
|
|
+ private final DictionarydetailMapper dictionarydetailMapper;
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@@ -309,8 +319,6 @@ public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUse
|
|
|
|
|
|
/**
|
|
|
* 个人财务画像,获取学生个人信息
|
|
|
- * @param userId
|
|
|
- * @return
|
|
|
*/
|
|
|
@Override
|
|
|
public PersonalPortraitPersonalInfoVo getPersonalInfo(Long userId) {
|
|
|
@@ -334,4 +342,122 @@ public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUse
|
|
|
}
|
|
|
return p;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean importStudentData(List<Map<Integer, Object>> excelDataList) {
|
|
|
+ //查询所有学生的用户信息,组装起来备用
|
|
|
+ List<BaseStudentUser> studentUsers = this.selectJoinList(BaseStudentUser.class,
|
|
|
+ new MPJLambdaWrapper<BaseStudentUser>()
|
|
|
+ .leftJoin(BaseStudent.class, BaseStudent::getUserId, BaseStudentUser::getId)
|
|
|
+ );
|
|
|
+ Map<String, BaseStudentUser> studentUserMap = new HashMap<>();
|
|
|
+ for (BaseStudentUser studentUser : studentUsers) {
|
|
|
+ studentUserMap.put(studentUser.getCredentialNumber(), studentUser);
|
|
|
+ }
|
|
|
+ //查询所有的学生信息,组装起来备用
|
|
|
+ List<BaseStudent> baseStudents = baseStudentMapper.selectJoinList(BaseStudent.class,
|
|
|
+ new MPJLambdaWrapper<BaseStudent>()
|
|
|
+ .leftJoin(BaseStudentUser.class, BaseStudentUser::getId, BaseStudent::getUserId)
|
|
|
+ );
|
|
|
+ Map<Long, BaseStudent> baseStudentMap = new HashMap<>();
|
|
|
+ for (BaseStudent studentUser : baseStudents) {
|
|
|
+ baseStudentMap.put(studentUser.getUserId(), studentUser);
|
|
|
+ }
|
|
|
+ //查询所用到的字典
|
|
|
+ Map<String, String> dictionary = initDictionary();
|
|
|
+
|
|
|
+ List<BaseStudentUser> updateStudentUserList = new ArrayList();
|
|
|
+ List<BaseStudent> updateBaseStudentList = new ArrayList();
|
|
|
+ for (Map<Integer, Object> dataMaps : excelDataList) {
|
|
|
+ String credentialNumber = dataMaps.get(0).toString();//身份证号
|
|
|
+ //已存在,更新
|
|
|
+ BaseStudentUser user;
|
|
|
+ BaseStudent baseStudent;
|
|
|
+ if(studentUserMap.containsKey(credentialNumber)){
|
|
|
+ //更新用户数据
|
|
|
+ user = studentUserMap.get(credentialNumber);
|
|
|
+ baseStudent = baseStudentMap.get(user.getId());
|
|
|
+
|
|
|
+ updateStudentUserList.add(user);
|
|
|
+ updateBaseStudentList.add(baseStudent);
|
|
|
+ }else{
|
|
|
+ user = new BaseStudentUser();
|
|
|
+ baseStudent = new BaseStudent();
|
|
|
+ }
|
|
|
+ //设置字段值
|
|
|
+ if(dataMaps.get(1).toString() != null && "".equals(dataMaps.get(1).toString())){
|
|
|
+ baseStudent.setStudentId(dataMaps.get(1).toString());//学号
|
|
|
+ }
|
|
|
+ if(dataMaps.get(3).toString() != null && "".equals(dataMaps.get(3).toString())){
|
|
|
+ user.setName(dataMaps.get(3).toString());//姓名
|
|
|
+ }
|
|
|
+ if(dataMaps.get(4).toString() != null && "".equals(dataMaps.get(4).toString())){
|
|
|
+ user.setGender(GenderDictionaryEnum.getCode(dataMaps.get(4).toString()));//性别
|
|
|
+ }
|
|
|
+ if(dataMaps.get(5).toString() != null && "".equals(dataMaps.get(5).toString())){
|
|
|
+ user.setMobile(dataMaps.get(5).toString());//手机号
|
|
|
+ }
|
|
|
+ if(dataMaps.get(6).toString() != null && "".equals(dataMaps.get(6).toString())){
|
|
|
+ user.setEmail(dataMaps.get(6).toString());//邮箱
|
|
|
+ }
|
|
|
+ if(dataMaps.get(7).toString() != null && "".equals(dataMaps.get(7).toString())){
|
|
|
+ baseStudent.setAsName(dataMaps.get(7).toString());//别名
|
|
|
+ }
|
|
|
+ if(dataMaps.get(8).toString() != null && "".equals(dataMaps.get(8).toString())){
|
|
|
+ baseStudent.setEnName(dataMaps.get(8).toString());//英文名
|
|
|
+ }
|
|
|
+ if(dataMaps.get(9).toString() != null && "".equals(dataMaps.get(9).toString())){
|
|
|
+ baseStudent.setPyName(dataMaps.get(9).toString());//姓名拼音
|
|
|
+ }
|
|
|
+ if(dataMaps.get(10).toString() != null && "".equals(dataMaps.get(10).toString())){
|
|
|
+ baseStudent.setPyName(dataMaps.get(10).toString());//曾用名
|
|
|
+ }
|
|
|
+ if(dataMaps.get(11).toString() != null && "".equals(dataMaps.get(11).toString())){
|
|
|
+ user.setCredentialType(dictionary.get(dataMaps.get(11).toString()));//证件类型
|
|
|
+ }
|
|
|
+ if(dataMaps.get(12).toString() != null && "".equals(dataMaps.get(12).toString())){
|
|
|
+ LocalDateTime birthday = LocalDateTime.parse(dataMaps.get(12).toString());
|
|
|
+ user.setBirthDate(birthday);//出生日期
|
|
|
+ baseStudent.setDayOfBirth(birthday);//出生日期
|
|
|
+ }
|
|
|
+ if(dataMaps.get(13).toString() != null && "".equals(dataMaps.get(13).toString())){
|
|
|
+ baseStudent.setBirthType(dictionary.get(dataMaps.get(13).toString()));//生日类型
|
|
|
+ }
|
|
|
+ if(dataMaps.get(14).toString() != null && "".equals(dataMaps.get(14).toString())){
|
|
|
+ baseStudent.setNation(dictionary.get(dataMaps.get(14).toString()));//民族
|
|
|
+ }
|
|
|
+ if(dataMaps.get(15).toString() != null && "".equals(dataMaps.get(15).toString())){
|
|
|
+ baseStudent.setNation(dictionary.get(dataMaps.get(15).toString()));//血型
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if(studentUserMap.containsKey(credentialNumber)){
|
|
|
+ updateStudentUserList.add(user);
|
|
|
+ updateBaseStudentList.add(baseStudent);
|
|
|
+ }else{
|
|
|
+ user = new BaseStudentUser();
|
|
|
+ baseStudent = new BaseStudent();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 初始化字典信息
|
|
|
+ * 身份证类型、
|
|
|
+ */
|
|
|
+ private Map<String, String> initDictionary(){
|
|
|
+ List<String> codeList = new ArrayList<>();
|
|
|
+ codeList.add("credential_type");codeList.add("nation");
|
|
|
+ codeList.add("blood_type");
|
|
|
+ List<DictionaryDetail> detailList = dictionarydetailMapper.selectJoinList(DictionaryDetail.class,
|
|
|
+ new MPJLambdaWrapper<DictionaryDetail>()
|
|
|
+ .leftJoin(DictionaryItem.class, DictionaryItem::getId, DictionaryDetail::getItemId)
|
|
|
+ );
|
|
|
+ Map<String, String> resultMap = new HashMap<>();
|
|
|
+ for (DictionaryDetail dictionaryDetail : detailList) {
|
|
|
+ resultMap.put(dictionaryDetail.getName(), dictionaryDetail.getCode());
|
|
|
+ }
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
}
|