schangxiang@126.com
2025-04-01 de7dbe7cf85aa01abb64040aae1c04dfba74c135
CC/iWareCC_ASRS/Handler/DeviceWarningHandler.cs
@@ -1,4 +1,5 @@
using iWareCommon.Common.Globle;
using Admin.NET.Application;
using iWareCommon.Common.Globle;
using iWareCommon.Utils;
using iWareModel;
using iWareSql.WmsDBModel;
@@ -23,13 +24,27 @@
            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()
                    {
@@ -43,7 +58,7 @@
            }
            output.wmsConfigDeviceWarnings = retList;
            output.wms_config_device_warning_list = dbList;
            output.wms_config_device_warning_list = real_dbList;
            return output;
        }