From c15bffb8522417ef4d9885d8a5e4a2aeb79831ea Mon Sep 17 00:00:00 2001 From: hutongqing <hutongqing@hnkhzn.com> Date: 星期四, 28 十一月 2024 15:46:21 +0800 Subject: [PATCH] 更新 --- WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/System/Sys_DictionaryController.cs | 245 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 231 insertions(+), 14 deletions(-) diff --git a/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/System/Sys_DictionaryController.cs b/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/System/Sys_DictionaryController.cs index c759c5b..be0efdc 100644 --- a/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/System/Sys_DictionaryController.cs +++ b/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/System/Sys_DictionaryController.cs @@ -19,8 +19,13 @@ using WIDESEAWCS_QuartzJob; using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime; using WIDESEAWCS_Common.TaskEnum; -using WIDESEAWCS_Core.Enums; using WIDESEAWCS_Core.Caches; +using WIDESEAWCS_QuartzJob.DeviceEnum; +using WIDESEAWCS_Core.Enums; +using WIDESEAWCS_Common.CommonEnum; +using WIDESEAWCS_Common.LocationEnum; +using WIDESEAWCS_Common.OrderEnum; +using WIDESEAWCS_Common.StockEnum; namespace WIDESEAWCS_WCSServer.Controllers.System { @@ -43,10 +48,11 @@ List<VueDictionaryDTO> vueDictionaryDTOs = Service.GetVueDictionary(dicNos); try { + List<string> selectDicNos = vueDictionaryDTOs.Select(x => x.DicNo).ToList(); List<string> cacheDicNos = new List<string>(); - foreach (string n in dicNos) + foreach (string n in dicNos.Where(x => !selectDicNos.Contains(x))) { - string str = _cacheService.Get(n); + string? str = _cacheService.Get(n); if (!string.IsNullOrEmpty(str)) { VueDictionaryDTO? vueDictionary = JsonConvert.DeserializeObject<VueDictionaryDTO>(str); @@ -59,7 +65,8 @@ } } List<string> dicList = dicNos.ToList(); - if (dicNos.Where(x => !cacheDicNos.Contains(x)).Count() > 0) + List<string> otherDicNos = dicNos.Where(x => !cacheDicNos.Contains(x) && !selectDicNos.Contains(x)).ToList(); + if (otherDicNos.Count() > 0) { string str = AppSettings.Configuration["dics"]; if (!string.IsNullOrEmpty(str)) @@ -68,19 +75,21 @@ List<string> dics = str.Split(",").ToList(); - foreach (var item in dics) + foreach (var item in otherDicNos) { - dicList.Remove(item); - cusDics.Add(item); + if (dics.Contains(item)) + { + cusDics.Add(item); + } } foreach (var item in cusDics) { - VueDictionaryDTO vueDictionaryDTO = GetVueDictionary(item.Trim()); + VueDictionaryDTO? vueDictionaryDTO = GetVueDictionary(item.Trim()); if (vueDictionaryDTO != null) { vueDictionaryDTOs.Add(vueDictionaryDTO); - if (!_cacheService.Exists(item)) + if (!_cacheService.Exists(item) && vueDictionaryDTO.SaveCache) { _cacheService.Add(item, vueDictionaryDTO.Serialize()); } @@ -107,9 +116,7 @@ { Type type = typeof(IDevice); var basePath = AppContext.BaseDirectory; - string path = Path.Combine(basePath, Assembly.GetExecutingAssembly().GetName().Name); - Assembly assembly = Assembly.LoadFrom(path); - List<Type> types = assembly.GetTypes().Where(x => type.IsAssignableFrom(x) && !x.IsAbstract && !x.IsInterface).ToList(); + List<Type> types = type.Assembly.GetTypes().Where(x => type.IsAssignableFrom(x) && !x.IsAbstract && !x.IsInterface).ToList(); List<object> data = new List<object>(); foreach (var deviceType in types) { @@ -147,12 +154,12 @@ case "deviceStatus": { List<object> data = new List<object>(); - Type type = Type.GetType("WIDESEAWCS_QuartzJob.DeviceEnum.DeviceStatusEnum"); + Type type = typeof(DeviceStatusEnum); List<int> enums = Enum.GetValues(type).Cast<int>().ToList(); int index = 0; foreach (var item in enums) { - FieldInfo? fieldInfo = type.GetField((item).ToString()); + FieldInfo? fieldInfo = type.GetField(((DeviceStatusEnum)item).ToString()); DescriptionAttribute? description = fieldInfo.GetCustomAttribute<DescriptionAttribute>(); if (description != null) { @@ -362,6 +369,216 @@ result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data }; } break; + case "outboundStatusEnum": + { + List<object> data = new List<object>(); + Type type = typeof(OutboundStatusEnum); + List<int> enums = Enum.GetValues(typeof(OutboundStatusEnum)).Cast<int>().ToList(); + int index = 0; + foreach (var item in enums) + { + FieldInfo? fieldInfo = typeof(OutboundStatusEnum).GetField(((OutboundStatusEnum)item).ToString()); + DescriptionAttribute? description = fieldInfo.GetCustomAttribute<DescriptionAttribute>(); + if (description != null) + { + data.Add(new { key = item.ToString(), value = description.Description }); + } + else + { + data.Add(new { key = item.ToString(), value = item.ToString() }); + } + index++; + } + + result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data }; + } + break; + case "outOrderType": + { + List<object> data = new List<object>(); + + { + Type type = typeof(OutOrderTypeEnum); + List<int> enums = Enum.GetValues(typeof(OutOrderTypeEnum)).Cast<int>().ToList(); + int index = 0; + foreach (var item in enums) + { + FieldInfo? fieldInfo = typeof(OutOrderTypeEnum).GetField(((OutOrderTypeEnum)item).ToString()); + DescriptionAttribute? description = fieldInfo.GetCustomAttribute<DescriptionAttribute>(); + if (description != null) + { + data.Add(new { key = item.ToString(), value = description.Description }); + } + else + { + data.Add(new { key = item.ToString(), value = item.ToString() }); + } + index++; + } + } + + result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data }; + } + break; + case "orderDetailStatusEnum": + { + List<object> data = new List<object>(); + + { + Type type = typeof(OrderDetailStatusEnum); + List<int> enums = Enum.GetValues(typeof(OrderDetailStatusEnum)).Cast<int>().ToList(); + int index = 0; + foreach (var item in enums) + { + FieldInfo? fieldInfo = typeof(OrderDetailStatusEnum).GetField(((OrderDetailStatusEnum)item).ToString()); + DescriptionAttribute? description = fieldInfo.GetCustomAttribute<DescriptionAttribute>(); + if (description != null) + { + data.Add(new { key = item.ToString(), value = description.Description }); + } + else + { + data.Add(new { key = item.ToString(), value = item.ToString() }); + } + index++; + } + } + + result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data }; + } + break; + case "enableEnum": + { + List<object> data = new List<object>(); + + { + Type type = typeof(EnableEnum); + List<int> enums = Enum.GetValues(typeof(EnableEnum)).Cast<int>().ToList(); + int index = 0; + foreach (var item in enums) + { + FieldInfo? fieldInfo = typeof(EnableEnum).GetField(((EnableEnum)item).ToString()); + DescriptionAttribute? description = fieldInfo.GetCustomAttribute<DescriptionAttribute>(); + if (description != null) + { + data.Add(new { key = item.ToString(), value = description.Description }); + } + else + { + data.Add(new { key = item.ToString(), value = item.ToString() }); + } + index++; + } + } + + result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data }; + } + break; + case "enableStatusEnum": + { + List<object> data = new List<object>(); + + { + Type type = typeof(EnableStatusEnum); + List<int> enums = Enum.GetValues(typeof(EnableStatusEnum)).Cast<int>().ToList(); + int index = 0; + foreach (var item in enums) + { + FieldInfo? fieldInfo = typeof(EnableStatusEnum).GetField(((EnableStatusEnum)item).ToString()); + DescriptionAttribute? description = fieldInfo.GetCustomAttribute<DescriptionAttribute>(); + if (description != null) + { + data.Add(new { key = item.ToString(), value = description.Description }); + } + else + { + data.Add(new { key = item.ToString(), value = item.ToString() }); + } + index++; + } + } + + result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data }; + } + break; + case "locationStatusEnum": + { + List<object> data = new List<object>(); + + { + Type type = typeof(LocationStatusEnum); + List<int> enums = Enum.GetValues(typeof(LocationStatusEnum)).Cast<int>().ToList(); + int index = 0; + foreach (var item in enums) + { + FieldInfo? fieldInfo = typeof(LocationStatusEnum).GetField(((LocationStatusEnum)item).ToString()); + DescriptionAttribute? description = fieldInfo.GetCustomAttribute<DescriptionAttribute>(); + if (description != null) + { + data.Add(new { key = item.ToString(), value = description.Description }); + } + else + { + data.Add(new { key = item.ToString(), value = item.ToString() }); + } + index++; + } + } + + result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data }; + } + break; + case "locationTypeEnum": + { + List<object> data = new List<object>(); + + { + Type type = typeof(LocationTypeEnum); + List<int> enums = Enum.GetValues(typeof(LocationTypeEnum)).Cast<int>().ToList(); + int index = 0; + foreach (var item in enums) + { + FieldInfo? fieldInfo = typeof(LocationTypeEnum).GetField(((LocationTypeEnum)item).ToString()); + DescriptionAttribute? description = fieldInfo.GetCustomAttribute<DescriptionAttribute>(); + if (description != null) + { + data.Add(new { key = item.ToString(), value = description.Description }); + } + else + { + data.Add(new { key = item.ToString(), value = item.ToString() }); + } + index++; + } + } + + result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data }; + } + break; + case "stockStatusEmun": + { + List<object> data = new List<object>(); + Type type = typeof(StockStatusEmun); + List<int> enums = Enum.GetValues(typeof(StockStatusEmun)).Cast<int>().ToList(); + int index = 0; + foreach (var item in enums) + { + FieldInfo? fieldInfo = typeof(StockStatusEmun).GetField(((StockStatusEmun)item).ToString()); + DescriptionAttribute? description = fieldInfo.GetCustomAttribute<DescriptionAttribute>(); + if (description != null) + { + data.Add(new { key = item.ToString(), value = description.Description }); + } + else + { + data.Add(new { key = item.ToString(), value = item.ToString() }); + } + index++; + } + + result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data }; + } + break; } return result; } -- Gitblit v1.9.3