|
|
@ -1,15 +1,10 @@
|
|
|
|
package com.dsideal.base.AI.Model;
|
|
|
|
package com.dsideal.base.AI.Model;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
import com.dsideal.base.AI.Generator.HtmlGenerator;
|
|
|
|
|
|
|
|
import com.dsideal.base.AI.Generator.WordGenerator;
|
|
|
|
|
|
|
|
import com.dsideal.base.DataEase.Model.DataEaseModel;
|
|
|
|
import com.dsideal.base.DataEase.Model.DataEaseModel;
|
|
|
|
import com.dsideal.base.Util.CallDeepSeek;
|
|
|
|
|
|
|
|
import com.jfinal.plugin.activerecord.Db;
|
|
|
|
import com.jfinal.plugin.activerecord.Db;
|
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
public class YunNanModel {
|
|
|
|
public class YunNanModel {
|
|
|
@ -51,96 +46,16 @@ public class YunNanModel {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dataContent.append("\n----------------------------------------\n\n");
|
|
|
|
dataContent.append("\n----------------------------------------\n\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return dataContent.toString();
|
|
|
|
return dataContent.toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 创建分析提示词
|
|
|
|
* 获取云南省下所有城市名称
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param dataContent 数据内容
|
|
|
|
* @return
|
|
|
|
* @param regions 对比地区
|
|
|
|
|
|
|
|
* @return 分析提示词
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public String createAnalysisPrompt(String dataContent, String[] regions) {
|
|
|
|
|
|
|
|
String regionNames = String.join("和", regions);
|
|
|
|
|
|
|
|
return "你是一位专业的教育数据分析专家,请基于以下数据对" + regionNames + "的教育资源配置情况进行深入对比分析。\n\n" +
|
|
|
|
|
|
|
|
"重要要求:请生成结构化的Markdown格式报告,使用标准的Markdown语法,包括标题、列表、粗体等格式。\n\n" +
|
|
|
|
|
|
|
|
"请按照以下结构进行分析并生成专业的分析报告:\n\n" +
|
|
|
|
|
|
|
|
"## 1. 执行摘要\n" +
|
|
|
|
|
|
|
|
"简要概述两州教育资源配置的整体情况和主要发现\n\n" +
|
|
|
|
|
|
|
|
"## 2. 数据概览\n" +
|
|
|
|
|
|
|
|
"两州基本教育数据对比和关键指标汇总\n\n" +
|
|
|
|
|
|
|
|
"## 3. 详细对比分析\n" +
|
|
|
|
|
|
|
|
"教育资源配置水平对比、发展趋势分析、优势与不足分析\n\n" +
|
|
|
|
|
|
|
|
"## 4. 问题识别\n" +
|
|
|
|
|
|
|
|
"存在的主要问题和资源配置不均衡情况\n\n" +
|
|
|
|
|
|
|
|
"## 5. 建议与对策\n" +
|
|
|
|
|
|
|
|
"针对性改进建议和资源优化配置方案\n\n" +
|
|
|
|
|
|
|
|
"## 6. 结论\n" +
|
|
|
|
|
|
|
|
"总体评价和未来发展方向\n\n" +
|
|
|
|
|
|
|
|
"请确保分析客观、专业,数据引用准确,建议具有可操作性。\n\n" +
|
|
|
|
|
|
|
|
"=== 原始数据 ===\n" + dataContent;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 生成Word报告
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public void generateWordReport(String analysisPrompt, String[] regions, String path) {
|
|
|
|
public List<Record> getYunNanCity() {
|
|
|
|
// 生成输出文件名(不包含路径)
|
|
|
|
String sql = "select id,area_code,area_name,full_name from t_dm_area where parent_id='FD61813E-70A1-42AB-9A8E-141ED4D47B98'";
|
|
|
|
String timestamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
|
|
|
|
return Db.find(sql);
|
|
|
|
|
|
|
|
|
|
|
|
// 构建区域名称
|
|
|
|
|
|
|
|
String regionName = String.join("与", regions);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 调用DeepSeek进行分析
|
|
|
|
|
|
|
|
CallDeepSeek.callDeepSeekStream(analysisPrompt, new CallDeepSeek.SSEListener() {
|
|
|
|
|
|
|
|
private StringBuilder fullResponse = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onData(String data) {
|
|
|
|
|
|
|
|
System.out.print(data);
|
|
|
|
|
|
|
|
System.out.flush();
|
|
|
|
|
|
|
|
fullResponse.append(data);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onComplete(String response) {
|
|
|
|
|
|
|
|
System.out.println("\n\n=== Word文档分析完成 ===");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
// 使用完整的分析结果
|
|
|
|
|
|
|
|
String analysisResult = fullResponse.toString();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 生成Word文档
|
|
|
|
|
|
|
|
String wordOutputPath = path + "/" + regionName + "_教育分析报告_" + timestamp + ".docx";
|
|
|
|
|
|
|
|
WordGenerator.generateWordDocument(analysisResult, wordOutputPath, regions);
|
|
|
|
|
|
|
|
System.out.println("Word文档生成完成: " + wordOutputPath);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 生成HTML报告
|
|
|
|
|
|
|
|
// String htmlOutputPath = path + "/" + regionName + "_教育分析报告_" + timestamp + ".html";
|
|
|
|
|
|
|
|
// String htmlFilePath = HtmlGenerator.generateHtmlReport(analysisResult, htmlOutputPath, regionName);
|
|
|
|
|
|
|
|
// if (htmlFilePath != null) {
|
|
|
|
|
|
|
|
// System.out.println("HTML报告生成完成: " + htmlFilePath);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// // 生成PPT
|
|
|
|
|
|
|
|
// String token = PptAIKit.createApiToken("dsideal", 1000);
|
|
|
|
|
|
|
|
// String pptFilePath = PptGenerator.generatePptPresentation(analysisResult, regions, token);
|
|
|
|
|
|
|
|
// if (pptFilePath != null) {
|
|
|
|
|
|
|
|
// System.out.println("PPT演示文稿生成完成: " + pptFilePath);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
System.err.println("保存文件时出错: " + e.getMessage());
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onError(String error) {
|
|
|
|
|
|
|
|
System.err.println("DeepSeek分析出错: " + error);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|