Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
deep-ask
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
deepseek
deep-ask
Commits
667d270c
Commit
667d270c
authored
Mar 04, 2025
by
luojun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
数据同步大屏
parent
5f0c7790
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
265 additions
and
70 deletions
+265
-70
DeepSeekAiListener.java
src/main/java/admin/listener/DeepSeekAiListener.java
+13
-0
SendSseModel.java
src/main/java/admin/model/SendSseModel.java
+37
-0
WebSocketModel.java
src/main/java/admin/model/WebSocketModel.java
+4
-2
ChatgptRoleRecordsController.java
src/main/java/admin/rest/ChatgptRoleRecordsController.java
+7
-1
OpenApiController.java
src/main/java/admin/rest/OpenApiController.java
+4
-3
VoiceWebSocketServer.java
src/main/java/admin/server/VoiceWebSocketServer.java
+71
-33
MaxkbOpenApiService.java
src/main/java/admin/service/MaxkbOpenApiService.java
+2
-1
MaxkbOpenApiServiceImpl.java
...main/java/admin/service/impl/MaxkbOpenApiServiceImpl.java
+3
-2
H5ConnectUtil.java
src/main/java/admin/util/H5ConnectUtil.java
+24
-0
ScreenEnum.java
src/main/java/admin/util/ScreenEnum.java
+44
-28
WebConnectUtil.java
src/main/java/admin/util/WebConnectUtil.java
+46
-0
WebSocketUtil.java
src/main/java/admin/util/WebSocketUtil.java
+10
-0
No files found.
src/main/java/admin/listener/DeepSeekAiListener.java
View file @
667d270c
...
...
@@ -8,6 +8,7 @@ import admin.modules.chatgpt.service.ChatgptRoleRecordsService;
import
admin.service.TextToSpeechService
;
import
admin.util.DateUtil
;
import
admin.util.ScreenEnum
;
import
admin.util.WebConnectUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.fasterxml.jackson.databind.DeserializationFeature
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
...
...
@@ -21,8 +22,10 @@ import okhttp3.sse.EventSourceListener;
import
javax.annotation.Resource
;
import
javax.websocket.Session
;
import
java.io.IOException
;
import
java.net.SocketException
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
...
...
@@ -89,6 +92,16 @@ public class DeepSeekAiListener extends EventSourceListener {
map
.
put
(
"content"
,
completionResponse
.
getContent
());
String
msg
=
JSON
.
toJSONString
(
map
);
this
.
session
.
getBasicRemote
().
sendText
(
msg
);
List
<
Session
>
webMap
=
WebConnectUtil
.
getWebMap
(
userName
);
if
(!
webMap
.
isEmpty
()){
webMap
.
forEach
(
i
->{
try
{
i
.
getBasicRemote
().
sendText
(
msg
);
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
});
}
}
//存储聊天记录
ChatgptRoleRecords
chatgptRoleRecords
=
new
ChatgptRoleRecords
();
...
...
src/main/java/admin/model/SendSseModel.java
0 → 100644
View file @
667d270c
package
admin
.
model
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
javax.websocket.Session
;
/**
* @author lj
* @date 2025/3/3 18:32
*/
@Data
@AllArgsConstructor
public
class
SendSseModel
{
/**
* 问题
*/
private
String
message
;
/**
* 会话id
*/
private
String
sessionId
;
/**
* session
*/
private
Session
seesion
;
/**
* 用户名
*/
private
String
userName
;
/**
* 是H5则发送消息给大屏
*/
private
boolean
isH5
;
}
src/main/java/admin/model/WebSocketModel.java
View file @
667d270c
...
...
@@ -10,6 +10,9 @@ import lombok.Data;
public
class
WebSocketModel
{
private
String
action
;
/**
* 后端响应数据
*/
private
String
content
;
private
String
type
;
/**
...
...
@@ -17,12 +20,11 @@ public class WebSocketModel {
*/
private
String
sessionId
;
/**
* 数据
*
前端提问
数据
*/
private
String
data
;
/**
* 大屏账号名称
*/
private
String
name
;
}
src/main/java/admin/rest/ChatgptRoleRecordsController.java
View file @
667d270c
...
...
@@ -26,7 +26,7 @@ import java.util.concurrent.TimeUnit;
@Slf4j
@RestController
@RequiredArgsConstructor
@Api
(
tags
=
"
微信小程序:
对话记录"
)
@Api
(
tags
=
"对话记录"
)
@RequestMapping
(
value
=
"wx/chatgptRoleRecords/"
)
public
class
ChatgptRoleRecordsController
{
...
...
@@ -56,4 +56,10 @@ public class ChatgptRoleRecordsController {
return
ApiResponse
.
buildSuccess
(
chatgptRoleRecordsService
.
queryTenRecords
(
userId
));
}
@ApiOperation
(
"查询屏幕列表"
)
@GetMapping
(
value
=
"queryScreenList"
)
public
ApiResponse
<
Object
>
queryScreenList
()
{
return
ApiResponse
.
buildSuccess
(
ScreenEnum
.
getScreen
());
}
}
src/main/java/admin/rest/OpenApiController.java
View file @
667d270c
package
admin
.
rest
;
import
admin.model.SendSseModel
;
import
admin.resp.ApiResponse
;
import
admin.service.DeepSeekOpenApiService
;
import
admin.service.MaxkbOpenApiService
;
...
...
@@ -38,12 +39,12 @@ public class OpenApiController {
@GetMapping
(
"testcompletions"
)
public
void
testcompletions
(
@RequestParam
String
chatId
,
@RequestParam
String
message
){
maxkbOpenApiService
.
chatCompletions
(
message
,
""
,
chatId
,
null
);
maxkbOpenApiService
.
chatCompletions
(
message
,
""
,
chatId
,
null
,
null
);
}
@GetMapping
(
"aItalk"
)
public
void
testcompletions
(
@RequestParam
S
tring
message
){
maxkbOpenApiService
.
talk
(
message
,
null
,
nul
l
);
public
void
testcompletions
(
@RequestParam
S
endSseModel
sendSseModel
){
maxkbOpenApiService
.
talk
(
sendSseMode
l
);
}
}
src/main/java/admin/server/VoiceWebSocketServer.java
View file @
667d270c
package
admin
.
server
;
import
admin.config.SpeechToTextConfig
;
import
admin.model.SendSseModel
;
import
admin.model.WebSocketModel
;
import
admin.modules.chatgpt.domain.ChatgptRoleRecords
;
import
admin.modules.chatgpt.domain.ChatgptRoleSession
;
import
admin.modules.chatgpt.service.ChatgptRoleRecordsService
;
import
admin.modules.chatgpt.service.ChatgptRoleSessionService
;
import
admin.service.MaxkbOpenApiService
;
import
admin.util.DateUtil
;
import
admin.util.ScreenEnum
;
import
admin.util.*
;
import
com.alibaba.fastjson.JSON
;
import
lombok.extern.slf4j.Slf4j
;
import
okhttp3.HttpUrl
;
...
...
@@ -31,7 +31,6 @@ import java.nio.charset.Charset;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.atomic.AtomicInteger
;
/**
* @author lj
...
...
@@ -41,7 +40,6 @@ import java.util.concurrent.atomic.AtomicInteger;
@Component
@Slf4j
public
class
VoiceWebSocketServer
{
private
static
AtomicInteger
onlineNum
=
new
AtomicInteger
();
private
static
SpeechToTextConfig
voiceConfig
;
private
static
MaxkbOpenApiService
maxkbOpenApiService
;
private
static
ChatgptRoleRecordsService
chatgptRoleRecordsService
;
...
...
@@ -73,16 +71,28 @@ public class VoiceWebSocketServer {
//建立连接成功调用
@OnOpen
public
void
onOpen
(
Session
session
,
@PathParam
(
value
=
"memberId"
)
String
memberId
)
{
log
.
info
(
"{}已连接"
,
memberId
);
sessionPools
.
put
(
memberId
,
session
);
//1.获取最新的会话id
String
[]
split
=
memberId
.
split
(
"__"
);
//1.h5还是web端
String
mark
=
split
[
0
];
//2.城市名称
String
name
=
split
[
1
];
//3.sessionId
String
sessionId
=
split
[
2
];
//4.存储不同的连接
if
(
mark
.
equals
(
WebSocketUtil
.
H5
)){
H5ConnectUtil
.
add
(
name
);
}
else
{
WebConnectUtil
.
put
(
sessionId
,
name
,
session
);
}
//5.获取最新的会话id
String
maxSessionId
=
chatgptRoleRecordsService
.
queryMaxSessionId
();
WebSocketModel
webSocketModel
=
new
WebSocketModel
();
webSocketModel
.
setType
(
"text"
);
webSocketModel
.
setAction
(
"replaySessionId"
);
webSocketModel
.
setContent
(
maxSessionId
);
webSocketModel
.
setSessionId
(
maxSessionId
);
//
2
.返回给前端最新的sessionId
//
6
.返回给前端最新的sessionId
String
msg
=
JSON
.
toJSONString
(
webSocketModel
);
try
{
session
.
getBasicRemote
().
sendText
(
msg
);
...
...
@@ -94,14 +104,25 @@ public class VoiceWebSocketServer {
//关闭连接时调用
@OnClose
public
void
onClose
(
Session
session
,
CloseReason
closeReason
,
@PathParam
(
value
=
"memberId"
)
String
memberId
)
{
sessionPools
.
remove
(
memberId
);
log
.
info
(
"关闭连接"
);
System
.
out
.
println
(
sessionPools
);
String
[]
split
=
memberId
.
split
(
"__"
);
//1.h5还是web端
String
mark
=
split
[
0
];
//2.城市名称
String
name
=
split
[
1
];
//3.sessionId
String
sessionId
=
split
[
2
];
//存储不同的连接
if
(
mark
.
equals
(
WebSocketUtil
.
H5
)){
H5ConnectUtil
.
remove
(
name
);
}
else
{
WebConnectUtil
.
remove
(
sessionId
);
}
}
//收到客户端信息
@OnMessage
(
maxMessageSize
=
10
*
1024
*
1024
)
public
void
onTextMessage
(
Session
session
,
String
message
)
throws
IOException
{
public
void
onTextMessage
(
Session
session
,
String
message
,
@PathParam
(
value
=
"memberId"
)
String
memberId
)
throws
IOException
{
// session.setMaxBinaryMessageBufferSize(50 * 1024 * 1024);
log
.
info
(
"message:{}"
,
message
);
WebSocketModel
webSocketModel
=
JSON
.
parseObject
(
message
,
WebSocketModel
.
class
);
...
...
@@ -123,6 +144,9 @@ public class VoiceWebSocketServer {
chatgptRoleRecords
.
setSenderId
(
ScreenEnum
.
getByUserName
(
webSocketModel
.
getName
()));
chatgptRoleRecords
.
setCreateTime
(
DateUtil
.
getNowTimestamp
());
chatgptRoleRecordsService
.
save
(
chatgptRoleRecords
);
//如果是H5则发送给大屏消息
sendMsgToWeb
(
memberId
,
webSocketModel
.
getData
(),
session
);
}
else
if
(
byId
!=
null
&&
"sendText"
.
equals
(
webSocketModel
.
getAction
()))
{
ChatgptRoleRecords
chatgptRoleRecords
=
new
ChatgptRoleRecords
();
chatgptRoleRecords
.
setMessage
(
webSocketModel
.
getData
());
...
...
@@ -131,33 +155,53 @@ public class VoiceWebSocketServer {
chatgptRoleRecords
.
setSenderId
(
ScreenEnum
.
getByUserName
(
webSocketModel
.
getName
()));
chatgptRoleRecords
.
setCreateTime
(
DateUtil
.
getNowTimestamp
());
chatgptRoleRecordsService
.
save
(
chatgptRoleRecords
);
//如果是H5则发送给大屏消息
sendMsgToWeb
(
memberId
,
webSocketModel
.
getData
(),
session
);
}
// 文字聊天
if
(
"sendText"
.
equals
(
webSocketModel
.
getAction
()))
{
String
msg
=
webSocketModel
.
getData
();
if
(
msg
!=
null
&&
!
msg
.
isEmpty
())
{
maxkbOpenApiService
.
talk
(
msg
,
webSocketModel
.
getSessionId
(),
session
,
webSocketModel
.
getName
());
SendSseModel
sendSseModel
=
new
SendSseModel
(
msg
,
webSocketModel
.
getSessionId
(),
session
,
webSocketModel
.
getName
(),
memberId
.
split
(
"__"
)[
0
].
equals
(
WebSocketUtil
.
web
));
maxkbOpenApiService
.
talk
(
sendSseModel
);
}
// 心跳
}
else
if
(
"heartbeat"
.
equals
(
webSocketModel
.
getAction
())){
Map
<
String
,
Object
>
map
=
new
HashMap
<>
();
map
.
put
(
"action"
,
"heartbeat_ack"
);
map
.
put
(
"type"
,
"text"
);
map
.
put
(
"content"
,
""
);
String
msg
=
JSON
.
toJSONString
(
map
);
WebSocketModel
webSocketModel1
=
new
WebSocketModel
();
webSocketModel1
.
setAction
(
"heartbeat_ack"
);
webSocketModel1
.
setType
(
"text"
);
webSocketModel1
.
setContent
(
""
);
String
msg
=
JSON
.
toJSONString
(
webSocketModel1
);
sendMessage
(
session
,
msg
);
}
}
// @OnMessage
// public void onBinaryMessage(Session session, ByteBuffer data) {
// session.setMaxBinaryMessageBufferSize(50 * 1024 * 1024);
// // 处理二进制音频数据块
// log.info("data:{}",data);
// handleAudioChunk(session, data);
// }
private
void
sendMsgToWeb
(
String
memberId
,
String
content
,
Session
session
)
{
String
[]
split
=
memberId
.
split
(
"__"
);
//1.h5还是web端
String
mark
=
split
[
0
];
//2.城市名称
String
name
=
split
[
1
];
if
(
mark
.
equals
(
WebSocketUtil
.
H5
)){
Map
<
String
,
String
>
map1
=
WebConnectUtil
.
getMap
();
map1
.
forEach
((
i
,
j
)->{
if
(
j
.
equals
(
name
)){
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"action"
,
"reply"
);
map
.
put
(
"type"
,
"text"
);
map
.
put
(
"content"
,
content
);
String
msg
=
JSON
.
toJSONString
(
map
);
try
{
session
.
getBasicRemote
().
sendText
(
msg
);
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
});
}
}
//错误时调用
@OnError
...
...
@@ -198,13 +242,10 @@ public class VoiceWebSocketServer {
//2.向ai提问获取答案
//3.文本转语音
textToSpeech
();
//
textToSpeech();
sendMessage
(
session
,
null
);
}
private
void
textToSpeech
()
{
}
/**
* 语音转文本
* @param data 语音数据
...
...
@@ -236,7 +277,6 @@ public class VoiceWebSocketServer {
StringBuilder
builder
=
new
StringBuilder
(
"host: "
).
append
(
url
.
getHost
()).
append
(
"\n"
).
//
append
(
"date: "
).
append
(
date
).
append
(
"\n"
).
//
append
(
"GET "
).
append
(
url
.
getPath
()).
append
(
" HTTP/1.1"
);
//System.out.println(builder);
Charset
charset
=
Charset
.
forName
(
"UTF-8"
);
Mac
mac
=
Mac
.
getInstance
(
"hmacsha256"
);
SecretKeySpec
spec
=
new
SecretKeySpec
(
apiSecret
.
getBytes
(
charset
),
"hmacsha256"
);
...
...
@@ -244,9 +284,7 @@ public class VoiceWebSocketServer {
byte
[]
hexDigits
=
mac
.
doFinal
(
builder
.
toString
().
getBytes
(
charset
));
String
sha
=
Base64
.
getEncoder
().
encodeToString
(
hexDigits
);
//System.out.println(sha);
String
authorization
=
String
.
format
(
"api_key=\"%s\", algorithm=\"%s\", headers=\"%s\", signature=\"%s\""
,
apiKey
,
"hmac-sha256"
,
"host date request-line"
,
sha
);
//System.out.println(authorization);
HttpUrl
httpUrl
=
HttpUrl
.
parse
(
"https://"
+
url
.
getHost
()
+
url
.
getPath
()).
newBuilder
().
//
addQueryParameter
(
"authorization"
,
Base64
.
getEncoder
().
encodeToString
(
authorization
.
getBytes
(
charset
))).
//
addQueryParameter
(
"date"
,
date
).
//
...
...
src/main/java/admin/service/MaxkbOpenApiService.java
View file @
667d270c
package
admin
.
service
;
import
admin.model.SendSseModel
;
import
admin.resp.ApiResponse
;
import
javax.websocket.Session
;
...
...
@@ -19,5 +20,5 @@ public interface MaxkbOpenApiService {
*/
void
chatCompletions
(
String
message
,
String
sessionId
,
String
chatId
,
Session
session
,
String
userName
);
void
talk
(
String
message
,
String
sessionId
,
Session
seesion
,
String
userName
);
void
talk
(
SendSseModel
sendSseModel
);
}
src/main/java/admin/service/impl/MaxkbOpenApiServiceImpl.java
View file @
667d270c
package
admin
.
service
.
impl
;
import
admin.model.SendSseModel
;
import
admin.model.WebSocketModel
;
import
admin.model.maxdb.MaxdbScreenConfig
;
import
admin.model.maxdb.MaxdbZkhjConfig
;
...
...
@@ -42,7 +43,7 @@ public class MaxkbOpenApiServiceImpl implements MaxkbOpenApiService {
}
@Override
public
void
talk
(
String
message
,
String
sessionId
,
Session
seesion
,
String
userName
)
{
public
void
talk
(
SendSseModel
sendSseModel
)
{
// if (message.contains("中科")){
//
// }else if (message.contains("大屏")){
...
...
@@ -53,6 +54,6 @@ public class MaxkbOpenApiServiceImpl implements MaxkbOpenApiService {
// }
ApiResponse
<
Object
>
maxkbSessionId
=
getMaxkbSessionId
(
maxdbScreenConfig
.
getApplicationId
());
chatCompletions
(
message
,
sessionId
,
String
.
valueOf
(
maxkbSessionId
.
getData
()),
seesion
,
userName
);
chatCompletions
(
sendSseModel
.
getMessage
(),
sendSseModel
.
getSessionId
(),
String
.
valueOf
(
maxkbSessionId
.
getData
()),
sendSseModel
.
getSeesion
(),
sendSseModel
.
getUserName
()
);
}
}
src/main/java/admin/util/H5ConnectUtil.java
0 → 100644
View file @
667d270c
package
admin
.
util
;
import
java.util.HashSet
;
import
java.util.Set
;
/**
* @author lj
* @date 2025/3/3 17:58
*/
public
class
H5ConnectUtil
{
/**
* 城市名
*/
private
static
final
Set
<
String
>
set
=
new
HashSet
<>();
public
static
void
add
(
String
value
){
set
.
add
(
value
);
}
public
static
void
remove
(
String
key
){
set
.
remove
(
key
);
}
}
src/main/java/admin/util/ScreenEnum.java
View file @
667d270c
...
...
@@ -4,6 +4,9 @@ import lombok.AllArgsConstructor;
import
lombok.Data
;
import
lombok.Getter
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @author lj
* @date 2025/2/27 18:14
...
...
@@ -12,36 +15,38 @@ import lombok.Getter;
@AllArgsConstructor
public
enum
ScreenEnum
{
PH_ADMIN
(
"ph"
,
1
),
PH_LC_ADMIN
(
"ph_lc"
,
2
),
PH_SCREEN
(
"phscreen"
,
3
),
PH_TEST
(
"test"
,
4
),
PH_PYT
(
"pyt"
,
5
),
PH_PYT_LS
(
"pytls"
,
6
),
ZP_GQ
(
"zp_gq"
,
7
),
ADMIN
(
"admin"
,
8
),
ALL_PARK
(
"all"
,
9
),
BLT_ADMIN
(
"blt"
,
10
),
BLT_LC_ADMIN
(
"blt_lc"
,
11
),
BLT_SCREEN
(
"screen"
,
12
),
JS_ADMIN
(
"js"
,
13
),
JS_LC_ADMIN
(
"js_lc"
,
14
),
JS_SCREEN
(
"jsscreen"
,
15
),
HK_ADMIN
(
"hk"
,
16
),
HK_LC_ADMIN
(
"hk_lc"
,
17
),
HK_SCREEN
(
"hkscreen"
,
18
),
JGS_ADMIN
(
"jgs"
,
19
),
JGS_LC_ADMIN
(
"jgs_lc"
,
20
),
JGS_SCREEN
(
"jgsscreen"
,
21
),
BJ_ADMIN
(
"bj"
,
22
),
HZ_ADMIN
(
"hz"
,
23
),
QY_ADMIN
(
"qy"
,
24
),
QYT_ADMIN
(
"qyt"
,
25
),
NC_ADMIN
(
"nc"
,
26
),
YZ_ADMIN
(
"yz"
,
27
),
NK_ADMIN
(
"nk"
,
28
);
PH_ADMIN
(
"ph"
,
1
,
1
,
"平湖"
),
PH_LC_ADMIN
(
"ph_lc"
,
2
,
0
,
"平湖"
),
PH_SCREEN
(
"phscreen"
,
3
,
0
,
"平湖"
),
PH_TEST
(
"test"
,
4
,
0
,
"平湖测试"
),
PH_PYT
(
"pyt"
,
5
,
0
,
"平湖平易停"
),
PH_PYT_LS
(
"pytls"
,
6
,
0
,
"平湖平易停"
),
ZP_GQ
(
"zp_gq"
,
7
,
0
,
"平湖"
),
ADMIN
(
"admin"
,
8
,
0
,
"全国"
),
ALL_PARK
(
"all"
,
9
,
1
,
"全国"
),
BLT_ADMIN
(
"blt"
,
10
,
1
,
"临沧"
),
BLT_LC_ADMIN
(
"blt_lc"
,
11
,
0
,
"临沧"
),
BLT_SCREEN
(
"screen"
,
12
,
0
,
"临沧"
),
JS_ADMIN
(
"js"
,
13
,
1
,
"嘉善"
),
JS_LC_ADMIN
(
"js_lc"
,
14
,
0
,
"嘉善"
),
JS_SCREEN
(
"jsscreen"
,
15
,
0
,
"嘉善"
),
HK_ADMIN
(
"hk"
,
16
,
1
,
"海口"
),
HK_LC_ADMIN
(
"hk_lc"
,
17
,
0
,
"海口"
),
HK_SCREEN
(
"hkscreen"
,
18
,
0
,
"海口"
),
JGS_ADMIN
(
"jgs"
,
19
,
1
,
"九宫山"
),
JGS_LC_ADMIN
(
"jgs_lc"
,
20
,
0
,
"九宫山"
),
JGS_SCREEN
(
"jgsscreen"
,
21
,
0
,
"九宫山"
),
BJ_ADMIN
(
"bj"
,
22
,
1
,
"北京"
),
HZ_ADMIN
(
"hz"
,
23
,
0
,
"展览路"
),
QY_ADMIN
(
"qy"
,
24
,
1
,
"庆阳"
),
QYT_ADMIN
(
"qyt"
,
25
,
0
,
"庆易停"
),
NC_ADMIN
(
"nc"
,
26
,
1
,
"南昌"
),
YZ_ADMIN
(
"yz"
,
27
,
1
,
"宜章"
),
NK_ADMIN
(
"nk"
,
28
,
1
,
"南康"
);
private
String
name
;
private
Integer
userId
;
private
Integer
isShow
;
private
String
screenName
;
public
static
Integer
getByUserName
(
String
userName
){
for
(
ScreenEnum
value:
ScreenEnum
.
values
()){
...
...
@@ -51,4 +56,15 @@ public enum ScreenEnum {
}
return
ScreenEnum
.
ALL_PARK
.
userId
;
}
public
static
List
<
ScreenEnum
>
getScreen
(){
List
<
ScreenEnum
>
list
=
new
ArrayList
<>();
for
(
ScreenEnum
value:
ScreenEnum
.
values
()){
if
(
value
.
isShow
.
equals
(
1
)){
list
.
add
(
value
);
}
}
return
list
;
}
}
src/main/java/admin/util/WebConnectUtil.java
0 → 100644
View file @
667d270c
package
admin
.
util
;
import
javax.websocket.Session
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
/**
* @author lj
* @date 2025/3/3 17:58
*/
public
class
WebConnectUtil
{
/**
* key - 网页的sessionId
* value - 城市名
*/
private
static
final
ConcurrentHashMap
<
String
,
String
>
map
=
new
ConcurrentHashMap
<>();
private
static
final
ConcurrentHashMap
<
String
,
Session
>
sessionMap
=
new
ConcurrentHashMap
<>();
public
static
void
put
(
String
key
,
String
value
,
Session
session
){
map
.
put
(
key
,
value
);
sessionMap
.
put
(
key
,
session
);
}
public
static
void
remove
(
String
key
){
map
.
remove
(
key
);
sessionMap
.
remove
(
key
);
}
public
static
Map
<
String
,
String
>
getMap
(){
return
map
;
}
public
static
List
<
Session
>
getWebMap
(
String
userName
)
{
List
<
Session
>
list
=
new
ArrayList
<>();
map
.
forEach
((
i
,
j
)->{
if
(
j
.
equals
(
userName
))
{
Session
session
=
sessionMap
.
get
(
i
);
list
.
add
(
session
);
}
});
return
list
;
}
}
src/main/java/admin/util/WebSocketUtil.java
0 → 100644
View file @
667d270c
package
admin
.
util
;
/**
* @author lj
* @date 2025/3/3 17:01
*/
public
class
WebSocketUtil
{
public
static
final
String
H5
=
"H5"
;
public
static
final
String
web
=
"WEB"
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment