|
|
|
@ -1,5 +1,8 @@
|
|
|
|
|
package com.ibeetl.jlw.service;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
|
|
import cn.hutool.core.util.BooleanUtil;
|
|
|
|
|
import cn.hutool.core.util.EnumUtil;
|
|
|
|
@ -22,6 +25,7 @@ import com.ibeetl.jlw.dao.TeacherOpenCourseStudentSigninSettingDao;
|
|
|
|
|
import com.ibeetl.jlw.entity.*;
|
|
|
|
|
import com.ibeetl.jlw.entity.dto.TeacherOpenCourseStudentSigninLogSigninDTO;
|
|
|
|
|
import com.ibeetl.jlw.entity.dto.TeacherOpenCourseStudentSigninLogSigninDTO.ManualClass;
|
|
|
|
|
import com.ibeetl.jlw.enums.StartStatusEnum;
|
|
|
|
|
import com.ibeetl.jlw.validator.TeacherOpenCourseStudentSigninLogSigninDTOValidator;
|
|
|
|
|
import com.ibeetl.jlw.web.query.TeacherOpenCourseStudentSigninLogQuery;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
@ -37,9 +41,11 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import static cn.jlw.util.IpUtils.getIpAddr;
|
|
|
|
|
import static cn.jlw.util.IpUtils.isRangeInner;
|
|
|
|
@ -546,16 +552,59 @@ public class TeacherOpenCourseStudentSigninLogService extends CoreBaseService<Te
|
|
|
|
|
* @param dto
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public void manualSigninAdd(@NotNull(message = "手动签到参数不能为空!") TeacherOpenCourseStudentSigninLogManualSignInDTO dto) {
|
|
|
|
|
teacherOpenCourseStudentSigninSettingDao.insert(dto.getSigninSetting());
|
|
|
|
|
|
|
|
|
|
// 签到配置ID
|
|
|
|
|
final Long settingId = dto.getSigninSetting().getTeacherOpenCourseStudentSigninSettingId();
|
|
|
|
|
|
|
|
|
|
dto.getSigninLogList().forEach(item -> {
|
|
|
|
|
item.setTeacherOpenCourseStudentSigninSettingId(settingId);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
insertBatch(dto.getSigninLogList());
|
|
|
|
|
public void manualSigninAdd(@NotNull(message = "手动签到参数不能为空!") TeacherOpenCourseStudentSigninLogManualMergeDTO dto) {
|
|
|
|
|
|
|
|
|
|
// 获取当前登录用户信息
|
|
|
|
|
final CoreUser user = getUser();
|
|
|
|
|
final HttpServletRequest request = getRequest();
|
|
|
|
|
|
|
|
|
|
// 添加我签到配置
|
|
|
|
|
TeacherOpenCourseStudentSigninSettingManualDTO signinSetting = dto.getSigninSetting();
|
|
|
|
|
TeacherOpenCourseStudentSigninSetting entity = new TeacherOpenCourseStudentSigninSetting();
|
|
|
|
|
|
|
|
|
|
// 拷贝前端传过来的值
|
|
|
|
|
BeanUtil.copyProperties(signinSetting, entity);
|
|
|
|
|
DateTime now = DateUtil.date();
|
|
|
|
|
|
|
|
|
|
// 默认的一些属性填充
|
|
|
|
|
entity.setTeacherOpenCourseStudentSigninSettingSessionTime(now);
|
|
|
|
|
entity.setTeacherOpenCourseStudentSigninSettingStartTime(now);
|
|
|
|
|
entity.setTeacherOpenCourseStudentSigninSettingAddTime(now);
|
|
|
|
|
entity.setTeacherOpenCourseStudentSigninSettingType(manual_signin.name());
|
|
|
|
|
entity.setTeacherOpenCourseStudentSigninSettingStartStatus(StartStatusEnum.READY);
|
|
|
|
|
entity.setTeacherOpenCourseStudentSigninSettingStatus(1);
|
|
|
|
|
entity.setOrgId(user.getOrgId());
|
|
|
|
|
entity.setUserId(user.getId());
|
|
|
|
|
teacherOpenCourseStudentSigninSettingDao.insert(entity);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取插入后的配置ID
|
|
|
|
|
final Long settingId = entity.getTeacherOpenCourseStudentSigninSettingId();
|
|
|
|
|
|
|
|
|
|
// 构建签到日志集合
|
|
|
|
|
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(user.getOrgId());
|
|
|
|
|
teacherOpenCourseStudentSigninLog.setUserId(user.getId());
|
|
|
|
|
// 拷贝前端传过来的值
|
|
|
|
|
BeanUtil.copyProperties(item, teacherOpenCourseStudentSigninLog);
|
|
|
|
|
return teacherOpenCourseStudentSigninLog;
|
|
|
|
|
// 默认的一些属性填充
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
insertBatch(signinLogList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|