From b222b1dfec8d8f98abb98aeca2d1b39701fa9967 Mon Sep 17 00:00:00 2001 From: cjw Date: Tue, 11 Jun 2024 11:17:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8B=E8=BD=BD=E5=85=B3?= =?UTF-8?q?=E9=97=AD=E6=B5=81=EF=BC=9B=E5=B9=B2=E9=A2=84=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=8F=96note=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/EvaluationRecordController.java | 3 +-- .../controller/InterveneRecordController.java | 2 +- .../controller/ScalePublishController.java | 2 +- .../service/ISysEvaluationRecordService.java | 3 +-- .../scale/service/ISysScalePublishService.java | 3 +-- .../impl/SysEvaluationRecordServiceImpl.java | 17 +++++++++++------ .../impl/SysInterveneRecordServiceImpl.java | 5 ++--- .../impl/SysScalePublishServiceImpl.java | 15 ++++++++------- 8 files changed, 26 insertions(+), 24 deletions(-) diff --git a/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/controller/EvaluationRecordController.java b/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/controller/EvaluationRecordController.java index b547243..cc66590 100644 --- a/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/controller/EvaluationRecordController.java +++ b/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/controller/EvaluationRecordController.java @@ -25,7 +25,6 @@ import org.springframework.web.bind.annotation.*; import java.io.File; import java.io.FileInputStream; -import java.io.IOException; import java.io.InputStream; /** @@ -57,7 +56,7 @@ public class EvaluationRecordController extends BaseController { @SaCheckPermission("evaluation:record:export") @Log(title = "个人量测记录", businessType = BusinessType.EXPORT) @PostMapping("/export") - public void export(BaseQueryBo bo, HttpServletResponse response) throws IOException { + public void export(BaseQueryBo bo, HttpServletResponse response) throws Exception { String filePath = sysEvaluationRecordService.getWordTemplate(bo); File pdf = FileUtil.createTempFile(".pdf", true); String pdfPath = pdf.getPath(); diff --git a/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/controller/InterveneRecordController.java b/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/controller/InterveneRecordController.java index 059cb54..066c591 100644 --- a/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/controller/InterveneRecordController.java +++ b/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/controller/InterveneRecordController.java @@ -42,7 +42,7 @@ public class InterveneRecordController extends BaseController { * * @param userId 主键 */ - @SaCheckPermission("intervene:record:pageList") + //@SaCheckPermission("intervene:record:pageList") @GetMapping("/pageList") public TableDataInfo list(@NotNull(message = "用户id不能为空") Long userId, PageQuery pageQuery) { return interveneRecordService.queryPageList(userId, pageQuery); diff --git a/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/controller/ScalePublishController.java b/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/controller/ScalePublishController.java index 7c70e9d..b47e724 100644 --- a/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/controller/ScalePublishController.java +++ b/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/controller/ScalePublishController.java @@ -135,7 +135,7 @@ public class ScalePublishController extends BaseController { @SaCheckPermission("scale:publish:export") @Log(title = "场次量测记录", businessType = BusinessType.EXPORT) @PostMapping("/export") - public void export(BaseQueryBo bo, HttpServletResponse response) throws IOException { + public void export(BaseQueryBo bo, HttpServletResponse response) throws Exception { String filePath = sysScalePublishService.getWordTemplate(bo); File pdf = FileUtil.createTempFile(".pdf", true); String pdfPath = pdf.getPath(); diff --git a/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/ISysEvaluationRecordService.java b/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/ISysEvaluationRecordService.java index 66c2c80..b49b0e7 100644 --- a/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/ISysEvaluationRecordService.java +++ b/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/ISysEvaluationRecordService.java @@ -6,7 +6,6 @@ import org.dromara.scale.domain.bo.BaseQueryBo; import org.dromara.scale.domain.bo.SysEvaluationRecordBo; import org.dromara.scale.domain.vo.SysEvaluationRecordVo; -import java.io.IOException; import java.util.List; /** @@ -33,7 +32,7 @@ public interface ISysEvaluationRecordService { List queryList(SysEvaluationRecordBo bo); - String getWordTemplate(BaseQueryBo bo) throws IOException; + String getWordTemplate(BaseQueryBo bo) throws Exception; diff --git a/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/ISysScalePublishService.java b/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/ISysScalePublishService.java index 881d380..98763e6 100644 --- a/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/ISysScalePublishService.java +++ b/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/ISysScalePublishService.java @@ -7,7 +7,6 @@ import org.dromara.scale.domain.bo.SysScalePublishBo; import org.dromara.scale.domain.vo.EvaluationVo; import org.dromara.scale.domain.vo.SysScalePublishVo; -import java.io.IOException; import java.util.List; /** @@ -51,7 +50,7 @@ public interface ISysScalePublishService { List queryUndoneExportList(BaseQueryBo query); - String getWordTemplate(BaseQueryBo bo) throws IOException; + String getWordTemplate(BaseQueryBo bo) throws Exception; int checkWord(BaseQueryBo bo); diff --git a/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/impl/SysEvaluationRecordServiceImpl.java b/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/impl/SysEvaluationRecordServiceImpl.java index ba45353..efd5847 100644 --- a/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/impl/SysEvaluationRecordServiceImpl.java +++ b/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/impl/SysEvaluationRecordServiceImpl.java @@ -34,7 +34,7 @@ import org.dromara.system.service.ISysConfigService; import org.springframework.stereotype.Service; import java.io.File; -import java.io.IOException; +import java.io.FileInputStream; import java.math.BigDecimal; import java.rmi.ServerException; import java.util.ArrayList; @@ -100,7 +100,7 @@ public class SysEvaluationRecordServiceImpl implements ISysEvaluationRecordServi } @Override - public String getWordTemplate(BaseQueryBo bo) throws IOException { + public String getWordTemplate(BaseQueryBo bo) throws Exception { Long userId = bo.getUserId(); if (userId == null) { throw new ServerException("用户ID不能为空"); @@ -216,13 +216,18 @@ public class SysEvaluationRecordServiceImpl implements ISysEvaluationRecordServi } wordData.setPropose(stringBuilder.toString()); File path = new File("/usr/local/mental/word/personalTemplate.docx"); - Configure config = Configure.builder() - .bind("factors", new LoopRowTableRenderPolicy()).useSpringEL().build(); - XWPFTemplate template = XWPFTemplate.compile(path, config).render(wordData); File docx = FileUtil.createTempFile(".docx", true); String wordPath = docx.getPath(); - template.writeToFile(wordPath); + try (FileInputStream fileInputStream = new FileInputStream(path)) { + Configure config = Configure.builder() + .bind("warnCharts", new LoopRowTableRenderPolicy()).useSpringEL().build(); + XWPFTemplate template = XWPFTemplate.compile(fileInputStream, config).render(wordData); + template.writeToFile(wordPath); + } + Configure config = Configure.builder() + .bind("factors", new LoopRowTableRenderPolicy()).useSpringEL().build(); + XWPFTemplate template = XWPFTemplate.compile(path, config).render(wordData); return wordPath; } } diff --git a/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/impl/SysInterveneRecordServiceImpl.java b/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/impl/SysInterveneRecordServiceImpl.java index ec865df..d850711 100644 --- a/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/impl/SysInterveneRecordServiceImpl.java +++ b/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/impl/SysInterveneRecordServiceImpl.java @@ -27,7 +27,6 @@ import org.dromara.system.mapper.SysUserMapper; import org.springframework.stereotype.Service; import java.util.Comparator; -import java.util.Date; import java.util.List; import java.util.stream.Collectors; @@ -66,7 +65,7 @@ public class SysInterveneRecordServiceImpl implements ISysInterveneRecordService SysScalePublish sysScalePublish = publishMapper.selectById(record.getBatchNo()); record.setSessionName(sysScalePublish.getSessionName()); SysWarnRecord warn = warnMapper.selectOne(new LambdaQueryWrapper() - .select(SysWarnRecord::getNote) + //.select(SysWarnRecord::getNote) .eq(SysWarnRecord::getBatchNo, record.getBatchNo()) .eq(SysWarnRecord::getUserId, record.getUserId())); record.setNote(warn.getNote()); @@ -123,7 +122,7 @@ public class SysInterveneRecordServiceImpl implements ISysInterveneRecordService throw new ServiceException("此用户状态为无需干预,无法提交干预记录"); } SysInterveneRecord add = MapstructUtils.convert(bo, SysInterveneRecord.class); - add.setCreateTime(new Date()); + //add.setCreateTime(new Date()); add.setCounselorId(loginUser.getUserId()); validEntityBeforeSave(add); boolean flag = baseMapper.insert(add) > 0; diff --git a/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/impl/SysScalePublishServiceImpl.java b/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/impl/SysScalePublishServiceImpl.java index f2cf2f8..d413fa5 100644 --- a/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/impl/SysScalePublishServiceImpl.java +++ b/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/service/impl/SysScalePublishServiceImpl.java @@ -42,7 +42,7 @@ import org.dromara.system.service.ISysConfigService; import org.springframework.stereotype.Service; import java.io.File; -import java.io.IOException; +import java.io.FileInputStream; import java.math.BigDecimal; import java.math.RoundingMode; import java.rmi.ServerException; @@ -314,7 +314,7 @@ public class SysScalePublishServiceImpl implements ISysScalePublishService { } @Override - public String getWordTemplate(BaseQueryBo bo) throws IOException { + public String getWordTemplate(BaseQueryBo bo) throws Exception { Long batchNo = bo.getBatchNo(); if (batchNo == null) { throw new ServerException("场次Id不能为空"); @@ -450,13 +450,14 @@ public class SysScalePublishServiceImpl implements ISysScalePublishService { } wordData.setWarnCharts(wordWarnList); File path = new File("/usr/local/mental/word/groupTemplate.docx"); - Configure config = Configure.builder() - .bind("warnCharts", new LoopRowTableRenderPolicy()).useSpringEL().build(); - XWPFTemplate template = XWPFTemplate.compile(path, config).render(wordData); - File docx = FileUtil.createTempFile(".docx", true); String wordPath = docx.getPath(); - template.writeToFile(wordPath); + try (FileInputStream fileInputStream = new FileInputStream(path)) { + Configure config = Configure.builder() + .bind("warnCharts", new LoopRowTableRenderPolicy()).useSpringEL().build(); + XWPFTemplate template = XWPFTemplate.compile(fileInputStream, config).render(wordData); + template.writeToFile(wordPath); + } return wordPath; }