From a51f327b912cfc80e8441339a7875d7dbf9cbe33 Mon Sep 17 00:00:00 2001 From: whb <17803890193@163.com> Date: Mon, 30 Dec 2024 14:57:09 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=85=AC=E5=91=8A?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../stu/StuExpermentTrainingController.java | 3 +- .../controller/tch/TchSignInfoController.java | 9 +- .../TeacherOpenCourseStudentSigninLog.java | 2 + .../trade/entity/dto/TchManualSignDTO.java | 17 +- .../entity/dto/TeacherSigninSettingDTO.java | 4 + .../impl/StuExpermentTrainingServiceImpl.java | 8 +- .../impl/TchPublicNoticeServiceImpl.java | 92 ++++++---- ...herOpenCourseStudentSigninServiceImpl.java | 159 ++++++++++++++---- src/main/resources/application-dev.yml | 3 +- 9 files changed, 213 insertions(+), 84 deletions(-) diff --git a/src/main/java/com/sztzjy/trade/controller/stu/StuExpermentTrainingController.java b/src/main/java/com/sztzjy/trade/controller/stu/StuExpermentTrainingController.java index 52a0dcd..c1f5415 100644 --- a/src/main/java/com/sztzjy/trade/controller/stu/StuExpermentTrainingController.java +++ b/src/main/java/com/sztzjy/trade/controller/stu/StuExpermentTrainingController.java @@ -108,14 +108,13 @@ public class StuExpermentTrainingController { @ApiOperation("实训文件上传接口") @PostMapping("/upload") @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()) { return new ResultEntity<>(HttpStatus.BAD_REQUEST,"文件不能为空"); } - //保存文件路径 String filePath = iFileUtil.upload(file); return service.uploadFileByExperment(filePath,module,userId,name); diff --git a/src/main/java/com/sztzjy/trade/controller/tch/TchSignInfoController.java b/src/main/java/com/sztzjy/trade/controller/tch/TchSignInfoController.java index 52cc43a..deef6a3 100644 --- a/src/main/java/com/sztzjy/trade/controller/tch/TchSignInfoController.java +++ b/src/main/java/com/sztzjy/trade/controller/tch/TchSignInfoController.java @@ -12,6 +12,8 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; 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.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -30,6 +32,7 @@ import java.util.Date; @RestController @Api(tags = "签到") @Validated +@EnableAsync public class TchSignInfoController { @@ -71,10 +74,11 @@ public class TchSignInfoController { @PostMapping("/endSign") @ApiOperation("教师端结束签到") @AnonymousAccess + @Async public ResultEntity endSign(@RequestBody TchEndSignDTO tchEndSignDTO) { - //结束签到要把未签到用户统计 + //结束签到要把未签到用户搞成未签到 return teacherOpenCourseStudentSigninService.endSign(tchEndSignDTO); } @@ -82,8 +86,7 @@ public class TchSignInfoController { @PostMapping("/manualSignByRandom") @ApiOperation("手动签到随机抽取") @AnonymousAccess - public ResultEntity manualSignByRandom(@RequestBody @Valid - @ApiParam("只传参:classIds") TchManualSignDTO tchManualSignDTO) { + public ResultEntity manualSignByRandom(@RequestBody @ApiParam("只传参:classIds") TchManualSignDTO tchManualSignDTO) { return teacherOpenCourseStudentSigninService.manualSignByRandom(tchManualSignDTO); diff --git a/src/main/java/com/sztzjy/trade/entity/TeacherOpenCourseStudentSigninLog.java b/src/main/java/com/sztzjy/trade/entity/TeacherOpenCourseStudentSigninLog.java index b96499e..1e296ce 100644 --- a/src/main/java/com/sztzjy/trade/entity/TeacherOpenCourseStudentSigninLog.java +++ b/src/main/java/com/sztzjy/trade/entity/TeacherOpenCourseStudentSigninLog.java @@ -4,6 +4,7 @@ import java.util.Date; import io.swagger.annotations.ApiModelProperty; import lombok.Builder; +import lombok.Data; /** * 教师-我的课程-开课-学生签到记录 @@ -11,6 +12,7 @@ import lombok.Builder; * @author whb * teacher_open_course_student_signin_log */ +@Data @Builder public class TeacherOpenCourseStudentSigninLog { @ApiModelProperty(notes = "ID") diff --git a/src/main/java/com/sztzjy/trade/entity/dto/TchManualSignDTO.java b/src/main/java/com/sztzjy/trade/entity/dto/TchManualSignDTO.java index de3c828..e84c89c 100644 --- a/src/main/java/com/sztzjy/trade/entity/dto/TchManualSignDTO.java +++ b/src/main/java/com/sztzjy/trade/entity/dto/TchManualSignDTO.java @@ -21,39 +21,34 @@ import java.util.List; public class TchManualSignDTO { @ApiModelProperty("签到表ID") - @NotNull(message = "签到表ID不能为空") private Long teacherOpenCourseStudentSigninSettingId; @ApiModelProperty("课程ID") - @NotNull(message = "课程ID不能为空") private Long teacherOpenCourseId; @ApiModelProperty("签到的班级") - @NotNull(message = "签到的班级能为空") private String classIds; + @ApiModelProperty("抽取人数") + private Integer RandomNumber; + @ApiModelProperty("场次时间") - @NotNull(message = "场次时间不能为空") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") private Date teacherOpenCourseStudentSigninSettingSessionTime; @ApiModelProperty("教师ID") - @NotNull(message = "教师ID不能为空") private Long userId; + @ApiModelProperty("教师ID") + private String orgId; + @ApiModelProperty("用户签到数据") private List tchManualSignSettingDTOList; - - - - - - } diff --git a/src/main/java/com/sztzjy/trade/entity/dto/TeacherSigninSettingDTO.java b/src/main/java/com/sztzjy/trade/entity/dto/TeacherSigninSettingDTO.java index e421a8f..6f2311e 100644 --- a/src/main/java/com/sztzjy/trade/entity/dto/TeacherSigninSettingDTO.java +++ b/src/main/java/com/sztzjy/trade/entity/dto/TeacherSigninSettingDTO.java @@ -3,9 +3,11 @@ package com.sztzjy.trade.entity.dto;/** * @date 2024-08-09 14:23 */ +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import lombok.Builder; import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; import java.util.Date; @@ -19,6 +21,8 @@ public class TeacherSigninSettingDTO { private Long teacherOpenCourseStudentSigninSettingId; @ApiModelProperty("场次时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") private Date teacherOpenCourseStudentSigninSettingSessionTime; @ApiModelProperty("开课ID") diff --git a/src/main/java/com/sztzjy/trade/service/impl/StuExpermentTrainingServiceImpl.java b/src/main/java/com/sztzjy/trade/service/impl/StuExpermentTrainingServiceImpl.java index 263edf6..ace9cb8 100644 --- a/src/main/java/com/sztzjy/trade/service/impl/StuExpermentTrainingServiceImpl.java +++ b/src/main/java/com/sztzjy/trade/service/impl/StuExpermentTrainingServiceImpl.java @@ -15,6 +15,7 @@ import com.sztzjy.trade.util.ResultEntity; import org.apache.poi.ss.formula.functions.T; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -58,6 +59,9 @@ public class StuExpermentTrainingServiceImpl implements StuExpermentTrainingServ private RedisUtil redisUtil; + @Value("${file.url}") + public String url; + @Override @Transactional(rollbackFor = Exception.class) public ResultEntity expermentSubmit(StuTaskPracticeRecord stuTaskPracticeRecord) { @@ -481,14 +485,14 @@ public class StuExpermentTrainingServiceImpl implements StuExpermentTrainingServ uploadExperment.setModule(module); uploadExperment.setUserId(userId); stuUploadExpermentMapper.insertSelective(uploadExperment); - return new ResultEntity<>(HttpStatus.OK, "上传成功!"); + return new ResultEntity<>(HttpStatus.OK, "上传成功!",url+filePath); } else { StuUploadExperment uploadExperment = stuUploadExpermentList.get(0); uploadExperment.setUpdateTime(new Date()); uploadExperment.setFilePath(filePath); stuUploadExpermentMapper.updateByPrimaryKeySelective(uploadExperment); - return new ResultEntity<>(HttpStatus.OK, "上传成功!"); + return new ResultEntity<>(HttpStatus.OK, "上传成功!",url+filePath); } diff --git a/src/main/java/com/sztzjy/trade/service/impl/TchPublicNoticeServiceImpl.java b/src/main/java/com/sztzjy/trade/service/impl/TchPublicNoticeServiceImpl.java index 8adb85a..efbd04c 100644 --- a/src/main/java/com/sztzjy/trade/service/impl/TchPublicNoticeServiceImpl.java +++ b/src/main/java/com/sztzjy/trade/service/impl/TchPublicNoticeServiceImpl.java @@ -22,6 +22,7 @@ import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; import java.util.*; +import java.util.stream.Collectors; @Service public class TchPublicNoticeServiceImpl implements TchPublicNoticeService { @@ -87,15 +88,21 @@ public class TchPublicNoticeServiceImpl implements TchPublicNoticeService { .userId(userId).build(); stuPublicNoticeReadInfoMapper.insertSelective(readInfo); + TchPublicNoticeExample noticeExample = new TchPublicNoticeExample(); + noticeExample.createCriteria().andNoticeIdEqualTo(noticeId); + List tchPublicNoticeList = publicNoticeMapper.selectByExampleWithBLOBs(noticeExample); - return new ResultEntity<>(HttpStatus.OK); + + + return new ResultEntity<>(HttpStatus.OK,tchPublicNoticeList.get(0).getNoticeContent()); } //学生查询课程内已发布公告 @Override public ResultEntity stuPublicNoticeByCourse(String courseId, String schoolId, String userId) { + //查询课程下所有公告 TchPublicNoticeCourseExample example = new TchPublicNoticeCourseExample(); example.createCriteria().andCourseIdEqualTo(courseId).andSchoolIdEqualTo(schoolId); List tchPublicNoticeCourseList = publicNoticeCourseMapper.selectByExample(example); @@ -103,48 +110,61 @@ public class TchPublicNoticeServiceImpl implements TchPublicNoticeService { { return new ResultEntity<>(HttpStatus.OK); } - - StuPublicNoticeByReadInfoDTO stuPublicNoticeByReadInfoDTO = new StuPublicNoticeByReadInfoDTO(); - - List publicNoticeArrayList = new ArrayList<>(); + //公告ID集合 + List stringList = tchPublicNoticeCourseList.stream().map(item -> item.getNoticeId()).collect(Collectors.toList()); + + //查询公告列表 + TchPublicNoticeExample noticeExample = new TchPublicNoticeExample(); + noticeExample.createCriteria().andNoticeIdIn(stringList).andSchoolIdEqualTo(schoolId); + List tchPublicNoticeList = publicNoticeMapper.selectByExampleWithBLOBs(noticeExample); + + //查询已读取列表数据 + StuPublicNoticeReadInfoExample publicNoticeReadInfoExample = new StuPublicNoticeReadInfoExample(); + publicNoticeReadInfoExample.createCriteria().andUserIdEqualTo(userId).andNoticeIdIn(stringList); + List stuPublicNoticeReadInfoList = stuPublicNoticeReadInfoMapper.selectByExample(publicNoticeReadInfoExample); List readInfoList = new ArrayList<>(); - for (TchPublicNoticeCourse publicNoticeCourse : tchPublicNoticeCourseList) { - - TchPublicNoticeExample noticeExample = new TchPublicNoticeExample(); - noticeExample.createCriteria().andNoticeIdEqualTo(publicNoticeCourse.getNoticeId()).andSchoolIdEqualTo(schoolId); - List tchPublicNoticeList = publicNoticeMapper.selectByExampleWithBLOBs(noticeExample); - if (tchPublicNoticeList.isEmpty()) - { - new RuntimeException("Id为:"+publicNoticeCourse.getNoticeId()+"不存在!"); - } - - publicNoticeArrayList.add(tchPublicNoticeList.get(0)); - + if (stuPublicNoticeReadInfoList.isEmpty()) + { + readInfoList = Collections.emptyList(); + } - StuPublicNoticeReadInfoExample publicNoticeReadInfoExample = new StuPublicNoticeReadInfoExample(); - publicNoticeReadInfoExample.createCriteria().andUserIdEqualTo(userId).andNoticeIdEqualTo(publicNoticeCourse.getNoticeId()); + readInfoList = stuPublicNoticeReadInfoList.stream().map(item->item.getNoticeId()).collect(Collectors.toList()); - List stuPublicNoticeReadInfoList = stuPublicNoticeReadInfoMapper.selectByExample(publicNoticeReadInfoExample); - if (stuPublicNoticeReadInfoList.isEmpty()) - { - continue; - }else { - readInfoList.add(publicNoticeCourse.getNoticeId()); - } - - } - Collections.sort(publicNoticeArrayList, new Comparator() { - @Override - public int compare(TchPublicNotice s1, TchPublicNotice s2) { - return s2.getCreateTime().compareTo(s1.getCreateTime()); - } - }); + StuPublicNoticeByReadInfoDTO stuPublicNoticeByReadInfoDTO = new StuPublicNoticeByReadInfoDTO(); - stuPublicNoticeByReadInfoDTO.setTchPublicNotices(publicNoticeArrayList); - stuPublicNoticeByReadInfoDTO.setUnNoticeList(readInfoList); +// List publicNoticeArrayList = new ArrayList<>(); +// + +// for (TchPublicNoticeCourse publicNoticeCourse : tchPublicNoticeCourseList) { +// +// if (tchPublicNoticeList.isEmpty()) +// { +// new RuntimeException("Id为:"+publicNoticeCourse.getNoticeId()+"不存在!"); +// } +// List 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 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); diff --git a/src/main/java/com/sztzjy/trade/service/impl/TeacherOpenCourseStudentSigninServiceImpl.java b/src/main/java/com/sztzjy/trade/service/impl/TeacherOpenCourseStudentSigninServiceImpl.java index c6f3334..436a865 100644 --- a/src/main/java/com/sztzjy/trade/service/impl/TeacherOpenCourseStudentSigninServiceImpl.java +++ b/src/main/java/com/sztzjy/trade/service/impl/TeacherOpenCourseStudentSigninServiceImpl.java @@ -20,12 +20,14 @@ import com.sztzjy.trade.mapper.StuUserMapper; import com.sztzjy.trade.mapper.TeacherOpenCourseStudentSigninLogMapper; import com.sztzjy.trade.mapper.TeacherOpenCourseStudentSigninSettingMapper; import com.sztzjy.trade.service.TeacherOpenCourseStudentSigninService; +import com.sztzjy.trade.util.ConvertUtil; 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.scheduling.annotation.Async; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StringUtils; @@ -123,10 +125,86 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou openCourseStudentSigninSetting.setTeacherOpenCourseStudentSigninSettingStartStatus(String.valueOf(StartStatusEnum.END)); openCourseStudentSigninSetting.setTeacherOpenCourseStudentSigninSettingEndTime(new Date()); + + + teacherOpenCourseStudentSigninSettingMapper.updateByPrimaryKeySelective(openCourseStudentSigninSetting); + //根据ID查询签到用户 把未签到用户添加到记录表 + String[] split = openCourseStudentSigninSetting.getSchoolClassIds().split(",");; + + //查询所有学生 + + List collect = Arrays.stream(split).collect(Collectors.toList()); + //根据班级列表查询对应所有用户数据 + StuUserExample stuUserExample = new StuUserExample(); + stuUserExample.createCriteria().andClassIdIn(collect).andRoleIdEqualTo(4); + List stuUserList = stuUserMapper.selectByExample(stuUserExample); + if (stuUserList.isEmpty()) { + return new ResultEntity<>(HttpStatus.BAD_REQUEST, "暂无该班级"); + } + + // + TeacherOpenCourseStudentSigninLogExample example = new TeacherOpenCourseStudentSigninLogExample(); + example.createCriteria().andTeacherOpenCourseStudentSigninSettingIdEqualTo(tchEndSignDTO.getTeacherOpenCourseStudentSigninSettingId()); + + List courseStudentSigninLogs = teacherOpenCourseStudentSigninLogMapper.selectByExample(example); + if (!courseStudentSigninLogs.isEmpty()) { + List 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 vo.setTeacherOpenCourseStudentSigninSettingId(IdUtil.getSnowflakeNextId()); - // 定义要随机抽取的数量 - int numberOfUsersToSelect = 6; + String[] split = tchManualSignDTO.getClassIds().split(","); - for (String classId : split) { - numberOfUsersToSelect += 2; - } + List collect = Arrays.stream(split).collect(Collectors.toList()); //根据班级列表查询对应所有用户数据 StuUserExample stuUserExample = new StuUserExample(); @@ -165,9 +240,7 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou // 检查列表大小是否大于等于要抽取的数量 - if (stuUserList.size() < numberOfUsersToSelect) { - - + if (stuUserList.size() < tchManualSignDTO.getRandomNumber()) { // 抽取指定数量的元素 List selectedUsers = stuUserList.subList(0, stuUserList.size()); vo.setUserList(selectedUsers); @@ -177,7 +250,7 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou } else { // 抽取指定数量的元素 - List selectedUsers = stuUserList.subList(0, numberOfUsersToSelect); + List selectedUsers = stuUserList.subList(0, tchManualSignDTO.getRandomNumber()); vo.setUserList(selectedUsers); return new ResultEntity<>(HttpStatus.OK, vo); } @@ -193,6 +266,7 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou */ @Override + @Async public ResultEntity manualSignSure(TchManualSignDTO tchManualSignDTO) { //查询是否为多次插入 TeacherOpenCourseStudentSigninSetting teacherOpenCourseStudentSigninSetting = @@ -208,7 +282,15 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou //创建签到表 TeacherOpenCourseStudentSigninSetting openCourseStudentSigninSetting = new TeacherOpenCourseStudentSigninSetting(); 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.setSchoolClassIds(tchManualSignDTO.getClassIds()); openCourseStudentSigninSetting.setTeacherOpenCourseStudentSigninSettingAddTime((new Date())); @@ -218,6 +300,7 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou openCourseStudentSigninSetting.setTeacherOpenCourseStudentSigninSettingEndTime(new Date()); openCourseStudentSigninSetting.setTeacherOpenCourseStudentSigninSettingType(Constant.MANUAL); openCourseStudentSigninSetting.setUserId(tchManualSignDTO.getUserId()); + openCourseStudentSigninSetting.setOrgId(Long.valueOf(tchManualSignDTO.getOrgId())); teacherOpenCourseStudentSigninSettingMapper.insertSelective(openCourseStudentSigninSetting); @@ -228,7 +311,7 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou //判断是否缺勤或者签到 TeacherOpenCourseStudentSigninLog studentSigninLog = TeacherOpenCourseStudentSigninLog.builder() - .teacherOpenCourseStudentSigninSettingId(tchManualSignDTO.getTeacherOpenCourseStudentSigninSettingId()) + .teacherOpenCourseStudentSigninSettingId((long) i2) .teacherOpenCourseStudentSigninSettingSessionTime(tchManualSignDTO.getTeacherOpenCourseStudentSigninSettingSessionTime()) .studentId(item.getStudentId()) .teacherOpenCourseStudentSigninLogTag(item.getTeacherOpenCourseStudentSigninLogTag()) @@ -253,7 +336,7 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou 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 stuUserList = stuUserMapper.selectByExample(userExample); if (stuUserList.isEmpty()) { @@ -275,7 +358,7 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou .teacherOpenCourseStudentSigninLogAddTime(list.get(0).getTeacherOpenCourseStudentSigninLogAddTime()) .teacherOpenCourseStudentSigninLogTag(10) .userId(Convert.toLong(stuUser.getUserId())) - .teacherOpenCourseStudentSigninSettingId(tchManualSignDTO.getTeacherOpenCourseStudentSigninSettingId()) + .teacherOpenCourseStudentSigninSettingId((long) i2) .teacherOpenCourseStudentSigninSettingSessionTime(tchManualSignDTO.getTeacherOpenCourseStudentSigninSettingSessionTime()) .teacherOpenCourseId(tchManualSignDTO.getTeacherOpenCourseId()) .schoolClassId(Long.parseLong(stuUser.getClassId())).build(); @@ -365,6 +448,12 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou int missStudent = 0; double totalAttendRate = 0.0; + + int summarySum = 0; + int summarySignCount = 0; + int summaryMissStudent = 0; + int summaryAttendRate = 0; + // 开启分页,确保分页在数据库查询之前 PageHelper.startPage(page, size); //根据课程ID查询所有签到数据 @@ -386,7 +475,7 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou } //合计老师开启签到次数 - sum = teacherOpenCourseStudentSigninSettingList.size(); + summarySum = teacherOpenCourseStudentSigninSettingList.size(); //存储记录表List List teacherSigninSettingDTOS = new ArrayList<>(); @@ -402,7 +491,7 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou //查询每个班级人数 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(); studentSigninLogExample.createCriteria() - .andTeacherOpenCourseStudentSigninSettingIdEqualTo - (openCourseStudentSigninSetting.getTeacherOpenCourseStudentSigninSettingId()); + .andTeacherOpenCourseStudentSigninSettingIdEqualTo(openCourseStudentSigninSetting.getTeacherOpenCourseStudentSigninSettingId()); List teacherOpenCourseStudentSigninLogList = teacherOpenCourseStudentSigninLogMapper.selectByExample(studentSigninLogExample); @@ -427,23 +515,31 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou //缺勤签到人数 - int missSizeManual = teacherOpenCourseStudentSigninLogList.stream() - .filter(item -> item.getTeacherOpenCourseStudentSigninLogType().equals(Constant.MANUAL)) - .filter(item -> item.getTeacherOpenCourseStudentSigninLogTag() == 20) - .collect(Collectors.toList()).size(); +// int missSizeManual = teacherOpenCourseStudentSigninLogList.stream() +// .filter(item -> item.getTeacherOpenCourseStudentSigninLogType().equals(Constant.MANUAL)) +// .filter(item -> item.getTeacherOpenCourseStudentSigninLogTag() == 20) +// .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; teacherSigninSettingDTO.setSum(countByClass); - teacherSigninSettingDTO.setSignCount(countByClass - missSizeManual); - teacherSigninSettingDTO.setMissStudent(missSizeManual); - teacherSigninSettingDTO.setTotalAttendRate(roundedResult); + teacherSigninSettingDTO.setSignCount(size1); + teacherSigninSettingDTO.setMissStudent(countByClass - size1); + summaryAttendRate = summaryAttendRate+(int) (roundedResult * 100); + teacherSigninSettingDTO.setTotalAttendRate(roundedResult * 100); teacherSigninSettingDTO.setClassName(classString(teacherSigninSettingDTO.getSchoolClassIds())); @@ -464,6 +560,9 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou missStudent = +info; + summarySignCount = summarySignCount +size1; + summaryMissStudent =summaryMissStudent + (countByClass - size1); + TeacherSigninSettingDTO teacherSigninSettingDTO = new TeacherSigninSettingDTO(); @@ -486,7 +585,7 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou //合计到课率 totalAttendRate = +roundedResult; - + summaryAttendRate = summaryAttendRate+(int) (roundedResult * 100); teacherSigninSettingDTO.setTotalAttendRate(roundedResult); teacherSigninSettingDTO.setClassName(classString(teacherSigninSettingDTO.getSchoolClassIds())); teacherSigninSettingDTOS.add(teacherSigninSettingDTO); @@ -513,8 +612,10 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou // 包装分页后的结果列表 PageInfo 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(); return new ResultEntity<>(HttpStatus.OK, tchSignInfoDTO); @@ -775,7 +876,7 @@ public class TeacherOpenCourseStudentSigninServiceImpl implements TeacherOpenCou //查询班级所有用户 String[] split = classIds.split(","); 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 stuUserList = stuUserMapper.selectByExample(userExample); if (stuUserList.isEmpty()) { return null; diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 97f71f8..5200762 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -12,7 +12,7 @@ spring: file: type: local path: D:\home\trade -# path: D:\home + url: "http://localhost:99" # path: /usr/local/tianzeProject/blockFinance/uploadFile item: @@ -24,3 +24,4 @@ item: + From 5084d4d2994c5bab0be41748872e10e9731baf54 Mon Sep 17 00:00:00 2001 From: whb <17803890193@163.com> Date: Mon, 30 Dec 2024 18:10:01 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AD=A6=E7=94=9F?= =?UTF-8?q?=E7=AB=AF=E7=AD=BE=E5=88=B0=E7=8A=B6=E6=80=81=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=20=E5=AF=B9=E6=8E=A5DIC=E7=94=B3=E9=A2=86?= =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E5=92=8C=E5=AD=A6=E7=94=9F=E7=AB=AF=E7=AD=BE?= =?UTF-8?q?=E5=88=B0=E6=8E=A5=E5=8F=A3=EF=BC=8C=E4=BF=AE=E6=94=B9=E5=AF=B9?= =?UTF-8?q?=E6=8E=A5=E5=87=BA=E7=8E=B0=E7=9A=84bug=20DIC=E7=94=B3=E9=A2=86?= =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E6=B7=BB=E5=8A=A0=E5=85=B3=E9=94=AE=E7=BC=96?= =?UTF-8?q?=E7=A0=81=E7=94=9F=E6=88=90=E6=8E=A5=E5=8F=A3=20=E8=A7=A3?= =?UTF-8?q?=E5=86=B3=E6=95=B0=E5=AD=97=E8=B4=B8=E6=98=93=E5=8D=95=E7=8B=AC?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=90=8E=E8=BF=94=E5=9B=9E=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=95=B0=E6=8D=AEstudentId=E5=92=8C=E7=8F=AD=E7=BA=A7ID?= =?UTF-8?q?=E4=B8=BA=E4=B8=BA=E7=A9=BAbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../security/AuthenticationService.java | 1 + .../sztzjy/trade/config/security/JwtUser.java | 1 + .../trade/config/security/LoginResult.java | 6 +++ .../stu/StuExpermentTrainingController.java | 43 +++++++++++++++++++ .../controller/stu/StuSignInfoController.java | 1 + .../trade/controller/stu/UserController.java | 15 ++++--- .../trade/controller/task/TaskController.java | 3 +- .../sztzjy/trade/entity/StuCodeInfoDTO.java | 28 ++++++++++++ .../service/impl/StuSignInfoServiceImpl.java | 9 +++- 9 files changed, 100 insertions(+), 7 deletions(-) create mode 100644 src/main/java/com/sztzjy/trade/entity/StuCodeInfoDTO.java diff --git a/src/main/java/com/sztzjy/trade/config/security/AuthenticationService.java b/src/main/java/com/sztzjy/trade/config/security/AuthenticationService.java index 7721e3e..52683a8 100644 --- a/src/main/java/com/sztzjy/trade/config/security/AuthenticationService.java +++ b/src/main/java/com/sztzjy/trade/config/security/AuthenticationService.java @@ -34,6 +34,7 @@ public class AuthenticationService implements UserDetailsService { jwtUser.setUserId(user.getUserId()); jwtUser.setName(user.getName()); jwtUser.setRoleId(user.getRoleId()); + jwtUser.setStudentId(user.getStudentId()); return jwtUser; } diff --git a/src/main/java/com/sztzjy/trade/config/security/JwtUser.java b/src/main/java/com/sztzjy/trade/config/security/JwtUser.java index 36e1451..0ea0267 100644 --- a/src/main/java/com/sztzjy/trade/config/security/JwtUser.java +++ b/src/main/java/com/sztzjy/trade/config/security/JwtUser.java @@ -16,6 +16,7 @@ import java.util.Objects; @Setter public class JwtUser implements UserDetails { private String username; + private String studentId; private String password; private String name; private String userId; diff --git a/src/main/java/com/sztzjy/trade/config/security/LoginResult.java b/src/main/java/com/sztzjy/trade/config/security/LoginResult.java index 201ce92..cd39ece 100644 --- a/src/main/java/com/sztzjy/trade/config/security/LoginResult.java +++ b/src/main/java/com/sztzjy/trade/config/security/LoginResult.java @@ -41,6 +41,11 @@ public class LoginResult { @ApiModelProperty("用户名") private String username; + @ApiModelProperty("studentId") + private String studentId; + + + // user.setUserId(dataObject.getStr("userId")); // user.setName(dataObject.getStr("name")); @@ -74,6 +79,7 @@ public class LoginResult { result.setCollegeId(jwtUser.getCollegeId()); result.setUsername(jwtUser.getUsername()); result.setSchoolName(jwtUser.getSchoolName()); + result.setStudentId(jwtUser.getStudentId()); return result; } } diff --git a/src/main/java/com/sztzjy/trade/controller/stu/StuExpermentTrainingController.java b/src/main/java/com/sztzjy/trade/controller/stu/StuExpermentTrainingController.java index c1f5415..00419d1 100644 --- a/src/main/java/com/sztzjy/trade/controller/stu/StuExpermentTrainingController.java +++ b/src/main/java/com/sztzjy/trade/controller/stu/StuExpermentTrainingController.java @@ -1,8 +1,14 @@ package com.sztzjy.trade.controller.stu; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.util.HashUtil; +import cn.hutool.core.util.RandomUtil; +import cn.hutool.crypto.SecureUtil; +import cn.hutool.crypto.digest.DigestUtil; import com.sztzjy.trade.annotation.AnonymousAccess; import com.sztzjy.trade.entity.StuAchievementInfo; +import com.sztzjy.trade.entity.StuCodeInfoDTO; import com.sztzjy.trade.entity.StuTaskPracticeRecord; import com.sztzjy.trade.entity.dto.StuExpermentSubmitDTO; import com.sztzjy.trade.service.StuExpermentTrainingService; @@ -20,6 +26,9 @@ import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.File; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Random; /** @@ -122,4 +131,38 @@ public class StuExpermentTrainingController { } + + @ApiOperation("生成关键编码") + @GetMapping("/createInfo") + @AnonymousAccess + public ResultEntity createInfo() { + + StuCodeInfoDTO stuCodeInfoDTO = new StuCodeInfoDTO(); + Date date = new Date(); + String info = "RDCSOOANT."+new SimpleDateFormat("yyyyMMdd").format(date)+RandomUtil.randomNumbers(10); + stuCodeInfoDTO.setDCI(info); + + stuCodeInfoDTO.setDciTime(new SimpleDateFormat("yyyy年MM月dd日HH:mm:ss").format(date)); + + + stuCodeInfoDTO.setDciCode(RandomUtil.randomString(68)); + stuCodeInfoDTO.setDciHash(DigestUtil.sha256Hex(info)); + + return new ResultEntity<>(HttpStatus.OK,stuCodeInfoDTO); + + } + + public static void main(String[] args) { + Date date = new Date(); + + //new SimpleDateFormat("yyyy年MM月dd日HH::mm::ss").format(date); + + + + + + + System.out.println( ); + } + } diff --git a/src/main/java/com/sztzjy/trade/controller/stu/StuSignInfoController.java b/src/main/java/com/sztzjy/trade/controller/stu/StuSignInfoController.java index 47eccac..291699e 100644 --- a/src/main/java/com/sztzjy/trade/controller/stu/StuSignInfoController.java +++ b/src/main/java/com/sztzjy/trade/controller/stu/StuSignInfoController.java @@ -60,4 +60,5 @@ public class StuSignInfoController { + } diff --git a/src/main/java/com/sztzjy/trade/controller/stu/UserController.java b/src/main/java/com/sztzjy/trade/controller/stu/UserController.java index 566d824..11a1c21 100644 --- a/src/main/java/com/sztzjy/trade/controller/stu/UserController.java +++ b/src/main/java/com/sztzjy/trade/controller/stu/UserController.java @@ -112,12 +112,15 @@ public class UserController { SecurityContextHolder.getContext().setAuthentication(authentication); jwtUser = (JwtUser) authentication.getPrincipal(); String token = TokenProvider.createToken(jwtUser); - + loginResult.setClassId(Convert.toInt(stuUser.getClassId())); loginResult.setUserId(stuUser.getUserId()); - loginResult.setUsername(stuUser.getSchoolId()); + loginResult.setUsername(stuUser.getStudentId()); + loginResult.setName(stuUser.getName()); loginResult.setRoleId(stuUser.getRoleId()); + loginResult.setSchoolName(stuUser.getSchoolName()); loginResult.setSchoolId(Integer.valueOf(stuUser.getSchoolId())); loginResult.setAccessToken(token); + loginResult.setStudentId(stuUser.getStudentId()); redisUtil.set(itemName+"-token:"+jwtUser.getUserId(),token,3600); redisUtil.set(itemName+"-userId:"+jwtUser.getUserId(),System.currentTimeMillis(),3600); @@ -130,13 +133,15 @@ public class UserController { SecurityContextHolder.getContext().setAuthentication(authentication); jwtUser = (JwtUser) authentication.getPrincipal(); String token = TokenProvider.createToken(jwtUser); - + loginResult.setClassId(Convert.toInt(stuUser.getClassId())); loginResult.setUserId(stuUser.getUserId()); - loginResult.setUsername(stuUser.getSchoolId()); + loginResult.setName(stuUser.getName()); + loginResult.setUsername(stuUser.getStudentId()); loginResult.setRoleId(stuUser.getRoleId()); loginResult.setSchoolId(Integer.valueOf(stuUser.getSchoolId())); + loginResult.setStudentId(stuUser.getStudentId()); loginResult.setAccessToken(token); - + loginResult.setSchoolName(stuUser.getSchoolName()); redisUtil.set(itemName+"-token:"+jwtUser.getUserId(),token,3600); redisUtil.set(itemName+"-userId:"+jwtUser.getUserId(),System.currentTimeMillis(),3600); diff --git a/src/main/java/com/sztzjy/trade/controller/task/TaskController.java b/src/main/java/com/sztzjy/trade/controller/task/TaskController.java index ac9ac9c..1bc37b8 100644 --- a/src/main/java/com/sztzjy/trade/controller/task/TaskController.java +++ b/src/main/java/com/sztzjy/trade/controller/task/TaskController.java @@ -40,7 +40,8 @@ public class TaskController { long currentTime = System.currentTimeMillis(); // 获取当前时间戳 long timeDifference = currentTime - newTime; // 计算时间差 - long time = 20 * 60 * 1000; + //long time = 20 * 60 * 1000; + long time = 60 * 60 * 1000; // 判断时间差是否大于 20 分钟(20 分钟 = 20 * 60 * 1000 毫秒) if (timeDifference > time) { //大于20分钟未操作 表明用户已经离线 在线时长+20分钟 diff --git a/src/main/java/com/sztzjy/trade/entity/StuCodeInfoDTO.java b/src/main/java/com/sztzjy/trade/entity/StuCodeInfoDTO.java new file mode 100644 index 0000000..f7dad69 --- /dev/null +++ b/src/main/java/com/sztzjy/trade/entity/StuCodeInfoDTO.java @@ -0,0 +1,28 @@ +package com.sztzjy.trade.entity; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author 17803 + * @date 2024-12-30 15:53 + */ +@Data +public class StuCodeInfoDTO { + + @ApiModelProperty("dci") + private String DCI; + + + @ApiModelProperty("dci申领时间") + private String dciTime; + + @ApiModelProperty("dci统一证据编号") + private String dciCode; + + + @ApiModelProperty("dci哈希") + private String dciHash; + + +} diff --git a/src/main/java/com/sztzjy/trade/service/impl/StuSignInfoServiceImpl.java b/src/main/java/com/sztzjy/trade/service/impl/StuSignInfoServiceImpl.java index f335ade..40bca0e 100644 --- a/src/main/java/com/sztzjy/trade/service/impl/StuSignInfoServiceImpl.java +++ b/src/main/java/com/sztzjy/trade/service/impl/StuSignInfoServiceImpl.java @@ -9,6 +9,7 @@ import cn.hutool.core.lang.Assert; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.RandomUtil; import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import com.sztzjy.trade.config.Constant; import com.sztzjy.trade.entity.*; import com.sztzjy.trade.entity.dto.StuSignDTO; @@ -19,6 +20,7 @@ import com.sztzjy.trade.mapper.TeacherOpenCourseStudentSigninLogMapper; import com.sztzjy.trade.mapper.TeacherOpenCourseStudentSigninSettingMapper; import com.sztzjy.trade.service.StuSignInfoService; import com.sztzjy.trade.util.IpUtils; +import com.sztzjy.trade.util.RedisUtil; import com.sztzjy.trade.util.ResultEntity; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -48,6 +50,7 @@ public class StuSignInfoServiceImpl implements StuSignInfoService { @Autowired private StuLearningRecordMapper stuLearningRecordMapper; + /** * 课程内查询用户所有签到信息 * @@ -64,6 +67,8 @@ public class StuSignInfoServiceImpl implements StuSignInfoService { //开启分页 PageHelper.startPage(page, size); + + List list = new ArrayList<>(); //查询签到记录 @@ -128,7 +133,9 @@ public class StuSignInfoServiceImpl implements StuSignInfoService { } } - return new ResultEntity(HttpStatus.OK, list); + + PageInfo studentSigninSettingDTOPageInfo = new PageInfo<>(list); + return new ResultEntity(HttpStatus.OK, studentSigninSettingDTOPageInfo); } /** From efc8a7b3eb0a88f3b997ed403f7aab249e28d8a2 Mon Sep 17 00:00:00 2001 From: whb <17803890193@163.com> Date: Thu, 2 Jan 2025 14:10:03 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=94=9F=E6=88=90=E7=BC=96=E5=8F=B7=E7=AD=89?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../stu/StuExpermentTrainingController.java | 29 +++++++++++++++++++ .../entity/dto/StuCodeCertificateInfoDTO.java | 26 +++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 src/main/java/com/sztzjy/trade/entity/dto/StuCodeCertificateInfoDTO.java diff --git a/src/main/java/com/sztzjy/trade/controller/stu/StuExpermentTrainingController.java b/src/main/java/com/sztzjy/trade/controller/stu/StuExpermentTrainingController.java index 00419d1..80363f0 100644 --- a/src/main/java/com/sztzjy/trade/controller/stu/StuExpermentTrainingController.java +++ b/src/main/java/com/sztzjy/trade/controller/stu/StuExpermentTrainingController.java @@ -10,6 +10,7 @@ import com.sztzjy.trade.annotation.AnonymousAccess; import com.sztzjy.trade.entity.StuAchievementInfo; import com.sztzjy.trade.entity.StuCodeInfoDTO; import com.sztzjy.trade.entity.StuTaskPracticeRecord; +import com.sztzjy.trade.entity.dto.StuCodeCertificateInfoDTO; import com.sztzjy.trade.entity.dto.StuExpermentSubmitDTO; import com.sztzjy.trade.service.StuExpermentTrainingService; import com.sztzjy.trade.util.ResultEntity; @@ -152,6 +153,34 @@ public class StuExpermentTrainingController { } + + @ApiOperation("生成权益存证关键编码") + @GetMapping("/certificateInfo") + @AnonymousAccess + public ResultEntity certificateInfo() { + + StuCodeCertificateInfoDTO stuCodeInfoDTO = new StuCodeCertificateInfoDTO(); + + String info = "TTAS_S.0.2_."+RandomUtil.randomNumbers(45); + stuCodeInfoDTO.setCode(info); + + stuCodeInfoDTO.setDataHash(DigestUtil.sha256Hex(info)); + + + stuCodeInfoDTO.setAllCode(RandomUtil.randomString(68)); + + stuCodeInfoDTO.setHash(DigestUtil.sha256Hex(RandomUtil.randomString(10))); + + return new ResultEntity<>(HttpStatus.OK,stuCodeInfoDTO); + + } + + + + + + + public static void main(String[] args) { Date date = new Date(); diff --git a/src/main/java/com/sztzjy/trade/entity/dto/StuCodeCertificateInfoDTO.java b/src/main/java/com/sztzjy/trade/entity/dto/StuCodeCertificateInfoDTO.java new file mode 100644 index 0000000..ef46115 --- /dev/null +++ b/src/main/java/com/sztzjy/trade/entity/dto/StuCodeCertificateInfoDTO.java @@ -0,0 +1,26 @@ +package com.sztzjy.trade.entity.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author 17803 + * @date 2024-12-31 10:38 + */ +@Data +public class StuCodeCertificateInfoDTO { + @ApiModelProperty("授权凭证编号") + private String code; + + + @ApiModelProperty("数据哈希值") + private String dataHash; + + @ApiModelProperty("统一证据编号") + private String allCode; + + + @ApiModelProperty("文件hash") + private String hash; + +}