Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 884bfbb4
由
LN
编写于
2026-02-07 18:52:00 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
msg转为MsgInfo
1 个父辈
4588d272
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
235 行增加
和
64 行删除
pom.xml
src/main/java/com/neotel/smfcore/core/device/bean/MsgInfo.java
src/main/java/com/neotel/smfcore/core/device/bean/StatusBean.java
src/main/java/com/neotel/smfcore/core/device/handler/impl/BaseDeviceHandler.java
src/main/java/com/neotel/smfcore/core/kanban/rest/BoxKanbanController.java
src/main/java/com/neotel/smfcore/core/kanban/rest/bean/dto/BoxStatusDto.java
src/main/java/com/neotel/smfcore/core/message/enums/MessageType.java
src/main/java/com/neotel/smfcore/core/system/util/DevicesStatusUtil.java
pom.xml
查看文件 @
884bfbb
...
...
@@ -16,7 +16,7 @@
<description>
SMF project for Spring Boot
</description>
<properties>
<maven.build.timestamp.format>
M.ddHHmm
</maven.build.timestamp.format>
<main.version>
3
.${maven.build.timestamp}
</main.version>
<main.version>
6
.${maven.build.timestamp}
</main.version>
<app.version>
${main.version}
</app.version>
<java.version>
1.8
</java.version>
<jjwt.version>
0.11.1
</jjwt.version>
...
...
src/main/java/com/neotel/smfcore/core/device/bean/MsgInfo.java
0 → 100644
查看文件 @
884bfbb
package
com
.
neotel
.
smfcore
.
core
.
device
.
bean
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.Serializable
;
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
MsgInfo
implements
Serializable
{
public
MsgInfo
(
String
msg
,
String
type
){
this
.
msg
=
msg
;
this
.
type
=
type
;
}
/**
* 提示消息
*/
private
String
msg
=
""
;
/**
* 消息类型,INFO,WARNING,ERROR,DATA
*/
private
String
type
;
/**
* 英文提示消息
*/
private
String
msgEn
=
""
;
private
String
msgJp
=
""
;
/**
* 翻译key
*/
private
String
msgKey
=
""
;
/**
* 翻译参数
*/
private
String
[]
msgParam
;
// /**
// * 报警类型
// */
// private String alarmType="";
// /**
// *报警错误码
// */
// private String alarmCode="";
/**
* 模块
*/
private
String
moudle
=
""
;
/**
* 当前收到时间
*/
private
long
lastReceiveTime
=
System
.
currentTimeMillis
();
}
src/main/java/com/neotel/smfcore/core/device/bean/StatusBean.java
查看文件 @
884bfbb
此文件的差异被折叠,
点击展开。
src/main/java/com/neotel/smfcore/core/device/handler/impl/BaseDeviceHandler.java
查看文件 @
884bfbb
...
...
@@ -17,6 +17,7 @@ import com.neotel.smfcore.core.barcode.service.po.Barcode;
import
com.neotel.smfcore.core.barcode.service.po.Component
;
import
com.neotel.smfcore.core.barcode.utils.CodeResolve
;
import
com.neotel.smfcore.core.device.bean.BoxStatusBean
;
import
com.neotel.smfcore.core.device.bean.MsgInfo
;
import
com.neotel.smfcore.core.device.enums.BOX_STATUS
;
import
com.neotel.smfcore.core.device.enums.OP
;
import
com.neotel.smfcore.core.device.enums.OP_STATUS
;
...
...
@@ -840,25 +841,30 @@ public class BaseDeviceHandler implements IDeviceHandler {
protected
void
handleMsg
(
StatusBean
statusBean
)
{
try
{
//转换为新格式
List
<
MsgInfo
>
mergeMsgList
=
statusBean
.
MsgDataProcess
();
//判断是否刚刚上线
StatusBean
bean
=
DevicesStatusUtil
.
getStatusBean
(
statusBean
.
getCid
());
if
(
bean
==
null
||
bean
.
getBoxStatus
()
==
null
)
{
DeviceMessageUtil
.
addOnlineMessage
(
statusBean
.
getCid
(),
""
,
statusBean
.
getClientIp
());
DevicesStatusUtil
.
updateClientMsg
(
statusBean
.
getCid
(),
""
,
""
,
""
,
""
,
null
);
DevicesStatusUtil
.
updateClientMsg
(
statusBean
.
getCid
(),
new
ArrayList
<>()
);
}
else
if
(
bean
.
timeOut
()
&&
(
bean
.
getOfflineTime
()
>
-
1
))
{
DeviceMessageUtil
.
addOnlineMessage
(
statusBean
.
getCid
(),
""
,
statusBean
.
getClientIp
());
DevicesStatusUtil
.
updateClientMsg
(
statusBean
.
getCid
(),
""
,
""
,
""
,
""
,
null
);
DevicesStatusUtil
.
updateClientMsg
(
statusBean
.
getCid
(),
new
ArrayList
<>()
);
}
//展示到界面
String
msg
=
statusBean
.
getMsg
();
String
msgEn
=
statusBean
.
getMsgEn
();
String
msgCode
=
statusBean
.
getMsgCode
();
String
msgJp
=
statusBean
.
getMsgJp
();
if
(
ObjectUtil
.
isNotEmpty
(
msg
)||
ObjectUtil
.
isNotEmpty
(
msgCode
))
{
DevicesStatusUtil
.
updateClientMsg
(
statusBean
.
getCid
(),
msgCode
,
msg
,
msgEn
,
msgJp
,
statusBean
.
getMsgParam
());
if
(
ObjectUtil
.
isNotEmpty
(
mergeMsgList
)&&
mergeMsgList
.
size
()>
0
)
{
DevicesStatusUtil
.
updateClientMsg
(
statusBean
.
getCid
(),
mergeMsgList
);
}
// //展示到界面
// String msg = statusBean.getMsg();
// String msgEn = statusBean.getMsgEn();
// String msgCode = statusBean.getMsgCode();
// String msgJp=statusBean.getMsgJp();
//
// if(ObjectUtil.isNotEmpty(msg)||ObjectUtil.isNotEmpty(msgCode)) {
// DevicesStatusUtil.updateClientMsg(statusBean.getCid(), msgCode, msg, msgEn, msgJp,statusBean.getMsgParam());
// }
}
catch
(
Exception
e
)
{
log
.
error
(
"客户端故障消息处理出错"
,
e
);
}
...
...
@@ -891,6 +897,7 @@ public class BaseDeviceHandler implements IDeviceHandler {
statusBean
.
setOp
(
statusBeanToSave
.
getOp
());
statusBean
.
setSeq
(
statusBeanToSave
.
getSeq
());
statusBean
.
setClientIp
(
statusBeanToSave
.
getClientIp
());
statusBean
.
setMsgList
(
statusBeanToSave
.
getMsgList
());
/**
* 已解除的报警信息存到数据库中
...
...
src/main/java/com/neotel/smfcore/core/kanban/rest/BoxKanbanController.java
查看文件 @
884bfbb
...
...
@@ -420,11 +420,12 @@ public class BoxKanbanController {
}
int
allCount
=
inTask
+
outTask
;
BoxStatusDto
boxDto
=
new
BoxStatusDto
(
storage
.
getId
(),
storage
.
getName
(),
storage
.
getCid
(),
false
,
0
,
"0"
,
"0"
,
"0"
,
""
,
allCount
,
inTask
,
outTask
,
"0"
,
"0"
,
"0"
,
""
,
""
,
allCount
,
inTask
,
outTask
,
0
,
""
,
""
,
""
,
""
,
""
,
storage
.
getType
(),
storage
.
getUsageMap
(),
new
HashMap
<>(),
storage
.
getInListName
());
//获取设备状态,设置状态和当前任务信息
StatusBean
bean
=
DevicesStatusUtil
.
getStatusBean
(
storage
.
getCid
());
if
(
bean
==
null
||
bean
.
getBoxStatus
()
==
null
)
{
boxDto
.
setOnLine
(
false
);
...
...
@@ -460,7 +461,10 @@ public class BoxKanbanController {
}
boxDto
.
setCodeAirTemp
(
boxStatus
.
getCodeAirTemp
());
boxDto
.
setStatus
(
bean
.
getStatus
());
boxDto
.
setMsg
(
bean
.
getShowMsg
(
locale
));
boxDto
.
setMsg
(
bean
.
getErrorMsg
(
locale
));
boxDto
.
setMsgInfo
(
bean
.
getInfoMsg
(
locale
));
boxDto
.
setBarcode
(
bean
.
getCode
());
boxDto
.
setPosName
(
bean
.
getPosId
());
boxDto
.
setData
(
bean
.
getData
());
...
...
src/main/java/com/neotel/smfcore/core/kanban/rest/bean/dto/BoxStatusDto.java
查看文件 @
884bfbb
...
...
@@ -37,9 +37,11 @@ public class BoxStatusDto {
private
String
humidity
;
@ApiModelProperty
(
"冷气机温度"
)
private
String
codeAirTemp
;
@ApiModelProperty
(
"
文字显示
"
)
@ApiModelProperty
(
"
报警文字显示:红色
"
)
private
String
msg
=
""
;
@ApiModelProperty
(
"信息文字显示:绿色"
)
private
String
msgInfo
=
""
;
@ApiModelProperty
(
"总任务数"
)
private
int
taskCount
=
0
;
...
...
@@ -77,6 +79,16 @@ public class BoxStatusDto {
//取出出库料盘:takeOutReel
//关闭仓门:confirmReelOut
// 状态显示: disable:不可用,enable:可用,点击按钮后发送 doit
//暂停蜂鸣器按钮:pauseBuzzer
// pauseBuzzer 状态显示: disable:不显示,enable:显示,点击按钮后发送 doit
// //SP1540 增加三个门按钮:
// D01Status D02Status D03Status
// 客户端发open表示当前是打开状态,可以关闭
// 客户端发close表示当前关闭状态,可以打开
// 打开门:openD01 openD02 openD03 值doit
// 关闭门:closeD01 closeD02 closeD03 值doit
private
Map
<
String
,
String
>
data
=
new
HashMap
<>();
@ApiModelProperty
(
"当前绑定的入库单名称"
)
...
...
src/main/java/com/neotel/smfcore/core/message/enums/MessageType.java
查看文件 @
884bfbb
...
...
@@ -21,4 +21,13 @@ public enum MessageType {
* 3 设备操作数据
*/
DATA
,
/**
* 4 显示数据,仅显示不保存
*/
SHOW
,
/**
* 5 需要人员立即操作的
*/
CRITICAL
}
src/main/java/com/neotel/smfcore/core/system/util/DevicesStatusUtil.java
查看文件 @
884bfbb
...
...
@@ -3,6 +3,8 @@ package com.neotel.smfcore.core.system.util;
import
cn.hutool.core.util.ObjectUtil
;
import
com.google.common.collect.Maps
;
import
com.neotel.smfcore.common.utils.SecurityUtils
;
import
com.neotel.smfcore.common.utils.StringUtils
;
import
com.neotel.smfcore.core.device.bean.MsgInfo
;
import
com.neotel.smfcore.core.device.bean.StatusBean
;
import
com.neotel.smfcore.core.message.enums.MessageType
;
import
com.neotel.smfcore.core.message.util.DeviceMessageUtil
;
...
...
@@ -44,6 +46,7 @@ public class DevicesStatusUtil {
statusBean
.
setMsgCode
(
msgBean
.
getMsgCode
());
statusBean
.
setMsgParam
(
msgBean
.
getMsgParam
());
statusBean
.
setMsgJp
(
msgBean
.
getMsgJp
());
statusBean
.
setMsgList
(
msgBean
.
getMsgList
());
}
}
return
statusBean
;
...
...
@@ -56,74 +59,150 @@ public class DevicesStatusUtil {
statusMap
.
put
(
statusBean
.
getCid
(),
statusBean
);
}
// /**
// * 更新客户端发上来的消息(设备故障等消息)
// */
// public static StatusBean updateClientMsg(String cid,String msgCode, String clientMsg, String clientMsgEn,String clientMsgJp,String[] msgParam) {
// if (clientMsg == null) {
// clientMsg = "";
// clientMsgEn = "";
// clientMsgJp="";
// }
// if(msgCode==null){
// msgCode="";
// }
// if(clientMsg==null){
// clientMsg="";
// }
// //判断消息是否有内容
// if(ObjectUtil.isNotEmpty(msgCode)||ObjectUtil.isNotEmpty(clientMsg)){
// boolean newMsg=true;
// //和上个消息是否一样
// StatusBean msgBean=clientMsgs.get(cid);
// if(msgBean!=null) {
//// if (msgBean.msgTimeOut()) {
//// newMsg = true;
//// } else
// if (msgBean.getMsgCode().equals(msgCode) && msgBean.getMsg().equals(clientMsg)) {
// newMsg = false;
// }
// }
// if(newMsg){
//
// //判断是否有换行
// String[] msgArray=clientMsg.split("\r\n");
// if(msgArray!=null&& msgArray.length>0) {
// for (String msg :
// msgArray) {
// String msgType = MessageType.ERROR.name();
// if (msg.startsWith("A=")) {
// msgType = MessageType.ERROR.name();
// msg = msg.substring(2);
// } else if (msg.startsWith("I=")) {
// msgType = MessageType.INFO.name();
// msg = msg.substring(2);
// } else if (msg.startsWith("W=")) {
// msgType = MessageType.WARNING.name();
// msg = msg.substring(2);
// }
// DeviceMessageUtil.addDeviceMessage(cid, msgType, "", msgCode, msg, msgParam);
// }
// }
// else {
// DeviceMessageUtil.addDeviceMessage(cid, MessageType.ERROR.name(), "", msgCode, clientMsg, msgParam);
// }
// }
// }
//
// StatusBean statusBean = new StatusBean();
// statusBean.setCid(cid);
// statusBean.setTime(System.currentTimeMillis());
// statusBean.setMsg(clientMsg);
// statusBean.setMsgEn(clientMsgEn);
// statusBean.setMsgCode(msgCode);
// statusBean.setMsgParam(msgParam);
// statusBean.setMsgJp(clientMsgJp);
// clientMsgs.put(cid, statusBean);
// return statusBean;
// }
//缓存信息
private
static
Map
<
String
,
List
<
MsgInfo
>>
cacheMsgMap
=
Maps
.
newConcurrentMap
();
/**
* 更新客户端发上来的消息(设备故障等消息)
*/
public
static
StatusBean
updateClientMsg
(
String
cid
,
String
msgCode
,
String
clientMsg
,
String
clientMsgEn
,
String
clientMsgJp
,
String
[]
msgParam
)
{
if
(
clientMsg
==
null
)
{
clientMsg
=
""
;
clientMsgEn
=
""
;
clientMsgJp
=
""
;
}
if
(
msgCode
==
null
){
msgCode
=
""
;
}
if
(
clientMsg
==
null
){
clientMsg
=
""
;
}
public
static
StatusBean
updateClientMsg
(
String
cid
,
List
<
MsgInfo
>
msgs
)
{
//判断消息是否有内容
if
(
ObjectUtil
.
isNotEmpty
(
msgCode
)||
ObjectUtil
.
isNotEmpty
(
clientMsg
)){
boolean
newMsg
=
true
;
//和上个消息是否一样
StatusBean
msgBean
=
clientMsgs
.
get
(
cid
);
if
(
msgBean
!=
null
)
{
// if (msgBean.msgTimeOut()) {
// newMsg = true;
// } else
if
(
msgBean
.
getMsgCode
().
equals
(
msgCode
)
&&
msgBean
.
getMsg
().
equals
(
clientMsg
))
{
newMsg
=
false
;
if
(
msgs
!=
null
&&
msgs
.
size
()
>
0
)
{
StatusBean
msgBean
=
clientMsgs
.
get
(
cid
);
List
<
MsgInfo
>
oldMsgs
=
msgBean
.
getMsgList
();
for
(
MsgInfo
msg
:
msgs
)
{
boolean
newMsg
=
true
;
if
(
oldMsgs
!=
null
)
{
for
(
MsgInfo
old
:
oldMsgs
)
{
if
(
ObjectUtil
.
isNotEmpty
(
old
.
getMsgKey
())&&
ObjectUtil
.
isNotEmpty
(
msg
.
getMsgKey
())&&
old
.
getMsgKey
().
equals
(
msg
.
getMsgKey
())
&&
old
.
getMsg
().
equals
(
msg
.
getMsg
()))
{
newMsg
=
false
;
break
;
}
}
}
if
(
newMsg
)
{
//判断是否有换行
String
[]
msgArray
=
clientMsg
.
split
(
"\r\n"
);
if
(
msgArray
!=
null
&&
msgArray
.
length
>
0
)
{
for
(
String
msg
:
msgArray
)
{
String
msgType
=
MessageType
.
ERROR
.
name
();
if
(
msg
.
startsWith
(
"A="
))
{
msgType
=
MessageType
.
ERROR
.
name
();
msg
=
msg
.
substring
(
2
);
}
else
if
(
msg
.
startsWith
(
"I="
))
{
msgType
=
MessageType
.
INFO
.
name
();
msg
=
msg
.
substring
(
2
);
}
else
if
(
msg
.
startsWith
(
"W="
))
{
msgType
=
MessageType
.
WARNING
.
name
(
);
msg
=
msg
.
substring
(
2
);
}
if
(
newMsg
)
{
List
<
MsgInfo
>
cacheMsgList
=
cacheMsgMap
.
get
(
cid
);
if
(
cacheMsgList
==
null
||
cacheMsgList
.
isEmpty
())
{
cacheMsgList
=
new
ArrayList
<>(
);
}
List
<
MsgInfo
>
newCacheList
=
new
ArrayList
<>();
for
(
MsgInfo
msgInfo
:
cacheMsgList
)
{
if
(
System
.
currentTimeMillis
()
-
msgInfo
.
getLastReceiveTime
()
>
1000
*
60
*
5
)
{
continue
;
}
String
msgKey
=
msg
.
getMsgKey
(
);
String
msgStr
=
msg
.
getMsg
();
if
(
StringUtils
.
isNotEmpty
(
msgKey
))
{
if
(
msgKey
.
equals
(
msgInfo
.
getMsgKey
()))
{
newMsg
=
false
;
msgInfo
.
setLastReceiveTime
(
System
.
currentTimeMillis
()
);
}
}
DeviceMessageUtil
.
addDeviceMessage
(
cid
,
msgType
,
""
,
msgCode
,
msg
,
msgParam
);
if
(
StringUtils
.
isNotEmpty
(
msgStr
))
{
if
(
msgStr
.
equals
(
msgInfo
.
getMsg
()))
{
newMsg
=
false
;
msgInfo
.
setLastReceiveTime
(
System
.
currentTimeMillis
());
}
}
newCacheList
.
add
(
msgInfo
);
}
if
(
newMsg
){
newCacheList
.
add
(
msg
);
}
cacheMsgMap
.
put
(
cid
,
newCacheList
);
}
else
{
DeviceMessageUtil
.
addDeviceMessage
(
cid
,
MessageType
.
ERROR
.
name
(),
""
,
msgCode
,
clientMsg
,
msgParam
);
if
(
newMsg
)
{
String
msgType
=
msg
.
getType
();
if
(
ObjectUtil
.
isEmpty
(
msgType
)){
msgType
=
MessageType
.
ERROR
.
name
();
}
DeviceMessageUtil
.
addDeviceMessage
(
cid
,
msgType
,
msg
.
getMoudle
(),
msg
.
getMsgKey
(),
msg
.
getMsg
(),
msg
.
getMsgParam
()
);
}
}
}
StatusBean
statusBean
=
new
StatusBean
();
statusBean
.
setCid
(
cid
);
statusBean
.
setTime
(
System
.
currentTimeMillis
());
statusBean
.
setMsg
(
clientMsg
);
statusBean
.
setMsgEn
(
clientMsgEn
);
statusBean
.
setMsgCode
(
msgCode
);
statusBean
.
setMsgParam
(
msgParam
);
statusBean
.
setMsgJp
(
clientMsgJp
);
statusBean
.
setOfflineTime
(-
1
);
statusBean
.
setMsgList
(
msgs
);
clientMsgs
.
put
(
cid
,
statusBean
);
return
statusBean
;
}
/**
* 主要用来存储感应料架库位报警信息
*/
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论