factors = new LinkedList<>();
@@ -138,9 +147,19 @@ public class SysEvaluationRecordServiceImpl implements ISysEvaluationRecordServi
for (int i = 0; i < size; i++) {
WordEvaluationFactor answerVo = answerVos.get(i);
double score = answerVo.getScore().doubleValue();
+ StringBuilder range = new StringBuilder();
+ BigDecimal minValue = answerVo.getMinValue();
+ BigDecimal maxValue = answerVo.getMaxValue();
+ if (minValue != null) {
+ range.append(minValue.doubleValue());
+ }
+ range.append("~");
+ if (maxValue != null) {
+ range.append(maxValue.doubleValue());
+ }
//处理因子得分表格
RowRenderData one = Rows.of(answerVo.getFactorName(), answerVo.getQuestionNum().toString(),
- answerVo.getTotalScore().toString(), answerVo.getScore().toString()).center().create();
+ answerVo.getTotalScore().toString(), answerVo.getScore().toString(), range.toString(), answerVo.getRangeName()).center().create();
factorTable.addRow(one);
//处理测评结果
WordFactor wordFactor = new WordFactor();
@@ -171,6 +190,11 @@ public class SysEvaluationRecordServiceImpl implements ISysEvaluationRecordServi
ClassPathResource classPathResource = new ClassPathResource("word/personalTemplate.docx");
Configure config = Configure.builder()
.bind("factors", new LoopRowTableRenderPolicy()).useSpringEL().build();
- return XWPFTemplate.compile(classPathResource.getInputStream(),config).render(wordData);
+ XWPFTemplate template = XWPFTemplate.compile(classPathResource.getInputStream(), config).render(wordData);
+
+ File docx = FileUtil.createTempFile(".docx", true);
+ String wordPath = docx.getPath();
+ template.writeToFile(wordPath);
+ return wordPath;
}
}
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 0a5aeec..75add79 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
@@ -1,5 +1,6 @@
package org.dromara.scale.service.impl;
+import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -37,9 +38,11 @@ import org.dromara.system.domain.SysUser;
import org.dromara.system.domain.vo.SysDeptVo;
import org.dromara.system.mapper.SysDeptMapper;
import org.dromara.system.mapper.SysUserMapper;
+import org.dromara.system.service.ISysConfigService;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Service;
+import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
@@ -72,6 +75,8 @@ public class SysScalePublishServiceImpl implements ISysScalePublishService {
private final SysWarnRecordMapper warnMapper;
+ private final ISysConfigService configService;
+
/**
* 查询量发布
*/
@@ -115,6 +120,12 @@ public class SysScalePublishServiceImpl implements ISysScalePublishService {
*/
@Override
public Boolean insertByBo(SysScalePublishBo bo) {
+ int i = baseMapper.selectCountScalePublish();
+ String s = configService.selectConfigByKey("sys.publish.limit");
+ int limit = Integer.parseInt(s);
+ if(limit != -1 && i>=limit){
+ throw new ServiceException("发布数量超出系统限制");
+ }
LoginUser loginUser = getLoginUser();
SysScalePublish add = MapstructUtils.convert(bo, SysScalePublish.class);
add.setStatus(StatusEnum.IN_USE.getValue());
@@ -273,7 +284,7 @@ public class SysScalePublishServiceImpl implements ISysScalePublishService {
}
@Override
- public XWPFTemplate getWordTemplate(BaseQueryBo bo) throws IOException {
+ public String getWordTemplate(BaseQueryBo bo) throws IOException {
Long batchNo = bo.getBatchNo();
if (batchNo == null) {
throw new ServerException("场次Id不能为空");
@@ -314,7 +325,6 @@ public class SysScalePublishServiceImpl implements ISysScalePublishService {
.series("", new Integer[]{maleNum, femaleNum}).create();
wordData.setSexChart(sexChart);
-
int undoneNum = recordMapper.selectUndoneNumByBatchNo(batchNo);
int recordNum = completeNum + undoneNum;
int completePercent = processHalfUpPercent(completeNum, recordNum);
@@ -402,7 +412,12 @@ public class SysScalePublishServiceImpl implements ISysScalePublishService {
ClassPathResource classPathResource = new ClassPathResource("word/groupTemplate.docx");
Configure config = Configure.builder()
.bind("warnCharts", new LoopRowTableRenderPolicy()).useSpringEL().build();
- return XWPFTemplate.compile(classPathResource.getInputStream(), config).render(wordData);
+ XWPFTemplate template = XWPFTemplate.compile(classPathResource.getInputStream(), config).render(wordData);
+
+ File docx = FileUtil.createTempFile(".docx", true);
+ String wordPath = docx.getPath();
+ template.writeToFile(wordPath);
+ return wordPath;
}
private int processHalfUpPercent(int num, int total) {
diff --git a/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/utils/AsposeUtil.java b/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/utils/AsposeUtil.java
new file mode 100644
index 0000000..7ac1a62
--- /dev/null
+++ b/ruoyi-modules/rouyi-scale/src/main/java/org/dromara/scale/utils/AsposeUtil.java
@@ -0,0 +1,46 @@
+package org.dromara.scale.utils;
+
+import com.aspose.words.Document;
+import com.aspose.words.License;
+import com.aspose.words.SaveFormat;
+import lombok.SneakyThrows;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+
+/**
+ * TODO
+ *
+ * @author cjw
+ * @version V1.0.0
+ * @date 2024/5/20 15:03
+ */
+public class AsposeUtil {
+ /**
+ * 加载license 用于破解 不生成水印
+ */
+ @SneakyThrows
+ private static void getLicense() {
+ try (InputStream is = AsposeUtil.class.getClassLoader().getResourceAsStream("License.xml")) {
+ License license = new License();
+ license.setLicense(is);
+ }
+ }
+
+ /**
+ * word转pdf
+ *
+ * @param wordPath word文件保存的路径
+ * @param pdfFile 转换后pdf文件保存的路径
+ */
+ @SneakyThrows
+ public static void wordToPdf(String wordPath, File pdfFile) {
+ getLicense();
+ try (FileOutputStream os = new FileOutputStream(pdfFile)) {
+ Document doc = new Document(wordPath);
+ doc.save(os, SaveFormat.PDF);
+ }
+ }
+
+}
diff --git a/ruoyi-modules/rouyi-scale/src/main/resources/License.xml b/ruoyi-modules/rouyi-scale/src/main/resources/License.xml
new file mode 100644
index 0000000..2cbce45
--- /dev/null
+++ b/ruoyi-modules/rouyi-scale/src/main/resources/License.xml
@@ -0,0 +1,15 @@
+
+
+
+ Aspose.Total for Java
+ Aspose.Words for Java
+
+ Enterprise
+ 20991231
+ 20991231
+ 8bfe198c-7f0c-4ef8-8ff0-acc3237bf0d7
+
+
+ sNLLKGMUdF0r8O1kKilWAGdgfs2BvJb/2Xp8p5iuDVfZXmhppo+d0Ran1P9TKdjV4ABwAgKXxJ3jcQTqE/2IRfqwnPf8itN8aFZlV3TJPYeD3yWE7IT55Gz6EijUpC7aKeoohTb4w2fpox58wWoF3SNp6sK6jDfiAUGEHYJ9pjU=
+
+
diff --git a/ruoyi-modules/rouyi-scale/src/main/resources/mapper/scale/SysEvaluationRecordMapper.xml b/ruoyi-modules/rouyi-scale/src/main/resources/mapper/scale/SysEvaluationRecordMapper.xml
index 1e98d61..48f478c 100644
--- a/ruoyi-modules/rouyi-scale/src/main/resources/mapper/scale/SysEvaluationRecordMapper.xml
+++ b/ruoyi-modules/rouyi-scale/src/main/resources/mapper/scale/SysEvaluationRecordMapper.xml
@@ -39,6 +39,9 @@
sf.question_score as `totalScore`,
ec.score as `score`,
ec.status as `status`,
+ sfr.range_name as `rangeName`,
+ sfr.min_value as `minValue`,
+ sfr.max_value as `maxValue`,
sfr.eval_desc as `evalDesc`,
sfr.eval_propose as `evalPropose`
from sys_evaluation_conclusion ec
diff --git a/ruoyi-modules/rouyi-scale/src/main/resources/mapper/scale/SysScalePublishMapper.xml b/ruoyi-modules/rouyi-scale/src/main/resources/mapper/scale/SysScalePublishMapper.xml
index 76e07f6..d0c7526 100644
--- a/ruoyi-modules/rouyi-scale/src/main/resources/mapper/scale/SysScalePublishMapper.xml
+++ b/ruoyi-modules/rouyi-scale/src/main/resources/mapper/scale/SysScalePublishMapper.xml
@@ -84,4 +84,9 @@
where er.batch_no = #{batchNo}
order by u.user_id
+
+
diff --git a/ruoyi-modules/rouyi-scale/src/main/resources/word/personalTemplate.docx b/ruoyi-modules/rouyi-scale/src/main/resources/word/personalTemplate.docx
index fc5ba33..802723b 100644
Binary files a/ruoyi-modules/rouyi-scale/src/main/resources/word/personalTemplate.docx and b/ruoyi-modules/rouyi-scale/src/main/resources/word/personalTemplate.docx differ