From e063d68d869c70b4a4897cbf3c46179a53a087b2 Mon Sep 17 00:00:00 2001 From: YXY <932687738@qq.com> Date: Wed, 31 May 2023 22:46:54 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E6=88=90pdf=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application.yml | 2 +- .../script/LarkCreatePdfHelper.java | 63 +++++++++++++++++++ .../flyingbook/controller/EdiController.java | 43 +++++++------ ...dimensionalTableMaintenanceRowOperate.java | 23 ++----- .../operate/MultidimensionalTableOperate.java | 2 - .../MultidimensionalTableSingleOperate.java | 11 +++- 6 files changed, 99 insertions(+), 45 deletions(-) create mode 100644 ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/LarkHelper/script/LarkCreatePdfHelper.java diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 0cf125e..80e8af8 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -113,4 +113,4 @@ lark: group: https://open.feishu.cn/open-apis/bot/v2/hook/cf432ef4-e526-4595-8330-2d2a361f7a29 pdf: generate: - path: /pdf/dependence/file + path: D:\test\ diff --git a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/LarkHelper/script/LarkCreatePdfHelper.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/LarkHelper/script/LarkCreatePdfHelper.java new file mode 100644 index 0000000..716a9bd --- /dev/null +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/LarkHelper/script/LarkCreatePdfHelper.java @@ -0,0 +1,63 @@ +package com.ruoyi.flyingbook.LarkHelper.script; + +import com.lark.oapi.service.bitable.v1.model.AppTableRecord; +import com.lark.oapi.service.bitable.v1.model.GetAppTableRecordResp; +import com.ruoyi.common.core.domain.PdfEntity; +import com.ruoyi.common.utils.PdfUtils; +import com.ruoyi.flyingbook.domain.RequestVo; +import com.ruoyi.flyingbook.domain.template.CourseFeedbackTemplateDto; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import java.util.Map; + +/** + * @author yuxiangyong + * @create 2023-05-31 22:26 + */ +@Component +public class LarkCreatePdfHelper { + + @Value("${pdf.generate.path}") + private String pdfGeneratePath; + + @Autowired + private PdfUtils pdfUtils; + + + public void createAndUpload(RequestVo request){ + PdfEntity entity = new PdfEntity(); +// GetAppTableRecordResp respBody = request.getRespBody(); +// AppTableRecord record = respBody.getData().getRecord(); +// CourseFeedbackTemplateDto data = build(record.getFields()); + String pdfAllPath = new StringBuilder(pdfGeneratePath).append("pdf\\test1.pdf").toString(); + String pdfWatermarkingAllPath = new StringBuilder(pdfGeneratePath).append("pdf\\test2.pdf").toString(); + entity.setPdfAllPath(pdfAllPath); + entity.setPdfWatermarkingAllPath(pdfWatermarkingAllPath); + entity.setTitlePicAllPath(new StringBuilder(pdfGeneratePath).append("photo\\title.jpg").toString()); + entity.setTemplatePath(new StringBuilder(pdfGeneratePath).append("template").toString()); + entity.setFontAllPath(new StringBuilder(pdfGeneratePath).append("font\\simsun.ttc").toString()); + entity.setWatermarkingPickAllPath(new StringBuilder(pdfGeneratePath).append("photo\\watermark.jpg").toString()); + entity.setData(build(null)); + entity.setTemplateName("COURSE_FEEDBACK.ftl"); + pdfUtils.createFile(entity); + } + + private CourseFeedbackTemplateDto build(Map fields){ + CourseFeedbackTemplateDto resultDTO = new CourseFeedbackTemplateDto(); + resultDTO.setProgram("program"); + resultDTO.setStudentName("student"); + resultDTO.setTutor("tutor"); + resultDTO.setStartClassTime("2023-05-21 15:51:45"); + resultDTO.setEndClassTime("2023-05-22 15:51:45"); + resultDTO.setFeedback("作业完成情况"); + resultDTO.setFeedbackScore("7 /10"); + resultDTO.setPerformance("课堂表现"); + resultDTO.setPerformanceScore("9/10"); + resultDTO.setContent("

