Pārlūkot izejas kodu

新生报到功能调整,增加学生数据同步机制

dzx 6 mēneši atpakaļ
vecāks
revīzija
64b2deaa8e

+ 33 - 0
src/main/java/com/xjrsoft/module/banding/service/impl/BandingTaskClassStudentServiceImpl.java

@@ -43,8 +43,10 @@ import org.springframework.transaction.annotation.Transactional;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.CompletableFuture;
 import java.util.stream.Collectors;
 
@@ -381,6 +383,37 @@ public class BandingTaskClassStudentServiceImpl extends MPJBaseServiceImpl<Bandi
     @Override
     @Transactional
     public Boolean syncStudentData(StudentReportPlan studentReportPlan) {
+        //先删除所有的
+        reportRecordMapper.deleteRecordByPlanId(studentReportPlan.getId());
+        
+        //拷贝试读报到的数据过来
+        StudentReportPlan tryReadingReportPlan = reportPlanService.getOne(
+                new QueryWrapper<StudentReportPlan>().lambda()
+                        .eq(StudentReportPlan::getCategory, 2)
+                        .eq(StudentReportPlan::getBandingTaskId, studentReportPlan.getBandingTaskId())
+        );
+
+        List<StudentReportRecord> records = reportRecordMapper.selectList(
+                new QueryWrapper<StudentReportRecord>().lambda()
+                        .eq(StudentReportRecord::getStudentReportPlanId, tryReadingReportPlan.getId())
+        );
+        Date createDate = new Date();
+        Set<Long> existInsertUserIds = new HashSet<>();
+        for (StudentReportRecord record : records) {
+            if(existInsertUserIds.contains(record.getUserId())){
+                continue;
+            }
+            record.setReportTime(null);
+            record.setModifyUserId(null);
+            record.setModifyDate(null);
+            record.setCreateDate(createDate);
+            record.setStudentReportPlanId(studentReportPlan.getId());
+            record.setId(null);
+            reportRecordMapper.insert(record);
+            existInsertUserIds.add(record.getUserId());
+        }
+
+
         List<SyncStudentDataListVo> syncStudentDataList = this.baseMapper.getSyncStudentDataList(studentReportPlan.getId());
         List<Long> newStudentIds = syncStudentDataList.stream().map(SyncStudentDataListVo::getNewStudentId).collect(Collectors.toList());
 

+ 4 - 0
src/main/java/com/xjrsoft/module/student/mapper/StudentReportRecordMapper.java

@@ -10,6 +10,7 @@ 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.Delete;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Update;
@@ -45,4 +46,7 @@ public interface StudentReportRecordMapper extends MPJBaseMapper<StudentReportRe
     @Update("update student_report_record set delete_mark = 1 where user_id = #{userId} and student_report_plan_id = #{planId}")
     Boolean deleteRecordByUserIdAndPlanId(@Param("userId") Long userId, @Param("planId") Long planId);
 
+    @Delete("delete from student_report_record where student_report_plan_id = #{planId}")
+    Boolean deleteRecordByPlanId(@Param("planId") Long planId);
+
 }

+ 2 - 2
src/main/resources/mapper/banding/BandingTaskClassStudentMapper.xml

@@ -208,8 +208,8 @@
     <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
+        INNER JOIN xjr_user t3 ON t2.credential_number = t3.credential_number AND t3.delete_mark = 0
+        INNER JOIN base_student_school_roll t4 ON t3.id = t4.user_id AND t4.delete_mark = 0
         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}