ソースを参照

Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	src/main/java/com/xjrsoft/module/banding/service/impl/BandingTaskClassServiceImpl.java
#	src/main/java/com/xjrsoft/module/banding/service/impl/BandingTaskClassStudentServiceImpl.java
#	src/main/java/com/xjrsoft/module/banding/service/impl/BandingTaskServiceImpl.java
#	src/main/java/com/xjrsoft/module/job/WfCourseAdjustTask.java
#	src/main/java/com/xjrsoft/module/liteflow/node/StudentDropOutNode.java
#	src/main/java/com/xjrsoft/module/student/controller/BaseNewStudentController.java
#	src/main/java/com/xjrsoft/module/student/controller/StudentTryReadingReportController.java
#	src/main/java/com/xjrsoft/module/student/service/IStudentReportRecordService.java
#	src/main/java/com/xjrsoft/module/student/service/impl/StudentChangeRecordServiceImpl.java
#	src/main/java/com/xjrsoft/module/student/service/impl/StudentReportRecordServiceImpl.java
大数据与最优化研究所 10 ヶ月 前
コミット
0e3200cfe1
26 ファイル変更1128 行追加721 行削除
  1. 3 0
      src/main/java/com/xjrsoft/module/banding/dto/ChangeClassDto.java
  2. 3 0
      src/main/java/com/xjrsoft/module/banding/entity/BandingTaskClass.java
  3. 150 70
      src/main/java/com/xjrsoft/module/banding/service/impl/BandingTaskClassServiceImpl.java
  4. 262 202
      src/main/java/com/xjrsoft/module/banding/service/impl/BandingTaskClassStudentServiceImpl.java
  5. 127 98
      src/main/java/com/xjrsoft/module/banding/service/impl/BandingTaskServiceImpl.java
  6. 3 0
      src/main/java/com/xjrsoft/module/banding/vo/BandingTaskClassReportStatisticsVo.java
  7. 13 0
      src/main/java/com/xjrsoft/module/classtime/controller/ClassTimeDeleteController.java
  8. 1 3
      src/main/java/com/xjrsoft/module/job/WfCourseAdjustTask.java
  9. 1 1
      src/main/java/com/xjrsoft/module/liteflow/node/StudentDropOutNode.java
  10. 85 79
      src/main/java/com/xjrsoft/module/student/controller/BaseNewStudentController.java
  11. 1 1
      src/main/java/com/xjrsoft/module/student/controller/StudentReportPlanController.java
  12. 156 73
      src/main/java/com/xjrsoft/module/student/controller/StudentTryReadingReportController.java
  13. 18 0
      src/main/java/com/xjrsoft/module/student/dto/BaseNewStudentPageDto.java
  14. 24 0
      src/main/java/com/xjrsoft/module/student/dto/StudentReportChangeClassBatchDto.java
  15. 2 0
      src/main/java/com/xjrsoft/module/student/service/IBaseStudentSchoolRollService.java
  16. 16 5
      src/main/java/com/xjrsoft/module/student/service/IStudentReportRecordService.java
  17. 18 8
      src/main/java/com/xjrsoft/module/student/service/impl/BaseStudentSchoolRollServiceImpl.java
  18. 29 22
      src/main/java/com/xjrsoft/module/student/service/impl/StudentChangeRecordServiceImpl.java
  19. 145 65
      src/main/java/com/xjrsoft/module/student/service/impl/StudentReportRecordServiceImpl.java
  20. 3 0
      src/main/java/com/xjrsoft/module/student/vo/BaseNewStudentPageVo.java
  21. 3 0
      src/main/java/com/xjrsoft/module/student/vo/StudentReportRecordStatisticsVo.java
  22. 2 2
      src/main/resources/application-prod.yml
  23. 28 1
      src/main/resources/mapper/student/BaseNewStudentMapper.xml
  24. 3 3
      src/main/resources/mapper/student/StudentReportRecordMapper.xml
  25. 4 0
      src/main/resources/sqlScript/20250310_sql.sql
  26. 28 88
      src/test/java/com/xjrsoft/module/liteflow/node/StudentDropOutNodeTest.java

+ 3 - 0
src/main/java/com/xjrsoft/module/banding/dto/ChangeClassDto.java

@@ -28,4 +28,7 @@ public class ChangeClassDto implements Serializable {
     @ApiModelProperty("是否手动分班(1:是 0:否)")
     private Integer isHandle = 0;
 
+    @ApiModelProperty("分班备注")
+    private String remarks;
+
 }

+ 3 - 0
src/main/java/com/xjrsoft/module/banding/entity/BandingTaskClass.java

@@ -120,4 +120,7 @@ public class BandingTaskClass implements Serializable {
 
     @ApiModelProperty("是否锁定(0:否 1:是)")
     private Integer status;
+
+    @ApiModelProperty("班级id(base_class)")
+    private Long baseClassId;
 }

+ 150 - 70
src/main/java/com/xjrsoft/module/banding/service/impl/BandingTaskClassServiceImpl.java

@@ -2,6 +2,7 @@ package com.xjrsoft.module.banding.service.impl;
 
 import cn.dev33.satoken.stp.StpUtil;
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.NumberUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.github.yulichang.base.MPJBaseServiceImpl;
@@ -28,14 +29,20 @@ import com.xjrsoft.module.banding.vo.BandingTaskClassStudentListVo;
 import com.xjrsoft.module.banding.vo.BandingTaskClassSureListVo;
 import com.xjrsoft.module.base.entity.BaseClass;
 import com.xjrsoft.module.base.entity.BaseClassroom;
+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.service.IBaseClassroomService;
 import com.xjrsoft.module.base.service.IBaseMajorSetService;
 import com.xjrsoft.module.organization.entity.User;
 import com.xjrsoft.module.organization.service.IUserService;
 import com.xjrsoft.module.student.dto.StudentTryReadingReportPageDto;
+import com.xjrsoft.module.student.entity.EnrollmentPlan;
+import com.xjrsoft.module.student.entity.StudentReportPlan;
+import com.xjrsoft.module.student.mapper.EnrollmentPlanMapper;
 import com.xjrsoft.module.student.mapper.StudentReportRecordMapper;
+import com.xjrsoft.module.student.service.IStudentReportPlanService;
 import com.xjrsoft.module.student.vo.StudentReportRecordPlanPageVo;
 import com.xjrsoft.module.system.entity.DictionaryDetail;
 import com.xjrsoft.module.system.entity.DictionaryItem;
