| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212 |
- package com.xjrsoft.module.student.service.impl;
- import cn.dev33.satoken.secure.BCrypt;
- import cn.dev33.satoken.stp.StpUtil;
- import cn.hutool.core.bean.BeanUtil;
- import cn.hutool.core.collection.CollectionUtil;
- import cn.hutool.core.convert.Convert;
- import cn.hutool.core.util.IdUtil;
- import cn.hutool.core.util.StrUtil;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.baomidou.mybatisplus.core.toolkit.StringPool;
- import com.baomidou.mybatisplus.core.toolkit.Wrappers;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.github.yulichang.base.MPJBaseServiceImpl;
- import com.github.yulichang.wrapper.MPJLambdaWrapper;
- import com.xjrsoft.common.constant.GlobalConstant;
- import com.xjrsoft.common.enums.*;
- import com.xjrsoft.common.exception.MyException;
- import com.xjrsoft.common.utils.RedisUtil;
- import com.xjrsoft.common.utils.TreeUtil;
- import com.xjrsoft.config.CommonPropertiesConfig;
- import com.xjrsoft.module.base.entity.BaseClass;
- import com.xjrsoft.module.base.entity.BaseGrade;
- import com.xjrsoft.module.base.entity.BaseMajorSet;
- import com.xjrsoft.module.base.mapper.BaseClassMapper;
- import com.xjrsoft.module.base.mapper.BaseGradeMapper;
- import com.xjrsoft.module.base.mapper.BaseMajorSetMapper;
- import com.xjrsoft.module.base.service.IBaseClassService;
- import com.xjrsoft.module.base.service.IBaseGradeService;
- import com.xjrsoft.module.organization.entity.Department;
- import com.xjrsoft.module.organization.entity.User;
- import com.xjrsoft.module.organization.entity.UserDeptRelation;
- import com.xjrsoft.module.organization.entity.UserRoleRelation;
- import com.xjrsoft.module.organization.mapper.UserDeptRelationMapper;
- import com.xjrsoft.module.organization.mapper.UserMapper;
- import com.xjrsoft.module.organization.mapper.UserRoleRelationMapper;
- import com.xjrsoft.module.organization.service.IDepartmentService;
- import com.xjrsoft.module.organization.service.IUserDeptRelationService;
- import com.xjrsoft.module.organization.service.IUserService;
- import com.xjrsoft.module.student.dto.AddBaseStudentUserDto;
- import com.xjrsoft.module.student.dto.BaseStudentSimpleInfoDto;
- import com.xjrsoft.module.student.dto.BaseStudentUserPageDto;
- import com.xjrsoft.module.student.dto.MajorGradeClassDto;
- import com.xjrsoft.module.student.dto.UpdateBaseStudentUserDto;
- import com.xjrsoft.module.student.entity.*;
- import com.xjrsoft.module.student.mapper.BaseStudentFamilyMapper;
- import com.xjrsoft.module.student.mapper.BaseStudentFamilyMemberMapper;
- import com.xjrsoft.module.student.mapper.BaseStudentMapper;
- import com.xjrsoft.module.student.mapper.BaseStudentUserMapper;
- import com.xjrsoft.module.student.service.*;
- import com.xjrsoft.module.student.vo.*;
- import com.xjrsoft.module.system.entity.Area;
- import com.xjrsoft.module.system.entity.DictionaryDetail;
- import com.xjrsoft.module.system.entity.DictionaryItem;
- import com.xjrsoft.module.system.mapper.DictionarydetailMapper;
- import com.xjrsoft.module.system.mapper.DictionaryitemMapper;
- import com.xjrsoft.module.system.service.IAreaService;
- import com.xjrsoft.module.system.service.IDictionarydetailService;
- import lombok.AllArgsConstructor;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.BeanUtils;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import org.springframework.web.multipart.MultipartFile;
- import java.io.IOException;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.time.LocalDate;
- import java.time.LocalDateTime;
- import java.time.format.DateTimeFormatter;
- import java.time.format.DateTimeParseException;
- import java.util.*;
- import java.util.concurrent.CompletableFuture;
- import java.util.stream.Collectors;
- @Service
- @AllArgsConstructor
- public class StudentManagerServiceImpl extends MPJBaseServiceImpl<BaseStudentUserMapper, BaseStudentUser> implements IStudentManagerService {
- private final com.xjrsoft.module.student.mapper.BaseStudentUserMapper baseStudentUserMapper;
- private final IBaseStudentService baseStudentService;
- private final BaseClassMapper baseClassMapper;
- private final IBaseStudentContactService studentContactService;
- private final BaseStudentFamilyMapper familyMapper;
- private final BaseStudentFamilyMemberMapper familyMemberMapper;
- private final UserRoleRelationMapper userRoleRelationMapper;
- private final DictionarydetailMapper dictionarydetailMapper;
- private final IAreaService areaService;
- private final BaseGradeMapper baseGradeMapper;
- private final BaseMajorSetMapper baseMajorSetMapper;
- private final DictionaryitemMapper dictionaryitemMapper;
- private final IBaseStudentSchoolRollService schoolRollService;
- private final IBaseStudentSubsidizeService subsidizeService;
- private final IBaseStudentFamilyService familyService;
- private final BaseStudentMapper baseStudentMapper;
- private final IUserDeptRelationService userDeptRelationService;
- private final RedisUtil redisUtil;
- private final UserDeptRelationMapper userDeptRelationMapper;
- private final IUserService userService;
- private final CommonPropertiesConfig propertiesConfig;
- private final IDepartmentService baseDeparmentService;
- private final IBaseMajorService baseMajorService;
- private final IBaseClassService baseClassService;
- private final IBaseGradeService baseGradeService;
- private final IStudentChangeRecordService recordService;
- private IDictionarydetailService dictionarydetailService;
- private final UserMapper userMapper;
- @Override
- @Transactional(rollbackFor = Exception.class)
- public Long add(AddBaseStudentUserDto dto) {
- BaseStudentUser baseStudentUser = BeanUtil.toBean(dto, BaseStudentUser.class);
- baseStudentUser.setCode(dto.getUserName());
- // 用户身份证后6位作为默认密码
- baseStudentUser.setPassword(BCrypt.hashpw(propertiesConfig.getDefaultPassword(), BCrypt.gensalt()));
- baseStudentUserMapper.insert(baseStudentUser);
- for (BaseStudent baseStudent : baseStudentUser.getBaseStudentList()) {
- baseStudent.setUserId(baseStudentUser.getId());
- BaseStudentSchoolRoll baseStudentSchoolRoll = baseStudentUser.getBaseStudentSchoolRollList().get(0);
- if (!StrUtil.isNotBlank(baseStudentSchoolRoll.getArchivesStatus())) {
- baseStudent.setIsNormal(1);
- } else {
- DictionaryDetail dictionaryDetail = dictionarydetailService.getOne(Wrappers.<DictionaryDetail>query()
- .lambda()
- .eq(DictionaryDetail::getCode, baseStudentSchoolRoll.getArchivesStatus())
- .inSql(DictionaryDetail::getItemId, "SELECT id from xjr_dictionary_item where code='archives_status'"));
- if (dictionaryDetail != null) {
- if ("0".equals(dictionaryDetail.getExtendField1())) {
- baseStudent.setIsNormal(0);
- } else {
- baseStudent.setIsNormal(1);
- }
- }
- }
- baseStudentService.save(baseStudent);
- }
- for (BaseStudentContact baseStudentContact : baseStudentUser.getBaseStudentContactList()) {
- baseStudentContact.setUserId(baseStudentUser.getId());
- studentContactService.save(baseStudentContact);
- }
- for (BaseStudentFamily BaseStudentFamily : baseStudentUser.getBaseStudentFamilyList()) {
- BaseStudentFamily.setUserId(baseStudentUser.getId());
- familyMapper.insert(BaseStudentFamily);
- }
- for (BaseStudentFamilyMember BaseStudentFamilyMember : baseStudentUser.getBaseStudentFamilyMemberList()) {
- BaseStudentFamilyMember.setUserId(baseStudentUser.getId());
- familyMemberMapper.insert(BaseStudentFamilyMember);
- }
- for (BaseStudentSchoolRoll baseStudentSchoolRoll : baseStudentUser.getBaseStudentSchoolRollList()) {
- baseStudentSchoolRoll.setUserId(baseStudentUser.getId());
- schoolRollService.save(baseStudentSchoolRoll);
- }
- for (BaseStudentSubsidize baseStudentSubsidize : baseStudentUser.getBaseStudentSubsidizeList()) {
- baseStudentSubsidize.setUserId(baseStudentUser.getId());
- subsidizeService.save(baseStudentSubsidize);
- }
- List<UserDeptRelation> userDeptRelationList = new ArrayList<>();
- if (StrUtil.isNotBlank(dto.getDepartmentIds())) {
- String allDeptIdStr = StrUtil.join(StringPool.COMMA, dto.getDepartmentIds());
- List<Long> departmentIds = Arrays.stream(allDeptIdStr.split(StringPool.COMMA)).map(Convert::toLong).collect(Collectors.toList());
- if (CollectionUtil.isNotEmpty(departmentIds)) {
- for (Long deptId : departmentIds) {
- //将用户所选部门保存到关联表中
- UserDeptRelation userDeptRelation = new UserDeptRelation();
- userDeptRelation.setUserId(baseStudentUser.getId());
- userDeptRelation.setDeptId(deptId);
- userDeptRelationList.add(userDeptRelation);
- }
- }
- userDeptRelationService.saveBatch(userDeptRelationList);
- }
- // 添加角色
- UserRoleRelation userRoleRelation = new UserRoleRelation();
- userRoleRelation.setUserId(baseStudentUser.getId());
- userRoleRelation.setRoleId(RoleEnum.STUDENT.getCode());
- userRoleRelationMapper.insert(userRoleRelation);
- CompletableFuture.runAsync(() -> {
- List<User> list = userService.list();
- redisUtil.set(GlobalConstant.USER_CACHE_KEY, list);
- List<UserDeptRelation> deptRelationList = userDeptRelationMapper.selectList(Wrappers.lambdaQuery(UserDeptRelation.class));
- redisUtil.set(GlobalConstant.USER_DEPT_RELATION_CACHE_KEY, deptRelationList);
- List<UserRoleRelation> userRoleRelationList = userRoleRelationMapper.selectList(Wrappers.lambdaQuery(UserRoleRelation.class));
- redisUtil.set(GlobalConstant.USER_ROLE_RELATION_CACHE_KEY, userRoleRelationList);
- });
- return baseStudentUser.getId();
- }
- @Override
- @Transactional(rollbackFor = Exception.class)
- public Boolean update(UpdateBaseStudentUserDto dto) {
- List<BaseStudentUser> studentUserList = baseStudentUserMapper.selectList(
- new QueryWrapper<BaseStudentUser>().lambda()
- .eq(BaseStudentUser::getCredentialNumber, dto.getCredentialNumber())
- .ne(BaseStudentUser::getId, dto.getId())
- );
- if(!studentUserList.isEmpty()){
- throw new MyException("该身份证已被其他人占用,请检查是否正确");
- }
- BaseStudentUser baseStudentUser = BeanUtil.toBean(dto, BaseStudentUser.class);
- baseStudentUser.setCode(dto.getUserName());
- baseStudentUserMapper.updateById(baseStudentUser);
- //先删除再新增
- userDeptRelationService.remove(Wrappers.<UserDeptRelation>query().lambda().eq(UserDeptRelation::getUserId, baseStudentUser.getId()));
- List<UserDeptRelation> userDeptRelationList = new ArrayList<>();
- if (StrUtil.isNotBlank(dto.getDepartmentIds())) {
- String allDeptIdStr = StrUtil.join(StringPool.COMMA, dto.getDepartmentIds());
- List<Long> departmentIds = Arrays.stream(allDeptIdStr.split(StringPool.COMMA)).map(Convert::toLong).collect(Collectors.toList());
- if (CollectionUtil.isNotEmpty(departmentIds)) {
- for (Long deptId : departmentIds) {
- //将用户所选部门保存到关联表中
- UserDeptRelation userDeptRelation = new UserDeptRelation();
- userDeptRelation.setUserId(baseStudentUser.getId());
- userDeptRelation.setDeptId(deptId);
- userDeptRelationList.add(userDeptRelation);
- }
- }
- userDeptRelationService.saveBatch(userDeptRelationList);
- }
- //********************************* BaseStudent 增删改 开始 *******************************************/
- {
- // 查出所有子级的id
- List<BaseStudent> baseStudentList = baseStudentService.list(Wrappers.lambdaQuery(BaseStudent.class).eq(BaseStudent::getUserId, baseStudentUser.getId()).select(BaseStudent::getId));
- List<Long> baseStudentIds = baseStudentList.stream().map(BaseStudent::getId).collect(Collectors.toList());
- //原有子表单 没有被删除的主键
- List<Long> baseStudentOldIds = baseStudentUser.getBaseStudentList().stream().map(BaseStudent::getId).filter(Objects::nonNull).collect(Collectors.toList());
- //找到需要删除的id
- List<Long> baseStudentRemoveIds = baseStudentIds.stream().filter(item -> !baseStudentOldIds.contains(item)).collect(Collectors.toList());
- for (BaseStudent baseStudent : baseStudentUser.getBaseStudentList()) {
- BaseStudentSchoolRoll baseStudentSchoolRoll = baseStudentUser.getBaseStudentSchoolRollList().get(0);
- if (!StrUtil.isNotBlank(baseStudentSchoolRoll.getArchivesStatus())) {
- baseStudent.setIsNormal(1);
- } else {
- DictionaryDetail dictionaryDetail = dictionarydetailService.getOne(Wrappers.<DictionaryDetail>query()
- .lambda()
- .eq(DictionaryDetail::getCode, baseStudentSchoolRoll.getArchivesStatus())
- .inSql(DictionaryDetail::getItemId, "SELECT id from xjr_dictionary_item where code='archives_status'"));
- if (dictionaryDetail != null) {
- if ("0".equals(dictionaryDetail.getExtendField1())) {
- baseStudent.setIsNormal(0);
- } else {
- baseStudent.setIsNormal(1);
- }
- }
- }
- //如果不等于空则修改
- if (baseStudent.getId() != null) {
- baseStudentService.updateById(baseStudent);
- }
- //如果等于空 则新增
- else {
- //已经不存在的id 删除
- baseStudent.setUserId(baseStudentUser.getId());
- baseStudentService.save(baseStudent);
- }
- }
- //已经不存在的id 删除
- if (baseStudentRemoveIds.size() > 0) {
- baseStudentService.removeBatchByIds(baseStudentRemoveIds);
- }
- }
- //********************************* BaseStudent 增删改 结束 *******************************************/
- //********************************* BaseStudentContact 增删改 开始 *******************************************/
- {
- // 查出所有子级的id
- List<BaseStudentContact> baseStudentContactList = studentContactService.list(Wrappers.lambdaQuery(BaseStudentContact.class).eq(BaseStudentContact::getUserId, baseStudentUser.getId()).select(BaseStudentContact::getId));
- List<Long> baseStudentContactIds = baseStudentContactList.stream().map(BaseStudentContact::getId).collect(Collectors.toList());
- //原有子表单 没有被删除的主键
- List<Long> baseStudentContactOldIds = baseStudentUser.getBaseStudentContactList().stream().map(BaseStudentContact::getId).filter(Objects::nonNull).collect(Collectors.toList());
- //找到需要删除的id
- List<Long> baseStudentContactRemoveIds = baseStudentContactIds.stream().filter(item -> !baseStudentContactOldIds.contains(item)).collect(Collectors.toList());
- for (BaseStudentContact baseStudentContact : baseStudentUser.getBaseStudentContactList()) {
- //如果不等于空则修改
- if (baseStudentContact.getId() != null) {
- studentContactService.updateById(baseStudentContact);
- }
- //如果等于空 则新增
- else {
- //已经不存在的id 删除
- baseStudentContact.setUserId(baseStudentUser.getId());
- studentContactService.save(baseStudentContact);
- }
- }
- //已经不存在的id 删除
- if (baseStudentContactRemoveIds.size() > 0) {
- studentContactService.removeBatchByIds(baseStudentContactRemoveIds);
- }
- }
- //********************************* BaseStudentContact 增删改 结束 *******************************************/
- //********************************* BaseStudentFamily 增删改 开始 *******************************************/
- {
- // 查出所有子级的id
- List<BaseStudentFamily> BaseStudentFamilyList = familyMapper.selectList(Wrappers.lambdaQuery(BaseStudentFamily.class).eq(BaseStudentFamily::getUserId, baseStudentUser.getId()).select(BaseStudentFamily::getId));
- List<Long> BaseStudentFamilyIds = BaseStudentFamilyList.stream().map(BaseStudentFamily::getId).collect(Collectors.toList());
- //原有子表单 没有被删除的主键
- List<Long> BaseStudentFamilyOldIds = baseStudentUser.getBaseStudentFamilyList().stream().map(BaseStudentFamily::getId).filter(Objects::nonNull).collect(Collectors.toList());
- //找到需要删除的id
- List<Long> BaseStudentFamilyRemoveIds = BaseStudentFamilyIds.stream().filter(item -> !BaseStudentFamilyOldIds.contains(item)).collect(Collectors.toList());
- for (BaseStudentFamily BaseStudentFamily : baseStudentUser.getBaseStudentFamilyList()) {
- //如果不等于空则修改
- if (BaseStudentFamily.getId() != null) {
- familyMapper.updateById(BaseStudentFamily);
- }
- //如果等于空 则新增
- else {
- //已经不存在的id 删除
- BaseStudentFamily.setUserId(baseStudentUser.getId());
- familyMapper.insert(BaseStudentFamily);
- }
- }
- //已经不存在的id 删除
- if (BaseStudentFamilyRemoveIds.size() > 0) {
- familyMapper.deleteBatchIds(BaseStudentFamilyRemoveIds);
- }
- }
- //********************************* BaseStudentFamily 增删改 结束 *******************************************/
- //********************************* BaseStudentFamilyMember 增删改 开始 *******************************************/
- {
- // 查出所有子级的id
- List<BaseStudentFamilyMember> BaseStudentFamilyMemberList = familyMemberMapper.selectList(Wrappers.lambdaQuery(BaseStudentFamilyMember.class).eq(BaseStudentFamilyMember::getUserId, baseStudentUser.getId()).select(BaseStudentFamilyMember::getId));
- List<Long> BaseStudentFamilyMemberIds = BaseStudentFamilyMemberList.stream().map(BaseStudentFamilyMember::getId).collect(Collectors.toList());
- //原有子表单 没有被删除的主键
- List<Long> BaseStudentFamilyMemberOldIds = baseStudentUser.getBaseStudentFamilyMemberList().stream().map(BaseStudentFamilyMember::getId).filter(Objects::nonNull).collect(Collectors.toList());
- //找到需要删除的id
- List<Long> BaseStudentFamilyMemberRemoveIds = BaseStudentFamilyMemberIds.stream().filter(item -> !BaseStudentFamilyMemberOldIds.contains(item)).collect(Collectors.toList());
- for (BaseStudentFamilyMember BaseStudentFamilyMember : baseStudentUser.getBaseStudentFamilyMemberList()) {
- //如果不等于空则修改
- if (BaseStudentFamilyMember.getId() != null) {
- familyMemberMapper.updateById(BaseStudentFamilyMember);
- }
- //如果等于空 则新增
- else {
- //已经不存在的id 删除
- BaseStudentFamilyMember.setUserId(baseStudentUser.getId());
- familyMemberMapper.insert(BaseStudentFamilyMember);
- }
- }
- //已经不存在的id 删除
- if (BaseStudentFamilyMemberRemoveIds.size() > 0) {
- familyMemberMapper.deleteBatchIds(BaseStudentFamilyMemberRemoveIds);
- }
- }
- //********************************* BaseStudentFamilyMember 增删改 结束 *******************************************/
- //********************************* StudentSchoolRoll 增删改 开始 *******************************************/
- {
- // 查出所有子级的id
- List<BaseStudentSchoolRoll> baseStudentSchoolRollList = schoolRollService.list(Wrappers.lambdaQuery(BaseStudentSchoolRoll.class).eq(BaseStudentSchoolRoll::getUserId, baseStudentUser.getId()).select(BaseStudentSchoolRoll::getId));
- List<Long> baseStudentSchoolRollIds = baseStudentSchoolRollList.stream().map(BaseStudentSchoolRoll::getId).collect(Collectors.toList());
- //原有子表单 没有被删除的主键
- List<Long> baseStudentSchoolRollOldIds = baseStudentUser.getBaseStudentSchoolRollList().stream().map(BaseStudentSchoolRoll::getId).filter(Objects::nonNull).collect(Collectors.toList());
- //找到需要删除的id
- List<Long> baseStudentSchoolRollRemoveIds = baseStudentSchoolRollIds.stream().filter(item -> !baseStudentSchoolRollOldIds.contains(item)).collect(Collectors.toList());
- for (BaseStudentSchoolRoll baseStudentSchoolRoll : baseStudentUser.getBaseStudentSchoolRollList()) {
- //如果不等于空则修改
- if (baseStudentSchoolRoll.getId() != null) {
- BaseStudentSchoolRoll beforeRoll = schoolRollService.getById(baseStudentSchoolRoll.getId());
- recordService.insertDataByStudentUpdate(beforeRoll, baseStudentSchoolRoll);
- schoolRollService.updateById(baseStudentSchoolRoll);
- }
- //如果等于空 则新增
- else {
- //已经不存在的id 删除
- baseStudentSchoolRoll.setUserId(baseStudentUser.getId());
- schoolRollService.save(baseStudentSchoolRoll);
- }
- }
- //已经不存在的id 删除
- if (baseStudentSchoolRollRemoveIds.size() > 0) {
- schoolRollService.removeBatchByIds(baseStudentSchoolRollRemoveIds);
- }
- }
- //********************************* StudentSchoolRoll 增删改 结束 *******************************************/
- //********************************* BaseStudentSubsidize 增删改 开始 *******************************************/
- {
- // 查出所有子级的id
- List<BaseStudentSubsidize> baseStudentSubsidizeList = subsidizeService.list(Wrappers.lambdaQuery(BaseStudentSubsidize.class).eq(BaseStudentSubsidize::getUserId, baseStudentUser.getId()).select(BaseStudentSubsidize::getId));
- List<Long> baseStudentSubsidizeIds = baseStudentSubsidizeList.stream().map(BaseStudentSubsidize::getId).collect(Collectors.toList());
- //原有子表单 没有被删除的主键
- List<Long> baseStudentSubsidizeOldIds = baseStudentUser.getBaseStudentSubsidizeList().stream().map(BaseStudentSubsidize::getId).filter(Objects::nonNull).collect(Collectors.toList());
- //找到需要删除的id
- List<Long> baseStudentSubsidizeRemoveIds = baseStudentSubsidizeIds.stream().filter(item -> !baseStudentSubsidizeOldIds.contains(item)).collect(Collectors.toList());
- for (BaseStudentSubsidize BaseStudentEducation : baseStudentUser.getBaseStudentSubsidizeList()) {
- //如果不等于空则修改
- if (BaseStudentEducation.getId() != null) {
- subsidizeService.updateById(BaseStudentEducation);
- }
- //如果等于空 则新增
- else {
- //已经不存在的id 删除
- BaseStudentEducation.setUserId(baseStudentUser.getId());
- subsidizeService.save(BaseStudentEducation);
- }
- }
- //已经不存在的id 删除
- if (baseStudentSubsidizeRemoveIds.size() > 0) {
- subsidizeService.removeBatchByIds(baseStudentSubsidizeRemoveIds);
- }
- }
- //********************************* BaseStudentEducation 增删改 结束 *******************************************/
- return true;
- }
- @Override
- @Transactional(rollbackFor = Exception.class)
- public Boolean delete(List<Long> ids) {
- baseStudentUserMapper.deleteBatchIds(ids);
- baseStudentService.remove(Wrappers.lambdaQuery(BaseStudent.class).in(BaseStudent::getUserId, ids));
- studentContactService.remove(Wrappers.lambdaQuery(BaseStudentContact.class).in(BaseStudentContact::getUserId, ids));
- familyMapper.delete(Wrappers.lambdaQuery(BaseStudentFamily.class).in(BaseStudentFamily::getUserId, ids));
- familyMemberMapper.delete(Wrappers.lambdaQuery(BaseStudentFamilyMember.class).in(BaseStudentFamilyMember::getUserId, ids));
- schoolRollService.remove(Wrappers.lambdaQuery(BaseStudentSchoolRoll.class).in(BaseStudentSchoolRoll::getUserId, ids));
- subsidizeService.remove(Wrappers.lambdaQuery(BaseStudentSubsidize.class).in(BaseStudentSubsidize::getUserId, ids));
- return true;
- }
- @Override
- public BaseStudentClassVo getStudentClass(Long userId) {
- MPJLambdaWrapper<BaseClass> queryWrapper = new MPJLambdaWrapper<>();
- queryWrapper
- .disableSubLogicDel()
- .innerJoin(BaseStudentSchoolRoll.class, BaseStudentSchoolRoll::getClassId, BaseStudent::getId)
- .eq(BaseStudentSchoolRoll::getUserId, userId)
- .selectAsClass(BaseClass.class, BaseStudentClassVo.class);
- BaseClass baseClass = baseClassMapper.selectOne(queryWrapper);
- return BeanUtil.toBean(baseClass, BaseStudentClassVo.class);
- }
- /**
- * 个人财务画像,获取学生个人信息
- */
- @Override
- public PersonalPortraitPersonalInfoVo getPersonalInfo(Long userId) {
- StudentPersonalInfoVo info = baseStudentService.getPersonalInfo(userId);
- PersonalPortraitPersonalInfoVo p = new PersonalPortraitPersonalInfoVo();
- BeanUtils.copyProperties(info, p);
- List<BaseStudentFamilyMember> members = familyMemberMapper.selectList(
- new QueryWrapper<BaseStudentFamilyMember>().lambda()
- .eq(BaseStudentFamilyMember::getUserId, userId)
- .eq(BaseStudentFamilyMember::getIsGuardian, 1)
- );
- String guardianPhone = "";
- for (int i = 0; i < members.size(); i++) {
- if (i > 0) {
- guardianPhone += ",";
- }
- guardianPhone += members.get(i).getMobile();
- }
- if (StrUtil.isNotEmpty(guardianPhone)) {
- info.setGuardianPhone(guardianPhone);
- }
- return p;
- }
- @Override
- public List<BaseStudentSompleInfoVo> importStudentData(List<Map<Integer, Object>> excelDataList) throws ParseException {
- List<String> idNumbers = new ArrayList<>();
- for (Map<Integer, Object> integerObjectMap : excelDataList) {
- idNumbers.add(integerObjectMap.get(0).toString());
- }
- List<BaseStudentSompleInfoVo> infos = userMapper.getInfosByParam(new BaseStudentSimpleInfoDto() {{
- setIdNumberList(idNumbers);
- }});
- if(!infos.isEmpty()){
- return infos;
- }
- //查询所有学生的用户信息,组装起来备用
- List<BaseStudentUser> studentUsers = this.selectJoinList(BaseStudentUser.class,
- new MPJLambdaWrapper<BaseStudentUser>()
- .leftJoin(BaseStudent.class, BaseStudent::getUserId, BaseStudentUser::getId)
- .in(BaseStudentUser::getCredentialNumber, idNumbers)
- );
- Map<String, BaseStudentUser> studentUserMap = new HashMap<>();
- Set<Long> userIds = new HashSet<>();
- for (BaseStudentUser studentUser : studentUsers) {
- studentUserMap.put(studentUser.getCredentialNumber(), studentUser);
- userIds.add(studentUser.getId());
- }
- //查询所有的学生信息,组装起来备用
- List<BaseStudent> baseStudents = baseStudentService.selectJoinList(BaseStudent.class,
- new MPJLambdaWrapper<BaseStudent>()
- .leftJoin(BaseStudentUser.class, BaseStudentUser::getId, BaseStudent::getUserId)
- .in(BaseStudentUser::getCredentialNumber, idNumbers)
- );
- Map<Long, BaseStudent> baseStudentMap = new HashMap<>();
- for (BaseStudent studentUser : baseStudents) {
- baseStudentMap.put(studentUser.getUserId(), studentUser);
- }
- //查询所用到的字典
- Map<String, String> dictionary = initDictionary();
- //查行政区划
- List<Area> areaList = areaService.list();
- Map<String, Long> areaMap = new HashMap<>();
- for (Area area : areaList) {
- areaMap.put(area.getName(), Long.parseLong(area.getCode()));
- }
- List<BaseStudentSchoolRoll> baseStudentSchoolRolls = schoolRollService.selectJoinList(BaseStudentSchoolRoll.class,
- new MPJLambdaWrapper<BaseStudentSchoolRoll>()
- .leftJoin(BaseStudent.class, BaseStudent::getUserId, BaseStudentSchoolRoll::getUserId)
- .in(!userIds.isEmpty(), BaseStudentSchoolRoll::getUserId, userIds)
- );
- Map<Long, BaseStudentSchoolRoll> studentSchoolRollMap = new HashMap<>();
- for (BaseStudentSchoolRoll schoolRoll : baseStudentSchoolRolls) {
- studentSchoolRollMap.put(schoolRoll.getUserId(), schoolRoll);
- }
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- //查询年级
- List<BaseGrade> gradeList = baseGradeMapper.selectList(new QueryWrapper<BaseGrade>().lambda().eq(BaseGrade::getDeleteMark, DeleteMark.NODELETE.getCode()));
- Map<String, Long> gradeMap = new HashMap<>();
- for (BaseGrade grade : gradeList) {
- gradeMap.put(grade.getName(), grade.getId());
- }
- //查询班级
- List<BaseClass> classList = baseClassMapper.selectList(new QueryWrapper<BaseClass>().lambda().eq(BaseClass::getDeleteMark, DeleteMark.NODELETE.getCode()));
- Map<String, Long> classMap = new HashMap<>();
- for (BaseClass grade : classList) {
- classMap.put(grade.getName(), grade.getId());
- }
- //查询专业
- List<BaseMajorSet> majorSetList = baseMajorSetMapper.selectList(new QueryWrapper<BaseMajorSet>().lambda().eq(BaseMajorSet::getDeleteMark, DeleteMark.NODELETE.getCode()));
- Map<String, Long> majorSetMap = new HashMap<>();
- for (BaseMajorSet baseMajorSet : majorSetList) {
- majorSetMap.put(baseMajorSet.getName(), baseMajorSet.getId());
- }
- //查询资助
- List<BaseStudentSubsidize> baseStudentSubsidizes = subsidizeService.list(null);
- Map<Long, BaseStudentSubsidize> subsidizesMap = new HashMap<>();
- for (BaseStudentSubsidize el : baseStudentSubsidizes) {
- subsidizesMap.put(el.getUserId(), el);
- }
- //查询家庭
- List<BaseStudentFamily> studentFamilies = familyMapper.selectList(null);
- Map<Long, BaseStudentFamily> familyMap = new HashMap<>();
- for (BaseStudentFamily el : studentFamilies) {
- familyMap.put(el.getUserId(), el);
- }
- //查询联系信息
- List<BaseStudentContact> contactList = studentContactService.list();
- Map<Long, BaseStudentContact> contactMap = new HashMap<>();
- for (BaseStudentContact el : contactList) {
- contactMap.put(el.getUserId(), el);
- }
- List<BaseStudentUser> updateStudentUserList = new ArrayList();
- List<BaseStudent> updateBaseStudentList = new ArrayList();
- List<BaseStudentSchoolRoll> updateSchoolRollList = new ArrayList();
- List<BaseStudentSubsidize> updateSubsidizeList = new ArrayList();
- List<BaseStudentFamily> updateFamilyList = new ArrayList();
- List<BaseStudentContact> updateContactList = new ArrayList();
- List<BaseStudentUser> insertStudentUserList = new ArrayList();
- List<BaseStudent> insertBaseStudentList = new ArrayList();
- List<BaseStudentSchoolRoll> insertSchoolRollList = new ArrayList();
- List<BaseStudentSubsidize> insertSubsidizeList = new ArrayList();
- List<BaseStudentFamily> insertFamilyList = new ArrayList();
- List<BaseStudentContact> insertContactList = new ArrayList();
- //异动记录
- List<StudentChangeRecord> changeRecordList = new ArrayList();
- long createUserId = StpUtil.getLoginIdAsLong();
- // long createUserId = 1000000000000000000L;
- int row = 3;
- for (Map<Integer, Object> dataMaps : excelDataList) {
- if (dataMaps.get(0) == null) {
- throw new MyException("第" + row + "行数据身份证号为空,无法导入");
- }
- String credentialNumber = dataMaps.get(0).toString();//身份证号
- //已存在,更新
- BaseStudentUser user = studentUserMap.get(credentialNumber);
- BaseStudent baseStudent;
- BaseStudentSchoolRoll schoolRoll;
- BaseStudentSubsidize subsidize;
- BaseStudentFamily studentFamily;
- BaseStudentContact contact;
- long userId = IdUtil.getSnowflakeNextId();
- if (user != null) {
- userId = user.getId();
- user.setDeleteMark(DeleteMark.NODELETE.getCode());
- baseStudent = baseStudentMap.get(user.getId());
- if (baseStudent == null) {
- baseStudent = new BaseStudent();
- baseStudent.setUserId(userId);
- baseStudent.setCreateUserId(createUserId);
- baseStudent.setCreateDate(LocalDateTime.now());
- }
- baseStudent.setDeleteMark(DeleteMark.NODELETE.getCode());
- schoolRoll = studentSchoolRollMap.get(user.getId());
- if (schoolRoll == null) {
- schoolRoll = new BaseStudentSchoolRoll();
- schoolRoll.setUserId(userId);
- schoolRoll.setCreateUserId(createUserId);
- schoolRoll.setCreateDate(LocalDateTime.now());
- }
- schoolRoll.setDeleteMark(DeleteMark.NODELETE.getCode());
- subsidize = subsidizesMap.get(user.getId());
- if (subsidize == null) {
- subsidize = new BaseStudentSubsidize();
- subsidize.setUserId(userId);
- subsidize.setCreateUserId(createUserId);
- subsidize.setCreateDate(LocalDateTime.now());
- }
- subsidize.setDeleteMark(DeleteMark.NODELETE.getCode());
- studentFamily = familyMap.get(user.getId());
- if (studentFamily == null) {
- studentFamily = new BaseStudentFamily();
- studentFamily.setUserId(userId);
- studentFamily.setCreateUserId(createUserId);
- studentFamily.setCreateDate(LocalDateTime.now());
- }
- studentFamily.setDeleteMark(DeleteMark.NODELETE.getCode());
- contact = contactMap.get(user.getId());
- if (contact == null) {
- contact = new BaseStudentContact();
- contact.setUserId(userId);
- contact.setCreateUserId(createUserId);
- contact.setCreateDate(LocalDateTime.now());
- }
- contact.setDeleteMark(DeleteMark.NODELETE.getCode());
- } else {
- user = new BaseStudentUser();
- user.setId(userId);
- user.setUserName(credentialNumber);
- user.setCredentialNumber(credentialNumber);
- user.setCreateUserId(createUserId);
- user.setCreateDate(LocalDateTime.now());
- baseStudent = new BaseStudent();
- baseStudent.setUserId(userId);
- baseStudent.setCreateUserId(createUserId);
- baseStudent.setCreateDate(LocalDateTime.now());
- schoolRoll = new BaseStudentSchoolRoll();
- schoolRoll.setUserId(userId);
- schoolRoll.setCreateUserId(createUserId);
- schoolRoll.setCreateDate(LocalDateTime.now());
- subsidize = new BaseStudentSubsidize();
- subsidize.setUserId(userId);
- subsidize.setCreateUserId(createUserId);
- subsidize.setCreateDate(LocalDateTime.now());
- studentFamily = new BaseStudentFamily();
- studentFamily.setUserId(userId);
- studentFamily.setCreateUserId(createUserId);
- studentFamily.setCreateDate(LocalDateTime.now());
- contact = new BaseStudentContact();
- contact.setUserId(userId);
- contact.setCreateUserId(createUserId);
- contact.setCreateDate(LocalDateTime.now());
- }
- //设置字段值
- if (dataMaps.get(1) != null && !"".equals(dataMaps.get(1).toString())) {
- baseStudent.setStudentId(dataMaps.get(1).toString());//学号
- }
- if (dataMaps.get(2) != null && !"".equals(dataMaps.get(2).toString())) {
- schoolRoll.setCandidateNumber(dataMaps.get(2).toString());//考号
- }
- if (dataMaps.get(3) != null && !"".equals(dataMaps.get(3).toString())) {
- user.setName(dataMaps.get(3).toString());//姓名
- }
- if (dataMaps.get(4) != null && !"".equals(dataMaps.get(4).toString())) {
- user.setGender(GenderDictionaryEnum.getCode(dataMaps.get(4).toString()));//性别
- }
- if (dataMaps.get(5) != null && !"".equals(dataMaps.get(5).toString())) {
- user.setMobile(dataMaps.get(5).toString());//手机号
- }
- if (dataMaps.get(6) != null && !"".equals(dataMaps.get(6).toString())) {
- user.setEmail(dataMaps.get(6).toString());//邮箱
- }
- if (dataMaps.get(7) != null && !"".equals(dataMaps.get(7).toString())) {
- baseStudent.setAsName(dataMaps.get(7).toString());//别名
- }
- if (dataMaps.get(8) != null && !"".equals(dataMaps.get(8).toString())) {
- baseStudent.setEnName(dataMaps.get(8).toString());//英文名
- }
- if (dataMaps.get(9) != null && !"".equals(dataMaps.get(9).toString())) {
- baseStudent.setPyName(dataMaps.get(9).toString());//姓名拼音
- }
- if (dataMaps.get(10) != null && !"".equals(dataMaps.get(10).toString())) {
- baseStudent.setFormerName(dataMaps.get(10).toString());//曾用名
- }
- if (dataMaps.get(11) != null && !"".equals(dataMaps.get(11).toString())) {
- user.setCredentialType(dictionary.get("credential_type" + dataMaps.get(11).toString()));//证件类型
- }
- if (dataMaps.get(12) != null && !"".equals(dataMaps.get(12).toString())) {
- LocalDateTime birthday = parseLocalDateTime(dataMaps.get(12).toString());
- user.setBirthDate(birthday);//出生日期
- baseStudent.setDayOfBirth(birthday.toLocalDate());//出生日期
- }
- if (dataMaps.get(13) != null && !"".equals(dataMaps.get(13).toString())) {
- baseStudent.setBirthType(dictionary.get("date_type" + dataMaps.get(13).toString()));//生日类型
- }
- if (dataMaps.get(14) != null && !"".equals(dataMaps.get(14).toString())) {
- baseStudent.setNation(dictionary.get("nation" + dataMaps.get(14).toString()));//民族
- }
- if (dataMaps.get(15) != null && !"".equals(dataMaps.get(15).toString())) {
- baseStudent.setBloodType(dictionary.get("blood_type" + dataMaps.get(15).toString()));//血型
- }
- if (dataMaps.get(16) != null && !"".equals(dataMaps.get(16).toString())) {
- baseStudent.setHealth(dictionary.get("health" + dataMaps.get(16).toString()));//健康状况
- }
- if (dataMaps.get(17) != null && !"".equals(dataMaps.get(17).toString())) {
- baseStudent.setMaritalState(dictionary.get("marital_state" + dataMaps.get(17).toString()));//婚姻状况
- }
- if (dataMaps.get(18) != null && !"".equals(dataMaps.get(18).toString())) {
- baseStudent.setPoliticalState(dictionary.get("political_state" + dataMaps.get(18).toString()));//政治面貌
- }
- if (dataMaps.get(19) != null && !"".equals(dataMaps.get(19).toString())) {
- baseStudent.setNationality(dictionary.get("nationality" + dataMaps.get(19).toString()));//国籍地区
- }
- if (dataMaps.get(20) != null && !"".equals(dataMaps.get(20).toString())) {
- baseStudent.setChineseType(dictionary.get("chinese_type" + dataMaps.get(20).toString()));//港澳台侨外
- }
- if (dataMaps.get(21) != null && !"".equals(dataMaps.get(21).toString())) {
- baseStudent.setHouseHoldType(dictionary.get("house_hold_type" + dataMaps.get(21).toString()));//户口类别
- }
- if (dataMaps.get(22) != null && !"".equals(dataMaps.get(22).toString())) {
- baseStudent.setNativePlaceType(dataMaps.get(22).toString());//籍贯类型
- }
- if (dataMaps.get(23) != null && !"".equals(dataMaps.get(23).toString())) {
- baseStudent.setProvinces(areaMap.get(dataMaps.get(23).toString()));//省
- }
- if (dataMaps.get(24) != null && !"".equals(dataMaps.get(24).toString())) {
- baseStudent.setCity(areaMap.get(dataMaps.get(24).toString()));//市
- }
- if (dataMaps.get(25) != null && !"".equals(dataMaps.get(25).toString())) {
- baseStudent.setDistrict(areaMap.get(dataMaps.get(25).toString()));//区县
- }
- if (dataMaps.get(26) != null && !"".equals(dataMaps.get(26).toString())) {
- baseStudent.setHouseProvinces(areaMap.get(dataMaps.get(26).toString()));//户口所在地省
- }
- if (dataMaps.get(27) != null && !"".equals(dataMaps.get(27).toString())) {
- baseStudent.setHouseCity(areaMap.get(dataMaps.get(27).toString()));//户口所在地市
- }
- if (dataMaps.get(28) != null && !"".equals(dataMaps.get(28).toString())) {
- baseStudent.setHouseDistrict(areaMap.get(dataMaps.get(28).toString()));//户口所在地区/县
- }
- if (dataMaps.get(29) != null && !"".equals(dataMaps.get(29).toString())) {
- baseStudent.setBelongsPolice(dataMaps.get(29).toString());//户口所属派出所
- }
- if (dataMaps.get(30) != null && !"".equals(dataMaps.get(30).toString())) {
- baseStudent.setBirthProvinces(areaMap.get(dataMaps.get(30).toString()));//出生所在地省
- }
- if (dataMaps.get(31) != null && !"".equals(dataMaps.get(31).toString())) {
- baseStudent.setBirthCity(areaMap.get(dataMaps.get(31).toString()));//出生所在地市
- }
- if (dataMaps.get(32) != null && !"".equals(dataMaps.get(32).toString())) {
- baseStudent.setBirthDistrict(areaMap.get(dataMaps.get(32).toString()));//出生所在地/区县
- }
- if (dataMaps.get(33) != null && !"".equals(dataMaps.get(33).toString())) {
- baseStudent.setHouseHoldAddress(dataMaps.get(33).toString());//户籍地址
- }
- if (dataMaps.get(34) != null && !"".equals(dataMaps.get(34).toString())) {
- baseStudent.setResidenceType(dictionary.get("residence_type" + dataMaps.get(34).toString()));//学生居住地类型
- }
- if (dataMaps.get(35) != null && !"".equals(dataMaps.get(35).toString())) {
- baseStudent.setTrainInterval(dataMaps.get(35).toString());//乘火车区间
- }
- if (dataMaps.get(36) != null && !"".equals(dataMaps.get(36).toString())) {
- baseStudent.setIsMigrateChildren(YesOrNoEnum.getCode(dataMaps.get(36).toString()));//是否随迁子女
- }
- if (dataMaps.get(37) != null && !"".equals(dataMaps.get(37).toString())) {
- baseStudent.setIsFloatingPopulation(YesOrNoEnum.getCode(dataMaps.get(37).toString()));//是否流动人口
- }
- if (dataMaps.get(38) != null && !"".equals(dataMaps.get(38).toString())) {
- baseStudent.setHeight(Double.parseDouble(dataMaps.get(38).toString()));//身高
- }
- if (dataMaps.get(39) != null && !"".equals(dataMaps.get(39).toString())) {
- baseStudent.setWeight(Double.parseDouble(dataMaps.get(39).toString()));//体重
- }
- if (dataMaps.get(40) != null && !"".equals(dataMaps.get(40).toString())) {
- baseStudent.setVision(Double.parseDouble(dataMaps.get(40).toString()));//视力
- }
- if (dataMaps.get(41) != null && !"".equals(dataMaps.get(41).toString())) {
- baseStudent.setSpecialty(dataMaps.get(41).toString());//特长
- }
- if (dataMaps.get(42) != null && !"".equals(dataMaps.get(42).toString())) {
- user.setQqNumber(dataMaps.get(42).toString());//QQ&MSN
- contact.setQqMsn(dataMaps.get(42).toString());//QQ&MSN
- }
- if (dataMaps.get(43) != null && !"".equals(dataMaps.get(43).toString())) {
- user.setWechatNumber(dataMaps.get(43).toString());//微信号码
- contact.setWechat(dataMaps.get(43).toString());//微信号码
- }
- if (dataMaps.get(44) != null && !"".equals(dataMaps.get(44).toString())) {
- contact.setUserPage(dataMaps.get(44).toString());//个人主页
- }
- if (dataMaps.get(45) != null && !"".equals(dataMaps.get(45).toString())) {
- schoolRoll.setRollNumber(dataMaps.get(45).toString());//学籍号
- }
- if (dataMaps.get(46) != null && !"".equals(dataMaps.get(46).toString())) {
- schoolRoll.setArchivesNumber(dataMaps.get(46).toString());//学生档案编号
- }
- if (dataMaps.get(47) != null && !"".equals(dataMaps.get(47).toString())) {
- schoolRoll.setEnrollmentDate(sdf.parse(dataMaps.get(47).toString()));//入学年月
- }
- if (dataMaps.get(48) != null && !"".equals(dataMaps.get(48).toString())) {
- schoolRoll.setEnrollmentType(dictionary.get("enrollment_type" + dataMaps.get(48).toString()));//入学方式
- }
- if (dataMaps.get(49) != null && !"".equals(dataMaps.get(49).toString())) {
- schoolRoll.setGradeId(gradeMap.get(dataMaps.get(49).toString()));//入学年级
- }
- if (dataMaps.get(50) != null && !"".equals(dataMaps.get(50).toString())) {
- schoolRoll.setEnrollType(dictionary.get("enroll_type" + dataMaps.get(50).toString()));//入学招生类型
- }
- if (dataMaps.get(51) != null && !"".equals(dataMaps.get(51).toString())) {
- schoolRoll.setMajorSetId(majorSetMap.get(dataMaps.get(51).toString()));//在读专业方向
- }
- if (dataMaps.get(52) != null && !"".equals(dataMaps.get(52).toString())) {
- schoolRoll.setStudyYear(Double.parseDouble(dataMaps.get(52).toString()));//学制
- }
- if (dataMaps.get(53) != null && !"".equals(dataMaps.get(53).toString())) {
- //schoolRoll.setClassId(classMap.get(dataMaps.get(53).toString()));//班级
- }
- if (dataMaps.get(54) != null && !"".equals(dataMaps.get(54).toString())) {
- schoolRoll.setStudentSource(dictionary.get("student_type" + dataMaps.get(54).toString()));//学生来源
- }
- if (dataMaps.get(55) != null && !"".equals(dataMaps.get(55).toString())) {
- //schoolRoll.setStudentType(dictionary.get("student_type" + dataMaps.get(55).toString()));//学生类别
- }
- if (dataMaps.get(56) != null && !"".equals(dataMaps.get(56).toString())) {
- //schoolRoll.setArchivesStatus(dictionary.get("archives_status" + dataMaps.get(56).toString()));//学籍状态
- }
- if (dataMaps.get(57) != null && !"".equals(dataMaps.get(57).toString())) {
- //schoolRoll.setLearnStatus(dictionary.get("roll_modality" + dataMaps.get(57).toString()));//学习形式
- //schoolRoll.setRollModality(dictionary.get("roll_modality" + dataMaps.get(57).toString()));//学习形式
- }
- if (dataMaps.get(58) != null && !"".equals(dataMaps.get(58).toString())) {
- //schoolRoll.setStduyStatus(dictionary.get("stduy_status" + dataMaps.get(58).toString()));//就读方式
- }
- if (dataMaps.get(59) != null && !"".equals(dataMaps.get(59).toString())) {
- schoolRoll.setChooseStatus(dictionary.get("choose_status" + dataMaps.get(59).toString()));//分流状态
- }
- if (dataMaps.get(60) != null && !"".equals(dataMaps.get(60).toString())) {
- schoolRoll.setFosterType(dictionary.get("foster_type" + dataMaps.get(60).toString()));//分段培养方式
- }
- if (dataMaps.get(61) != null && !"".equals(dataMaps.get(61).toString())) {
- schoolRoll.setRecruitType(dictionary.get("recruit_type" + dataMaps.get(61).toString()));//招生类型
- }
- if (dataMaps.get(62) != null && !"".equals(dataMaps.get(62).toString())) {
- schoolRoll.setRecruitTarget(dictionary.get("recruit_target" + dataMaps.get(62).toString()));//招生对象
- }
- if (dataMaps.get(63) != null && !"".equals(dataMaps.get(63).toString())) {
- schoolRoll.setHighestEducation(dictionary.get("education" + dataMaps.get(63).toString()));//入学前最高学历
- }
- if (dataMaps.get(64) != null && !"".equals(dataMaps.get(64).toString())) {
- schoolRoll.setGraduatedUniversity(dataMaps.get(64).toString());//入学前毕业院校
- }
- if (dataMaps.get(65) != null && !"".equals(dataMaps.get(65).toString())) {
- schoolRoll.setGraduatedScore(Double.parseDouble(dataMaps.get(65).toString()));//入学前毕业成绩
- }
- if (dataMaps.get(66) != null && !"".equals(dataMaps.get(66).toString())) {
- schoolRoll.setExamineeNumber(dataMaps.get(66).toString());//入学考试准考证号
- }
- if (dataMaps.get(67) != null && !"".equals(dataMaps.get(67).toString())) {
- schoolRoll.setTicketNumber(dataMaps.get(67).toString());//入学考试准考证号
- }
- if (dataMaps.get(68) != null && !"".equals(dataMaps.get(68).toString())) {
- schoolRoll.setAdmissionScores(Double.parseDouble(dataMaps.get(68).toString()));//入学考试成绩
- }
- if (dataMaps.get(69) != null && !"".equals(dataMaps.get(69).toString())) {
- schoolRoll.setRemark(dataMaps.get(69).toString());//备注
- }
- if (dataMaps.get(69) != null && !"".equals(dataMaps.get(69).toString())) {
- schoolRoll.setRemark(dataMaps.get(69).toString());//备注
- }
- if (dataMaps.get(70) != null && !"".equals(dataMaps.get(70).toString())) {
- subsidize.setIsIndemnify(YesOrNoEnum.getCode(dataMaps.get(70).toString()));//是否低保户
- }
- if (dataMaps.get(71) != null && !"".equals(dataMaps.get(71).toString())) {
- subsidize.setIsStipend(YesOrNoEnum.getCode(dataMaps.get(71).toString()));//是否享受国家助学金
- }
- if (dataMaps.get(72) != null && !"".equals(dataMaps.get(72).toString())) {
- subsidize.setStipendStand(Double.parseDouble(dataMaps.get(72).toString()));//助学金发放标准(元)
- }
- if (dataMaps.get(73) != null && !"".equals(dataMaps.get(73).toString())) {
- subsidize.setStipendNumber(dataMaps.get(73).toString());//学生资助卡号
- }
- if (dataMaps.get(74) != null && !"".equals(dataMaps.get(74).toString())) {
- subsidize.setIsFree(YesOrNoEnum.getCode(dataMaps.get(74).toString()));//是否免学费
- }
- if (dataMaps.get(75) != null && !"".equals(dataMaps.get(75).toString())) {
- subsidize.setIsFilingCard(YesOrNoEnum.getCode(dataMaps.get(75).toString()));//是否建档立卡
- }
- if (dataMaps.get(76) != null && !"".equals(dataMaps.get(76).toString())) {
- studentFamily.setZipCode(dataMaps.get(76).toString());//家庭邮编
- }
- if (dataMaps.get(77) != null && !"".equals(dataMaps.get(77).toString())) {
- studentFamily.setTelephone(dataMaps.get(77).toString());//家庭电话
- }
- if (dataMaps.get(78) != null && !"".equals(dataMaps.get(78).toString())) {
- studentFamily.setContact(dataMaps.get(76).toString());//联系人姓名
- }
- if (dataMaps.get(79) != null && !"".equals(dataMaps.get(79).toString())) {
- studentFamily.setPopulation(Integer.parseInt(dataMaps.get(79).toString()));//家庭人口
- }
- if (dataMaps.get(80) != null && !"".equals(dataMaps.get(80).toString())) {
- studentFamily.setAddress(dataMaps.get(80).toString());//家庭地址
- }
- if (dataMaps.get(81) != null && !"".equals(dataMaps.get(81).toString())) {
- studentFamily.setIncomeSource(dataMaps.get(81).toString());//家庭主要收入来源
- }
- if (dataMaps.get(82) != null && !"".equals(dataMaps.get(82).toString())) {
- studentFamily.setIncomeNumber(Double.parseDouble(dataMaps.get(82).toString()));//家庭月收入(元)
- }
- if (dataMaps.get(83) != null && !"".equals(dataMaps.get(83).toString())) {
- studentFamily.setRailwayStation(dataMaps.get(83).toString());//离家最近火车站
- }
- if (studentUserMap.containsKey(credentialNumber)) {
- updateStudentUserList.add(user);
- updateBaseStudentList.add(baseStudent);
- updateSchoolRollList.add(schoolRoll);
- updateSubsidizeList.add(subsidize);
- updateFamilyList.add(studentFamily);
- updateContactList.add(contact);
- } else {
- insertStudentUserList.add(user);
- insertBaseStudentList.add(baseStudent);
- if (schoolRoll.getClassId() != null && schoolRoll.getGradeId() != null && schoolRoll.getMajorSetId() != null) {
- insertSchoolRollList.add(schoolRoll);
- }
- insertSubsidizeList.add(subsidize);
- insertFamilyList.add(studentFamily);
- insertContactList.add(contact);
- }
- row++;
- }
- //批量修改
- if (!updateStudentUserList.isEmpty()) {
- this.updateBatchById(updateStudentUserList);
- }
- if (!updateSchoolRollList.isEmpty()) {
- schoolRollService.updateBatchById(updateSchoolRollList);
- }
- if (!updateSubsidizeList.isEmpty()) {
- subsidizeService.updateBatchById(updateSubsidizeList);
- }
- if (!updateFamilyList.isEmpty()) {
- familyService.updateBatchById(updateFamilyList);
- }
- if (!updateBaseStudentList.isEmpty()) {
- baseStudentService.updateBatchById(updateBaseStudentList);
- }
- if (!updateContactList.isEmpty()) {
- studentContactService.updateBatchById(updateContactList);
- }
- //批量新增
- if (!insertStudentUserList.isEmpty()) {
- this.saveBatch(insertStudentUserList);
- }
- if (!insertBaseStudentList.isEmpty()) {
- baseStudentService.saveBatch(insertBaseStudentList);
- }
- if (!insertSubsidizeList.isEmpty()) {
- subsidizeService.saveBatch(insertSubsidizeList);
- }
- if (!insertFamilyList.isEmpty()) {
- familyService.saveBatch(insertFamilyList);
- }
- if (!insertSchoolRollList.isEmpty()) {
- schoolRollService.saveBatch(insertSchoolRollList);
- }
- if (!insertContactList.isEmpty()) {
- studentContactService.saveBatch(insertContactList);
- }
- return new ArrayList<>();
- }
- @Override
- public Page<BaseStudentUserPageVo> getStudentPage(Page<BaseStudentUserPageVo> page, BaseStudentUserPageDto dto) {
- return baseStudentMapper.getStudentPage(page, dto);
- }
- @Override
- public Boolean uploadImage(Long userId, MultipartFile file) throws IOException {
- BaseStudentUser studentUser = baseStudentUserMapper.selectById(userId);
- String[] imgSuffix = new String[]{"png", "jpg", "jpeg"};
- String suffix = StringUtils.substringAfterLast(file.getOriginalFilename(), StringPool.DOT);
- if (!Arrays.asList(imgSuffix).contains(suffix)) {
- throw new MyException("图片格式不正确!");
- }
- String base64String = Base64.getEncoder().encodeToString(file.getBytes());
- Map<String, String> map = new HashMap<String, String>() {
- {
- put("jpg", "data:image/jpg;base64,");
- put("jpeg", "data:image/jpeg;base64,");
- put("png", "data:image/png;base64,");
- }
- };
- studentUser.setAvatar(map.get(suffix) + base64String);
- baseStudentUserMapper.updateById(studentUser);
- return true;
- }
- @Override
- public List<BaseDepMajorGradeClassStudenTreeVo> deptMajorGradeClassTree(MajorGradeClassDto dto) {
- List<BaseDepMajorGradeClassStudenTreeVo> voList = new ArrayList<>();
- MPJLambdaWrapper<BaseClass> baseClassMPJLambdaWrapper = new MPJLambdaWrapper<>();
- baseClassMPJLambdaWrapper
- .selectAs(BaseClass::getId, BaseClassMajorSetVo::getClassId)
- .selectAs(BaseMajorSet::getMajorId, BaseClassMajorSetVo::getMajorId)
- .selectAs(BaseClass::getName, BaseClassMajorSetVo::getClassName)
- .selectAs(BaseClass::getGradeId, BaseClassMajorSetVo::getGradeId)
- .leftJoin(BaseMajorSet.class, BaseMajorSet::getId, BaseClass::getMajorSetId)
- .eq(dto.getIsGraduate() != null, BaseClass::getIsGraduate, dto.getIsGraduate())
- .eq(BaseClass::getDeleteMark, DeleteMark.NODELETE.getCode())
- .eq(BaseClass::getEnabledMark, EnabledMark.ENABLED.getCode())
- ;
- List<BaseClassMajorSetVo> majorSetList = baseClassService.selectJoinList(BaseClassMajorSetVo.class, baseClassMPJLambdaWrapper);
- if (majorSetList.isEmpty()) {
- return new ArrayList<>();
- }
- Set<Long> gradeIds = majorSetList.stream().map(BaseClassMajorSetVo::getGradeId).collect(Collectors.toSet());
- Set<Long> majorSetIds = majorSetList.stream().map(BaseClassMajorSetVo::getMajorId).collect(Collectors.toSet());
- Map<Long, Map<Long, List<BaseClassMajorSetVo>>> classMap = majorSetList.stream().collect(Collectors.groupingBy(BaseClassMajorSetVo::getMajorId, Collectors.groupingBy(BaseClassMajorSetVo::getGradeId)));
- List<BaseGrade> gradeList = baseGradeService.list(
- new QueryWrapper<BaseGrade>().lambda()
- .eq(BaseGrade::getDeleteMark, DeleteMark.NODELETE.getCode())
- .in(!gradeIds.isEmpty(), BaseGrade::getId, gradeIds)
- .orderByDesc(BaseGrade::getTitle)
- );
- List<BaseMajor> majorList = baseMajorService.list(
- new QueryWrapper<BaseMajor>().lambda()
- .eq(BaseMajor::getDeleteMark, DeleteMark.NODELETE.getCode())
- .in(!majorSetIds.isEmpty(), BaseMajor::getId, majorSetIds)
- );
- List<Long> deptIds = majorList.stream().map(BaseMajor::getDepartmentId).collect(Collectors.toList());
- List<Department> departmentList = baseDeparmentService.list(
- new QueryWrapper<Department>().lambda()
- .eq(Department::getDeleteMark, DeleteMark.NODELETE.getCode())
- .eq(Department::getIsMajor, 1)
- .in(!deptIds.isEmpty(), Department::getId, deptIds)
- );
- departmentList.forEach((node) -> {
- voList.add(new BaseDepMajorGradeClassStudenTreeVo() {{
- setId(node.getId().toString());
- setTreeType(1);
- setName(node.getName());
- setParentId("0");
- }});
- });
- majorList.forEach((node) -> {
- voList.add(new BaseDepMajorGradeClassStudenTreeVo() {{
- setId(node.getId().toString());
- setName(node.getName());
- setTreeType(2);
- setParentId(node.getDepartmentId().toString());
- }});
- Map<Long, List<BaseClassMajorSetVo>> gradeMap = classMap.get(node.getId());
- gradeList.forEach((DDD) -> {
- List<BaseClassMajorSetVo> list = gradeMap.get(DDD.getId());
- if (list == null || list.isEmpty() || list.size() == 0) {
- return;
- }
- voList.add(new BaseDepMajorGradeClassStudenTreeVo() {{
- setId(node.getId().toString() + "_" + DDD.getId().toString());
- setName(DDD.getName());
- setTreeType(3);
- setParentId(node.getId().toString());
- }});
- });
- });
- majorSetList.forEach((node) -> {
- voList.add(new BaseDepMajorGradeClassStudenTreeVo() {{
- setId(node.getClassId().toString());
- setName(node.getClassName());
- setTreeType(4);
- setParentId(node.getMajorId().toString() + "_" + node.getGradeId());
- }});
- });
- List<BaseDepMajorGradeClassStudenTreeVo> treeVoList = TreeUtil.build(voList);
- return treeVoList;
- }
- /**
- * 初始化字典信息
- * 身份证类型、
- */
- private Map<String, String> initDictionary() {
- List<String> codeList = new ArrayList<>();
- codeList.add("credential_type");
- codeList.add("nation");
- codeList.add("blood_type");
- codeList.add("health");
- codeList.add("marital_state");
- codeList.add("political_state");
- codeList.add("nationality");
- codeList.add("chinese_type");
- codeList.add("house_hold_type");
- codeList.add("residence_type");
- codeList.add("enrollment_type");
- codeList.add("enroll_type");
- codeList.add("student_type");
- codeList.add("archives_status");
- codeList.add("roll_modality");
- codeList.add("stduy_status");
- codeList.add("choose_status");
- codeList.add("foster_type");
- codeList.add("recruit_type");
- codeList.add("recruit_target");
- codeList.add("education");
- codeList.add("recruit_target");
- codeList.add("date_type");
- List<DictionaryDetail> detailList = dictionarydetailMapper.selectJoinList(DictionaryDetail.class,
- new MPJLambdaWrapper<DictionaryDetail>()
- .leftJoin(DictionaryItem.class, DictionaryItem::getId, DictionaryDetail::getItemId)
- .in(DictionaryItem::getCode, codeList)
- );
- List<DictionaryItem> dictionaryItemList = dictionaryitemMapper.selectList(
- new QueryWrapper<DictionaryItem>().lambda()
- .eq(DictionaryItem::getDeleteMark, DeleteMark.NODELETE.getCode())
- );
- Map<Long, String> itemMap = new HashMap<>();
- for (DictionaryItem dictionaryItem : dictionaryItemList) {
- itemMap.put(dictionaryItem.getId(), dictionaryItem.getCode());
- }
- Map<String, String> resultMap = new HashMap<>();
- for (DictionaryDetail dictionaryDetail : detailList) {
- resultMap.put(itemMap.get(dictionaryDetail.getItemId()) + dictionaryDetail.getName(), dictionaryDetail.getCode());
- }
- return resultMap;
- }
- private LocalDateTime parseLocalDateTime(String dateStr) {
- LocalDate time = null;
- try {
- time = LocalDate.parse(dateStr, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
- } catch (DateTimeParseException e) {
- try {
- time = LocalDate.parse(dateStr, DateTimeFormatter.ofPattern("yyyy/MM/dd"));
- } catch (DateTimeParseException e2) {
- try {
- time = LocalDate.parse(dateStr, DateTimeFormatter.ofPattern("yyyy年MM月dd日"));
- } catch (DateTimeParseException e3) {
- try {
- time = LocalDate.parse(dateStr, DateTimeFormatter.ofPattern("yyyyMMdd"));
- } catch (DateTimeParseException e4) {
- throw new MyException("日期格式不正确");
- }
- }
- }
- }
- if (time != null) {
- return time.atStartOfDay();
- }
- return null;
- }
- }
|