Commit 884bfbb4 LN

msg转为MsgInfo

1 个父辈 4588d272
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<description>SMF project for Spring Boot</description> <description>SMF project for Spring Boot</description>
<properties> <properties>
<maven.build.timestamp.format>M.ddHHmm</maven.build.timestamp.format> <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> <app.version>${main.version}</app.version>
<java.version>1.8</java.version> <java.version>1.8</java.version>
<jjwt.version>0.11.1</jjwt.version> <jjwt.version>0.11.1</jjwt.version>
......
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();
}
...@@ -17,6 +17,7 @@ import com.neotel.smfcore.core.barcode.service.po.Barcode; ...@@ -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.service.po.Component;
import com.neotel.smfcore.core.barcode.utils.CodeResolve; import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.device.bean.BoxStatusBean; 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.BOX_STATUS;
import com.neotel.smfcore.core.device.enums.OP; import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.enums.OP_STATUS; import com.neotel.smfcore.core.device.enums.OP_STATUS;
...@@ -840,25 +841,30 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -840,25 +841,30 @@ public class BaseDeviceHandler implements IDeviceHandler {
protected void handleMsg(StatusBean statusBean) { protected void handleMsg(StatusBean statusBean) {
try { try {
//转换为新格式
List<MsgInfo> mergeMsgList = statusBean.MsgDataProcess();
//判断是否刚刚上线 //判断是否刚刚上线
StatusBean bean = DevicesStatusUtil.getStatusBean(statusBean.getCid()); StatusBean bean = DevicesStatusUtil.getStatusBean(statusBean.getCid());
if (bean == null || bean.getBoxStatus() == null) { if (bean == null || bean.getBoxStatus() == null) {
DeviceMessageUtil.addOnlineMessage(statusBean.getCid(), "",statusBean.getClientIp()); DeviceMessageUtil.addOnlineMessage(statusBean.getCid(), "",statusBean.getClientIp());
DevicesStatusUtil.updateClientMsg(statusBean.getCid(), "", "", "","", null); DevicesStatusUtil.updateClientMsg(statusBean.getCid(),new ArrayList<>());
} else if (bean.timeOut() && (bean.getOfflineTime() > -1)) { } else if (bean.timeOut() && (bean.getOfflineTime() > -1)) {
DeviceMessageUtil.addOnlineMessage(statusBean.getCid(), "",statusBean.getClientIp()); DeviceMessageUtil.addOnlineMessage(statusBean.getCid(), "",statusBean.getClientIp());
DevicesStatusUtil.updateClientMsg(statusBean.getCid(), "", "", "","", null); DevicesStatusUtil.updateClientMsg(statusBean.getCid(),new ArrayList<>());
} }
//展示到界面 if(ObjectUtil.isNotEmpty(mergeMsgList)&& mergeMsgList.size()>0) {
String msg = statusBean.getMsg(); DevicesStatusUtil.updateClientMsg(statusBean.getCid(), mergeMsgList);
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());
} }
// //展示到界面
// 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) { } catch (Exception e) {
log.error("客户端故障消息处理出错", e); log.error("客户端故障消息处理出错", e);
} }
...@@ -891,6 +897,7 @@ public class BaseDeviceHandler implements IDeviceHandler { ...@@ -891,6 +897,7 @@ public class BaseDeviceHandler implements IDeviceHandler {
statusBean.setOp(statusBeanToSave.getOp()); statusBean.setOp(statusBeanToSave.getOp());
statusBean.setSeq(statusBeanToSave.getSeq()); statusBean.setSeq(statusBeanToSave.getSeq());
statusBean.setClientIp(statusBeanToSave.getClientIp()); statusBean.setClientIp(statusBeanToSave.getClientIp());
statusBean.setMsgList(statusBeanToSave.getMsgList());
/** /**
* 已解除的报警信息存到数据库中 * 已解除的报警信息存到数据库中
......
...@@ -420,11 +420,12 @@ public class BoxKanbanController { ...@@ -420,11 +420,12 @@ public class BoxKanbanController {
} }
int allCount = inTask + outTask; int allCount = inTask + outTask;
BoxStatusDto boxDto = new BoxStatusDto(storage.getId(), storage.getName(), storage.getCid(), false, 0, 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()); 0, "", "", "", "", "",storage.getType(),storage.getUsageMap(),new HashMap<>(),storage.getInListName());
//获取设备状态,设置状态和当前任务信息 //获取设备状态,设置状态和当前任务信息
StatusBean bean = DevicesStatusUtil.getStatusBean(storage.getCid()); StatusBean bean = DevicesStatusUtil.getStatusBean(storage.getCid());
if (bean == null || bean.getBoxStatus() == null) { if (bean == null || bean.getBoxStatus() == null) {
boxDto.setOnLine(false); boxDto.setOnLine(false);
...@@ -460,7 +461,10 @@ public class BoxKanbanController { ...@@ -460,7 +461,10 @@ public class BoxKanbanController {
} }
boxDto.setCodeAirTemp(boxStatus.getCodeAirTemp()); boxDto.setCodeAirTemp(boxStatus.getCodeAirTemp());
boxDto.setStatus(bean.getStatus()); boxDto.setStatus(bean.getStatus());
boxDto.setMsg(bean.getShowMsg(locale));
boxDto.setMsg(bean.getErrorMsg(locale));
boxDto.setMsgInfo(bean.getInfoMsg(locale));
boxDto.setBarcode(bean.getCode()); boxDto.setBarcode(bean.getCode());
boxDto.setPosName(bean.getPosId()); boxDto.setPosName(bean.getPosId());
boxDto.setData(bean.getData()); boxDto.setData(bean.getData());
......
...@@ -37,9 +37,11 @@ public class BoxStatusDto { ...@@ -37,9 +37,11 @@ public class BoxStatusDto {
private String humidity; private String humidity;
@ApiModelProperty("冷气机温度") @ApiModelProperty("冷气机温度")
private String codeAirTemp; private String codeAirTemp;
@ApiModelProperty("文字显示") @ApiModelProperty("报警文字显示:红色")
private String msg = ""; private String msg = "";
@ApiModelProperty("信息文字显示:绿色")
private String msgInfo = "";
@ApiModelProperty("总任务数") @ApiModelProperty("总任务数")
private int taskCount=0; private int taskCount=0;
...@@ -77,6 +79,16 @@ public class BoxStatusDto { ...@@ -77,6 +79,16 @@ public class BoxStatusDto {
//取出出库料盘:takeOutReel //取出出库料盘:takeOutReel
//关闭仓门:confirmReelOut //关闭仓门:confirmReelOut
// 状态显示: disable:不可用,enable:可用,点击按钮后发送 doit // 状态显示: 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<>(); private Map<String, String> data = new HashMap<>();
@ApiModelProperty("当前绑定的入库单名称") @ApiModelProperty("当前绑定的入库单名称")
......
...@@ -21,4 +21,13 @@ public enum MessageType { ...@@ -21,4 +21,13 @@ public enum MessageType {
* 3 设备操作数据 * 3 设备操作数据
*/ */
DATA, DATA,
/**
* 4 显示数据,仅显示不保存
*/
SHOW,
/**
* 5 需要人员立即操作的
*/
CRITICAL
} }
...@@ -3,6 +3,8 @@ package com.neotel.smfcore.core.system.util; ...@@ -3,6 +3,8 @@ package com.neotel.smfcore.core.system.util;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.neotel.smfcore.common.utils.SecurityUtils; 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.device.bean.StatusBean;
import com.neotel.smfcore.core.message.enums.MessageType; import com.neotel.smfcore.core.message.enums.MessageType;
import com.neotel.smfcore.core.message.util.DeviceMessageUtil; import com.neotel.smfcore.core.message.util.DeviceMessageUtil;
...@@ -44,6 +46,7 @@ public class DevicesStatusUtil { ...@@ -44,6 +46,7 @@ public class DevicesStatusUtil {
statusBean.setMsgCode(msgBean.getMsgCode()); statusBean.setMsgCode(msgBean.getMsgCode());
statusBean.setMsgParam(msgBean.getMsgParam()); statusBean.setMsgParam(msgBean.getMsgParam());
statusBean.setMsgJp(msgBean.getMsgJp()); statusBean.setMsgJp(msgBean.getMsgJp());
statusBean.setMsgList(msgBean.getMsgList());
} }
} }
return statusBean; return statusBean;
...@@ -56,74 +59,150 @@ public class DevicesStatusUtil { ...@@ -56,74 +59,150 @@ public class DevicesStatusUtil {
statusMap.put(statusBean.getCid(), statusBean); 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) { public static StatusBean updateClientMsg(String cid, List<MsgInfo> msgs) {
if (clientMsg == null) {
clientMsg = ""; //判断消息是否有内容
clientMsgEn = ""; if (msgs != null && msgs.size() > 0) {
clientMsgJp="";
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(msgCode==null){
msgCode="";
} }
if(clientMsg==null){
clientMsg="";
} }
//判断消息是否有内容 if (newMsg) {
if(ObjectUtil.isNotEmpty(msgCode)||ObjectUtil.isNotEmpty(clientMsg)){ List<MsgInfo> cacheMsgList = cacheMsgMap.get(cid);
boolean newMsg=true; if (cacheMsgList == null || cacheMsgList.isEmpty()) {
//和上个消息是否一样 cacheMsgList = new ArrayList<>();
StatusBean msgBean=clientMsgs.get(cid); }
if(msgBean!=null) { List<MsgInfo> newCacheList = new ArrayList<>();
// if (msgBean.msgTimeOut()) { for (MsgInfo msgInfo : cacheMsgList) {
// newMsg = true; if (System.currentTimeMillis() - msgInfo.getLastReceiveTime() > 1000 * 60 * 5) {
// } else continue;
if (msgBean.getMsgCode().equals(msgCode) && msgBean.getMsg().equals(clientMsg)) { }
String msgKey = msg.getMsgKey();
String msgStr = msg.getMsg();
if (StringUtils.isNotEmpty(msgKey)) {
if (msgKey.equals(msgInfo.getMsgKey())) {
newMsg = false; newMsg = false;
msgInfo.setLastReceiveTime(System.currentTimeMillis());
} }
} }
if(newMsg){ if (StringUtils.isNotEmpty(msgStr)) {
if (msgStr.equals(msgInfo.getMsg())) {
//判断是否有换行 newMsg = false;
String[] msgArray=clientMsg.split("\r\n"); msgInfo.setLastReceiveTime(System.currentTimeMillis());
if(msgArray!=null&& msgArray.length>0) { }
for (String msg : }
msgArray) { newCacheList.add(msgInfo);
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); 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 statusBean = new StatusBean();
statusBean.setCid(cid); statusBean.setCid(cid);
statusBean.setTime(System.currentTimeMillis()); statusBean.setTime(System.currentTimeMillis());
statusBean.setMsg(clientMsg); statusBean.setOfflineTime(-1);
statusBean.setMsgEn(clientMsgEn); statusBean.setMsgList(msgs);
statusBean.setMsgCode(msgCode);
statusBean.setMsgParam(msgParam);
statusBean.setMsgJp(clientMsgJp);
clientMsgs.put(cid, statusBean); clientMsgs.put(cid, statusBean);
return statusBean; return statusBean;
} }
/** /**
* 主要用来存储感应料架库位报警信息 * 主要用来存储感应料架库位报警信息
*/ */
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!