Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
J
jyzb_platformV2
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Members
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
赵剑炜
jyzb_platformV2
Commits
9c9ffee4
Commit
9c9ffee4
authored
Jan 23, 2024
by
李小惠
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of
http://gitlab.sothing.top/843502640/jyzb_platformV2
into develop-lxh
parents
6ad08e10
bbe3f593
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
109 行增加
和
61 行删除
+109
-61
OnOpenReq.java
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/req/wsReq/OnOpenReq.java
+0
-26
pom.xml
jyzb-biz/pom.xml
+6
-0
CabinetWebSocketServer.java
jyzb-biz/src/main/java/com/junmp/jyzb/websocket/CabinetWebSocketServer.java
+74
-0
WarehouseWebSocketServer.java
jyzb-biz/src/main/java/com/junmp/jyzb/websocket/WarehouseWebSocketServer.java
+12
-34
pom.xml
jyzb-boot/pom.xml
+6
-0
application-local.yml
jyzb-boot/src/main/resources/application-local.yml
+4
-1
pom.xml
pom.xml
+7
-0
没有找到文件。
jyzb-api/src/main/java/com/junmp/jyzb/api/bean/req/wsReq/OnOpenReq.java
deleted
100644 → 0
View file @
6ad08e10
package
com
.
junmp
.
jyzb
.
api
.
bean
.
req
.
wsReq
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
lombok.Data
;
@Data
public
class
OnOpenReq
{
/**
*
*/
private
String
type
;
/**
*
*/
private
String
typeId
;
// 有参构造函数
public
OnOpenReq
(
@JsonProperty
(
"type"
)
String
type
,
@JsonProperty
(
"typeId"
)
String
typeId
)
{
this
.
type
=
type
;
this
.
typeId
=
typeId
;
}
}
jyzb-biz/pom.xml
View file @
9c9ffee4
...
...
@@ -157,5 +157,11 @@
<groupId>
org.bouncycastle
</groupId>
<artifactId>
bcprov-jdk15on
</artifactId>
</dependency>
<dependency>
<groupId>
com.junmp.v2
</groupId>
<artifactId>
thing-server
</artifactId>
<version>
1.0.0
</version>
<scope>
compile
</scope>
</dependency>
</dependencies>
</project>
jyzb-biz/src/main/java/com/junmp/jyzb/websocket/CabinetWebSocketServer.java
0 → 100644
View file @
9c9ffee4
package
com
.
junmp
.
jyzb
.
websocket
;
import
cn.hutool.core.date.DateTime
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.extra.spring.SpringUtil
;
import
com.alibaba.fastjson2.JSON
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.junmp.iot.server.ws.WebSocketServerListener
;
import
com.junmp.iot.server.ws.impl.DefaultWebSocketServerMessage
;
import
com.junmp.iot.server.ws.impl.DefaultWebSocketServerProtocol
;
import
com.junmp.jyzb.cache.OnlineRedisCache
;
import
com.junmp.jyzb.entity.Cabinet
;
import
com.junmp.jyzb.entity.Temp.OnlineState
;
import
com.junmp.jyzb.service.CabinetService
;
import
com.junmp.jyzb.service.impl.CabinetServiceImpl
;
import
com.junmp.v2.ws.api.enums.ClientMsgType
;
import
com.junmp.v2.ws.api.enums.ServerMsgType
;
import
com.junmp.v2.ws.api.enums.SysMsgTypeEnum
;
import
com.junmp.v2.ws.api.message.WsCallbackApi
;
import
com.junmp.v2.ws.api.session.bean.WsSession
;
import
com.junmp.v2.ws.bean.WsMsgDto
;
import
com.junmp.v2.ws.channel.WsSessionContainer
;
import
com.junmp.v2.ws.message.WsMessageHandle
;
import
com.junmp.v2.ws.session.WsSessionHandle
;
import
io.jsonwebtoken.JwtException
;
import
lombok.extern.slf4j.Slf4j
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.annotation.Order
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
javax.websocket.*
;
import
javax.websocket.server.PathParam
;
import
javax.websocket.server.ServerEndpoint
;
import
java.io.IOException
;
import
java.time.Instant
;
@Component
@Slf4j
public
class
CabinetWebSocketServer
implements
WebSocketServerListener
{
@Resource
public
CabinetService
cabinetService
;
@Override
public
String
uri
()
{
return
"/cabinet/ws"
;
}
@Override
public
void
onText
(
DefaultWebSocketServerProtocol
protocol
)
{
String
text
=
protocol
.
readText
();
log
.
info
(
"[接收客户端({})指令]|指令内容:{}"
,
protocol
.
getEquipCode
(),
text
);
Cabinet
cabinet
=
cabinetService
.
getOne
(
new
LambdaQueryWrapper
<
Cabinet
>()
.
eq
(
Cabinet:
:
getCabinetNum
,
text
));
cabinet
.
setOnlineState
(
1
);
cabinet
.
setUpdateTime
(
DateTime
.
now
());
DefaultWebSocketServerMessage
message
=
protocol
.
requestMessage
();
protocol
.
response
(
text
);
}
@Override
public
void
onClose
(
DefaultWebSocketServerProtocol
protocol
)
{
WebSocketServerListener
.
super
.
onClose
(
protocol
);
}
@Override
public
void
onBinary
(
DefaultWebSocketServerProtocol
protocol
)
{
WebSocketServerListener
.
super
.
onBinary
(
protocol
);
}
}
\ No newline at end of file
jyzb-biz/src/main/java/com/junmp/jyzb/websocket/
CustomScreen
WebSocketServer.java
→
jyzb-biz/src/main/java/com/junmp/jyzb/websocket/
Warehouse
WebSocketServer.java
View file @
9c9ffee4
...
...
@@ -8,11 +8,8 @@ import com.alibaba.fastjson2.JSON;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.junmp.jyzb.api.bean.req.wsReq.OnOpenReq
;
import
com.junmp.jyzb.cache.OnlineRedisCache
;
import
com.junmp.jyzb.cache.TemperatureRedisCache
;
import
com.junmp.jyzb.entity.Cabinet
;
import
com.junmp.jyzb.entity.Reassignment
;
import
com.junmp.jyzb.entity.Temp.OnlineState
;
import
com.junmp.jyzb.service.CabinetService
;
import
com.junmp.v2.ws.api.enums.ClientMsgType
;
...
...
@@ -23,7 +20,6 @@ import com.junmp.v2.ws.api.session.bean.WsSession;
import
com.junmp.v2.ws.bean.WsMsgDto
;
import
com.junmp.v2.ws.channel.WsSessionContainer
;
import
com.junmp.v2.ws.message.WsMessageHandle
;
import
com.junmp.v2.ws.server.ScreenWebSocketServer
;
import
com.junmp.v2.ws.session.WsSessionHandle
;
import
io.jsonwebtoken.JwtException
;
import
org.slf4j.Logger
;
...
...
@@ -37,28 +33,17 @@ import javax.websocket.server.ServerEndpoint;
import
java.io.IOException
;
import
java.time.Instant
;
//@Component
//@ServerEndpoint("/notice1/{data}")
//public class CustomScreenWebSocketServer extends ScreenWebSocketServer {
// @Override
//
// public void onOpen(Session session, @PathParam("data") String data) {
// String aa=data;
// // Your custom logic here
// super.onOpen(session, data); // Call the original method if needed
// }
//}
@Component
@ServerEndpoint
(
"/
notice1
/{data}"
)
public
class
CustomScreen
WebSocketServer
{
@ServerEndpoint
(
"/
warehouse
/{data}"
)
public
class
Warehouse
WebSocketServer
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
com
.
junmp
.
v2
.
ws
.
server
.
ScreenWebSocketServer
.
class
);
@Resource
public
CabinetService
cabinetService
;
@Resource
private
OnlineRedisCache
onlineRedisCache
;
public
CustomScreen
WebSocketServer
()
{
public
Warehouse
WebSocketServer
()
{
}
@OnOpen
...
...
@@ -66,30 +51,22 @@ public class CustomScreenWebSocketServer {
String
userId
=
null
;
try
{
ObjectMapper
objectMapper
=
new
ObjectMapper
();
OnOpenReq
onOpenObject
=
objectMapper
.
readValue
(
data
,
OnOpenReq
.
class
);
String
type
=
onOpenObject
.
getType
();
String
typeId
=
onOpenObject
.
getTypeId
();
// 获取当前时间的时间戳
Instant
now
=
Instant
.
now
();
// 转换为long类型
long
timestamp
=
now
.
toEpochMilli
();
if
(
type
.
equals
(
"cabinet"
))
//警柜已连接
{
Cabinet
cabinet
=
cabinetService
.
getOne
(
new
LambdaQueryWrapper
<
Cabinet
>()
.
eq
(
Cabinet:
:
getCabinetNum
,
typeId
));
Cabinet
cabinet
=
cabinetService
.
getOne
(
new
LambdaQueryWrapper
<
Cabinet
>()
.
eq
(
Cabinet:
:
getCabinetNum
,
data
));
cabinet
.
setOnlineState
(
1
);
cabinet
.
setUpdateTime
(
DateTime
.
now
());
// cabinetService.updateById(cabinet);
// //将数据放入redis
// onlineRedisCache.addSessionValue(session.getId(),type,typeId,timestamp);
}
else
if
(
type
.
equals
(
"warehouse"
))
{
//仓库主机已连接
}
}
catch
(
JwtException
|
JsonProcessingException
var15
)
{
}
catch
(
JwtException
var15
)
{
log
.
error
(
"建立连接异常>>"
+
var15
.
getMessage
());
try
{
...
...
@@ -183,8 +160,8 @@ public class CustomScreenWebSocketServer {
WsCallbackApi
wsCallbackApi
=
WsMessageHandle
.
getWsCallback
(
SysMsgTypeEnum
.
LISTENER_ON_CLOSE
.
getCode
());
if
(
ObjectUtil
.
isNotEmpty
(
wsSession
)
&&
ObjectUtil
.
isNotEmpty
(
wsCallbackApi
))
{
OnlineState
os
=
onlineRedisCache
.
getDataValue
(
wsSession
.
getSessionId
());
String
type
=
os
.
getType
();
String
typeId
=
os
.
getTypeId
();
String
type
=
os
.
getType
();
String
typeId
=
os
.
getTypeId
();
if
(
type
.
equals
(
"cabinet"
))
//警柜断开连接
{
Cabinet
cabinet
=
cabinetService
.
getOne
(
new
LambdaQueryWrapper
<
Cabinet
>()
...
...
@@ -215,4 +192,4 @@ public class CustomScreenWebSocketServer {
}
}
}
}
\ No newline at end of file
jyzb-boot/pom.xml
View file @
9c9ffee4
...
...
@@ -116,6 +116,12 @@
<groupId>
com.junmp.v2
</groupId>
<artifactId>
dict-boot-starter
</artifactId>
</dependency>
<dependency>
<groupId>
com.junmp.v2
</groupId>
<artifactId>
thing-boot-starter
</artifactId>
</dependency>
</dependencies>
<build>
...
...
jyzb-boot/src/main/resources/application-local.yml
View file @
9c9ffee4
...
...
@@ -6,7 +6,10 @@ easy-es:
address
:
192.168.3.121:9200
username
:
password
:
thing
:
server
:
websocket
:
start
:
true
# 配置第三方请求
junmp
:
swagger
:
...
...
pom.xml
View file @
9c9ffee4
...
...
@@ -226,6 +226,13 @@
<artifactId>
auth-sdk
</artifactId>
<version>
${junmp.v2.version}
</version>
</dependency>
<dependency>
<groupId>
com.junmp.v2
</groupId>
<artifactId>
thing-boot-starter
</artifactId>
<version>
${junmp.v2.version}
</version>
</dependency>
<dependency>
<groupId>
com.junmp.v2
</groupId>
<artifactId>
system-biz-user
</artifactId>
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论