| | |
| | | using iWareCommon.Common.Globle; |
| | | using Admin.NET.Application; |
| | | using iWareCommon.Common.Globle; |
| | | using iWareCommon.Utils; |
| | | using iWareModel; |
| | | using iWareSql.WmsDBModel; |
| | |
| | | DeviceWarningOutput output = new DeviceWarningOutput(); |
| | | System.Collections.Generic.List<iWareCC.StationService.WmsConfigDeviceWarning> retList = new System.Collections.Generic.List<iWareCC.StationService.WmsConfigDeviceWarning>(); |
| | | System.Collections.Generic.List<wms_config_device_warning> dbList = new System.Collections.Generic.List<wms_config_device_warning>(); |
| | | System.Collections.Generic.List<wms_config_device_warning> real_dbList = new System.Collections.Generic.List<wms_config_device_warning>(); |
| | | try |
| | | { |
| | | using (WmsDBModel edm = new WmsDBModel()) |
| | | { |
| | | dbList = edm.wms_config_device_warning.ToList(); |
| | | //注意:只查询 安全报警、硬件报警信息 |
| | | var query1 = (int)DeviceWarningTypeEnum.安全报警; |
| | | var query2 = (int)DeviceWarningTypeEnum.硬件报警; |
| | | dbList = edm.wms_config_device_warning.Where(x => x.DeviceWarningType == query1 || x.DeviceWarningType == query2).ToList(); |
| | | //每种区域的每种类型,只取前20条记录 |
| | | var groupedData = dbList.GroupBy(x => new { x.DeviceAreaCode, x.DeviceWarningType }).Select(group => new |
| | | { |
| | | GroupKey = group.Key, |
| | | Top20Items = group.ToList().OrderBy(x => x.Id).Take(20) |
| | | }); |
| | | foreach (var item in groupedData) |
| | | { |
| | | real_dbList.AddRange(item.Top20Items); |
| | | } |
| | | } |
| | | foreach (var item in dbList) |
| | | foreach (var item in real_dbList) |
| | | { |
| | | retList.Add(new StationService.WmsConfigDeviceWarning() |
| | | { |
| | |
| | | } |
| | | |
| | | output.wmsConfigDeviceWarnings = retList; |
| | | output.wms_config_device_warning_list = dbList; |
| | | output.wms_config_device_warning_list = real_dbList; |
| | | return output; |
| | | } |
| | | |
| | |
| | | /// <param name="deviceName"></param> |
| | | /// <param name="warningCode"></param> |
| | | /// <param name="warningContent"></param> |
| | | public static void SaveWarning(EDevice device, LogType _LogType, string warningCode, int deviceAreaCode, string warningContent,int deviceWarningType) |
| | | public static void SaveWarning(EDevice device, LogType _LogType, string warningCode, int deviceAreaCode, string warningContent, int deviceWarningType) |
| | | { |
| | | Task.Run(() => |
| | | { |
| | |
| | | WarningTime = DateTime.Now, |
| | | CreateUserName = SysGloble.WCSSystem, |
| | | DeviceAreaCode = deviceAreaCode, |
| | | DeviceWarningType= deviceWarningType, |
| | | DeviceWarningType = deviceWarningType, |
| | | DurationTime = "", |
| | | |
| | | CreateTime = DateTime.Now, |
| | |
| | | /// <param name="deviceId">设备区域</param> |
| | | /// <param name="_LogType"></param> |
| | | /// <returns></returns> |
| | | public static void AutoCloseWarning(EDevice device, LogType _LogType, System.Collections.Generic.List<string> warningAddressList) |
| | | public static void AutoCloseWarning(EDevice device, LogType _LogType, System.Collections.Generic.List<string> warningCodeList) |
| | | { |
| | | Task.Run(() => |
| | | { |
| | | try |
| | | { |
| | | string deviceCode = ((int)device).ToString(); |
| | | using (WmsDBModel edm = new WmsDBModel()) |
| | | { |
| | | var dataList = edm.wms_record_device_warning.Where(x => x.WarningCode == deviceCode && x.DeviceWarningStatus == 0).ToList(); |
| | | var dataList = edm.wms_record_device_warning.Where(x => x.DeviceWarningStatus == 0).ToList(); |
| | | if (dataList != null && dataList.Count > 0) |
| | | { |
| | | var msg = ""; |
| | | var nowDate = DateTime.Now; |
| | | foreach (var detail in dataList) |
| | | { |
| | | if (!warningAddressList.Contains(detail.WarningCode)) |
| | | if (!warningCodeList.Contains(detail.WarningCode)) |
| | | { |
| | | nowDate = DateTime.Now; |
| | | detail.DeviceWarningStatus = 1; //状态(0:新建 1:已处理) |