Commit cc78723741a358d30c66bd83049c442b619bdcb7

Authored by 赖素文
1 parent ed45ba8e

--设备在线离线 状态功能实现

sys/Hh.Mes.Service/WebService/Equipment/BaseEquipmentService.cs
... ... @@ -11,6 +11,7 @@ using System.Linq;
11 11 using System.Linq.Expressions;
12 12 using Hh.Mes.Pojo.System;
13 13 using NPOI.SS.Formula.Functions;
  14 +using Hh.Mes.Common.DataTableTo;
14 15  
15 16 namespace Hh.Mes.Service.Equipment
16 17 {
... ... @@ -24,24 +25,26 @@ namespace Hh.Mes.Service.Equipment
24 25  
25 26 //先组合查询表达式
26 27 dynamic query = null;
27   -
28   - //如果非管理员查出对应用户客户管理项目下厂房里的设备:
29   - string currentUser = sysWebUser.Account;
  28 +
  29 + var currentTime = DateTime.Now;
  30 + //如果非管理员查出对应用户客户管理项目下厂房里的设备:
  31 + string currentUser = sysWebUser.Account;
30 32 if (currentUser != SystemVariable.DefaultCreated)
31 33 {
32 34 var expression = LinqWhereNoSystem(entity);
33   - query = Context.Queryable<sys_user_client_rel, base_project_client_rel, base_equipment, base_equipment_type, base_project, base_sim_equipment_rel, base_factory>
34   - ((x, y, z, type, p, s, f) =>
  35 + query = Context.Queryable<sys_user_client_rel, base_project_client_rel, base_equipment, base_equipment_type, base_project, base_sim_equipment_rel, base_factory, daq_equipment_status_record>
  36 + ((x, y, z, type, p, s, f,xp) =>
35 37 new JoinQueryInfos(JoinType.Inner, x.userAccount == currentUser && x.clientKeys == y.clientKeys,
36 38 JoinType.Inner, y.projectKeys == z.projectKeys,
37 39 JoinType.Inner, z.equipmentTypeCode == type.code,
38 40 JoinType.Inner, z.projectKeys == p.keys,
39 41 JoinType.Left, s.equipmentCode == z.equipmentCode,
40   - JoinType.Inner, f.projectKeys == z.projectKeys && f.factoryCode == z.factoryCode
41   - )
  42 + JoinType.Inner, f.projectKeys == z.projectKeys && f.factoryCode == z.factoryCode,
  43 + JoinType.Inner, xp.equipmentCode == z.equipmentCode
  44 + )
42 45 )
43 46 .Where(expression)
44   - .Select((x, y, z, type, p, s, f) => new
  47 + .Select((x, y, z, type, p, s, f, xp) => new
45 48 {
46 49 z.id,
47 50 z.projectKeys,
... ... @@ -61,8 +64,10 @@ namespace Hh.Mes.Service.Equipment
61 64 z.equipmentMaintainRuleCode,
62 65 z.isEnable,
63 66 z.startTime,
  67 +
  68 + xp.status,
64 69  
65   - z.createBy,
  70 + z.createBy,
66 71 z.createTime,
67 72 z.updateBy,
68 73 z.updateTime,
... ... @@ -72,17 +77,18 @@ namespace Hh.Mes.Service.Equipment
72 77 else
73 78 {
74 79 var expression = LinqWhereSystem(entity);
75   - query = Context.Queryable<base_equipment, base_equipment_type, base_project, base_sim_equipment_rel, base_factory>
76   - ((x, y, p, s, f) =>
  80 + query = Context.Queryable<base_equipment, base_equipment_type, base_project, base_sim_equipment_rel, base_factory, daq_equipment_status_record>
  81 + ((x, y, p, s, f,z) =>
77 82 new JoinQueryInfos(
78 83 JoinType.Inner, x.equipmentTypeCode == y.code,
79 84 JoinType.Inner, x.projectKeys == p.keys,
80 85 JoinType.Left, s.equipmentCode == x.equipmentCode,
81   - JoinType.Inner, f.projectKeys == x.projectKeys && f.factoryCode == x.factoryCode
82   - )
  86 + JoinType.Inner, f.projectKeys == x.projectKeys && f.factoryCode == x.factoryCode,
  87 + JoinType.Left, z.equipmentCode == x.equipmentCode
  88 + )
83 89 )
84 90 .Where(expression)
85   - .Select((x, y, p, s, f) => new
  91 + .Select((x, y, p, s, f,z) => new
86 92 {
87 93 x.id,
88 94 x.projectKeys,
... ... @@ -103,7 +109,10 @@ namespace Hh.Mes.Service.Equipment
103 109 x.isEnable,
104 110 x.startTime,
105 111  
106   - x.createBy,
  112 + z.status,
  113 + eqOnLineUpdateTime = z.updateTime,
  114 + eqOnLineNowTime = currentTime,
  115 + x.createBy,
107 116 x.createTime,
108 117 x.updateBy,
109 118 x.updateTime,
... ...
web/WebMvc/Areas/configure/Views/BaseProject/ProjectOverview.cshtml
... ... @@ -120,7 +120,7 @@
120 120 </div>
121 121 </div>
122 122 </div>
123   - @*<div class="contcss">
  123 + <div class="contcss">
124 124 <div class="divcontent-left">
125 125 <div>离线数</div>
126 126 <div class="textStyle" style="color:red;">5</div>
... ... @@ -130,7 +130,7 @@
130 130 <span class="iconfont icon-lixianshu" style="color: rgb(146, 133, 235);"></span>
131 131 </div>
132 132 </div>
133   - </div>*@
  133 + </div>
134 134 </div>
135 135 </div>
136 136 </div>
... ... @@ -138,39 +138,7 @@
138 138 <div class="layui-colla-title">设备运行(当天)</div>
139 139 <div class="layui-colla-content layui-show" style="height: 10vh">
140 140 <div class="divcontent">
141   - <div class="contcss">
142   - <div class="divcontent-left">
143   - <div>故障时间</div>
144   - <div class="textStyle">20H</div>
145   - </div>
146   - <div class="divcontent-right">
147   - <div class="imgdiv">
148   - <span class="iconfont icon-guzhangshijian" style="color: rgb(146, 133, 235);"></span>
149   - </div>
150   - </div>
151   - </div>
152   - <div class="contcss">
153   - <div class="divcontent-left">
154   - <div>运行时间</div>
155   - <div class="textStyle">40H</div>
156   - </div>
157   - <div class="divcontent-right">
158   - <div class="imgdiv">
159   - <span class="iconfont icon-yunhangshijian" style="color: rgb(146, 133, 235);"></span>
160   - </div>
161   - </div>
162   - </div>
163   - <div class="contcss">
164   - <div class="divcontent-left">
165   - <div>待机时间</div>
166   - <div class="textStyle">30H</div>
167   - </div>
168   - <div class="divcontent-right">
169   - <div class="imgdiv">
170   - <span class="iconfont icon-daijishijian" style="color: rgb(146, 133, 235);"></span>
171   - </div>
172   - </div>
173   - </div>
  141 +
174 142  
175 143 <div class="contcss">
176 144 <div class="divcontent-left">
... ...
web/WebMvc/wwwroot/productjs/equipment/BaseEquipment.js
... ... @@ -233,9 +233,31 @@ layui.config({
233 233 { field: "simNumber", width: 150, title: "SIM卡号" },
234 234 { field: "equipmentTypeCode", width: 150, title: "设备类型编码", hide: true },
235 235 { field: "name", width: 120, title: "设备类型" },
236   - { field: "equipmentMaintainRuleCode", width: 150, title: "维护规则" },
  236 + { field: "equipmentMaintainRuleCode", width: 150, title: "维护规则", hide: true },
  237 +
  238 + {
  239 + field: "status", width: 150, title: "状态", templet: function (d) {
  240 + if (d.status == "" || d.status == null) return "";
  241 + var bg = "layui-badge-dot layui-bg-green",
  242 + statusText = "在线";
  243 + if (d.status == "Failure") {
  244 + statusText = "故障";
  245 + bg = "layui-badge-dot layui-bg-red";
  246 + }
  247 + if (d.eqOnLineUpdateTime !="0001-01-01 00:00:00") {
  248 + var dateDiff = new Date(d.eqOnLineNowTime) - new Date(d.eqOnLineUpdateTime);
  249 + var seconds = dateDiff / 1000;
  250 + if (seconds > 300) {
  251 + statusText = "离线";
  252 + bg = "layui-badge-dot layui-bg-gray";
  253 + }
  254 + }
  255 + return ` <span >${d.ip}</span><span class="${bg}" style=" left: 7px;"></span> <span style="padding-left: 8px;">${statusText}</span`;
  256 + }
  257 + },
  258 +
  259 +
237 260  
238   - { field: "equipmentStatus", width: 150, title: "状态" },
239 261 { field: "startTime", width: 150, title: "出厂时间" },
240 262  
241 263 { field: "imgSrc", width: 150, title: "图片" },
... ...