|
|
@@ -17,6 +17,7 @@ import freemarker.template.Configuration;
|
|
|
import freemarker.template.Template;
|
|
|
import freemarker.template.Version;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -32,6 +33,7 @@ import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
+@Slf4j
|
|
|
@AllArgsConstructor
|
|
|
public class RateService {
|
|
|
|
|
|
@@ -109,17 +111,13 @@ public class RateService {
|
|
|
Configuration configuration = new Configuration(new Version("2.3.0"));
|
|
|
|
|
|
configuration.setDefaultEncoding("utf-8");
|
|
|
-
|
|
|
- configuration.setDirectoryForTemplateLoading(new File(Paths
|
|
|
- .get(System.getProperty("user.dir"), "src", "main", "resources", "templates")
|
|
|
- .toString()));//指定ftl所在目录,根据自己的改
|
|
|
- String fileName = DateTimeFormatter.ofPattern("yyyyMMdd").format(LocalDate.now());
|
|
|
+ configuration.setClassForTemplateLoading(this.getClass(), "/templates");//指定ftl所在目录,根据自己的改
|
|
|
StringWriter writer = new StringWriter();
|
|
|
Template template = configuration.getTemplate("RateTemplate.ftl", "utf-8");//以utf-8的编码读取ftl文件
|
|
|
template.process(dataMap, writer);
|
|
|
return writer.toString();
|
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ log.error("生成word错误", e);
|
|
|
throw new BusinessException(e.getMessage());
|
|
|
}
|
|
|
}
|