| | |
| | | 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()) |
| | |
| | | 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; |
| | | } |
| | | |