|
|
@ -23,6 +23,7 @@ public class AiGenerate {
|
|
|
|
public static DataEaseModel dm = new DataEaseModel();
|
|
|
|
public static DataEaseModel dm = new DataEaseModel();
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
|
|
|
|
|
|
|
//加载配置文件
|
|
|
|
//加载配置文件
|
|
|
|
String configFile = "application.yaml";
|
|
|
|
String configFile = "application.yaml";
|
|
|
|
BaseApplication.PropKit = new YamlProp(configFile);
|
|
|
|
BaseApplication.PropKit = new YamlProp(configFile);
|
|
|
@ -85,7 +86,7 @@ public class AiGenerate {
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// 使用Apache POI生成Word文档
|
|
|
|
// 使用Apache POI生成Word文档
|
|
|
|
generateWordDocument(fullResponse.toString(), outputPath);
|
|
|
|
generateWordDocument(fullResponse.toString(), outputPath, biJiao);
|
|
|
|
System.out.println("分析报告已保存到: " + outputPath);
|
|
|
|
System.out.println("分析报告已保存到: " + outputPath);
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
System.err.println("保存文件时出错: " + e.getMessage());
|
|
|
|
System.err.println("保存文件时出错: " + e.getMessage());
|
|
|
@ -126,15 +127,23 @@ public class AiGenerate {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 使用Apache POI生成Word文档
|
|
|
|
* 使用Apache POI生成Word文档
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private static void generateWordDocument(String analysisResult, String outputPath) throws Exception {
|
|
|
|
private static void generateWordDocument(String analysisResult, String outputPath, String[] cities) throws Exception {
|
|
|
|
XWPFDocument document = new XWPFDocument();
|
|
|
|
XWPFDocument document = new XWPFDocument();
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
// 动态生成标题
|
|
|
|
|
|
|
|
String reportTitle;
|
|
|
|
|
|
|
|
if (cities != null && cities.length >= 2) {
|
|
|
|
|
|
|
|
reportTitle = String.join("与", cities) + "教育资源配置对比分析报告";
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
reportTitle = "教育资源配置对比分析报告"; // 默认标题
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 添加标题
|
|
|
|
// 添加标题
|
|
|
|
XWPFParagraph titleParagraph = document.createParagraph();
|
|
|
|
XWPFParagraph titleParagraph = document.createParagraph();
|
|
|
|
titleParagraph.setAlignment(ParagraphAlignment.CENTER);
|
|
|
|
titleParagraph.setAlignment(ParagraphAlignment.CENTER);
|
|
|
|
XWPFRun titleRun = titleParagraph.createRun();
|
|
|
|
XWPFRun titleRun = titleParagraph.createRun();
|
|
|
|
titleRun.setText("文山州与楚雄州教育资源配置对比分析报告");
|
|
|
|
titleRun.setText(reportTitle);
|
|
|
|
titleRun.setBold(true);
|
|
|
|
titleRun.setBold(true);
|
|
|
|
titleRun.setFontSize(18);
|
|
|
|
titleRun.setFontSize(18);
|
|
|
|
titleRun.setFontFamily("宋体");
|
|
|
|
titleRun.setFontFamily("宋体");
|
|
|
|