diff --git a/start/src/main/resources/templates/template/attendance_record.docx b/start/src/main/resources/templates/template/attendance_record.docx index b7d0e13..8cf126c 100644 --- a/start/src/main/resources/templates/template/attendance_record.docx +++ b/start/src/main/resources/templates/template/attendance_record.docx @@ -14,7 +14,7 @@ 培训类型 {{trainTypeName}} 视频学习时长 - {{videoTotalTime}}(包含{{videoCount}}个视频课件) + {{videoTotalTimeStr}}(包含{{videoCount}}个视频课件) 培训单位:(盖章) 日期: diff --git a/start/src/main/resources/templates/template/studyRecord.docx b/start/src/main/resources/templates/template/studyRecord.docx index 675a2ff..a2acc59 100644 --- a/start/src/main/resources/templates/template/studyRecord.docx +++ b/start/src/main/resources/templates/template/studyRecord.docx @@ -6,7 +6,7 @@ 课程名称 {{trainSubject}} 视频时长 - {{videoTotalTime}} + {{videoTotalTimeStr}} 是否完成 {{stateName}} 签到人脸验证 diff --git a/web-app/src/main/java/com/zcloud/edu/command/query/archives/ArchivesQueryExe.java b/web-app/src/main/java/com/zcloud/edu/command/query/archives/ArchivesQueryExe.java index 44176df..41bf6e3 100644 --- a/web-app/src/main/java/com/zcloud/edu/command/query/archives/ArchivesQueryExe.java +++ b/web-app/src/main/java/com/zcloud/edu/command/query/archives/ArchivesQueryExe.java @@ -54,6 +54,7 @@ import org.springframework.stereotype.Component; import org.springframework.util.ObjectUtils; import java.io.File; +import java.math.BigDecimal; import java.nio.file.Files; import java.nio.file.Paths; import java.time.format.DateTimeFormatter; @@ -471,6 +472,7 @@ public class ArchivesQueryExe { // // workItem.put("examSignFacePicture", defaultPicture); // } } + BigDecimal videoTotalTime = params.getVideoTotalTime(); String templatePath = "templates/template/studyRecord.docx"; ByteArrayOutputStream outputStream = Tools.renderTemplate(templatePath, workItem); @@ -521,11 +523,11 @@ public class ArchivesQueryExe { workItem.put("className", params.getClassName()); if(!ObjectUtils.isEmpty(params.getStudentExamRecord().getSignUrl())){ // PictureRenderData signPicture = Pictures.ofUrl(fileUrlConfig.getPrefixUrl() + params.getStudentExamRecord().getSignUrl(), PictureType.JPEG).size(50, 15).create();//网络图片地址 - PictureRenderData signPicture = ImageUtil.createWithThumbnailator(fileUrlConfig.getPrefixUrl() + params.getStudentExamRecord(), 50, 15); + PictureRenderData signPicture = ImageUtil.createWithThumbnailator(fileUrlConfig.getPrefixUrl() + params.getStudentExamRecord().getSignUrl(), 50, 15); workItem.put("signPicture", signPicture); } - log.info("考试试卷下载转换前,{}",JSONUtil.toJsonStr(params.getStudentExamRecord())); - log.info("考试试卷下载,{}",JSONUtil.toJsonStr(workItem)); +// log.info("考试试卷下载转换前,{}",JSONUtil.toJsonStr(params.getStudentExamRecord())); +// log.info("考试试卷下载,{}",JSONUtil.toJsonStr(workItem)); String templatePath = "templates/template/exam.docx"; ByteArrayOutputStream outputStream = Tools.renderTemplate(templatePath, workItem); return outputStream.toByteArray(); diff --git a/web-client/src/main/java/com/zcloud/edu/dto/data/archives/PersonArchivesDTO.java b/web-client/src/main/java/com/zcloud/edu/dto/data/archives/PersonArchivesDTO.java index 6a68c60..9e9428f 100644 --- a/web-client/src/main/java/com/zcloud/edu/dto/data/archives/PersonArchivesDTO.java +++ b/web-client/src/main/java/com/zcloud/edu/dto/data/archives/PersonArchivesDTO.java @@ -139,6 +139,7 @@ public class PersonArchivesDTO { @ApiModelProperty(value = "视频时长") private BigDecimal videoTotalTime; + private String videoTotalTimeStr; @ApiModelProperty(value = "课件数") private Integer videoCount; diff --git a/web-domain/src/main/java/com/zcloud/edu/domain/model/archives/PersonArchivesE.java b/web-domain/src/main/java/com/zcloud/edu/domain/model/archives/PersonArchivesE.java index 821d6d1..06b31a4 100644 --- a/web-domain/src/main/java/com/zcloud/edu/domain/model/archives/PersonArchivesE.java +++ b/web-domain/src/main/java/com/zcloud/edu/domain/model/archives/PersonArchivesE.java @@ -140,6 +140,7 @@ public class PersonArchivesE extends BaseE { private String trainSubject; @ApiModelProperty(value = "视频时长") private BigDecimal videoTotalTime; + private String videoTotalTimeStr; @ApiModelProperty(value = "课件数") private Integer videoCount; @ApiModelProperty(value = "打卡签到人脸图片路径") @@ -199,7 +200,32 @@ public class PersonArchivesE extends BaseE { .filter(bigDecimal -> bigDecimal != null) // 过滤null值,防止空指针异常 .reduce(BigDecimal.ZERO, BigDecimal::add); setVideoTotalTime(videoTotalTime); + setVideoTotalTimeStr(getTimeStr(videoTotalTime)); } + + public String getTimeStr(BigDecimal decimal) { + + if (decimal != null) { + long totalSeconds = decimal.longValue(); + long hours = totalSeconds / 3600; + long minutes = (totalSeconds % 3600) / 60; + long seconds = totalSeconds % 60; + + StringBuilder timeText = new StringBuilder(); + if (hours > 0) { + timeText.append(hours).append("小时"); + } + if (minutes > 0) { + timeText.append(minutes).append("分"); + } + if (seconds > 0 || timeText.length() == 0) { + timeText.append(seconds).append("秒"); + } + return timeText.toString(); + } + return ""; + } + public void initStudyRecord(StudentE studentE, ClassE classE, List studentSignEList, List classCurList) { BeanUtils.copyProperties(studentE, this); @@ -226,6 +252,7 @@ public class PersonArchivesE extends BaseE { String trainSubject = classCurList.stream().map(ClassCurriculumE::getCurriculumName).collect(Collectors.joining(",")); setTrainSubject(trainSubject); setVideoTotalTime(videoTotalTime); + setVideoTotalTimeStr(getTimeStr(videoTotalTime)); if (studentSignEList != null && studentSignEList.size() > 0){ for (StudentSignE studentSignE : studentSignEList){ if(studentSignE.getType() == 1 @@ -280,6 +307,7 @@ public class PersonArchivesE extends BaseE { .filter(bigDecimal -> bigDecimal != null) // 过滤null值,防止空指针异常 .reduce(BigDecimal.ZERO, BigDecimal::add); setVideoTotalTime(videoTotalTime); + setVideoTotalTimeStr(getTimeStr(videoTotalTime)); } if (chapterEList != null && chapterEList.size() > 0){ setVideoCount(chapterEList.size());