From f3434f830cfee5838211e58a3a361c73f7166342 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期三, 22 七月 2026 10:30:48 +0800
Subject: [PATCH] 【丽水】外链测试接口
---
smartor/src/main/java/com/smartor/DeepSeekApi.java | 75 +++++++++++++++++++++++++++++++++++++
smartor/src/main/resources/mapper/smartor/ServiceOutPathMapper.xml | 2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/SmsController.java | 31 +++++++++++++++
3 files changed, 107 insertions(+), 1 deletions(-)
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/SmsController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/SmsController.java
index 06e31b7..6e53314 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/SmsController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/SmsController.java
@@ -217,5 +217,36 @@
return AjaxResult.success(sendMsg);
}
+ /**
+ * @param
+ * @return
+ */
+ @ApiOperation("鐢熸垚澶栭摼")
+ @PostMapping("/getUrl")
+ public AjaxResult getUrl(@RequestBody smsVO vo) throws UnsupportedEncodingException {
+ String content = "";
+ if (StringUtils.isNotEmpty(vo.getTaskId()) && StringUtils.isNotEmpty(vo.getPatId()) && StringUtils.isNotEmpty(vo.getSubId())) {
+ RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample();
+ String taskId = rsaPublicKeyExample.encryptedData(vo.getTaskId().toString(), pub_key);
+ String patid = rsaPublicKeyExample.encryptedData(vo.getPatId().toString(), pub_key);
+ String subId = rsaPublicKeyExample.encryptedData(vo.getSubId().toString(), pub_key);
+ Integer radix = iServiceOutPathService.selectAutoId();
+ String format = String.format("%03X", radix);
+ ServiceOutPath serviceOutPath = new ServiceOutPath();
+ serviceOutPath.setParam1(taskId);
+ serviceOutPath.setParam2(patid);
+ serviceOutPath.setParam3(vo.getTaskName());
+ serviceOutPath.setParam6(subId);
+ serviceOutPath.setRadix(format);
+ serviceOutPath.setCreateTime(new Date());
+ serviceOutPath.setOrgid(vo.getOrgid());
+ String url = ip + ":" + req_path + "/wt?p=" + format;
+// content = "鎮ㄥソ锛岄個璇锋偍濉啓鍑洪櫌璋冩煡琛紝璇风偣鍑�" + url + "濉啓銆傛劅璋㈡偍閰嶅悎锛�";
+ content = url;
+ serviceOutPath.setUrl(url);
+ iServiceOutPathService.insertServiceOutPath(serviceOutPath);
+ }
+ return AjaxResult.success(content);
+ }
}
diff --git a/smartor/src/main/java/com/smartor/DeepSeekApi.java b/smartor/src/main/java/com/smartor/DeepSeekApi.java
new file mode 100644
index 0000000..ff9fb7f
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/DeepSeekApi.java
@@ -0,0 +1,75 @@
+package com.smartor;
+
+;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import okhttp3.*;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class DeepSeekApi {
+ // 鏇挎崲涓轰綘鑷繁鐨刱ey
+ private static final String API_KEY = "sk-";
+ private static final String API_URL = "https://api.deepseek.com/v1/chat/completions";
+
+ public static void main(String[] args) {
+ String resp = chatCompletion("鐢↗ava鍐欎竴涓啋娉℃帓搴�");
+ System.out.println("DeepSeek杩斿洖缁撴灉锛歕n" + resp);
+ }
+
+ public static String chatCompletion(String userPrompt) {
+ OkHttpClient client = new OkHttpClient();
+
+ // 1. 缁勮娑堟伅浣�
+ List<Map<String, String>> messages = new ArrayList<>();
+ // 绯荤粺瑙掕壊锛堝彲閫夛紝鐢ㄤ簬璁惧畾AI韬唤锛�
+ Map<String, String> sysMsg = new HashMap<>();
+ sysMsg.put("role", "system");
+ sysMsg.put("content", "浣犳槸涓撲笟Java寮�鍙戝伐绋嬪笀锛屽洖绛旂畝娲佽鑼�");
+ messages.add(sysMsg);
+ // 鐢ㄦ埛鎻愰棶
+ Map<String, String> userMsg = new HashMap<>();
+ userMsg.put("role", "user");
+ userMsg.put("content", userPrompt);
+ messages.add(userMsg);
+
+ // 2. 璇锋眰鍙傛暟
+ Map<String, Object> requestBody = new HashMap<>();
+ requestBody.put("model", "deepseek-chat");
+ requestBody.put("messages", messages);
+ requestBody.put("temperature", 0.7); // 闅忔満鎬�0~1锛岃秺浣庤秺涓ヨ皑
+ requestBody.put("max_tokens", 1024);
+
+ // 3. 鏋勫缓璇锋眰
+ String jsonBody = JSON.toJSONString(requestBody);
+ RequestBody body = RequestBody.create(MediaType.parse("application/json"), jsonBody);
+
+ Request request = new Request.Builder()
+ .url(API_URL)
+ .header("Authorization", "Bearer " + API_KEY)
+ .header("Content-Type", "application/json")
+ .post(body)
+ .build();
+
+ // 4. 鍙戦�佽姹�
+ try (Response response = client.newCall(request).execute()) {
+ if (!response.isSuccessful()) {
+ return "璇锋眰澶辫触锛岀姸鎬佺爜锛�" + response.code() + "锛岄敊璇俊鎭細" + response.body().string();
+ }
+ String resJson = response.body().string();
+ JSONObject jsonObj = JSON.parseObject(resJson);
+ // 鎻愬彇AI鍥炵瓟鍐呭
+ return jsonObj.getJSONArray("choices")
+ .getJSONObject(0)
+ .getJSONObject("message")
+ .getString("content");
+ } catch (IOException e) {
+ e.printStackTrace();
+ return "鎺ュ彛璋冪敤寮傚父锛�" + e.getMessage();
+ }
+ }
+}
\ No newline at end of file
diff --git a/smartor/src/main/resources/mapper/smartor/ServiceOutPathMapper.xml b/smartor/src/main/resources/mapper/smartor/ServiceOutPathMapper.xml
index 1501541..fd1a9fb 100644
--- a/smartor/src/main/resources/mapper/smartor/ServiceOutPathMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/ServiceOutPathMapper.xml
@@ -229,7 +229,7 @@
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = 'service_out_path'
AND table_schema = DATABASE()
- and onorgid
+-- and onorgid
</select>
</mapper>
--
Gitblit v1.9.3