修改公告接口

main
whb 3 months ago
parent d181d809ab
commit a51f327b91

@ -108,14 +108,13 @@ public class StuExpermentTrainingController {
@ApiOperation("实训文件上传接口") @ApiOperation("实训文件上传接口")
@PostMapping("/upload") @PostMapping("/upload")
@AnonymousAccess @AnonymousAccess
public ResultEntity upload(MultipartFile file, @ApiParam("实训名称")String module,String userId,@ApiParam("例如:身份证明文件/其他主要证明文件") String name) { public ResultEntity upload(@RequestPart MultipartFile file, @ApiParam("实训名称")String module,String userId,@ApiParam("例如:身份证明文件/其他主要证明文件") String name) {
if (file.isEmpty()) if (file.isEmpty())
{ {
return new ResultEntity<>(HttpStatus.BAD_REQUEST,"文件不能为空"); return new ResultEntity<>(HttpStatus.BAD_REQUEST,"文件不能为空");
} }
//保存文件路径 //保存文件路径
String filePath = iFileUtil.upload(file); String filePath = iFileUtil.upload(file);
return service.uploadFileByExperment(filePath,module,userId,name); return service.uploadFileByExperment(filePath,module,userId,name);

@ -12,6 +12,8 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -30,6 +32,7 @@ import java.util.Date;
@RestController @RestController
@Api(tags = "签到") @Api(tags = "签到")
@Validated @Validated
@EnableAsync
public class TchSignInfoController { public class TchSignInfoController {
@ -71,10 +74,11 @@ public class TchSignInfoController {
@PostMapping("/endSign") @PostMapping("/endSign")
@ApiOperation("教师端结束签到") @ApiOperation("教师端结束签到")
@AnonymousAccess @AnonymousAccess
@Async
public ResultEntity endSign(@RequestBody public ResultEntity endSign(@RequestBody
TchEndSignDTO tchEndSignDTO) { TchEndSignDTO tchEndSignDTO) {
//结束签到要把未签到用户统计 //结束签到要把未签到用户搞成未签到
return teacherOpenCourseStudentSigninService.endSign(tchEndSignDTO); return teacherOpenCourseStudentSigninService.endSign(tchEndSignDTO);
} }
@ -82,8 +86,7 @@ public class TchSignInfoController {
@PostMapping("/manualSignByRandom") @PostMapping("/manualSignByRandom")
@ApiOperation("手动签到随机抽取") @ApiOperation("手动签到随机抽取")
@AnonymousAccess @AnonymousAccess
public ResultEntity manualSignByRandom(@RequestBody @Valid public ResultEntity manualSignByRandom(@RequestBody @ApiParam("只传参:classIds") TchManualSignDTO tchManualSignDTO) {
@ApiParam("只传参:classIds") TchManualSignDTO tchManualSignDTO) {
return teacherOpenCourseStudentSigninService.manualSignByRandom(tchManualSignDTO); return teacherOpenCourseStudentSigninService.manualSignByRandom(tchManualSignDTO);

@ -4,6 +4,7 @@ import java.util.Date;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Builder; import lombok.Builder;
import lombok.Data;
/** /**
* --- * ---
@ -11,6 +12,7 @@ import lombok.Builder;
* @author whb * @author whb
* teacher_open_course_student_signin_log * teacher_open_course_student_signin_log
*/ */
@Data
@Builder @Builder
public class TeacherOpenCourseStudentSigninLog { public class TeacherOpenCourseStudentSigninLog {
@ApiModelProperty(notes = "ID") @ApiModelProperty(notes = "ID")

@ -21,39 +21,34 @@ import java.util.List;
public class TchManualSignDTO { public class TchManualSignDTO {
@ApiModelProperty("签到表ID") @ApiModelProperty("签到表ID")
@NotNull(message = "签到表ID不能为空")
private Long teacherOpenCourseStudentSigninSettingId; private Long teacherOpenCourseStudentSigninSettingId;
@ApiModelProperty("课程ID") @ApiModelProperty("课程ID")
@NotNull(message = "课程ID不能为空")
private Long teacherOpenCourseId; private Long teacherOpenCourseId;
@ApiModelProperty("签到的班级") @ApiModelProperty("签到的班级")
@NotNull(message = "签到的班级能为空")
private String classIds; private String classIds;
@ApiModelProperty("抽取人数")
private Integer RandomNumber;
@ApiModelProperty("场次时间") @ApiModelProperty("场次时间")
@NotNull(message = "场次时间不能为空")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
private Date teacherOpenCourseStudentSigninSettingSessionTime; private Date teacherOpenCourseStudentSigninSettingSessionTime;
@ApiModelProperty("教师ID") @ApiModelProperty("教师ID")
@NotNull(message = "教师ID不能为空")
private Long userId; private Long userId;
@ApiModelProperty("教师ID")
private String orgId;
@ApiModelProperty("用户签到数据") @ApiModelProperty("用户签到数据")
private List<TchManualSignSettingDTO> tchManualSignSettingDTOList; private List<TchManualSignSettingDTO> tchManualSignSettingDTOList;
} }

@ -3,9 +3,11 @@ package com.sztzjy.trade.entity.dto;/**
* @date 2024-08-09 14:23 * @date 2024-08-09 14:23
*/ */
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date; import java.util.Date;
@ -19,6 +21,8 @@ public class TeacherSigninSettingDTO {
private Long teacherOpenCourseStudentSigninSettingId; private Long teacherOpenCourseStudentSigninSettingId;
@ApiModelProperty("场次时间") @ApiModelProperty("场次时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date teacherOpenCourseStudentSigninSettingSessionTime; private Date teacherOpenCourseStudentSigninSettingSessionTime;
@ApiModelProperty("开课ID") @ApiModelProperty("开课ID")

@ -15,6 +15,7 @@ import com.sztzjy.trade.util.ResultEntity;
import org.apache.poi.ss.formula.functions.T; import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -58,6 +59,9 @@ public class StuExpermentTrainingServiceImpl implements StuExpermentTrainingServ
private RedisUtil redisUtil; private RedisUtil redisUtil;
@Value("${file.url}")
public String url;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResultEntity expermentSubmit(StuTaskPracticeRecord stuTaskPracticeRecord) { public ResultEntity expermentSubmit(StuTaskPracticeRecord stuTaskPracticeRecord) {
@ -481,14 +485,14 @@ public class StuExpermentTrainingServiceImpl implements StuExpermentTrainingServ
uploadExperment.setModule(module); uploadExperment.setModule(module);
uploadExperment.setUserId(userId); uploadExperment.setUserId(userId);
stuUploadExpermentMapper.insertSelective(uploadExperment); stuUploadExpermentMapper.insertSelective(uploadExperment);
return new ResultEntity<>(HttpStatus.OK, "上传成功!"); return new ResultEntity<>(HttpStatus.OK, "上传成功!",url+filePath);
} else { } else {
StuUploadExperment uploadExperment = stuUploadExpermentList.get(0); StuUploadExperment uploadExperment = stuUploadExpermentList.get(0);
uploadExperment.setUpdateTime(new Date()); uploadExperment.setUpdateTime(new Date());
uploadExperment.setFilePath(filePath); uploadExperment.setFilePath(filePath);
stuUploadExpermentMapper.updateByPrimaryKeySelective(uploadExperment); stuUploadExpermentMapper.updateByPrimaryKeySelective(uploadExperment);
return new ResultEntity<>(HttpStatus.OK, "上传成功!"); return new ResultEntity<>(HttpStatus.OK, "上传成功!",url+filePath);
} }

@ -22,6 +22,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
@Service @Service
public class TchPublicNoticeServiceImpl implements TchPublicNoticeService { public class TchPublicNoticeServiceImpl implements TchPublicNoticeService {
@ -87,15 +88,21 @@ public class TchPublicNoticeServiceImpl implements TchPublicNoticeService {
.userId(userId).build(); .userId(userId).build();
stuPublicNoticeReadInfoMapper.insertSelective(readInfo); stuPublicNoticeReadInfoMapper.insertSelective(readInfo);
TchPublicNoticeExample noticeExample = new TchPublicNoticeExample();
noticeExample.createCriteria().andNoticeIdEqualTo(noticeId);
List<TchPublicNotice> tchPublicNoticeList = publicNoticeMapper.selectByExampleWithBLOBs(noticeExample);
return new ResultEntity<>(HttpStatus.OK);
return new ResultEntity<>(HttpStatus.OK,tchPublicNoticeList.get(0).getNoticeContent());
} }
//学生查询课程内已发布公告 //学生查询课程内已发布公告
@Override @Override
public ResultEntity stuPublicNoticeByCourse(String courseId, String schoolId, String userId) { public ResultEntity stuPublicNoticeByCourse(String courseId, String schoolId, String userId) {
//查询课程下所有公告
TchPublicNoticeCourseExample example = new TchPublicNoticeCourseExample(); TchPublicNoticeCourseExample example = new TchPublicNoticeCourseExample();
example.createCriteria().andCourseIdEqualTo(courseId).andSchoolIdEqualTo(schoolId); example.createCriteria().andCourseIdEqualTo(courseId).andSchoolIdEqualTo(schoolId);
List<TchPublicNoticeCourse> tchPublicNoticeCourseList = publicNoticeCourseMapper.selectByExample(example); List<TchPublicNoticeCourse> tchPublicNoticeCourseList = publicNoticeCourseMapper.selectByExample(example);
@ -103,48 +110,61 @@ public class TchPublicNoticeServiceImpl implements TchPublicNoticeService {
{ {
return new ResultEntity<>(HttpStatus.OK); return new ResultEntity<>(HttpStatus.OK);
} }
//公告ID集合
StuPublicNoticeByReadInfoDTO stuPublicNoticeByReadInfoDTO = new StuPublicNoticeByReadInfoDTO(); List<String> stringList = tchPublicNoticeCourseList.stream().map(item -> item.getNoticeId()).collect(Collectors.toList());
List<TchPublicNotice> publicNoticeArrayList = new ArrayList<>(); //查询公告列表
TchPublicNoticeExample noticeExample = new TchPublicNoticeExample();
noticeExample.createCriteria().andNoticeIdIn(stringList).andSchoolIdEqualTo(schoolId);
List<TchPublicNotice> tchPublicNoticeList = publicNoticeMapper.selectByExampleWithBLOBs(noticeExample);
//查询已读取列表数据
StuPublicNoticeReadInfoExample publicNoticeReadInfoExample = new StuPublicNoticeReadInfoExample();
publicNoticeReadInfoExample.createCriteria().andUserIdEqualTo(userId).andNoticeIdIn(stringList);
List<StuPublicNoticeReadInfo> stuPublicNoticeReadInfoList = stuPublicNoticeReadInfoMapper.selectByExample(publicNoticeReadInfoExample);
List<String> readInfoList = new ArrayList<>(); List<String> readInfoList = new ArrayList<>();
for (TchPublicNoticeCourse publicNoticeCourse : tchPublicNoticeCourseList) { if (stuPublicNoticeReadInfoList.isEmpty())
{
TchPublicNoticeExample noticeExample = new TchPublicNoticeExample(); readInfoList = Collections.emptyList();
noticeExample.createCriteria().andNoticeIdEqualTo(publicNoticeCourse.getNoticeId()).andSchoolIdEqualTo(schoolId); }
List<TchPublicNotice> tchPublicNoticeList = publicNoticeMapper.selectByExampleWithBLOBs(noticeExample);
if (tchPublicNoticeList.isEmpty())
{
new RuntimeException("Id为"+publicNoticeCourse.getNoticeId()+"不存在!");
}
publicNoticeArrayList.add(tchPublicNoticeList.get(0));
StuPublicNoticeReadInfoExample publicNoticeReadInfoExample = new StuPublicNoticeReadInfoExample(); readInfoList = stuPublicNoticeReadInfoList.stream().map(item->item.getNoticeId()).collect(Collectors.toList());
publicNoticeReadInfoExample.createCriteria().andUserIdEqualTo(userId).andNoticeIdEqualTo(publicNoticeCourse.getNoticeId());
List<StuPublicNoticeReadInfo> stuPublicNoticeReadInfoList = stuPublicNoticeReadInfoMapper.selectByExample(publicNoticeReadInfoExample);
if (stuPublicNoticeReadInfoList.isEmpty())
{
continue;
}else {
readInfoList.add(publicNoticeCourse.getNoticeId());
}
}
Collections.sort(publicNoticeArrayList, new Comparator<TchPublicNotice>() {
@Override
public int compare(TchPublicNotice s1, TchPublicNotice s2) {
return s2.getCreateTime().compareTo(s1.getCreateTime());
}
});
StuPublicNoticeByReadInfoDTO stuPublicNoticeByReadInfoDTO = new StuPublicNoticeByReadInfoDTO();
stuPublicNoticeByReadInfoDTO.setTchPublicNotices(publicNoticeArrayList); // List<TchPublicNotice> publicNoticeArrayList = new ArrayList<>();
stuPublicNoticeByReadInfoDTO.setUnNoticeList(readInfoList); //
// for (TchPublicNoticeCourse publicNoticeCourse : tchPublicNoticeCourseList) {
//
// if (tchPublicNoticeList.isEmpty())
// {
// new RuntimeException("Id为"+publicNoticeCourse.getNoticeId()+"不存在!");
// }
// List<TchPublicNotice> publicNoticeList = tchPublicNoticeList.stream().filter(item -> item.getNoticeId().equals(publicNoticeCourse.getNoticeId())).collect(Collectors.toList());
//
// publicNoticeArrayList.add(tchPublicNoticeList.get(0));
//
// if (stuPublicNoticeReadInfoList.isEmpty())
// {
// continue;
//
// }else {
// readInfoList.add(publicNoticeCourse.getNoticeId());
// }
//
// }
List<String> stringList1 = tchPublicNoticeList.stream().map(item -> item.getNoticeId()).collect(Collectors.toList());
stringList1.removeAll(readInfoList);
tchPublicNoticeList.stream().sorted(Comparator.comparing(TchPublicNotice::getCreateTime));
stuPublicNoticeByReadInfoDTO.setTchPublicNotices(tchPublicNoticeList);
stuPublicNoticeByReadInfoDTO.setUnNoticeList(stringList1);
return new ResultEntity<>(HttpStatus.OK,stuPublicNoticeByReadInfoDTO); return new ResultEntity<>(HttpStatus.OK,stuPublicNoticeByReadInfoDTO);

@ -20,12 +20,14 @@ import com.sztzjy.trade.mapper.StuUserMapper;
import com.sztzjy.trade.mapper.TeacherOpenCourseStudentSigninLogMapper; import com.sztzjy.trade.mapper.TeacherOpenCourseStudentSigninLogMapper;
import com.sztzjy.trade.mapper.TeacherOpenCourseStudentSigninSettingMapper; import com.sztzjy.trade.mapper.TeacherOpenCourseStudentSigninSettingMapper;
import com.sztzjy.trade.service.TeacherOpenCourseStudentSigninService; import com.sztzjy.trade.service.TeacherOpenCourseStudentSigninService;
import com.sztzjy.trade.util.ConvertUtil;
import com.sztzjy.trade.util.ResultEntity; import com.sztzjy.trade.util.ResultEntity;
import com.sztzjy.trade.util.excel.FilePortUtil; import com.sztzjy.trade.util.excel.FilePortUtil;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -123,10 +125,86 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
openCourseStudentSigninSetting.setTeacherOpenCourseStudentSigninSettingStartStatus(String.valueOf(StartStatusEnum.END)); openCourseStudentSigninSetting.setTeacherOpenCourseStudentSigninSettingStartStatus(String.valueOf(StartStatusEnum.END));
openCourseStudentSigninSetting.setTeacherOpenCourseStudentSigninSettingEndTime(new Date()); openCourseStudentSigninSetting.setTeacherOpenCourseStudentSigninSettingEndTime(new Date());
teacherOpenCourseStudentSigninSettingMapper.updateByPrimaryKeySelective(openCourseStudentSigninSetting); teacherOpenCourseStudentSigninSettingMapper.updateByPrimaryKeySelective(openCourseStudentSigninSetting);
//根据ID查询签到用户 把未签到用户添加到记录表
String[] split = openCourseStudentSigninSetting.getSchoolClassIds().split(",");;
//查询所有学生
List<String> collect = Arrays.stream(split).collect(Collectors.toList());
//根据班级列表查询对应所有用户数据
StuUserExample stuUserExample = new StuUserExample();
stuUserExample.createCriteria().andClassIdIn(collect).andRoleIdEqualTo(4);
List<StuUser> stuUserList = stuUserMapper.selectByExample(stuUserExample);
if (stuUserList.isEmpty()) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "暂无该班级");
}
//
TeacherOpenCourseStudentSigninLogExample example = new TeacherOpenCourseStudentSigninLogExample();
example.createCriteria().andTeacherOpenCourseStudentSigninSettingIdEqualTo(tchEndSignDTO.getTeacherOpenCourseStudentSigninSettingId());
List<TeacherOpenCourseStudentSigninLog> courseStudentSigninLogs = teacherOpenCourseStudentSigninLogMapper.selectByExample(example);
if (!courseStudentSigninLogs.isEmpty()) {
List<StuUser> list = new ArrayList<>();
stuUserList.forEach(stuUser -> {
courseStudentSigninLogs.forEach(item->{
if (item.getUserId().equals(stuUser.getUserId())) {
list.add(stuUser);
}
});
});
stuUserList.removeAll(list);
for (StuUser stuUser : stuUserList) {
TeacherOpenCourseStudentSigninLog build = TeacherOpenCourseStudentSigninLog.builder()
.teacherOpenCourseStudentSigninSettingId(tchEndSignDTO.getTeacherOpenCourseStudentSigninSettingId())
.teacherOpenCourseStudentSigninSettingSessionTime(openCourseStudentSigninSetting.getTeacherOpenCourseStudentSigninSettingSessionTime())
.studentId(stuUser.getStudentId())
.teacherOpenCourseId(1L)
.schoolClassId(Convert.toLong(stuUser.getClassId()))
.teacherOpenCourseStudentSigninLogAddTime(openCourseStudentSigninSetting.getTeacherOpenCourseStudentSigninSettingAddTime())
.teacherOpenCourseStudentSigninLogType(openCourseStudentSigninSetting.getTeacherOpenCourseStudentSigninSettingType())
.teacherOpenCourseStudentSigninLogTag(20)
.userId(Convert.toLong(stuUser.getUserId())).build();
teacherOpenCourseStudentSigninLogMapper.insertSelective(build);
//写入学习记录中
updateLearningRecord(build);
}
}else {
for (StuUser stuUser : stuUserList) {
TeacherOpenCourseStudentSigninLog build = TeacherOpenCourseStudentSigninLog.builder()
.teacherOpenCourseStudentSigninSettingId(tchEndSignDTO.getTeacherOpenCourseStudentSigninSettingId())
.teacherOpenCourseStudentSigninSettingSessionTime(openCourseStudentSigninSetting.getTeacherOpenCourseStudentSigninSettingSessionTime())
.studentId(stuUser.getStudentId())
.teacherOpenCourseId(1L)
.schoolClassId(Convert.toLong(stuUser.getClassId()))
.teacherOpenCourseStudentSigninLogAddTime(openCourseStudentSigninSetting.getTeacherOpenCourseStudentSigninSettingAddTime())
.teacherOpenCourseStudentSigninLogType(openCourseStudentSigninSetting.getTeacherOpenCourseStudentSigninSettingType())
.teacherOpenCourseStudentSigninLogTag(20)
.userId(Convert.toLong(stuUser.getUserId())).build();
teacherOpenCourseStudentSigninLogMapper.insertSelective(build);
//写入学习记录中
updateLearningRecord(build);
return null; }
}
return new ResultEntity<>(HttpStatus.OK);
} }
/** /**
@ -145,13 +223,10 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
//签到表ID //签到表ID
vo.setTeacherOpenCourseStudentSigninSettingId(IdUtil.getSnowflakeNextId()); vo.setTeacherOpenCourseStudentSigninSettingId(IdUtil.getSnowflakeNextId());
// 定义要随机抽取的数量
int numberOfUsersToSelect = 6;
String[] split = tchManualSignDTO.getClassIds().split(","); String[] split = tchManualSignDTO.getClassIds().split(",");
for (String classId : split) {
numberOfUsersToSelect += 2;
}
List<String> collect = Arrays.stream(split).collect(Collectors.toList()); List<String> collect = Arrays.stream(split).collect(Collectors.toList());
//根据班级列表查询对应所有用户数据 //根据班级列表查询对应所有用户数据
StuUserExample stuUserExample = new StuUserExample(); StuUserExample stuUserExample = new StuUserExample();
@ -165,9 +240,7 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
// 检查列表大小是否大于等于要抽取的数量 // 检查列表大小是否大于等于要抽取的数量
if (stuUserList.size() < numberOfUsersToSelect) { if (stuUserList.size() < tchManualSignDTO.getRandomNumber()) {
// 抽取指定数量的元素 // 抽取指定数量的元素
List<StuUser> selectedUsers = stuUserList.subList(0, stuUserList.size()); List<StuUser> selectedUsers = stuUserList.subList(0, stuUserList.size());
vo.setUserList(selectedUsers); vo.setUserList(selectedUsers);
@ -177,7 +250,7 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
} else { } else {
// 抽取指定数量的元素 // 抽取指定数量的元素
List<StuUser> selectedUsers = stuUserList.subList(0, numberOfUsersToSelect); List<StuUser> selectedUsers = stuUserList.subList(0, tchManualSignDTO.getRandomNumber());
vo.setUserList(selectedUsers); vo.setUserList(selectedUsers);
return new ResultEntity<>(HttpStatus.OK, vo); return new ResultEntity<>(HttpStatus.OK, vo);
} }
@ -193,6 +266,7 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
*/ */
@Override @Override
@Async
public ResultEntity manualSignSure(TchManualSignDTO tchManualSignDTO) { public ResultEntity manualSignSure(TchManualSignDTO tchManualSignDTO) {
//查询是否为多次插入 //查询是否为多次插入
TeacherOpenCourseStudentSigninSetting teacherOpenCourseStudentSigninSetting = TeacherOpenCourseStudentSigninSetting teacherOpenCourseStudentSigninSetting =
@ -208,7 +282,15 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
//创建签到表 //创建签到表
TeacherOpenCourseStudentSigninSetting openCourseStudentSigninSetting = new TeacherOpenCourseStudentSigninSetting(); TeacherOpenCourseStudentSigninSetting openCourseStudentSigninSetting = new TeacherOpenCourseStudentSigninSetting();
openCourseStudentSigninSetting.setTeacherOpenCourseStudentSigninSettingSessionTime(tchManualSignDTO.getTeacherOpenCourseStudentSigninSettingSessionTime()); openCourseStudentSigninSetting.setTeacherOpenCourseStudentSigninSettingSessionTime(tchManualSignDTO.getTeacherOpenCourseStudentSigninSettingSessionTime());
openCourseStudentSigninSetting.setTeacherOpenCourseStudentSigninSettingId(tchManualSignDTO.getTeacherOpenCourseStudentSigninSettingId());
int i = UUID.randomUUID().hashCode();
if (i<0)
{
i = -1;
}
final int i2 = i;
openCourseStudentSigninSetting.setTeacherOpenCourseStudentSigninSettingId((long) i);
openCourseStudentSigninSetting.setTeacherOpenCourseId(tchManualSignDTO.getTeacherOpenCourseId()); openCourseStudentSigninSetting.setTeacherOpenCourseId(tchManualSignDTO.getTeacherOpenCourseId());
openCourseStudentSigninSetting.setSchoolClassIds(tchManualSignDTO.getClassIds()); openCourseStudentSigninSetting.setSchoolClassIds(tchManualSignDTO.getClassIds());
openCourseStudentSigninSetting.setTeacherOpenCourseStudentSigninSettingAddTime((new Date())); openCourseStudentSigninSetting.setTeacherOpenCourseStudentSigninSettingAddTime((new Date()));
@ -218,6 +300,7 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
openCourseStudentSigninSetting.setTeacherOpenCourseStudentSigninSettingEndTime(new Date()); openCourseStudentSigninSetting.setTeacherOpenCourseStudentSigninSettingEndTime(new Date());
openCourseStudentSigninSetting.setTeacherOpenCourseStudentSigninSettingType(Constant.MANUAL); openCourseStudentSigninSetting.setTeacherOpenCourseStudentSigninSettingType(Constant.MANUAL);
openCourseStudentSigninSetting.setUserId(tchManualSignDTO.getUserId()); openCourseStudentSigninSetting.setUserId(tchManualSignDTO.getUserId());
openCourseStudentSigninSetting.setOrgId(Long.valueOf(tchManualSignDTO.getOrgId()));
teacherOpenCourseStudentSigninSettingMapper.insertSelective(openCourseStudentSigninSetting); teacherOpenCourseStudentSigninSettingMapper.insertSelective(openCourseStudentSigninSetting);
@ -228,7 +311,7 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
//判断是否缺勤或者签到 //判断是否缺勤或者签到
TeacherOpenCourseStudentSigninLog studentSigninLog = TeacherOpenCourseStudentSigninLog.builder() TeacherOpenCourseStudentSigninLog studentSigninLog = TeacherOpenCourseStudentSigninLog.builder()
.teacherOpenCourseStudentSigninSettingId(tchManualSignDTO.getTeacherOpenCourseStudentSigninSettingId()) .teacherOpenCourseStudentSigninSettingId((long) i2)
.teacherOpenCourseStudentSigninSettingSessionTime(tchManualSignDTO.getTeacherOpenCourseStudentSigninSettingSessionTime()) .teacherOpenCourseStudentSigninSettingSessionTime(tchManualSignDTO.getTeacherOpenCourseStudentSigninSettingSessionTime())
.studentId(item.getStudentId()) .studentId(item.getStudentId())
.teacherOpenCourseStudentSigninLogTag(item.getTeacherOpenCourseStudentSigninLogTag()) .teacherOpenCourseStudentSigninLogTag(item.getTeacherOpenCourseStudentSigninLogTag())
@ -253,7 +336,7 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
StuUserExample userExample = new StuUserExample(); StuUserExample userExample = new StuUserExample();
userExample.createCriteria().andClassIdIn(Arrays.stream(split).collect(Collectors.toList())); userExample.createCriteria().andClassIdIn(Arrays.stream(split).collect(Collectors.toList())).andRoleIdEqualTo(4);
//查询多个班级所有学生 //查询多个班级所有学生
List<StuUser> stuUserList = stuUserMapper.selectByExample(userExample); List<StuUser> stuUserList = stuUserMapper.selectByExample(userExample);
if (stuUserList.isEmpty()) { if (stuUserList.isEmpty()) {
@ -275,7 +358,7 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
.teacherOpenCourseStudentSigninLogAddTime(list.get(0).getTeacherOpenCourseStudentSigninLogAddTime()) .teacherOpenCourseStudentSigninLogAddTime(list.get(0).getTeacherOpenCourseStudentSigninLogAddTime())
.teacherOpenCourseStudentSigninLogTag(10) .teacherOpenCourseStudentSigninLogTag(10)
.userId(Convert.toLong(stuUser.getUserId())) .userId(Convert.toLong(stuUser.getUserId()))
.teacherOpenCourseStudentSigninSettingId(tchManualSignDTO.getTeacherOpenCourseStudentSigninSettingId()) .teacherOpenCourseStudentSigninSettingId((long) i2)
.teacherOpenCourseStudentSigninSettingSessionTime(tchManualSignDTO.getTeacherOpenCourseStudentSigninSettingSessionTime()) .teacherOpenCourseStudentSigninSettingSessionTime(tchManualSignDTO.getTeacherOpenCourseStudentSigninSettingSessionTime())
.teacherOpenCourseId(tchManualSignDTO.getTeacherOpenCourseId()) .teacherOpenCourseId(tchManualSignDTO.getTeacherOpenCourseId())
.schoolClassId(Long.parseLong(stuUser.getClassId())).build(); .schoolClassId(Long.parseLong(stuUser.getClassId())).build();
@ -365,6 +448,12 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
int missStudent = 0; int missStudent = 0;
double totalAttendRate = 0.0; double totalAttendRate = 0.0;
int summarySum = 0;
int summarySignCount = 0;
int summaryMissStudent = 0;
int summaryAttendRate = 0;
// 开启分页,确保分页在数据库查询之前 // 开启分页,确保分页在数据库查询之前
PageHelper.startPage(page, size); PageHelper.startPage(page, size);
//根据课程ID查询所有签到数据 //根据课程ID查询所有签到数据
@ -386,7 +475,7 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
} }
//合计老师开启签到次数 //合计老师开启签到次数
sum = teacherOpenCourseStudentSigninSettingList.size(); summarySum = teacherOpenCourseStudentSigninSettingList.size();
//存储记录表List //存储记录表List
List<TeacherSigninSettingDTO> teacherSigninSettingDTOS = new ArrayList<>(); List<TeacherSigninSettingDTO> teacherSigninSettingDTOS = new ArrayList<>();
@ -402,7 +491,7 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
//查询每个班级人数 //查询每个班级人数
StuUserExample stuUserExample = new StuUserExample(); StuUserExample stuUserExample = new StuUserExample();
stuUserExample.createCriteria().andClassIdIn(Arrays.stream(split).collect(Collectors.toList())); stuUserExample.createCriteria().andClassIdIn(Arrays.stream(split).collect(Collectors.toList())).andRoleIdEqualTo(4);
//总人数 //总人数
@ -412,8 +501,7 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
TeacherOpenCourseStudentSigninLogExample studentSigninLogExample = new TeacherOpenCourseStudentSigninLogExample(); TeacherOpenCourseStudentSigninLogExample studentSigninLogExample = new TeacherOpenCourseStudentSigninLogExample();
studentSigninLogExample.createCriteria() studentSigninLogExample.createCriteria()
.andTeacherOpenCourseStudentSigninSettingIdEqualTo .andTeacherOpenCourseStudentSigninSettingIdEqualTo(openCourseStudentSigninSetting.getTeacherOpenCourseStudentSigninSettingId());
(openCourseStudentSigninSetting.getTeacherOpenCourseStudentSigninSettingId());
List<TeacherOpenCourseStudentSigninLog> teacherOpenCourseStudentSigninLogList = List<TeacherOpenCourseStudentSigninLog> teacherOpenCourseStudentSigninLogList =
teacherOpenCourseStudentSigninLogMapper.selectByExample(studentSigninLogExample); teacherOpenCourseStudentSigninLogMapper.selectByExample(studentSigninLogExample);
@ -427,23 +515,31 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
//缺勤签到人数 //缺勤签到人数
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();
//签到人数
int size1 = teacherOpenCourseStudentSigninLogList.stream().filter(item -> item.getTeacherOpenCourseStudentSigninLogTag() == 10).collect(Collectors.toList()).size();
summarySignCount = summarySignCount+size1;
summaryMissStudent = summaryMissStudent+ (countByClass - size1);
// 先转换为浮点数进行除法运算 // 先转换为浮点数进行除法运算
double result = (double) missSizeManual / countByClass; double result = (double) size1 / countByClass;
// 四舍五入保留两位小数 // 四舍五入保留两位小数
//总到课率 //总到课率
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(size1);
teacherSigninSettingDTO.setMissStudent(missSizeManual); teacherSigninSettingDTO.setMissStudent(countByClass - size1);
teacherSigninSettingDTO.setTotalAttendRate(roundedResult); summaryAttendRate = summaryAttendRate+(int) (roundedResult * 100);
teacherSigninSettingDTO.setTotalAttendRate(roundedResult * 100);
teacherSigninSettingDTO.setClassName(classString(teacherSigninSettingDTO.getSchoolClassIds())); teacherSigninSettingDTO.setClassName(classString(teacherSigninSettingDTO.getSchoolClassIds()));
@ -464,6 +560,9 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
missStudent = +info; missStudent = +info;
summarySignCount = summarySignCount +size1;
summaryMissStudent =summaryMissStudent + (countByClass - size1);
TeacherSigninSettingDTO teacherSigninSettingDTO = new TeacherSigninSettingDTO(); TeacherSigninSettingDTO teacherSigninSettingDTO = new TeacherSigninSettingDTO();
@ -486,7 +585,7 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
//合计到课率 //合计到课率
totalAttendRate = +roundedResult; totalAttendRate = +roundedResult;
summaryAttendRate = summaryAttendRate+(int) (roundedResult * 100);
teacherSigninSettingDTO.setTotalAttendRate(roundedResult); teacherSigninSettingDTO.setTotalAttendRate(roundedResult);
teacherSigninSettingDTO.setClassName(classString(teacherSigninSettingDTO.getSchoolClassIds())); teacherSigninSettingDTO.setClassName(classString(teacherSigninSettingDTO.getSchoolClassIds()));
teacherSigninSettingDTOS.add(teacherSigninSettingDTO); teacherSigninSettingDTOS.add(teacherSigninSettingDTO);
@ -513,8 +612,10 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
// 包装分页后的结果列表 // 包装分页后的结果列表
PageInfo<TeacherSigninSettingDTO> teacherSigninSettingDTOPageInfo = new PageInfo<>(teacherSigninSettingDTOS); PageInfo<TeacherSigninSettingDTO> teacherSigninSettingDTOPageInfo = new PageInfo<>(teacherSigninSettingDTOS);
summaryAttendRate = summaryAttendRate / summarySum;
TchSignInfoDTO tchSignInfoDTO = TchSignInfoDTO.builder().signCount(signCount).sum(sum).missStudent(missStudent).totalAttendRate(totalAttendRate) TchSignInfoDTO tchSignInfoDTO = TchSignInfoDTO.builder().signCount(summarySignCount).sum(summarySum).missStudent(summaryMissStudent).totalAttendRate(summaryAttendRate)
.signinSettingList(teacherSigninSettingDTOPageInfo).build(); .signinSettingList(teacherSigninSettingDTOPageInfo).build();
return new ResultEntity<>(HttpStatus.OK, tchSignInfoDTO); return new ResultEntity<>(HttpStatus.OK, tchSignInfoDTO);
@ -775,7 +876,7 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou
//查询班级所有用户 //查询班级所有用户
String[] split = classIds.split(","); String[] split = classIds.split(",");
StuUserExample userExample = new StuUserExample(); StuUserExample userExample = new StuUserExample();
userExample.createCriteria().andClassIdIn(Arrays.stream(split).collect(Collectors.toList())); userExample.createCriteria().andClassIdIn(Arrays.stream(split).collect(Collectors.toList())).andRoleIdEqualTo(4);
List<StuUser> stuUserList = stuUserMapper.selectByExample(userExample); List<StuUser> stuUserList = stuUserMapper.selectByExample(userExample);
if (stuUserList.isEmpty()) { if (stuUserList.isEmpty()) {
return null; return null;

@ -12,7 +12,7 @@ spring:
file: file:
type: local type: local
path: D:\home\trade path: D:\home\trade
# path: D:\home url: "http://localhost:99"
# path: /usr/local/tianzeProject/blockFinance/uploadFile # path: /usr/local/tianzeProject/blockFinance/uploadFile
item: item:
@ -24,3 +24,4 @@ item:

Loading…
Cancel
Save