@@ -45,15 +52,23 @@ import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.*;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 /**
- * @title: 新生分班任务
- * @Author dzx
- * @Date: 2024-07-01
- * @Version 1.0
- */
+* @title: 新生分班任务
+* @Author dzx
+* @Date: 2024-07-01
+* @Version 1.0
+*/
 @Service
 @AllArgsConstructor
 public class BandingTaskClassServiceImpl extends MPJBaseServiceImpl<BandingTaskClassMapper, BandingTaskClass> implements IBandingTaskClassService {
@@ -66,6 +81,10 @@ public class BandingTaskClassServiceImpl extends MPJBaseServiceImpl<BandingTaskC
     private final DictionarydetailMapper detailMapper;
     private final BaseClassMapper classMapper;
     private final StudentReportRecordMapper reportRecordMapper;
+    private final EnrollmentPlanMapper enrollmentPlanMapper;
+    private final IStudentReportPlanService reportPlanService;
+    private final BaseGradeMapper gradeMapper;
+
 
     @Override
     public Boolean add(BandingTaskClass bandingTaskClass) {
@@ -112,7 +131,7 @@ public class BandingTaskClassServiceImpl extends MPJBaseServiceImpl<BandingTaskC
         }
 
         List<Long> classIds = classList.stream().map(BandingTaskClass::getId).collect(Collectors.toList());
-        if (!classIds.isEmpty()) {
+        if(!classIds.isEmpty()){
             classStudentMapper.delete(
                     new QueryWrapper<BandingTaskClassStudent>().lambda()
                             .in(BandingTaskClassStudent::getBandingTaskClassId, classIds)
@@ -174,20 +193,20 @@ public class BandingTaskClassServiceImpl extends MPJBaseServiceImpl<BandingTaskC
         List<BandingTaskClass> classList = new ArrayList<>();
         Date createDate = new Date();
         for (Map<Integer, Object> taskClass : excelDataList) {
-            classList.add(new BandingTaskClass() {{
+            classList.add(new BandingTaskClass(){{
                 setBandingTaskId(bandingTaskId);
                 setCreateDate(createDate);
                 setName(taskClass.get(1).toString());
                 setMajorSetId(majorSetMap.get(taskClass.get(0).toString().trim()));
                 setNumber(Integer.parseInt(taskClass.get(2).toString()));
                 setClassroomId(classroomMap.get(taskClass.get(4).toString()));
-                if (taskClass.get(5) != null) {
+                if(taskClass.get(5) != null){
                     setClassType(classTypeMap.get(taskClass.get(5).toString()));
                 }
-                if (taskClass.get(6) != null) {
+                if(taskClass.get(6) != null){
                     setIsOrderClass(YesOrNoEnum.getCode(taskClass.get(6).toString()));
                 }
-                if (taskClass.get(7) != null) {
+                if(taskClass.get(7) != null){
                     setSortCode(Integer.parseInt(taskClass.get(7).toString()));
                 }
                 setTeacherId(userMap.get(taskClass.get(3).toString()));
@@ -220,10 +239,10 @@ public class BandingTaskClassServiceImpl extends MPJBaseServiceImpl<BandingTaskC
 
         UpdateBandingClassDto updateBandingClassDto = dtoList.get(0);
         BandingTask task;
-        if (updateBandingClassDto.getBandingTaskId() == null) {
+        if(updateBandingClassDto.getBandingTaskId() == null){
             BandingTaskClass taskClass = this.getById(updateBandingClassDto.getId());
             task = bandingTaskMapper.selectById(taskClass.getBandingTaskId());
-        } else {
+        }else{
             task = bandingTaskMapper.selectById(updateBandingClassDto.getBandingTaskId());
         }
         List<BaseClass> classList = classMapper.selectList(
@@ -232,53 +251,90 @@ public class BandingTaskClassServiceImpl extends MPJBaseServiceImpl<BandingTaskC
                         .eq(BaseClass::getGradeId, task.getGradeId())
                         .eq(BaseClass::getEnrollType, task.getEnrollType())
         );
+        List<BaseClass> classCodes = classList.stream().filter(x -> x.getCode() != null).collect(Collectors.toList());
+        Collections.sort(classCodes, Comparator.comparing(BaseClass::getCode));
+        String classCode = null;
+        if(!classCodes.isEmpty()){
+            classCode = classCodes.get(0).getCode();
+        }
 
-        Map<String, BaseClass> classMap = classList.stream().collect(Collectors.toMap(BaseClass::getName, x -> x));
-        List<BaseClass> updateClassList = new ArrayList<>();//修改班级
-        List<BaseClass> insertClassList = new ArrayList<>();//修改班级
+        Map<Long, BaseClass> classMap = classList.stream().collect(Collectors.toMap(BaseClass::getId, x -> x));
 
         List<BaseMajorSet> majorSetList = majorSetService.list(
                 new QueryWrapper<BaseMajorSet>().lambda()
                         .eq(BaseMajorSet::getDeleteMark, DeleteMark.NODELETE.getCode())
         );
-        Map<Long, Long> majorDeptMap = majorSetList.stream().collect(Collectors.toMap(BaseMajorSet::getId, BaseMajorSet::getDepartmentId));
 
+        Map<Long, Long> majorDeptMap = majorSetList.stream().collect(Collectors.toMap(BaseMajorSet::getId, BaseMajorSet::getDepartmentId));
+        BaseGrade baseGrade = gradeMapper.selectById(task.getGradeId());
+        int i = 0;
+        if(NumberUtil.isNumber(classCode)){
+            i = Integer.parseInt(classCode.trim().substring(classCode.length() - 3));
+        }
         for (UpdateBandingClassDto dto : dtoList) {
-            if (dto.getSortCode() != null) {
+            if(dto.getSortCode() != null){
                 List<BandingTaskClass> list = this.list(
                         new QueryWrapper<BandingTaskClass>().lambda()
                                 .eq(BandingTaskClass::getSortCode, dto.getSortCode())
                                 .eq(BandingTaskClass::getBandingTaskId, dto.getBandingTaskId())
-                                .ne(dto.getId() != null, BandingTaskClass::getId, dto.getId())
+                                .ne(dto.getId() != null,BandingTaskClass::getId, dto.getId())
                 );
-                if (!list.isEmpty()) {
+                if(!list.isEmpty()){
                     errorList.add(dto.getName());
                 }
             }
 
-            BandingTaskClass taskClass = BeanUtil.toBean(dto, BandingTaskClass.class);
-            if (taskClass.getId() != null) {
-                taskClass.setModifyDate(new Date());
-                if (taskClass.getSortCode() == null) {
-                    updNullList.add(taskClass);
-                } else {
-                    updList.add(taskClass);
+            if(dto.getId() != null){
+                //修改
+                BandingTaskClass sourceObj = this.getById(dto.getId());
+                BeanUtil.copyProperties(dto, sourceObj);
+                sourceObj.setModifyDate(new Date());
+
+                if(sourceObj.getBaseClassId() != null){
+                    BaseClass baseClass = classMap.get(sourceObj.getBaseClassId());
+                    baseClass.setName(sourceObj.getName());
+                    baseClass.setClassType(sourceObj.getClassType());
+                    baseClass.setTeacherId(sourceObj.getTeacherId());
+                    baseClass.setMajorSetId(sourceObj.getMajorSetId());
+                    baseClass.setClassroomId(sourceObj.getClassroomId());
+                    baseClass.setIsOrderClass(sourceObj.getIsOrderClass());
+                    baseClass.setOrgId(majorDeptMap.get(sourceObj.getMajorSetId()));
+                    baseClass.setEnrollType(task.getEnrollType());
+                    if(baseClass.getCode() == null){
+                        i ++;
+                        baseClass.setCode(baseGrade.getTitle().replace("年", "") + String.format("%03d", i));
+                    }
+                    classMapper.updateById(baseClass);
+                }else{
+                    i ++;
+                    BaseClass baseClass = new BaseClass();
+                    baseClass.setClassType(sourceObj.getClassType());
+                    baseClass.setTeacherId(sourceObj.getTeacherId());
+                    baseClass.setMajorSetId(sourceObj.getMajorSetId());
+                    baseClass.setClassroomId(sourceObj.getClassroomId());
+                    baseClass.setIsOrderClass(sourceObj.getIsOrderClass());
+                    baseClass.setOrgId(majorDeptMap.get(sourceObj.getMajorSetId()));
+                    baseClass.setName(sourceObj.getName());
+                    baseClass.setGradeId(task.getGradeId());
+                    baseClass.setEnrollType(task.getEnrollType());
+                    baseClass.setIsGraduate(1);
+                    baseClass.setCreateUserId(StpUtil.getLoginIdAsLong());
+                    baseClass.setCreateDate(new Date());
+                    baseClass.setCode(baseGrade.getTitle().replace("年", "") + String.format("%03d", i));
+                    classMapper.insert(baseClass);
+                    sourceObj.setBaseClassId(baseClass.getId());
                 }
-            } else {
+                if(sourceObj.getSortCode() == null){
+                    updNullList.add(sourceObj);
+                }else{
+                    updList.add(sourceObj);
+                }
+            }else{
+                //新增
+                i ++;
+                BandingTaskClass taskClass = BeanUtil.toBean(dto, BandingTaskClass.class);
                 taskClass.setCreateDate(new Date());
-                insList.add(taskClass);
-            }
-            if (classMap.containsKey(taskClass.getName())) {
-                BaseClass baseClass = classMap.get(taskClass.getName());
-                baseClass.setClassType(taskClass.getClassType());
-                baseClass.setTeacherId(taskClass.getTeacherId());
-                baseClass.setMajorSetId(taskClass.getMajorSetId());
-                baseClass.setClassroomId(taskClass.getClassroomId());
-                baseClass.setIsOrderClass(taskClass.getIsOrderClass());
-                baseClass.setOrgId(majorDeptMap.get(taskClass.getMajorSetId()));
-                baseClass.setEnrollType(task.getEnrollType());
-                updateClassList.add(baseClass);
-            } else {
+
                 BaseClass baseClass = new BaseClass();
                 baseClass.setClassType(taskClass.getClassType());
                 baseClass.setTeacherId(taskClass.getTeacherId());
@@ -292,27 +348,21 @@ public class BandingTaskClassServiceImpl extends MPJBaseServiceImpl<BandingTaskC
                 baseClass.setIsGraduate(1);
                 baseClass.setCreateUserId(StpUtil.getLoginIdAsLong());
                 baseClass.setCreateDate(new Date());
-                insertClassList.add(baseClass);
+                baseClass.setCode(baseGrade.getTitle().replace("年", "") + String.format("%03d", i));
+                classMapper.insert(baseClass);
+
+                taskClass.setBaseClassId(baseClass.getId());
+                insList.add(taskClass);
             }
         }
-        if (!errorList.isEmpty()) {
+        if(!errorList.isEmpty()){
             throw new MyException(errorList.toString().replace("[", "").replace("]", "") + ",分班排序重复");
         }
 
-        if (!updNullList.isEmpty()) {
+        if(!updNullList.isEmpty()){
             this.updateNull(updNullList);
         }
 
-        if (!insertClassList.isEmpty()) {
-            for (BaseClass baseClass : insertClassList) {
-                classMapper.insert(baseClass);
-            }
-        }
-        if (!updateClassList.isEmpty()) {
-            for (BaseClass baseClass : updateClassList) {
-                classMapper.updateById(baseClass);
-            }
-        }
 
         this.saveBatch(insList);
         return this.updateBatchById(updList);
@@ -332,21 +382,17 @@ public class BandingTaskClassServiceImpl extends MPJBaseServiceImpl<BandingTaskC
                         .orderByDesc(BandingTask::getId)
                         .eq(BandingTask::getStatus, 0)
         );
-        if (bandingTasks.isEmpty()) {
+        if(bandingTasks.isEmpty()){
             return true;
         }
         BandingTaskClass one = this.getOne(
                 new MPJLambdaWrapper<BandingTaskClass>()
                         .select(BandingTaskClass::getId)
                         .select(BandingTaskClass.class, x -> VoToColumnUtil.fieldsToColumns(BandingTaskClass.class).contains(x.getProperty()))
-                        .innerJoin(BandingTask.class, BandingTask::getId, BandingTaskClass::getBandingTaskId)
                         .eq(BandingTaskClass::getDeleteMark, DeleteMark.NODELETE.getCode())
-                        .eq(BandingTaskClass::getName, baseClass.getName())
-                        .eq(BandingTask::getGradeId, baseClass.getGradeId())
-                        .eq(BandingTask::getEnrollType, baseClass.getEnrollType())
-                        .eq(BandingTask::getStatus, 0)
+                        .eq(BandingTaskClass::getBaseClassId, baseClass.getId())
         );
-        if (one == null) {
+        if(one == null){
             BandingTask task = bandingTasks.get(0);
             one = new BandingTaskClass();
             one.setBandingTaskId(task.getId());
@@ -361,7 +407,7 @@ public class BandingTaskClassServiceImpl extends MPJBaseServiceImpl<BandingTaskC
             one.setName(baseClass.getName());
             one.setCreateUserId(StpUtil.getLoginIdAsLong());
             this.save(one);
-        } else {
+        }else{
             one.setIsOrderClass(baseClass.getIsOrderClass());
             one.setClassType(baseClass.getClassType());
             one.setTeacherId(baseClass.getTeacherId());
@@ -402,10 +448,11 @@ public class BandingTaskClassServiceImpl extends MPJBaseServiceImpl<BandingTaskC
             one.setName(baseClass.getName());
             one.setCreateUserId(StpUtil.getLoginIdAsLong());
             one.setStatus(0);
+            one.setBaseClassId(baseClass.getId());
             insList.add(one);
         }
-        if (!insList.isEmpty()) {
-            this.saveBatch(insList);
+        if(!insList.isEmpty()){
+           this.saveBatch(insList);
         }
         return true;
     }
@@ -413,13 +460,13 @@ public class BandingTaskClassServiceImpl extends MPJBaseServiceImpl<BandingTaskC
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Boolean deleteClass(List<Long> ids) {
-        if (!ids.isEmpty()) {
+        if(!ids.isEmpty()){
             List<BandingTaskClassStudent> list = classStudentMapper.selectList(
                     new QueryWrapper<BandingTaskClassStudent>().lambda()
                             .in(BandingTaskClassStudent::getBandingTaskClassId, ids)
                             .eq(BandingTaskClassStudent::getDeleteMark, DeleteMark.NODELETE.getCode())
             );
-            if (!list.isEmpty()) {
+            if(!list.isEmpty()){
                 throw new MyException("该班级下已分配学生,无法删除");
             }
         }
@@ -446,8 +493,37 @@ public class BandingTaskClassServiceImpl extends MPJBaseServiceImpl<BandingTaskC
     @Override
     public BandingTaskClassReportStatisticsVo getTryReadingReportClassStatistics(Long classId) {
         BandingTaskClassReportStatisticsVo result = new BandingTaskClassReportStatisticsVo();
-
         StudentTryReadingReportPageDto dto = new StudentTryReadingReportPageDto();
+        if(classId == 0L){
+            StudentReportPlan plan = reportPlanService.getLastTryReadingPlan();
+            BandingTask bandingTask = bandingTaskMapper.selectById(plan.getBandingTaskId());
+            List<EnrollmentPlan> enrollmentPlans = enrollmentPlanMapper.selectList(
+                    new QueryWrapper<EnrollmentPlan>().lambda()
+                            .eq(EnrollmentPlan::getDeleteMark, DeleteMark.NODELETE.getCode())
+                            .eq(EnrollmentPlan::getEnabledMark, EnabledMark.ENABLED.getCode())
+                            .eq(EnrollmentPlan::getEnrollType, bandingTask.getEnrollType())
+                            .eq(EnrollmentPlan::getGradeId, bandingTask.getGradeId())
+                            .orderByDesc(EnrollmentPlan::getId)
+            );
+            if(!enrollmentPlans.isEmpty()){
+                dto.setEnrollmentPlanId(enrollmentPlans.get(0).getId());
+            }
+        }else{
+            BandingTaskClass taskClass = this.getById(classId);
+            BandingTask task = bandingTaskMapper.selectById(taskClass.getBandingTaskId());
+            List<EnrollmentPlan> enrollmentPlanList = enrollmentPlanMapper.selectList(
+                    new QueryWrapper<EnrollmentPlan>().lambda()
+                            .eq(EnrollmentPlan::getEnrollType, task.getEnrollType())
+                            .eq(EnrollmentPlan::getGradeId, task.getGradeId())
+                            .eq(EnrollmentPlan::getEnabledMark, EnabledMark.ENABLED.getCode())
+                            .eq(EnrollmentPlan::getDeleteMark, DeleteMark.NODELETE.getCode())
+                            .orderByDesc(EnrollmentPlan::getId)
+            );
+            if(!enrollmentPlanList.isEmpty()){
+                dto.setEnrollmentPlanId(enrollmentPlanList.get(0).getId());
+            }
+        }
+
         dto.setClassId(classId);
         List<StudentReportRecordPlanPageVo> tryReadingList = reportRecordMapper.getTryReadingList(dto);
 
@@ -455,12 +531,12 @@ public class BandingTaskClassServiceImpl extends MPJBaseServiceImpl<BandingTaskC
 
         //女生人数
         List<StudentReportRecordPlanPageVo> femaleList = tryReadingList.stream()
-                .filter(x -> x.getGender() != null && GenderDictionaryEnum.FEMALE.getCode().equals(x.getGender()))
+                .filter(x -> x.getGender() != null && GenderDictionaryEnum.FEMALE.getValue().equals(x.getGender()))
                 .collect(Collectors.toList());
         result.setMaleCount(femaleList.size());
         //男生人数
         List<StudentReportRecordPlanPageVo> maleList = tryReadingList.stream()
-                .filter(x -> x.getGender() != null && GenderDictionaryEnum.MALE.getCode().equals(x.getGender()))
+                .filter(x -> x.getGender() != null && GenderDictionaryEnum.MALE.getValue().equals(x.getGender()))
                 .collect(Collectors.toList());
         result.setFemaleCount(maleList.size());
         //已到人数
@@ -470,9 +546,13 @@ public class BandingTaskClassServiceImpl extends MPJBaseServiceImpl<BandingTaskC
         result.setArrivedCount(arrivedList.size());
         //未到人数
         List<StudentReportRecordPlanPageVo> notArrivedList = tryReadingList.stream()
-                .filter(x -> x.getIsReport() == 1)
+                .filter(x -> x.getIsReport() == 0)
                 .collect(Collectors.toList());
         result.setNotArrivedCount(notArrivedList.size());
+
+        BigDecimal divide = BigDecimal.valueOf(result.getArrivedCount()).divide(BigDecimal.valueOf(result.getAllCount()), 4, RoundingMode.HALF_UP);
+        result.setReportRate(divide.doubleValue() + "");
+
         return result;
     }
 }

+ 262 - 202
src/main/java/com/xjrsoft/module/banding/service/impl/BandingTaskClassStudentServiceImpl.java

@@ -1,52 +1,98 @@
 package com.xjrsoft.module.banding.service.impl;
 
+import cn.dev33.satoken.secure.BCrypt;
 import cn.dev33.satoken.stp.StpUtil;
 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.constant.GlobalConstant;
+import com.xjrsoft.common.enums.ArchivesStatusEnum;
 import com.xjrsoft.common.enums.DeleteMark;
 import com.xjrsoft.common.enums.EnabledMark;
+import com.xjrsoft.common.enums.RoleEnum;
 import com.xjrsoft.common.exception.MyException;
+import com.xjrsoft.common.utils.RedisUtil;
 import com.xjrsoft.common.utils.VoToColumnUtil;
+import com.xjrsoft.config.CommonPropertiesConfig;
+import com.xjrsoft.module.banding.dto.BandingTaskClassStudentPageDto;
 import com.xjrsoft.module.banding.dto.ChangeClassDto;
 import com.xjrsoft.module.banding.dto.StudentDto;
+import com.xjrsoft.module.banding.entity.BandingTask;
 import com.xjrsoft.module.banding.entity.BandingTaskClass;
 import com.xjrsoft.module.banding.entity.BandingTaskClassStudent;
 import com.xjrsoft.module.banding.mapper.BandingTaskClassMapper;
 import com.xjrsoft.module.banding.mapper.BandingTaskClassStudentMapper;
+import com.xjrsoft.module.banding.mapper.BandingTaskMapper;
 import com.xjrsoft.module.banding.service.IBandingTaskClassStudentService;
+import com.xjrsoft.module.banding.vo.BandingTaskClassSureListVo;
+import com.xjrsoft.module.base.entity.BaseClass;
+import com.xjrsoft.module.base.entity.BaseMajorSet;
 import com.xjrsoft.module.base.entity.BaseSemester;
+import com.xjrsoft.module.base.mapper.BaseMajorSetMapper;
+import com.xjrsoft.module.base.service.IBaseClassService;
 import com.xjrsoft.module.base.service.IBaseSemesterService;
+import com.xjrsoft.module.organization.entity.User;
+import com.xjrsoft.module.organization.entity.UserRoleRelation;
+import com.xjrsoft.module.organization.service.IUserRoleRelationService;
+import com.xjrsoft.module.organization.service.IUserService;
 import com.xjrsoft.module.student.dto.BaseNewStudentPageDto;
+import com.xjrsoft.module.student.entity.BaseClassMajorSet;
+import com.xjrsoft.module.student.entity.BaseNewStudent;
+import com.xjrsoft.module.student.entity.BaseStudent;
+import com.xjrsoft.module.student.entity.BaseStudentFamily;
+import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
 import com.xjrsoft.module.student.entity.StudentReportPlan;
 import com.xjrsoft.module.student.entity.StudentReportRecord;
+import com.xjrsoft.module.student.mapper.BaseClassMajorSetMapper;
 import com.xjrsoft.module.student.mapper.StudentReportRecordMapper;
+import com.xjrsoft.module.student.service.IBaseNewStudentService;
+import com.xjrsoft.module.student.service.IBaseStudentFamilyService;
+import com.xjrsoft.module.student.service.IBaseStudentSchoolRollService;
+import com.xjrsoft.module.student.service.IBaseStudentService;
 import com.xjrsoft.module.student.service.IStudentReportPlanService;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.time.LocalDate;
+import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import java.util.stream.Collectors;
 
 /**
- * @title: 新生分班任务
- * @Author dzx
- * @Date: 2024-07-01
- * @Version 1.0
- */
+* @title: 新生分班任务
+* @Author dzx
+* @Date: 2024-07-01
+* @Version 1.0
+*/
 @Service
 @AllArgsConstructor
 public class BandingTaskClassStudentServiceImpl extends MPJBaseServiceImpl<BandingTaskClassStudentMapper, BandingTaskClassStudent> implements IBandingTaskClassStudentService {
     private final BandingTaskClassMapper taskClassMapper;
-
+    private final BandingTaskMapper bandingTaskMapper;
     private final IStudentReportPlanService reportPlanService;
     private final IBaseSemesterService semesterService;
+    private final IBaseNewStudentService newStudentService;
     private final StudentReportRecordMapper reportRecordMapper;
 
+    private final IBaseClassService classService;
+    private final BaseClassMajorSetMapper classMajorSetMapper;
+    private final CommonPropertiesConfig propertiesConfig;
+    private final IUserService userService;
+    private final IUserRoleRelationService roleRelationService;
+    private final IBaseStudentSchoolRollService schoolRollService;
+    private final IBaseStudentService studentService;
+    private final IBaseStudentFamilyService familyService;
+    private final BaseMajorSetMapper majorSetMapper;
+    private final RedisUtil redisUtil;
+
     @Override
     public Boolean add(BandingTaskClassStudent bandingTaskClass) {
         bandingTaskClass.setCreateDate(new Date());
@@ -76,6 +122,8 @@ public class BandingTaskClassStudentServiceImpl extends MPJBaseServiceImpl<Bandi
                         .in(BandingTaskClassStudent::getNewStudentId, dto.getNewStudentIds())
         );
 
+        BandingTaskClass taskClass = taskClassMapper.selectById(dto.getBandingTaskClassId());
+
         //新增报到计划,如果有多个分班任务确认,需要保证试读报到计划只有一个
         BaseSemester semester = semesterService.getCurrentSemester();
         StudentReportPlan plan = reportPlanService.getOne(
@@ -84,7 +132,19 @@ public class BandingTaskClassStudentServiceImpl extends MPJBaseServiceImpl<Bandi
                         .eq(StudentReportPlan::getEnabledMark, EnabledMark.ENABLED.getCode())
                         .eq(StudentReportPlan::getSemesterId, semester.getId())
                         .eq(StudentReportPlan::getCategory, 2)
+                        .eq(StudentReportPlan::getBandingTaskId, taskClass.getBandingTaskId())
         );
+        if(plan == null){
+            plan = new StudentReportPlan();
+            plan.setStatus(0);
+            plan.setCategory(2);
+            plan.setBandingTaskId(taskClass.getBandingTaskId());
+            plan.setDeleteMark(DeleteMark.NODELETE.getCode());
+            plan.setEnabledMark(EnabledMark.ENABLED.getCode());
+            plan.setCreateDate(new Date());
+            plan.setCreateUserId(StpUtil.getLoginIdAsLong());
+            reportPlanService.save(plan);
+        }
 
         List<BandingTaskClassStudent> dataList = new ArrayList<>();
         long createUserId = StpUtil.getLoginIdAsLong();
@@ -92,220 +152,220 @@ public class BandingTaskClassStudentServiceImpl extends MPJBaseServiceImpl<Bandi
         List<StudentReportRecord> insertList = new ArrayList<>();
         for (Long newStudentId : dto.getNewStudentIds()) {
             dataList.add(
-                    new BandingTaskClassStudent() {{
+                    new BandingTaskClassStudent(){{
                         setCreateDate(new Date());
                         setNewStudentId(newStudentId);
                         setBandingTaskClassId(dto.getBandingTaskClassId());
                         setCreateUserId(createUserId);
                         setStatus(0);
-                        if (dto.getIsHandle() != null && dto.getIsHandle() == 1) {
+                        if(dto.getIsHandle() != null && dto.getIsHandle() == 1){
                             setStatus(1);
                         }
                     }}
             );
-            insertList.add(
-                    new StudentReportRecord() {{
-                        setCreateDate(new Date());
-                        setCreateUserId(StpUtil.getLoginIdAsLong());
-                        setUserId(newStudentId);
-                        setStudentReportPlanId(plan.getId());
-                        setDeleteMark(DeleteMark.NODELETE.getCode());
-                        setEnabledMark(EnabledMark.ENABLED.getCode());
-                    }}
-            );
+            if(dto.getIsHandle() != null && dto.getIsHandle() == 1){
+                StudentReportRecord record = new StudentReportRecord();
+                record.setCreateDate(new Date());
+                record.setCreateUserId(StpUtil.getLoginIdAsLong());
+                record.setUserId(newStudentId);
+                record.setStudentReportPlanId(plan.getId());
+                record.setDeleteMark(DeleteMark.NODELETE.getCode());
+                record.setEnabledMark(EnabledMark.ENABLED.getCode());
+                insertList.add(record);
+            }
         }
-        if (!dataList.isEmpty()) {
+        if(!dataList.isEmpty()){
             this.saveBatch(dataList);
         }
 
-        if (!insertList.isEmpty()) {
+        if(!insertList.isEmpty()){
             for (StudentReportRecord studentReportRecord : insertList) {
                 reportRecordMapper.insert(studentReportRecord);
             }
         }
 
 
-//        if(dto.getIsHandle() != null && dto.getIsHandle() == 1){
-//            BandingTaskClass taskClass = taskClassMapper.selectById(dto.getBandingTaskClassId());
-//            List<Long> studentIds = dataList.stream().map(BandingTaskClassStudent::getNewStudentId).collect(Collectors.toList());
-//            List<BaseNewStudent> list = newStudentService.list(
-//                    new QueryWrapper<BaseNewStudent>().lambda()
-//                            .in(BaseNewStudent::getId, studentIds)
-//            );
-//            List<BaseNewStudent> updateList = new ArrayList<>();
-//            for (BaseNewStudent student : list) {
-//                student.setStatus(1);
-//                student.setOperateMode(2);
-//                updateList.add(student);
-//            }
-//            if(!updateList.isEmpty()){
-//                newStudentService.updateBatchById(updateList);
-//            }
-//            {
-//                Date createDate = new Date();
-//                BandingTask bandingTask = bandingTaskMapper.selectById(taskClass.getBandingTaskId());
-//                List<BandingTaskClassSureListVo> classSure = taskClassMapper.getClassSure(new BandingTaskClassStudentPageDto() {{
-//                    setBandingTaskId(taskClass.getBandingTaskId());
-//                }});
-//
-//                Map<Long, Integer> classTotal = classSure.stream().collect(Collectors.toMap(BandingTaskClassSureListVo::getId, BandingTaskClassSureListVo::getNumber));
-//                Map<Long, Integer> classBoy = classSure.stream().collect(Collectors.toMap(BandingTaskClassSureListVo::getId, BandingTaskClassSureListVo::getMaleCount));
-//                Map<Long, Integer> classGirl = classSure.stream().collect(Collectors.toMap(BandingTaskClassSureListVo::getId, BandingTaskClassSureListVo::getFemaleCount));
-//
-//
-//                //生成班级数据
-//                Map<Long, Long> classMap = new HashMap<>();
-//                Map<Long, Long> taskClassMajorMap = new HashMap<>();
-//                //查询出需要新增的班级信息
-//                Map<Long, Long> majorDeptMap = majorSetMapper.selectList(
-//                        new QueryWrapper<BaseMajorSet>()
-//                ).stream().collect(Collectors.toMap(BaseMajorSet::getId, BaseMajorSet::getDepartmentId));
-//                //先查询是否已经存在这个班级,如果存在就更新,不存在就新增
-//                BaseClass baseClass = classService.getOne(
-//                        new QueryWrapper<BaseClass>().lambda()
-//                                .eq(BaseClass::getName, taskClass.getName())
-//                                .eq(BaseClass::getGradeId, bandingTask.getGradeId())
-//                                .eq(BaseClass::getEnrollType, bandingTask.getEnrollType())
-//                );
-//                if(baseClass == null){
-//                    baseClass = new BaseClass() {{
-//                        setName(taskClass.getName());
-//                        setClassroomId(taskClass.getClassroomId());
-//                        setTeacherId(taskClass.getTeacherId());
-//                        setIsGraduate(1);
-//                        setMajorSetId(taskClass.getMajorSetId());
-//                        setOrgId(majorDeptMap.get(taskClass.getMajorSetId()));
-//                        setIsOrderClass(taskClass.getIsOrderClass()==null?0:taskClass.getIsOrderClass().intValue());
-//                        setGradeId(bandingTask.getGradeId());
-//                        setDeleteMark(DeleteMark.NODELETE.getCode());
-//                        setEnrollType(bandingTask.getEnrollType());
-//                        setCreateDate(new Date());
-//                    }};
-//
-//                    classService.save(baseClass);
-//
-//                    BaseClassMajorSet majorSet = new BaseClassMajorSet() {{
-//                        setCreateDate(createDate);
-//                        setMajorSetId(taskClass.getMajorSetId());
-//                        setPlanTotalStudent(taskClass.getNumber());
-//                        setTotalStudent(classTotal.get(taskClass.getId()));
-//                        setBoyNum(classBoy.get(taskClass.getId()));
-//                        setGirlNum(classGirl.get(taskClass.getId()));
-//                    }};
-//                    majorSet.setClassId(baseClass.getId());
-//                    classMajorSetMapper.insert(majorSet);
-//                }
-//
-//
-//                classMap.put(taskClass.getId(), baseClass.getId());
-//                taskClassMajorMap.put(taskClass.getId(), taskClass.getMajorSetId());
-//
-//                /**
-//                 * 新增学生数据
-//                 * 1、新增用户xjr_user,需要先查询用户信息是否已经存在
-//                 * 2、新增用户与角色的关系xjr_user_role_relation
-//                 * 3、新增学生基本信息base_student
-//                 * 4、新增学籍信息表base_student_school_roll
-//                 * 5、新增家庭信息表base_student_family
-//                 */
-//                LocalDateTime now = LocalDateTime.now();
-//                List<String> idNumbers = updateList.stream().map(BaseNewStudent::getCredentialNumber).collect(Collectors.toList());
-//                List<User> students = userService.list(
-//                        new MPJLambdaWrapper<User>()
-//                                .disableLogicDel()
-//                                .in(User::getCredentialNumber, idNumbers)
-//                                .orderByAsc(User::getCreateDate)
-//                );
-//                Map<String, Long> userSet = new HashMap<>();
-//                Map<String, Integer> userDeleteMarkMap = new HashMap<>();
-//                for (User student : students) {
-//                    userSet.put(student.getCredentialNumber(), student.getId());
-//                    userDeleteMarkMap.put(student.getCredentialNumber(), student.getDeleteMark());
-//                }
-//                Map<Long, Long> studentClassRelation = dataList.stream().collect(Collectors.toMap(BandingTaskClassStudent::getNewStudentId, BandingTaskClassStudent::getBandingTaskClassId));
-//                for (BaseNewStudent student : updateList) {
-//                    if(userSet.containsKey(student.getCredentialNumber())){
-//                        schoolRollService.updateStudentClass(classMap.get(studentClassRelation.get(student.getId())), userSet.get(student.getCredentialNumber()));
-//                        Integer deleteMark = userDeleteMarkMap.get(student.getCredentialNumber());
-//                        if(deleteMark != null && deleteMark == 1){
-//                            userService.recoveryStudentInfo(userSet.get(student.getCredentialNumber()));
-//                        }
-//                        continue;
-//                    }
-//                    LocalDate birthDate = getBirthDate(student.getCredentialNumber());
-//                    User xjrUser = new User() {{
-//                        setCreateDate(now);
-//                        setPassword(BCrypt.hashpw(propertiesConfig.getDefaultPassword(), BCrypt.gensalt()));
-//                        setName(student.getName());
-//                        setUserName(student.getCredentialNumber());
-//                        setCredentialNumber(student.getCredentialNumber());
-//                        setCredentialType("ZZLS10007");
-//                        setMobile(student.getMobile());
-//                        setEnabledMark(EnabledMark.DISABLED.getCode());
-//                        setGender(student.getGender());
-//                        setIsChangePassword(1);
-//                        setBirthDate(birthDate.atStartOfDay());
-//                    }};
-//                    userService.save(xjrUser);
-//
-//                    UserRoleRelation userRoleRelation = new UserRoleRelation() {{
-//                        setRoleId(RoleEnum.STUDENT.getCode());
-//                        setUserId(xjrUser.getId());
-//                    }};
-//                    roleRelationService.save(userRoleRelation);
-//
-//                    BaseStudent baseStudent = new BaseStudent() {{
-//                        setUserId(xjrUser.getId());
-//                        setCreateDate(now);
-//                        setStudentId(student.getCredentialNumber());
-//                        if(student.getHeight() != null){
-//                            setHeight(student.getHeight().doubleValue());
-//                        }
-//                        if(student.getWeight() != null){
-//                            setWeight(student.getWeight().doubleValue());
-//                        }
-//                    }};
-//                    studentService.save(baseStudent);
-//
-//                    BaseStudentSchoolRoll schoolRoll = new BaseStudentSchoolRoll() {{
-//                        setUserId(xjrUser.getId());
-//                        if(student.getScore() != null){
-//                            setGraduatedScore(student.getScore().doubleValue());
-//                        }
-//
-//                        setGraduatedUniversity(student.getGraduateSchool());
-//                        setClassId(classMap.get(studentClassRelation.get(student.getId())));
-//                        setMajorSetId(taskClassMajorMap.get(studentClassRelation.get(student.getId())));
-//                        setStduyStatus(student.getStduyStatus());
-//                        setEnrollType(bandingTask.getEnrollType());
-//                        setStudentSource(student.getSource());
-//                        setGradeId(bandingTask.getGradeId());
-//                        setArchivesStatus(ArchivesStatusEnum.FB2901.getCode());
-//                        setCreateDate(now);
-//                    }};
-//                    schoolRollService.save(schoolRoll);
-//
-//                    BaseStudentFamily studentFamily = new BaseStudentFamily() {{
-//                        setCreateDate(now);
-//                        setUserId(xjrUser.getId());
-//                        setTelephone(student.getFamilyMobile());
-//                        setAddress(student.getFamilyAddress());
-//                    }};
-//                    familyService.save(studentFamily);
-//                }
-//            }
-//            CompletableFuture.runAsync(() -> {
-//                List<User> userList = userService.list();
-//                redisUtil.set(GlobalConstant.USER_CACHE_KEY, userList);
-//
-//                List<UserRoleRelation> userRoleRelationList = roleRelationService.list(Wrappers.lambdaQuery(UserRoleRelation.class));
-//                redisUtil.set(GlobalConstant.USER_ROLE_RELATION_CACHE_KEY, userRoleRelationList);
-//            });
-//        }
+        if(dto.getIsHandle() != null && dto.getIsHandle() == 1){
+            List<Long> studentIds = dataList.stream().map(BandingTaskClassStudent::getNewStudentId).collect(Collectors.toList());
+            List<BaseNewStudent> list = newStudentService.list(
+                    new QueryWrapper<BaseNewStudent>().lambda()
+                            .in(BaseNewStudent::getId, studentIds)
+            );
+            List<BaseNewStudent> updateList = new ArrayList<>();
+            for (BaseNewStudent student : list) {
+                student.setStatus(1);
+                student.setOperateMode(2);
+                student.setRemarks(dto.getRemarks());
+                updateList.add(student);
+            }
+            if(!updateList.isEmpty()){
+                newStudentService.updateBatchById(updateList);
+            }
+            {
+                Date createDate = new Date();
+                BandingTask bandingTask = bandingTaskMapper.selectById(taskClass.getBandingTaskId());
+                List<BandingTaskClassSureListVo> classSure = taskClassMapper.getClassSure(new BandingTaskClassStudentPageDto() {{
+                    setBandingTaskId(taskClass.getBandingTaskId());
+                }});
+
+                Map<Long, Integer> classTotal = classSure.stream().collect(Collectors.toMap(BandingTaskClassSureListVo::getId, BandingTaskClassSureListVo::getNumber));
+                Map<Long, Integer> classBoy = classSure.stream().collect(Collectors.toMap(BandingTaskClassSureListVo::getId, BandingTaskClassSureListVo::getMaleCount));
+                Map<Long, Integer> classGirl = classSure.stream().collect(Collectors.toMap(BandingTaskClassSureListVo::getId, BandingTaskClassSureListVo::getFemaleCount));
+
+
+                //生成班级数据
+                Map<Long, Long> classMap = new HashMap<>();
+                Map<Long, Long> taskClassMajorMap = new HashMap<>();
+                //查询出需要新增的班级信息
+                Map<Long, Long> majorDeptMap = majorSetMapper.selectList(
+                        new QueryWrapper<BaseMajorSet>()
+                ).stream().collect(Collectors.toMap(BaseMajorSet::getId, BaseMajorSet::getDepartmentId));
+                //先查询是否已经存在这个班级,如果存在就更新,不存在就新增
+                BaseClass baseClass = classService.getOne(
+                        new QueryWrapper<BaseClass>().lambda()
+                                .eq(BaseClass::getName, taskClass.getName())
+                                .eq(BaseClass::getGradeId, bandingTask.getGradeId())
+                                .eq(BaseClass::getEnrollType, bandingTask.getEnrollType())
+                );
+                if(baseClass == null){
+                    baseClass = new BaseClass() {{
+                        setName(taskClass.getName());
+                        setClassroomId(taskClass.getClassroomId());
+                        setTeacherId(taskClass.getTeacherId());
+                        setIsGraduate(1);
+                        setMajorSetId(taskClass.getMajorSetId());
+                        setOrgId(majorDeptMap.get(taskClass.getMajorSetId()));
+                        setIsOrderClass(taskClass.getIsOrderClass()==null?0:taskClass.getIsOrderClass().intValue());
+                        setGradeId(bandingTask.getGradeId());
+                        setDeleteMark(DeleteMark.NODELETE.getCode());
+                        setEnrollType(bandingTask.getEnrollType());
+                        setCreateDate(new Date());
+                    }};
+
+                    classService.save(baseClass);
+
+                    BaseClassMajorSet majorSet = new BaseClassMajorSet() {{
+                        setCreateDate(createDate);
+                        setMajorSetId(taskClass.getMajorSetId());
+                        setPlanTotalStudent(taskClass.getNumber());
+                        setTotalStudent(classTotal.get(taskClass.getId()));
+                        setBoyNum(classBoy.get(taskClass.getId()));
+                        setGirlNum(classGirl.get(taskClass.getId()));
+                    }};
+                    majorSet.setClassId(baseClass.getId());
+                    classMajorSetMapper.insert(majorSet);
+                }
+
+
+                classMap.put(taskClass.getId(), baseClass.getId());
+                taskClassMajorMap.put(taskClass.getId(), taskClass.getMajorSetId());
+
+                /**
+                 * 新增学生数据
+                 * 1、新增用户xjr_user,需要先查询用户信息是否已经存在
+                 * 2、新增用户与角色的关系xjr_user_role_relation
+                 * 3、新增学生基本信息base_student
+                 * 4、新增学籍信息表base_student_school_roll
+                 * 5、新增家庭信息表base_student_family
+                 */
+                LocalDateTime now = LocalDateTime.now();
+                List<String> idNumbers = updateList.stream().map(BaseNewStudent::getCredentialNumber).collect(Collectors.toList());
+                List<User> students = userService.list(
+                        new MPJLambdaWrapper<User>()
+                                .disableLogicDel()
+                                .in(User::getCredentialNumber, idNumbers)
+                                .orderByAsc(User::getCreateDate)
+                );
+                Map<String, Long> userSet = new HashMap<>();
+                Map<String, Integer> userDeleteMarkMap = new HashMap<>();
+                for (User student : students) {
+                    userSet.put(student.getCredentialNumber(), student.getId());
+                    userDeleteMarkMap.put(student.getCredentialNumber(), student.getDeleteMark());
+                }
+                Map<Long, Long> studentClassRelation = dataList.stream().collect(Collectors.toMap(BandingTaskClassStudent::getNewStudentId, BandingTaskClassStudent::getBandingTaskClassId));
+                for (BaseNewStudent student : updateList) {
+                    if(userSet.containsKey(student.getCredentialNumber())){
+                        schoolRollService.updateStudentClass(classMap.get(studentClassRelation.get(student.getId())), userSet.get(student.getCredentialNumber()));
+                        Integer deleteMark = userDeleteMarkMap.get(student.getCredentialNumber());
+                        if(deleteMark != null && deleteMark == 1){
+                            userService.recoveryStudentInfo(userSet.get(student.getCredentialNumber()));
+                        }
+                        continue;
+                    }
+                    LocalDate birthDate = getBirthDate(student.getCredentialNumber());
+                    User xjrUser = new User() {{
+                        setCreateDate(now);
+                        setPassword(BCrypt.hashpw(propertiesConfig.getDefaultPassword(), BCrypt.gensalt()));
+                        setName(student.getName());
+                        setUserName(student.getCredentialNumber());
+                        setCredentialNumber(student.getCredentialNumber());
+                        setCredentialType("ZZLS10007");
+                        setMobile(student.getMobile());
+                        setEnabledMark(EnabledMark.DISABLED.getCode());
+                        setGender(student.getGender());
+                        setIsChangePassword(1);
+                        setBirthDate(birthDate.atStartOfDay());
+                    }};
+                    userService.save(xjrUser);
+
+                    UserRoleRelation userRoleRelation = new UserRoleRelation() {{
+                        setRoleId(RoleEnum.STUDENT.getCode());
+                        setUserId(xjrUser.getId());
+                    }};
+                    roleRelationService.save(userRoleRelation);
+
+                    BaseStudent baseStudent = new BaseStudent() {{
+                        setUserId(xjrUser.getId());
+                        setCreateDate(now);
+                        setStudentId(student.getCredentialNumber());
+                        if(student.getHeight() != null){
+                            setHeight(student.getHeight().doubleValue());
+                        }
+                        if(student.getWeight() != null){
+                            setWeight(student.getWeight().doubleValue());
+                        }
+                    }};
+                    studentService.save(baseStudent);
+
+                    BaseStudentSchoolRoll schoolRoll = new BaseStudentSchoolRoll() {{
+                        setUserId(xjrUser.getId());
+                        if(student.getScore() != null){
+                            setGraduatedScore(student.getScore().doubleValue());
+                        }
+
+                        setGraduatedUniversity(student.getGraduateSchool());
+                        setClassId(classMap.get(studentClassRelation.get(student.getId())));
+                        setMajorSetId(taskClassMajorMap.get(studentClassRelation.get(student.getId())));
+                        setStduyStatus(student.getStduyStatus());
+                        setEnrollType(bandingTask.getEnrollType());
+                        setStudentSource(student.getSource());
+                        setGradeId(bandingTask.getGradeId());
+                        setArchivesStatus(ArchivesStatusEnum.FB2901.getCode());
+                        setCreateDate(now);
+                    }};
+                    schoolRollService.save(schoolRoll);
+
+                    BaseStudentFamily studentFamily = new BaseStudentFamily() {{
+                        setCreateDate(now);
+                        setUserId(xjrUser.getId());
+                        setTelephone(student.getFamilyMobile());
+                        setAddress(student.getFamilyAddress());
+                    }};
+                    familyService.save(studentFamily);
+                }
+            }
+            CompletableFuture.runAsync(() -> {
+                List<User> userList = userService.list();
+                redisUtil.set(GlobalConstant.USER_CACHE_KEY, userList);
+
+                List<UserRoleRelation> userRoleRelationList = roleRelationService.list(Wrappers.lambdaQuery(UserRoleRelation.class));
+                redisUtil.set(GlobalConstant.USER_ROLE_RELATION_CACHE_KEY, userRoleRelationList);
+            });
+        }
         return true;
     }
 
-    LocalDate getBirthDate(String idCardNumber) {
+    LocalDate getBirthDate(String idCardNumber){
         // 获取出生日期前6位,即yyyyMM
         String birthdayString = idCardNumber.substring(6, 14);
 
@@ -314,7 +374,7 @@ public class BandingTaskClassStudentServiceImpl extends MPJBaseServiceImpl<Bandi
         try {
             LocalDate parse = LocalDate.parse(birthdayString, formatter);
             return parse;
-        } catch (Exception e) {
+        }catch (Exception e){
             throw new MyException("身份证号填写错误,无法提取出生日期");
         }
     }
@@ -366,7 +426,7 @@ public class BandingTaskClassStudentServiceImpl extends MPJBaseServiceImpl<Bandi
         Date createDate = new Date();
         for (Long newStudentId : dto.getNewStudentIds()) {
             dataList.add(
-                    new BandingTaskClassStudent() {{
+                    new BandingTaskClassStudent(){{
                         setNewStudentId(newStudentId);
                         setCreateDate(createDate);
                         setStatus(0);
@@ -374,8 +434,8 @@ public class BandingTaskClassStudentServiceImpl extends MPJBaseServiceImpl<Bandi
                     }}
             );
         }
-        if (!dataList.isEmpty()) {
-            this.saveBatch(dataList);
+        if(!dataList.isEmpty()){
+           this.saveBatch(dataList);
         }
 
         return true;

+ 127 - 98
src/main/java/com/xjrsoft/module/banding/service/impl/BandingTaskServiceImpl.java

@@ -8,7 +8,11 @@ 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.enums.ArchivesStatusEnum;
+import com.xjrsoft.common.enums.DeleteMark;
+import com.xjrsoft.common.enums.EnabledMark;
+import com.xjrsoft.common.enums.GenderDictionaryEnum;
+import com.xjrsoft.common.enums.RoleEnum;
 import com.xjrsoft.common.exception.MyException;
 import com.xjrsoft.common.utils.RedisUtil;
 import com.xjrsoft.common.utils.VoToColumnUtil;
@@ -17,7 +21,12 @@ import com.xjrsoft.module.banding.dto.AutomaticBandingTaskDto;
 import com.xjrsoft.module.banding.dto.BandingTaskClassStudentPageDto;
 import com.xjrsoft.module.banding.dto.BandingTaskPageDto;
 import com.xjrsoft.module.banding.dto.SureBandingTaskDto;
-import com.xjrsoft.module.banding.entity.*;
+import com.xjrsoft.module.banding.entity.BandingRule;
+import com.xjrsoft.module.banding.entity.BandingTask;
+import com.xjrsoft.module.banding.entity.BandingTaskClass;
+import com.xjrsoft.module.banding.entity.BandingTaskClassStudent;
+import com.xjrsoft.module.banding.entity.BandingTaskMajorCondition;
+import com.xjrsoft.module.banding.entity.BandingTaskRule;
 import com.xjrsoft.module.banding.mapper.BandingRuleMapper;
 import com.xjrsoft.module.banding.mapper.BandingTaskClassMapper;
 import com.xjrsoft.module.banding.mapper.BandingTaskMapper;
@@ -41,10 +50,21 @@ import com.xjrsoft.module.organization.entity.UserRoleRelation;
 import com.xjrsoft.module.organization.service.IUserRoleRelationService;
 import com.xjrsoft.module.organization.service.IUserService;
 import com.xjrsoft.module.outint.vo.IdCountVo;
-import com.xjrsoft.module.student.entity.*;
+import com.xjrsoft.module.student.entity.BaseClassMajorSet;
+import com.xjrsoft.module.student.entity.BaseNewStudent;
+import com.xjrsoft.module.student.entity.BaseStudent;
+import com.xjrsoft.module.student.entity.BaseStudentFamily;
+import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
+import com.xjrsoft.module.student.entity.EnrollmentPlan;
+import com.xjrsoft.module.student.entity.StudentReportPlan;
+import com.xjrsoft.module.student.entity.StudentReportRecord;
 import com.xjrsoft.module.student.mapper.BaseClassMajorSetMapper;
 import com.xjrsoft.module.student.mapper.StudentReportRecordMapper;
-import com.xjrsoft.module.student.service.*;
+import com.xjrsoft.module.student.service.IBaseNewStudentService;
+import com.xjrsoft.module.student.service.IBaseStudentFamilyService;
+import com.xjrsoft.module.student.service.IBaseStudentSchoolRollService;
+import com.xjrsoft.module.student.service.IBaseStudentService;
+import com.xjrsoft.module.student.service.IStudentReportPlanService;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -53,16 +73,23 @@ import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Random;
 import java.util.concurrent.CompletableFuture;
 import java.util.stream.Collectors;
 
 /**
- * @title: 新生分班任务
- * @Author dzx
- * @Date: 2024-07-01
- * @Version 1.0
- */
+* @title: 新生分班任务
+* @Author dzx
+* @Date: 2024-07-01
+* @Version 1.0
+*/
 @Service
 @AllArgsConstructor
 public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper, BandingTask> implements IBandingTaskService {
@@ -128,7 +155,7 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
     @Transactional(rollbackFor = Exception.class)
     public Boolean automaticBanding(AutomaticBandingTaskDto dto) {
         BandingTask bandingTask = this.getById(dto.getBandingTaskId());
-        if (bandingTask == null) {
+        if(bandingTask == null){
             throw new MyException("未能查询到该任务,无法自动分班");
         }
         //1、查询需要分班的学生信息
@@ -157,7 +184,11 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
         );
         //2、查询所有班级信息
         List<BandingTaskClass> classList = taskClassMapper.getListOrderByAsc(bandingTask.getId());
-        if (!classList.isEmpty()) {
+        List<BandingTaskClass> nullNumberClass = classList.stream().filter(x -> x.getNumber() == null).collect(Collectors.toList());
+        if(!nullNumberClass.isEmpty()){
+            throw new MyException("班级配置中有班级未设置人数,无法自动分班");
+        }
+        if(!classList.isEmpty()){
             //清除数据
             List<Long> classIds = classList.stream().map(BandingTaskClass::getId).collect(Collectors.toList());
             classStudentService.remove(
@@ -185,12 +216,12 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
         //计算每个专业平均的男女人数
         Map<Long, Integer> majorMaleCountMap = new HashMap<>();
         Map<Long, Integer> majorFemaleCountMap = new HashMap<>();
-        if (ruleCodes.contains("BR0001")) {
+        if(ruleCodes.contains("BR0001")){
             for (Long majorSetId : majorClassCount.keySet()) {
                 int classCount = majorClassCount.get(majorSetId);
                 Integer maleCount = majorStudentCountMap.get(majorSetId).getMaleCount();
                 Integer femaleCount = majorStudentCountMap.get(majorSetId).getFemaleCount();
-                if (classCount == 1 || classCount == 0) {
+                if(classCount == 1 || classCount == 0){
                     majorMaleCountMap.put(majorSetId, maleCount);
                     majorFemaleCountMap.put(majorSetId, femaleCount);
                     continue;
@@ -202,7 +233,7 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
 
         //包含下面个条件,则需要计算每个班级应该分配的人数
         Map<Long, Integer> classLimitMap = new HashMap<>();
-        if (ruleCodes.contains("BR0004")) {
+        if(ruleCodes.contains("BR0004")){
             //查询每个专业下面的班级人数
             Map<Long, Integer> majorClassStudentCount = taskClassMapper.getMajorClassStudentCount(bandingTask.getId())
                     .stream().collect(Collectors.toMap(IdCountVo::getId, IdCountVo::getCount));
@@ -212,21 +243,21 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
             Map<Long, Integer> majorLimitMap = new HashMap<>();
             for (Long majorSetId : majorClassStudentCount.keySet()) {
                 int majorClassNumber = 0;
-                if (majorClassStudentCount.get(majorSetId) != null) {
+                if(majorClassStudentCount.get(majorSetId) != null){
                     majorClassNumber = majorClassStudentCount.get(majorSetId);
                 }
-                if (majorClassCount.get(majorSetId) == 1 || majorClassCount.get(majorSetId) == 0) {
+                if(majorClassCount.get(majorSetId) == 1 || majorClassCount.get(majorSetId) == 0){
                     continue;
                 }
                 int majorStudentNumber = 0;
-                if (majorStudentCount.get(majorSetId) != null) {
+                if(majorStudentCount.get(majorSetId) != null){
                     majorStudentNumber = majorStudentCount.get(majorSetId);
                 }
                 Integer classCount = majorClassCount.get(majorSetId);
-                if (majorStudentNumber < majorClassNumber) {//报名人数小于班级人数
+                if(majorStudentNumber < majorClassNumber){//报名人数小于班级人数
                     Integer classLimtCount = majorStudentNumber / classCount;
                     majorLimitMap.put(majorSetId, classLimtCount);
-                } else {
+                }else{
                     Integer classLimtCount = majorClassNumber / classCount;
                     majorLimitMap.put(majorSetId, classLimtCount);
                 }
@@ -248,7 +279,7 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
         }
 
         Map<Long, List<BaseNewStudent>> classStudentMap = new HashMap<>();
-        if (ruleCodes.contains("BR0002")) {
+        if(ruleCodes.contains("BR0002")){
             classStudentMap.putAll(divideStudentByScore(classConditionMap, baseNewStudents, classList));
         }
 
@@ -258,32 +289,32 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
         //4、开始分班
         for (BandingTaskClass taskClass : classList) {
             Integer number = taskClass.getNumber();//班级总人数
-            if (classLimitMap.get(taskClass.getId()) != null) {
-                if (number > classLimitMap.get(taskClass.getId())) {
+            if(classLimitMap.get(taskClass.getId()) != null){
+                if(number > classLimitMap.get(taskClass.getId())){
                     number = classLimitMap.get(taskClass.getId());
                 }
             }
             Integer maleCount = 0, femaleCount = 0;
-            if (ruleCodes.contains("BR0001")) {
+            if(ruleCodes.contains("BR0001")){
                 IdManyCountVo countVo = majorStudentCountMap.get(taskClass.getMajorSetId());
                 maleCount = number / 2;
                 femaleCount = number / 2;
                 //如果班级人数是奇数,随机分配一个名额
-                if (number % 2 != 0) {
+                if(number % 2 != 0){
                     Random random = new Random();
                     int randomIndex = random.nextInt(GenderDictionaryEnum.getCodes().length);
 
                     String randomGender = GenderDictionaryEnum.getCodes()[randomIndex];
-                    if (GenderDictionaryEnum.MALE.getCode().equals(randomGender)) {
-                        maleCount++;
-                    } else if (GenderDictionaryEnum.FEMALE.getCode().equals(randomGender)) {
-                        femaleCount++;
+                    if(GenderDictionaryEnum.MALE.getCode().equals(randomGender)){
+                        maleCount ++;
+                    }else if(GenderDictionaryEnum.FEMALE.getCode().equals(randomGender)){
+                        femaleCount ++ ;
                     }
                 }
-                if (majorMaleCountMap.get(taskClass.getMajorSetId()) < maleCount) {
+                if(majorMaleCountMap.get(taskClass.getMajorSetId()) < maleCount){
                     maleCount = countVo.getMaleCount();
                     femaleCount = number - maleCount;
-                } else if (majorFemaleCountMap.get(taskClass.getMajorSetId()) < femaleCount) {
+                }else if(majorFemaleCountMap.get(taskClass.getMajorSetId()) < femaleCount){
                     femaleCount = countVo.getFemaleCount();
                     maleCount = number - femaleCount;
                 }
@@ -294,68 +325,68 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
 
             List<BaseNewStudent> studentList = new ArrayList<>();
             studentList.addAll(baseNewStudents);
-            if (ruleCodes.contains("BR0002") && classStudentMap.get(taskClass.getMajorSetId()) != null && !classStudentMap.get(taskClass.getMajorSetId()).isEmpty()) {
+            if(ruleCodes.contains("BR0002") && classStudentMap.get(taskClass.getMajorSetId()) != null && !classStudentMap.get(taskClass.getMajorSetId()).isEmpty()){
                 studentList.clear();
                 studentList.addAll(classStudentMap.get(taskClass.getMajorSetId()));
             }
 
             for (BaseNewStudent newStudent : studentList) {
                 //人数已满,进行下一个班级的的循环
-                if (nameList.size() == number) {
+                if(nameList.size() == number){
                     break;
                 }
                 //该学生已被分配
-                if (studentClassMap.containsKey(newStudent.getId())) {
+                if(studentClassMap.containsKey(newStudent.getId())){
                     continue;
                 }
-                if (ruleCodes.contains("BR0003") && nameList.contains(newStudent.getName())) {
+                if(ruleCodes.contains("BR0003") && nameList.contains(newStudent.getName())){
                     continue;
                 }
                 //专业不匹配,直接跳过
-                if (!Objects.equals(taskClass.getMajorSetId(), newStudent.getFirstAmbitionId()) && !Objects.equals(taskClass.getMajorSetId(), newStudent.getSecondAmbitionId())) {
+                if(!Objects.equals(taskClass.getMajorSetId(), newStudent.getFirstAmbitionId()) && !Objects.equals(taskClass.getMajorSetId(), newStudent.getSecondAmbitionId())){
                     continue;
                 }
                 //判断该班性别是否已满,如果设置了排序,即使性别满了班级人数没满继续分班
-                if (ruleCodes.contains("BR0001")) {
-                    if (GenderDictionaryEnum.MALE.getCode().equals(newStudent.getGender()) && maleList.size() == maleCount) {
+                if(ruleCodes.contains("BR0001")){
+                    if(GenderDictionaryEnum.MALE.getCode().equals(newStudent.getGender()) && maleList.size() == maleCount){
                         continue;
-                    } else if (GenderDictionaryEnum.FEMALE.getCode().equals(newStudent.getGender()) && femaleList.size() == femaleCount) {
+                    }else if(GenderDictionaryEnum.FEMALE.getCode().equals(newStudent.getGender()) && femaleList.size() == femaleCount){
                         continue;
                     }
                 }
 
-                if (taskClass.getSortCode() == null && !Objects.equals(taskClass.getMajorSetId(), newStudent.getFirstAmbitionId())) {//如果未给班级设置优先级,只匹配一志愿的学生
+                if(taskClass.getSortCode() == null && !Objects.equals(taskClass.getMajorSetId(), newStudent.getFirstAmbitionId())){//如果未给班级设置优先级,只匹配一志愿的学生
                     continue;
                 }
 
                 List<Boolean> conditionList = new ArrayList<>();
                 BandingTaskMajorCondition condition = classConditionMap.get(taskClass.getMajorSetId());
-                if (condition != null) {
-                    if (condition.getHeight() != null && newStudent.getHeight() != null && newStudent.getHeight().compareTo(condition.getHeight()) >= 0) {
+                if(condition != null){
+                    if(condition.getHeight() !=null && newStudent.getHeight() != null && newStudent.getHeight().compareTo(condition.getHeight()) >= 0 ){
                         conditionList.add(true);
-                    } else if (condition.getHeight() != null && newStudent.getHeight() != null && newStudent.getHeight().compareTo(condition.getHeight()) < 0) {
+                    }else if(condition.getHeight() !=null && newStudent.getHeight() != null && newStudent.getHeight().compareTo(condition.getHeight()) < 0){
                         conditionList.add(false);
-                    } else if (condition.getHeight() != null && newStudent.getHeight() == null) {
+                    }else if(condition.getHeight() !=null && newStudent.getHeight() == null){
                         conditionList.add(false);
                     }
 
-                    if (condition.getScore() != null && newStudent.getScore() != null && newStudent.getScore().compareTo(condition.getScore()) >= 0) {
+                    if(condition.getScore() !=null && newStudent.getScore() != null && newStudent.getScore().compareTo(condition.getScore()) >= 0 ){
                         conditionList.add(true);
-                    } else if (condition.getScore() != null && newStudent.getScore() != null && newStudent.getScore().compareTo(condition.getScore()) < 0) {
+                    }else if(condition.getScore() !=null && newStudent.getScore() != null && newStudent.getScore().compareTo(condition.getScore()) < 0){
                         conditionList.add(false);
-                    } else if (condition.getScore() != null && newStudent.getScore() == null) {
+                    }else if(condition.getScore() !=null && newStudent.getScore() == null){
                         conditionList.add(false);
                     }
                 }
 
                 //如果包含false,则表明不符合条件,这个学生跳过
-                if (conditionList.contains(false)) {
+                if(conditionList.contains(false)){
                     continue;
                 }
                 studentClassMap.put(newStudent.getId(), taskClass.getId());
-                if (GenderDictionaryEnum.MALE.getCode().equals(newStudent.getGender())) {
+                if(GenderDictionaryEnum.MALE.getCode().equals(newStudent.getGender())){
                     maleList.add(newStudent);
-                } else if (GenderDictionaryEnum.FEMALE.getCode().equals(newStudent.getGender())) {
+                }else if(GenderDictionaryEnum.FEMALE.getCode().equals(newStudent.getGender())){
                     femaleList.add(newStudent);
                 }
                 nameList.add(newStudent.getName());
@@ -365,54 +396,54 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
         // 4.1、二次循环班级,对没有设置排序的班级进行分班,
         for (BandingTaskClass taskClass : classList) {
             Integer number = taskClass.getNumber();//班级总人数
-            if (classLimitMap.get(taskClass.getId()) != null) {
-                if (number > classLimitMap.get(taskClass.getId())) {
+            if(classLimitMap.get(taskClass.getId()) != null){
+                if(number > classLimitMap.get(taskClass.getId())){
                     number = classLimitMap.get(taskClass.getId());
                 }
             }
             List<String> nameList = classNameMap.get(taskClass.getId());
-            if (nameList.size() == number) {
+            if(nameList.size() == number){
                 continue;
             }
             for (BaseNewStudent newStudent : baseNewStudents) {
                 //人数已满,进行下一个班级的的循环
-                if (nameList.size() == number) {
+                if(nameList.size() == number){
                     break;
                 }
                 //该学生已被分配
-                if (studentClassMap.containsKey(newStudent.getId())) {
+                if(studentClassMap.containsKey(newStudent.getId())){
                     continue;
                 }
-                if (ruleCodes.contains("BR0003") && nameList.contains(newStudent.getName())) {
+                if(ruleCodes.contains("BR0003") && nameList.contains(newStudent.getName())){
                     continue;
                 }
                 //专业不匹配,直接跳过
-                if (!Objects.equals(taskClass.getMajorSetId(), newStudent.getFirstAmbitionId()) && !Objects.equals(taskClass.getMajorSetId(), newStudent.getSecondAmbitionId())) {
+                if(!Objects.equals(taskClass.getMajorSetId(), newStudent.getFirstAmbitionId()) && !Objects.equals(taskClass.getMajorSetId(), newStudent.getSecondAmbitionId())){
                     continue;
                 }
                 //判断该班性别是否已满
                 List<Boolean> conditionList = new ArrayList<>();
                 BandingTaskMajorCondition condition = classConditionMap.get(taskClass.getMajorSetId());
-                if (condition != null) {
-                    if (condition.getHeight() != null && newStudent.getHeight() != null && newStudent.getHeight().compareTo(condition.getHeight()) >= 0) {
+                if(condition != null){
+                    if(condition.getHeight() !=null && newStudent.getHeight() != null && newStudent.getHeight().compareTo(condition.getHeight()) >= 0 ){
                         conditionList.add(true);
-                    } else if (condition.getHeight() != null && newStudent.getHeight() != null && newStudent.getHeight().compareTo(condition.getHeight()) < 0) {
+                    }else if(condition.getHeight() !=null && newStudent.getHeight() != null && newStudent.getHeight().compareTo(condition.getHeight()) < 0){
                         conditionList.add(false);
-                    } else if (condition.getHeight() != null && newStudent.getHeight() == null) {
+                    }else if(condition.getHeight() !=null && newStudent.getHeight() == null){
                         conditionList.add(false);
                     }
 
-                    if (condition.getScore() != null && newStudent.getScore() != null && newStudent.getScore().compareTo(condition.getScore()) >= 0) {
+                    if(condition.getScore() !=null && newStudent.getScore() != null && newStudent.getScore().compareTo(condition.getScore()) >= 0 ){
                         conditionList.add(true);
-                    } else if (condition.getScore() != null && newStudent.getScore() != null && newStudent.getScore().compareTo(condition.getScore()) < 0) {
+                    }else if(condition.getScore() !=null && newStudent.getScore() != null && newStudent.getScore().compareTo(condition.getScore()) < 0){
                         conditionList.add(false);
-                    } else if (condition.getScore() != null && newStudent.getScore() == null) {
+                    }else if(condition.getScore() !=null && newStudent.getScore() == null){
                         conditionList.add(false);
                     }
                 }
 
                 //如果包含false,则表明不符合条件,这个学生跳过
-                if (conditionList.contains(false)) {
+                if(conditionList.contains(false)){
                     continue;
                 }
                 studentClassMap.put(newStudent.getId(), taskClass.getId());
@@ -425,7 +456,7 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
         Date createDate = new Date();
         for (Long studentId : studentClassMap.keySet()) {
             dataList.add(
-                    new BandingTaskClassStudent() {{
+                    new BandingTaskClassStudent(){{
                         setBandingTaskClassId(studentClassMap.get(studentId));
                         setNewStudentId(studentId);
                         setStatus(0);
@@ -433,7 +464,7 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
                     }}
             );
         }
-        if (!dataList.isEmpty()) {
+        if(!dataList.isEmpty()){
             classStudentService.saveBatch(dataList);
         }
 
@@ -442,11 +473,10 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
 
     /**
      * 按照成绩均衡划分学生
-     *
      * @return 班级id和学生
      */
     Map<Long, List<BaseNewStudent>> divideStudentByScore(Map<Long, BandingTaskMajorCondition> classConditionMap, List<BaseNewStudent> baseNewStudents,
-                                                         List<BandingTaskClass> classList) {
+                                                         List<BandingTaskClass> classList){
         Map<Long, List<BaseNewStudent>> classStudentMap = new HashMap<>();
         for (Long majorSetId : classConditionMap.keySet()) {
             //查询该专业下面有几个班级,把这部分学生按照成绩均匀分组
@@ -454,7 +484,7 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
             for (int i = 0; i < classList.size(); i++) {
                 result.add(new ArrayList<>());
             }
-            if (result.size() == 1) {
+            if(result.size() == 1){
                 continue;
             }
 
@@ -462,36 +492,36 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
             List<BaseNewStudent> stuList = new ArrayList<>();
 
             for (BaseNewStudent newStudent : baseNewStudents) {
-                if (!Objects.equals(majorSetId, newStudent.getFirstAmbitionId()) && !Objects.equals(majorSetId, newStudent.getSecondAmbitionId())) {
+                if(!Objects.equals(majorSetId, newStudent.getFirstAmbitionId()) && !Objects.equals(majorSetId, newStudent.getSecondAmbitionId())){
                     continue;
                 }
 
                 List<Boolean> conditionList = new ArrayList<>();
                 BandingTaskMajorCondition condition = classConditionMap.get(majorSetId);
-                if (condition.getHeight() != null && newStudent.getHeight() != null && newStudent.getHeight().compareTo(condition.getHeight()) >= 0) {
+                if(condition.getHeight() !=null && newStudent.getHeight() != null && newStudent.getHeight().compareTo(condition.getHeight()) >= 0 ){
                     conditionList.add(true);
-                } else if (condition.getHeight() != null && newStudent.getHeight() != null && newStudent.getHeight().compareTo(condition.getHeight()) < 0) {
+                }else if(condition.getHeight() !=null && newStudent.getHeight() != null && newStudent.getHeight().compareTo(condition.getHeight()) < 0){
                     conditionList.add(false);
-                } else if (condition.getHeight() != null && newStudent.getHeight() == null) {
+                }else if(condition.getHeight() !=null && newStudent.getHeight() == null){
                     conditionList.add(false);
                 }
 
-                if (condition.getScore() != null && newStudent.getScore() != null && newStudent.getScore().compareTo(condition.getScore()) >= 0) {
+                if(condition.getScore() !=null && newStudent.getScore() != null && newStudent.getScore().compareTo(condition.getScore()) >= 0 ){
                     conditionList.add(true);
-                } else if (condition.getScore() != null && newStudent.getScore() != null && newStudent.getScore().compareTo(condition.getScore()) < 0) {
+                }else if(condition.getScore() !=null && newStudent.getScore() != null && newStudent.getScore().compareTo(condition.getScore()) < 0){
                     conditionList.add(false);
-                } else if (condition.getScore() != null && newStudent.getScore() == null) {
+                }else if(condition.getScore() !=null && newStudent.getScore() == null){
                     conditionList.add(false);
                 }
                 //如果包含false,则表明不符合条件,这个学生跳过
-                if (conditionList.contains(false)) {
+                if(conditionList.contains(false)){
                     continue;
                 }
                 stuList.add(newStudent);
             }
-            if (!stuList.isEmpty()) {
+            if(!stuList.isEmpty()){
                 for (BaseNewStudent student : stuList) {
-                    if (student.getScore() == null) {
+                    if(student.getScore() == null){
                         student.setScore(BigDecimal.ZERO);
                     }
                 }
@@ -504,7 +534,7 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
                 result.get(classIndex).add(currentStudent);
             }
 
-            for (int i = 0; i < result.size(); i++) {
+            for (int i = 0; i < result.size(); i ++){
                 classStudentMap.put(classList.get(i).getId(), result.get(i));
             }
         }
@@ -527,7 +557,7 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
                         .eq(BandingTaskClassStudent::getStatus, 0)
         );
         List<Long> studentIds = classStudents.stream().map(BandingTaskClassStudent::getNewStudentId).collect(Collectors.toList());
-        if (studentIds.isEmpty()) {
+        if(studentIds.isEmpty()){
             throw new MyException("未能查询到学生,无法确认");
         }
         List<BaseNewStudent> list = newStudentService.list(
@@ -540,7 +570,7 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
             updateList.add(student);
         }
 
-        if (!updateList.isEmpty()) {
+        if(!updateList.isEmpty()){
             newStudentService.updateBatchById(updateList);
         }
 
@@ -578,7 +608,7 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
                     setClassroomId(taskClass.getClassroomId());
                     setTeacherId(taskClass.getTeacherId());
                     setIsGraduate(1);
-                    setIsOrderClass(taskClass.getIsOrderClass() == null ? 0 : taskClass.getIsOrderClass().intValue());
+                    setIsOrderClass(taskClass.getIsOrderClass()==null?0:taskClass.getIsOrderClass().intValue());
                     setGradeId(bandingTask.getGradeId());
                     setDeleteMark(DeleteMark.NODELETE.getCode());
                     setEnrollType(bandingTask.getEnrollType());
@@ -603,7 +633,7 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
 
                 classMap.put(taskClass.getId(), baseClass.getId());
                 taskClassMajorMap.put(taskClass.getId(), taskClass.getMajorSetId());
-                maxCode++;
+                maxCode ++;
             }
 
             /**
@@ -650,7 +680,7 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
 
                 BaseStudentSchoolRoll schoolRoll = new BaseStudentSchoolRoll() {{
                     setUserId(xjrUser.getId());
-                    if (student.getScore() != null) {
+                    if(student.getScore() != null){
                         setGraduatedScore(student.getScore().doubleValue());
                     }
                     setGraduatedUniversity(student.getGraduateSchool());
@@ -698,7 +728,6 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
 
     /**
      * 确认分班后,进入
-     *
      * @param dto
      * @return
      */
@@ -714,7 +743,7 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
                         .eq(BandingTaskClass::getBandingTaskId, dto.getId())
         );
         List<Long> studentIds = classStudents.stream().map(BandingTaskClassStudent::getNewStudentId).collect(Collectors.toList());
-        if (studentIds.isEmpty()) {
+        if(studentIds.isEmpty()){
             throw new MyException("未能查询到学生,无法确认");
         }
         BandingTask bandingTask = this.getById(dto.getId());
@@ -730,7 +759,7 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
             updateList.add(student);
         }
 
-        if (!updateList.isEmpty()) {
+        if(!updateList.isEmpty()){
             newStudentService.updateBatchById(updateList);
         }
 
@@ -742,8 +771,9 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
                         .eq(StudentReportPlan::getEnabledMark, EnabledMark.ENABLED.getCode())
                         .eq(StudentReportPlan::getSemesterId, semester.getId())
                         .eq(StudentReportPlan::getCategory, 2)
+                        .eq(StudentReportPlan::getBandingTaskId, dto.getBandingTaskId())
         );
-        if (plan == null) {
+        if(plan == null){
             plan = new StudentReportPlan() {{
                 setName(bandingTask.getName());
                 setCategory(2);
@@ -770,12 +800,13 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
         }
 
 
+
         bandingTask.setStatus(1);
         bandingTask.setModifyDate(new Date());
         return this.update(bandingTask);
     }
 
-    LocalDate getBirthDate(String idCardNumber) {
+    LocalDate getBirthDate(String idCardNumber){
         // 获取出生日期前6位,即yyyyMM
         String birthdayString = idCardNumber.substring(6, 14);
 
@@ -785,20 +816,18 @@ public class BandingTaskServiceImpl extends MPJBaseServiceImpl<BandingTaskMapper
         try {
             LocalDate parse = LocalDate.parse(birthdayString, formatter);
             return parse;
-        } catch (Exception e) {
+        }catch (Exception e){
             throw new MyException("身份证号填写错误,无法提取出生日期");
         }
     }
 
     /**
      * 修改新生信息中的状态和分班类型
-     *
-     * @param bandingTaskId    分班任务id
-     * @param operateMode      分班类型(1:自动分班 2:手动分班)
+     * @param bandingTaskId 分班任务id
+     * @param operateMode 分班类型(1:自动分班 2:手动分班)
      * @param baseNewStudentId 新生id,适合手动调整班级时调用
      */
-    void updateBaseNewStudentStatus(Long bandingTaskId, Integer operateMode, Long baseNewStudentId) {
-
-    }
+    void updateBaseNewStudentStatus(Long bandingTaskId, Integer operateMode, Long baseNewStudentId){
 
+    };
 }

+ 3 - 0
src/main/java/com/xjrsoft/module/banding/vo/BandingTaskClassReportStatisticsVo.java

@@ -60,4 +60,7 @@ public class BandingTaskClassReportStatisticsVo {
 
     @ApiModelProperty("已到女生人数")
     private Integer arrivedFemaleCount;
+
+    @ApiModelProperty("报到率")
+    private String reportRate;
 }

+ 13 - 0
src/main/java/com/xjrsoft/module/classtime/controller/ClassTimeDeleteController.java

@@ -75,6 +75,19 @@ public class ClassTimeDeleteController {
         return RT.ok(isSuccess);
     }
 
+    @PostMapping(value = "add-batch")
+    @ApiOperation(value = "批量新增新增课时删除")
+    @SaCheckPermission("classtimedelete:add")
+    public RT<Boolean> add(@Valid @RequestBody List<AddClassTimeDeleteDto> dtoList){
+        for (AddClassTimeDeleteDto dto : dtoList) {
+            ClassTimeDelete classTimeDelete = BeanUtil.toBean(dto, ClassTimeDelete.class);
+            classTimeDelete.setCreateDate(new Date());
+            classTimeDeleteService.save(classTimeDelete);
+        }
+
+        return RT.ok(true);
+    }
+
     @PutMapping
     @ApiOperation(value = "修改课时删除")
     @SaCheckPermission("classtimedelete:edit")

+ 1 - 3
src/main/java/com/xjrsoft/module/job/WfCourseAdjustTask.java

@@ -19,7 +19,6 @@ import java.util.List;
 
 /**
  * 每过10分钟定时处理没有处理成功的调课或者顶课流程
- *
  * @author dzx
  * @date 2025/3/3
  */
@@ -54,8 +53,7 @@ public class WfCourseAdjustTask {
                     " AND t1.course_name = t2.course_name" +
                     " AND t1.site_id = t2.site_id" +
                     " AND t1.teacher_name = t2.teacher_name";
-            long count = SqlRunnerAdapter.db().selectCount(sql);
-            if (count > 0) {
+            if(!SqlRunnerAdapter.db().selectList(sql).isEmpty()){
                 continue;
             }
             courseTableService.adjustCourse(wfCourseAdjust);

+ 1 - 1
src/main/java/com/xjrsoft/module/liteflow/node/StudentDropOutNode.java

@@ -109,9 +109,9 @@ public class StudentDropOutNode extends NodeComponent {
                                 2
                         );
 
-
                         schoolRoll.setArchivesStatus(ArchivesStatusEnum.FB2904.getCode());
                         studentSchoolRollService.updateById(schoolRoll);
+                        studentSchoolRollService.disableStudent(schoolRoll.getUserId(), studentDropOut.getCreateUserId());
                     });
                 }
             });

+ 85 - 79
src/main/java/com/xjrsoft/module/student/controller/BaseNewStudentController.java

@@ -12,7 +12,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.xjrsoft.common.annotation.XjrLog;
 import com.xjrsoft.common.constant.GlobalConstant;
 import com.xjrsoft.common.enums.EnabledMark;
 import com.xjrsoft.common.model.result.RT;
@@ -31,17 +30,36 @@ import com.xjrsoft.module.organization.entity.User;
 import com.xjrsoft.module.organization.entity.UserRoleRelation;
 import com.xjrsoft.module.organization.service.IUserRoleRelationService;
 import com.xjrsoft.module.organization.service.IUserService;
-import com.xjrsoft.module.student.dto.*;
+import com.xjrsoft.module.room.entity.RoomBed;
+import com.xjrsoft.module.student.dto.ActiveAccountDto;
+import com.xjrsoft.module.student.dto.AddBaseNewStudentDto;
+import com.xjrsoft.module.student.dto.BaseNewStudentPageDto;
+import com.xjrsoft.module.student.dto.ChangeBandingStatusDto;
+import com.xjrsoft.module.student.dto.DeleteNewStudentDto;
+import com.xjrsoft.module.student.dto.UpdateBaseNewStudentDto;
 import com.xjrsoft.module.student.entity.BaseNewStudent;
 import com.xjrsoft.module.student.entity.BaseStudentFamilyMember;
 import com.xjrsoft.module.student.service.IBaseNewStudentService;
 import com.xjrsoft.module.student.service.IBaseStudentFamilyMemberService;
-import com.xjrsoft.module.student.vo.*;
+import com.xjrsoft.module.student.vo.BaseNewStudentExportVo;
+import com.xjrsoft.module.student.vo.BaseNewStudentPageVo;
+import com.xjrsoft.module.student.vo.BaseNewStudentScoreExcelVo;
+import com.xjrsoft.module.student.vo.BaseNewStudentTreeVo;
+import com.xjrsoft.module.student.vo.BaseNewStudentVo;
+import com.xjrsoft.module.student.vo.EnrollmentPlanGradeVo;
+import com.xjrsoft.module.student.vo.EnrollmentPlanTreeVo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.validation.Valid;
@@ -49,18 +67,22 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.concurrent.CompletableFuture;
 
 /**
- * @title: 新生维护信息
- * @Author dzx
- * @Date: 2024-06-27
- * @Version 1.0
- */
+* @title: 新生维护信息
+* @Author dzx
+* @Date: 2024-06-27
+* @Version 1.0
+*/
 @RestController
 @RequestMapping("/student" + "/baseNewStudent")
-@Api(value = "/student" + "/baseNewStudent", tags = "新生维护信息代码")
+@Api(value = "/student"  + "/baseNewStudent",tags = "新生维护信息代码")
 @AllArgsConstructor
 public class BaseNewStudentController {
 
@@ -73,34 +95,30 @@ public class BaseNewStudentController {
     private final IBaseUserStudentService userStudentService;
     private final CommonPropertiesConfig propertiesConfig;
     private final IBaseSemesterService semesterService;
-
     @GetMapping(value = "/page")
-    @ApiOperation(value = "新生维护信息列表(分页)")
+    @ApiOperation(value="新生维护信息列表(分页)")
     @SaCheckPermission("basenewstudent:detail")
-    @XjrLog(value = "新生维护信息列表(分页)")
-    public RT<PageOutput<BaseNewStudentPageVo>> page(@Valid BaseNewStudentPageDto dto) {
-
+    public RT<PageOutput<BaseNewStudentPageVo>> page(@Valid BaseNewStudentPageDto dto){
         Page<BaseNewStudentPageVo> page = baseNewStudentService.getPage(new Page<>(dto.getLimit(), dto.getSize()), dto);
         PageOutput<BaseNewStudentPageVo> pageOutput = ConventPage.getPageOutput(page, BaseNewStudentPageVo.class);
         return RT.ok(pageOutput);
     }
 
     @GetMapping(value = "/report-page")
-    @ApiOperation(value = "新生报到(分页)")
+    @ApiOperation(value="新生报到(分页)")
     @SaCheckPermission("basenewstudent:detail")
-    @XjrLog(value = "新生报到(分页)")
-    public RT<PageOutput<BaseNewStudentPageVo>> reportPage(@Valid BaseNewStudentPageDto dto) {
+    public RT<PageOutput<BaseNewStudentPageVo>> reportPage(@Valid BaseNewStudentPageDto dto){
         List<String> roleList = StpUtil.getRoleList();
-        if (roleList.contains("CLASSTE") && roleList.contains("TEACHER") && dto.getTeacherId() == null) {
+        if(roleList.contains("CLASSTE") && roleList.contains("TEACHER") && dto.getTeacherId() == null){
             dto.setTeacherId(StpUtil.getLoginIdAsLong());
         }
-        if (dto.getBaseSemesterId() == null) {
+        if(dto.getBaseSemesterId() == null){
             LambdaQueryWrapper<BaseSemester> queryWrapper = new LambdaQueryWrapper<>();
             queryWrapper
                     .orderByDesc(BaseSemester::getStartDate)
-                    .select(BaseSemester.class, x -> VoToColumnUtil.fieldsToColumns(BaseSemester.class).contains(x.getProperty()));
+                    .select(BaseSemester.class,x -> VoToColumnUtil.fieldsToColumns(BaseSemester.class).contains(x.getProperty()));
             List<BaseSemester> semesterList = semesterService.list(queryWrapper);
-            if (!semesterList.isEmpty()) {
+            if(!semesterList.isEmpty()){
                 dto.setBaseSemesterId(semesterList.get(0).getId());
             }
         }
@@ -110,11 +128,9 @@ public class BaseNewStudentController {
     }
 
     @GetMapping(value = "/tree")
-    @ApiOperation(value = "新生维护信息树")
+    @ApiOperation(value="新生维护信息树")
     @SaCheckPermission("basenewstudent:detail")
-    @XjrLog(value = "新生维护信息树")
-    public RT<List<BaseNewStudentTreeVo>> tree() {
-
+    public RT<List<BaseNewStudentTreeVo>> tree(){
         List<EnrollmentPlanGradeVo> gradeList = baseNewStudentService.getGradeList();
         List<EnrollmentPlanTreeVo> list = baseNewStudentService.getEnrollmentPlanList();
 
@@ -127,7 +143,7 @@ public class BaseNewStudentController {
             }};
             List<BaseNewStudentTreeVo> children = new ArrayList<>();
             for (EnrollmentPlanTreeVo planTreeVo : list) {
-                if (planTreeVo.getGradeId().equals(gradeVo.getId())) {
+                if(planTreeVo.getGradeId().equals(gradeVo.getId())){
                     children.add(new BaseNewStudentTreeVo() {{
                         setId(planTreeVo.getId());
                         setName(planTreeVo.getEnrollTypeCn());
@@ -144,13 +160,12 @@ public class BaseNewStudentController {
     }
 
     @GetMapping(value = "/info")
-    @ApiOperation(value = "根据id查询新生维护信息信息")
+    @ApiOperation(value="根据id查询新生维护信息信息")
     @SaCheckPermission("basenewstudent:detail")
-    @XjrLog(value = "根据id查询新生维护信息信息", saveResponseData = true)
-    public RT<BaseNewStudentVo> info(@RequestParam Long id) {
+    public RT<BaseNewStudentVo> info(@RequestParam Long id){
         BaseNewStudent baseNewStudent = baseNewStudentService.getById(id);
         if (baseNewStudent == null) {
-            return RT.error("找不到此数据!");
+           return RT.error("找不到此数据!");
         }
         return RT.ok(BeanUtil.toBean(baseNewStudent, BaseNewStudentVo.class));
     }
@@ -159,8 +174,7 @@ public class BaseNewStudentController {
     @PostMapping
     @ApiOperation(value = "新增新生维护信息")
     @SaCheckPermission("basenewstudent:add")
-    @XjrLog(value = "新增新生维护信息", saveResponseData = true)
-    public RT<Boolean> add(@Valid @RequestBody AddBaseNewStudentDto dto) {
+    public RT<Boolean> add(@Valid @RequestBody AddBaseNewStudentDto dto){
         BaseNewStudent baseNewStudent = BeanUtil.toBean(dto, BaseNewStudent.class);
         baseNewStudent.setFirstAmbitionId(Long.parseLong(dto.getFirstAmbition()));
         baseNewStudent.setSecondAmbitionId(Long.parseLong(dto.getSecondAmbition()));
@@ -172,8 +186,7 @@ public class BaseNewStudentController {
     @PutMapping
     @ApiOperation(value = "修改新生维护信息")
     @SaCheckPermission("basenewstudent:edit")
-    @XjrLog(value = "修改新生维护信息", saveResponseData = true)
-    public RT<Boolean> update(@Valid @RequestBody UpdateBaseNewStudentDto dto) {
+    public RT<Boolean> update(@Valid @RequestBody UpdateBaseNewStudentDto dto){
 
         BaseNewStudent baseNewStudent = BeanUtil.toBean(dto, BaseNewStudent.class);
         return RT.ok(baseNewStudentService.updateById(baseNewStudent));
@@ -183,45 +196,42 @@ public class BaseNewStudentController {
     @DeleteMapping
     @ApiOperation(value = "删除新生维护信息")
     @SaCheckPermission("basenewstudent:delete")
-    @XjrLog(value = "删除新生维护信息", saveResponseData = true)
-    public RT<Boolean> delete(@Valid @RequestBody List<Long> ids) {
+    public RT<Boolean> delete(@Valid @RequestBody List<Long> ids){
         return RT.ok(baseNewStudentService.removeBatchByIds(ids));
     }
 
     @DeleteMapping("deleteByUserIds")
     @ApiOperation(value = "删除新生(保留新生信息,删除基础信息)")
     @SaCheckPermission("basenewstudent:delete")
-    @XjrLog(value = "删除新生(保留新生信息,删除基础信息)", saveResponseData = true)
-    public RT<Boolean> deleteByUserIds(@Valid @RequestBody DeleteNewStudentDto dto) {
+    public RT<Boolean> deleteByUserIds(@Valid @RequestBody DeleteNewStudentDto dto){
         return RT.ok(baseNewStudentService.deleteByUserIds(dto));
     }
 
 
     @PostMapping("/import")
     @ApiOperation(value = "导入")
-    @XjrLog(value = "导入", saveRequestData = false, saveResponseData = true)
     public RT<List<Map<String, String>>> importData(@RequestParam Long treeId, @RequestParam MultipartFile file) throws IOException {
         List<Map<Integer, Object>> errorList = baseNewStudentService.importData(treeId, file);
         List<Map<String, String>> result = new ArrayList<>();
 
         for (Map<Integer, Object> objectMap : errorList) {
             Map<String, String> object = new LinkedHashMap<>();
-            object.put("毕业学校", objectMap.get(0) == null ? "" : objectMap.get(0).toString());
-            object.put("学生姓名", objectMap.get(1) == null ? "" : objectMap.get(1).toString());
-            object.put("性别", objectMap.get(2) == null ? "" : objectMap.get(2).toString());
-            object.put("身份证号", objectMap.get(3) == null ? "" : objectMap.get(3).toString());
-            object.put("身高(cm)", objectMap.get(4) == null ? "" : objectMap.get(4).toString());
-            object.put("体重(kg)", objectMap.get(5) == null ? "" : objectMap.get(5).toString());
-            object.put("毕业班级", objectMap.get(6) == null ? "" : objectMap.get(6).toString());
-            object.put("学生来源", objectMap.get(7) == null ? "" : objectMap.get(7).toString());
-            object.put("住宿类型", objectMap.get(8) == null ? "" : objectMap.get(8).toString());
-            object.put("手机号", objectMap.get(9) == null ? "" : objectMap.get(9).toString());
-            object.put("第一志愿", objectMap.get(10) == null ? "" : objectMap.get(10).toString());
-            object.put("第二志愿", objectMap.get(11) == null ? "" : objectMap.get(11).toString());
-            object.put("是否可调配", objectMap.get(12) == null ? "" : objectMap.get(12).toString());
-            object.put("家庭电话", objectMap.get(13) == null ? "" : objectMap.get(13).toString());
-            object.put("家庭地址", objectMap.get(14) == null ? "" : objectMap.get(14).toString());
-            object.put("错误信息", objectMap.get(15) == null ? "" : objectMap.get(15).toString());
+            object.put("毕业学校", objectMap.get(0)==null?"":objectMap.get(0).toString());
+            object.put("学生姓名", objectMap.get(1)==null?"":objectMap.get(1).toString());
+            object.put("性别", objectMap.get(2)==null?"":objectMap.get(2).toString());
+            object.put("身份证号", objectMap.get(3)==null?"":objectMap.get(3).toString());
+            object.put("身高(cm)", objectMap.get(4)==null?"":objectMap.get(4).toString());
+            object.put("体重(kg)", objectMap.get(5)==null?"":objectMap.get(5).toString());
+            object.put("毕业班级", objectMap.get(6)==null?"":objectMap.get(6).toString());
+            object.put("学生来源", objectMap.get(7)==null?"":objectMap.get(7).toString());
+            object.put("住宿类型", objectMap.get(8)==null?"":objectMap.get(8).toString());
+            object.put("手机号", objectMap.get(9)==null?"":objectMap.get(9).toString());
+            object.put("第一志愿", objectMap.get(10)==null?"":objectMap.get(10).toString());
+            object.put("第二志愿", objectMap.get(11)==null?"":objectMap.get(11).toString());
+            object.put("是否可调配", objectMap.get(12)==null?"":objectMap.get(12).toString());
+            object.put("家庭电话", objectMap.get(13)==null?"":objectMap.get(13).toString());
+            object.put("家庭地址", objectMap.get(14)==null?"":objectMap.get(14).toString());
+            object.put("错误信息", objectMap.get(15)==null?"":objectMap.get(15).toString());
             result.add(object);
         }
         return RT.ok(result);
@@ -229,7 +239,6 @@ public class BaseNewStudentController {
 
     @PostMapping("/score-import")
     @ApiOperation(value = "成绩导入")
-    @XjrLog(value = "成绩导入", saveRequestData = false, saveResponseData = true)
     public RT<List<Map<String, String>>> scoreImport(@RequestParam MultipartFile file) throws IOException {
         List<BaseNewStudentScoreExcelVo> errorList = baseNewStudentService.scoreImport(file);
         List<Map<String, String>> result = new ArrayList<>();
@@ -249,7 +258,6 @@ public class BaseNewStudentController {
 
     @PostMapping("/active-account")
     @ApiOperation(value = "激活账号")
-    @XjrLog(value = "激活账号", saveResponseData = true)
     public RT<Boolean> activeAccount(@Valid @RequestBody ActiveAccountDto dto) {
         User user = userService.getById(dto.getId());
         user.setMobile(dto.getMobile());
@@ -257,7 +265,7 @@ public class BaseNewStudentController {
         user.setModifyDate(LocalDateTime.now());
         userService.updateById(user);
         // 新增家庭成员信息
-        if (StrUtil.isNotEmpty(dto.getParentName()) && StrUtil.isNotEmpty(dto.getParentMobile())) {
+        if(StrUtil.isNotEmpty(dto.getParentName()) && StrUtil.isNotEmpty(dto.getParentMobile())){
             List<BaseStudentFamilyMember> list = familyMemberService.list(
                     new QueryWrapper<BaseStudentFamilyMember>().lambda()
                             .eq(BaseStudentFamilyMember::getName, dto.getParentName())
@@ -265,7 +273,7 @@ public class BaseNewStudentController {
                             .eq(BaseStudentFamilyMember::getMobile, dto.getParentMobile())
             );
             BaseStudentFamilyMember member;
-            if (list.isEmpty()) {
+            if(list.isEmpty()){
                 member = new BaseStudentFamilyMember();
                 member.setUserId(user.getId());
                 member.setName(dto.getParentName());
@@ -273,7 +281,7 @@ public class BaseNewStudentController {
                 member.setCreateDate(LocalDateTime.now());
                 member.setCreateUserId(StpUtil.getLoginIdAsLong());
                 familyMemberService.save(member);
-            } else {
+            }else{
                 member = list.get(0);
             }
             List<User> parents = userService.list(
@@ -282,7 +290,7 @@ public class BaseNewStudentController {
                             .or()
                             .eq(User::getMobile, dto.getParentMobile())
             );
-            if (parents.isEmpty()) {
+            if(parents.isEmpty()){
                 User parentUser = new User() {{
                     setUserName(dto.getParentMobile());
                     setName(dto.getParentName());
@@ -294,7 +302,7 @@ public class BaseNewStudentController {
                 }};
                 userService.save(parentUser);
 
-                userRoleRelationService.save(new UserRoleRelation() {{
+                userRoleRelationService.save(new UserRoleRelation(){{
                     setUserId(parentUser.getId());
                     setRoleId(4L);
                 }});
@@ -307,7 +315,7 @@ public class BaseNewStudentController {
                 userStudent.setUserId(parentUser.getId());
                 userStudent.setStatus(1);
                 userStudentService.save(userStudent);
-            } else {
+            }else{
                 User parentUser = parents.get(0);
                 BaseUserStudent userStudent = new BaseUserStudent();
                 userStudent.setStudentId(user.getId());
@@ -326,7 +334,7 @@ public class BaseNewStudentController {
                 new QueryWrapper<WhitelistManagement>().lambda()
                         .eq(WhitelistManagement::getUserId, dto.getId())
         );
-        if (managementList.isEmpty()) {
+        if(managementList.isEmpty()){
             WhitelistManagement whitelistManagement = new WhitelistManagement() {{
                 setName(user.getName());
                 setUserId(user.getId());
@@ -335,7 +343,7 @@ public class BaseNewStudentController {
                 setPhone(user.getMobile());
             }};
             whitelistManagementService.save(whitelistManagement);
-        } else {
+        }else{
             WhitelistManagement whitelistManagement = managementList.get(0);
             whitelistManagement.setName(user.getName());
             whitelistManagement.setUserId(user.getId());
@@ -360,20 +368,19 @@ public class BaseNewStudentController {
 
     @PostMapping("/report-export-query")
     @ApiOperation(value = "导出")
-    @XjrLog(value = "导出")
     public ResponseEntity<byte[]> exportData(@Valid @RequestBody BaseNewStudentPageDto dto) {
-        if (dto.getBaseSemesterId() == null) {
+        if(dto.getBaseSemesterId() == null){
             LambdaQueryWrapper<BaseSemester> queryWrapper = new LambdaQueryWrapper<>();
             queryWrapper
                     .orderByDesc(BaseSemester::getStartDate)
-                    .select(BaseSemester.class, x -> VoToColumnUtil.fieldsToColumns(BaseSemester.class).contains(x.getProperty()));
+                    .select(BaseSemester.class,x -> VoToColumnUtil.fieldsToColumns(BaseSemester.class).contains(x.getProperty()));
             List<BaseSemester> semesterList = semesterService.list(queryWrapper);
-            if (!semesterList.isEmpty()) {
+            if(!semesterList.isEmpty()){
                 dto.setBaseSemesterId(semesterList.get(0).getId());
             }
         }
         List<String> roleList = StpUtil.getRoleList();
-        if (roleList.contains("CLASSTE") && roleList.contains("TEACHER") && dto.getTeacherId() == null) {
+        if(roleList.contains("CLASSTE") && roleList.contains("TEACHER") && dto.getTeacherId() == null){
             dto.setTeacherId(StpUtil.getLoginIdAsLong());
         }
         List<BaseNewStudentPageVo> reportList = baseNewStudentService.getReportList(dto);
@@ -381,12 +388,12 @@ public class BaseNewStudentController {
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH:mm:ss");
         for (BaseNewStudentPageVo el : reportList) {
             BaseNewStudentExportVo vo = BeanUtil.toBean(el, BaseNewStudentExportVo.class);
-            if (el.getIsReport() == 1) {
+            if(el.getIsReport() == 1){
                 vo.setReportStatus("是");
-            } else if (el.getIsReport() == 0) {
+            }else if(el.getIsReport() == 0){
                 vo.setReportStatus("否");
             }
-            if (el.getReportTime() != null) {
+            if(el.getReportTime() != null){
                 vo.setReportTime(el.getReportTime().format(formatter));
             }
             exportVos.add(vo);
@@ -400,17 +407,16 @@ public class BaseNewStudentController {
     @PostMapping("/change-banding-status")
     @ApiOperation(value = "修改分班状态")
     @SaCheckPermission("basenewstudent:add")
-    @XjrLog(value = "修改分班状态", saveResponseData = true)
-    public RT<Boolean> changeBandingStatus(@Valid @RequestBody List<ChangeBandingStatusDto> dto) {
+    public RT<Boolean> changeBandingStatus(@Valid @RequestBody List<ChangeBandingStatusDto> dto){
         for (ChangeBandingStatusDto el : dto) {
             BaseNewStudent newStudent = baseNewStudentService.getById(el.getId());
 
             UpdateWrapper<BaseNewStudent> updateWrapper = new UpdateWrapper<>();
             updateWrapper.eq("id", newStudent.getId());
             updateWrapper.setSql("is_can_banding = " + el.getIsCanBanding());
-            if (StrUtil.isNotEmpty(el.getRemarks())) {
+            if(StrUtil.isNotEmpty(el.getRemarks())){
                 updateWrapper.setSql("remarks = '" + el.getRemarks() + "'");
-            } else {
+            }else{
                 updateWrapper.setSql("remarks = null");
             }
             baseNewStudentService.update(newStudent, updateWrapper);

+ 1 - 1
src/main/java/com/xjrsoft/module/student/controller/StudentReportPlanController.java

@@ -244,7 +244,7 @@ public class StudentReportPlanController {
                         .eq(BandingTask::getGradeId, enrollmentPlan.getGradeId())
         );
         if (plan == null) {
-            return RT.ok(new StudentReportPlanVo());
+            return RT.error("未能查询到有报到学生,无法设置");
         }
         return RT.ok(BeanUtil.toBean(plan, StudentReportPlanVo.class));
     }

+ 156 - 73
src/main/java/com/xjrsoft/module/student/controller/StudentTryReadingReportController.java

@@ -9,7 +9,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.xjrsoft.common.annotation.XjrLog;
-import com.xjrsoft.common.enums.*;
+import com.xjrsoft.common.enums.DeleteMark;
+import com.xjrsoft.common.enums.EnabledMark;
+import com.xjrsoft.common.enums.EnrollTypeEnum;
+import com.xjrsoft.common.enums.GenderDictionaryEnum;
+import com.xjrsoft.common.enums.RoleCodeEnum;
+import com.xjrsoft.common.enums.StudyStatusEnum;
 import com.xjrsoft.common.model.result.RT;
 import com.xjrsoft.common.page.ConventPage;
 import com.xjrsoft.common.page.PageOutput;
@@ -25,10 +30,21 @@ import com.xjrsoft.module.base.entity.BaseGrade;
 import com.xjrsoft.module.base.service.IBaseGradeService;
 import com.xjrsoft.module.base.service.IBaseSemesterService;
 import com.xjrsoft.module.databoard.vo.ItemCountVo;
-import com.xjrsoft.module.student.dto.*;
+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.dto.ChangeBandingStatusDto;
+import com.xjrsoft.module.student.dto.StudentReportChangeClassBatchDto;
+import com.xjrsoft.module.student.dto.StudentReportRecordPageDto;
+import com.xjrsoft.module.student.dto.StudentReportRecordStatisticsDto;
+import com.xjrsoft.module.student.dto.StudentReportSignDto;
+import com.xjrsoft.module.student.dto.StudentTryReadingReportPageDto;
+import com.xjrsoft.module.student.entity.BaseNewStudent;
 import com.xjrsoft.module.student.entity.EnrollmentPlan;
 import com.xjrsoft.module.student.entity.StudentReportPlan;
 import com.xjrsoft.module.student.entity.StudentReportRecord;
+import com.xjrsoft.module.student.service.IBaseNewStudentService;
+import com.xjrsoft.module.student.service.IBaseStudentSchoolRollService;
 import com.xjrsoft.module.student.service.IEnrollmentPlanService;
 import com.xjrsoft.module.student.service.IStudentReportPlanService;
 import com.xjrsoft.module.student.service.IStudentReportRecordService;
@@ -40,7 +56,12 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 
 import javax.validation.Valid;
 import java.io.ByteArrayOutputStream;
@@ -53,14 +74,14 @@ import java.util.Map;
 import java.util.stream.Collectors;
 
 /**
- * @title: 新生维护信息
- * @Author dzx
- * @Date: 2024-06-27
- * @Version 1.0
- */
+* @title: 新生维护信息
+* @Author dzx
+* @Date: 2024-06-27
+* @Version 1.0
+*/
 @RestController
 @RequestMapping("/student" + "/tryReadingReport")
-@Api(value = "/student" + "/tryReadingReport", tags = "试读报到模块代码")
+@Api(value = "/student"  + "/tryReadingReport",tags = "试读报到模块代码")
 @AllArgsConstructor
 public class StudentTryReadingReportController {
 
@@ -72,18 +93,21 @@ public class StudentTryReadingReportController {
     private final IBaseGradeService gradeService;
     private final IEnrollmentPlanService enrollmentPlanService;
     private final IBandingTaskService bandingTaskService;
+    private final IUserService userService;
+    private final IBaseStudentSchoolRollService rollService;
+    private final IBaseNewStudentService newStudentService;
 
 
     @GetMapping(value = "/page")
-    @ApiOperation(value = "试读报到(分页)")
+    @ApiOperation(value="试读报到(分页)")
     @SaCheckPermission("tryreadingreport:detail")
-    @XjrLog(value = "试读报到(分页)")
-    public RT<PageOutput<StudentReportRecordPlanPageVo>> page(@Valid StudentTryReadingReportPageDto dto) {
+    @XjrLog(value="试读报到(分页)")
+    public RT<PageOutput<StudentReportRecordPlanPageVo>> page(@Valid StudentTryReadingReportPageDto dto){
         List<String> roleList = StpUtil.getRoleList();
-        if (roleList.contains("CLASSTE") && roleList.contains("TEACHER")) {
+        if(roleList.contains("CLASSTE") && roleList.contains("TEACHER")){
             dto.setTeacherId(StpUtil.getLoginIdAsLong());
         }
-        if (dto.getIsMoible() != null && dto.getIsMoible() == 1) {
+        if(dto.getIsMoible() != null && dto.getIsMoible() == 1){
             StudentReportPlan plan = reportPlanService.getLastTryReadingPlan();
             BandingTask bandingTask = bandingTaskService.getById(plan.getBandingTaskId());
             List<EnrollmentPlan> enrollmentPlans = enrollmentPlanService.list(
@@ -94,7 +118,7 @@ public class StudentTryReadingReportController {
                             .eq(EnrollmentPlan::getGradeId, bandingTask.getGradeId())
                             .orderByDesc(EnrollmentPlan::getId)
             );
-            if (!enrollmentPlans.isEmpty()) {
+            if(!enrollmentPlans.isEmpty()){
                 dto.setEnrollmentPlanId(enrollmentPlans.get(0).getId());
             }
         }
@@ -106,31 +130,42 @@ public class StudentTryReadingReportController {
     @PostMapping("/clear-class")
     @ApiOperation(value = "非本班学生")
     @SaCheckPermission("tryreadingreport:add")
-    @XjrLog(value = "非本班学生")
-    public RT<Boolean> clearClass(@Valid @RequestBody ChangeBandingStatusDto dto) {
+    @XjrLog(value="非本班学生")
+    public RT<Boolean> clearClass(@Valid @RequestBody ChangeBandingStatusDto dto){
         StudentReportRecord record = recordService.getById(dto.getId());
         StudentReportPlan reportPlan = reportPlanService.getById(record.getStudentReportPlanId());
         List<Long> list = new ArrayList<>();
         list.add(record.getUserId());
         classStudentService.removeStudent(list, reportPlan.getBandingTaskId());
+        BaseNewStudent newStudent = newStudentService.getById(record.getUserId());
+        if(newStudent != null){
+            User user = userService.getUserByParam(new GetUserByParamDto() {{
+                setCredentialNumber(newStudent.getCredentialNumber());
+            }});
+            if(user != null){
+                rollService.disableStudent(user.getId());
+            }
+        }
+
+
         return RT.ok(true);
     }
 
     @PostMapping(value = "/sign")
-    @ApiOperation(value = "试读报到")
+    @ApiOperation(value="试读报到")
     @SaCheckPermission("tryreadingreport:detail")
-    @XjrLog(value = "试读报到")
-    public RT<Boolean> sign(@Valid @RequestBody StudentReportSignDto dto) {
+    @XjrLog(value="试读报到")
+    public RT<Boolean> sign(@Valid @RequestBody StudentReportSignDto dto){
         return RT.ok(recordService.tryReadingSign(dto));
     }
 
     @PostMapping(value = "/all-sign")
-    @ApiOperation(value = "变更为已报到")
+    @ApiOperation(value="变更为已报到")
     @SaCheckPermission("tryreadingreport:detail")
-    @XjrLog(value = "试读报到")
-    public RT<Boolean> sign(@Valid @RequestBody List<Long> ids) {
+    @XjrLog(value="试读报到")
+    public RT<Boolean> sign(@Valid @RequestBody List<Long> ids){
         for (Long id : ids) {
-            recordService.tryReadingSign(new StudentReportSignDto() {{
+            recordService.tryReadingSign(new StudentReportSignDto(){{
                 setId(id);
             }});
         }
@@ -141,30 +176,39 @@ public class StudentTryReadingReportController {
     @ApiOperation(value = "调整班级")
     @SaCheckPermission("tryreadingreport:change-class")
     @XjrLog(value = "调整班级")
-    public RT<Boolean> changeClass(@Valid @RequestBody StudentReportSignDto dto) {
+    public RT<Boolean> changeClass(@Valid @RequestBody StudentReportSignDto dto){
         boolean isSuccess = recordService.changeClass(dto);
         return RT.ok(isSuccess);
     }
 
+    @PostMapping("/change-class-batch")
+    @ApiOperation(value = "批量调整班级")
+    @SaCheckPermission("tryreadingreport:change-class")
+    @XjrLog(value = "批量调整班级")
+    public RT<Boolean> changeClassBatch(@Valid @RequestBody StudentReportChangeClassBatchDto dto){
+        boolean isSuccess = recordService.changeClassBatch(dto);
+        return RT.ok(isSuccess);
+    }
+
     @PostMapping(value = "/update-stduyStatus")
-    @ApiOperation(value = "切换就读方式")
+    @ApiOperation(value="切换就读方式")
     @SaCheckPermission("tryreadingreport:update-stduyStatus")
     @XjrLog(value = "切换就读方式")
-    public RT<Boolean> updateStduyStatus(@Valid @RequestBody StudentReportSignDto dto) {
+    public RT<Boolean> updateStduyStatus(@Valid @RequestBody StudentReportSignDto dto){
         boolean isSuccess = recordService.updateStduyStatusByTryReading(dto);
         return RT.ok(isSuccess);
     }
 
     @PostMapping(value = "/export-query")
-    @ApiOperation(value = "导出")
+    @ApiOperation(value="导出")
     @SaCheckPermission("studentreportrecord:detail")
     @XjrLog(value = "导出")
-    public ResponseEntity<byte[]> exportQuerty(@Valid @RequestBody StudentTryReadingReportPageDto dto) {
+    public ResponseEntity<byte[]> exportQuerty(@Valid @RequestBody StudentTryReadingReportPageDto dto){
         List<StudentReportRecordExcelVo> dataList = new ArrayList<>();
 
         List<String> roleList = StpUtil.getRoleList();
-        if (roleList.contains(RoleCodeEnum.TEACHER.getCode()) && roleList.contains(RoleCodeEnum.CLASSTE.getCode())) {
-            if (dto.getClassId() == null) {
+        if(roleList.contains(RoleCodeEnum.TEACHER.getCode()) && roleList.contains(RoleCodeEnum.CLASSTE.getCode())){
+            if(dto.getClassId() == null){
                 dto.setTeacherId(StpUtil.getLoginIdAsLong());
             }
         }
@@ -174,11 +218,11 @@ public class StudentTryReadingReportController {
 
         for (StudentReportRecordPlanPageVo pageVo : planPageList) {
             StudentReportRecordExcelVo excelVo = BeanUtil.toBean(pageVo, StudentReportRecordExcelVo.class);
-            if (pageVo.getReportTime() != null) {
+            if(pageVo.getReportTime() != null){
                 excelVo.setReportTime(sdf.format(pageVo.getReportTime()));
             }
             excelVo.setIsReport("否");
-            if (pageVo.getIsReport() != null && pageVo.getIsReport() == 1) {
+            if(pageVo.getIsReport() != null && pageVo.getIsReport() == 1){
                 excelVo.setIsReport("是");
             }
 
@@ -191,25 +235,25 @@ public class StudentTryReadingReportController {
     }
 
     @GetMapping(value = "/class-list")
-    @ApiOperation(value = "查询班级信息")
+    @ApiOperation(value="查询班级信息")
     @SaCheckPermission("studentreportrecord:detail")
-    @XjrLog(value = "导出")
-    public RT<List<BandingTaskClassPageVo>> classList(@Valid StudentReportRecordPageDto dto) {
+    @XjrLog(value = "查询班级信息")
+    public RT<List<BandingTaskClassPageVo>> classList(@Valid StudentReportRecordPageDto dto){
         BandingTaskClassPageDto classDto = new BandingTaskClassPageDto();
-        if (dto.getEnrollmentPlanId() == null) {
-            if (dto.getTeacherId() != null) {
+        if(dto.getEnrollmentPlanId() == null){
+            if(dto.getTeacherId() != null){
                 classDto.setTeacherId(dto.getTeacherId());
-            } else {
+            }else{
                 classDto.setTeacherId(StpUtil.getLoginIdAsLong());
             }
             StudentReportPlan plan = reportPlanService.getLastTryReadingPlan();
-            if (plan == null) {
+            if(plan == null){
                 return RT.ok(new ArrayList<>());
             }
             classDto.setBandingTaskId(plan.getBandingTaskId());
-        } else {
+        }else{
             EnrollmentPlan enrollmentPlan = enrollmentPlanService.getById(dto.getEnrollmentPlanId());
-            if (enrollmentPlan != null) {
+            if(enrollmentPlan != null){
                 List<BandingTask> list = bandingTaskService.list(
                         new QueryWrapper<BandingTask>().lambda()
                                 .eq(BandingTask::getEnrollType, enrollmentPlan.getEnrollType())
@@ -218,43 +262,46 @@ public class StudentTryReadingReportController {
                                 .eq(BandingTask::getEnabledMark, EnabledMark.ENABLED.getCode())
                                 .orderByDesc(BandingTask::getId)
                 );
-                if (!list.isEmpty()) {
+                if(!list.isEmpty()){
                     classDto.setBandingTaskId(list.get(0).getId());
                 }
             }
         }
+        List<String> roleList = StpUtil.getRoleList();
+        if(roleList.contains("CLASSTE") && roleList.contains("TEACHER")){
+            dto.setTeacherId(StpUtil.getLoginIdAsLong());
+        }
 
         List<BandingTaskClassPageVo> list = bandingTaskClassService.getList(classDto);
         return RT.ok(list);
     }
 
     @GetMapping(value = "/class-statistics")
-    @ApiOperation(value = "班级数据统计")
+    @ApiOperation(value="班级数据统计")
     @SaCheckPermission("studentreportrecord:detail")
-    @XjrLog(value = "导出")
-    public RT<BandingTaskClassReportStatisticsVo> classStatistics(@Valid Long classId) {
+    @XjrLog(value = "班级数据统计")
+    public RT<BandingTaskClassReportStatisticsVo> classStatistics(@RequestParam Long classId){
         return RT.ok(bandingTaskClassService.getTryReadingReportClassStatistics(classId));
     }
 
     @GetMapping(value = "/statistics")
-    @ApiOperation(value = "领导统计")
+    @ApiOperation(value="领导统计")
     @SaCheckPermission("studentreportrecord:detail")
-    @XjrLog(value = "领导统计")
-    public RT<StudentReportRecordStatisticsVo> statistics(@Valid StudentReportRecordStatisticsDto dto) {
-        if (dto.getGradeId() == null && (dto.getCategory() == null || dto.getCategory() == 1)) {
+    public RT<StudentReportRecordStatisticsVo> statistics(@Valid StudentReportRecordStatisticsDto dto){
+        if(dto.getGradeId() == null && (dto.getCategory() == null || dto.getCategory() == 1)){
             LambdaQueryWrapper<BaseGrade> queryWrapper = new LambdaQueryWrapper<>();
             queryWrapper
                     .orderByDesc(BaseGrade::getTitle)
-                    .select(BaseGrade.class, x -> VoToColumnUtil.fieldsToColumns(BaseGrade.class).contains(x.getProperty()));
+                    .select(BaseGrade.class,x -> VoToColumnUtil.fieldsToColumns(BaseGrade.class).contains(x.getProperty()));
             List<BaseGrade> gradeList = gradeService.list(queryWrapper);
-            if (!gradeList.isEmpty()) {
+            if(!gradeList.isEmpty()){
                 dto.setGradeId(gradeList.get(0).getId());
             }
         }
-        if (dto.getEnrollType() == null || dto.getEnrollType().isEmpty()) {
+        if(dto.getEnrollType() == null || dto.getEnrollType().isEmpty()){
             dto.setEnrollType(EnrollTypeEnum.AUTUMN_ENROLLMENT.getCode());
         }
-        if (dto.getCategory() != null && dto.getCategory() == 2 && dto.getBaseSemesterId() == null) {
+        if(dto.getCategory() != null && dto.getCategory() == 2 && dto.getBaseSemesterId() == null){
             dto.setBaseSemesterId(semesterService.getLastSemester());
         }
 
@@ -266,7 +313,7 @@ public class StudentTryReadingReportController {
                         .eq(EnrollmentPlan::getEnabledMark, EnabledMark.ENABLED.getCode())
                         .orderByDesc(EnrollmentPlan::getId)
         );
-        if (enrollmentPlanList.isEmpty()) {
+        if(enrollmentPlanList.isEmpty()){
             return RT.ok(new StudentReportRecordStatisticsVo());
         }
 
@@ -279,37 +326,37 @@ public class StudentTryReadingReportController {
 
         statisticsVo.setArrivedCount(dataList.stream().filter(x -> x.getReportTime() != null).count());
         statisticsVo.setNotArrivedCount(dataList.stream().filter(x -> x.getReportTime() == null).count());
-        statisticsVo.setArrivedMaleCount(dataList.stream().filter(x -> x.getReportTime() != null && GenderDictionaryEnum.MALE.getCode().equals(x.getGender())).count());
-        statisticsVo.setArrivedFemaleCount(dataList.stream().filter(x -> x.getReportTime() != null && GenderDictionaryEnum.FEMALE.getCode().equals(x.getGender())).count());
+        statisticsVo.setArrivedMaleCount(dataList.stream().filter(x -> x.getReportTime() != null && GenderDictionaryEnum.MALE.getValue().equals(x.getGender())).count());
+        statisticsVo.setArrivedFemaleCount(dataList.stream().filter(x -> x.getReportTime() != null && GenderDictionaryEnum.FEMALE.getValue().equals(x.getGender())).count());
 
         statisticsVo.setStayMaleCount(dataList.stream().filter(
-                x -> GenderDictionaryEnum.MALE.getCode().equals(x.getGender())
+                x -> GenderDictionaryEnum.MALE.getValue().equals(x.getGender())
                         && StudyStatusEnum.InResidence.getCode().equals(x.getStduyStatusCn())
                         && x.getReportTime() != null
         ).count());
         statisticsVo.setStayFemaleCount(dataList.stream().filter(
-                x -> GenderDictionaryEnum.FEMALE.getCode().equals(x.getGender())
+                x -> GenderDictionaryEnum.FEMALE.getValue().equals(x.getGender())
                         && StudyStatusEnum.InResidence.getCode().equals(x.getStduyStatusCn())
                         && x.getReportTime() != null
         ).count());
         statisticsVo.setNotStayMaleCount(dataList.stream().filter(
-                x -> GenderDictionaryEnum.MALE.getCode().equals(x.getGender())
+                x -> GenderDictionaryEnum.MALE.getValue().equals(x.getGender())
                         && StudyStatusEnum.AttendDaySchool.getCode().equals(x.getStduyStatusCn())
                         && x.getReportTime() != null
         ).count());
         statisticsVo.setNotStayFemaleCount(dataList.stream().filter(
-                x -> GenderDictionaryEnum.FEMALE.getCode().equals(x.getGender())
+                x -> GenderDictionaryEnum.FEMALE.getValue().equals(x.getGender())
                         && StudyStatusEnum.AttendDaySchool.getCode().equals(x.getStduyStatusCn())
                         && x.getReportTime() != null
         ).count());
 
-        if (dto.getCategory() != null && dto.getCategory() == 1) {
+        if(dto.getCategory() != null && dto.getCategory() == 3){
             Map<String, List<StudentReportRecordPlanPageVo>> graduatedUniversityMap = dataList.stream().filter(x -> x.getReportTime() != null)
                     .collect(Collectors.groupingBy(StudentReportRecordPlanPageVo::getGraduateSchool));
             List<ItemCountVo> graduatedUniversityList = new ArrayList<>();
             for (String graduatedUniversity : graduatedUniversityMap.keySet()) {
                 graduatedUniversityList.add(
-                        new ItemCountVo() {{
+                        new ItemCountVo(){{
                             setItem(graduatedUniversity);
                             setCount(graduatedUniversityMap.get(graduatedUniversity).size());
                         }}
@@ -320,15 +367,15 @@ public class StudentTryReadingReportController {
 
         Map<String, List<StudentReportRecordPlanPageVo>> classMap = dataList.stream().filter(x -> x.getReportTime() != null)
                 .collect(Collectors.groupingBy(StudentReportRecordPlanPageVo::getClassName));
-        Map<String, List<StudentReportRecordPlanPageVo>> classNotMap = dataList.stream().filter(x -> x.getReportTime() == null)
+        Map<String, List<StudentReportRecordPlanPageVo>> classNotMap = dataList.stream().filter(x -> x.getReportTime() == null && x.getClassName() != null)
                 .collect(Collectors.groupingBy(StudentReportRecordPlanPageVo::getClassName));
         List<StudentReportRecordItemVo> classList = new ArrayList<>();
         for (String className : classMap.keySet()) {
             classList.add(
-                    new StudentReportRecordItemVo() {{
+                    new StudentReportRecordItemVo(){{
                         setItem(className);
                         setCount(classMap.get(className).size());
-                        if (classNotMap.get(className) != null && !(classNotMap.get(className).isEmpty())) {
+                        if(classNotMap.get(className) != null && !(classNotMap.get(className).isEmpty())){
                             setCount2(classNotMap.get(className).size());
                         }
                     }}
@@ -337,14 +384,15 @@ public class StudentTryReadingReportController {
         statisticsVo.setClassList(classList);
 
         Map<String, List<StudentReportRecordPlanPageVo>> classTypeMap = dataList.stream().filter(x -> x.getReportTime() != null).collect(Collectors.groupingBy(StudentReportRecordPlanPageVo::getClassType));
-        Map<String, List<StudentReportRecordPlanPageVo>> classTypeNotMap = dataList.stream().filter(x -> x.getReportTime() == null).collect(Collectors.groupingBy(StudentReportRecordPlanPageVo::getClassType));
+        Map<String, List<StudentReportRecordPlanPageVo>> classTypeNotMap = dataList.stream().filter(x -> x.getReportTime() == null && x.getClassType() != null)
+                .collect(Collectors.groupingBy(StudentReportRecordPlanPageVo::getClassType));
         List<StudentReportRecordItemVo> classTypeList = new ArrayList<>();
         for (String classType : classTypeMap.keySet()) {
             classTypeList.add(
-                    new StudentReportRecordItemVo() {{
+                    new StudentReportRecordItemVo(){{
                         setItem(classType);
                         setCount(classTypeMap.get(classType).size());
-                        if (classTypeNotMap.get(classType) != null && !(classTypeNotMap.get(classType).isEmpty())) {
+                        if(classTypeNotMap.get(classType) != null && !(classTypeNotMap.get(classType).isEmpty())){
                             setCount2(classTypeNotMap.get(classType).size());
                         }
                     }}
@@ -357,10 +405,10 @@ public class StudentTryReadingReportController {
         List<StudentReportRecordItemVo> majorList = new ArrayList<>();
         for (String majorName : majorMap.keySet()) {
             majorList.add(
-                    new StudentReportRecordItemVo() {{
+                    new StudentReportRecordItemVo(){{
                         setItem(majorName);
                         setCount(majorMap.get(majorName).size());
-                        if (majorNotMap.get(majorName) != null && !(majorNotMap.get(majorName).isEmpty())) {
+                        if(majorNotMap.get(majorName) != null && !(majorNotMap.get(majorName).isEmpty())){
                             setCount2(majorNotMap.get(majorName).size());
                         }
                     }}
@@ -372,7 +420,7 @@ public class StudentTryReadingReportController {
         List<ItemCountVo> deptList = new ArrayList<>();
         for (String deptName : deptMap.keySet()) {
             deptList.add(
-                    new ItemCountVo() {{
+                    new ItemCountVo(){{
                         setItem(deptName);
                         setCount(deptMap.get(deptName).size());
                     }}
@@ -381,10 +429,45 @@ public class StudentTryReadingReportController {
         statisticsVo.setDeptList(deptList);
 
         BigDecimal divide = BigDecimal.ZERO;
-        if (statisticsVo.getAllCount() != 0) {
+        if( statisticsVo.getAllCount() != 0){
             divide = BigDecimal.valueOf(statisticsVo.getArrivedCount()).divide(BigDecimal.valueOf(statisticsVo.getAllCount()), 4, RoundingMode.HALF_UP);
         }
         statisticsVo.setReportRate(divide.doubleValue());
+
+        //查询年级趋势
+        List<BaseGrade> gradeList = gradeService.list(
+                new QueryWrapper<BaseGrade>().lambda()
+                        .eq(BaseGrade::getDeleteMark, DeleteMark.NODELETE.getCode())
+                        .eq(BaseGrade::getEnabledMark, EnabledMark.ENABLED.getCode())
+                        .eq(BaseGrade::getStatus, 1)
+                        .orderByDesc(BaseGrade::getTitle)
+        );
+        List<ItemCountVo> gradeDataList = new ArrayList<>();
+        for (int i = 0; i < 3; i ++){
+            BaseGrade baseGrade = gradeList.get(i);
+
+            List<EnrollmentPlan> enrollmentPlans = enrollmentPlanService.list(
+                    new QueryWrapper<EnrollmentPlan>().lambda()
+                            .eq(EnrollmentPlan::getGradeId, baseGrade.getId())
+                            .eq(EnrollmentPlan::getDeleteMark, DeleteMark.NODELETE.getCode())
+                            .eq(EnrollmentPlan::getEnabledMark, EnabledMark.ENABLED.getCode())
+                            .orderByDesc(EnrollmentPlan::getId)
+            );
+            int gradeCount = 0;
+            for (EnrollmentPlan enrollmentPlan : enrollmentPlans) {
+                StudentTryReadingReportPageDto gradeRecordPageDto = new StudentTryReadingReportPageDto();
+                gradeRecordPageDto.setEnrollmentPlanId(enrollmentPlan.getId());
+                gradeRecordPageDto.setIsReport(1);
+                gradeCount += recordService.getTryReadingList(gradeRecordPageDto).size();
+            }
+            ItemCountVo itemCountVo = new ItemCountVo();
+            itemCountVo.setItem(baseGrade.getName());
+            itemCountVo.setCount(gradeCount);
+            gradeDataList.add(itemCountVo);
+        }
+
+        statisticsVo.setGradeList(gradeDataList);
+
         return RT.ok(statisticsVo);
     }
 

+ 18 - 0
src/main/java/com/xjrsoft/module/student/dto/BaseNewStudentPageDto.java

@@ -77,4 +77,22 @@ public class BaseNewStudentPageDto extends PageInput {
 
     @ApiModelProperty("学生来源")
     private String source;
+
+    @ApiModelProperty("是否可以分班(0:否,1:是)")
+    private Integer isCanBanding;
+
+    @ApiModelProperty("分班类型(1:自动分班 2:手动分班)")
+    private Integer operateMode;
+
+    @ApiModelProperty("缴费状态(已缴费、未缴费)")
+    private String paymnystate;
+
+    @ApiModelProperty("应届生、往届生")
+    private String previous;
+
+    @ApiModelProperty("户籍所在地")
+    private String city;
+
+    @ApiModelProperty("班主任")
+    private String teacherName;
 }

+ 24 - 0
src/main/java/com/xjrsoft/module/student/dto/StudentReportChangeClassBatchDto.java

@@ -0,0 +1,24 @@
+package com.xjrsoft.module.student.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+
+/**
+* @title: 学生报到计划分页查询入参
+* @Author dzx
+* @Date: 2025-01-21
+* @Version 1.0
+*/
+@Data
+public class StudentReportChangeClassBatchDto {
+
+    @ApiModelProperty("主键ids")
+    private List<Long> ids;
+
+
+    @ApiModelProperty("班级id")
+    private Long classId;
+}

+ 2 - 0
src/main/java/com/xjrsoft/module/student/service/IBaseStudentSchoolRollService.java

@@ -60,4 +60,6 @@ public interface IBaseStudentSchoolRollService extends MPJBaseService<BaseStuden
     Boolean activateStudent(Long userId);
 
     Boolean disableStudent(Long userId);
+
+    Boolean disableStudent(Long userId, Long modifyUserId);
 }

+ 16 - 5
src/main/java/com/xjrsoft/module/student/service/IStudentReportRecordService.java

@@ -2,6 +2,8 @@ package com.xjrsoft.module.student.service;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.base.MPJBaseService;
+import com.xjrsoft.module.banding.dto.ChangeClassDto;
+import com.xjrsoft.module.student.dto.StudentReportChangeClassBatchDto;
 import com.xjrsoft.module.student.dto.StudentReportRecordPageDto;
 import com.xjrsoft.module.student.dto.StudentReportRecordStatisticsDto;
 import com.xjrsoft.module.student.dto.StudentReportSignDto;
@@ -11,15 +13,16 @@ import com.xjrsoft.module.student.vo.StudentReportRecordPageVo;
 import com.xjrsoft.module.student.vo.StudentReportRecordPlanPageVo;
 import com.xjrsoft.module.student.vo.StudentReportRecordStatisticsListVo;
 import com.xjrsoft.module.student.vo.StudentReportRecordStatisticsVo;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
 /**
- * @title: 学生报到记录表
- * @Author dzx
- * @Date: 2024-08-28
- * @Version 1.0
- */
+* @title: 学生报到记录表
+* @Author dzx
+* @Date: 2024-08-28
+* @Version 1.0
+*/
 
 public interface IStudentReportRecordService extends MPJBaseService<StudentReportRecord> {
 
@@ -54,5 +57,13 @@ public interface IStudentReportRecordService extends MPJBaseService<StudentRepor
 
     Boolean tryReadingSign(StudentReportSignDto dto);
 
+    /**
+     * 试读报到或者新生报到调整班级
+     */
     Boolean changeClass(StudentReportSignDto dto);
+
+    /**
+     * 试读报到或者新生报到批量调整班级
+     */
+    Boolean changeClassBatch(StudentReportChangeClassBatchDto dto);
 }

+ 18 - 8
src/main/java/com/xjrsoft/module/student/service/impl/BaseStudentSchoolRollServiceImpl.java

@@ -3,6 +3,7 @@ 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.xjrsoft.common.enums.*;
@@ -300,6 +301,12 @@ public class BaseStudentSchoolRollServiceImpl extends MPJBaseServiceImpl<BaseStu
         return true;
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean disableStudent(Long userId) {
+        return disableStudent(userId, StpUtil.getLoginIdAsLong());
+    }
+
     /**
      * 禁用学生
      *
@@ -308,12 +315,12 @@ public class BaseStudentSchoolRollServiceImpl extends MPJBaseServiceImpl<BaseStu
      */
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public Boolean disableStudent(Long userId) {
+    public Boolean disableStudent(Long userId, Long modifyUserId) {
         //激活用户信息
         User user = userMapper.selectById(userId);
         user.setDeleteMark(DeleteMark.DELETED.getCode());
         user.setEnabledMark(EnabledMark.DISABLED.getCode());
-        user.setModifyUserId(StpUtil.getLoginIdAsLong());
+        user.setModifyUserId(modifyUserId);
         user.setModifyDate(LocalDateTime.now());
         userMapper.updateById(user);
 
@@ -322,11 +329,14 @@ public class BaseStudentSchoolRollServiceImpl extends MPJBaseServiceImpl<BaseStu
                 new QueryWrapper<BaseStudentSchoolRoll>().lambda()
                         .eq(BaseStudentSchoolRoll::getUserId, userId)
         );
-        schoolRoll.setDeleteMark(DeleteMark.DELETED.getCode());
-        schoolRoll.setEnabledMark(EnabledMark.DISABLED.getCode());
-        schoolRoll.setModifyUserId(StpUtil.getLoginIdAsLong());
-        schoolRoll.setModifyDate(LocalDateTime.now());
-        this.updateById(schoolRoll);
+        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(
@@ -334,7 +344,7 @@ public class BaseStudentSchoolRollServiceImpl extends MPJBaseServiceImpl<BaseStu
                         .eq(BaseStudent::getUserId, userId)
         );
         baseStudent.setIsNormal(0);
-        baseStudent.setModifyUserId(StpUtil.getLoginIdAsLong());
+        baseStudent.setModifyUserId(modifyUserId);
         baseStudent.setModifyDate(LocalDateTime.now());
         baseStudentMapper.updateById(baseStudent);
 

+ 29 - 22
src/main/java/com/xjrsoft/module/student/service/impl/StudentChangeRecordServiceImpl.java

@@ -4,7 +4,14 @@ import cn.dev33.satoken.stp.StpUtil;
 import cn.hutool.db.Entity;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.base.MPJBaseServiceImpl;
-import com.xjrsoft.common.enums.*;
+import com.xjrsoft.common.enums.ArchivesStatusEnum;
+import com.xjrsoft.common.enums.DeleteMark;
+import com.xjrsoft.common.enums.EnabledMark;
+import com.xjrsoft.common.enums.RollModalityEnum;
+import com.xjrsoft.common.enums.RoomApplicantTypeEnum;
+import com.xjrsoft.common.enums.StudentChangeTypeEnum;
+import com.xjrsoft.common.enums.StudentTypeEnum;
+import com.xjrsoft.common.enums.StudyStatusEnum;
 import com.xjrsoft.common.mybatis.SqlRunnerAdapter;
 import com.xjrsoft.module.base.entity.BaseClass;
 import com.xjrsoft.module.base.service.IBaseClassService;
@@ -25,23 +32,22 @@ import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 
 /**
- * @title: 学生异动记录表
- * @Author dzx
- * @Date: 2025-01-20
- * @Version 1.0
- */
+* @title: 学生异动记录表
+* @Author dzx
+* @Date: 2025-01-20
+* @Version 1.0
+*/
 @Service
 @AllArgsConstructor
 public class StudentChangeRecordServiceImpl extends MPJBaseServiceImpl<StudentChangeRecordMapper, StudentChangeRecord> implements IStudentChangeRecordService {
 
     private final StudentChangeClassMapper studentChangeClassMapper;
     private final IBaseClassService classService;
-
     /**
      * 记录转班异动数据
-     *
      * @param formId 转班流程表的id
      */
     @Override
@@ -106,10 +112,10 @@ public class StudentChangeRecordServiceImpl extends MPJBaseServiceImpl<StudentCh
 
         StudentChangeRecord record = new StudentChangeRecord() {{
 
-            if (RoomApplicantTypeEnum.ToBeBoarder.getCode().equals(wfRoomApplicant.getRecedeType())) {
+            if(RoomApplicantTypeEnum.ToBeBoarder.getCode().equals(wfRoomApplicant.getRecedeType())){
                 setAfterData(StudyStatusEnum.InResidence.getValue());
                 setAfterDataCode(StudyStatusEnum.InResidence.getCode());
-            } else if (RoomApplicantTypeEnum.ToBeDayPupil.getCode().equals(wfRoomApplicant.getRecedeType())) {
+            }else if(RoomApplicantTypeEnum.ToBeDayPupil.getCode().equals(wfRoomApplicant.getRecedeType())){
                 setAfterData(StudyStatusEnum.AttendDaySchool.getValue());
                 setAfterDataCode(StudyStatusEnum.AttendDaySchool.getCode());
             }
@@ -129,14 +135,15 @@ public class StudentChangeRecordServiceImpl extends MPJBaseServiceImpl<StudentCh
     }
 
     /**
-     * @param beforeData     变更之前的数据
+     *
+     * @param beforeData 变更之前的数据
      * @param beforeDataCode 变更之前的数据code
-     * @param afterData      变更之后的数据
-     * @param afterDataCode  变更之后的数据code
-     * @param userId         学生id
-     * @param createUserId   操作人id
-     * @param changeType     变更类型
-     * @param operateMode    操作方式
+     * @param afterData 变更之后的数据
+     * @param afterDataCode 变更之后的数据code
+     * @param userId 学生id
+     * @param createUserId 操作人id
+     * @param changeType 变更类型
+     * @param operateMode 操作方式
      */
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -166,7 +173,7 @@ public class StudentChangeRecordServiceImpl extends MPJBaseServiceImpl<StudentCh
     @Override
     public Boolean insertDataByStudentUpdate(BaseStudentSchoolRoll beforeRoll, BaseStudentSchoolRoll afterRoll) {
         List<StudentChangeRecord> insertList = new ArrayList<>();
-        if (!beforeRoll.getClassId().equals(afterRoll.getClassId())) {
+        if(!Objects.equals(beforeRoll.getClassId(), afterRoll.getClassId())){
             BaseClass afterClass = classService.getById(afterRoll.getClassId());
             BaseClass beforeClass = classService.getById(beforeRoll.getClassId());
 
@@ -186,7 +193,7 @@ public class StudentChangeRecordServiceImpl extends MPJBaseServiceImpl<StudentCh
             insertList.add(record);
         }
 
-        if (!beforeRoll.getArchivesStatus().equals(afterRoll.getArchivesStatus())) {
+        if(!Objects.equals(beforeRoll.getArchivesStatus(), afterRoll.getArchivesStatus())){
             StudentChangeRecord record = new StudentChangeRecord() {{
                 setAfterData(ArchivesStatusEnum.fromCode(afterRoll.getArchivesStatus()));
                 setAfterDataCode(afterRoll.getArchivesStatus());
@@ -202,7 +209,7 @@ public class StudentChangeRecordServiceImpl extends MPJBaseServiceImpl<StudentCh
             }};
             insertList.add(record);
         }
-        if (!beforeRoll.getStudentType().equals(afterRoll.getStudentType())) {
+        if(!Objects.equals(beforeRoll.getStudentType(), afterRoll.getStudentType())){
             StudentChangeRecord record = new StudentChangeRecord() {{
                 setAfterData(StudentTypeEnum.fromCode(afterRoll.getStudentType()));
                 setAfterDataCode(afterRoll.getStudentType());
@@ -219,7 +226,7 @@ public class StudentChangeRecordServiceImpl extends MPJBaseServiceImpl<StudentCh
             insertList.add(record);
         }
 
-        if (!beforeRoll.getStduyStatus().equals(afterRoll.getStduyStatus())) {
+        if(!Objects.equals(beforeRoll.getStduyStatus(), afterRoll.getStduyStatus())){
             StudentChangeRecord record = new StudentChangeRecord() {{
                 setAfterData(StudyStatusEnum.fromCode(afterRoll.getStduyStatus()));
                 setAfterDataCode(afterRoll.getStduyStatus());
@@ -236,7 +243,7 @@ public class StudentChangeRecordServiceImpl extends MPJBaseServiceImpl<StudentCh
             insertList.add(record);
         }
 
-        if (!beforeRoll.getLearnStatus().equals(afterRoll.getLearnStatus())) {
+        if(!Objects.equals(beforeRoll.getLearnStatus(), afterRoll.getLearnStatus())){
             StudentChangeRecord record = new StudentChangeRecord() {{
                 setAfterData(RollModalityEnum.fromCode(afterRoll.getLearnStatus()));
                 setAfterDataCode(afterRoll.getLearnStatus());

+ 145 - 65
src/main/java/com/xjrsoft/module/student/service/impl/StudentReportRecordServiceImpl.java

@@ -2,6 +2,8 @@ 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.util.NumberUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -9,32 +11,52 @@ 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.enums.ArchivesStatusEnum;
+import com.xjrsoft.common.enums.DeleteMark;
+import com.xjrsoft.common.enums.EnabledMark;
+import com.xjrsoft.common.enums.RoleEnum;
+import com.xjrsoft.common.enums.StudentChangeTypeEnum;
+import com.xjrsoft.common.enums.StudyStatusEnum;
 import com.xjrsoft.common.exception.MyException;
+import com.xjrsoft.common.utils.LocalDateTimeUtil;
 import com.xjrsoft.common.utils.LocalDateUtil;
 import com.xjrsoft.common.utils.RedisUtil;
 import com.xjrsoft.common.utils.VoToColumnUtil;
 import com.xjrsoft.config.CommonPropertiesConfig;
+import com.xjrsoft.module.banding.entity.BandingTask;
 import com.xjrsoft.module.banding.entity.BandingTaskClass;
 import com.xjrsoft.module.banding.entity.BandingTaskClassStudent;
 import com.xjrsoft.module.banding.service.IBandingTaskClassService;
 import com.xjrsoft.module.banding.service.IBandingTaskClassStudentService;
+import com.xjrsoft.module.banding.service.IBandingTaskService;
 import com.xjrsoft.module.base.entity.BaseClass;
+import com.xjrsoft.module.base.entity.BaseGrade;
 import com.xjrsoft.module.base.mapper.BaseClassMapper;
+import com.xjrsoft.module.base.mapper.BaseGradeMapper;
 import com.xjrsoft.module.organization.dto.GetUserByParamDto;
 import com.xjrsoft.module.organization.entity.User;
 import com.xjrsoft.module.organization.entity.UserRoleRelation;
 import com.xjrsoft.module.organization.service.IUserRoleRelationService;
 import com.xjrsoft.module.organization.service.IUserService;
+import com.xjrsoft.module.student.dto.StudentReportChangeClassBatchDto;
 import com.xjrsoft.module.student.dto.StudentReportRecordPageDto;
 import com.xjrsoft.module.student.dto.StudentReportRecordStatisticsDto;
 import com.xjrsoft.module.student.dto.StudentReportSignDto;
 import com.xjrsoft.module.student.dto.StudentTryReadingReportPageDto;
-import com.xjrsoft.module.student.entity.*;
+import com.xjrsoft.module.student.entity.BaseNewStudent;
+import com.xjrsoft.module.student.entity.BaseStudent;
+import com.xjrsoft.module.student.entity.BaseStudentFamily;
+import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
+import com.xjrsoft.module.student.entity.StudentReportPlan;
+import com.xjrsoft.module.student.entity.StudentReportRecord;
 import com.xjrsoft.module.student.mapper.BaseNewStudentMapper;
 import com.xjrsoft.module.student.mapper.StudentReportPlanMapper;
 import com.xjrsoft.module.student.mapper.StudentReportRecordMapper;
-import com.xjrsoft.module.student.service.*;
+import com.xjrsoft.module.student.service.IBaseStudentFamilyService;
+import com.xjrsoft.module.student.service.IBaseStudentSchoolRollService;
+import com.xjrsoft.module.student.service.IBaseStudentService;
+import com.xjrsoft.module.student.service.IStudentChangeRecordService;
+import com.xjrsoft.module.student.service.IStudentReportRecordService;
 import com.xjrsoft.module.student.vo.StudentReportRecordPageVo;
 import com.xjrsoft.module.student.vo.StudentReportRecordPlanPageVo;
 import com.xjrsoft.module.student.vo.StudentReportRecordStatisticsListVo;
@@ -47,16 +69,19 @@ import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.Date;
 import java.util.List;
 import java.util.concurrent.CompletableFuture;
+import java.util.stream.Collectors;
 
 /**
- * @title: 学生报到记录表
- * @Author dzx
- * @Date: 2024-08-28
- * @Version 1.0
- */
+* @title: 学生报到记录表
+* @Author dzx
+* @Date: 2024-08-28
+* @Version 1.0
+*/
 @Service
 @AllArgsConstructor
 public class StudentReportRecordServiceImpl extends MPJBaseServiceImpl<StudentReportRecordMapper, StudentReportRecord> implements IStudentReportRecordService {
@@ -74,6 +99,8 @@ public class StudentReportRecordServiceImpl extends MPJBaseServiceImpl<StudentRe
     private final RedisUtil redisUtil;
     private final IBandingTaskClassStudentService taskClassStudentService;
     private final IBandingTaskClassService taskClassService;
+    private final IBandingTaskService taskService;
+    private final BaseGradeMapper gradeMapper;
 
 
     @Override
@@ -84,13 +111,13 @@ public class StudentReportRecordServiceImpl extends MPJBaseServiceImpl<StudentRe
     @Override
     public List<StudentReportRecordStatisticsListVo> getStatisticsDataList(StudentReportRecordStatisticsDto dto) {
         List<StudentReportRecordStatisticsListVo> resultList;
-        if (dto.getCategory() != null && dto.getCategory() == 1) {
+        if(dto.getCategory() != null && dto.getCategory() == 1){
             resultList = this.baseMapper.getStatisticsDataList(dto);
-        } else if (dto.getCategory() != null && dto.getCategory() == 2) {
+        }else if(dto.getCategory() != null && dto.getCategory() == 2){
             resultList = this.baseMapper.getStatisticsPlanDataList(dto);
-        } else if (dto.getCategory() != null && dto.getCategory() == 3) {
+        }else if(dto.getCategory() != null && dto.getCategory() == 3){
             resultList = this.baseMapper.getStatisticsDataList(dto);
-        } else {
+        }else{
             resultList = this.baseMapper.getStatisticsDataList(dto);
         }
         return resultList;
@@ -99,7 +126,7 @@ public class StudentReportRecordServiceImpl extends MPJBaseServiceImpl<StudentRe
     @Override
     public Boolean removeByUserId(List<Long> ids) {
         this.baseMapper.delete(
-                new QueryWrapper<StudentReportRecord>().lambda().in(StudentReportRecord::getUserId, ids)
+            new QueryWrapper<StudentReportRecord>().lambda().in(StudentReportRecord::getUserId, ids)
         );
         return true;
     }
@@ -111,7 +138,6 @@ public class StudentReportRecordServiceImpl extends MPJBaseServiceImpl<StudentRe
 
     /**
      * 签到,签到后,修改学生的状态信息
-     *
      * @param dto
      * @return
      */
@@ -121,7 +147,7 @@ public class StudentReportRecordServiceImpl extends MPJBaseServiceImpl<StudentRe
         StudentReportRecord record = this.getById(dto.getId());
         record.setModifyDate(new Date());
         record.setModifyUserId(StpUtil.getLoginIdAsLong());
-        if (record.getReportTime() != null) {
+        if(record.getReportTime() != null){
             UpdateWrapper<StudentReportRecord> updateWrapper = new UpdateWrapper<>();
             updateWrapper.eq("id", dto.getId());
             updateWrapper.setSql("report_time = null");
@@ -140,7 +166,7 @@ public class StudentReportRecordServiceImpl extends MPJBaseServiceImpl<StudentRe
             userService.updateById(user);
 
 
-        } else {
+        }else{
             record.setReportTime(new Date());
             this.updateById(record);
 
@@ -201,7 +227,7 @@ public class StudentReportRecordServiceImpl extends MPJBaseServiceImpl<StudentRe
         LocalDate now = LocalDate.now();
         StudentReportRecord record = this.getById(dto.getId());
         StudentReportPlan reportPlan = planMapper.selectById(record.getStudentReportPlanId());
-        if (!LocalDateUtil.isDateInRange(now, reportPlan.getUpdateStartTime(), reportPlan.getUpdateEndTime())) {
+        if(!LocalDateUtil.isDateInRange(now, reportPlan.getUpdateStartTime(), reportPlan.getUpdateEndTime())){
             throw new MyException("不在修改时间内,无法修改");
         }
 
@@ -216,9 +242,9 @@ public class StudentReportRecordServiceImpl extends MPJBaseServiceImpl<StudentRe
         String beforeData = StudyStatusEnum.fromCode(beforeDataCode);
 
 
-        if (StudyStatusEnum.InResidence.getCode().equals(roll.getStduyStatus())) {
+        if(StudyStatusEnum.InResidence.getCode().equals(roll.getStduyStatus())){
             roll.setStduyStatus(StudyStatusEnum.AttendDaySchool.getCode());
-        } else if (StudyStatusEnum.AttendDaySchool.getCode().equals(roll.getStduyStatus())) {
+        }else if(StudyStatusEnum.AttendDaySchool.getCode().equals(roll.getStduyStatus())){
             roll.setStduyStatus(StudyStatusEnum.InResidence.getCode());
         }
         rollService.updateById(roll);
@@ -227,8 +253,8 @@ public class StudentReportRecordServiceImpl extends MPJBaseServiceImpl<StudentRe
         String afterData = StudyStatusEnum.fromCode(afterDataCode);
 
         changeRecordService.insertData(
-                beforeDataCode, beforeData,
-                afterDataCode, afterData,
+                beforeDataCode,beforeData,
+                afterDataCode,afterData,
                 roll.getUserId(), StpUtil.getLoginIdAsLong(),
                 StudentChangeTypeEnum.StduyStatus.getCode(), 3
         );
@@ -246,14 +272,14 @@ public class StudentReportRecordServiceImpl extends MPJBaseServiceImpl<StudentRe
         LocalDate now = LocalDate.now();
         StudentReportRecord record = this.getById(dto.getId());
         StudentReportPlan reportPlan = planMapper.selectById(record.getStudentReportPlanId());
-        if (!LocalDateUtil.isDateInRange(now, reportPlan.getUpdateStartTime(), reportPlan.getUpdateEndTime())) {
+        if(!LocalDateUtil.isDateInRange(now, reportPlan.getUpdateStartTime(), reportPlan.getUpdateEndTime())){
             throw new MyException("不在修改时间内,无法修改");
         }
         BaseNewStudent student = newStudentMapper.selectById(record.getUserId());
 
-        if (StudyStatusEnum.InResidence.getCode().equals(student.getStduyStatus())) {
+        if(StudyStatusEnum.InResidence.getCode().equals(student.getStduyStatus())){
             student.setStduyStatus(StudyStatusEnum.AttendDaySchool.getCode());
-        } else if (StudyStatusEnum.AttendDaySchool.getCode().equals(student.getStduyStatus())) {
+        }else if(StudyStatusEnum.AttendDaySchool.getCode().equals(student.getStduyStatus())){
             student.setStduyStatus(StudyStatusEnum.InResidence.getCode());
         }
         newStudentMapper.updateById(student);
@@ -262,7 +288,7 @@ public class StudentReportRecordServiceImpl extends MPJBaseServiceImpl<StudentRe
             setCredentialNumber(student.getCredentialNumber());
         }});
 
-        if (record.getReportTime() != null) {
+        if(record.getReportTime() != null && user != null){
 
             BaseStudentSchoolRoll roll = rollService.getOne(
                     new QueryWrapper<BaseStudentSchoolRoll>().lambda()
@@ -290,7 +316,6 @@ public class StudentReportRecordServiceImpl extends MPJBaseServiceImpl<StudentRe
 
     /**
      * 试读报到
-     *
      * @param dto
      * @return
      */
@@ -298,40 +323,72 @@ public class StudentReportRecordServiceImpl extends MPJBaseServiceImpl<StudentRe
     @Transactional(rollbackFor = Exception.class)
     public Boolean tryReadingSign(StudentReportSignDto dto) {
         StudentReportRecord record = this.getById(dto.getId());
+        LocalDateTime now = LocalDateTime.now();
+        StudentReportPlan reportPlan = planMapper.selectById(record.getStudentReportPlanId());
+        if(!LocalDateTimeUtil.isDateTimeInRange(now, reportPlan.getStartTime(), reportPlan.getEndTime())){
+            throw new MyException("不在修改时间内,无法修改");
+        }
+
         BaseNewStudent student = newStudentMapper.selectById(record.getUserId());
-        if (record.getReportTime() == null) {
+        if(record.getReportTime() == null){
             record.setReportTime(new Date());
             record.setModifyUserId(StpUtil.getLoginIdAsLong());
             record.setModifyDate(new Date());
             this.updateById(record);
-
-            //先查询是否已经存在这个班级,如果存在就更新,不存在就新增
-            BaseClass baseClass = classMapper.selectOne(
-                    new MPJLambdaWrapper<BaseClass>()
-                            .select(BaseClass::getId)
-                            .select(BaseClass.class, x -> VoToColumnUtil.fieldsToColumns(BaseClass.class).contains(x.getProperty()))
-                            .innerJoin(BandingTaskClass.class, BandingTaskClass::getName, BaseClass::getName)
+            BandingTaskClass taskClass = taskClassService.getOne(
+                    new MPJLambdaWrapper<BandingTaskClass>()
+                            .select(BandingTaskClass::getId)
+                            .select(BandingTaskClass.class, x -> VoToColumnUtil.fieldsToColumns(BandingTaskClass.class).contains(x.getProperty()))
                             .innerJoin(BandingTaskClassStudent.class, BandingTaskClassStudent::getBandingTaskClassId, BandingTaskClass::getId)
                             .eq(BandingTaskClassStudent::getNewStudentId, student.getId())
                             .eq(BandingTaskClassStudent::getDeleteMark, DeleteMark.NODELETE.getCode())
                             .eq(BandingTaskClassStudent::getEnabledMark, EnabledMark.ENABLED.getCode())
                             .eq(BandingTaskClass::getDeleteMark, DeleteMark.NODELETE.getCode())
                             .eq(BandingTaskClass::getEnabledMark, EnabledMark.ENABLED.getCode())
-                            .eq(BaseClass::getDeleteMark, DeleteMark.NODELETE.getCode())
-                            .eq(BaseClass::getEnabledMark, EnabledMark.ENABLED.getCode())
             );
+
+            //先查询是否已经存在这个班级,如果存在就更新,不存在就新增
+            BaseClass baseClass = classMapper.selectById(taskClass.getBaseClassId());
+            if(baseClass == null){
+                BandingTask task = taskService.getById(taskClass.getBandingTaskId());
+                List<BaseClass> classList = classMapper.selectList(
+                        new QueryWrapper<BaseClass>().lambda()
+                                .eq(BaseClass::getDeleteMark, DeleteMark.NODELETE.getCode())
+                                .eq(BaseClass::getGradeId, task.getGradeId())
+                                .eq(BaseClass::getEnrollType, task.getEnrollType())
+                );
+                BaseGrade baseGrade = gradeMapper.selectById(task.getGradeId());
+                List<BaseClass> classCodes = classList.stream().filter(x -> x.getCode() != null).collect(Collectors.toList());
+                Collections.sort(classCodes, Comparator.comparing(BaseClass::getCode));
+                String classCode = null;
+                if(!classCodes.isEmpty()){
+                    classCode = classCodes.get(0).getCode();
+                }
+
+                baseClass = new BaseClass();
+                BeanUtil.copyProperties(taskClass, baseClass);
+                baseClass.setCreateDate(new Date());
+                baseClass.setCreateUserId(StpUtil.getLoginIdAsLong());
+                int i = 0;
+                if(NumberUtil.isNumber(classCode)){
+                    i = Integer.parseInt(classCode.trim().substring(classCode.length() - 3));
+                    i ++;
+                    baseClass.setCode(baseGrade.getTitle().replace("年", "") + String.format("%03d", i));
+                }
+
+                classMapper.insert(baseClass);
+            }
             //根据身份证号查询这个学生是否存在
             User user = userService.getOne(
                     new QueryWrapper<User>().lambda()
                             .eq(User::getCredentialNumber, student.getCredentialNumber())
             );
-            if (user != null) {
+            if(user != null){
                 //学生已存在,则修改班级信息
                 rollService.updateStudentClass(baseClass.getId(), user.getId());
                 rollService.activateStudent(user.getId());
-            } else {
+            }else{
                 LocalDate birthDate = getBirthDate(student.getCredentialNumber());
-                LocalDateTime now = LocalDateTime.now();
                 User xjrUser = new User() {{
                     setCreateDate(now);
                     setPassword(BCrypt.hashpw(propertiesConfig.getDefaultPassword(), BCrypt.gensalt()));
@@ -357,31 +414,31 @@ public class StudentReportRecordServiceImpl extends MPJBaseServiceImpl<StudentRe
                     setUserId(xjrUser.getId());
                     setCreateDate(now);
                     setStudentId(student.getCredentialNumber());
-                    if (student.getHeight() != null) {
+                    if(student.getHeight() != null){
                         setHeight(student.getHeight().doubleValue());
                     }
-                    if (student.getWeight() != null) {
+                    if(student.getWeight() != null){
                         setWeight(student.getWeight().doubleValue());
                     }
                 }};
                 studentService.save(baseStudent);
 
-                BaseStudentSchoolRoll schoolRoll = new BaseStudentSchoolRoll() {{
-                    setUserId(xjrUser.getId());
-                    if (student.getScore() != null) {
-                        setGraduatedScore(student.getScore().doubleValue());
-                    }
+                BaseStudentSchoolRoll schoolRoll = new BaseStudentSchoolRoll();
+                schoolRoll.setUserId(xjrUser.getId());
+                if(student.getScore() != null){
+                    schoolRoll.setGraduatedScore(student.getScore().doubleValue());
+                }
+
+                schoolRoll.setGraduatedUniversity(student.getGraduateSchool());
+                schoolRoll.setClassId(baseClass.getId());
+                schoolRoll.setMajorSetId(baseClass.getMajorSetId());
+                schoolRoll.setStduyStatus(student.getStduyStatus());
+                schoolRoll.setEnrollType(baseClass.getEnrollType());
+                schoolRoll.setStudentSource(student.getSource());
+                schoolRoll.setGradeId(baseClass.getGradeId());
+                schoolRoll.setArchivesStatus(ArchivesStatusEnum.FB2901.getCode());
+                schoolRoll.setCreateDate(now);
 
-                    setGraduatedUniversity(student.getGraduateSchool());
-                    setClassId(baseClass.getId());
-                    setMajorSetId(baseClass.getMajorSetId());
-                    setStduyStatus(student.getStduyStatus());
-                    setEnrollType(baseClass.getEnrollType());
-                    setStudentSource(student.getSource());
-                    setGradeId(baseClass.getGradeId());
-                    setArchivesStatus(ArchivesStatusEnum.FB2901.getCode());
-                    setCreateDate(now);
-                }};
                 rollService.save(schoolRoll);
 
                 BaseStudentFamily studentFamily = new BaseStudentFamily() {{
@@ -400,7 +457,7 @@ public class StudentReportRecordServiceImpl extends MPJBaseServiceImpl<StudentRe
                     redisUtil.set(GlobalConstant.USER_ROLE_RELATION_CACHE_KEY, userRoleRelationList);
                 });
             }
-        } else {
+        }else{
             UpdateWrapper<StudentReportRecord> wrapper = new UpdateWrapper<>();
             wrapper.eq("id", record.getId());
             wrapper.setSql("report_time = null");
@@ -418,19 +475,18 @@ public class StudentReportRecordServiceImpl extends MPJBaseServiceImpl<StudentRe
 
     /**
      * 试读报到/新生报到调整班级,
-     *
      * @param dto
      * @return
      */
     @Override
-    @Transactional(rollbackFor = Exception.class)
+        @Transactional(rollbackFor = Exception.class)
     public Boolean changeClass(StudentReportSignDto dto) {
         StudentReportRecord record = this.getById(dto.getId());
         record.setReportTime(new Date());
         this.updateById(record);
 
         BaseNewStudent student = newStudentMapper.selectById(record.getUserId());
-        if (student == null) {
+        if(student == null){
             throw new MyException("未能找到该学生");
         }
         //找到后,先清除该学生原来的新生班级
@@ -441,7 +497,7 @@ public class StudentReportRecordServiceImpl extends MPJBaseServiceImpl<StudentRe
 
         //绑定到新的班级上
         taskClassStudentService.save(
-                new BandingTaskClassStudent() {{
+                new BandingTaskClassStudent(){{
                     setNewStudentId(student.getId());
                     setCreateDate(new Date());
                     setCreateUserId(StpUtil.getLoginIdAsLong());
@@ -452,7 +508,7 @@ public class StudentReportRecordServiceImpl extends MPJBaseServiceImpl<StudentRe
                 }}
         );
         //如果已经报到了,根据身份证号查询是否已经添加到基础心中
-        if (record.getReportTime() != null) {
+        if(record.getReportTime() != null){
             User userByParam = userService.getUserByParam(
                     new GetUserByParamDto() {{
                         setCredentialNumber(student.getCredentialNumber());
@@ -463,7 +519,7 @@ public class StudentReportRecordServiceImpl extends MPJBaseServiceImpl<StudentRe
                     new QueryWrapper<BaseClass>().lambda()
                             .eq(BaseClass::getName, taskClass.getName())
             );
-            if (userByParam != null && baseClass != null) {
+            if(userByParam != null && baseClass != null){
                 rollService.updateStudentClass(baseClass.getId(), userByParam.getId());
                 rollService.activateStudent(userByParam.getId());
             }
@@ -471,7 +527,31 @@ public class StudentReportRecordServiceImpl extends MPJBaseServiceImpl<StudentRe
         return true;
     }
 
-    LocalDate getBirthDate(String idCardNumber) {
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean changeClassBatch(StudentReportChangeClassBatchDto dto) {
+        List<StudentReportRecord> records = this.listByIds(dto.getIds());
+        List<Long> newStudentIds = records.stream().map(StudentReportRecord::getUserId).collect(Collectors.toList());
+        List<BandingTaskClassStudent> classStudents = taskClassStudentService.list(
+                new QueryWrapper<BandingTaskClassStudent>().lambda()
+                        .eq(BandingTaskClassStudent::getDeleteMark, DeleteMark.NODELETE.getCode())
+                        .eq(BandingTaskClassStudent::getEnabledMark, EnabledMark.ENABLED.getCode())
+                        .in(BandingTaskClassStudent::getNewStudentId, newStudentIds)
+        );
+        if(!classStudents.isEmpty()){
+            throw new MyException("选择了已分班的学生,无法调整班级");
+        }
+        for (Long id : dto.getIds()) {
+            this.changeClass(new StudentReportSignDto(){{
+                setId(id);
+                setClassId(dto.getClassId());
+            }});
+        }
+
+        return true;
+    }
+
+    LocalDate getBirthDate(String idCardNumber){
         // 获取出生日期前6位,即yyyyMM
         String birthdayString = idCardNumber.substring(6, 14);
 
@@ -480,7 +560,7 @@ public class StudentReportRecordServiceImpl extends MPJBaseServiceImpl<StudentRe
         try {
             LocalDate parse = LocalDate.parse(birthdayString, formatter);
             return parse;
-        } catch (Exception e) {
+        }catch (Exception e){
             throw new MyException("身份证号填写错误,无法提取出生日期");
         }
     }

+ 3 - 0
src/main/java/com/xjrsoft/module/student/vo/BaseNewStudentPageVo.java

@@ -197,4 +197,7 @@ public class BaseNewStudentPageVo {
 
     @ApiModelProperty("是否可以分班(0:否,1:是)")
     private Integer isCanBanding;
+
+    @ApiModelProperty("分班类型(1:自动分班 2:手动分班)")
+    private Integer operateMode;
 }

+ 3 - 0
src/main/java/com/xjrsoft/module/student/vo/StudentReportRecordStatisticsVo.java

@@ -76,4 +76,7 @@ public class StudentReportRecordStatisticsVo {
     @ApiModelProperty("专业部报到情况")
     private List<ItemCountVo> deptList;
 
+    @ApiModelProperty("年级报到情况")
+    private List<ItemCountVo> gradeList;
+
 }

+ 2 - 2
src/main/resources/application-prod.yml

@@ -6,8 +6,8 @@ spring:
     type: com.alibaba.druid.pool.DruidDataSource
     driver-class-name: com.mysql.cj.jdbc.Driver
     url: jdbc:mysql://219.153.208.35:3306/smart_campus?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&autoReconnect=true&failOverReadOnly=false
-    username: root
-    password: xzNDL3dcx#TyEz^a
+    username: smart_campus
+    password: W2Xk@8QFe3hYR7QZ?-yY
 
 
   redis:

+ 28 - 1
src/main/resources/mapper/student/BaseNewStudentMapper.xml

@@ -7,7 +7,7 @@
         SELECT t1.id,t1.graduate_school,t1.name,t1.gender,t2.name AS gender_cn,t1.credential_number,t1.height,t1.weight,
         t1.score,t1.graduate_class,t1.source,t5.name as source_cn,t1.stduy_status,t3.name AS stduy_status_cn,t1.mobile,t7.name as first_ambition,
         t8.name as second_ambition,t1.is_adjust,t1.status,ifnull(t11.name,t1.delete_reason) AS class_name,t12.name AS teacher_name,
-        t1.paymnystate,t1.userdef6,t1.previous,t1.province,t1.city,t1.myarea,t1.remarks,t1.is_can_banding FROM base_new_student t1
+        t1.paymnystate,t1.userdef6,t1.previous,t1.province,t1.city,t1.myarea,t1.remarks,t1.is_can_banding,t1.operate_mode FROM base_new_student t1
         LEFT JOIN xjr_dictionary_detail t2 ON t1.gender = t2.code AND t2.item_id = 2023000000000000004
         LEFT JOIN xjr_dictionary_detail t3 ON t1.stduy_status = t3.code AND t3.item_id = 2023000000000000030
         LEFT JOIN xjr_dictionary_detail t5 ON t1.source = t5.code AND t5.item_id = 2023000000000000028
@@ -49,6 +49,12 @@
         <if test="dto.gender != null and dto.gender != ''">
             AND t1.gender = #{dto.gender}
         </if>
+        <if test="dto.teacherName != null and dto.teacherName != ''">
+            AND t12.name like concat('%', #{dto.teacherName}, '%')
+        </if>
+        <if test="dto.gender != null and dto.gender != ''">
+            AND t1.gender = #{dto.gender}
+        </if>
         <if test="dto.status != null">
             AND t1.status = #{dto.status}
         </if>
@@ -58,6 +64,27 @@
         <if test="dto.enrollmentPlanId != null">
             AND t1.enrollment_plan_id = #{dto.enrollmentPlanId}
         </if>
+
+        <if test="dto.isCanBanding != null">
+            and t1.is_can_banding = #{dto.isCanBanding}
+        </if>
+        <if test="dto.operateMode != null">
+            and t1.operate_mode = #{dto.operateMode}
+        </if>
+        <if test="dto.paymnystate != null and dto.paymnystate != ''">
+            AND t1.paymnystate = #{dto.paymnystate}
+        </if>
+        <if test="dto.previous != null and dto.previous != ''">
+            AND t1.previous = #{dto.previous}
+        </if>
+        <if test="dto.city != null and dto.city != ''">
+            AND (
+                t1.province like concat('%', #{dto.city}, '%')
+                or t1.city like concat('%', #{dto.city}, '%')
+                or t1.myarea like concat('%', #{dto.city}, '%')
+                )
+        </if>
+
         <if test="dto.treeId != null and dto.treeType != null">
             <if test="dto.treeType == 1">
                 AND t4.grade_id = #{dto.treeId}

+ 3 - 3
src/main/resources/mapper/student/StudentReportRecordMapper.xml

@@ -291,13 +291,13 @@
         <if test="dto.reportTimeStart != null and dto.reportTimeEnd != null">
             and t1.report_time between #{dto.reportTimeStart} and #{dto.reportTimeEnd}
         </if>
-        ORDER BY t1.report_time IS NULL DESC, t1.report_time DESC,t5.name is null desc,t5.name
+        ORDER BY t5.name IS NULL,t5.name DESC,t1.report_time IS NULL DESC, t1.report_time DESC
     </select>
     <select id="getTryReadingList" parameterType="com.xjrsoft.module.student.dto.StudentTryReadingReportPageDto" resultType="com.xjrsoft.module.student.vo.StudentReportRecordPlanPageVo">
         SELECT t1.id, t1.user_id, t4.name AS grade_name,t5.name AS class_name,t6.name AS teacher_name,
         t3.name,t7.name AS gender,t3.credential_number,t3.mobile,t8.name AS student_type_cn,
         t9.name AS stduy_status_cn,t3.gender,t13.name as major_name,t14.name as class_type,
-        t1.report_time,IF(t1.report_time IS NULL, 0, 1) AS is_report,
+        t1.report_time,IF(t1.report_time IS NULL, 0, 1) AS is_report,t3.graduate_school,
         t3.family_mobile AS parent_mobile,t15.name as dept_name
         FROM student_report_record t1
         INNER JOIN base_new_student t3 ON t3.id = t1.user_id
@@ -363,6 +363,6 @@
         <if test="dto.reportTimeStart != null and dto.reportTimeEnd != null">
             and t1.report_time between #{dto.reportTimeStart} and #{dto.reportTimeEnd}
         </if>
-        ORDER BY t1.report_time IS NULL DESC, t1.report_time DESC,t5.name is null desc,t5.name
+        ORDER BY t5.name IS NULL,t5.name DESC,t1.report_time IS NULL DESC, t1.report_time DESC
     </select>
 </mapper>

+ 4 - 0
src/main/resources/sqlScript/20250310_sql.sql

@@ -8,3 +8,7 @@ ALTER TABLE `student_report_plan`
   
 ALTER TABLE `student_report_plan`   
   ADD COLUMN `banding_task_id` BIGINT NULL   COMMENT '分班任务id';
+
+
+ALTER TABLE `banding_task_class`   
+  ADD COLUMN `base_class_id` BIGINT NULL   COMMENT '班级id(base_class)' AFTER `status`;

+ 28 - 88
src/test/java/com/xjrsoft/module/liteflow/node/StudentDropOutNodeTest.java

@@ -3,20 +3,15 @@ package com.xjrsoft.module.liteflow.node;
 import cn.hutool.core.convert.Convert;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
 import com.xjrsoft.common.enums.ArchivesStatusEnum;
 import com.xjrsoft.common.enums.DeleteMark;
+import com.xjrsoft.common.enums.StudentChangeTypeEnum;
 import com.xjrsoft.common.enums.WorkflowApproveType;
-import com.xjrsoft.module.hikvision.entity.HikvisionData;
-import com.xjrsoft.module.hikvision.mapper.HikvisionDataMapper;
-import com.xjrsoft.module.hikvision.util.ApiUtil;
 import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
 import com.xjrsoft.module.student.entity.StudentDropOut;
 import com.xjrsoft.module.student.mapper.StudentDropOutMapper;
 import com.xjrsoft.module.student.service.IBaseStudentSchoolRollService;
+import com.xjrsoft.module.student.service.IStudentChangeRecordService;
 import com.xjrsoft.module.workflow.entity.WorkflowRecord;
 import com.xjrsoft.module.workflow.mapper.WorkflowRecordMapper;
 import com.xjrsoft.module.workflow.service.IWorkflowExecuteService;
@@ -28,15 +23,10 @@ import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.transaction.support.TransactionSynchronization;
 import org.springframework.transaction.support.TransactionSynchronizationManager;
 
-import java.util.HashSet;
 import java.util.List;
-import java.util.Map;
 import java.util.Optional;
-import java.util.Set;
 import java.util.concurrent.CompletableFuture;
 
-import static org.junit.jupiter.api.Assertions.*;
-
 /**
  * @author dzx
  * @date 2024/4/19
@@ -55,90 +45,40 @@ class StudentDropOutNodeTest {
     private WorkflowRecordMapper workflowRecordMapper;
 
     @Autowired
-    private HikvisionDataMapper hikvisionDataMapper;
+    private IStudentChangeRecordService changeRecordService;
 
     @Test
     void test(){
-        Long formId = 1863523681699409920L;
+        Long formId = 1900442309068136448L;
         // 获取表单中数据编号
-        Object processInstanceId = "ee72acf7-b6a0-11ef-9921-0242c8000007";
+        Object processInstanceId = "3f8296aa-00a2-11f0-80c9-0242d2000004";
         String processInstanceIdStr = Convert.toStr(processInstanceId);
         if (formId != null && StringUtils.isNotEmpty(processInstanceIdStr)) {
-            TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
-                @Override
-                public void afterCommit() {
-                    CompletableFuture.runAsync(() -> {
-                        Optional<HistoricProcessInstance> historicProcessInstanceOptional = workflowExecuteService.getHistoricProcessInstance(processInstanceId.toString());
-
-                        if (historicProcessInstanceOptional.isEmpty()) {
-                            return;
-                        }
-                        HistoricProcessInstance historicProcessInstance = historicProcessInstanceOptional.get();
-                        if (!historicProcessInstance.getState().equals(HistoricProcessInstance.STATE_ACTIVE)) {
-                            // 获取流程记录中的非正常结束
-                            LambdaQueryWrapper<WorkflowRecord> workflowRecordLambdaQueryWrapper = new LambdaQueryWrapper<>();
-                            workflowRecordLambdaQueryWrapper
-                                    .and(wq -> wq.eq(WorkflowRecord::getWorkflowApproveType, WorkflowApproveType.DISAGREE.getCode())
-                                            .or()
-                                            .eq(WorkflowRecord::getWorkflowApproveType, WorkflowApproveType.WITHDRAW.getCode())
-                                    )
-                                    .eq(WorkflowRecord::getProcessId, processInstanceId)
-                            ;
-                            List<WorkflowRecord> workflowRecordList = workflowRecordMapper.selectList(workflowRecordLambdaQueryWrapper);
-
-                            if (!workflowRecordList.isEmpty()) {
-                                return;
-                            }
-                        }
-
-                        //查询出数据
-                        StudentDropOut studentDropOut = studentDropOutMapper.selectById(formId);
-                        //跟新学籍信息
-                        BaseStudentSchoolRoll schoolRoll = studentSchoolRollService.getOne(
-                                new QueryWrapper<BaseStudentSchoolRoll>().lambda()
-                                        .eq(BaseStudentSchoolRoll::getClassId, studentDropOut.getClassId())
-                                        .eq(BaseStudentSchoolRoll::getUserId, studentDropOut.getStudentUserId())
-                                        .eq(BaseStudentSchoolRoll::getDeleteMark, DeleteMark.NODELETE.getCode())
-                        );
-                        schoolRoll.setArchivesStatus(ArchivesStatusEnum.FB2904.getCode());
-                        studentSchoolRollService.updateById(schoolRoll);
-
-                        //删除海康出入权限
-                        String hikvisionId = hikvisionDataMapper.getStudentHikvisionId(studentDropOut.getStudentUserId());
-                        ApiUtil apiUtil = new ApiUtil();
-                        String apiPath = "/api/pmas/v1/person/batch/delete";
-                        JsonObject paramJson = new JsonObject();
-                        JsonArray personIndexCodes = new JsonArray();
-                        personIndexCodes.add(hikvisionId);
-                        paramJson.add("personIndexCodes", personIndexCodes);
-                        String doPost = apiUtil.doPost(apiPath, paramJson.toString(), null);
+            //查询出数据
+            StudentDropOut studentDropOut = studentDropOutMapper.selectById(formId);
+            //跟新学籍信息
+            BaseStudentSchoolRoll schoolRoll = studentSchoolRollService.getOne(
+                    new QueryWrapper<BaseStudentSchoolRoll>().lambda()
+                            .eq(BaseStudentSchoolRoll::getClassId, studentDropOut.getClassId())
+                            .eq(BaseStudentSchoolRoll::getUserId, studentDropOut.getStudentUserId())
+                            .eq(BaseStudentSchoolRoll::getDeleteMark, DeleteMark.NODELETE.getCode())
+            );
 
-                        JsonParser parser = new JsonParser();
-                        JsonObject resultJson = parser.parse(doPost).getAsJsonObject();
-                        if(resultJson.get("code").getAsInt() == 0){
-                            JsonArray success = resultJson.get("data").getAsJsonObject().get("success").getAsJsonArray();
+            //记录异动
+            changeRecordService.insertData(
+                    ArchivesStatusEnum.fromCode(schoolRoll.getArchivesStatus()),
+                    schoolRoll.getArchivesStatus(),
+                    ArchivesStatusEnum.FB2904.getValue(),
+                    ArchivesStatusEnum.FB2904.getCode(),
+                    studentDropOut.getStudentUserId(),
+                    studentDropOut.getCreateUserId(),
+                    StudentChangeTypeEnum.ArchivesStatus.getCode(),
+                    2
+            );
 
-                            Set<String> valuesSet = new HashSet<>();
-                            String keyToExtract = "indexCode";
-                            // 遍历 JSON 数组并提取指定键的值
-                            for (JsonElement jsonElement : success) {
-                                JsonObject jsonObject = jsonElement.getAsJsonObject();
-                                if (jsonObject.has(keyToExtract)) {
-                                    String value = jsonObject.get(keyToExtract).getAsString();
-                                    valuesSet.add(value);
-                                }
-                            }
-                            if(valuesSet.contains(hikvisionId)){
-                                hikvisionDataMapper.delete(
-                                        new QueryWrapper<HikvisionData>().lambda()
-                                                .eq(HikvisionData::getSourceId, studentDropOut.getClassId())
-                                                .eq(HikvisionData::getHikvisionId, hikvisionId)
-                                );
-                            }
-                        }
-                    });
-                }
-            });
+            schoolRoll.setArchivesStatus(ArchivesStatusEnum.FB2904.getCode());
+            studentSchoolRollService.updateById(schoolRoll);
+            studentSchoolRollService.disableStudent(schoolRoll.getUserId());
         }
     }
 }