|
|
|
@ -10,6 +10,7 @@ import com.alibaba.excel.EasyExcel;
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
|
import com.nimbusds.jose.util.IntegerUtils;
|
|
|
|
|
import com.sztzjy.trade.annotation.AnonymousAccess;
|
|
|
|
|
import com.sztzjy.trade.config.Constant;
|
|
|
|
|
import com.sztzjy.trade.entity.*;
|
|
|
|
|
import com.sztzjy.trade.entity.dto.*;
|
|
|
|
@ -19,12 +20,17 @@ import com.sztzjy.trade.mapper.TeacherOpenCourseStudentSigninLogMapper;
|
|
|
|
|
import com.sztzjy.trade.mapper.TeacherOpenCourseStudentSigninSettingMapper;
|
|
|
|
|
import com.sztzjy.trade.service.TeacherOpenCourseStudentSigninService;
|
|
|
|
|
import com.sztzjy.trade.util.ResultEntity;
|
|
|
|
|
import com.sztzjy.trade.util.excel.FilePortUtil;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
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.util.StringUtils;
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
@ -134,7 +140,7 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
|
|
|
|
|
|
|
|
|
|
// 定义要随机抽取的数量
|
|
|
|
|
int numberOfUsersToSelect = 6;
|
|
|
|
|
String[] split = tchManualSignDTO.getClassIds().split(".");
|
|
|
|
|
String[] split = tchManualSignDTO.getClassIds().split(",");
|
|
|
|
|
|
|
|
|
|
for (String classId : split) {
|
|
|
|
|
numberOfUsersToSelect += 2;
|
|
|
|
@ -206,7 +212,7 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
|
|
|
|
|
|
|
|
|
|
//批量插入学生信息
|
|
|
|
|
|
|
|
|
|
System.out.println(tchManualSignDTO.getTchManualSignSettingDTOList().size());
|
|
|
|
|
//System.out.println(tchManualSignDTO.getTchManualSignSettingDTOList().size());
|
|
|
|
|
tchManualSignDTO.getTchManualSignSettingDTOList().forEach(item -> {
|
|
|
|
|
|
|
|
|
|
//判断是否缺勤或者签到
|
|
|
|
@ -451,6 +457,7 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
|
|
|
|
|
.map(Long::valueOf) // 将每个字符串转换为 Long
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
criteria.andSchoolClassIdIn(collect);
|
|
|
|
|
System.out.println(collect);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StringUtils.hasText(studentId)) {
|
|
|
|
@ -479,14 +486,13 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
|
|
|
|
|
criteria.andTeacherOpenCourseStudentSigninLogTypeEqualTo(type);
|
|
|
|
|
|
|
|
|
|
//往里面加数据teacherOpenCourseStudentSigninLogList
|
|
|
|
|
|
|
|
|
|
List<TeacherOpenCourseStudentSigninLog> teacherOpenCourseStudentSigninLogList =
|
|
|
|
|
teacherOpenCourseStudentSigninLogMapper.selectByExample(openCourseStudentSigninLogExample);
|
|
|
|
|
if (teacherOpenCourseStudentSigninLogList.isEmpty()) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK);
|
|
|
|
|
}
|
|
|
|
|
//查询班级所有用户
|
|
|
|
|
|
|
|
|
|
//查询班级所有用户
|
|
|
|
|
String[] split = classIds.split(",");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -496,7 +502,6 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
|
|
|
|
|
if (stuUserList.isEmpty()) {
|
|
|
|
|
return new ResultEntity<>(HttpStatus.OK);
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
// for (StuUser stuUser : stuUserList) {
|
|
|
|
|
// for (TeacherOpenCourseStudentSigninLog studentSigninLog : teacherOpenCourseStudentSigninLogList) {
|
|
|
|
|
// if (stuUser.getStudentId().equals(studentSigninLog.getStudentId())) {
|
|
|
|
@ -515,7 +520,6 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
for (StuUser stuUser : stuUserList) {
|
|
|
|
|
boolean found = false;
|
|
|
|
|
for (TeacherOpenCourseStudentSigninLog studentSigninLog : teacherOpenCourseStudentSigninLogList) {
|
|
|
|
@ -564,9 +568,165 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
|
|
|
|
|
|
|
|
|
|
//导出
|
|
|
|
|
@Override
|
|
|
|
|
public void importListInfo(String studentId, String type, String classId, Integer page, Integer size, Date signTime, Integer signInfo, String missInfo, Long signId, String classIds) {
|
|
|
|
|
public void importListInfo(HttpServletResponse response, String studentId, String type, String classId, Integer page, Integer size, Date signTime, Integer signInfo, String missInfo, Long signId, String classIds) {
|
|
|
|
|
//导出的表名
|
|
|
|
|
String title = IdUtil.simpleUUID();
|
|
|
|
|
//表中第一行表头字段
|
|
|
|
|
String[] headers = null;
|
|
|
|
|
List<String> listColumn = null;
|
|
|
|
|
headers = new String[]{"姓名", "学号", "班级", "签到情况", "缺勤理由", "签到日期"};
|
|
|
|
|
listColumn = Arrays.asList("name", "studentId", "className", "teacherOpenCourseStudentSigninLogType", "teacherOpenCourseStudentSigninLogRemark", "teacherOpenCourseStudentSigninLogAddTime");
|
|
|
|
|
//实际数据结果集
|
|
|
|
|
|
|
|
|
|
List<StuImportExcelDTO> resultListInfo = resultList(studentId, type, classId, page, size, signTime, signInfo, missInfo, signId, classIds);
|
|
|
|
|
|
|
|
|
|
//具体需要写入excel需要哪些字段,这些字段取自UserReward类,也就是上面的实际数据结果集的泛型
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
FilePortUtil.exportExcel(response, title, headers, resultListInfo, listColumn);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//实际数据结果集
|
|
|
|
|
private List<StuImportExcelDTO> resultList(String studentId, String type, String classId, Integer page, Integer size, Date signTime,
|
|
|
|
|
Integer signInfo, String missInfo, Long signId, String classIds) {
|
|
|
|
|
|
|
|
|
|
List<StuImportExcelDTO> importExcelDTOList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
//开始时间,结束时间,签到情况,缺勤理由 {班级ID,签到ID(默认查询)} 根据签到方式展示老师手动签到学生信息,其他学生默认全部签到
|
|
|
|
|
TeacherOpenCourseStudentSigninLogExample openCourseStudentSigninLogExample = new TeacherOpenCourseStudentSigninLogExample();
|
|
|
|
|
TeacherOpenCourseStudentSigninLogExample.Criteria criteria = openCourseStudentSigninLogExample.createCriteria();
|
|
|
|
|
if (StringUtils.hasText(classIds)) {
|
|
|
|
|
String[] split = classIds.split(",");
|
|
|
|
|
|
|
|
|
|
List<Long> collect = Arrays.stream(split)
|
|
|
|
|
.map(Long::valueOf) // 将每个字符串转换为 Long
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
criteria.andSchoolClassIdIn(collect);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StringUtils.hasText(studentId)) {
|
|
|
|
|
criteria.andStudentIdEqualTo(studentId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (signTime != null) {
|
|
|
|
|
criteria.andTeacherOpenCourseStudentSigninSettingSessionTimeBetween(signTime, signTime);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (signInfo != null) {
|
|
|
|
|
criteria.andTeacherOpenCourseStudentSigninLogTagEqualTo(signInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StringUtils.hasText(missInfo)) {
|
|
|
|
|
criteria.andTeacherOpenCourseStudentSigninLogRemarkEqualTo(missInfo);
|
|
|
|
|
}
|
|
|
|
|
criteria.andTeacherOpenCourseStudentSigninSettingIdEqualTo(signId);
|
|
|
|
|
|
|
|
|
|
//查询班级所有用户
|
|
|
|
|
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 null;
|
|
|
|
|
}
|
|
|
|
|
//手动签到
|
|
|
|
|
if (StringUtils.hasText(type)) {
|
|
|
|
|
|
|
|
|
|
if (Constant.MANUAL.equals(type)) {
|
|
|
|
|
//只能查出来老师手动签到的用户数据 未抽中用户默认已经签到并且要展示出来
|
|
|
|
|
criteria.andTeacherOpenCourseStudentSigninLogTypeEqualTo(type);
|
|
|
|
|
|
|
|
|
|
//往里面加数据teacherOpenCourseStudentSigninLogList
|
|
|
|
|
List<TeacherOpenCourseStudentSigninLog> teacherOpenCourseStudentSigninLogList =
|
|
|
|
|
teacherOpenCourseStudentSigninLogMapper.selectByExample(openCourseStudentSigninLogExample);
|
|
|
|
|
if (teacherOpenCourseStudentSigninLogList.isEmpty()) {
|
|
|
|
|
return null;
|
|
|
|
|
} 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) {
|
|
|
|
|
StuImportExcelDTO stuImportExcelDTO = new StuImportExcelDTO();
|
|
|
|
|
|
|
|
|
|
boolean found = false;
|
|
|
|
|
for (TeacherOpenCourseStudentSigninLog studentSigninLog : teacherOpenCourseStudentSigninLogList) {
|
|
|
|
|
if (stuUser.getStudentId().equals(studentSigninLog.getStudentId())) {
|
|
|
|
|
stuImportExcelDTO.setStudentId(stuUser.getStudentId());
|
|
|
|
|
stuImportExcelDTO.setName(stuUser.getName());
|
|
|
|
|
stuImportExcelDTO.setClassName(stuUser.getClassName());
|
|
|
|
|
stuImportExcelDTO.setTeacherOpenCourseStudentSigninLogAddTime(studentSigninLog.getTeacherOpenCourseStudentSigninLogAddTime());
|
|
|
|
|
stuImportExcelDTO.setTeacherOpenCourseStudentSigninLogType(studentSigninLog.getTeacherOpenCourseStudentSigninLogType() == "manual" ? "手动签到" : studentSigninLog.getTeacherOpenCourseStudentSigninLogType());
|
|
|
|
|
stuImportExcelDTO.setTeacherOpenCourseStudentSigninLogRemark(studentSigninLog.getTeacherOpenCourseStudentSigninLogRemark());
|
|
|
|
|
importExcelDTOList.add(stuImportExcelDTO);
|
|
|
|
|
found = true;
|
|
|
|
|
break; // 找到匹配项,跳出内层循环
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!found) {
|
|
|
|
|
// 如果没有找到匹配项,加入新数据到 teacherOpenCourseStudentSigninLogList
|
|
|
|
|
stuImportExcelDTO.setStudentId(stuUser.getStudentId());
|
|
|
|
|
stuImportExcelDTO.setName(stuUser.getName());
|
|
|
|
|
stuImportExcelDTO.setClassName(stuUser.getClassName());
|
|
|
|
|
stuImportExcelDTO.setTeacherOpenCourseStudentSigninLogAddTime(teacherOpenCourseStudentSigninLogList.get(0).getTeacherOpenCourseStudentSigninLogAddTime());
|
|
|
|
|
stuImportExcelDTO.setTeacherOpenCourseStudentSigninLogType(teacherOpenCourseStudentSigninLogList.get(0).getTeacherOpenCourseStudentSigninLogType() == "manual" ? "手动签到" : teacherOpenCourseStudentSigninLogList.get(0).getTeacherOpenCourseStudentSigninLogType());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
importExcelDTOList.add(stuImportExcelDTO);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return importExcelDTOList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<TeacherOpenCourseStudentSigninLog> teacherOpenCourseStudentSigninLogList =
|
|
|
|
|
teacherOpenCourseStudentSigninLogMapper.selectByExample(openCourseStudentSigninLogExample);
|
|
|
|
|
|
|
|
|
|
for (StuUser stuUser : stuUserList) {
|
|
|
|
|
|
|
|
|
|
StuImportExcelDTO stuImportExcelDTO = new StuImportExcelDTO();
|
|
|
|
|
for (TeacherOpenCourseStudentSigninLog studentSigninLog : teacherOpenCourseStudentSigninLogList) {
|
|
|
|
|
if (stuUser.getStudentId().equals(studentSigninLog.getStudentId()))
|
|
|
|
|
{
|
|
|
|
|
stuImportExcelDTO.setStudentId(stuUser.getStudentId());
|
|
|
|
|
stuImportExcelDTO.setName(stuUser.getName());
|
|
|
|
|
stuImportExcelDTO.setClassName(stuUser.getClassName());
|
|
|
|
|
stuImportExcelDTO.setTeacherOpenCourseStudentSigninLogAddTime(studentSigninLog.getTeacherOpenCourseStudentSigninLogAddTime());
|
|
|
|
|
stuImportExcelDTO.setTeacherOpenCourseStudentSigninLogType(studentSigninLog.getTeacherOpenCourseStudentSigninLogType() == "manual" ? "手动签到" : studentSigninLog.getTeacherOpenCourseStudentSigninLogType());
|
|
|
|
|
stuImportExcelDTO.setTeacherOpenCourseStudentSigninLogRemark(studentSigninLog.getTeacherOpenCourseStudentSigninLogRemark());
|
|
|
|
|
importExcelDTOList.add(stuImportExcelDTO);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return importExcelDTOList;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|