Преглед на файлове

前端"客户端版本"页面,离线状态隐藏

17491 преди 2 дни
родител
ревизия
357892ec00

+ 4 - 1
src/main/java/com/jeesite/modules/mesclient/entity/MesClientRuntime.java

@@ -23,6 +23,7 @@ public class MesClientRuntime extends DataEntity<MesClientRuntime> {
     private String clientId, clientType, lineSn, stationCode, hostIp, status, statusMessage, desiredConfigJson;
     private Long jarVersion, configVersion, desiredJarVersion, desiredConfigVersion;
     private Date lastHeartbeat;
+    private boolean showOffline;
     // 关联 mes_line_process 带出,非数据库字段
     private String stationTitle;
     private Integer stationSorts;
@@ -145,4 +146,6 @@ public class MesClientRuntime extends DataEntity<MesClientRuntime> {
     public void setLastHeartbeat(Date v) {
         lastHeartbeat = v;
     }
-}
+    public boolean isShowOffline() { return showOffline; }
+    public void setShowOffline(boolean v) { showOffline = v; }
+}

+ 1 - 0
src/main/java/com/jeesite/modules/mesclient/web/MesClientRuntimeController.java

@@ -39,6 +39,7 @@ public class MesClientRuntimeController extends BaseController {
     @RequestMapping("listData")
     @ResponseBody
     public Page<MesClientRuntime> listData(MesClientRuntime x, HttpServletRequest req, HttpServletResponse resp) {
+        x.setShowOffline("true".equalsIgnoreCase(req.getParameter("showOffline")));
         x.setPage(new Page<>(req, resp));
         return service.findPage(x);
     }

+ 1 - 0
src/main/resources/mappings/modules/mesclient/MesClientRuntimeDao.xml

@@ -35,6 +35,7 @@
             <if test="stationCode != null and stationCode != ''">AND r.station_code = #{stationCode}</if>
             <if test="lineSn != null and lineSn != ''">AND r.line_sn = #{lineSn}</if>
             <if test="statusMessage != null and statusMessage != ''">AND r.status_message LIKE CONCAT('%', #{statusMessage}, '%')</if>
+            <if test="!showOffline">AND r.last_heartbeat IS NOT NULL AND r.last_heartbeat >= DATE_SUB(NOW(), INTERVAL 180 SECOND)</if>
         </where>
         ORDER BY
           CASE WHEN r.last_heartbeat >= DATE_SUB(NOW(), INTERVAL 60 SECOND) THEN 0 ELSE 1 END,

+ 9 - 0
src/main/resources/views/modules/mesclient/mesClientVersionList.html

@@ -22,6 +22,7 @@
 <div id="runtimePanel" class="tab-pane">
     <div style="margin-bottom:8px">
         <button type="button" class="btn btn-sm btn-primary" onclick="$('#runtimeGrid').trigger('reloadGrid')"><i class="fa fa-refresh"></i> 刷新</button>
+        <button type="button" class="btn btn-sm btn-default" id="btnShowOffline"><i class="fa fa-eye"></i> 显示离线</button>
         <span style="color:#888;margin-left:8px;font-size:12px">列表每次切到本页也会自动刷新</span>
     </div>
     <table id="runtimeGrid"></table><div id="runtimeGridPage"></div>
@@ -57,6 +58,7 @@ window.addEventListener('storage', function(e){
 });
 
 // —— 客户端监控 grid ——
+var showOffline = false;
 function pad2(n){return (n<10?'0':'')+n;}
 function heartbeatCell(v){
     if(!v) return '<span class="label label-default">未知</span>';
@@ -73,6 +75,7 @@ function heartbeatCell(v){
 
 $('#runtimeGrid').dataGrid({
     url: '${ctx}/mes/clientRuntime/listData',
+    postData: {showOffline: 'false'},
     // 与版本发布列表使用相同的分页配置,容器由 dataGrid 按表格 ID 自动匹配
     columnModel: [
         {header:'类型', name:'clientType', width:110, formatter:function(v){return clientTypeName(v);}},
@@ -86,6 +89,12 @@ $('#runtimeGrid').dataGrid({
     ]
 });
 
+$('#btnShowOffline').on('click', function(){
+    showOffline = !showOffline;
+    $(this).html(showOffline ? '<i class="fa fa-eye-slash"></i> 隐藏离线' : '<i class="fa fa-eye"></i> 显示离线');
+    $('#runtimeGrid').jqGrid('setGridParam', {postData: {showOffline: String(showOffline)}}).trigger('reloadGrid');
+});
+
 // —— 配置/升级弹窗 ——
 function openRuntimeDialog(id){
     $.getJSON('${ctx}/mes/clientRuntime/get', {id:id}, function(resp){