Commit ad213aa4 sunke

条码异常中英文提示

1 个父辈 26a758a3
...@@ -246,7 +246,7 @@ public class StatusBean { ...@@ -246,7 +246,7 @@ public class StatusBean {
* 是否需要往数据库保存(5分钟保存一次) * 是否需要往数据库保存(5分钟保存一次)
*/ */
public boolean needSaveToMongo(){ public boolean needSaveToMongo(){
return System.currentTimeMillis() - lastSaveTime >= 1 * 1000; return System.currentTimeMillis() - lastSaveTime >= 10 * 60 * 1000;
} }
public long getLastSaveTime() { public long getLastSaveTime() {
......
...@@ -48,6 +48,8 @@ public interface ITaskService { ...@@ -48,6 +48,8 @@ public interface ITaskService {
*/ */
List<DataLog> getWaitingTasks(); List<DataLog> getWaitingTasks();
Exception getServerException(String cid);
StatusBean getStatus(String cid); StatusBean getStatus(String cid);
Map<String, StatusBean> allStatus(); Map<String, StatusBean> allStatus();
......
...@@ -7,6 +7,7 @@ import com.myproject.bean.update.Humiture; ...@@ -7,6 +7,7 @@ import com.myproject.bean.update.Humiture;
import com.myproject.bean.update.Settings; import com.myproject.bean.update.Settings;
import com.myproject.bean.utils.BoxStatusBean; import com.myproject.bean.utils.BoxStatusBean;
import com.myproject.bean.utils.StatusBean; import com.myproject.bean.utils.StatusBean;
import com.myproject.exception.ValidateException;
import com.myproject.manager.IHumitureManager; import com.myproject.manager.IHumitureManager;
import com.myproject.webapp.controller.storage.BaseController; import com.myproject.webapp.controller.storage.BaseController;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
...@@ -51,6 +52,17 @@ public class StatusController extends BaseController{ ...@@ -51,6 +52,17 @@ public class StatusController extends BaseController{
// } // }
//log.debug("Get cid: " + cid + " status: " + statusBean.getStatus() + " and error: " + statusBean.getError()); //log.debug("Get cid: " + cid + " status: " + statusBean.getStatus() + " and error: " + statusBean.getError());
Exception e = taskService.getServerException(cid);
if(e != null){
if(e instanceof ValidateException){
String msg = getText(e.getMessage(),((ValidateException) e).getParams(), request.getLocale(),e.getMessage());
statusBean.setMsg(msg);
statusBean.setMsgEn(msg);
}else{
statusBean.setMsg(e.getMessage());
statusBean.setMsgEn(e.getMessage());
}
}
return statusBean; return statusBean;
} }
......
...@@ -99,7 +99,7 @@ public class TaskService implements ITaskService { ...@@ -99,7 +99,7 @@ public class TaskService implements ITaskService {
/** /**
* CID的服务器消息(key 为 cid) * CID的服务器消息(key 为 cid)
*/ */
private static Map<String, String> serverMsgs = new ConcurrentHashMap<>(); private static Map<String, Exception> serverExceptions = new ConcurrentHashMap<>();
/** /**
...@@ -248,16 +248,16 @@ public class TaskService implements ITaskService { ...@@ -248,16 +248,16 @@ public class TaskService implements ITaskService {
log.info(barcode+"["+plateW+"x"+plateH + "]开始入库到"+storage.getCid()+"["+posId+"]"); log.info(barcode+"["+plateW+"x"+plateH + "]开始入库到"+storage.getCid()+"["+posId+"]");
//清空展示的消息 //清空展示的消息
serverMsgs.put(storage.getCid(),""); serverExceptions.remove(storage.getCid());
} catch (ValidateException e) { } catch (ValidateException e) {
log.warn("入库到"+storage.getCid() + "失败:"+e.getMessage()); log.warn("入库到"+storage.getCid() + "失败:"+e.getMessage());
statusBean.setMsg(e.getMessage()); statusBean.setMsg(e.getMessage());
serverMsgs.put(storage.getCid(),e.getMessage()); serverExceptions.put(storage.getCid(),e);
} catch (Exception e) { } catch (Exception e) {
log.error(statusBean.getCode() + "入库到"+storage.getCid() + "失败", e); log.error(statusBean.getCode() + "入库到"+storage.getCid() + "失败", e);
statusBean.setMsg(e.getMessage()); statusBean.setMsg(e.getMessage());
serverMsgs.put(storage.getCid(),e.getMessage()); serverExceptions.put(storage.getCid(),e);
} }
return statusBean; return statusBean;
} }
...@@ -1176,6 +1176,12 @@ public class TaskService implements ITaskService { ...@@ -1176,6 +1176,12 @@ public class TaskService implements ITaskService {
} }
@Override @Override
public Exception getServerException(String cid){
return serverExceptions.get(cid);
}
@Override
public StatusBean getStatus(String cid) { public StatusBean getStatus(String cid) {
StatusBean statusBean = statusMap.get(cid); StatusBean statusBean = statusMap.get(cid);
if (statusBean == null || statusBean.timeOut()) { if (statusBean == null || statusBean.timeOut()) {
...@@ -1183,10 +1189,6 @@ public class TaskService implements ITaskService { ...@@ -1183,10 +1189,6 @@ public class TaskService implements ITaskService {
statusBean.setCid(cid); statusBean.setCid(cid);
statusBean.setStatus(StorageConstants.STATUS.OFFLINE); statusBean.setStatus(StorageConstants.STATUS.OFFLINE);
} }
String serverMsg = serverMsgs.get(cid);
if(!Strings.isNullOrEmpty(serverMsg)){
statusBean.setMsg(serverMsg);
}
return statusBean; return statusBean;
} }
......
...@@ -101,6 +101,13 @@ ...@@ -101,6 +101,13 @@
text-decoration:line-through; text-decoration:line-through;
} }
.red{
color:red;
}
.green{
color:green;
}
</style> </style>
<link href="${ctx}/scripts/lobibox/css/lobibox.min.css?id=2" rel="stylesheet" type="text/css"/> <link href="${ctx}/scripts/lobibox/css/lobibox.min.css?id=2" rel="stylesheet" type="text/css"/>
...@@ -111,19 +118,6 @@ ...@@ -111,19 +118,6 @@
<i class="fa fa-sign-out"></i><fmt:message key="button.checkout"/></button> <i class="fa fa-sign-out"></i><fmt:message key="button.checkout"/></button>
</div> </div>
<div id="chart"> <div id="chart">
<div class='itembox' id="7x8">
<div class='item-start barheight'>7 x 8 mm</div>
<div class='progress my-progress'>
<div class='progress-bar progress-bar-used barheight' style='width: 0%' title=""></div>
<div class='progress-bar progress-bar-idle barheight' style='width: 0%' title=""></div>
</div>
</div>
<div class='itembox' id="7x16"><div class='item-start barheight'>7 x 16 mm</div>
<div class='progress my-progress'>
<div class='progress-bar progress-bar-used barheight' style='width: 0%'></div>
<div class='progress-bar progress-bar-idle barheight' style='width: 0%'></div>
</div>
</div>
</div> </div>
...@@ -536,17 +530,21 @@ ...@@ -536,17 +530,21 @@
function flushStatus(){ function flushStatus(){
$.get('${ctx}/service/store/status?cid=${show}', function (statusBean) { $.get('${ctx}/service/store/status?cid=${show}', function (statusBean) {
if(statusBean && statusBean.boxStatus["1"]){ if(statusBean && statusBean.boxStatus["1"]){
var statusTxt = statusMsg[statusBean.boxStatus["1"].status]; var boxStatusBean = statusBean.boxStatus["1"];
var statusTxt = statusMsg[boxStatusBean.status];
$("#smdstatus").html("${boxStatus_label}: ["+statusTxt+"]"); $("#smdstatus").html("${boxStatus_label}: ["+statusTxt+"]");
var locale = "${locale}"; var color = "green";
var msg = statusBean.msg; if(boxStatusBean.status == 2 || boxStatusBean.status == 3 || boxStatusBean.status == 4 || boxStatusBean.status == 5){
if(locale == 'en'){ color = "red";
msg = statusBean.msgEn;
} }
$("#clientMsg").html(msg); $("#smdstatus").attr("class","smdstatus " + color);
$("#clientMsg").html(statusBean.msg);
}else{ }else{
var statusTxt = statusMsg["999"]; var statusTxt = statusMsg["999"];
$("#smdstatus").html("${boxStatus_label}: ["+statusTxt+"]"); $("#smdstatus").html("${boxStatus_label}: ["+statusTxt+"]");
$("#smdstatus").attr("class","smdstatus red");
$("#clientMsg").html(""); $("#clientMsg").html("");
} }
}); });
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!