ソースを参照

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

大数据与最优化研究所 6 ヶ月 前
コミット
b365137e63

+ 3 - 0
src/main/java/com/xjrsoft/module/banding/mapper/BandingTaskClassStudentMapper.java

@@ -3,6 +3,7 @@ package com.xjrsoft.module.banding.mapper;
 import com.github.yulichang.base.MPJBaseMapper;
 import com.xjrsoft.module.banding.dto.StudentDto;
 import com.xjrsoft.module.banding.entity.BandingTaskClassStudent;
+import com.xjrsoft.module.banding.vo.SyncStudentDataListVo;
 import com.xjrsoft.module.student.dto.BaseNewStudentPageDto;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -25,4 +26,6 @@ public interface BandingTaskClassStudentMapper extends MPJBaseMapper<BandingTask
     List<BaseNewStudentPageDto> surplusStudent(@Param("dto") StudentDto dto);
 
     List<BaseNewStudentPageDto> surplusStudentSure(@Param("dto") StudentDto dto);
+
+    List<SyncStudentDataListVo> getSyncStudentDataList(@Param("studentReportPlanId") Long studentReportPlanId);
 }

+ 3 - 0
src/main/java/com/xjrsoft/module/banding/service/IBandingTaskClassStudentService.java

@@ -5,6 +5,7 @@ import com.xjrsoft.module.banding.dto.ChangeClassDto;
 import com.xjrsoft.module.banding.dto.StudentDto;
 import com.xjrsoft.module.banding.entity.BandingTaskClassStudent;
 import com.xjrsoft.module.student.dto.BaseNewStudentPageDto;
+import com.xjrsoft.module.student.entity.StudentReportPlan;
 
 import java.util.List;
 
@@ -54,4 +55,6 @@ public interface IBandingTaskClassStudentService extends MPJBaseService<BandingT
 
 
     Boolean insertStudent(ChangeClassDto dto);
+
+    Boolean syncStudentData(StudentReportPlan studentReportPlan);
 }

+ 51 - 14
src/main/java/com/xjrsoft/module/banding/service/impl/BandingTaskClassStudentServiceImpl.java

@@ -1,21 +1,16 @@
 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.LocalDateUtil;
 import com.xjrsoft.common.utils.RedisUtil;
 import com.xjrsoft.common.utils.VoToColumnUtil;
-import com.xjrsoft.config.CommonPropertiesConfig;
 import com.xjrsoft.module.banding.dto.ChangeClassDto;
 import com.xjrsoft.module.banding.dto.StudentDto;
 import com.xjrsoft.module.banding.entity.BandingTask;
@@ -25,6 +20,7 @@ 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.SyncStudentDataListVo;
 import com.xjrsoft.module.base.entity.BaseClass;
 import com.xjrsoft.module.base.entity.BaseSemester;
 import com.xjrsoft.module.base.service.IBaseClassService;
@@ -35,27 +31,18 @@ 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.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.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.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.CompletableFuture;
@@ -388,4 +375,54 @@ public class BandingTaskClassStudentServiceImpl extends MPJBaseServiceImpl<Bandi
         return true;
     }
 
+    /**
+     * 同步修改学生的班级信息
+     */
+    @Override
+    @Transactional
+    public Boolean syncStudentData(StudentReportPlan studentReportPlan) {
+        List<SyncStudentDataListVo> syncStudentDataList = this.baseMapper.getSyncStudentDataList(studentReportPlan.getId());
+        List<Long> newStudentIds = syncStudentDataList.stream().map(SyncStudentDataListVo::getNewStudentId).collect(Collectors.toList());
+
+        //修改新生基本信息
+        Map<Long, String> stduyStatusMap = syncStudentDataList.stream().collect(Collectors.toMap(SyncStudentDataListVo::getNewStudentId, SyncStudentDataListVo::getStduyStatus));
+        List<BaseNewStudent> studentList = newStudentService.listByIds(newStudentIds);
+        for (BaseNewStudent student : studentList) {
+            student.setStduyStatus(stduyStatusMap.get(student.getId()));
+        }
+        newStudentService.updateBatchById(studentList);
+
+        //修改班级信息
+        Map<Long, Long> bandingTaskClassMap = syncStudentDataList.stream().filter(x -> x.getBandingTaskClassId() != null).collect(Collectors.toMap(SyncStudentDataListVo::getNewStudentId, SyncStudentDataListVo::getBandingTaskClassId));
+
+        List<BandingTaskClass> taskClassList = taskClassMapper.selectList(
+                new QueryWrapper<BandingTaskClass>().lambda()
+                        .eq(BandingTaskClass::getBandingTaskId, studentReportPlan.getBandingTaskId())
+        );
+        Map<Long, Long> taskClassMap = taskClassList.stream().collect(Collectors.toMap(BandingTaskClass::getBaseClassId, BandingTaskClass::getId));
+
+        List<BandingTaskClassStudent> insertList = new ArrayList<>();
+        for (BaseNewStudent student : studentList) {
+            Long bandingTaskClassId = bandingTaskClassMap.get(student.getId());
+            if(bandingTaskClassId == null){
+                continue;
+            }
+            insertList.add(new BandingTaskClassStudent(){{
+                setBandingTaskClassId(taskClassMap.get(bandingTaskClassId));
+                setNewStudentId(student.getId());
+                setCreateDate(new Date());
+                setStatus(1);
+            }});
+        }
+
+        if(!insertList.isEmpty()){
+            this.remove(
+                    new QueryWrapper<BandingTaskClassStudent>().lambda()
+                            .in(BandingTaskClassStudent::getNewStudentId, newStudentIds)
+            );
+            this.saveBatch(insertList);
+        }
+        return true;
+    }
+
 }

