Commit 2daaa59972d3253a3dcb7a0e0eae9ddf75e8f60a

Authored by ljq
1 parent ffbca700

deepseek页面

src/main/resources/static/real_control_v2/css/main.css
@@ -2339,4 +2339,10 @@ g.gps-wrap rect.twinkle[updown="1"] { @@ -2339,4 +2339,10 @@ g.gps-wrap rect.twinkle[updown="1"] {
2339 background: #fafff2!important; 2339 background: #fafff2!important;
2340 color: #659f13!important; 2340 color: #659f13!important;
2341 2341
  2342 +}
  2343 +
  2344 +#depsepDiv{
  2345 + width: 413px;
  2346 + height: 300px;
  2347 + overflow-y: scroll;
2342 } 2348 }
2343 \ No newline at end of file 2349 \ No newline at end of file
src/main/resources/static/real_control_v2/js/data/json/north_toolbar.json
@@ -212,6 +212,12 @@ @@ -212,6 +212,12 @@
212 "id": 4.6, 212 "id": 4.6,
213 "text": "智能调度开关", 213 "text": "智能调度开关",
214 "event": "zndd_status" 214 "event": "zndd_status"
  215 + },
  216 +
  217 + {
  218 + "id": 4.7,
  219 + "text": "调度助手(deepseek)",
  220 + "event": "deepseek"
215 } 221 }
216 222
217 ] 223 ]
src/main/resources/static/real_control_v2/js/main.js
@@ -4,33 +4,55 @@ var gb_main_ep = new EventProxy(), @@ -4,33 +4,55 @@ var gb_main_ep = new EventProxy(),
4 4
5 5
6 var recorder; 6 var recorder;
7 - var fired = true;  
8 - document.onkeypress =function(e) { //对整个页面监听  
9 - var keyNum = window.event ? e.keyCode : e.which; //获取被按下的键值  
10 - //判断如果用户按下了回车键(keycody=13)  
11 - if (keyNum == 13) {  
12 - var id = document.getElementById("len");  
13 - if(fired)  
14 - fired = false;  
15 - else  
16 - return  
17 - 7 + var fired = false;
  8 + let timer = null;//定时器
  9 + const longPressDuration = 500; // 长按的阈值,单位毫秒
  10 + var zxFl = true; //定时器内只执行一次;
  11 +
  12 + function openAi(){
  13 + if (zxFl){
  14 + console.log('长按回车键');
  15 + zxFl = false;
  16 + fired = true;
18 document.getElementById("recidress").style.display = ""; 17 document.getElementById("recidress").style.display = "";
19 HZRecorder.get(function (rec) { 18 HZRecorder.get(function (rec) {
20 recorder = rec; 19 recorder = rec;
21 recorder.start(); 20 recorder.start();
22 }); 21 });
  22 + }
  23 + }
23 24
24 25
  26 + document.addEventListener('keydown', function(event) {
  27 + if (event.key === 'Enter' && zxFl) {
  28 + // 开始计时
  29 + timer = setTimeout(() => {
  30 + openAi();
  31 + // 执行长按的逻辑
  32 + }, longPressDuration);
25 } 33 }
26 - } 34 + });
  35 +
  36 + document.addEventListener('keyup', function(event) {
  37 + if (event.key === 'Enter') {
  38 + // 清除计时器,表示短按
  39 + clearTimeout(timer);
  40 + console.log('短按回车键');
  41 + // 执行短按的逻辑
  42 + }
  43 + });
  44 +
