| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- package com.xjrsoft.module.liteflow.node;
- import cn.dev33.satoken.secure.BCrypt;
- import cn.hutool.core.convert.Convert;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.xjrsoft.XjrSoftApplication;
- import com.xjrsoft.common.enums.ArchivesStatusEnum;
- import com.xjrsoft.common.enums.DeleteMark;
- import com.xjrsoft.common.enums.EnabledMark;
- import com.xjrsoft.common.utils.LocalDateUtil;
- import com.xjrsoft.config.CommonPropertiesConfig;
- import com.xjrsoft.module.base.entity.BaseClass;
- import com.xjrsoft.module.base.mapper.BaseClassMapper;
- import com.xjrsoft.module.organization.dto.GetUserByParamDto;
- import com.xjrsoft.module.organization.entity.User;
- import com.xjrsoft.module.organization.service.IUserService;
- import com.xjrsoft.module.student.entity.BaseClassMajorSet;
- import com.xjrsoft.module.student.entity.BaseNewStudent;
- import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
- import com.xjrsoft.module.student.entity.StudentTransfer;
- import com.xjrsoft.module.student.mapper.BaseClassMajorSetMapper;
- import com.xjrsoft.module.student.mapper.StudentTransferMapper;
- import com.xjrsoft.module.student.service.IBaseNewStudentService;
- import com.xjrsoft.module.student.service.IBaseStudentSchoolRollService;
- import org.junit.jupiter.api.Test;
- import org.junit.runner.RunWith;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.boot.test.context.SpringBootTest;
- import org.springframework.test.context.junit4.SpringRunner;
- import java.time.LocalDate;
- import java.time.LocalDateTime;
- import java.util.Map;
- import static org.junit.jupiter.api.Assertions.*;
- /**
- * @author dzx
- * @date 2025/3/21
- */
- @RunWith(SpringRunner.class)
- @SpringBootTest(classes = XjrSoftApplication.class)
- class StudentTransferNodeTest {
- @Autowired
- private StudentTransferMapper studentTransferMapper;
- @Autowired
- private IBaseStudentSchoolRollService studentSchoolRollService;
- @Autowired
- private BaseClassMapper baseClassMapper;
- @Autowired
- private BaseClassMajorSetMapper baseClassMajorSetMapper;
- @Autowired
- private IBaseNewStudentService newStudentService;
- @Autowired
- private IUserService userService;
- @Autowired
- private CommonPropertiesConfig propertiesConfig;
- @Test
- public void process() throws Exception {
- // 获取表单中数据编号
- Long formId = 1902955784296742912L;
- if (formId != null) {
- //查询出数据
- StudentTransfer studentTransfer = studentTransferMapper.selectById(formId);
- BaseNewStudent newStudent = newStudentService.getById(studentTransfer.getStudentUserId());
- User user = userService.getUserByParam(
- new GetUserByParamDto() {{
- setCredentialNumber(newStudent.getCredentialNumber());
- }}
- );
- LocalDate birthDate = LocalDateUtil.getBirthDate(newStudent.getCredentialNumber());
- BaseClass baseClass = baseClassMapper.selectById(studentTransfer.getClassId());
- if(user == null){
- User xjrUser = new User() {{
- setCreateDate(LocalDateTime.now());
- // setPassword(BCrypt.hashpw(propertiesConfig.getDefaultPassword(), BCrypt.gensalt()));
- String credentialNumber = newStudent.getCredentialNumber();
- String lastSixDigits = credentialNumber.length() <= 6
- ? credentialNumber
- : credentialNumber.substring(credentialNumber.length() - 6);
- setPassword(BCrypt.hashpw(lastSixDigits, BCrypt.gensalt()));
- setName(newStudent.getName());
- setUserName(newStudent.getCredentialNumber());
- setCredentialNumber(newStudent.getCredentialNumber());
- setCredentialType("ZZLS10007");
- setMobile(newStudent.getMobile());
- setEnabledMark(EnabledMark.ENABLED.getCode());
- setGender(newStudent.getGender());
- setIsChangePassword(1);
- setBirthDate(birthDate.atStartOfDay());
- }};
- userService.save(xjrUser);
- BaseClassMajorSet majorSet = baseClassMajorSetMapper.selectOne(
- new QueryWrapper<BaseClassMajorSet>().lambda()
- .eq(BaseClassMajorSet::getClassId, studentTransfer.getClassId())
- .eq(BaseClassMajorSet::getDeleteMark, DeleteMark.NODELETE.getCode())
- );
- BaseStudentSchoolRoll roll = new BaseStudentSchoolRoll();
- roll.setStduyStatus(studentTransfer.getStudyStatus());
- roll.setClassId(studentTransfer.getClassId());
- roll.setEnrollType(baseClass.getEnrollType());
- roll.setCreateDate(LocalDateTime.now());
- roll.setGradeId(baseClass.getGradeId());
- roll.setMajorSetId(majorSet.getMajorSetId());
- roll.setCreateUserId(studentTransfer.getCreateUserId());
- roll.setArchivesStatus(ArchivesStatusEnum.FB2901.getCode());
- roll.setUserId(xjrUser.getId());
- roll.setDeleteMark(DeleteMark.NODELETE.getCode());
- roll.setEnabledMark(EnabledMark.ENABLED.getCode());
- //新增学籍信息
- studentSchoolRollService.save(roll);
- }else{
- studentSchoolRollService.updateStudentClass(studentTransfer.getClassId(), user.getId());
- }
- newStudent.setRemarks("通过插班进入" + baseClass.getName());
- newStudent.setStatus(1);
- newStudent.setOperateMode(2);
- newStudentService.updateById(newStudent);
- }
- }
- }
|