|
|
|
@ -15,6 +15,7 @@ import com.sztzjy.trade.config.Constant;
|
|
|
|
|
import com.sztzjy.trade.entity.*;
|
|
|
|
|
import com.sztzjy.trade.entity.dto.*;
|
|
|
|
|
import com.sztzjy.trade.enums.StartStatusEnum;
|
|
|
|
|
import com.sztzjy.trade.mapper.StuLearningRecordMapper;
|
|
|
|
|
import com.sztzjy.trade.mapper.StuUserMapper;
|
|
|
|
|
import com.sztzjy.trade.mapper.TeacherOpenCourseStudentSigninLogMapper;
|
|
|
|
|
import com.sztzjy.trade.mapper.TeacherOpenCourseStudentSigninSettingMapper;
|
|
|
|
@ -26,6 +27,7 @@ import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
@ -46,6 +48,9 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
|
|
|
|
|
@Autowired
|
|
|
|
|
private TeacherOpenCourseStudentSigninLogMapper teacherOpenCourseStudentSigninLogMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private StuLearningRecordMapper stuLearningRecordMapper;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ResultEntity addDo(TeacherOpenCourseStudentSigninSettingDTO teacherOpenCourseStudentSigninSettingDTO) {
|
|
|
|
|
|
|
|
|
@ -191,6 +196,10 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
|
|
|
|
|
//查询是否为多次插入
|
|
|
|
|
TeacherOpenCourseStudentSigninSetting teacherOpenCourseStudentSigninSetting =
|
|
|
|
|
teacherOpenCourseStudentSigninSettingMapper.selectByPrimaryKey(tchManualSignDTO.getTeacherOpenCourseStudentSigninSettingId());
|
|
|
|
|
//已签到数据
|
|
|
|
|
List<TeacherOpenCourseStudentSigninLog> list = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
List<TeacherOpenCourseStudentSigninLog> notSignList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
if (teacherOpenCourseStudentSigninSetting != null) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "请勿重复操作!");
|
|
|
|
@ -228,15 +237,120 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
|
|
|
|
|
.teacherOpenCourseStudentSigninLogType(Constant.MANUAL)
|
|
|
|
|
.teacherOpenCourseStudentSigninLogRemark(item.getTeacherOpenCourseStudentSigninLogRemark())
|
|
|
|
|
.userId(item.getUserId()).build();
|
|
|
|
|
list.add(studentSigninLog);
|
|
|
|
|
teacherOpenCourseStudentSigninLogMapper.insertSelective(studentSigninLog);
|
|
|
|
|
|
|
|
|
|
//写入学习记录中
|
|
|
|
|
updateLearningRecord(studentSigninLog);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//TODO 未被抽中用户数据 进行全部签到操作
|
|
|
|
|
|
|
|
|
|
//查询班级所有用户
|
|
|
|
|
String[] split = tchManualSignDTO.getClassIds().split(",");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StuUserExample userExample = new StuUserExample();
|
|
|
|
|
userExample.createCriteria().andClassIdIn(Arrays.stream(split).collect(Collectors.toList()));
|
|
|
|
|
//查询多个班级所有学生
|
|
|
|
|
List<StuUser> stuUserList = stuUserMapper.selectByExample(userExample);
|
|
|
|
|
if (stuUserList.isEmpty()) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK);
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
for (StuUser stuUser : stuUserList) {
|
|
|
|
|
boolean found = false;
|
|
|
|
|
for (TeacherOpenCourseStudentSigninLog studentSigninLog : list) {
|
|
|
|
|
if (stuUser.getStudentId().equals(studentSigninLog.getStudentId())) {
|
|
|
|
|
found = true;
|
|
|
|
|
break; // 找到匹配项,跳出内层循环
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!found) {
|
|
|
|
|
// 如果没有找到匹配项,加入新数据到 teacherOpenCourseStudentSigninLogList
|
|
|
|
|
TeacherOpenCourseStudentSigninLog teacherOpenCourseStudentSigninLog = TeacherOpenCourseStudentSigninLog.builder()
|
|
|
|
|
.studentId(stuUser.getStudentId())
|
|
|
|
|
.teacherOpenCourseStudentSigninLogAddTime(list.get(0).getTeacherOpenCourseStudentSigninLogAddTime())
|
|
|
|
|
.teacherOpenCourseStudentSigninLogTag(10)
|
|
|
|
|
.userId(Convert.toLong(stuUser.getUserId()))
|
|
|
|
|
.teacherOpenCourseStudentSigninSettingId(tchManualSignDTO.getTeacherOpenCourseStudentSigninSettingId())
|
|
|
|
|
.teacherOpenCourseStudentSigninSettingSessionTime(tchManualSignDTO.getTeacherOpenCourseStudentSigninSettingSessionTime())
|
|
|
|
|
.teacherOpenCourseId(tchManualSignDTO.getTeacherOpenCourseId())
|
|
|
|
|
.schoolClassId(Long.parseLong(stuUser.getClassId())).build();
|
|
|
|
|
notSignList.add(teacherOpenCourseStudentSigninLog);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//遍历数据写入数据库
|
|
|
|
|
notSignList.forEach(item -> {
|
|
|
|
|
//写入学习记录中
|
|
|
|
|
updateLearningRecord(item);
|
|
|
|
|
//写入签到记录中
|
|
|
|
|
insertSignLog(item);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "操作成功!");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//学习记录
|
|
|
|
|
public void updateLearningRecord(TeacherOpenCourseStudentSigninLog item) {
|
|
|
|
|
StuLearningRecord stuLearningRecord = stuLearningRecordMapper.selectByUserId(item.getUserId().toString());
|
|
|
|
|
|
|
|
|
|
if (stuLearningRecord == null) {
|
|
|
|
|
StuLearningRecord record = new StuLearningRecord(item.getUserId().toString());
|
|
|
|
|
|
|
|
|
|
int i = UUID.randomUUID().hashCode();
|
|
|
|
|
if (i <0)
|
|
|
|
|
{
|
|
|
|
|
i = -i;
|
|
|
|
|
}
|
|
|
|
|
record.setId(i);
|
|
|
|
|
record.setUserId(item.getUserId().toString());
|
|
|
|
|
record.setNumberOfAbsences(0);
|
|
|
|
|
record.setLearningDuration(0);
|
|
|
|
|
record.setCheckInFrequency(0);
|
|
|
|
|
record.setTrainingProgress(0.0);
|
|
|
|
|
record.setNumberOfInteractions(0);
|
|
|
|
|
|
|
|
|
|
stuLearningRecordMapper.insertSelective(record);
|
|
|
|
|
stuLearningRecord = record;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//随机抽取的用户数据同时记录签到和缺勤次数
|
|
|
|
|
if (item.getTeacherOpenCourseStudentSigninLogTag() == 10) {
|
|
|
|
|
//写入的是已签到和未签到抽取的用户
|
|
|
|
|
stuLearningRecord.setCheckInFrequency(stuLearningRecord.getCheckInFrequency() + 1);
|
|
|
|
|
|
|
|
|
|
} else if (item.getTeacherOpenCourseStudentSigninLogTag() == 20) {
|
|
|
|
|
stuLearningRecord.setNumberOfAbsences(stuLearningRecord.getNumberOfAbsences() + 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, "操作成功!");
|
|
|
|
|
stuLearningRecordMapper.updateByPrimaryKeySelective(stuLearningRecord);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void insertSignLog(TeacherOpenCourseStudentSigninLog item){
|
|
|
|
|
//判断是否缺勤或者签到
|
|
|
|
|
TeacherOpenCourseStudentSigninLog studentSigninLog = TeacherOpenCourseStudentSigninLog.builder()
|
|
|
|
|
.teacherOpenCourseStudentSigninSettingId(item.getTeacherOpenCourseStudentSigninSettingId())
|
|
|
|
|
.teacherOpenCourseStudentSigninSettingSessionTime(item.getTeacherOpenCourseStudentSigninSettingSessionTime())
|
|
|
|
|
.studentId(item.getStudentId())
|
|
|
|
|
.teacherOpenCourseStudentSigninLogTag(item.getTeacherOpenCourseStudentSigninLogTag())
|
|
|
|
|
.teacherOpenCourseId(item.getTeacherOpenCourseId())
|
|
|
|
|
.schoolClassId(item.getSchoolClassId())
|
|
|
|
|
.teacherOpenCourseStudentSigninLogAddTime(item.getTeacherOpenCourseStudentSigninLogAddTime())
|
|
|
|
|
.teacherOpenCourseStudentSigninLogType(Constant.MANUAL)
|
|
|
|
|
.teacherOpenCourseStudentSigninLogRemark(item.getTeacherOpenCourseStudentSigninLogRemark())
|
|
|
|
|
.userId(item.getUserId()).build();
|
|
|
|
|
|
|
|
|
|
teacherOpenCourseStudentSigninLogMapper.insertSelective(studentSigninLog);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -442,14 +556,14 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
|
|
|
|
|
String classId, Integer page,
|
|
|
|
|
Integer size, Date signTime,
|
|
|
|
|
Integer signInfo,
|
|
|
|
|
String missInfo, Long signId, String classIds
|
|
|
|
|
) {
|
|
|
|
|
String missInfo, Long signId, String classIds) {
|
|
|
|
|
//开启分页
|
|
|
|
|
PageHelper.startPage(page, size);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//开始时间,结束时间,签到情况,缺勤理由 {班级ID,签到ID(默认查询)} 根据签到方式展示老师手动签到学生信息,其他学生默认全部签到
|
|
|
|
|
TeacherOpenCourseStudentSigninLogExample openCourseStudentSigninLogExample = new TeacherOpenCourseStudentSigninLogExample();
|
|
|
|
|
openCourseStudentSigninLogExample.setOrderByClause("school_class_id desc");
|
|
|
|
|
TeacherOpenCourseStudentSigninLogExample.Criteria criteria = openCourseStudentSigninLogExample.createCriteria();
|
|
|
|
|
if (StringUtils.hasText(classIds)) {
|
|
|
|
|
String[] split = classIds.split(",");
|
|
|
|
@ -458,7 +572,7 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
|
|
|
|
|
.map(Long::valueOf) // 将每个字符串转换为 Long
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
criteria.andSchoolClassIdIn(collect);
|
|
|
|
|
System.out.println(collect);
|
|
|
|
|
//System.out.println(collect);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StringUtils.hasText(studentId)) {
|
|
|
|
@ -493,56 +607,57 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//查询班级所有用户
|
|
|
|
|
String[] split = classIds.split(",");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StuUserExample userExample = new StuUserExample();
|
|
|
|
|
userExample.createCriteria().andClassIdIn(Arrays.stream(split).collect(Collectors.toList()));
|
|
|
|
|
List<StuUser> stuUserList = stuUserMapper.selectByExample(userExample);
|
|
|
|
|
if (stuUserList.isEmpty()) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK);
|
|
|
|
|
} else {
|
|
|
|
|
// //查询班级所有用户
|
|
|
|
|
// String[] split = classIds.split(",");
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// StuUserExample userExample = new StuUserExample();
|
|
|
|
|
// userExample.createCriteria().andClassIdIn(Arrays.stream(split).collect(Collectors.toList()));
|
|
|
|
|
// //查询多个班级所有学生
|
|
|
|
|
// List<StuUser> stuUserList = stuUserMapper.selectByExample(userExample);
|
|
|
|
|
// if (stuUserList.isEmpty()) {
|
|
|
|
|
// return new ResultEntity<>(HttpStatus.OK);
|
|
|
|
|
// } else {
|
|
|
|
|
//// for (StuUser stuUser : stuUserList) {
|
|
|
|
|
//// for (TeacherOpenCourseStudentSigninLog studentSigninLog : teacherOpenCourseStudentSigninLogList) {
|
|
|
|
|
//// if (stuUser.getStudentId().equals(studentSigninLog.getStudentId())) {
|
|
|
|
|
//// continue;
|
|
|
|
|
//// } else {
|
|
|
|
|
//// //加入往里面加数据teacherOpenCourseStudentSigninLogList
|
|
|
|
|
//// TeacherOpenCourseStudentSigninLog teacherOpenCourseStudentSigninLog = TeacherOpenCourseStudentSigninLog.builder()
|
|
|
|
|
//// .studentId(stuUser.getStudentId())
|
|
|
|
|
//// .teacherOpenCourseStudentSigninLogAddTime(teacherOpenCourseStudentSigninLogList.get(0).getTeacherOpenCourseStudentSigninLogAddTime())
|
|
|
|
|
//// .teacherOpenCourseStudentSigninLogTag(10)
|
|
|
|
|
//// .schoolClassId(Long.parseLong(stuUser.getClassId())).build();
|
|
|
|
|
//// teacherOpenCourseStudentSigninLogList.add(teacherOpenCourseStudentSigninLog);
|
|
|
|
|
//// }
|
|
|
|
|
////
|
|
|
|
|
//// }
|
|
|
|
|
////
|
|
|
|
|
////
|
|
|
|
|
//// }
|
|
|
|
|
// for (StuUser stuUser : stuUserList) {
|
|
|
|
|
// boolean found = false;
|
|
|
|
|
// for (TeacherOpenCourseStudentSigninLog studentSigninLog : teacherOpenCourseStudentSigninLogList) {
|
|
|
|
|
// if (stuUser.getStudentId().equals(studentSigninLog.getStudentId())) {
|
|
|
|
|
// continue;
|
|
|
|
|
// } else {
|
|
|
|
|
// //加入往里面加数据teacherOpenCourseStudentSigninLogList
|
|
|
|
|
// TeacherOpenCourseStudentSigninLog teacherOpenCourseStudentSigninLog = TeacherOpenCourseStudentSigninLog.builder()
|
|
|
|
|
// .studentId(stuUser.getStudentId())
|
|
|
|
|
// .teacherOpenCourseStudentSigninLogAddTime(teacherOpenCourseStudentSigninLogList.get(0).getTeacherOpenCourseStudentSigninLogAddTime())
|
|
|
|
|
// .teacherOpenCourseStudentSigninLogTag(10)
|
|
|
|
|
// .schoolClassId(Long.parseLong(stuUser.getClassId())).build();
|
|
|
|
|
// teacherOpenCourseStudentSigninLogList.add(teacherOpenCourseStudentSigninLog);
|
|
|
|
|
// found = true;
|
|
|
|
|
// break; // 找到匹配项,跳出内层循环
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// if (!found) {
|
|
|
|
|
// // 如果没有找到匹配项,加入新数据到 teacherOpenCourseStudentSigninLogList
|
|
|
|
|
// TeacherOpenCourseStudentSigninLog teacherOpenCourseStudentSigninLog = TeacherOpenCourseStudentSigninLog.builder()
|
|
|
|
|
// .studentId(stuUser.getStudentId())
|
|
|
|
|
// .teacherOpenCourseStudentSigninLogAddTime(teacherOpenCourseStudentSigninLogList.get(0).getTeacherOpenCourseStudentSigninLogAddTime())
|
|
|
|
|
// .teacherOpenCourseStudentSigninLogTag(10)
|
|
|
|
|
// .schoolClassId(Long.parseLong(stuUser.getClassId())).build();
|
|
|
|
|
// teacherOpenCourseStudentSigninLogList.add(teacherOpenCourseStudentSigninLog);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
for (StuUser stuUser : stuUserList) {
|
|
|
|
|
boolean found = false;
|
|
|
|
|
for (TeacherOpenCourseStudentSigninLog studentSigninLog : teacherOpenCourseStudentSigninLogList) {
|
|
|
|
|
if (stuUser.getStudentId().equals(studentSigninLog.getStudentId())) {
|
|
|
|
|
found = true;
|
|
|
|
|
break; // 找到匹配项,跳出内层循环
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!found) {
|
|
|
|
|
// 如果没有找到匹配项,加入新数据到 teacherOpenCourseStudentSigninLogList
|
|
|
|
|
TeacherOpenCourseStudentSigninLog teacherOpenCourseStudentSigninLog = TeacherOpenCourseStudentSigninLog.builder()
|
|
|
|
|
.studentId(stuUser.getStudentId())
|
|
|
|
|
.teacherOpenCourseStudentSigninLogAddTime(teacherOpenCourseStudentSigninLogList.get(0).getTeacherOpenCourseStudentSigninLogAddTime())
|
|
|
|
|
.teacherOpenCourseStudentSigninLogTag(10)
|
|
|
|
|
.schoolClassId(Long.parseLong(stuUser.getClassId())).build();
|
|
|
|
|
teacherOpenCourseStudentSigninLogList.add(teacherOpenCourseStudentSigninLog);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
PageInfo<TeacherOpenCourseStudentSigninLog> courseStudentSigninLogPageInfo = new PageInfo<>(teacherOpenCourseStudentSigninLogList);
|
|
|
|
|
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK, courseStudentSigninLogPageInfo);
|
|
|
|
|
}
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -698,8 +813,7 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
|
|
|
|
|
|
|
|
|
|
StuImportExcelDTO stuImportExcelDTO = new StuImportExcelDTO();
|
|
|
|
|
for (TeacherOpenCourseStudentSigninLog studentSigninLog : teacherOpenCourseStudentSigninLogList) {
|
|
|
|
|
if (stuUser.getStudentId().equals(studentSigninLog.getStudentId()))
|
|
|
|
|
{
|
|
|
|
|
if (stuUser.getStudentId().equals(studentSigninLog.getStudentId())) {
|
|
|
|
|
stuImportExcelDTO.setStudentId(stuUser.getStudentId());
|
|
|
|
|
stuImportExcelDTO.setName(stuUser.getName());
|
|
|
|
|
stuImportExcelDTO.setClassName(stuUser.getClassName());
|
|
|
|
|