签到所有功能

main
whb 7 months ago
parent 74dae8aa14
commit 699b3a55af

@ -4,6 +4,7 @@ import com.sztzjy.trade.annotation.AnonymousAccess;
import com.sztzjy.trade.entity.dto.TchEndSignDTO;
import com.sztzjy.trade.entity.dto.TchManualSignDTO;
import com.sztzjy.trade.entity.dto.TeacherOpenCourseStudentSigninSettingDTO;
import com.sztzjy.trade.service.TchLoginLogAndStuListService;
import com.sztzjy.trade.service.TeacherOpenCourseStudentSigninService;
import com.sztzjy.trade.util.ResultEntity;
import io.swagger.annotations.Api;
@ -14,6 +15,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.Date;
/**
* @author 17803
@ -32,82 +34,121 @@ public class TchSignInfoController {
/**
* -
*
* <p>
* teacherOpenCourseStudentSigninSettingType
*
* @param teacherOpenCourseStudentSigninSettingDTO
* @return
*/
@PostMapping("/add")
@ApiOperation("教师端-发起签到(统一签到接口,根据类型验证)")
@AnonymousAccess
public ResultEntity addDo(@Valid @RequestBody TeacherOpenCourseStudentSigninSettingDTO teacherOpenCourseStudentSigninSettingDTO){
public ResultEntity addDo(@Valid @RequestBody TeacherOpenCourseStudentSigninSettingDTO teacherOpenCourseStudentSigninSettingDTO) {
if(null == teacherOpenCourseStudentSigninSettingDTO.getTeacherOpenCourseStudentSigninSettingStatus()){
teacherOpenCourseStudentSigninSettingDTO.setTeacherOpenCourseStudentSigninSettingStatus(1);
}
return teacherOpenCourseStudentSigninService.addDo(teacherOpenCourseStudentSigninSettingDTO);
if (null == teacherOpenCourseStudentSigninSettingDTO.getTeacherOpenCourseStudentSigninSettingStatus()) {
teacherOpenCourseStudentSigninSettingDTO.setTeacherOpenCourseStudentSigninSettingStatus(1);
}
return teacherOpenCourseStudentSigninService.addDo(teacherOpenCourseStudentSigninSettingDTO);
}
@PostMapping("/openStartState")
@ApiOperation("教师端开始签到")
@AnonymousAccess
public ResultEntity openStartState(Long teacherOpenCourseStudentSigninSettingId){
public ResultEntity openStartState(Long teacherOpenCourseStudentSigninSettingId) {
return teacherOpenCourseStudentSigninService.openStartState(teacherOpenCourseStudentSigninSettingId);
}
@PostMapping("/endSign")
@ApiOperation("教师端结束签到")
@AnonymousAccess
public ResultEntity endSign(@RequestBody
TchEndSignDTO tchEndSignDTO){
TchEndSignDTO tchEndSignDTO) {
return teacherOpenCourseStudentSigninService.endSign(tchEndSignDTO);
}
@PostMapping("/manualSignByRandom")
@ApiOperation("手动签到随机抽取")
@AnonymousAccess
public ResultEntity manualSignByRandom(@RequestBody @Valid
@ApiParam("只传参:classIds") TchManualSignDTO tchManualSignDTO){
@ApiParam("只传参:classIds") TchManualSignDTO tchManualSignDTO) {
return teacherOpenCourseStudentSigninService.manualSignByRandom(tchManualSignDTO);
}
@PostMapping("/manualSignSure")
@ApiOperation("手动签到确认按钮")
@AnonymousAccess
@Transactional
public ResultEntity manualSignSure(@RequestBody @Valid
TchManualSignDTO tchManualSignDTO){
TchManualSignDTO tchManualSignDTO) {
return teacherOpenCourseStudentSigninService.manualSignSure(tchManualSignDTO);
}
//查询所有签到信息 根据课程ID班级id,分页展示
@GetMapping("/getSignInfoByTeacher")
@ApiOperation("课程内查询签到信息")
@AnonymousAccess
public ResultEntity getSignInfoByTeacher(@ApiParam("课程ID") Long courseId, @ApiParam("学校ID") Long orgId,Integer page,Integer size){
public ResultEntity getSignInfoByTeacher(@ApiParam("课程ID") Long courseId, @ApiParam("学校ID") Long orgId, Integer page, Integer size) {
return teacherOpenCourseStudentSigninService.getSignInfoByTeacher(courseId,orgId,page,size);
return teacherOpenCourseStudentSigninService.getSignInfoByTeacher(courseId, orgId, page, size);
}
@ApiOperation("班级下拉框")
@GetMapping("/getClassListByNameOrSchoolId")
@AnonymousAccess
public ResultEntity getClassListByNameOrSchoolId(@ApiParam("学校ID") @RequestParam(required = true) String schoolId,
@ApiParam("学生ID") @RequestParam(required = false) String studentId,
@ApiParam("学生姓名") @RequestParam(required = false) String name,
@ApiParam("班级ID") @RequestParam(required = false) String classID,
@ApiParam("当前页") @RequestParam(required = true) Integer page,
@ApiParam("每页展示条数") @RequestParam(required = true) Integer size) {
//"yyyy-MM-dd HH:mm:ss"
return teacherOpenCourseStudentSigninService.getClassListByNameOrSchoolId(schoolId, studentId, name, classID, page, size);
}
@ApiOperation("签到详情")
@GetMapping("/getPageList")
@AnonymousAccess
public ResultEntity getPageList(
@ApiParam("学生ID") @RequestParam(required = false) String studentId,
@ApiParam("签到方式为手动签到传参:manual") @RequestParam(required = false) String type,
@ApiParam("班级ID") @RequestParam(required = false) String classId,
@ApiParam("当前页") @RequestParam(required = true) Integer page,
@ApiParam("每页展示条数") @RequestParam(required = true) Integer size,
@ApiParam("签到时间") @RequestParam(required = false)Date signTime,
@ApiParam("签到情况(10签到/20缺勤)") @RequestParam(required = false)Integer signInfo,
@ApiParam("缺勤理由") @RequestParam(required = false)String missInfo,
@ApiParam("签到表ID") @RequestParam(required = true)Long signId,
@ApiParam("班级列表") @RequestParam(required = true)String classIds
) {
//"yyyy-MM-dd HH:mm:ss"
return teacherOpenCourseStudentSigninService.getPageList(studentId, type, classId, page, size,signTime,signInfo,missInfo,signId,classIds);
}
}

@ -5,6 +5,7 @@ import java.util.Date;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* ---

@ -7,6 +7,8 @@ import com.sztzjy.trade.entity.dto.TeacherOpenCourseStudentSigninSettingDTO;
import com.sztzjy.trade.util.ResultEntity;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
/**
* @author 17803
* @date 2024-08-08 9:23
@ -56,4 +58,11 @@ public interface TeacherOpenCourseStudentSigninService {
*/
ResultEntity getSignInfoByTeacher(@Param("courseId") Long courseId, @Param("orgId") Long orgId,Integer page,Integer size);
//班级下拉框
ResultEntity getClassListByNameOrSchoolId(String schoolId, String studentId, String name, String classID,Integer page,Integer size);
//签到详情
ResultEntity getPageList(String studentId, String type, String classId, Integer page, Integer size, Date startTime, Integer signInfo, String missInfo,Long signId,String classIds
);
}

@ -1,11 +1,14 @@
package com.sztzjy.trade.service.impl;/**
package com.sztzjy.trade.service.impl;
/**
* @author 17803
* @date 2024-08-08 9:24
*/
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.IdUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.nimbusds.jose.util.IntegerUtils;
import com.sztzjy.trade.config.Constant;
import com.sztzjy.trade.entity.*;
import com.sztzjy.trade.entity.dto.*;
@ -247,7 +250,7 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
List<TeacherOpenCourseStudentSigninSetting> teacherOpenCourseStudentSigninSettingList = teacherOpenCourseStudentSigninSettingMapper.selectByExample(example);
// 包装分页后的结果
// PageInfo<TeacherOpenCourseStudentSigninSetting> pageInfo = new PageInfo<>(teacherOpenCourseStudentSigninSettingList);
// PageInfo<TeacherOpenCourseStudentSigninSetting> pageInfo = new PageInfo<>(teacherOpenCourseStudentSigninSettingList);
if (teacherOpenCourseStudentSigninSettingList.isEmpty()) {
@ -280,7 +283,7 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
//总人数
countByClass =+stuUserMapper.selectByExample(stuUserExample).size();
countByClass = +stuUserMapper.selectByExample(stuUserExample).size();
TeacherOpenCourseStudentSigninLogExample studentSigninLogExample = new TeacherOpenCourseStudentSigninLogExample();
@ -294,21 +297,19 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
if (!teacherOpenCourseStudentSigninLogList.isEmpty()) {
//对手动签到做处理
if (Constant.MANUAL.equals(openCourseStudentSigninSetting.getTeacherOpenCourseStudentSigninSettingType()))
{
if (Constant.MANUAL.equals(openCourseStudentSigninSetting.getTeacherOpenCourseStudentSigninSettingType())) {
TeacherSigninSettingDTO teacherSigninSettingDTO = new TeacherSigninSettingDTO();
BeanUtils.copyProperties(openCourseStudentSigninSetting, teacherSigninSettingDTO);
//缺勤签到人数
int missSizeManual = teacherOpenCourseStudentSigninLogList.stream()
int missSizeManual = teacherOpenCourseStudentSigninLogList.stream()
.filter(item -> item.getTeacherOpenCourseStudentSigninLogType().equals(Constant.MANUAL))
.filter(item->item.getTeacherOpenCourseStudentSigninLogTag()==20)
.filter(item -> item.getTeacherOpenCourseStudentSigninLogTag() == 20)
.collect(Collectors.toList()).size();
// 先转换为浮点数进行除法运算
double result = (double) missSizeManual / countByClass;
@ -317,28 +318,26 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
double roundedResult = Math.round(result * 100.0) / 100.0;
teacherSigninSettingDTO.setSum(countByClass);
teacherSigninSettingDTO.setSignCount(countByClass-missSizeManual);
teacherSigninSettingDTO.setSignCount(countByClass - missSizeManual);
teacherSigninSettingDTO.setMissStudent(missSizeManual);
teacherSigninSettingDTO.setTotalAttendRate(roundedResult);
teacherSigninSettingDTOS.add(teacherSigninSettingDTO);
continue;
continue;
}
//签到人数
int size1 = teacherOpenCourseStudentSigninLogList.stream().filter(item -> item.getTeacherOpenCourseStudentSigninLogTag() == 10).collect(Collectors.toList()).size();
signCount =+size1;
signCount = +size1;
//缺勤人数
int info = teacherOpenCourseStudentSigninLogList.size() - size1;
missStudent =+info;
missStudent = +info;
TeacherSigninSettingDTO teacherSigninSettingDTO = new TeacherSigninSettingDTO();
@ -346,7 +345,6 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
BeanUtils.copyProperties(openCourseStudentSigninSetting, teacherSigninSettingDTO);
//当前签到总人数
teacherSigninSettingDTO.setSum(countByClass);
//当前签到缺勤人数
@ -397,6 +395,171 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
}
//班级下拉框
@Override
public ResultEntity getClassListByNameOrSchoolId(String schoolId, String studentId,
String name, String classID,
Integer page, Integer size) {
PageHelper.startPage(page, size);
StuUserExample userExample = new StuUserExample();
StuUserExample.Criteria criteria = userExample.createCriteria();
criteria.andSchoolIdEqualTo(schoolId);
if (StringUtils.hasText(studentId)) {
criteria.andStudentIdLike("%" + studentId + "%");
}
if (StringUtils.hasText(name)) {
criteria.andNameLike("%" + name + "%");
}
if (StringUtils.hasText(classID)) {
criteria.andClassIdEqualTo(classID);
}
List<StuUser> stuUserList = stuUserMapper.selectByExample(userExample);
if (stuUserList.isEmpty()) {
return new ResultEntity<>(HttpStatus.OK);
}
PageInfo<StuUser> userPageInfo = new PageInfo<>(stuUserList);
return new ResultEntity<>(HttpStatus.OK, userPageInfo);
}
//签到详情
@Override
public ResultEntity getPageList(String studentId, String type,
String classId, Integer page,
Integer size, Date signTime,
Integer signInfo,
String missInfo, Long signId, String classIds
) {
//开启分页
PageHelper.startPage(page, size);
//开始时间,结束时间,签到情况,缺勤理由 {班级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);
//手动签到
if (StringUtils.hasText(type)) {
if (Constant.MANUAL.equals(type)) {
//只能查出来老师手动签到的用户数据 未抽中用户默认已经签到并且要展示出来
criteria.andTeacherOpenCourseStudentSigninLogTypeEqualTo(type);
//往里面加数据teacherOpenCourseStudentSigninLogList
List<TeacherOpenCourseStudentSigninLog> teacherOpenCourseStudentSigninLogList =
teacherOpenCourseStudentSigninLogMapper.selectByExample(openCourseStudentSigninLogExample);
if (teacherOpenCourseStudentSigninLogList.isEmpty()) {
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 {
// 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())) {
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);
}
}
}
List<TeacherOpenCourseStudentSigninLog> teacherOpenCourseStudentSigninLogList =
teacherOpenCourseStudentSigninLogMapper.selectByExample(openCourseStudentSigninLogExample);
if (teacherOpenCourseStudentSigninLogList.isEmpty()) {
return new ResultEntity<>(HttpStatus.OK);
}
PageInfo<TeacherOpenCourseStudentSigninLog> courseStudentSigninLogPageInfo = new PageInfo<>(teacherOpenCourseStudentSigninLogList);
return new ResultEntity<>(HttpStatus.OK, courseStudentSigninLogPageInfo);
}
}

@ -17,6 +17,7 @@ public class Tset {
@Test
public void test(){

Loading…
Cancel
Save