diff --git a/Doc/待处理/区/【13】教育特征决策建议/【云南省】教育特征-决策建议.xlsx b/Doc/待处理/区/【13】教育特征决策建议/【云南省】教育特征-决策建议.xlsx
index 63a5f73b..b43c3aab 100644
Binary files a/Doc/待处理/区/【13】教育特征决策建议/【云南省】教育特征-决策建议.xlsx and b/Doc/待处理/区/【13】教育特征决策建议/【云南省】教育特征-决策建议.xlsx differ
diff --git a/Doc/待处理/区/【13】教育特征决策建议/【云南省】教育特征-决策建议【成果】.xlsx b/Doc/待处理/区/【13】教育特征决策建议/【云南省】教育特征-决策建议【成果】.xlsx
deleted file mode 100644
index c332a637..00000000
Binary files a/Doc/待处理/区/【13】教育特征决策建议/【云南省】教育特征-决策建议【成果】.xlsx and /dev/null differ
diff --git a/pom.xml b/pom.xml
index 916808b2..e229ea19 100644
--- a/pom.xml
+++ b/pom.xml
@@ -60,7 +60,24 @@
cos
${jfinal-cos.version}
-
+
+
+
+ com.alibaba
+ dashscope-sdk-java
+
+
+ org.slf4j
+ slf4j-simple
+
+
+ 2.16.9
+
+
+ com.squareup.okhttp3
+ okhttp
+ 4.10.0
+
cn.smallbun.screw
screw-core
diff --git a/src/main/java/com/dsideal/base/Test/Main.java b/src/main/java/com/dsideal/base/Test/Main.java
new file mode 100644
index 00000000..fe166aa9
--- /dev/null
+++ b/src/main/java/com/dsideal/base/Test/Main.java
@@ -0,0 +1,47 @@
+package com.dsideal.base.Test;
+// Copyright (c) Alibaba, Inc. and its affiliates.
+
+import java.util.Arrays;
+
+import com.alibaba.dashscope.aigc.generation.Generation;
+import com.alibaba.dashscope.aigc.generation.GenerationResult;
+import com.alibaba.dashscope.aigc.generation.models.QwenParam;
+import com.alibaba.dashscope.common.Message;
+import com.alibaba.dashscope.common.Role;
+import com.alibaba.dashscope.exception.ApiException;
+import com.alibaba.dashscope.exception.InputRequiredException;
+import com.alibaba.dashscope.exception.NoApiKeyException;
+import com.alibaba.dashscope.utils.Constants;
+
+
+public class Main {
+
+ /**
+ * 调用通义千问
+ * @param question
+ * @return
+ * @throws NoApiKeyException
+ * @throws ApiException
+ * @throws InputRequiredException
+ */
+ public static String callTongYiQianWen(String question)
+ throws NoApiKeyException, ApiException, InputRequiredException {
+ //使用驿来特的api key
+ Constants.apiKey = "sk-f6da0c787eff4b0389e4ad03a35a911f";
+ Generation gen = new Generation();
+ Message userMsg = Message.builder().role(Role.USER.getValue()).content(question).build();
+ QwenParam param =
+ QwenParam.builder().model("qwen-long").messages(Arrays.asList(userMsg))
+ .resultFormat(QwenParam.ResultFormat.MESSAGE).topP(0.8).build();
+ GenerationResult result = gen.call(param);
+ return result.getOutput().getChoices().getFirst().getMessage().getContent();
+ }
+
+
+ public static void main(String[] args) throws NoApiKeyException, InputRequiredException {
+ String question = "我将给你一段文字,帮我缩短到30字以内,我给出一个范例:红河人口负增长加剧,城镇人口先增后减,乡村人口剧减 ,后面就是原始文字:";
+ question += "2012-2020年,古城区总人口呈持续大幅增长趋势,年增长率约为3.0%。 2020年末至2022年,受新冠疫情、经济下滑等不利因素影响,总人口增长逐年下降,从28.7万人下降至26.7万人,减少2.0万人。未来人口预测结果显示,2023年起,全区人口总数呈逐年下降趋势,至2035年全区总人口仅为19.5万人(图1)。";
+
+ System.out.println(callTongYiQianWen(question));
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/dsideal/base/Tools/FillData/Area/A13.java b/src/main/java/com/dsideal/base/Tools/FillData/Area/A13.java
index 26260fdd..b5065cf4 100644
--- a/src/main/java/com/dsideal/base/Tools/FillData/Area/A13.java
+++ b/src/main/java/com/dsideal/base/Tools/FillData/Area/A13.java
@@ -1,6 +1,15 @@
package com.dsideal.base.Tools.FillData.Area;
import cn.hutool.core.io.FileUtil;
+import com.alibaba.dashscope.aigc.generation.Generation;
+import com.alibaba.dashscope.aigc.generation.GenerationResult;
+import com.alibaba.dashscope.aigc.generation.models.QwenParam;
+import com.alibaba.dashscope.common.Message;
+import com.alibaba.dashscope.common.Role;
+import com.alibaba.dashscope.exception.ApiException;
+import com.alibaba.dashscope.exception.InputRequiredException;
+import com.alibaba.dashscope.exception.NoApiKeyException;
+import com.alibaba.dashscope.utils.Constants;
import com.dsideal.base.DataEase.Model.DataEaseModel;
import com.dsideal.base.Tools.FillData.DataEaseKit.DsKit;
import com.dsideal.base.Tools.Util.LocalMysqlConnectUtil;
@@ -10,6 +19,8 @@ import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.apache.poi.xwpf.usermodel.XWPFDocument;
+import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
@@ -105,6 +116,28 @@ public class A13 {
return list;
}
+ /**
+ * 调用通义千问
+ *
+ * @param question
+ * @return
+ * @throws NoApiKeyException
+ * @throws ApiException
+ * @throws InputRequiredException
+ */
+ public static String callTongYiQianWen(String question)
+ throws NoApiKeyException, ApiException, InputRequiredException {
+ //使用驿来特的api key
+ Constants.apiKey = "sk-f6da0c787eff4b0389e4ad03a35a911f";
+ Generation gen = new Generation();
+ Message userMsg = Message.builder().role(Role.USER.getValue()).content(question).build();
+ QwenParam param =
+ QwenParam.builder().model("qwen-long").messages(Arrays.asList(userMsg))
+ .resultFormat(QwenParam.ResultFormat.MESSAGE).topP(0.8).build();
+ GenerationResult result = gen.call(param);
+ return result.getOutput().getChoices().getFirst().getMessage().getContent();
+ }
+
public static String rs(String s) {
//如果s中以 形如 (一) (二)或者 (三) (四)这样的内容替换为空,其它的内容保留下来
String regex = "(\\([一二三四五六七八九十]+\\))|(\\([一二三四五六七八九十]+\\))";
@@ -112,7 +145,25 @@ public class A13 {
}
- public static void main(String[] args) throws IOException, DocumentException {
+ public static String get2012Summary(String filePath) {
+ try (FileInputStream fis = new FileInputStream(filePath);
+ XWPFDocument document = new XWPFDocument(fis)) {
+
+ List paragraphs = document.getParagraphs();
+ for (XWPFParagraph paragraph : paragraphs) {
+ String text = paragraph.getText();
+ if (text != null && text.trim().startsWith("2012")) {
+ return text.trim();
+ }
+ }
+ return null;
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ public static void main(String[] args) throws IOException, DocumentException, NoApiKeyException, InputRequiredException {
//初始化数据库连接
LocalMysqlConnectUtil.Init();
//结果Excel
@@ -170,7 +221,11 @@ public class A13 {
}
}
Row outRow = outSheet.createRow(++rowIndex);
- DsKit.putData(outRow, Arrays.asList(areaName, "教育特征", "全县人口呈平稳增长趋势",
+ String content = get2012Summary(file.getAbsolutePath());
+ String question = "我将给你一段文字,帮我缩短到30字以内,我给出一个范例:红河人口负增长加剧,城镇人口先增后减,乡村人口剧减 ,后面就是原始文字:";
+ question += content;
+ String tz = callTongYiQianWen(question);
+ DsKit.putData(outRow, Arrays.asList(areaName, "教育特征", tz,
rs(list4.getFirst()),
rs(list4.get(1)),
rs(list4.get(2)),
diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml
index 496e52f6..139a58f4 100644
--- a/src/main/resources/application.yaml
+++ b/src/main/resources/application.yaml
@@ -47,4 +47,7 @@ excel:
# 上传文件地址
upload:
- path: D:/dsWork/YunNanDsBase/WebRoot/upload
\ No newline at end of file
+ path: D:/dsWork/YunNanDsBase/WebRoot/upload
+
+# 通义千问API KEY
+TongYiApiKey: sk-f6da0c787eff4b0389e4ad03a35a911f