Explorar o código

搜索条件新增

change %!s(int64=3) %!d(string=hai) anos
pai
achega
730833ac2f

+ 0 - 11
zhongzheng-api/pom.xml

@@ -10,20 +10,9 @@
     <modelVersion>4.0.0</modelVersion>
     <packaging>jar</packaging>
     <artifactId>zhongzheng-api</artifactId>
-    <repositories>
-        <repository>
-            <id>com.e-iceblue</id>
-            <url>https://repo.e-iceblue.cn/repository/maven-public/</url>
-        </repository>
-    </repositories>
 
     <dependencies>
         <!-- spring-boot-devtools -->
-        <dependency>
-            <groupId> e-iceblue </groupId>
-            <artifactId>spire.pdf</artifactId>
-            <version>3.11.6</version>
-        </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-devtools</artifactId>

+ 4 - 1
zhongzheng-system/pom.xml

@@ -31,7 +31,10 @@
             <groupId>org.springframework</groupId>
             <artifactId>spring-test</artifactId>
         </dependency>
-
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-freemarker</artifactId>
+        </dependency>
     </dependencies>
 
 </project>

+ 26 - 10
zhongzheng-system/src/main/java/com/zhongzheng/modules/base/service/impl/UserProfileServiceImpl.java

@@ -2,12 +2,8 @@ package com.zhongzheng.modules.base.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.io.FileUtil;
-import cn.hutool.core.util.StrUtil;
-import cn.hutool.extra.template.Template;
-import cn.hutool.extra.template.TemplateConfig;
-import cn.hutool.extra.template.TemplateEngine;
-import cn.hutool.extra.template.TemplateUtil;
-import cn.hutool.poi.word.Word07Writer;
+
+import cn.hutool.extra.template.TemplateException;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.fasterxml.jackson.databind.exc.InvalidFormatException;
@@ -26,6 +22,9 @@ import com.zhongzheng.modules.inform.vo.InformRemindVo;
 import com.zhongzheng.modules.order.vo.OrderGoodsVo;
 import com.zhongzheng.modules.user.service.IUserService;
 import com.zhongzheng.modules.user.vo.UserVo;
+import freemarker.template.Configuration;
+import freemarker.template.Template;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.http.entity.ContentType;
 import org.apache.poi.xwpf.usermodel.BreakType;
 import org.apache.poi.xwpf.usermodel.ParagraphAlignment;
@@ -198,8 +197,8 @@ public class UserProfileServiceImpl extends ServiceImpl<UserProfileMapper, UserP
         //第一种方式
         Map<String, String> maps = JSONObject.parseObject(info.getKeyValue(),Map.class);
         //默认配置就够用了
-        TemplateEngine engine = TemplateUtil.createEngine(new TemplateConfig("templates", TemplateConfig.ResourceMode.CLASSPATH));
-        Template template = engine.getTemplate("word.ftl");
+ /*       TemplateEngine engine = TemplateUtil.createEngine(new TemplateConfig("templates", TemplateConfig.ResourceMode.CLASSPATH));
+        Template template = engine.getTemplate("word.ftl");*/
         //给STRING_TEMPLATE绑定数据
         Map<String, Object> bindingMap = new HashMap<>();
         bindingMap.put("name", JSONObject.parseObject(String.valueOf(maps.get("name")), UserProfileFit.class).getValue());
@@ -218,9 +217,26 @@ public class UserProfileServiceImpl extends ServiceImpl<UserProfileMapper, UserP
         bindingMap.put("d", 1);
         bindingMap.put("time", JSONObject.parseObject(String.valueOf(maps.get("graduation_time")), UserProfileFit.class).getValue());
         bindingMap.put("year", JSONObject.parseObject(String.valueOf(maps.get("working_years")), UserProfileFit.class).getValue());
-        File touch = FileUtil.touch(ZHONGZHENG_PROFILE+"word.docx");
+        File touch = FileUtil.touch(ZHONGZHENG_PROFILE+"word.doc");
         //最终渲染出来的样子
-        template.render(bindingMap,touch);
+        /*template.render(bindingMap,touch);*/
+
+
+        Configuration configuration = new Configuration();
+        configuration.setDefaultEncoding("utf-8");
+        configuration.setClassForTemplateLoading(this.getClass(), "/templates");
+        Template template = configuration.getTemplate("word.ftl");
+        Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(touch),"UTF-8"));
+        try {
+            template.process(bindingMap,out);
+            out.flush();
+            out.close();
+
+        } catch (TemplateException | freemarker.template.TemplateException e) {
+            e.printStackTrace();
+        }
+
+
         OssRequest ossRequest = new OssRequest();
         FileInputStream fileInputStream = new FileInputStream(touch);
         MultipartFile multipartFile = new MockMultipartFile(touch.getName(), touch.getName(),