pdf图片调整
continuous-integration/drone/push Build is passing Details

yxy/生成PDF
YXY 1 year ago
parent b79048cd13
commit cfcdb9c05d

@ -146,6 +146,7 @@ public class PdfUtils {
watermark.setLineWidth(1f);
watermark.stroke();
}
stamper.close();
reader.close();
return true;
@ -161,8 +162,17 @@ public class PdfUtils {
if (fileOutputStream != null){
fileOutputStream.close();
}
removeFile(new File(pdf.getPdfAllPath()));
return false;
}
}
private void removeFile(File file){
try {
file.delete();
}catch (Exception e){
log.error("PdfUtils removeFile failed",e);
}
}
}

@ -28,6 +28,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.io.File;
import java.time.LocalDateTime;
import java.util.*;
/**
@ -103,6 +104,7 @@ public class LarkCreatePdfHelper {
entity.setTemplateName("JTDX_PDF_TEMPLATE.ftl");
pdfUtils.createFile(entity);
File file = new File(pdfWatermarkingAllPath);
if (file.exists()) {
Long length = file.length();
LarkFileRequest fileRequest = new LarkFileRequest(request.getAppId(), request.getAppSecret(),
file, file.getName(), length.intValue(), tableRelation.getFromAppToken());
@ -115,6 +117,16 @@ public class LarkCreatePdfHelper {
LarkTableRequest updateRequest = new LarkTableRequest(request.getAppId(), request.getAppSecret(),
tableRelation.getFromAppToken(), tableRelation.getFromTableId(), record.getRecordId(), fields);
larkTableHelper.updateTableRecord(updateRequest);
removeLocalFile(file);
}
}
private void removeLocalFile(File file){
try {
file.delete();
}catch (Exception e){
log.error("LarkCreatePdfHelper removeLocalFile fail",e);
}
}
private LarkTableConfiguration check(RequestVo request) {
@ -141,10 +153,12 @@ public class LarkCreatePdfHelper {
resultDTO.setProgram(program);
resultDTO.setStudentName(getUser(fields.get("人员"),"name"));
resultDTO.setTutor(getUser(fields.get("人员"),"name"));
String startTimeStr = getTimeByDate(fields.get("日期"));
String endTimeStr = getTimeByDate(fields.get("日期"));
resultDTO.setStartClassTime(startTimeStr);
resultDTO.setEndClassTime(endTimeStr);
LocalDateTime startTime = getTimeByDate(fields.get("日期"));
LocalDateTime endTime = getTimeByDate(fields.get("日期"));
resultDTO.setMonth(String.valueOf(startTime.getMonthValue()));
resultDTO.setDay(String.valueOf(startTime.getDayOfMonth()));
resultDTO.setStartClassTime(DateUtils.ldt2str(startTime,DateUtils.YYYY_MM_DD_HH_MM_SS));
resultDTO.setEndClassTime(DateUtils.ldt2str(endTime,DateUtils.YYYY_MM_DD_HH_MM_SS));
resultDTO.setFeedback("作业完成情况");
Integer feedbackScore = getNumber(fields.get("数字"));
resultDTO.setFeedbackScore(String.format("%s /10",feedbackScore));
@ -170,9 +184,9 @@ public class LarkCreatePdfHelper {
/**
*
*/
private String getTimeByDate(Object data){
private LocalDateTime getTimeByDate(Object data){
try {
return DateUtils.e2Str(data,DateUtils.YYYY_MM_DD_HH_MM_SS);
return DateUtils.e2ldt(data);
}catch (Exception e){
log.info("LarkCreatePdfHelper getTimeByDate data",data,e);
}

@ -67,7 +67,7 @@ public class EdiController extends BaseController {
String pdfWatermarkingAllPath = new StringBuilder(pdfGeneratePath).append("temporary").append(FOLDER_SPLIT).append(fileName).append("watermark").append(".pdf").toString();
entity.setPdfAllPath(pdfAllPath);
entity.setPdfWatermarkingAllPath(pdfWatermarkingAllPath);
entity.setTitlePicAllPath(new StringBuilder(pdfGeneratePath).append("photo").append(FOLDER_SPLIT).append("pdf").append(FOLDER_SPLIT).append("jtdx_pdf_title.png").toString());
entity.setTitlePicAllPath(new StringBuilder(pdfGeneratePath).append("photo").append(FOLDER_SPLIT).append("pdf").append(FOLDER_SPLIT).toString());
entity.setTemplatePath(new StringBuilder(pdfGeneratePath).append("template").toString());
entity.setFontAllPath(new StringBuilder(pdfGeneratePath).append("font").append(FOLDER_SPLIT).append("simsun.ttc").toString());
entity.setWatermarkingPickAllPath(new StringBuilder(pdfGeneratePath).append("photo").append(FOLDER_SPLIT).append("pdf").append(FOLDER_SPLIT).append("jtdx_pdf_watermark.jpg").toString());
@ -97,6 +97,8 @@ public class EdiController extends BaseController {
resultDTO.setProgram("program");
resultDTO.setStudentName("student");
resultDTO.setTutor("tutor");
resultDTO.setMonth("10");
resultDTO.setDay("12");
resultDTO.setStartClassTime("2023-05-21 15:51:45");
resultDTO.setEndClassTime("2023-05-22 15:51:45");
resultDTO.setFeedback("作业完成情况");

@ -13,6 +13,9 @@ public class CourseFeedbackTemplateDto {
private String watermark;
private String month;
private String day;
private String program;
private String studentName;
private String startClassTime;

Loading…
Cancel
Save