|
|
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;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.extra.validation.BeanValidationResult;
|
|
|
import cn.hutool.extra.validation.ValidationUtil;
|
|
|
import cn.jlw.util.ToolUtils;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.ibeetl.admin.core.entity.CoreUser;
|
|
|
import com.ibeetl.admin.core.service.CoreBaseService;
|
|
|
import com.ibeetl.admin.core.util.PlatformException;
|
|
|
import com.ibeetl.admin.core.util.TimeTool;
|
|
|
import com.ibeetl.admin.core.web.JsonResult;
|
|
|
import com.ibeetl.admin.core.web.JsonReturnCode;
|
|
|
import com.ibeetl.jlw.dao.StudentDao;
|
|
|
import com.ibeetl.jlw.dao.TeacherOpenCourseMergeSchoolClassDao;
|
|
|
import com.ibeetl.jlw.dao.TeacherOpenCourseStudentSigninLogDao;
|
|
|
import com.ibeetl.jlw.dao.TeacherOpenCourseStudentSigninSettingDao;
|
|
|
import com.ibeetl.jlw.entity.*;
|
|
|
import com.ibeetl.jlw.entity.dto.TeacherOpenCourseStudentSigninLogManualMergeDTO;
|
|
|
import com.ibeetl.jlw.entity.dto.TeacherOpenCourseStudentSigninLogSigninDTO;
|
|
|
import com.ibeetl.jlw.entity.dto.TeacherOpenCourseStudentSigninLogSigninDTO.ManualClass;
|
|
|
import com.ibeetl.jlw.entity.dto.TeacherOpenCourseStudentSigninSettingManualDTO;
|
|
|
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;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.beetl.sql.core.SqlId;
|
|
|
import org.beetl.sql.core.engine.PageQuery;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.validation.constraints.NotNull;
|
|
|
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;
|
|
|
import static com.ibeetl.jlw.entity.dto.TeacherOpenCourseStudentSigninLogSigninDTO.TeacherOpenCourseStudentSigninLogTypeEnum.*;
|
|
|
import static com.ibeetl.jlw.enums.SignInTypeEnum.SIGN_IN;
|
|
|
import static com.ibeetl.jlw.enums.SignInTypeEnum.UN_SIGN_IN;
|
|
|
|
|
|
/**
|
|
|
* 学生签到记录 Service
|
|
|
* 当分布式ID开启后请勿使用insert(*,true)
|
|
|
*/
|
|
|
|
|
|
@Service
|
|
|
@Transactional
|
|
|
@Validated
|
|
|
@Slf4j
|
|
|
public class TeacherOpenCourseStudentSigninLogService extends CoreBaseService<TeacherOpenCourseStudentSigninLog> implements DeleteResourcesBy{
|
|
|
|
|
|
@Autowired private TeacherOpenCourseStudentSigninLogDao teacherOpenCourseStudentSigninLogDao;
|
|
|
@Autowired private TeacherOpenCourseStudentSigninSettingDao teacherOpenCourseStudentSigninSettingDao;
|
|
|
|
|
|
@Autowired private StudentDao studentDao;
|
|
|
@Autowired private TeacherOpenCourseMergeSchoolClassDao teacherOpenCourseMergeSchoolClassDao;
|
|
|
@Autowired private TeacherOpenCourseMergeStudentService teacherOpenCourseMergeStudentService;
|
|
|
@Autowired private TeacherOpenCourseStudentSigninLogSigninDTOValidator teacherOpenCourseStudentSigninLogSigninDTOValidator;
|
|
|
|
|
|
public PageQuery<TeacherOpenCourseStudentSigninLog>queryByCondition(PageQuery query){
|
|
|
PageQuery ret = teacherOpenCourseStudentSigninLogDao.queryByCondition(query);
|
|
|
queryListAfter(ret.getList());
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
public PageQuery<TeacherOpenCourseStudentSigninLog>queryByConditionQuery(PageQuery query){
|
|
|
PageQuery ret = teacherOpenCourseStudentSigninLogDao.queryByConditionQuery(query);
|
|
|
queryListAfter(ret.getList());
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 缺勤备注添加
|
|
|
* @param signinLogQuery
|
|
|
* @return
|
|
|
*/
|
|
|
public JsonResult<String> editReasonForAbsence(TeacherOpenCourseStudentSigninLogQuery signinLogQuery){
|
|
|
if (Objects.isNull(signinLogQuery.getTeacherOpenCourseStudentSigninLogId())){
|
|
|
return JsonResult.failMessage("用户编号不存在");
|
|
|
}
|
|
|
TeacherOpenCourseStudentSigninLog single = teacherOpenCourseStudentSigninLogDao.getSQLManager().lambdaQuery(TeacherOpenCourseStudentSigninLog.class)
|
|
|
.andEq(TeacherOpenCourseStudentSigninLog::getTeacherOpenCourseStudentSigninLogId, signinLogQuery.getTeacherOpenCourseStudentSigninLogId())
|
|
|
.andEq(TeacherOpenCourseStudentSigninLog::getTeacherOpenCourseStudentSigninLogTag, UN_SIGN_IN)
|
|
|
.single();
|
|
|
|
|
|
if (Objects.isNull(single)){
|
|
|
return JsonResult.failMessage("查询不到用户数据");
|
|
|
}else {
|
|
|
single.setTeacherOpenCourseStudentSigninLogRemark(signinLogQuery.getTeacherOpenCourseStudentSigninLogRemark());
|
|
|
teacherOpenCourseStudentSigninLogDao.getSQLManager().lambdaQuery(TeacherOpenCourseStudentSigninLog.class)
|
|
|
.andEq(TeacherOpenCourseStudentSigninLog::getTeacherOpenCourseStudentSigninLogId, signinLogQuery.getTeacherOpenCourseStudentSigninLogId())
|
|
|
.updateSelective(single);
|
|
|
}
|
|
|
return JsonResult.success();
|
|
|
}
|
|
|
|
|
|
public void deleteByList(List list){
|
|
|
String ids = "";
|
|
|
ToolUtils.deleteNullList(list);
|
|
|
for(int i=0;null != list && i<list.size();i++){
|
|
|
ids += list.get(i).toString()+(i==list.size()-1?"":",");
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(ids)){
|
|
|
teacherOpenCourseStudentSigninLogDao.deleteTeacherOpenCourseStudentSigninLogByIds(ids);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void deleteTeacherOpenCourseStudentSigninLog(String ids){
|
|
|
try {
|
|
|
teacherOpenCourseStudentSigninLogDao.deleteTeacherOpenCourseStudentSigninLogByIds(ids);
|
|
|
} catch (Exception e) {
|
|
|
throw new PlatformException("批量删除学生签到记录失败", e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public String addAll(TeacherOpenCourseStudentSigninLogQuery teacherOpenCourseStudentSigninLogQuery){
|
|
|
String msg = "";
|
|
|
List<TeacherOpenCourseStudentSigninLog> teacherOpenCourseStudentSigninLogList = new ArrayList<>();
|
|
|
try {
|
|
|
teacherOpenCourseStudentSigninLogList = JSON.parseArray(teacherOpenCourseStudentSigninLogQuery.getTeacherOpenCourseStudentSigninLogJsonStr(), TeacherOpenCourseStudentSigninLog.class);
|
|
|
} catch (Exception e) {
|
|
|
try {
|
|
|
teacherOpenCourseStudentSigninLogList.add(JSONObject.parseObject(teacherOpenCourseStudentSigninLogQuery.getTeacherOpenCourseStudentSigninLogJsonStr(), TeacherOpenCourseStudentSigninLog.class));
|
|
|
} catch (Exception e1) {}
|
|
|
}
|
|
|
ToolUtils.deleteNullList(teacherOpenCourseStudentSigninLogList);
|
|
|
if(null != teacherOpenCourseStudentSigninLogList && teacherOpenCourseStudentSigninLogList.size()>0){
|
|
|
for(int i=0;i<teacherOpenCourseStudentSigninLogList.size();i++){
|
|
|
TeacherOpenCourseStudentSigninLog teacherOpenCourseStudentSigninLog = teacherOpenCourseStudentSigninLogList.get(i);
|
|
|
teacherOpenCourseStudentSigninLog.setUserId(teacherOpenCourseStudentSigninLogQuery.getUserId());
|
|
|
teacherOpenCourseStudentSigninLog.setOrgId(teacherOpenCourseStudentSigninLogQuery.getOrgId());
|
|
|
}
|
|
|
insertBatch(teacherOpenCourseStudentSigninLogList);
|
|
|
}
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
public JsonResult add(TeacherOpenCourseStudentSigninLogQuery teacherOpenCourseStudentSigninLogQuery){
|
|
|
String msg = "";
|
|
|
TeacherOpenCourseStudentSigninLog teacherOpenCourseStudentSigninLog = teacherOpenCourseStudentSigninLogQuery.pojo();
|
|
|
teacherOpenCourseStudentSigninLog.setTeacherOpenCourseStudentSigninLogAddTime(new Date());
|
|
|
teacherOpenCourseStudentSigninLogDao.insert(teacherOpenCourseStudentSigninLog);
|
|
|
teacherOpenCourseStudentSigninLogQuery.setTeacherOpenCourseStudentSigninLogId(teacherOpenCourseStudentSigninLog.getTeacherOpenCourseStudentSigninLogId());
|
|
|
JsonResult jsonResult = new JsonResult();
|
|
|
jsonResult.setData(teacherOpenCourseStudentSigninLog.getTeacherOpenCourseStudentSigninLogId());//自增的ID丢进去
|
|
|
jsonResult.setCode(JsonReturnCode.SUCCESS.getCode());
|
|
|
jsonResult.setMsg(msg);
|
|
|
return jsonResult;
|
|
|
}
|
|
|
|
|
|
public String edit(TeacherOpenCourseStudentSigninLogQuery teacherOpenCourseStudentSigninLogQuery){
|
|
|
String msg = "";
|
|
|
TeacherOpenCourseStudentSigninLog teacherOpenCourseStudentSigninLog = teacherOpenCourseStudentSigninLogQuery.pojo();
|
|
|
teacherOpenCourseStudentSigninLogDao.updateTemplateById(teacherOpenCourseStudentSigninLog);
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
public String updateGivenByIds(TeacherOpenCourseStudentSigninLogQuery teacherOpenCourseStudentSigninLogQuery){
|
|
|
String msg = "";
|
|
|
if(StringUtils.isNotBlank(teacherOpenCourseStudentSigninLogQuery.get_given())){
|
|
|
boolean flag = teacherOpenCourseStudentSigninLogDao.updateGivenByIds(teacherOpenCourseStudentSigninLogQuery) > 0;
|
|
|
if(!flag){
|
|
|
msg = "更新指定参数失败";
|
|
|
}
|
|
|
}else{
|
|
|
msg = "指定参数为空";
|
|
|
}
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
public List<TeacherOpenCourseStudentSigninLog> getValues (Object paras){
|
|
|
return sqlManager.select(SqlId.of("jlw.teacherOpenCourseStudentSigninLog.getTeacherOpenCourseStudentSigninLogValues"), TeacherOpenCourseStudentSigninLog.class, paras);
|
|
|
}
|
|
|
|
|
|
public List<TeacherOpenCourseStudentSigninLog> getValuesByQuery (TeacherOpenCourseStudentSigninLogQuery teacherOpenCourseStudentSigninLogQuery){
|
|
|
return teacherOpenCourseStudentSigninLogDao.getValuesByQuery(teacherOpenCourseStudentSigninLogQuery);
|
|
|
}
|
|
|
|
|
|
public List<TeacherOpenCourseStudentSigninLog> getValuesByQueryNotWithPermission (TeacherOpenCourseStudentSigninLogQuery teacherOpenCourseStudentSigninLogQuery){
|
|
|
List<TeacherOpenCourseStudentSigninLog> values = teacherOpenCourseStudentSigninLogDao.getValuesByQueryNotWithPermission(teacherOpenCourseStudentSigninLogQuery);
|
|
|
queryListAfter(values);
|
|
|
return values;
|
|
|
}
|
|
|
|
|
|
public TeacherOpenCourseStudentSigninLog getInfo (Long teacherOpenCourseStudentSigninLogId){
|
|
|
TeacherOpenCourseStudentSigninLogQuery teacherOpenCourseStudentSigninLogQuery = new TeacherOpenCourseStudentSigninLogQuery();
|
|
|
teacherOpenCourseStudentSigninLogQuery.setTeacherOpenCourseStudentSigninLogId(teacherOpenCourseStudentSigninLogId);
|
|
|
List<TeacherOpenCourseStudentSigninLog> list = teacherOpenCourseStudentSigninLogDao.getValuesByQuery(teacherOpenCourseStudentSigninLogQuery);
|
|
|
if(null != list && list.size()>0){
|
|
|
return list.get(0);
|
|
|
}else{
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public TeacherOpenCourseStudentSigninLog getInfo (TeacherOpenCourseStudentSigninLogQuery teacherOpenCourseStudentSigninLogQuery){
|
|
|
List<TeacherOpenCourseStudentSigninLog> list = teacherOpenCourseStudentSigninLogDao.getValuesByQuery(teacherOpenCourseStudentSigninLogQuery);
|
|
|
if(null != list && list.size()>0){
|
|
|
return list.get(0);
|
|
|
}else{
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 学生端-教师端-签到
|
|
|
*
|
|
|
* @param signinDTO
|
|
|
*/
|
|
|
public void signin(@Validated TeacherOpenCourseStudentSigninLogSigninDTO signinDTO) {
|
|
|
|
|
|
Student student = getStudent();
|
|
|
Assert.notNull(student, "该接口只能学生操作");
|
|
|
|
|
|
// 通过签到配置ID查询配置信息
|
|
|
List<TeacherOpenCourseStudentSigninSetting> signinSettingList =
|
|
|
teacherOpenCourseStudentSigninSettingDao.getByIds(signinDTO.getTeacherOpenCourseStudentSigninSettingId() + "");
|
|
|
Assert.notEmpty(signinSettingList, "签到配置ID无效!");
|
|
|
|
|
|
// 通过签到配置ID查询对应的参数信息。用于下面的验证。
|
|
|
TeacherOpenCourseStudentSigninSetting signinSetting = signinSettingList.get(0);
|
|
|
|
|
|
// 断言验证,学生某个课程只能签到一次。三种签到类型,都可以签到
|
|
|
TeacherOpenCourseStudentSigninLog entity = new TeacherOpenCourseStudentSigninLog();
|
|
|
entity.setStudentId(student.getStudentId());
|
|
|
entity.setTeacherOpenCourseStudentSigninSettingId(signinSetting.getTeacherOpenCourseStudentSigninSettingId());
|
|
|
entity.setTeacherOpenCourseStudentSigninLogTag(SIGN_IN);
|
|
|
Assert.isTrue(ObjectUtil.isEmpty(teacherOpenCourseStudentSigninLogDao.template(entity)), "该学生已经签到过了!");
|
|
|
|
|
|
// 判断是否加入到这个课程中
|
|
|
long teacherOpenCourseInCount = teacherOpenCourseMergeSchoolClassDao.createLambdaQuery()
|
|
|
.andEq(TeacherOpenCourseMergeSchoolClass::getSchoolClassId, student.getClassId())
|
|
|
.andEq(TeacherOpenCourseMergeSchoolClass::getTeacherOpenCourseId, signinSetting.getTeacherOpenCourseId())
|
|
|
.count();
|
|
|
Assert.isTrue(teacherOpenCourseInCount > 0, "未加入到该课程中,开课ID或学生ID有误!");
|
|
|
|
|
|
switch (signinDTO.getTeacherOpenCourseStudentSigninLogType()) {
|
|
|
// IP签到
|
|
|
|
|
|
case ip_signin: {
|
|
|
ipSignInHandler(signinDTO, signinSetting);
|
|
|
}break;
|
|
|
// 手动签到。教师端操作
|
|
|
case manual_signin: {
|
|
|
manualSignInHandler(signinDTO, signinSetting);
|
|
|
}break;
|
|
|
// 验证码签到
|
|
|
case code_signin: {
|
|
|
codeSignInHandler(signinDTO, signinSetting);
|
|
|
}break;
|
|
|
default:
|
|
|
throw new RuntimeException("不支持的签到类型,请核对!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 判断班级ID是否在集合中
|
|
|
*
|
|
|
* @param schoolClassId
|
|
|
* @param signinSetting
|
|
|
* @return
|
|
|
*/
|
|
|
private boolean schoolClassIdJudgment(@NotNull(message = "班级ID不能为空!") Long schoolClassId,
|
|
|
@NotNull(message = "签到配置不能为空!") TeacherOpenCourseStudentSigninSetting signinSetting) {
|
|
|
Assert.notEmpty(signinSetting.getSchoolClassIds(), "班级ID集合不能为空!");
|
|
|
|
|
|
if(signinSetting.getSchoolClassIds().equals(ALL_SCHOOL_CLASS_IDS_SIGN)) {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
// 分割班级ID,逐一比对,只要有一个符合要求,就返回true
|
|
|
return Arrays.stream(signinSetting.getSchoolClassIds().split(","))
|
|
|
.anyMatch(item -> item.equals(schoolClassId.toString()));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* IP签到
|
|
|
*
|
|
|
* @param signinDTO
|
|
|
* @param signinSetting
|
|
|
*/
|
|
|
public void ipSignInHandler(@Validated TeacherOpenCourseStudentSigninLogSigninDTO signinDTO,
|
|
|
@NotNull(message = "签到配置不能为空!") TeacherOpenCourseStudentSigninSetting signinSetting) {
|
|
|
|
|
|
teacherOpenCourseStudentSigninLogSigninDTOValidator.validator(signinDTO).validatorBySetting(signinSetting);
|
|
|
|
|
|
// 获取登录用户,教师身份不支持IP签到,教师只能手动签到
|
|
|
Student student = getStudent();
|
|
|
Assert.notNull(student, "IP签到方式,只允许学生进行操作!");
|
|
|
// 获取学生信息
|
|
|
Assert.isTrue(schoolClassIdJudgment(student.getClassId(), signinSetting), "该学生所在的班级不符合签到要求!");
|
|
|
Date time = new Date();
|
|
|
Date startTime = signinSetting.getTeacherOpenCourseStudentSigninSettingStartTime();
|
|
|
Date endTime = signinSetting.getTeacherOpenCourseStudentSigninSettingEndTime();
|
|
|
if (Objects.isNull(startTime)){
|
|
|
Assert.notNull(null, "未开始签到");
|
|
|
}
|
|
|
|
|
|
if (startTime.getTime() > time.getTime()){
|
|
|
Assert.notNull(null, "未开始签到");
|
|
|
}
|
|
|
|
|
|
if (!Objects.isNull(endTime) && endTime.getTime() < time.getTime()){
|
|
|
Assert.notNull(null, "已结束签到");
|
|
|
}
|
|
|
|
|
|
// 获取到真实的IP
|
|
|
String myIpAddress = getIpAddr(getRequest());
|
|
|
|
|
|
// 断言,如果IP不在指定的IP段内,则添加失败,异常信息丢给前台
|
|
|
Assert.isTrue(isRangeInner(myIpAddress, signinSetting.getTeacherOpenCourseStudentSigninSettingValue()),
|
|
|
"您的IP地址:{},不在指定的IP段内!", myIpAddress);
|
|
|
|
|
|
// 构建实体
|
|
|
TeacherOpenCourseStudentSigninLogQuery signinLogQuery = new TeacherOpenCourseStudentSigninLogQuery();
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninSettingSessionTime(signinSetting.getTeacherOpenCourseStudentSigninSettingSessionTime().toString());
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninSettingId(signinSetting.getTeacherOpenCourseStudentSigninSettingId());
|
|
|
signinLogQuery.setTeacherOpenCourseId(signinSetting.getTeacherOpenCourseId());
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninLogType(ip_signin.name());
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninLogIp(myIpAddress);
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninLogTag(SIGN_IN);
|
|
|
signinLogQuery.setSchoolClassId(student.getClassId());
|
|
|
signinLogQuery.setStudentId(student.getStudentId());
|
|
|
signinLogQuery.setOrgId(student.getOrgId());
|
|
|
signinLogQuery.setUserId(student.getUserId());
|
|
|
|
|
|
TeacherOpenCourseStudentSigninLog single = teacherOpenCourseStudentSigninLogDao.getSQLManager()
|
|
|
.lambdaQuery(TeacherOpenCourseStudentSigninLog.class)
|
|
|
.andEq(TeacherOpenCourseStudentSigninLog::getTeacherOpenCourseStudentSigninSettingId, signinSetting.getTeacherOpenCourseStudentSigninSettingId())
|
|
|
.andEq(TeacherOpenCourseStudentSigninLog::getTeacherOpenCourseStudentSigninLogTag,UN_SIGN_IN)
|
|
|
.andEq(TeacherOpenCourseStudentSigninLog::getStudentId,student.getStudentId())
|
|
|
.andEq(TeacherOpenCourseStudentSigninLog::getSchoolClassId,student.getClassId())
|
|
|
.single();
|
|
|
if (ObjectUtil.isNotNull(single)){
|
|
|
single.setTeacherOpenCourseStudentSigninLogRemark(null);
|
|
|
single.setTeacherOpenCourseStudentSigninLogTag(SIGN_IN);
|
|
|
single.setTeacherOpenCourseStudentSigninLogAddTime(new Date());
|
|
|
single.setTeacherOpenCourseStudentSigninLogIp(myIpAddress);
|
|
|
teacherOpenCourseStudentSigninLogDao.upsertByTemplate(single);
|
|
|
}else {
|
|
|
// 学生签到记录添加
|
|
|
add(signinLogQuery);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 手动签到
|
|
|
*
|
|
|
* @param signinDTO
|
|
|
* @param signinSetting
|
|
|
*/
|
|
|
public void manualSignInHandler(@Validated TeacherOpenCourseStudentSigninLogSigninDTO signinDTO,
|
|
|
@NotNull(message = "签到配置不能为空!") TeacherOpenCourseStudentSigninSetting signinSetting) {
|
|
|
|
|
|
teacherOpenCourseStudentSigninLogSigninDTOValidator.validator(signinDTO).validatorBySetting(signinSetting);
|
|
|
|
|
|
// 获取学生信息
|
|
|
Student student = getStudent();
|
|
|
Assert.notNull(student, "IP签到方式,只允许学生进行操作!");
|
|
|
// 获取学生信息
|
|
|
Assert.isTrue(schoolClassIdJudgment(student.getClassId(), signinSetting), "该学生所在的班级不符合签到要求!");
|
|
|
|
|
|
// 构建实体
|
|
|
TeacherOpenCourseStudentSigninLogQuery signinLogQuery = new TeacherOpenCourseStudentSigninLogQuery();
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninSettingSessionTime(signinSetting.getTeacherOpenCourseStudentSigninSettingSessionTime().toString());
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninSettingId(signinSetting.getTeacherOpenCourseStudentSigninSettingId());
|
|
|
signinLogQuery.setTeacherOpenCourseId(signinSetting.getTeacherOpenCourseId());
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninLogType(manual_signin.name());
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninLogIp(getIpAddr(getRequest()));
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninLogTag(signinDTO.getIsAbsent() ? UN_SIGN_IN : SIGN_IN);
|
|
|
signinLogQuery.setSchoolClassId(student.getClassId());
|
|
|
signinLogQuery.setStudentId(student.getStudentId());
|
|
|
|
|
|
// 是否缺勤
|
|
|
if(BooleanUtil.isTrue(signinDTO.getIsAbsent())) {
|
|
|
// 断言验证缺勤时候,必传的字段
|
|
|
BeanValidationResult isAbsentValidationResult = ValidationUtil.warpValidate(signinDTO, ManualClass.class);
|
|
|
Assert.isTrue(isAbsentValidationResult.isSuccess(), () -> getFirstErrorMessage(isAbsentValidationResult.getErrorMessages()));
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninLogRemark(signinDTO.getTeacherOpenCourseStudentSigninLogRemark());
|
|
|
}
|
|
|
// 学生签到记录添加
|
|
|
add(signinLogQuery);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 验证码签到
|
|
|
*
|
|
|
* @param signinDTO
|
|
|
* @param signinSetting
|
|
|
*/
|
|
|
public void codeSignInHandler(@Validated TeacherOpenCourseStudentSigninLogSigninDTO signinDTO,
|
|
|
@NotNull(message = "签到配置不能为空!") TeacherOpenCourseStudentSigninSetting signinSetting) {
|
|
|
|
|
|
teacherOpenCourseStudentSigninLogSigninDTOValidator.validator(signinDTO).validatorBySetting(signinSetting);
|
|
|
|
|
|
// 获取登录用户,教师身份不支持IP签到,教师只能手动签到
|
|
|
// 获取学生信息
|
|
|
Student student = getStudent();
|
|
|
Assert.notNull(student, "验证码签到方式,只允许学生进行操作!");
|
|
|
// 获取学生信息
|
|
|
Assert.isTrue(schoolClassIdJudgment(student.getClassId(), signinSetting), "该学生所在的班级不符合签到要求!");
|
|
|
|
|
|
Date time = new Date();
|
|
|
Date startTime = signinSetting.getTeacherOpenCourseStudentSigninSettingStartTime();
|
|
|
Date endTime = signinSetting.getTeacherOpenCourseStudentSigninSettingEndTime();
|
|
|
if (Objects.isNull(startTime)){
|
|
|
Assert.notNull(null, "未开始签到");
|
|
|
}
|
|
|
|
|
|
if (startTime.getTime() > time.getTime()){
|
|
|
Assert.notNull(null, "未开始签到");
|
|
|
}
|
|
|
|
|
|
if (!Objects.isNull(endTime) && endTime.getTime() < time.getTime()){
|
|
|
Assert.notNull(null, "已结束签到");
|
|
|
}
|
|
|
|
|
|
// 断言,验证码验证
|
|
|
boolean verificationSuccess = signinSetting.getTeacherOpenCourseStudentSigninSettingValue().equals(signinDTO.getVerificationCode());
|
|
|
Assert.isTrue(verificationSuccess, "错误的验证码,签到失败!");
|
|
|
|
|
|
// 构建实体
|
|
|
TeacherOpenCourseStudentSigninLogQuery signinLogQuery = new TeacherOpenCourseStudentSigninLogQuery();
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninSettingSessionTime(signinSetting.getTeacherOpenCourseStudentSigninSettingSessionTime().toString());
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninSettingId(signinSetting.getTeacherOpenCourseStudentSigninSettingId());
|
|
|
signinLogQuery.setTeacherOpenCourseId(signinSetting.getTeacherOpenCourseId());
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninLogType(code_signin.name());
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninLogIp(getIpAddr(getRequest()));
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninLogTag(SIGN_IN);
|
|
|
signinLogQuery.setStudentId(student.getStudentId());
|
|
|
signinLogQuery.setSchoolClassId(student.getClassId());
|
|
|
signinLogQuery.setOrgId(student.getOrgId());
|
|
|
signinLogQuery.setUserId(student.getUserId());
|
|
|
|
|
|
TeacherOpenCourseStudentSigninLog single = teacherOpenCourseStudentSigninLogDao.getSQLManager()
|
|
|
.lambdaQuery(TeacherOpenCourseStudentSigninLog.class)
|
|
|
.andEq(TeacherOpenCourseStudentSigninLog::getTeacherOpenCourseStudentSigninSettingId, signinSetting.getTeacherOpenCourseStudentSigninSettingId())
|
|
|
.andEq(TeacherOpenCourseStudentSigninLog::getTeacherOpenCourseStudentSigninLogTag,UN_SIGN_IN)
|
|
|
.andEq(TeacherOpenCourseStudentSigninLog::getStudentId,student.getStudentId())
|
|
|
.andEq(TeacherOpenCourseStudentSigninLog::getSchoolClassId,student.getClassId())
|
|
|
.single();
|
|
|
if (ObjectUtil.isNotNull(single)){
|
|
|
single.setTeacherOpenCourseStudentSigninLogRemark(null);
|
|
|
single.setTeacherOpenCourseStudentSigninLogTag(SIGN_IN);
|
|
|
single.setTeacherOpenCourseStudentSigninLogAddTime(new Date());
|
|
|
teacherOpenCourseStudentSigninLogDao.upsertByTemplate(single);
|
|
|
}else {
|
|
|
// 学生签到记录添加
|
|
|
add(signinLogQuery);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public JsonResult importTemplate(List<FileEntity> fileEntityList, List<Long>list, CoreUser coreUser){
|
|
|
List<String[]>errMsg = new ArrayList<>();
|
|
|
String msg ="";
|
|
|
int count = 0;
|
|
|
Date date = new Date();
|
|
|
for(int item=0;null != fileEntityList && item<fileEntityList.size();item++){
|
|
|
FileEntity fileEntity = fileEntityList.get(item);
|
|
|
if(null != fileEntity){
|
|
|
File file = new File(fileEntity.getAbsoluteUrl());
|
|
|
if(file.exists() && file.isFile() && file.canRead() && ToolUtils.findInSet("xls,xlsx",fileEntity.getFormat())){
|
|
|
Workbook wb = null;
|
|
|
InputStream is = null;
|
|
|
try {
|
|
|
is = new FileInputStream(fileEntity.getAbsoluteUrl());
|
|
|
if("xls".equals(fileEntity.getFormat())){
|
|
|
wb = new HSSFWorkbook(is);
|
|
|
}else if("xlsx".equals(fileEntity.getFormat())){
|
|
|
wb = new XSSFWorkbook(is);
|
|
|
}
|
|
|
} catch (FileNotFoundException e) {
|
|
|
e.printStackTrace();
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
try {
|
|
|
if(null != is){
|
|
|
is.close();
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
if(wb != null){
|
|
|
//获取Sheet1
|
|
|
Sheet sheet = wb.getSheet("Sheet1");
|
|
|
//获取最大行数
|
|
|
int rowNum = sheet.getPhysicalNumberOfRows();
|
|
|
//获取第一行
|
|
|
Row firstRow = sheet.getRow(0);
|
|
|
//获取最大列数
|
|
|
int colNum = firstRow.getPhysicalNumberOfCells();
|
|
|
String[] columns = {
|
|
|
"签到配置",
|
|
|
"场次时间",
|
|
|
"学生",
|
|
|
"开课",
|
|
|
"班级",
|
|
|
"签到日期",
|
|
|
"签到方式 ",
|
|
|
"备注",
|
|
|
"签到的IP",
|
|
|
"标记 10签到 20缺勤",
|
|
|
};
|
|
|
Map<String,Integer> map = new HashMap<>();//获取需要的表头的列
|
|
|
//从第一列找到需要的表头
|
|
|
for (int i=0; i<colNum; i++){
|
|
|
String cellData = getCellFormatValue(firstRow.getCell(i));
|
|
|
for(int j=0;j<columns.length;j++){
|
|
|
if(columns[j].equals(cellData)){
|
|
|
map.put(columns[j],i);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//验证所需要的表头是否全
|
|
|
Integer flag = 0;
|
|
|
for(int i=0;i<columns.length;i++){
|
|
|
if(null != map.get(columns[i])){
|
|
|
flag ++;
|
|
|
}
|
|
|
}
|
|
|
if(flag != columns.length){
|
|
|
String str = " ";
|
|
|
for(int i=0;i<columns.length;i++){
|
|
|
str += "\""+columns[i]+"\""+(i == columns.length-1?"":", ");
|
|
|
}
|
|
|
return JsonResult.failMessage("导入失败,表格表头应包含"+str);
|
|
|
}
|
|
|
for (int i = 1; i<rowNum; i++) {
|
|
|
Row row = sheet.getRow(i);
|
|
|
if(null == row){
|
|
|
errMsg.add(new String[]{"第"+(i+1)+"数据为空"});
|
|
|
continue;
|
|
|
}
|
|
|
String teacherOpenCourseStudentSigninSettingId = getCellFormatValue(row.getCell(map.get(columns[0])));
|
|
|
String teacherOpenCourseStudentSigninSettingSessionTime = getCellFormatValue(row.getCell(map.get(columns[1])));
|
|
|
String studentId = getCellFormatValue(row.getCell(map.get(columns[2])));
|
|
|
String teacherOpenCourseId = getCellFormatValue(row.getCell(map.get(columns[3])));
|
|
|
String schoolClassId = getCellFormatValue(row.getCell(map.get(columns[4])));
|
|
|
String teacherOpenCourseStudentSigninLogAddTime = getCellFormatValue(row.getCell(map.get(columns[5])));
|
|
|
String teacherOpenCourseStudentSigninLogType = getCellFormatValue(row.getCell(map.get(columns[6])));
|
|
|
String teacherOpenCourseStudentSigninLogRemark = getCellFormatValue(row.getCell(map.get(columns[7])));
|
|
|
String teacherOpenCourseStudentSigninLogIp = getCellFormatValue(row.getCell(map.get(columns[8])));
|
|
|
String teacherOpenCourseStudentSigninLogTag = getCellFormatValue(row.getCell(map.get(columns[9])));
|
|
|
//TODO 判断(如重复等复杂判断要额外写)
|
|
|
if(StringUtils.isBlank(teacherOpenCourseStudentSigninSettingId)){
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[0])+1)+"列,第"+(i+1)+"行签到配置为空"});
|
|
|
continue;
|
|
|
}else
|
|
|
if(StringUtils.isBlank(teacherOpenCourseStudentSigninSettingSessionTime)){
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[1])+1)+"列,第"+(i+1)+"行场次时间为空"});
|
|
|
continue;
|
|
|
}else
|
|
|
if(StringUtils.isBlank(studentId)){
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[2])+1)+"列,第"+(i+1)+"行学生为空"});
|
|
|
continue;
|
|
|
}else
|
|
|
if(StringUtils.isBlank(teacherOpenCourseId)){
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[3])+1)+"列,第"+(i+1)+"行开课为空"});
|
|
|
continue;
|
|
|
}else
|
|
|
if(StringUtils.isBlank(schoolClassId)){
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[4])+1)+"列,第"+(i+1)+"行班级为空"});
|
|
|
continue;
|
|
|
}else
|
|
|
if(StringUtils.isBlank(teacherOpenCourseStudentSigninLogAddTime)){
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[5])+1)+"列,第"+(i+1)+"行签到日期为空"});
|
|
|
continue;
|
|
|
}else
|
|
|
if(StringUtils.isBlank(teacherOpenCourseStudentSigninLogType)){
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[6])+1)+"列,第"+(i+1)+"行签到方式 为空"});
|
|
|
continue;
|
|
|
}else
|
|
|
if(StringUtils.isBlank(teacherOpenCourseStudentSigninLogRemark)){
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[7])+1)+"列,第"+(i+1)+"行备注为空"});
|
|
|
continue;
|
|
|
}else
|
|
|
if(StringUtils.isBlank(teacherOpenCourseStudentSigninLogIp)){
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[8])+1)+"列,第"+(i+1)+"行签到的IP为空"});
|
|
|
continue;
|
|
|
}else
|
|
|
if(StringUtils.isBlank(teacherOpenCourseStudentSigninLogTag)){
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[9])+1)+"列,第"+(i+1)+"行标记 10签到 20缺勤为空"});
|
|
|
continue;
|
|
|
}else
|
|
|
{
|
|
|
//TODO 保存
|
|
|
TeacherOpenCourseStudentSigninLog teacherOpenCourseStudentSigninLog = new TeacherOpenCourseStudentSigninLog();
|
|
|
teacherOpenCourseStudentSigninLog.setTeacherOpenCourseStudentSigninSettingId(Long.parseLong(teacherOpenCourseStudentSigninSettingId));
|
|
|
teacherOpenCourseStudentSigninLog.setTeacherOpenCourseStudentSigninSettingSessionTime(TimeTool.getTime(teacherOpenCourseStudentSigninSettingSessionTime));
|
|
|
teacherOpenCourseStudentSigninLog.setStudentId(Long.parseLong(studentId));
|
|
|
teacherOpenCourseStudentSigninLog.setTeacherOpenCourseId(Long.parseLong(teacherOpenCourseId));
|
|
|
teacherOpenCourseStudentSigninLog.setSchoolClassId(Long.parseLong(schoolClassId));
|
|
|
teacherOpenCourseStudentSigninLog.setTeacherOpenCourseStudentSigninLogAddTime(TimeTool.getTime(teacherOpenCourseStudentSigninLogAddTime));
|
|
|
teacherOpenCourseStudentSigninLog.setTeacherOpenCourseStudentSigninLogType(teacherOpenCourseStudentSigninLogType);
|
|
|
teacherOpenCourseStudentSigninLog.setTeacherOpenCourseStudentSigninLogRemark(teacherOpenCourseStudentSigninLogRemark);
|
|
|
teacherOpenCourseStudentSigninLog.setTeacherOpenCourseStudentSigninLogIp(teacherOpenCourseStudentSigninLogIp);
|
|
|
teacherOpenCourseStudentSigninLog.setTeacherOpenCourseStudentSigninLogTag(EnumUtil
|
|
|
.likeValueOf(SignInTypeEnum.class, teacherOpenCourseStudentSigninLogTag));
|
|
|
teacherOpenCourseStudentSigninLog.setOrgId(coreUser.getOrgId());
|
|
|
teacherOpenCourseStudentSigninLog.setUserId(coreUser.getId());
|
|
|
count++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
JsonResult jsonResult = new JsonResult();
|
|
|
jsonResult.setCode(count>0?JsonReturnCode.SUCCESS.getCode():JsonReturnCode.FAIL.getCode());
|
|
|
jsonResult.setData(errMsg);
|
|
|
jsonResult.setMsg((count>0?"导入成功,共导入"+count+"条":"导入失败")+(StringUtils.isNotBlank(msg)?"<br>"+msg:""));
|
|
|
return jsonResult;
|
|
|
}
|
|
|
public List<Map<String,Object>> getExcelValues (TeacherOpenCourseStudentSigninLogQuery teacherOpenCourseStudentSigninLogQuery){
|
|
|
return teacherOpenCourseStudentSigninLogDao.getExcelValues(teacherOpenCourseStudentSigninLogQuery);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 教师端-手动签到逻辑
|
|
|
* @param dto
|
|
|
* @return
|
|
|
*/
|
|
|
public void manualSigninAdd(@NotNull(message = "手动签到参数不能为空!") TeacherOpenCourseStudentSigninLogManualMergeDTO dto) {
|
|
|
|
|
|
// 获取当前登录用户信息
|
|
|
final CoreUser operatorUser = getUser();
|
|
|
final HttpServletRequest request = getRequest();
|
|
|
|
|
|
// 添加我签到配置
|
|
|
TeacherOpenCourseStudentSigninSettingManualDTO signinSetting = dto.getSigninSetting();
|
|
|
TeacherOpenCourseStudentSigninSetting entity = new TeacherOpenCourseStudentSigninSetting();
|
|
|
|
|
|
// 拷贝前端传过来的值
|
|
|
BeanUtil.copyProperties(signinSetting, entity);
|
|
|
DateTime now = DateUtil.date();
|
|
|
|
|
|
//获取现在的时间 精确到分
|
|
|
|
|
|
// 默认的一些属性填充。添加主表
|
|
|
DateTime parse = DateUtil.parse(DateUtil.format(now, "yyyy-MM-dd HH:mm"), "yyyy-MM-dd HH:mm");
|
|
|
entity.setTeacherOpenCourseStudentSigninSettingSessionTime(parse);
|
|
|
|
|
|
entity.setTeacherOpenCourseStudentSigninSettingStartTime(now);
|
|
|
entity.setTeacherOpenCourseStudentSigninSettingEndTime(now);
|
|
|
entity.setTeacherOpenCourseStudentSigninSettingAddTime(now);
|
|
|
entity.setTeacherOpenCourseStudentSigninSettingType(manual_signin.name());
|
|
|
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 = 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);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 缺勤
|
|
|
* @param id
|
|
|
* @param logTypeEnum
|
|
|
*/
|
|
|
public void studentAbsence(@NotNull(message = "签到配置ID不能为空!") Long id,
|
|
|
@NotNull(message = "签到状态不能为空!")
|
|
|
TeacherOpenCourseStudentSigninLogSigninDTO.TeacherOpenCourseStudentSigninLogTypeEnum logTypeEnum){
|
|
|
final HttpServletRequest request = getRequest();
|
|
|
//获取签到班级
|
|
|
TeacherOpenCourseStudentSigninSetting single = teacherOpenCourseStudentSigninSettingDao.getSQLManager().lambdaQuery(TeacherOpenCourseStudentSigninSetting.class)
|
|
|
.andEq(TeacherOpenCourseStudentSigninSetting::getTeacherOpenCourseStudentSigninSettingId, id)
|
|
|
.single();
|
|
|
|
|
|
if (!Objects.isNull(single)){
|
|
|
StudentQuery studentQuery = new StudentQuery();
|
|
|
studentQuery.setClassIds(single.getSchoolClassIds());
|
|
|
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());
|
|
|
studentList.forEach(item ->{
|
|
|
TeacherOpenCourseStudentSigninLog studentSignInLog = teacherOpenCourseStudentSigninLogDao.getSQLManager()
|
|
|
.lambdaQuery(TeacherOpenCourseStudentSigninLog.class)
|
|
|
.andEq(TeacherOpenCourseStudentSigninLog::getTeacherOpenCourseStudentSigninSettingId, single.getTeacherOpenCourseStudentSigninSettingId())
|
|
|
.andEq(TeacherOpenCourseStudentSigninLog::getStudentId, item.getStudentId())
|
|
|
.andEq(TeacherOpenCourseStudentSigninLog::getTeacherOpenCourseId, single.getTeacherOpenCourseId())
|
|
|
.single();
|
|
|
|
|
|
if (Objects.isNull(studentSignInLog)){
|
|
|
DateTime date = DateUtil.date();
|
|
|
TeacherOpenCourseStudentSigninLog signInLog = new TeacherOpenCourseStudentSigninLog();
|
|
|
signInLog.setTeacherOpenCourseStudentSigninSettingId(single.getTeacherOpenCourseStudentSigninSettingId());
|
|
|
signInLog.setTeacherOpenCourseStudentSigninSettingSessionTime(date);
|
|
|
signInLog.setStudentId(item.getStudentId());
|
|
|
signInLog.setTeacherOpenCourseId(single.getTeacherOpenCourseId());
|
|
|
signInLog.setSchoolClassId(item.getClassId());
|
|
|
signInLog.setTeacherOpenCourseStudentSigninLogAddTime(date);
|
|
|
signInLog.setTeacherOpenCourseStudentSigninLogType(logTypeEnum.toString());
|
|
|
signInLog.setTeacherOpenCourseStudentSigninLogIp(getIpAddr(Objects.requireNonNull(request)));
|
|
|
signInLog.setTeacherOpenCourseStudentSigninLogTag(UN_SIGN_IN);
|
|
|
signInLog.setOrgId(single.getOrgId());
|
|
|
signInLog.setUserId(item.getUserId());
|
|
|
teacherOpenCourseStudentSigninLogDao.insert(signInLog);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 签到汇总
|
|
|
* @param teacherOpenCourseId
|
|
|
*/
|
|
|
public TeacherOpenCourseStudentSigninLogSummaryVO summary(@NotNull(message = "开课ID不能为空!") Long teacherOpenCourseId) {
|
|
|
return teacherOpenCourseStudentSigninLogDao.summary(teacherOpenCourseId);
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void resetOperationByTeacherOpenCourseId(Long teacherOpenCourseId) {
|
|
|
log.info("可能需要实现重置操作!");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void deleteTeacherOpenCourseAllRelatedByTeacherOpenCourseId(@NotNull(message = "开课ID不能为空!") Long teacherOpenCourseId) {
|
|
|
log.info("需要实现删除操作!");
|
|
|
}
|
|
|
}
|