Commit 4d419695 LN

设备定时通信消息结构更改,消息改为集合

1 个父辈 eba8d243
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="";
}
......@@ -79,6 +79,9 @@ public class StatusBean {
public String msgJp="";
/**
* 翻译key
*/
public String msgCode="";
public String[] msgParam ;
......@@ -112,6 +115,10 @@ public class StatusBean {
*/
public String language="";
/**
* 消息集合
*/
public List<MsgInfo> msgList;
/**
* 料仓类型
*/
private String deviceType = DeviceType.AUTO.name();
......@@ -536,92 +543,196 @@ public class StatusBean {
}
return doorReelSignal;
}
//
// public String getShowMsg(Locale locale) {
// if(ObjectUtil.isEmpty(this.msg)){
// return "";
// }
// //从收到数据中查找
// String lan = locale.toLanguageTag();
// if (lan.equals(MessageUtils.JA_JP) && ObjectUtil.isNotEmpty(getMsgJp())) {
// String resultMsg= getMsgJp().replace("A=","").replace("I=","").replace("W=","");
// return resultMsg;
// } else if (lan.equals(MessageUtils.EN_US) && ObjectUtil.isNotEmpty(getMsgEn())) {
// String resultMsg= getMsgEn().replace("A=","").replace("I=","").replace("W=","");
// return resultMsg;
// }
// //提示信息国际化
// if (ObjectUtil.isEmpty(getMsgCode())) {
// return this.msg.replace("A=","").replace("I=","").replace("W=","");
// } else {
// String code = this.msgCode;
// if (!code.startsWith(MessageUtils.smfcore)) {
// code = MessageUtils.smfcore + "." + this.msgCode;
// }
// String newMsg=this.msg.replace("A=","").replace("I=","").replace("W=","");
// newMsg = MessageUtils.getText(code, getMsgParam(), locale, newMsg);
// return newMsg;
// }
// }
//
// public String getErrorMsg(Locale locale) {
// if(ObjectUtil.isEmpty(this.msg)){
// return "";
// }
//
// //判断是否有换行
// String[] msgArray=this.msg.split("\r\n");
// if(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(msgType.equals(MessageType.ERROR.name())){
// return msg;
// }
// }
// }
// return "";
// }
//
// public Map<String,String> getMsgMap() {
// Map<String,String> resultMap=new HashMap<>();
// if(ObjectUtil.isEmpty(this.msg)){
// return resultMap;
// }
//
// //判断是否有换行
// String[] msgArray=this.msg.split("\r\n");
// if(msgArray.length>0) {
// for (String msg :
// msgArray) {
// if(ObjectUtil.isEmpty(msg)){
// continue;
// }
// 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);
// }
// resultMap.put(msg,msgType);
// }
// }
// return resultMap;
// }
public String getShowMsg(Locale locale) {
if(ObjectUtil.isEmpty(this.msg)){
return "";
}
private String GetMsgStr(MsgInfo msg,Locale locale){
String mMsg = "";
//从收到数据中查找
String lan = locale.toLanguageTag();
if (lan.equals(MessageUtils.JA_JP) && ObjectUtil.isNotEmpty(getMsgJp())) {
String resultMsg= getMsgJp().replace("A=","").replace("I=","").replace("W=","");
return resultMsg;
} else if (lan.equals(MessageUtils.EN_US) && ObjectUtil.isNotEmpty(getMsgEn())) {
String resultMsg= getMsgEn().replace("A=","").replace("I=","").replace("W=","");
return resultMsg;
if (lan.equals(MessageUtils.JA_JP) && ObjectUtil.isNotEmpty(msg.getMsgJp())) {
mMsg = msg.getMsgJp();
} else if (lan.equals(MessageUtils.EN_US) && ObjectUtil.isNotEmpty(msg.getMsgEn())) {
mMsg = msg.getMsgEn();
}
//提示信息国际化
if (ObjectUtil.isEmpty(getMsgCode())) {
return this.msg.replace("A=","").replace("I=","").replace("W=","");
else if (ObjectUtil.isEmpty(msg.getMsgKey())) {
mMsg = msg.getMsg();
} else {
String code = this.msgCode;
String code = msg.getMsgKey();
if (!code.startsWith(MessageUtils.smfcore)) {
code = MessageUtils.smfcore + "." + this.msgCode;
code = MessageUtils.smfcore + "." + msg.getMsgKey();
}
String newMsg=this.msg.replace("A=","").replace("I=","").replace("W=","");
newMsg = MessageUtils.getText(code, getMsgParam(), locale, newMsg);
return newMsg;
String newMsg = msg.getMsg().replace("A=", "").replace("I=", "").replace("W=", "");
mMsg = MessageUtils.getText(code, msg.getMsgParam(), locale, newMsg);
}
return mMsg;
}
public String getShowMsg(Locale locale) {
if (ObjectUtil.isEmpty(this.msgList)) {
return "";
}
String returnMsg = "";
for (MsgInfo msg :
msgList) {
String mMsg = GetMsgStr(msg,locale);
if (ObjectUtil.isEmpty(returnMsg)) {
returnMsg = mMsg;
} else {
returnMsg += "\r\n" + mMsg;
}
}
return returnMsg;
}
public String getErrorMsg(Locale locale) {
if(ObjectUtil.isEmpty(this.msg)){
if (ObjectUtil.isEmpty(this.msgList)) {
return "";
}
for (MsgInfo msg :
msgList) {
//判断是否有换行
String[] msgArray=this.msg.split("\r\n");
if(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(msgType.equals(MessageType.ERROR.name())){
return msg;
}
if (msg.getType().toUpperCase().equals(MessageType.ERROR.name())) {
return msg.getMsg();
}
}
return "";
}
public Map<String,String> getMsgMap() {
Map<String,String> resultMap=new HashMap<>();
if(ObjectUtil.isEmpty(this.msg)){
public Map<String,String> getMsgMap(Locale locale) {
Map<String, String> resultMap = new HashMap<>();
if (ObjectUtil.isEmpty(msgList)) {
return resultMap;
}
//判断是否有换行
String[] msgArray=this.msg.split("\r\n");
if(msgArray.length>0) {
for (String msg :
msgArray) {
if(ObjectUtil.isEmpty(msg)){
continue;
}
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);
for (MsgInfo msg : msgList) {
resultMap.put(GetMsgStr(msg,locale) , msg.getType());
}
return resultMap;
}
public void MsgDataProcess() {
//消息格式处理
if( getMsgList()==null&& ObjectUtil.isNotEmpty(msg)){
msgList=new ArrayList<>();
//判断是否有换行
String[] msgArray=this.msg.split("\r\n");
if(msgArray.length>0) {
for (String msg :
msgArray) {
if (ObjectUtil.isEmpty(msg)) {
continue;
}
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 (msgArray.length == 1) {
msgList.add(new MsgInfo(msg, msgType,msgEn,msgJp,msgCode,msgParam,"",""));
} else {
msgList.add(new MsgInfo(msg, msgType));
}
}
resultMap.put(msg,msgType);
}
}
return resultMap;
}
public void setRMsg(String msgKey, String[] msgParam, String message) {
......
......@@ -843,25 +843,39 @@ public class BaseDeviceHandler implements IDeviceHandler {
protected void handleMsg(StatusBean statusBean) {
try {
//转换为新格式
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(statusBean.msgList)&& statusBean.msgList.size()>0) {
DevicesStatusUtil.updateClientMsg(statusBean.getCid(), statusBean.msgList);
}
// //判断是否刚刚上线
// StatusBean bean = DevicesStatusUtil.getStatusBean(statusBean.getCid());
// if (bean == null || bean.getBoxStatus() == null) {
// DeviceMessageUtil.addOnlineMessage(statusBean.getCid(), "",statusBean.getClientIp());
// DevicesStatusUtil.updateClientMsg(statusBean.getCid(), "", "", "","", null);
// } else if (bean.timeOut() && (bean.getOfflineTime() > -1)) {
// DeviceMessageUtil.addOnlineMessage(statusBean.getCid(), "",statusBean.getClientIp());
// DevicesStatusUtil.updateClientMsg(statusBean.getCid(), "", "", "","", null);
// }
//
// //展示到界面
// 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);
}
......
......@@ -63,13 +63,23 @@ public class MessageUtils {
private static Map<String,Map<String, LanguageMsg>> msgMap = new HashMap<>();
private static ILanguageMsgManager languageMsgManager;
private static DataCache dataCache;
private static LanguageMsgService messageService;
@Autowired
ILanguageMsgManager languageMsgManager;
@Autowired
DataCache dataCache;
void setLanguageMsgManager(ILanguageMsgManager languageMsgManager) {
MessageUtils.languageMsgManager = languageMsgManager;
}
@Autowired
LanguageMsgService messageService;
void SetDataCache(DataCache dataCache) {
MessageUtils.dataCache = dataCache;
}
@Autowired
void SetMessageService(LanguageMsgService messageService) {
MessageUtils.messageService = messageService;
}
public static final String ZH_CN = "zh-CN";
public static final String ZH_TW = "zh-TW";
......@@ -157,6 +167,7 @@ public class MessageUtils {
return msg.getMsg();
}
log.info("获取资源[" + msgKey + "][" + defaultMsg + "][" + lanType + "]失败:未找到code[" + msgKey + "]");
// autoAddMsg(msgKey,defaultMsg,"");
}
return defaultMsg;
}
......@@ -224,6 +235,23 @@ public class MessageUtils {
return lanList;
}
private static void autoAddMsg(String msgKey, String defaultMsg,String type ) {
try {
if (ObjectUtil.isEmpty(type)) {
type = smfcore;
}
LanguageMsg languageMsg = new LanguageMsg(msgKey, defaultMsg, type);
List<LanguageInfo> list=dataCache.getLanguageList();
for (LanguageInfo lan:list
) {
languageMsg.setContent(lan.getLanCode(),defaultMsg);
}
languageMsg = languageMsgManager.save(languageMsg);
updateMsg(languageMsg);
log.info("autoAddMsg: key=" + msgKey + ",msg=" + defaultMsg + ",type=" + type + ",defLocal=" + getDefaultLocal().toLanguageTag() + "");
} catch (Exception ex) {
log.error("autoAddMsg: key=" + msgKey + ",msg=" + defaultMsg + ",type=" + type + ",defLocal=" + getDefaultLocal().toLanguageTag() + "出错:" + ex.toString());
}
}
}
......@@ -22,13 +22,20 @@ import java.util.Locale;
@AllArgsConstructor
public class Message extends BasePo implements Serializable {
public static Message newMsg(MessageType type,String deviceName,String deviceId,String module,String msgCode,String msg,String[] msgParams){
Message message=new Message(deviceName,deviceId,module, type.name(),msgCode,msg,msgParams,null,null,"");
Message message=new Message(deviceName,deviceId,module, type.name(),msgCode,msg,msgParams,null,null,"",msgCode,"");
return message;
}
public static Message newMsg(String type,String deviceName,String deviceId,String module,String msgCode,String msg,String[] msgParams){
Message message=new Message(deviceName,deviceId,module, type,msgCode,msg,msgParams,null,null,"");
Message message=new Message(deviceName,deviceId,module, type,msgCode,msg,msgParams,null,null,"",msgCode,"");
return message;
}
public static Message newMsg(MessageType type,String deviceName,String deviceId,String module,String msgCode,String msg,String[] msgParams,String alarmType,String alarmCode){
Message message=new Message(deviceName,deviceId,module, type.name(),msgCode,msg,msgParams,null,null,"",alarmType,alarmCode);
return message;
}
public static Message newMsg(String type,String deviceName,String deviceId,String module,String msgCode,String msg,String[] msgParams,String alarmType,String alarmCode){
Message message=new Message(deviceName,deviceId,module, type,msgCode,msg,msgParams,null,null,"",alarmType,alarmCode);
return message;
}
/**
......@@ -75,6 +82,14 @@ public class Message extends BasePo implements Serializable {
*/
private String operator;
/**
* 报警类型
*/
public String alarmType="";
/**
*报警错误码
*/
public String alarmCode="";
public void addData(String key,String value){
if(dataList==null){
dataList=new ArrayList<>();
......
......@@ -96,6 +96,20 @@ public class DeviceMessageUtil {
messageManager.save(message);
}
}
public static void addDeviceMessage(String cid,String msgType, String moudle, String msgCode, String msg, String[] msgParam,String almType,String almCode) {
DeviceInfo deviceInfo=getDeviceName(cid);
if (deviceInfo!=null) {
String code=msgCode;
if(ObjectUtil.isNotEmpty(msgCode)){
if(!msgCode.startsWith(MessageUtils.smfcore)){
code=MessageUtils.smfcore+"."+msgCode;
}
}
Message message=Message.newMsg(msgType ,deviceInfo.getName(), deviceInfo.getId(), moudle, code,msg,msgParam,almType,almCode);
messageManager.save(message);
}
}
public static void addOnlineMessage(String cid, String moudle,String ip) {
DeviceInfo deviceInfo=getDeviceName(cid);
......
......@@ -3,6 +3,7 @@ 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.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 +45,7 @@ public class DevicesStatusUtil {
statusBean.setMsgCode(msgBean.getMsgCode());
statusBean.setMsgParam(msgBean.getMsgParam());
statusBean.setMsgJp(msgBean.getMsgJp());
statusBean.setMsgList(msgBean.getMsgList());
}
}
return statusBean;
......@@ -55,75 +57,111 @@ public class DevicesStatusUtil {
public static void updateStatusBean(StatusBean 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;
// }
/**
* 更新客户端发上来的消息(设备故障等消息)
*/
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(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 (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 (old.getMsgKey().equals(msg.getMsgKey()) && old.getMsg().equals(msg.getMsg())) {
newMsg = false;
break;
}
DeviceMessageUtil.addDeviceMessage(cid, msgType, "", msgCode, msg, msgParam);
}
}
else {
DeviceMessageUtil.addDeviceMessage(cid, MessageType.ERROR.name(), "", msgCode, clientMsg, msgParam);
if (newMsg) {
DeviceMessageUtil.addDeviceMessage(cid, MessageType.ERROR.name(), "", msg.getMsgKey(), msg.getMsg(), msg.getMsgParam(),msg.getAlarmType(),msg.getAlarmCode());
}
}
}
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.setMsgList(msgs);
clientMsgs.put(cid, statusBean);
return statusBean;
}
/**
* 主要用来存储感应料架库位报警信息
*/
......
......@@ -8,6 +8,7 @@ import com.neotel.smfcore.core.device.bean.BoxStatusBean;
import com.neotel.smfcore.core.device.bean.StatusBean;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.language.util.MessageUtils;
import com.neotel.smfcore.core.message.enums.MessageType;
import com.neotel.smfcore.core.report.bean.ChartItem;
import com.neotel.smfcore.core.storage.bean.UsageItem;
......@@ -109,10 +110,18 @@ public class MicronStatusController {
}
//料仓状态
List<String> boxList = new ArrayList<>();
for (int i = 1; i <= 8; i++
) {
boxList.add("M" + i);
}
// for (int i = 1; i <= 8; i++
// ) {
// boxList.add("M" + i);
// }
boxList.add("KTS-R001A");
boxList.add("KTS-R001B");
boxList.add("KTS-R001C");
boxList.add("KTS-R001D");
boxList.add("KTS-R002A");
boxList.add("KTS-R002B");
boxList.add("KTS-R002C");
boxList.add("KTS-R002D");
// SBDH1, SBDH2, SBDH3, SBSH1, SBSH2
boxList.add("SBDH1-1");
boxList.add("SBDH1-2");
......@@ -156,7 +165,6 @@ public class MicronStatusController {
dto.getMsgList().add(dtoMsg);
// }
}
return dto;
}
......@@ -165,9 +173,9 @@ public class MicronStatusController {
Map<String, Storage> allStorages = dataCache.getAllStorage();
for (Storage storage :
allStorages.values()) {
if (storage.getCid().contains(boxName)) {
if (storage.getCid().contains(boxName.trim())) {
cids.add(storage.getCid());
}else if(storage.getName().equals(boxName)){
}else if(storage.getName().trim().equals(boxName.trim())){
cids.add(storage.getCid());
}
}
......@@ -210,15 +218,20 @@ public class MicronStatusController {
dto.setStatus(0);
}
//如果状态还是0,需要改为1
else if(dto.getStatus()==0) {
else if(dto.getStatus()==0) {
dto.setStatus(1);
}
Map<String,String> msgMap=s.getMsgMap();
Map<String,String> msgMap=s.getMsgMap(locale);
if(msgMap!=null&&msgMap.size()>0) {
String name=cid;
Storage storage=dataCache.getStorage(cid);
if(storage!=null){
name=storage.getName();
}
for (String msg :
msgMap.keySet()) {
String type= msgMap.getOrDefault(msg, "");
dto.getMsgList().add(new EquipMsg(cid, s.getStatus(), msg, new Date(s.getTime()), type.toUpperCase(), "", "", new String[]{}));
dto.getMsgList().add(new EquipMsg(name, s.getStatus(), msg, new Date(s.getTime()), type.toUpperCase(), "", "", new String[]{}));
}
}
// String msg=s.getErrorMsg(locale);
......@@ -245,6 +258,7 @@ public class MicronStatusController {
for (String cid :
cids) {
Storage storage = dataCache.getStorage(cid);
String name=storage.getName();
for (UsageItem item : storage.getUsageMap().values()
) {
useCount += item.getUsedCount();
......@@ -259,14 +273,14 @@ public class MicronStatusController {
dto.setHumidity(humidity);
dto.setTemperature(temperature);
}
dto.getStatuMap().put(cid, boxStatus.getStatus());
dto.getMsgMap().put(cid, statusBean.getErrorMsg(servletRequest.getLocale()));
dto.getStatuMap().put(name, boxStatus.getStatus());
dto.getMsgMap().put(name, statusBean.getErrorMsg(servletRequest.getLocale()));
}
}else{
dto.getStatuMap().put(cid,0);
dto.getMsgMap().put(cid,"");
dto.getStatuMap().put(name,0);
dto.getMsgMap().put(name,"");
}
//出入库报表 默认过去一周到现在的
......@@ -313,10 +327,12 @@ public class MicronStatusController {
String[] nameList = new String[]{};
String robotName = "R1";
if (boxName.equals("MI1")) {
nameList = new String[]{"M3", "M4", "M7", "M8"};
// nameList = new String[]{"M3", "M4", "M7", "M8"};
nameList = new String[]{"KTS-R001A", "KTS-R001B", "KTS-R001C", "KTS-R001D"};
robotName = "R1";
} else if (boxName.equals("MI2")) {
nameList = new String[]{"M1", "M2", "M5", "M6"};
// nameList = new String[]{"M1", "M2", "M5", "M6"};
nameList = new String[]{ "KTS-R002A", "KTS-R002B","KTS-R002C", "KTS-R002D"};
robotName = "R2";
}
......@@ -430,7 +446,7 @@ public class MicronStatusController {
// if (ObjectUtil.isNotEmpty(msg)) {
// count += 1;
// }
Map<String, String> msgMap = statusBean.getMsgMap();
Map<String, String> msgMap = statusBean.getMsgMap(MessageUtils.getDefaultLocal());
if (msgMap != null && msgMap.size() > 0) {
for (String msg :
msgMap.keySet()) {
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!