feat(archives): 添加视频时长格式化功能
parent
8030a85288
commit
5026b838a0
|
|
@ -14,7 +14,7 @@
|
||||||
培训类型
|
培训类型
|
||||||
{{trainTypeName}}
|
{{trainTypeName}}
|
||||||
视频学习时长
|
视频学习时长
|
||||||
{{videoTotalTime}}(包含{{videoCount}}个视频课件)
|
{{videoTotalTimeStr}}(包含{{videoCount}}个视频课件)
|
||||||
培训单位:(盖章)
|
培训单位:(盖章)
|
||||||
日期:
|
日期:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
课程名称
|
课程名称
|
||||||
{{trainSubject}}
|
{{trainSubject}}
|
||||||
视频时长
|
视频时长
|
||||||
{{videoTotalTime}}
|
{{videoTotalTimeStr}}
|
||||||
是否完成
|
是否完成
|
||||||
{{stateName}}
|
{{stateName}}
|
||||||
签到人脸验证
|
签到人脸验证
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
@ -471,6 +472,7 @@ public class ArchivesQueryExe {
|
||||||
// // workItem.put("examSignFacePicture", defaultPicture);
|
// // workItem.put("examSignFacePicture", defaultPicture);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
BigDecimal videoTotalTime = params.getVideoTotalTime();
|
||||||
|
|
||||||
String templatePath = "templates/template/studyRecord.docx";
|
String templatePath = "templates/template/studyRecord.docx";
|
||||||
ByteArrayOutputStream outputStream = Tools.renderTemplate(templatePath, workItem);
|
ByteArrayOutputStream outputStream = Tools.renderTemplate(templatePath, workItem);
|
||||||
|
|
@ -521,11 +523,11 @@ public class ArchivesQueryExe {
|
||||||
workItem.put("className", params.getClassName());
|
workItem.put("className", params.getClassName());
|
||||||
if(!ObjectUtils.isEmpty(params.getStudentExamRecord().getSignUrl())){
|
if(!ObjectUtils.isEmpty(params.getStudentExamRecord().getSignUrl())){
|
||||||
// PictureRenderData signPicture = Pictures.ofUrl(fileUrlConfig.getPrefixUrl() + params.getStudentExamRecord().getSignUrl(), PictureType.JPEG).size(50, 15).create();//网络图片地址
|
// 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);
|
workItem.put("signPicture", signPicture);
|
||||||
}
|
}
|
||||||
log.info("考试试卷下载转换前,{}",JSONUtil.toJsonStr(params.getStudentExamRecord()));
|
// log.info("考试试卷下载转换前,{}",JSONUtil.toJsonStr(params.getStudentExamRecord()));
|
||||||
log.info("考试试卷下载,{}",JSONUtil.toJsonStr(workItem));
|
// log.info("考试试卷下载,{}",JSONUtil.toJsonStr(workItem));
|
||||||
String templatePath = "templates/template/exam.docx";
|
String templatePath = "templates/template/exam.docx";
|
||||||
ByteArrayOutputStream outputStream = Tools.renderTemplate(templatePath, workItem);
|
ByteArrayOutputStream outputStream = Tools.renderTemplate(templatePath, workItem);
|
||||||
return outputStream.toByteArray();
|
return outputStream.toByteArray();
|
||||||
|
|
|
||||||
|
|
@ -139,6 +139,7 @@ public class PersonArchivesDTO {
|
||||||
|
|
||||||
@ApiModelProperty(value = "视频时长")
|
@ApiModelProperty(value = "视频时长")
|
||||||
private BigDecimal videoTotalTime;
|
private BigDecimal videoTotalTime;
|
||||||
|
private String videoTotalTimeStr;
|
||||||
@ApiModelProperty(value = "课件数")
|
@ApiModelProperty(value = "课件数")
|
||||||
private Integer videoCount;
|
private Integer videoCount;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -140,6 +140,7 @@ public class PersonArchivesE extends BaseE {
|
||||||
private String trainSubject;
|
private String trainSubject;
|
||||||
@ApiModelProperty(value = "视频时长")
|
@ApiModelProperty(value = "视频时长")
|
||||||
private BigDecimal videoTotalTime;
|
private BigDecimal videoTotalTime;
|
||||||
|
private String videoTotalTimeStr;
|
||||||
@ApiModelProperty(value = "课件数")
|
@ApiModelProperty(value = "课件数")
|
||||||
private Integer videoCount;
|
private Integer videoCount;
|
||||||
@ApiModelProperty(value = "打卡签到人脸图片路径")
|
@ApiModelProperty(value = "打卡签到人脸图片路径")
|
||||||
|
|
@ -199,7 +200,32 @@ public class PersonArchivesE extends BaseE {
|
||||||
.filter(bigDecimal -> bigDecimal != null) // 过滤null值,防止空指针异常
|
.filter(bigDecimal -> bigDecimal != null) // 过滤null值,防止空指针异常
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
setVideoTotalTime(videoTotalTime);
|
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<StudentSignE> studentSignEList, List<ClassCurriculumE> classCurList) {
|
public void initStudyRecord(StudentE studentE, ClassE classE, List<StudentSignE> studentSignEList, List<ClassCurriculumE> classCurList) {
|
||||||
BeanUtils.copyProperties(studentE, this);
|
BeanUtils.copyProperties(studentE, this);
|
||||||
|
|
||||||
|
|
@ -226,6 +252,7 @@ public class PersonArchivesE extends BaseE {
|
||||||
String trainSubject = classCurList.stream().map(ClassCurriculumE::getCurriculumName).collect(Collectors.joining(","));
|
String trainSubject = classCurList.stream().map(ClassCurriculumE::getCurriculumName).collect(Collectors.joining(","));
|
||||||
setTrainSubject(trainSubject);
|
setTrainSubject(trainSubject);
|
||||||
setVideoTotalTime(videoTotalTime);
|
setVideoTotalTime(videoTotalTime);
|
||||||
|
setVideoTotalTimeStr(getTimeStr(videoTotalTime));
|
||||||
if (studentSignEList != null && studentSignEList.size() > 0){
|
if (studentSignEList != null && studentSignEList.size() > 0){
|
||||||
for (StudentSignE studentSignE : studentSignEList){
|
for (StudentSignE studentSignE : studentSignEList){
|
||||||
if(studentSignE.getType() == 1
|
if(studentSignE.getType() == 1
|
||||||
|
|
@ -280,6 +307,7 @@ public class PersonArchivesE extends BaseE {
|
||||||
.filter(bigDecimal -> bigDecimal != null) // 过滤null值,防止空指针异常
|
.filter(bigDecimal -> bigDecimal != null) // 过滤null值,防止空指针异常
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
setVideoTotalTime(videoTotalTime);
|
setVideoTotalTime(videoTotalTime);
|
||||||
|
setVideoTotalTimeStr(getTimeStr(videoTotalTime));
|
||||||
}
|
}
|
||||||
if (chapterEList != null && chapterEList.size() > 0){
|
if (chapterEList != null && chapterEList.size() > 0){
|
||||||
setVideoCount(chapterEList.size());
|
setVideoCount(chapterEList.size());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue