| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380 |
- package com.xjrsoft.module.student.service.impl;
- import cn.dev33.satoken.stp.StpUtil;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.github.yulichang.base.MPJBaseServiceImpl;
- import com.github.yulichang.wrapper.MPJLambdaWrapper;
- import com.xjrsoft.common.enums.*;
- import com.xjrsoft.common.utils.VoToColumnUtil;
- import com.xjrsoft.module.base.entity.BaseClass;
- import com.xjrsoft.module.base.mapper.BaseClassMapper;
- import com.xjrsoft.module.organization.entity.User;
- import com.xjrsoft.module.organization.mapper.UserMapper;
- import com.xjrsoft.module.room.mapper.RoomBedMapper;
- import com.xjrsoft.module.room.vo.RoomBedInfoVo;
- import com.xjrsoft.module.student.dto.*;
- import com.xjrsoft.module.student.entity.BaseStudent;
- import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
- import com.xjrsoft.module.student.mapper.BaseNewStudentMapper;
- import com.xjrsoft.module.student.mapper.BaseStudentMapper;
- import com.xjrsoft.module.student.mapper.BaseStudentSchoolRollMapper;
- import com.xjrsoft.module.student.mapper.PbSemesterConfigMapper;
- import com.xjrsoft.module.student.mapper.PbVXsxxsfytbMapper;
- import com.xjrsoft.module.student.service.IBaseStudentSchoolRollService;
- import com.xjrsoft.module.student.service.IStudentChangeRecordService;
- import com.xjrsoft.module.student.vo.*;
- import lombok.AllArgsConstructor;
- 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;
- /**
- * @title: 助学金申请
- * @Author dzx
- * @Date: 2023-11-24
- * @Version 1.0
- */
- @Service
- @AllArgsConstructor
- public class BaseStudentSchoolRollServiceImpl extends MPJBaseServiceImpl<BaseStudentSchoolRollMapper, BaseStudentSchoolRoll> implements IBaseStudentSchoolRollService {
- private final BaseStudentSchoolRollMapper baseStudentSchoolRollMapper;
- private final RoomBedMapper roomBedMapper;
- private final BaseClassMapper baseClassMapper;
- private final PbSemesterConfigMapper pbSemesterConfigMapper;
- private final PbVXsxxsfytbMapper pbVXsxxsfytbMapper;
- private final UserMapper userMapper;
- private final IStudentChangeRecordService recordService;
- private final BaseStudentMapper baseStudentMapper;
- private final BaseNewStudentMapper newStudentMapper;
- @Override
- public Page<BaseStudentInfoPageVo> getMobilePage(Page<BaseStudentInfoPageVo> page, BaseStudentInfoPageDto dto) {
- List<String> roleList = StpUtil.getRoleList();
- long teacherId = StpUtil.getLoginIdAsLong();
- List<BaseClass> classList = baseClassMapper.selectList(
- new QueryWrapper<BaseClass>().lambda().eq(BaseClass::getTeacherId, teacherId)
- .eq(BaseClass::getDeleteMark, DeleteMark.NODELETE.getCode())
- );
- if (roleList.size() == 1 && roleList.contains("CLASSTE")) {
- if (classList != null && !classList.isEmpty()) {
- dto.setTeacherId(teacherId);
- }
- } else {
- if (classList != null && !classList.isEmpty() && dto.getClassId() == null) {
- dto.setClassId(classList.get(0).getId());
- }
- }
- String lastBeltcode = pbSemesterConfigMapper.getLastBeltcode();
- dto.setBeltcode(lastBeltcode);
- Page<BaseStudentInfoPageVo> mobilePage = baseStudentSchoolRollMapper.getMobilePage(page, dto);
- List<String> studentCodes = new ArrayList<>();
- for (BaseStudentInfoPageVo record : mobilePage.getRecords()) {
- studentCodes.add(record.getStudentId());
- }
- PbVXsxxsfytbDto dto2 = new PbVXsxxsfytbDto();
- dto2.setStudentCodes(studentCodes);
- dto2.setBeltcode(lastBeltcode);
- List<PbVXsxxsfytbVo> list = pbVXsxxsfytbMapper.getList(dto2);
- Map<String, String> jfztMaps = new HashMap<>();
- for (PbVXsxxsfytbVo pbVXsxxsfytb : list) {
- jfztMaps.put(pbVXsxxsfytb.getStudentcode() + pbVXsxxsfytb.getFeeitemcode(), pbVXsxxsfytb.getJfzt().replaceAll("未缴费", "欠费"));
- }
- for (BaseStudentInfoPageVo record : mobilePage.getRecords()) {
- record.setSsf(jfztMaps.get(record.getStudentId() + "103042766003001") == null ? "欠费" : jfztMaps.get(record.getStudentId() + "103042766003001"));
- record.setJxf(jfztMaps.get(record.getStudentId() + "999010604") == null ? "欠费" : jfztMaps.get(record.getStudentId() + "999010604"));
- record.setJcf(jfztMaps.get(record.getStudentId() + "999010603") == null ? "欠费" : jfztMaps.get(record.getStudentId() + "999010603"));
- }
- return mobilePage;
- }
- @Override
- public Boolean updateInfo(UpdateBaseStudentInfoDto dto) {
- for (Long id : dto.getUserIds()) {
- BaseStudentSchoolRoll schoolRoll = this.getOne(new QueryWrapper<BaseStudentSchoolRoll>().lambda().eq(BaseStudentSchoolRoll::getUserId, id));
- if (!dto.getStduyStatus().equals(schoolRoll.getStduyStatus())) {
- recordService.insertData(
- StudyStatusEnum.fromCode(schoolRoll.getStduyStatus()),
- schoolRoll.getStduyStatus(),
- StudyStatusEnum.fromCode(dto.getStduyStatus()),
- dto.getStduyStatus(),
- id,
- StpUtil.getLoginIdAsLong(),
- StudentChangeTypeEnum.StduyStatus.getCode(),
- 2
- );
- }
- if (!dto.getRollModality().equals(schoolRoll.getLearnStatus())) {
- recordService.insertData(
- RollModalityEnum.fromCode(schoolRoll.getLearnStatus()),
- schoolRoll.getLearnStatus(),
- RollModalityEnum.fromCode(dto.getRollModality()),
- dto.getRollModality(),
- id,
- StpUtil.getLoginIdAsLong(),
- StudentChangeTypeEnum.LearnStatus.getCode(),
- 2
- );
- }
- if (schoolRoll.getArchivesStatus() != null && !schoolRoll.getArchivesStatus().equals(dto.getArchivesStatus())) {
- recordService.insertData(
- ArchivesStatusEnum.fromCode(schoolRoll.getArchivesStatus()),
- schoolRoll.getArchivesStatus(),
- ArchivesStatusEnum.fromCode(dto.getArchivesStatus()),
- dto.getArchivesStatus(),
- id,
- StpUtil.getLoginIdAsLong(),
- StudentChangeTypeEnum.ArchivesStatus.getCode(),
- 2
- );
- }
- if((dto.getArchivesStatus() != null && !ArchivesStatusEnum.FB2901.getCode().equals(dto.getArchivesStatus())
- || (dto.getStduyStatus() != null && !StudyStatusEnum.InResidence.getCode().equals(dto.getStduyStatus())))){
- roomBedMapper.clearBedInfoByStudentUserId(id, StpUtil.getLoginIdAsLong());
- }
- baseStudentSchoolRollMapper.updateInfoByUserId(dto, id);
- }
- return true;
- }
- @Override
- public BaseStudentInfoDetailVo getInfoById(BaseStudentInfoDetailDto dto) {
- String lastBeltcode = pbSemesterConfigMapper.getLastBeltcode();
- dto.setBeltcode(lastBeltcode);
- BaseStudentInfoDetailVo info = baseStudentSchoolRollMapper.getInfoById(dto);
- RoomBedInfoVo bedInfoByUserId = roomBedMapper.getBedInfoByUserId(info.getId());
- if (bedInfoByUserId != null) {
- info.setBedInfo(bedInfoByUserId.getBuildName() + " " + bedInfoByUserId.getRoomName() + " " + bedInfoByUserId.getBedNumber());
- }
- return info;
- }
- @Override
- public BaseStudentInfoPageDataVo getMobilePageStatistics(BaseStudentInfoPageDto dto) {
- List<String> roleList = StpUtil.getRoleList();
- long teacherId = StpUtil.getLoginIdAsLong();
- List<BaseClass> classList = baseClassMapper.selectList(
- new QueryWrapper<BaseClass>().lambda()
- .eq(BaseClass::getTeacherId, teacherId)
- .eq(BaseClass::getDeleteMark, DeleteMark.NODELETE.getCode())
- );
- if (roleList.size() == 1 && roleList.contains("CLASSTE")) {
- if (classList != null && !classList.isEmpty()) {
- dto.setTeacherId(teacherId);
- }
- } else {
- if (classList != null && !classList.isEmpty() && dto.getClassId() == null) {
- dto.setClassId(classList.get(0).getId());
- }
- }
- List<BaseStudentInfoCategoryVo> genderCount = baseStudentSchoolRollMapper.getGenderCount(dto);
- int totalCount = 0;
- BaseStudentInfoPageDataVo result = new BaseStudentInfoPageDataVo();
- for (BaseStudentInfoCategoryVo categoryVo : genderCount) {
- totalCount = totalCount + categoryVo.getNumber();
- if ("男".equals(GenderDictionaryEnum.getValue(categoryVo.getCategory()))) {
- result.setMaleCount(categoryVo.getNumber());
- } else if ("女".equals(GenderDictionaryEnum.getValue(categoryVo.getCategory()))) {
- result.setFemaleCount(categoryVo.getNumber());
- }
- }
- result.setTotalCount(totalCount);
- List<BaseStudentInfoCategoryVo> studyStatusCount = baseStudentSchoolRollMapper.getStudyStatusCount(dto);
- int stayCount = 0;
- int notStayCount = 0;
- for (BaseStudentInfoCategoryVo categoryVo : studyStatusCount) {
- if (StudyStatusEnum.InResidence.getCode().equals(categoryVo.getCategory())) {
- stayCount = stayCount + categoryVo.getNumber();
- if ("男".equals(GenderDictionaryEnum.getValue(categoryVo.getGender()))) {
- result.setMaleStayCount(categoryVo.getNumber());
- } else if ("女".equals(GenderDictionaryEnum.getValue(categoryVo.getGender()))) {
- result.setFemaleStayCount(categoryVo.getNumber());
- }
- } else if (StudyStatusEnum.AttendDaySchool.getCode().equals(categoryVo.getCategory())) {
- notStayCount = notStayCount + categoryVo.getNumber();
- if ("男".equals(GenderDictionaryEnum.getValue(categoryVo.getGender()))) {
- result.setMaleNotStayCount(categoryVo.getNumber());
- } else if ("女".equals(GenderDictionaryEnum.getValue(categoryVo.getGender()))) {
- result.setFemaleNotStayCount(categoryVo.getNumber());
- }
- }
- }
- result.setStayCount(stayCount);
- result.setNotStayCount(notStayCount);
- return result;
- }
- @Override
- public MobileClassStatisticsVo getMobileClassStatistics(BaseStudentInfoPageDto dto) {
- //获取当前用户的班级
- LambdaQueryWrapper<BaseClass> baseClassLambdaQueryWrapper = new LambdaQueryWrapper<>();
- baseClassLambdaQueryWrapper
- .eq(BaseClass::getTeacherId, StpUtil.getLoginIdAsLong());
- List<BaseClass> baseClassList = baseClassMapper.selectList(baseClassLambdaQueryWrapper);
- //如果集合不为空,表示该登录用户是班主任
- if (baseClassList != null && !baseClassList.isEmpty()) {
- for (BaseClass baseClass : baseClassList) {
- }
- } else {
- }
- return null;
- }
- @Override
- @Transactional(rollbackFor = Exception.class)
- public Boolean updateStudentClass(Long classId, Long majorSetId, Long userId) {
- return baseStudentSchoolRollMapper.updateStudentClass1(classId, majorSetId, userId);
- }
- @Override
- public Boolean updateStudentClassGradeMajorStduyStatus(Long classId, Long gradeId, Long majorSetId, String stduyStatus, Long userId) {
- return this.baseMapper.updateStudentClassGradeMajorStduyStatus(classId, gradeId, majorSetId, stduyStatus, userId);
- }
- @Override
- @Transactional(rollbackFor = Exception.class)
- public Boolean updateStudentClass(Long classId, Long userId) {
- return baseStudentSchoolRollMapper.updateStudentClass(classId, userId);
- }
- @Override
- public List<BaseStudentSompleInfoVo> getInfosByParam(BaseStudentSimpleInfoDto dto) {
- List<BaseStudentSompleInfoVo> userList = userMapper.getInfosByParam(dto);
- if(userList.isEmpty()){
- userList = newStudentMapper.getInfosByParam(dto);
- }
- return userList;
- }
- public String getClassNameByUserId(Long userId) {
- return baseStudentSchoolRollMapper.getClassNameByUserId(userId);
- }
- public Long getClassIdByUserId(Long userId) {
- return baseStudentSchoolRollMapper.getClassIdByUserId(userId);
- }
- /**
- * 激活学生信息
- *
- * @param userId 学生用户信息
- */
- @Override
- @Transactional(rollbackFor = Exception.class)
- public Boolean activateStudent(Long userId) {
- return activateStudent(userId, StpUtil.getLoginIdAsLong());
- }
- @Override
- public Boolean activateStudent(Long userId, Long modifyUserId) {
- //激活用户信息
- User user = userMapper.selectById(userId);
- user.setDeleteMark(DeleteMark.NODELETE.getCode());
- user.setEnabledMark(EnabledMark.ENABLED.getCode());
- user.setModifyUserId(modifyUserId);
- user.setModifyDate(LocalDateTime.now());
- userMapper.updateById(user);
- //将学籍信息改为在读
- BaseStudentSchoolRoll schoolRoll = this.baseMapper.selectOne(
- new MPJLambdaWrapper<BaseStudentSchoolRoll>()
- .disableLogicDel()
- .select(BaseStudentSchoolRoll::getId)
- .select(BaseStudentSchoolRoll.class, x -> VoToColumnUtil.fieldsToColumns(BaseStudentSchoolRoll.class).contains(x.getProperty()))
- .eq(BaseStudentSchoolRoll::getUserId, userId)
- );
- schoolRoll.setDeleteMark(DeleteMark.NODELETE.getCode());
- schoolRoll.setEnabledMark(EnabledMark.ENABLED.getCode());
- schoolRoll.setArchivesStatus(ArchivesStatusEnum.FB2901.getCode());
- schoolRoll.setModifyUserId(modifyUserId);
- schoolRoll.setModifyDate(LocalDateTime.now());
- this.updateById(schoolRoll);
- //将学生基本信息中状态改为正常
- BaseStudent baseStudent = baseStudentMapper.selectOne(
- new QueryWrapper<BaseStudent>().lambda()
- .eq(BaseStudent::getUserId, userId)
- );
- baseStudent.setIsNormal(1);
- baseStudent.setModifyUserId(modifyUserId);
- baseStudent.setModifyDate(LocalDateTime.now());
- baseStudentMapper.updateById(baseStudent);
- return true;
- }
- @Override
- @Transactional(rollbackFor = Exception.class)
- public Boolean disableStudent(Long userId) {
- return disableStudent(userId, StpUtil.getLoginIdAsLong());
- }
- /**
- * 禁用学生
- *
- * @param userId
- * @return
- */
- @Override
- @Transactional(rollbackFor = Exception.class)
- public Boolean disableStudent(Long userId, Long modifyUserId) {
- //激活用户信息
- User user = userMapper.selectById(userId);
- user.setDeleteMark(DeleteMark.DELETED.getCode());
- user.setEnabledMark(EnabledMark.DISABLED.getCode());
- user.setModifyUserId(modifyUserId);
- user.setModifyDate(LocalDateTime.now());
- userMapper.updateById(user);
- //将学籍信息改为在读
- BaseStudentSchoolRoll schoolRoll = this.getOne(
- new MPJLambdaWrapper<BaseStudentSchoolRoll>()
- .disableLogicDel()
- .select(BaseStudentSchoolRoll::getId)
- .select(BaseStudentSchoolRoll.class, x -> VoToColumnUtil.fieldsToColumns(BaseStudentSchoolRoll.class).contains(x.getProperty()))
- .eq(BaseStudentSchoolRoll::getUserId, userId)
- );
- UpdateWrapper<BaseStudentSchoolRoll> updateRoll = new UpdateWrapper<>();
- updateRoll.eq("id", schoolRoll.getId());
- updateRoll.setSql("delete_mark = 1");
- updateRoll.setSql("enabled_mark = 0");
- // updateRoll.setSql("class_id = null");
- updateRoll.setSql("modify_user_id = " + modifyUserId);
- updateRoll.setSql("modify_date = now()");
- this.update(schoolRoll, updateRoll);
- //将学生基本信息中状态改为正常
- BaseStudent baseStudent = baseStudentMapper.selectOne(
- new QueryWrapper<BaseStudent>().lambda()
- .eq(BaseStudent::getUserId, userId)
- );
- baseStudent.setIsNormal(0);
- baseStudent.setModifyUserId(modifyUserId);
- baseStudent.setModifyDate(LocalDateTime.now());
- baseStudentMapper.updateById(baseStudent);
- return true;
- }
- }
|