From 554b43b55ab6f50721f3ceb04ab9650950fdb9f7 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期四, 23 七月 2026 13:44:37 +0800
Subject: [PATCH] 【丽水】去掉入科-经管医生
---
/dev/null | 75 ------------------
.idea/encodings.xml | 3
smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java | 6 -
smartor/src/main/java/com/smartor/common/DeepSeekApi.java | 148 +++++++++++++++++++++++++++++++++++++
4 files changed, 150 insertions(+), 82 deletions(-)
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
index e609fe5..e9b8913 100644
--- a/.idea/encodings.xml
+++ b/.idea/encodings.xml
@@ -39,7 +39,8 @@
<file url="file://$PROJECT_DIR$/ruoyi-system/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/ruoyi-system/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/smartor/src/main/java" charset="UTF-8" />
- <file url="file://$PROJECT_DIR$/smartor/src/main/java/com/smartor/DeepSeekApi.java" charset="GBK" />
+ <file url="file://$PROJECT_DIR$/smartor/src/main/java/com/smartor/common/DeepSeekApi.java" charset="UTF-8" />
+ <file url="file://$PROJECT_DIR$/smartor/src/main/java/com/smartor/common/DeepSeekApi.java" charset="GBK" />
<file url="file://$PROJECT_DIR$/smartor/src/main/java/com/smartor/domain/PatMedOuthospProvisional.java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/smartor/src/main/java/com/smartor/domain/ServiceSubtaskPreachform.java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/smartor/src/main/java/com/smartor/mapper/PatMedOuthospProvisionalMapper.java" charset="UTF-8" />
diff --git a/smartor/src/main/java/com/smartor/DeepSeekApi.java b/smartor/src/main/java/com/smartor/DeepSeekApi.java
deleted file mode 100644
index ff9fb7f..0000000
--- a/smartor/src/main/java/com/smartor/DeepSeekApi.java
+++ /dev/null
@@ -1,75 +0,0 @@
-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/java/com/smartor/common/DeepSeekApi.java b/smartor/src/main/java/com/smartor/common/DeepSeekApi.java
new file mode 100644
index 0000000..6f20955
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/common/DeepSeekApi.java
@@ -0,0 +1,148 @@
+package com.smartor.common;
+
+;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import okhttp3.*;
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.IOException;
+import java.util.*;
+
+@Slf4j
+public class DeepSeekApi {
+ // 鏇挎崲涓轰綘鑷繁鐨刱ey
+ private static final String API_KEY = "sk-4e489637e105411596be6c72e2dacdbd";
+ private static final String API_URL = "https://api.deepseek.com/v1/chat/completions";
+
+ public static void main(String[] args) {
+ String questionText = "鎮ㄥソ,璇烽棶鎮ㄦ槸鎮h�呮湰浜鸿繕鏄灞烇紵\n";
+ String voiceText = "鎴戣嚜宸�";
+ List<String> options = new ArrayList<>(Arrays.asList("鏈汉","浜插睘","鍏朵粬"));
+ Integer resp = matchOptionIndex(questionText, voiceText, options);
+ System.out.println("DeepSeek杩斿洖缁撴灉锛歕n" + resp);
+ }
+
+ public static String chatCompletion(String systemPrompt, 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", systemPrompt);
+ 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();
+ }
+ }
+
+ /**
+ * 鍒ゆ柇璇煶鏂囨湰鏈�鎺ヨ繎鍝釜閫夐」锛岃繑鍥為�夐」鍦ㄥ垪琛ㄤ腑鐨勪笅鏍囥��
+ *
+ * @param voiceText 璇煶璇嗗埆寰楀埌鐨勬枃鏈�
+ * @param options 鍊欓�夐�夐」鍒楄〃
+ * @return 鍛戒腑閫夐」鐨勪笅鏍囷紙浠� 0 寮�濮嬶級锛涙棤娉曞尮閰嶄换涓�閫夐」鏃惰繑鍥� {@code -1}
+ */
+ public static int matchOptionIndex(String questionText, String voiceText, List<String> options) {
+ if (StringUtils.isBlank(voiceText) || options == null || options.isEmpty()) {
+ return -1;
+ }
+ // 鍙湁涓�涓�夐」鏃舵棤闇�璋冪敤妯″瀷
+ if (options.size() == 1) {
+ return 0;
+ }
+
+ StringBuilder optionText = new StringBuilder();
+ for (int i = 0; i < options.size(); i++) {
+ optionText.append(i + 1).append(". ").append(options.get(i)).append('\n');
+ }
+
+ String systemPrompt = "\"浣犳槸涓�涓笓涓氱殑璇煶璇嗗埆鏂囨湰璇箟鍖归厤鍔╂墜銆備綘鐨勪换鍔℃槸鍒ゆ柇鐢ㄦ埛鐨勮闊虫枃鏈湪璇箟涓婃渶绗﹀悎鐨勯�夐」銆傜敤鎴蜂細缁欏嚭涓�娈佃闊宠瘑鍒枃鏈拰鑻ュ共涓甫缂栧彿鐨勯�夐」锛�"
+ + "璇峰垽鏂繖娈垫枃鏈湪璇箟涓婃渶鎺ヨ繎鍝竴涓�夐」銆傚彧鍏佽浠庣粰瀹氶�夐」涓�夋嫨锛�"
+ + "涓嶈鍋氫换浣曡В閲娿�傜洿鎺ヨ緭鍑烘渶鍖归厤閫夐」鐨勭紪鍙锋暟瀛楋紱鑻ユ病鏈変换浣曢�夐」涓庢枃鏈浉鍏筹紝鍒欒緭鍑� 0銆�";
+ String userPrompt = "璇锋牴鎹互涓嬩俊鎭繘琛岃涔夊尮閰嶅垽鏂細\n" +
+ "- 闂鏂囨湰锛�" + questionText + "\n\n"
+ + "- 璇煶璇嗗埆鏂囨湰锛�" + voiceText + "\n\n"
+ + "- 閫夐」锛歕n" + optionText
+ + "\n璇峰彧杈撳嚭涓�涓暟瀛楋紙鏈�鍖归厤閫夐」鐨勭紪鍙凤紝娌℃湁鍖归厤鍒欒緭鍑� 0锛夈��";
+
+ String content = chatCompletion(systemPrompt, userPrompt);
+ if (StringUtils.isBlank(content)) {
+ return -1;
+ }
+
+ Integer number = extractFirstNumber(content);
+ if (number == null || number <= 0 || number > options.size()) {
+ log.warn("DeepSeek 閫夐」鍖归厤鏈懡涓紝voiceText={}, options={}, modelReturn={}", voiceText, options, content);
+ return -1;
+ }
+ return number - 1;
+ }
+
+ /**
+ * 浠庢ā鍨嬪洖澶嶄腑鎻愬彇绗竴涓暣鏁般�傛ā鍨嬪伓灏斾細鍥炲 鈥滈�夐」2鈥� 鈥�2銆傗�� 涔嬬被锛屽仛涓�娆″厹搴曡В鏋愩��
+ */
+ private static Integer extractFirstNumber(String text) {
+ List<Character> digits = new ArrayList<>();
+ for (int i = 0; i < text.length(); i++) {
+ char c = text.charAt(i);
+ if (c >= '0' && c <= '9') {
+ digits.add(c);
+ } else if (!digits.isEmpty()) {
+ break;
+ }
+ }
+ if (digits.isEmpty()) {
+ return null;
+ }
+ StringBuilder sb = new StringBuilder();
+ for (char c : digits) {
+ sb.append(c);
+ }
+ try {
+ return Integer.parseInt(sb.toString());
+ } catch (NumberFormatException e) {
+ return null;
+ }
+ }
+}
\ No newline at end of file
diff --git a/smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java
index b4fe522..66d22d4 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java
@@ -434,12 +434,6 @@
ExternalInHospPatientInfo externalInHospPatientInfo = BeanUtil.mapToBean(BingRenXX, ExternalInHospPatientInfo.class, true);
ExternalInDeptPatientInfo externalInDeptPatientInfo = BeanUtil.mapToBean(RuKeXX, ExternalInDeptPatientInfo.class, true);
-
- ExternalInDeptPatientInfo externalJZInfo = BeanUtil.mapToBean(JiuZhenXX, ExternalInDeptPatientInfo.class, true);
- if(ObjectUtils.isNotEmpty(externalJZInfo)){
- externalInHospPatientInfo.setJingGuanYSID(externalJZInfo.getJingGuanYSID());
- externalInHospPatientInfo.setJingGuanYSXM(externalJZInfo.getJingGuanYSXM());
- }
externalInHospPatientInfo.setZeRenHSID(externalInDeptPatientInfo.getZeRenHSID());
externalInHospPatientInfo.setZeRenHSXM(externalInDeptPatientInfo.getZeRenHSXM());
externalInHospPatientInfo.setZhuZhiYSID(externalInDeptPatientInfo.getZhuZhiYSID());
--
Gitblit v1.9.3