|
|
|
@ -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 CoreBaseService<Te
|
|
|
|
|
|
|
|
|
|
@Autowired private StudentDao studentDao;
|
|
|
|
|
@Autowired private TeacherOpenCourseMergeSchoolClassDao teacherOpenCourseMergeSchoolClassDao;
|
|
|
|
|
@Autowired private TeacherOpenCourseMergeStudentService teacherOpenCourseMergeStudentService;
|
|
|
|
|
@Autowired private TeacherOpenCourseStudentSigninLogSigninDTOValidator teacherOpenCourseStudentSigninLogSigninDTOValidator;
|
|
|
|
|
|
|
|
|
|
public PageQuery<TeacherOpenCourseStudentSigninLog>queryByCondition(PageQuery query){
|
|
|
|
@ -576,43 +582,64 @@ public class TeacherOpenCourseStudentSigninLogService extends CoreBaseService<Te
|
|
|
|
|
BeanUtil.copyProperties(signinSetting, entity);
|
|
|
|
|
DateTime now = DateUtil.date();
|
|
|
|
|
|
|
|
|
|
// 默认的一些属性填充
|
|
|
|
|
// 默认的一些属性填充。添加主表
|
|
|
|
|
entity.setTeacherOpenCourseStudentSigninSettingSessionTime(now);
|
|
|
|
|
entity.setTeacherOpenCourseStudentSigninSettingStartTime(now);
|
|
|
|
|
entity.setTeacherOpenCourseStudentSigninSettingEndTime(now);
|
|
|
|
|
entity.setTeacherOpenCourseStudentSigninSettingAddTime(now);
|
|
|
|
|
entity.setTeacherOpenCourseStudentSigninSettingType(manual_signin.name());
|
|
|
|
|
entity.setTeacherOpenCourseStudentSigninSettingStartStatus(StartStatusEnum.READY);
|
|
|
|
|
entity.setTeacherOpenCourseStudentSigninSettingStartStatus(StartStatusEnum.END);
|
|
|
|
|
entity.setTeacherOpenCourseStudentSigninSettingStatus(1);
|
|
|
|
|
entity.setOrgId(operatorUser.getOrgId());
|
|
|
|
|
entity.setUserId(operatorUser.getId());
|
|
|
|
|
teacherOpenCourseStudentSigninSettingDao.insert(entity);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取插入后的配置ID
|
|
|
|
|
final Long settingId = entity.getTeacherOpenCourseStudentSigninSettingId();
|
|
|
|
|
|
|
|
|
|
// 查询所有要签到的班级,抽查几个学生以后,其他的学生全部默认是签到状态。
|
|
|
|
|
String schoolClassIds = signinSetting.getSchoolClassIds();
|
|
|
|
|
StudentQuery studentQuery = new StudentQuery();
|
|
|
|
|
studentQuery.setClassIds(schoolClassIds);
|
|
|
|
|
studentQuery.setStudentStatus(1);
|
|
|
|
|
// 查询指定班级下面的所有学生IDs
|
|
|
|
|
List<Student> studentList = studentDao.getValuesByQuery(studentQuery);
|
|
|
|
|
String allStudentIds = listJoin(studentList, Student::getStudentId);
|
|
|
|
|
|
|
|
|
|
// 查询这个开课下的所有学生
|
|
|
|
|
TeacherOpenCourseMergeStudentQuery mergeStudentQuery = new TeacherOpenCourseMergeStudentQuery();
|
|
|
|
|
mergeStudentQuery.setTeacherOpenCourseSchoolClassMergeStudentStatus(1);
|
|
|
|
|
mergeStudentQuery.setStudentIdPlural(allStudentIds);
|
|
|
|
|
Set<Long> mergeStudentIdsSet = getFieldToSet(teacherOpenCourseMergeStudentService.getValuesByQueryNotWithPermission(mergeStudentQuery), TeacherOpenCourseMergeStudent::getStudentId);
|
|
|
|
|
|
|
|
|
|
// 替换原来查询到的所有学生,过滤后的数据
|
|
|
|
|
studentList = studentList.stream().filter(item -> mergeStudentIdsSet.contains(item.getStudentId())).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
// 构建签到日志集合
|
|
|
|
|
List<TeacherOpenCourseStudentSigninLog> 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<TeacherOpenCourseStudentSigninLog> 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);
|
|
|
|
|