|
|
@@ -0,0 +1,82 @@
|
|
|
+package com.xjrsoft.module.student.service.impl;
|
|
|
+
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
+import com.xjrsoft.XjrSoftApplication;
|
|
|
+import com.xjrsoft.common.enums.ArchivesStatusEnum;
|
|
|
+import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
+import com.xjrsoft.module.base.entity.BaseClass;
|
|
|
+import com.xjrsoft.module.organization.entity.User;
|
|
|
+import com.xjrsoft.module.organization.service.IUserService;
|
|
|
+import com.xjrsoft.module.student.dto.AddBaseStudentGraduateDto;
|
|
|
+import com.xjrsoft.module.student.entity.BaseStudentGraduate;
|
|
|
+import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
|
|
|
+import com.xjrsoft.module.student.service.IBaseStudentGraduateService;
|
|
|
+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.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import static org.junit.jupiter.api.Assertions.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author dzx
|
|
|
+ * @date 2024/12/10
|
|
|
+ */
|
|
|
+@RunWith(SpringRunner.class)
|
|
|
+@SpringBootTest(classes = XjrSoftApplication.class)
|
|
|
+class BaseStudentGraduateServiceImplTest {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IBaseStudentSchoolRollService rollService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IBaseStudentGraduateService baseStudentGraduateService;
|
|
|
+ @Test
|
|
|
+ void test(){
|
|
|
+ Long gradeId = 345678345680L;
|
|
|
+ List<BaseStudentSchoolRoll> schoolRollList = rollService.list(
|
|
|
+ new MPJLambdaWrapper<BaseStudentSchoolRoll>()
|
|
|
+ .select(BaseStudentSchoolRoll::getId)
|
|
|
+ .select(BaseStudentSchoolRoll.class, x -> VoToColumnUtil.fieldsToColumns(BaseStudentSchoolRoll.class).contains(x.getProperty()))
|
|
|
+ .innerJoin(BaseClass.class, BaseClass::getId, BaseStudentSchoolRoll::getClassId)
|
|
|
+ .innerJoin(User.class, User::getId, BaseStudentSchoolRoll::getUserId)
|
|
|
+ .eq(BaseStudentSchoolRoll::getArchivesStatus, ArchivesStatusEnum.FB2901.getCode())
|
|
|
+ .eq(BaseClass::getGradeId, gradeId)
|
|
|
+ );
|
|
|
+
|
|
|
+ for (BaseStudentSchoolRoll schoolRoll : schoolRollList) {
|
|
|
+ AddBaseStudentGraduateDto dto = new AddBaseStudentGraduateDto(){{
|
|
|
+ setUserId(schoolRoll.getUserId());
|
|
|
+ setStatus(0);
|
|
|
+ }};
|
|
|
+ BaseStudentGraduate baseStudentGraduate = BeanUtil.toBean(dto, BaseStudentGraduate.class);
|
|
|
+ baseStudentGraduate.setCreateUserId(1000000000000000000L);
|
|
|
+ baseStudentGraduate.setCreateDate(new Date());
|
|
|
+ baseStudentGraduate.setAppendixId(dto.getFolderId());
|
|
|
+ QueryWrapper<BaseStudentGraduate> queryWrapperSortcode = new QueryWrapper<>();
|
|
|
+ queryWrapperSortcode.select("IFNULL(MAX(sort_code),0) as sortCode");
|
|
|
+ BaseStudentGraduate t = baseStudentGraduateService.getOne(queryWrapperSortcode);
|
|
|
+ baseStudentGraduate.setSortCode(t.getSortCode() + 1);
|
|
|
+ //修改学籍状态
|
|
|
+ LambdaQueryWrapper<BaseStudentSchoolRoll> baseStudentSchoolRollLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ baseStudentSchoolRollLambdaQueryWrapper
|
|
|
+ .eq(BaseStudentSchoolRoll::getUserId, dto.getUserId());
|
|
|
+ rollService.update(new BaseStudentSchoolRoll(){{
|
|
|
+ setArchivesStatus(ArchivesStatusEnum.FB2907.getCode());
|
|
|
+ }}, baseStudentSchoolRollLambdaQueryWrapper);
|
|
|
+
|
|
|
+ //保存毕业信息
|
|
|
+ baseStudentGraduateService.save(baseStudentGraduate);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+}
|