1、课堂内容1

1、课堂内容2

"); + resultDTO.setWork("

1、课后作业1

1、课后作业2

1、课后作业3

"); + return resultDTO; + } + +} diff --git a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/controller/EdiController.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/controller/EdiController.java index 725d3c1..110c724 100644 --- a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/controller/EdiController.java +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/controller/EdiController.java @@ -4,6 +4,7 @@ import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.PdfEntity; import com.ruoyi.common.utils.PdfUtils; import com.ruoyi.flyingbook.LarkHelper.LarkFileHelper; +import com.ruoyi.flyingbook.LarkHelper.script.LarkCreatePdfHelper; import com.ruoyi.flyingbook.domain.edi.EdiResponseVo; import com.ruoyi.flyingbook.domain.edi.SyncToTableRequest; import com.ruoyi.flyingbook.domain.template.CourseFeedbackTemplateDto; @@ -11,6 +12,7 @@ import com.ruoyi.flyingbook.edi.EdiOperateService; import com.ruoyi.flyingbook.service.IEventLogService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.core.io.ResourceLoader; import org.springframework.web.bind.annotation.*; @@ -25,12 +27,17 @@ public class EdiController extends BaseController { @Autowired private PdfUtils pdfUtils; @Autowired + private LarkCreatePdfHelper larkCreatePdfHelper; + @Autowired private LarkFileHelper larkFileHelper; @Autowired ResourceLoader resourceLoader; @Autowired private IEventLogService iEventLogService; + @Value("${pdf.generate.path}") + private String pdfGeneratePath; + /** * 同步数据到飞书表格 */ @@ -41,28 +48,20 @@ public class EdiController extends BaseController { @RequestMapping("/createPdf") public void exportPdfDemo(@RequestParam("param") String param) throws Exception { - - PdfEntity entity = new PdfEntity(); - CourseFeedbackTemplateDto data = build(); - String pdfAllPath = "D:\\test\\pdf\\test1.pdf"; - String pdfWatermarkingAllPath = "D:\\test\\pdf\\test2.pdf"; - entity.setPdfAllPath(pdfAllPath); - entity.setPdfWatermarkingAllPath(pdfWatermarkingAllPath); - entity.setTitlePicAllPath("D:\\test\\photo\\title.jpg"); - entity.setTemplatePath("D:\\test\\template"); - entity.setFontAllPath("D:\\test\\font\\simsun.ttc"); - entity.setWatermarkingPickAllPath("D:\\test\\photo\\watermark.jpg"); - entity.setData(data); - entity.setTemplateName("COURSE_FEEDBACK.ftl"); - pdfUtils.createFile(entity); - File file1 = new File(pdfAllPath); - if (file1.exists()){ - file1.delete(); - } - File file2 = new File(pdfWatermarkingAllPath); - if (file2.exists()){ - file2.delete(); - } + larkCreatePdfHelper.createAndUpload(null); +// PdfEntity entity = new PdfEntity(); +// CourseFeedbackTemplateDto data = build(); +// String pdfAllPath = "D:\\test\\pdf\\test1.pdf"; +// String pdfWatermarkingAllPath = "D:\\test\\pdf\\test2.pdf"; +// entity.setPdfAllPath(pdfAllPath); +// entity.setPdfWatermarkingAllPath(pdfWatermarkingAllPath); +// entity.setTitlePicAllPath("D:\\test\\photo\\title.jpg"); +// entity.setTemplatePath("D:\\test\\template"); +// entity.setFontAllPath("D:\\test\\font\\simsun.ttc"); +// entity.setWatermarkingPickAllPath("D:\\test\\photo\\watermark.jpg"); +// entity.setData(data); +// entity.setTemplateName("COURSE_FEEDBACK.ftl"); +// pdfUtils.createFile(entity); // LarkFileRequest fileRequest = new LarkFileRequest("cli_a482a8572cbc9013","lZNXbCLlOslWbwBIVc4qvgxOdnfA8Mos", // file2,file2.getName(),length.intValue(),"fldcnLt2RyUgDDD6rgC6K9gIWlM"); // larkFileHelper.uploadFile(fileRequest); diff --git a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/strategy/operate/MultidimensionalTableMaintenanceRowOperate.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/strategy/operate/MultidimensionalTableMaintenanceRowOperate.java index 496ba86..bc3a34a 100644 --- a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/strategy/operate/MultidimensionalTableMaintenanceRowOperate.java +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/strategy/operate/MultidimensionalTableMaintenanceRowOperate.java @@ -1,12 +1,14 @@ package com.ruoyi.flyingbook.strategy.operate; -import com.alibaba.fastjson.JSONObject; -import com.lark.oapi.service.bitable.v1.model.*; -import com.ruoyi.common.enums.*; +import com.lark.oapi.service.bitable.v1.model.AppTableRecord; +import com.lark.oapi.service.bitable.v1.model.GetAppTableRecordResp; +import com.ruoyi.common.enums.EventOperateStatus; +import com.ruoyi.common.enums.EventOperateType; +import com.ruoyi.common.enums.FlagStatus; +import com.ruoyi.common.enums.TableDetailRelationTypeEnum; import com.ruoyi.flyingbook.LarkHelper.LarkTableFieldHelper; import com.ruoyi.flyingbook.LarkHelper.LarkTableHelper; import com.ruoyi.flyingbook.domain.*; -import com.ruoyi.flyingbook.domain.lark.LarkTableFieldRequest; import com.ruoyi.flyingbook.domain.lark.LarkTableRequest; import com.ruoyi.flyingbook.service.*; import lombok.extern.slf4j.Slf4j; @@ -15,7 +17,6 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.lang.reflect.Field; import java.util.*; @@ -45,18 +46,6 @@ public class MultidimensionalTableMaintenanceRowOperate extends LarkAbstract { protected IEventService eventService; @Autowired protected IEventLogService eventLogService; - /** - * 新增明细行 - */ - protected static final String CREATE_OPERATE = "CREATE_OPERATE"; - /** - * 修改明细行 - */ - protected static final String UPDATE_OPERATE = "UPDATE_OPERATE"; - /** - * 删除明细行 - */ - protected static final String DELETE_OPERATE = "DELETE_OPERATE"; @Override protected void preOperate(RequestVo request) { diff --git a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/strategy/operate/MultidimensionalTableOperate.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/strategy/operate/MultidimensionalTableOperate.java index bd17014..5afc09f 100644 --- a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/strategy/operate/MultidimensionalTableOperate.java +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/strategy/operate/MultidimensionalTableOperate.java @@ -5,7 +5,6 @@ import com.google.gson.internal.LinkedTreeMap; import com.lark.oapi.service.bitable.v1.model.*; import com.ruoyi.common.constant.RedisConstants; import com.ruoyi.common.enums.*; -import com.ruoyi.common.utils.sign.Md5Utils; import com.ruoyi.flyingbook.LarkHelper.LarkTableFieldHelper; import com.ruoyi.flyingbook.LarkHelper.LarkTableHelper; import com.ruoyi.flyingbook.domain.*; @@ -16,7 +15,6 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.stereotype.Service; import java.util.*; import java.util.stream.Collectors; diff --git a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/strategy/operate/MultidimensionalTableSingleOperate.java b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/strategy/operate/MultidimensionalTableSingleOperate.java index 10f88b1..408885b 100644 --- a/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/strategy/operate/MultidimensionalTableSingleOperate.java +++ b/ruoyi-flyingbook/src/main/java/com/ruoyi/flyingbook/strategy/operate/MultidimensionalTableSingleOperate.java @@ -1,13 +1,18 @@ package com.ruoyi.flyingbook.strategy.operate; import com.ruoyi.common.enums.TableDetailRelationTypeEnum; -import com.ruoyi.flyingbook.domain.*; -import com.ruoyi.flyingbook.service.*; +import com.ruoyi.flyingbook.domain.LarkTableRelation; +import com.ruoyi.flyingbook.domain.LarkTableRowRelation; +import com.ruoyi.flyingbook.domain.RequestVo; +import com.ruoyi.flyingbook.service.ILarkTableRowRelationService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /**