签到所有功能

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.TchEndSignDTO;
import com.sztzjy.trade.entity.dto.TchManualSignDTO; import com.sztzjy.trade.entity.dto.TchManualSignDTO;
import com.sztzjy.trade.entity.dto.TeacherOpenCourseStudentSigninSettingDTO; import com.sztzjy.trade.entity.dto.TeacherOpenCourseStudentSigninSettingDTO;
import com.sztzjy.trade.service.TchLoginLogAndStuListService;
import com.sztzjy.trade.service.TeacherOpenCourseStudentSigninService; import com.sztzjy.trade.service.TeacherOpenCourseStudentSigninService;
import com.sztzjy.trade.util.ResultEntity; import com.sztzjy.trade.util.ResultEntity;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -14,6 +15,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.Date;
/** /**
* @author 17803 * @author 17803
@ -32,82 +34,121 @@ public class TchSignInfoController {
/** /**
* - * -
* * <p>
* teacherOpenCourseStudentSigninSettingType * teacherOpenCourseStudentSigninSettingType
*
* @param teacherOpenCourseStudentSigninSettingDTO * @param teacherOpenCourseStudentSigninSettingDTO
* @return * @return
*/ */
@PostMapping("/add") @PostMapping("/add")
@ApiOperation("教师端-发起签到(统一签到接口,根据类型验证)") @ApiOperation("教师端-发起签到(统一签到接口,根据类型验证)")
@AnonymousAccess @AnonymousAccess
public ResultEntity addDo(@Valid @RequestBody TeacherOpenCourseStudentSigninSettingDTO teacherOpenCourseStudentSigninSettingDTO){ public ResultEntity addDo(@Valid @RequestBody TeacherOpenCourseStudentSigninSettingDTO teacherOpenCourseStudentSigninSettingDTO) {
if(null == teacherOpenCourseStudentSigninSettingDTO.getTeacherOpenCourseStudentSigninSettingStatus()){ if (null == teacherOpenCourseStudentSigninSettingDTO.getTeacherOpenCourseStudentSigninSettingStatus()) {
teacherOpenCourseStudentSigninSettingDTO.setTeacherOpenCourseStudentSigninSettingStatus(1); teacherOpenCourseStudentSigninSettingDTO.setTeacherOpenCourseStudentSigninSettingStatus(1);
}
return teacherOpenCourseStudentSigninService.addDo(teacherOpenCourseStudentSigninSettingDTO);
} }
return teacherOpenCourseStudentSigninService.addDo(teacherOpenCourseStudentSigninSettingDTO);
}
@PostMapping("/openStartState") @PostMapping("/openStartState")
@ApiOperation("教师端开始签到") @ApiOperation("教师端开始签到")
@AnonymousAccess @AnonymousAccess
public ResultEntity openStartState(Long teacherOpenCourseStudentSigninSettingId){ public ResultEntity openStartState(Long teacherOpenCourseStudentSigninSettingId) {
return teacherOpenCourseStudentSigninService.openStartState(teacherOpenCourseStudentSigninSettingId); return teacherOpenCourseStudentSigninService.openStartState(teacherOpenCourseStudentSigninSettingId);
} }
@PostMapping("/endSign") @PostMapping("/endSign")
@ApiOperation("教师端结束签到") @ApiOperation("教师端结束签到")
@AnonymousAccess @AnonymousAccess
public ResultEntity endSign(@RequestBody public ResultEntity endSign(@RequestBody
TchEndSignDTO tchEndSignDTO){ TchEndSignDTO tchEndSignDTO) {
return teacherOpenCourseStudentSigninService.endSign(tchEndSignDTO); return teacherOpenCourseStudentSigninService.endSign(tchEndSignDTO);
} }
@PostMapping("/manualSignByRandom") @PostMapping("/manualSignByRandom")
@ApiOperation("手动签到随机抽取") @ApiOperation("手动签到随机抽取")
@AnonymousAccess @AnonymousAccess
public ResultEntity manualSignByRandom(@RequestBody @Valid public ResultEntity manualSignByRandom(@RequestBody @Valid
@ApiParam("只传参:classIds") TchManualSignDTO tchManualSignDTO){ @ApiParam("只传参:classIds") TchManualSignDTO tchManualSignDTO) {
return teacherOpenCourseStudentSigninService.manualSignByRandom(tchManualSignDTO); return teacherOpenCourseStudentSigninService.manualSignByRandom(tchManualSignDTO);
} }
@PostMapping("/manualSignSure") @PostMapping("/manualSignSure")
@ApiOperation("手动签到确认按钮") @ApiOperation("手动签到确认按钮")
@AnonymousAccess @AnonymousAccess
@Transactional @Transactional
public ResultEntity manualSignSure(@RequestBody @Valid public ResultEntity manualSignSure(@RequestBody @Valid
TchManualSignDTO tchManualSignDTO){ TchManualSignDTO tchManualSignDTO) {
return teacherOpenCourseStudentSigninService.manualSignSure(tchManualSignDTO); return teacherOpenCourseStudentSigninService.manualSignSure(tchManualSignDTO);
} }
//查询所有签到信息 根据课程ID班级id,分页展示 //查询所有签到信息 根据课程ID班级id,分页展示
@GetMapping("/getSignInfoByTeacher") @GetMapping("/getSignInfoByTeacher")
@ApiOperation("课程内查询签到信息") @ApiOperation("课程内查询签到信息")
@AnonymousAccess @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 io.swagger.annotations.ApiModelProperty;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
/** /**
* --- * ---

@ -7,6 +7,8 @@ import com.sztzjy.trade.entity.dto.TeacherOpenCourseStudentSigninSettingDTO;
import com.sztzjy.trade.util.ResultEntity; import com.sztzjy.trade.util.ResultEntity;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.Date;
/** /**
* @author 17803 * @author 17803
* @date 2024-08-08 9:23 * @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 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 * @author 17803
* @date 2024-08-08 9:24 * @date 2024-08-08 9:24
*/ */
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.nimbusds.jose.util.IntegerUtils;
import com.sztzjy.trade.config.Constant; import com.sztzjy.trade.config.Constant;
import com.sztzjy.trade.entity.*; import com.sztzjy.trade.entity.*;
import com.sztzjy.trade.entity.dto.*; import com.sztzjy.trade.entity.dto.*;
@ -247,7 +250,7 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
List<TeacherOpenCourseStudentSigninSetting> teacherOpenCourseStudentSigninSettingList = teacherOpenCourseStudentSigninSettingMapper.selectByExample(example); List<TeacherOpenCourseStudentSigninSetting> teacherOpenCourseStudentSigninSettingList = teacherOpenCourseStudentSigninSettingMapper.selectByExample(example);
// 包装分页后的结果 // 包装分页后的结果
// PageInfo<TeacherOpenCourseStudentSigninSetting> pageInfo = new PageInfo<>(teacherOpenCourseStudentSigninSettingList); // PageInfo<TeacherOpenCourseStudentSigninSetting> pageInfo = new PageInfo<>(teacherOpenCourseStudentSigninSettingList);
if (teacherOpenCourseStudentSigninSettingList.isEmpty()) { 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(); TeacherOpenCourseStudentSigninLogExample studentSigninLogExample = new TeacherOpenCourseStudentSigninLogExample();
@ -294,21 +297,19 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
if (!teacherOpenCourseStudentSigninLogList.isEmpty()) { if (!teacherOpenCourseStudentSigninLogList.isEmpty()) {
//对手动签到做处理 //对手动签到做处理
if (Constant.MANUAL.equals(openCourseStudentSigninSetting.getTeacherOpenCourseStudentSigninSettingType())) if (Constant.MANUAL.equals(openCourseStudentSigninSetting.getTeacherOpenCourseStudentSigninSettingType())) {
{
TeacherSigninSettingDTO teacherSigninSettingDTO = new TeacherSigninSettingDTO(); TeacherSigninSettingDTO teacherSigninSettingDTO = new TeacherSigninSettingDTO();
BeanUtils.copyProperties(openCourseStudentSigninSetting, teacherSigninSettingDTO); BeanUtils.copyProperties(openCourseStudentSigninSetting, teacherSigninSettingDTO);
//缺勤签到人数 //缺勤签到人数
int missSizeManual = teacherOpenCourseStudentSigninLogList.stream() int missSizeManual = teacherOpenCourseStudentSigninLogList.stream()
.filter(item -> item.getTeacherOpenCourseStudentSigninLogType().equals(Constant.MANUAL)) .filter(item -> item.getTeacherOpenCourseStudentSigninLogType().equals(Constant.MANUAL))
.filter(item->item.getTeacherOpenCourseStudentSigninLogTag()==20) .filter(item -> item.getTeacherOpenCourseStudentSigninLogTag() == 20)
.collect(Collectors.toList()).size(); .collect(Collectors.toList()).size();
// 先转换为浮点数进行除法运算 // 先转换为浮点数进行除法运算
double result = (double) missSizeManual / countByClass; double result = (double) missSizeManual / countByClass;
@ -317,28 +318,26 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
double roundedResult = Math.round(result * 100.0) / 100.0; double roundedResult = Math.round(result * 100.0) / 100.0;
teacherSigninSettingDTO.setSum(countByClass); teacherSigninSettingDTO.setSum(countByClass);
teacherSigninSettingDTO.setSignCount(countByClass-missSizeManual); teacherSigninSettingDTO.setSignCount(countByClass - missSizeManual);
teacherSigninSettingDTO.setMissStudent(missSizeManual); teacherSigninSettingDTO.setMissStudent(missSizeManual);
teacherSigninSettingDTO.setTotalAttendRate(roundedResult); teacherSigninSettingDTO.setTotalAttendRate(roundedResult);
teacherSigninSettingDTOS.add(teacherSigninSettingDTO); teacherSigninSettingDTOS.add(teacherSigninSettingDTO);
continue; continue;
} }
//签到人数 //签到人数
int size1 = teacherOpenCourseStudentSigninLogList.stream().filter(item -> item.getTeacherOpenCourseStudentSigninLogTag() == 10).collect(Collectors.toList()).size(); int size1 = teacherOpenCourseStudentSigninLogList.stream().filter(item -> item.getTeacherOpenCourseStudentSigninLogTag() == 10).collect(Collectors.toList()).size();
signCount =+size1; signCount = +size1;
//缺勤人数 //缺勤人数
int info = teacherOpenCourseStudentSigninLogList.size() - size1; int info = teacherOpenCourseStudentSigninLogList.size() - size1;
missStudent =+info; missStudent = +info;
TeacherSigninSettingDTO teacherSigninSettingDTO = new TeacherSigninSettingDTO(); TeacherSigninSettingDTO teacherSigninSettingDTO = new TeacherSigninSettingDTO();
@ -346,7 +345,6 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
BeanUtils.copyProperties(openCourseStudentSigninSetting, teacherSigninSettingDTO); BeanUtils.copyProperties(openCourseStudentSigninSetting, teacherSigninSettingDTO);
//当前签到总人数 //当前签到总人数
teacherSigninSettingDTO.setSum(countByClass); 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 @Test
public void test(){ public void test(){

Loading…
Cancel
Save