+ 31 - 0
src/main/java/com/xjrsoft/module/banding/vo/SyncStudentDataListVo.java

@@ -0,0 +1,31 @@
+package com.xjrsoft.module.banding.vo;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ContentStyle;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @title: 分班后的学生导出
+ * @Author dzx
+ * @Date: 2024-07-01
+ * @Version 1.0
+ */
+@Data
+public class SyncStudentDataListVo {
+
+    @ApiModelProperty("新生id")
+    private Long newStudentId;
+
+    @ApiModelProperty("班级id")
+    private String classId;
+
+    @ApiModelProperty("就读方式")
+    private String stduyStatus;
+
+    @ApiModelProperty("分班班级id")
+    private Long bandingTaskClassId;
+
+}

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

@@ -17,6 +17,7 @@ import com.xjrsoft.common.utils.LocalDateTimeUtil;
 import com.xjrsoft.common.utils.TreeUtil;
 import com.xjrsoft.common.utils.VoToColumnUtil;
 import com.xjrsoft.module.banding.entity.BandingTask;
+import com.xjrsoft.module.banding.service.IBandingTaskClassStudentService;
 import com.xjrsoft.module.base.entity.BaseClass;
 import com.xjrsoft.module.base.entity.BaseSemester;
 import com.xjrsoft.module.base.service.IBaseClassService;
@@ -61,6 +62,7 @@ public class StudentReportPlanController {
     private final IBaseSemesterService semesterService;
     private final IBaseClassService classService;
     private final IEnrollmentPlanService enrollmentPlanService;
+    private final IBandingTaskClassStudentService taskClassStudentService;
 
     @GetMapping(value = "/page")
     @ApiOperation(value = "学生报到计划列表(分页)")
@@ -116,6 +118,9 @@ public class StudentReportPlanController {
         if((reportPlan.getCategory() == 2 || reportPlan.getCategory() == 3) && LocalDateTimeUtil.isDateTimeInRange(LocalDateTime.now(), reportPlan.getStartTime(), reportPlan.getEndTime())){
             reportPlan.setStatus(1);
         }
+        if(reportPlan.getCategory() == 3){
+            taskClassStudentService.syncStudentData(reportPlan);
+        }
         return RT.ok(studentReportPlanService.update(reportPlan));
     }
 

+ 10 - 0
src/main/resources/mapper/banding/BandingTaskClassStudentMapper.xml

@@ -204,4 +204,14 @@
             </if>
         </if>
     </select>
+
+    <select id="getSyncStudentDataList" resultType="com.xjrsoft.module.banding.vo.SyncStudentDataListVo">
+        SELECT t2.id AS new_student_id,t4.class_id,t6.banding_task_class_id,t4.stduy_status FROM student_report_record t1
+        INNER JOIN base_new_student t2 ON t1.user_id = t2.id
+        INNER JOIN xjr_user t3 ON t2.credential_number = t3.credential_number
+        INNER JOIN base_student_school_roll t4 ON t3.id = t4.user_id
+        LEFT JOIN banding_task_class t5 ON t4.class_id = t5.base_class_id
+        LEFT JOIN banding_task_class_student t6 ON t2.id = t6.new_student_id AND t6.delete_mark = 0
+        WHERE t1.delete_mark = 0 AND t1.student_report_plan_id = #{studentReportPlanId}
+    </select>
 </mapper>