Commit 05947b19f337bbabf18fe5e688f482fb69e17798
1 parent
2186ab05
--设备报警处理
Showing
5 changed files
with
119 additions
and
39 deletions
sys/Hh.Mes.POJO/WebEntity/view/VW_CurrentUserDevice.cs
0 → 100644
1 | +using System; | |
2 | +using SqlSugar; | |
3 | + | |
4 | +namespace Hh.Mes.POJO.Entity | |
5 | +{ | |
6 | + [SugarTable("VW_CurrentUserDevice")] | |
7 | + public partial class VW_CurrentUserDevice : base_Entity | |
8 | + { | |
9 | + /// <summary> | |
10 | + /// 用户账号 | |
11 | + /// </summary> | |
12 | + [SugarColumn(Length = 100, ColumnDescription = "用户账号", IsNullable = false)] | |
13 | + public string userAccount { get; set; } | |
14 | + | |
15 | + /// <summary> | |
16 | + /// 客户keys | |
17 | + /// </summary> | |
18 | + [SugarColumn(Length = 100, ColumnDescription = "客户keys", IsNullable = false)] | |
19 | + public Guid clientKeys { get; set; } | |
20 | + | |
21 | + /// <summary> | |
22 | + /// 项目keys | |
23 | + /// </summary> | |
24 | + [SugarColumn(Length = 100, ColumnDescription = "项目keys", IsNullable = false)] | |
25 | + public Guid projectKeys { get; set; } | |
26 | + | |
27 | + /// <summary> | |
28 | + /// 项目名称 | |
29 | + /// </summary> | |
30 | + [SugarColumn(Length = 100, ColumnDescription = "项目名称", IsNullable = false)] | |
31 | + public string projectName { get; set; } | |
32 | + | |
33 | + /// <summary> | |
34 | + /// 厂房名称 | |
35 | + /// </summary> | |
36 | + [SugarColumn(Length = 100, ColumnDescription = "厂房名称", IsNullable = false)] | |
37 | + public string factoryName { get; set; } | |
38 | + | |
39 | + /// <summary> | |
40 | + /// 设备类型 | |
41 | + /// </summary> | |
42 | + [SugarColumn(Length = 20, ColumnDescription = "设备类型", IsNullable = true)] | |
43 | + public string equipmentTypeName { get; set; } | |
44 | + | |
45 | + /// <summary> | |
46 | + /// 设备编码 | |
47 | + /// </summary> | |
48 | + [SugarColumn(Length = 100, ColumnDescription = "设备编码", IsNullable = false)] | |
49 | + public string equipmentCode { get; set; } | |
50 | + | |
51 | + /// <summary> | |
52 | + /// 设备名称 | |
53 | + /// </summary> | |
54 | + [SugarColumn(Length = 100, ColumnDescription = "设备名称", IsNullable = true)] | |
55 | + public string equipmentName { get; set; } | |
56 | + } | |
57 | +} | |
0 | 58 | \ No newline at end of file |
... | ... |
sys/Hh.Mes.Service/WebService/Equipment/BusEquipmentAlarmHandleService.cs
... | ... | @@ -22,10 +22,11 @@ namespace Hh.Mes.Service.Equipment |
22 | 22 | var result = new Response(); |
23 | 23 | var expression = LinqWhere(entity); |
24 | 24 | //先组合查询表达式(多表查询查看IOT 设备列表案例) |
25 | - var query = Context.Queryable<bus_equipment_alarm_handle, daq_equipment_alarm_record>( | |
26 | - (x, y) => x.equipmentAlarmRecordId == y.id) | |
25 | + var query = Context.Queryable<bus_equipment_alarm_handle, daq_equipment_alarm_record,VW_CurrentUserDevice>( | |
26 | + (x, y, v) => x.equipmentAlarmRecordId == y.id && y.equipmentCode==v.equipmentCode) | |
27 | 27 | .Where(expression) |
28 | - .Select((x, y) => new | |
28 | + .OrderBy((x, y,v) => new { v.projectKeys,v.factoryName, y.createTime, y.handleTime}, OrderByType.Desc)//报警发生时间,报警处理时间降序排列 | |
29 | + .Select((x, y, v) => new | |
29 | 30 | { |
30 | 31 | x.id, |
31 | 32 | x.equipmentAlarmRecordId, |
... | ... | @@ -40,7 +41,11 @@ namespace Hh.Mes.Service.Equipment |
40 | 41 | y.alarmMessage, |
41 | 42 | y.equipmentCode, |
42 | 43 | y.equipmentName, |
43 | - y.createTime | |
44 | + y.createTime, | |
45 | + | |
46 | + v.projectName, | |
47 | + v.factoryName, | |
48 | + v.equipmentTypeName | |
44 | 49 | }); |
45 | 50 | //Exel false 分页 |
46 | 51 | if (!entity.Exel) |
... | ... | @@ -99,20 +104,29 @@ namespace Hh.Mes.Service.Equipment |
99 | 104 | return Load(null, entity); |
100 | 105 | } |
101 | 106 | |
102 | - public Expression<Func<bus_equipment_alarm_handle, daq_equipment_alarm_record, bool>> LinqWhere(bus_equipment_alarm_handle model) | |
107 | + public Expression<Func<bus_equipment_alarm_handle, daq_equipment_alarm_record,VW_CurrentUserDevice, bool>> LinqWhere(bus_equipment_alarm_handle model) | |
103 | 108 | { |
104 | 109 | try |
105 | 110 | { |
106 | - var exp = Expressionable.Create<bus_equipment_alarm_handle, daq_equipment_alarm_record>(); | |
111 | + string currentUser = sysWebUser.Account; | |
112 | + var exp = Expressionable.Create<bus_equipment_alarm_handle, daq_equipment_alarm_record,VW_CurrentUserDevice> (); | |
107 | 113 | //数据过滤条件 |
108 | 114 | //if (!string.IsNullOrWhiteSpace(model.XXX)) exp.And(x => x.XXX.Contains(model.XXX)); |
109 | 115 | if (!string.IsNullOrWhiteSpace(model.handleInfo)) |
110 | 116 | { |
111 | - exp.And((x, y) => x.handleInfo.Contains(model.handleInfo)); | |
117 | + exp.And((x, y, v) => x.handleInfo.Contains(model.handleInfo)); | |
112 | 118 | } |
113 | 119 | if (!string.IsNullOrWhiteSpace(model.handleUser)) |
114 | 120 | { |
115 | - exp.And((x, y) => x.handleUser.Contains(model.handleUser)); | |
121 | + exp.And((x, y, v) => x.handleUser.Contains(model.handleUser)); | |
122 | + } | |
123 | + if (model.equipmentAlarmRecordId != new Guid("00000000-0000-0000-0000-000000000000")) | |
124 | + { | |
125 | + exp.And((x, y, v) => x.equipmentAlarmRecordId.Equals(model.equipmentAlarmRecordId)); | |
126 | + } | |
127 | + if (currentUser != SystemVariable.DefaultCreated) | |
128 | + { | |
129 | + exp.And((x, y, v) => v.userAccount==currentUser); | |
116 | 130 | } |
117 | 131 | return exp.ToExpression();//拼接表达式 |
118 | 132 | } |
... | ... |
sys/Hh.Mes.Service/WebService/Equipment/DaqEquipmentAlarmRecordService.cs
... | ... | @@ -38,8 +38,7 @@ namespace Hh.Mes.Service.Equipment |
38 | 38 | stringBuilder.Append("declare @pageIndex int,@pageSize int,@offset int"); |
39 | 39 | stringBuilder.AppendLine($" select @pageIndex={pageReq.page}, @pageSize={pageReq.limit}, @offset=(@pageIndex - 1) * @pageSize"); |
40 | 40 | } |
41 | - | |
42 | - stringBuilder.AppendLine($@" select distinct | |
41 | + string sql = $@"select distinct | |
43 | 42 | vw.projectName, vw.factoryName, t1.EquipmentCode, t1.EquipmentName, vw.equipmentTypeName, |
44 | 43 | counts=count(*) |
45 | 44 | from {nameof(daq_equipment_alarm_record)} t1 with(nolock) |
... | ... | @@ -47,21 +46,14 @@ namespace Hh.Mes.Service.Equipment |
47 | 46 | on t1.equipmentCode=vw.equipmentCode {userWhere} |
48 | 47 | where {sqlWhere} |
49 | 48 | group by vw.projectName,vw.factoryName ,t1.EquipmentCode, |
50 | - t1.EquipmentName,vw.equipmentTypeName,vw.userAccount | |
51 | - order by {orderBy} "); | |
49 | + t1.EquipmentName,vw.equipmentTypeName,vw.userAccount"; | |
50 | + stringBuilder.AppendLine(sql+ $@" order by {orderBy} "); | |
52 | 51 | |
53 | 52 | //Exel ture 不分页 |
54 | 53 | if (!model.Exel) |
55 | 54 | { |
56 | 55 | stringBuilder.AppendLine(" offset @offset row fetch next @pageSize row only "); |
57 | - stringBuilder.Append($@" select rowTotal= count(*) from ( | |
58 | - select distinct vw.projectName | |
59 | - from {nameof(daq_equipment_alarm_record)} t1 with(nolock) | |
60 | - inner join vw_CurrentUserDevice vw | |
61 | - on t1.equipmentCode=vw.equipmentCode {userWhere} | |
62 | - where {sqlWhere} | |
63 | - group by vw.projectName,vw.factoryName ,t1.EquipmentCode,t1.EquipmentName,vw.equipmentTypeName,vw.userAccount | |
64 | - )t"); | |
56 | + stringBuilder.Append($@" select rowTotal= count(*) from ({sql})t"); | |
65 | 57 | } |
66 | 58 | var ds = base.Context.Ado.GetDataSetAll(stringBuilder.ToString()); |
67 | 59 | result.Result = ds.Tables[0]; |
... | ... | @@ -86,7 +78,7 @@ namespace Hh.Mes.Service.Equipment |
86 | 78 | var result = new Response(); |
87 | 79 | var expression = LinqWhere(entity); |
88 | 80 | //先组合查询表达式(多表查询查看IOT 设备列表案例) |
89 | - var query = Context.Queryable<daq_equipment_alarm_record>().Where(expression); | |
81 | + var query = Context.Queryable<daq_equipment_alarm_record>().Where(expression).OrderBy(x=>x.createTime,OrderByType.Desc); | |
90 | 82 | //Exel false 分页 |
91 | 83 | if (!entity.Exel) |
92 | 84 | { |
... | ... | @@ -209,8 +201,8 @@ namespace Hh.Mes.Service.Equipment |
209 | 201 | { |
210 | 202 | var response = new Response(); |
211 | 203 | //更新 设备报警表【是否处理】报警标识 |
212 | - var alamList = Context.Queryable<daq_equipment_alarm_record>().Where(x => x.id == entity.id && x.isHandled == false).ToList(); | |
213 | - if (alamList.Count == 0) | |
204 | + var alamList = Context.Queryable<daq_equipment_alarm_record>().First(x => x.id == entity.id && x.isHandled == false); | |
205 | + if (alamList==null) | |
214 | 206 | { |
215 | 207 | response.Code = 500; |
216 | 208 | response.Message = $"未查询到匹配的数据或者该报警数据已被处理,EquipmentName:{entity.equipmentName},AlarmMessage:{entity.alarmMessage}"; |
... | ... | @@ -218,12 +210,12 @@ namespace Hh.Mes.Service.Equipment |
218 | 210 | } |
219 | 211 | else |
220 | 212 | { |
221 | - alamList.ForEach(x => | |
222 | - { | |
213 | + //alamList.ForEach(x => | |
214 | + //{ | |
223 | 215 | x.isHandled = true; |
224 | 216 | x.FaultType = entity.FaultType;//故障类别 |
225 | 217 | x.handleTime = DateTime.Now; |
226 | - }); | |
218 | + //}); | |
227 | 219 | } |
228 | 220 | Context.Updateable<daq_equipment_alarm_record>(alamList).AddQueue(); |
229 | 221 | |
... | ... | @@ -312,7 +304,7 @@ namespace Hh.Mes.Service.Equipment |
312 | 304 | var result = new Dictionary<string, string>(); |
313 | 305 | |
314 | 306 | //报警处理人 alarmHandlePeople |
315 | - var res = Context.Queryable<sys_dict_data>().Where(x => x.headerId == 2208).ToList(); | |
307 | + var res = Context.Queryable<sys_dict_data>().Where(x => x.dictType == "AlarmHandlePeople").ToList(); | |
316 | 308 | |
317 | 309 | foreach (var item in res) |
318 | 310 | { |
... | ... |
web/WebMvc/Areas/equipment/Views/BusEquipmentAlarmHandle/Index.cshtml
1 | +@model Dictionary<string,string> | |
1 | 2 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers |
2 | 3 | @{ |
3 | 4 | ViewData["title"] = "设备故障处理记录表"; |
... | ... | @@ -30,10 +31,24 @@ |
30 | 31 | <div class="layui-col-sm3"> |
31 | 32 | <label class="layui-form-label">处理人</label> |
32 | 33 | <div class="layui-input-inline"> |
33 | - <input name="handleUser" type="text" autocomplete="off" maxlength="70" class="layui-input"> | |
34 | + <select name="handleUser" lay-verify="required" class="layui-select"> | |
35 | + </select> | |
36 | + </div> | |
37 | + </div> | |
38 | + <div class="layui-col-sm6" style="padding-top: 5px;"> | |
39 | + <label class="layui-form-label">处理时间</label> | |
40 | + <div class=" div-flex"> | |
41 | + <input name="createTime" type="text" placeholder="开始时间" class="layui-input layui-date" time="datetime" /> | |
42 | + <label style="padding-top:4px;">-</label> | |
43 | + <input name="updateTime" type="text" placeholder="结束时间" class="layui-input layui-date" time="datetime" /> | |
44 | + </div> | |
45 | + </div> | |
46 | + <div class="layui-col-sm3"> | |
47 | + <label class="layui-form-label">报警ID</label> | |
48 | + <div class="layui-input-inline"> | |
49 | + <input name="equipmentAlarmRecordId" type="text" autocomplete="off" maxlength="357" class="layui-input"> | |
34 | 50 | </div> |
35 | 51 | </div> |
36 | - | |
37 | 52 | </div> |
38 | 53 | </div> |
39 | 54 | </fieldset> |
... | ... |
web/WebMvc/wwwroot/productjs/equipment/BusEquipmentAlarmHandle.js
... | ... | @@ -138,8 +138,11 @@ layui.config({ |
138 | 138 | data: { |
139 | 139 | cols: [[ |
140 | 140 | { checkbox: true, fixed: true }, |
141 | - { field: "id", width: 80, hide: true, title: "Id" }, | |
141 | + { field: "id", width: 80, hide: true, title: "Id", hide: true }, | |
142 | 142 | { field: "equipmentAlarmRecordId", width: 150, title: "报警记录编号", hide: true }, |
143 | + { field: "projectName", width: 150, title: "项目名称"}, | |
144 | + { field: "factoryName", width: 150, title: "厂房名称" }, | |
145 | + { field: "equipmentTypeName", width: 150, title: "设备类型", hide:true }, | |
143 | 146 | { field: "equipmentCode", width: 150, title: "设备编号", hide: true }, |
144 | 147 | { field: "equipmentName", width: 150, title: "设备名称" }, |
145 | 148 | { field: "alarmMessage", width: 150, title: "报警信息" }, |
... | ... | @@ -159,14 +162,13 @@ layui.config({ |
159 | 162 | |
160 | 163 | //下拉框配置 |
161 | 164 | selectOption: { |
162 | - //station: { | |
163 | - // SelType: "FromUrl", | |
164 | - // SelFrom: `/${areaName}/${controllerName}/StationLineSelect`, | |
165 | - // SelLabel: "workStationName", | |
166 | - // SelValue: "workStationCode", | |
167 | - // OptGroup: true, | |
168 | - // Dom: [$("[name='stationCode']")] | |
169 | - //}, | |
165 | + selectHandleUser: { | |
166 | + SelType: "FromDict", | |
167 | + SelFrom: "AlarmHandlePeople", | |
168 | + SelLabel: "DictLabel", | |
169 | + SelValue: "DictValue", | |
170 | + Dom: [$("[name='handleUser']")] | |
171 | + }, | |
170 | 172 | //返回的数据 用于后续操作 |
171 | 173 | selectData: { |
172 | 174 | |
... | ... | @@ -219,7 +221,7 @@ layui.config({ |
219 | 221 | }, |
220 | 222 | |
221 | 223 | initFrom() { |
222 | - //sysU.initSelect(app.data.selectOption); | |
224 | + sysU.initSelect(app.data.selectOption); | |
223 | 225 | |
224 | 226 | //sysU.initSelecteByEnum(app.data.selectOptionEnum); |
225 | 227 | } |
... | ... |