27 45
28 document.onkeyup =function(e) { //对整个页面监听 46 document.onkeyup =function(e) { //对整个页面监听
29 var keyNum = window.event ? e.keyCode : e.which; //获取被按下的键值 47 var keyNum = window.event ? e.keyCode : e.which; //获取被按下的键值
30 //判断如果用户按下了回车键(keycody=13) 48 //判断如果用户按下了回车键(keycody=13)
  49 + console.log('松开回车键');
  50 + clearTimeout(timer);
31 if (keyNum == 13) { 51 if (keyNum == 13) {
32 - fired = true; 52 + if(!fired)
  53 + return;
33 54
  55 + fired = false;zxFl= true;
34 let lineCode = gb_schedule_table.TablelineCode; 56 let lineCode = gb_schedule_table.TablelineCode;
35 document.getElementById("recidress").style.display = 'none'; 57 document.getElementById("recidress").style.display = 'none';
36 recorder.upload("zndd/do/"+lineCode, function (state, e) { 58 recorder.upload("zndd/do/"+lineCode, function (state, e) {
src/main/resources/static/real_control_v2/js/north/toolbar.js
@@ -152,6 +152,10 @@ var gb_northToolbar = (function () { @@ -152,6 +152,10 @@ var gb_northToolbar = (function () {
152 open_modal('/real_control_v2/zndd/zndd_status.html', {}, modal_opts); 152 open_modal('/real_control_v2/zndd/zndd_status.html', {}, modal_opts);
153 }, 153 },
154 154
  155 + deepseek: function () {
  156 + open_modal('/real_control_v2/zndd/deepseek/deepseek.html', {}, modal_opts);
  157 + },
  158 +
155 // bcgxsj_config: function () { 159 // bcgxsj_config: function () {
156 // open_modal('/real_control_v2/fragments/north/nav/line_config/bcgxsj_config.html', {}, modal_opts); 160 // open_modal('/real_control_v2/fragments/north/nav/line_config/bcgxsj_config.html', {}, modal_opts);
157 // }, 161 // },
src/main/resources/static/real_control_v2/main.html
@@ -382,6 +382,8 @@ @@ -382,6 +382,8 @@
382 <div class="multi_plat_msg_pop_klyj" ></div> 382 <div class="multi_plat_msg_pop_klyj" ></div>
383 <script id="klyj_plat_msg_template" type="text/html"> 383 <script id="klyj_plat_msg_template" type="text/html">
384 <div class="multi_plat_config" data-type="{{type}}" data-uuid="{{uuid}}"> 384 <div class="multi_plat_config" data-type="{{type}}" data-uuid="{{uuid}}">
  385 + <div class="msg-popup warning-color" style="text-align: center;min-height: 0;"> <span>智能调度助手分析</span></div>
  386 + <div id="depsepDiv" class="msg-popup warning-color" style="white-space: pre-line;"></div>
385 <div id ={{uuid}} class="timer"></div> 387 <div id ={{uuid}} class="timer"></div>
386 <div class="msg-popup warning-color"> 388 <div class="msg-popup warning-color">
387 <div class="msg-times" style="cursor: pointer;">×</div> 389 <div class="msg-times" style="cursor: pointer;">×</div>
src/main/resources/static/real_control_v2/zndd/deepseek/deepseek.html 0 → 100644
  1 +<div class="uk-modal ct-form-modal" id="tts-config-modal">
  2 + <div class="uk-modal-dialog" style="width: 1030px;">
  3 + <a href="" class="uk-modal-close uk-close"></a>
  4 + <div class="uk-modal-header">
  5 + <h2>调度助手(deepseek)</h2></div>
  6 +
  7 + <div class="chat-container">
  8 + <div class="messages-container" id="messages"></div>
  9 + <div class="typing-indicator" id="typing" style="display: none;">DeepSeek 正在思考输入...</div>
  10 + <div class="input-container">
  11 + <input type="text" id="input" placeholder="输入你的问题...">
  12 + <button onclick="sendMessage()">发送</button>
  13 + </div>
  14 + </div>
  15 + </div>
  16 + <style>
  17 +
  18 +
  19 + .chat-container {
  20 + max-width: 800px;
  21 + margin: 0 auto;
  22 + background-color: white;
  23 + border-radius: 10px;
  24 + box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  25 + }
  26 +
  27 + .messages-container {
  28 + height: 500px;
  29 + overflow-y: auto;
  30 + padding: 20px;
  31 + }
  32 +
  33 + .message {
  34 + display: flex;
  35 + margin-bottom: 15px;
  36 + }
  37 +
  38 + .message.user {
  39 + justify-content: flex-end;
  40 + }
  41 +
  42 + .message.bot {
  43 + justify-content: flex-start;
  44 + }
  45 +
  46 + .bubble {
  47 + max-width: 70%;
  48 + padding: 12px 18px;
  49 + border-radius: 15px;
  50 + line-height: 1.4;
  51 + white-space: pre-line;
  52 + }
  53 +
  54 + .user .bubble {
  55 + background-color: #007bff;
  56 + color: white;
  57 + }
  58 +
  59 + .bot .bubble {
  60 + background-color: #e9ecef;
  61 + color: black;
  62 + }
  63 +
  64 + .input-container {
  65 + display: flex;
  66 + padding: 20px;
  67 + border-top: 1px solid #ddd;
  68 + }
  69 +
  70 + input[type="text"] {
  71 + flex: 1;
  72 + padding: 12px;
  73 + border: 1px solid #ddd;
  74 + border-radius: 5px;
  75 + margin-right: 10px;
  76 + }
  77 +
  78 + button {
  79 + padding: 12px 24px;
  80 + background-color: #007bff;
  81 + color: white;
  82 + border: none;
  83 + border-radius: 5px;
  84 + cursor: pointer;
  85 + }
  86 +
  87 + button:hover {
  88 + background-color: #0056b3;
  89 + }
  90 +
  91 + .typing-indicator {
  92 + padding: 0 20px 10px;
  93 + color: #666;
  94 + font-style: italic;
  95 + }
  96 + </style>
  97 + <script>
  98 + const messagesContainer = document.getElementById('messages');
  99 + const input = document.getElementById('input');
  100 + const typingIndicator = document.getElementById('typing');
  101 +
  102 + // 处理回车键
  103 + input.addEventListener('keypress', (e) => {
  104 + if (e.key === 'Enter') {
  105 + sendMessage();
  106 + }
  107 + });
  108 +
  109 + function sendMessage() {
  110 + const message = input.value.trim();
  111 + if (!message) return;
  112 +
  113 + // 添加用户消息
  114 + addMessage(message, 'user');
  115 + input.value = '';
  116 + var tEnum ={
  117 + xl_1 : "线",
  118 + xl_2 : "路",
  119 + yyqk : "营运情况",
  120 + }
  121 +
  122 + // 模拟AI回复
  123 + let date = {
  124 + "message": message/*"遇到大客流帮我推荐一种方案"*/, //消息
  125 + "mode": "query" //chat聊天 query知识库查询 选一个
  126 + }
  127 + //线路
  128 + if ((message.includes(tEnum.xl_1) && message.includes(tEnum.yyqk)) || (message.includes(tEnum.xl_2) && message.includes(tEnum.yyqk))){
  129 + bcyyqk(message);
  130 + }else {
  131 + subtim(date);
  132 + }
  133 + showTypingIndicator();
  134 +
  135 +
  136 +
  137 + }
  138 +
  139 + function addMessage(text, sender) {
  140 + const messageDiv = document.createElement('div');
  141 + messageDiv.className = `message ${sender}`;
  142 +
  143 + const bubble = document.createElement('div');
  144 + bubble.className = 'bubble';
  145 + bubble.textContent = text;
  146 + if (sender == 'bot'){
  147 + bubble.textContent = '';
  148 + tests = text
  149 + bubbles = bubble;
  150 + char_index = 0;
  151 + //type(text);
  152 + }
  153 + messageDiv.appendChild(bubble);
  154 + messagesContainer.appendChild(messageDiv);
  155 +
  156 + // 自动滚动到底部
  157 + messagesContainer.scrollTop = messagesContainer.scrollHeight;
  158 + }
  159 + var tests =""
  160 + var bubbles;
  161 + char_index = 0
  162 +
  163 + function bcyyqk(message){
  164 + $.get("/logZndd/schDeepSeep",{message:message},function (re){
  165 + if (re.code == 200){
  166 + //根据返回的参数组成一句话,再让deepseep扩充一下
  167 + var mes = "根据后面这些话,解析并优化一下,"+"线路:"+re.xlName+",总班次数"+re.bcs
  168 + +",进场班次数"+re.inbcs+",出场班次数"+re.outbcs+",临加班次数"+re.ljbcs+",正常班次数"+re.normalbcs
  169 + +",区间班次"+re.regionbcs+",未执行班次数"+re.wzxbcs+",正在执行班次数"+re.zzxbcs+",已执行班次数"+re.yzxbcs
  170 + +",烂班班次数" +re.lbbcs;
  171 +
  172 + console.log(mes);
  173 + var datas = {
  174 + "message": mes/*"遇到大客流帮我推荐一种方案"*/, //消息
  175 + "mode": "chat" //chat聊天 query知识库查询 选一个
  176 + }
  177 +
  178 + subtim(datas);
  179 + }else {
  180 + // 弹出添加失败提示消息
  181 + layer.msg('无法找到输入线路...');
  182 + hideTypingIndicator();
  183 + }
  184 + })
  185 + }
  186 +
  187 +
  188 + function subtim(date){
  189 +
  190 + const apiUrl = 'http://61.169.120.202:3001/api/v1/workspace/deep/stream-chat'; // 替换为实际接口地址
  191 + let xhr = new XMLHttpRequest();
  192 + xhr.open('POST', apiUrl, true);
  193 + // 设置请求头
  194 + xhr.setRequestHeader('Content-Type', 'application/json');
  195 + xhr.setRequestHeader('Authorization', `Bearer 701MSMS-JNS4WNG-JSDY4GH-RHD93NM`);
  196 +
  197 + addMessage("", 'bot');
  198 + var ins = 0;
  199 + // 监听数据流
  200 + xhr.onprogress = function (event) {
  201 + // 获取当前接收的数据片段
  202 + const responseText = xhr.responseText;
  203 + const lines = responseText.split('\n').filter(line => line !== '');
  204 + try {
  205 + for (var i = 0 ; i < lines.length ; i ++) {
  206 + if (i >= ins || ins == 0) {
  207 + ins = i +1;
  208 + var line = lines[i].replace(/^data: /, '');
  209 + const data = JSON.parse(line);
  210 + let txt = bubbles.textContent;
  211 + bubbles.textContent += data.textResponse!= null? data.textResponse :"";
  212 + //结束
  213 + if (data.type == "finalizeResponseStream"){
  214 + hideTypingIndicator();
  215 + }
  216 + }
  217 + }
  218 + } catch (e) {
  219 + console.error('解析错误:', e);
  220 + }
  221 + };
  222 +
  223 + // 发送请求
  224 + const requestBody = JSON.stringify(date);
  225 + xhr.send(requestBody);
  226 +
  227 + // 错误处理
  228 + xhr.onerror = function () {
  229 + console.error('请求失败');
  230 + };
  231 +
  232 +
  233 + ///一次性请求的方法,慢弃用。
  234 + /* // 提交
  235 + $.ajax({
  236 + type: 'POST',
  237 + url: "http://192.168.168.141:3001/api/v1/workspace/deep/stream-chat",
  238 + contentType: "application/json",
  239 + headers: {
  240 + authorization: "Bearer 701MSMS-JNS4WNG-JSDY4GH-RHD93NM",
  241 + },
  242 + timeout: 0,
  243 + data: JSON.stringify(date),
  244 + success: function(datas){
  245 + setTimeout(() => {
  246 + hideTypingIndicator();
  247 + addMessage(datas.textResponse, 'bot');
  248 + }, 1500);
  249 + },
  250 + error: function(xhr, type){
  251 + alert('错误:TODO');
  252 + }
  253 + });*/
  254 + }
  255 +
  256 +
  257 + function showTypingIndicator() {
  258 + typingIndicator.style.display = 'block';
  259 + messagesContainer.scrollTop = messagesContainer.scrollHeight;
  260 + }
  261 +
  262 + function hideTypingIndicator() {
  263 + typingIndicator.style.display = 'none';
  264 + }
  265 +
  266 + </script>
  267 +</div>
  268 +