From 224176f14373136f67f61103b032c2c1370bf82c Mon Sep 17 00:00:00 2001 From: Mlxa0324 Date: Mon, 27 Mar 2023 23:20:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=BD=E6=9F=A5=E6=89=8B=E5=8A=A8=E7=AD=BE?= =?UTF-8?q?=E5=88=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...cherOpenCourseStudentSigninLogService.java | 75 +++++++++++++------ 1 file changed, 51 insertions(+), 24 deletions(-) diff --git a/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseStudentSigninLogService.java b/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseStudentSigninLogService.java index 62ea0bb9..33026eb2 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseStudentSigninLogService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseStudentSigninLogService.java @@ -31,6 +31,8 @@ import com.ibeetl.jlw.entity.vo.TeacherOpenCourseStudentSigninLogSummaryVO; import com.ibeetl.jlw.enums.SignInTypeEnum; import com.ibeetl.jlw.enums.StartStatusEnum; import com.ibeetl.jlw.validator.TeacherOpenCourseStudentSigninLogSigninDTOValidator; +import com.ibeetl.jlw.web.query.StudentQuery; +import com.ibeetl.jlw.web.query.TeacherOpenCourseMergeStudentQuery; import com.ibeetl.jlw.web.query.TeacherOpenCourseStudentSigninLogQuery; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -52,11 +54,14 @@ import java.io.*; import java.util.*; import java.util.stream.Collectors; +import static cn.hutool.core.collection.CollUtil.emptyIfNull; import static cn.jlw.util.CacheUserUtil.getStudent; import static cn.jlw.util.IpUtils.getIpAddr; import static cn.jlw.util.IpUtils.isRangeInner; import static cn.jlw.util.ValidatorUtil.getFirstErrorMessage; import static com.ibeetl.admin.core.util.ExcelUtil.getCellFormatValue; +import static com.ibeetl.admin.core.util.StreamUtils.getFieldToSet; +import static com.ibeetl.admin.core.util.StreamUtils.listJoin; import static com.ibeetl.admin.core.util.servlet.ServletUtils.getRequest; import static com.ibeetl.admin.core.util.user.CacheUserUtil.getUser; import static com.ibeetl.jlw.entity.TeacherOpenCourseStudentSigninSetting.ALL_SCHOOL_CLASS_IDS_SIGN; @@ -80,6 +85,7 @@ public class TeacherOpenCourseStudentSigninLogService extends CoreBaseServicequeryByCondition(PageQuery query){ @@ -576,43 +582,64 @@ public class TeacherOpenCourseStudentSigninLogService extends CoreBaseService studentList = studentDao.getValuesByQuery(studentQuery); + String allStudentIds = listJoin(studentList, Student::getStudentId); + + // 查询这个开课下的所有学生 + TeacherOpenCourseMergeStudentQuery mergeStudentQuery = new TeacherOpenCourseMergeStudentQuery(); + mergeStudentQuery.setTeacherOpenCourseSchoolClassMergeStudentStatus(1); + mergeStudentQuery.setStudentIdPlural(allStudentIds); + Set mergeStudentIdsSet = getFieldToSet(teacherOpenCourseMergeStudentService.getValuesByQueryNotWithPermission(mergeStudentQuery), TeacherOpenCourseMergeStudent::getStudentId); + + // 替换原来查询到的所有学生,过滤后的数据 + studentList = studentList.stream().filter(item -> mergeStudentIdsSet.contains(item.getStudentId())).collect(Collectors.toList()); + // 构建签到日志集合 - List signinLogList = dto.getSigninLogList().stream() - .map(item -> { - Student studentInfo = studentDao.getById(item.getStudentId()); - Long classId = studentInfo.getClassId(); - Assert.notNull(classId, "学生姓名:{}, 编号:{} 信息异常,请联系管理员!" - , studentInfo.getStudentName(), studentInfo.getStudentSn()); - - TeacherOpenCourseStudentSigninLog teacherOpenCourseStudentSigninLog = new TeacherOpenCourseStudentSigninLog(); - teacherOpenCourseStudentSigninLog.setTeacherOpenCourseId(entity.getTeacherOpenCourseId()); - teacherOpenCourseStudentSigninLog.setSchoolClassId(classId); - teacherOpenCourseStudentSigninLog.setTeacherOpenCourseStudentSigninLogAddTime(now); - teacherOpenCourseStudentSigninLog.setTeacherOpenCourseStudentSigninLogIp(getIpAddr(request)); - teacherOpenCourseStudentSigninLog.setTeacherOpenCourseStudentSigninLogTag(SIGN_IN); - teacherOpenCourseStudentSigninLog.setTeacherOpenCourseStudentSigninSettingSessionTime(now); - teacherOpenCourseStudentSigninLog.setTeacherOpenCourseStudentSigninSettingId(settingId); - teacherOpenCourseStudentSigninLog.setOrgId(operatorUser.getOrgId()); - teacherOpenCourseStudentSigninLog.setUserId(studentInfo.getUserId()); - // 拷贝前端传过来的值 - BeanUtil.copyProperties(item, teacherOpenCourseStudentSigninLog); - return teacherOpenCourseStudentSigninLog; - // 默认的一些属性填充 + List signinLogList = emptyIfNull(studentList).stream().map(studentInfo -> { + Long classId = studentInfo.getClassId(); + Assert.notNull(classId, "学生姓名:{}, 编号:{} 信息异常,请联系管理员!" + , studentInfo.getStudentName(), studentInfo.getStudentSn()); + + TeacherOpenCourseStudentSigninLog teacherOpenCourseStudentSigninLog = new TeacherOpenCourseStudentSigninLog(); + + teacherOpenCourseStudentSigninLog.setStudentId(studentInfo.getStudentId()); + teacherOpenCourseStudentSigninLog.setTeacherOpenCourseId(entity.getTeacherOpenCourseId()); + teacherOpenCourseStudentSigninLog.setSchoolClassId(classId); + teacherOpenCourseStudentSigninLog.setTeacherOpenCourseStudentSigninLogAddTime(now); + teacherOpenCourseStudentSigninLog.setTeacherOpenCourseStudentSigninLogIp(getIpAddr(request)); + teacherOpenCourseStudentSigninLog.setTeacherOpenCourseStudentSigninLogTag(SIGN_IN); + teacherOpenCourseStudentSigninLog.setTeacherOpenCourseStudentSigninSettingSessionTime(now); + teacherOpenCourseStudentSigninLog.setTeacherOpenCourseStudentSigninSettingId(settingId); + teacherOpenCourseStudentSigninLog.setOrgId(operatorUser.getOrgId()); + teacherOpenCourseStudentSigninLog.setUserId(studentInfo.getUserId()); + + // 查询到抽取的学生信息,替换默认的参数 + emptyIfNull(dto.getSigninLogList()).stream().filter(ite -> studentInfo.getStudentId().equals(ite.getStudentId())).forEach(findOne -> { + teacherOpenCourseStudentSigninLog.setTeacherOpenCourseStudentSigninLogTag(findOne.getTeacherOpenCourseStudentSigninLogTag()); + teacherOpenCourseStudentSigninLog.setTeacherOpenCourseStudentSigninLogRemark(findOne.getTeacherOpenCourseStudentSigninLogRemark()); + }); + return teacherOpenCourseStudentSigninLog; }).collect(Collectors.toList()); insertBatch(signinLogList);