1
yangpeixing
4 天以前 07b56c461476f7d580318749b2cd5f752aa38f3a
项目代码/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/System/Sys_DictionaryController.cs
@@ -24,58 +24,58 @@
    public IActionResult GetVueDictionary([FromBody] string[] dicNos)
    {
        List<VueDictionaryDTO> vueDictionaryDTOs = Service.GetVueDictionary(dicNos);
        try
        {
            List<string> cacheDicNos = new List<string>();
            foreach (string n in dicNos)
            {
                string str = _cacheService.Get(n);
                if (!string.IsNullOrEmpty(str))
                {
                    VueDictionaryDTO? vueDictionary = JsonConvert.DeserializeObject<VueDictionaryDTO>(str);
        //try
        //{
        //    List<string> cacheDicNos = new List<string>();
        //    foreach (string n in dicNos)
        //    {
        //        string str = _cacheService.Get(n);
        //        if (!string.IsNullOrEmpty(str))
        //        {
        //            VueDictionaryDTO? vueDictionary = JsonConvert.DeserializeObject<VueDictionaryDTO>(str);
                    if (vueDictionary != null)
                    {
                        vueDictionaryDTOs.Add(vueDictionary);
                        cacheDicNos.Add(n);
                    }
                }
            }
            List<string> dicList = dicNos.ToList();
            if (dicNos.Where(x => !cacheDicNos.Contains(x)).Count() > 0)
            {
                string str = AppSettings.Configuration["dics"];
                if (!string.IsNullOrEmpty(str))
                {
                    List<string> cusDics = new List<string>();
        //            if (vueDictionary != null)
        //            {
        //                vueDictionaryDTOs.Add(vueDictionary);
        //                cacheDicNos.Add(n);
        //            }
        //        }
        //    }
        //    List<string> dicList = dicNos.ToList();
        //    if (dicNos.Where(x => !cacheDicNos.Contains(x)).Count() > 0)
        //    {
        //        string str = AppSettings.Configuration["dics"];
        //        if (!string.IsNullOrEmpty(str))
        //        {
        //            List<string> cusDics = new List<string>();
                    List<string> dics = str.Split(",").ToList();
        //            List<string> dics = str.Split(",").ToList();
                    foreach (var item in dics)
                    {
                        dicList.Remove(item);
                        cusDics.Add(item);
                    }
        //            foreach (var item in dics)
        //            {
        //                dicList.Remove(item);
        //                cusDics.Add(item);
        //            }
                    foreach (var item in cusDics)
                    {
                        VueDictionaryDTO vueDictionaryDTO = GetVueDictionary(item.Trim());
                        if (vueDictionaryDTO != null)
                        {
                            vueDictionaryDTOs.Add(vueDictionaryDTO);
                            if (!_cacheService.Exists(item) && vueDictionaryDTO.SaveCache)
                            {
                                _cacheService.Add(item, vueDictionaryDTO.Serialize());
                            }
                        }
                    }
                }
            }
        }
        catch
        {
        //            foreach (var item in cusDics)
        //            {
        //                VueDictionaryDTO vueDictionaryDTO = GetVueDictionary(item.Trim());
        //                if (vueDictionaryDTO != null)
        //                {
        //                    vueDictionaryDTOs.Add(vueDictionaryDTO);
        //                    if (!_cacheService.Exists(item) && vueDictionaryDTO.SaveCache)
        //                    {
        //                        _cacheService.Add(item, vueDictionaryDTO.Serialize());
        //                    }
        //                }
        //            }
        //        }
        //    }
        //}
        //catch
        //{
        }
        //}
        return Json(vueDictionaryDTOs);
    }
    private VueDictionaryDTO GetVueDictionary(string key)
@@ -370,7 +370,243 @@
                        result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data };
                    }
                    break;
                case "operateTypeEnum":
                    {
                        List<object> data = new List<object>();
                        #region operateTypeEnum
                        {
                            Type type = typeof(OperateTypeEnum);
                            List<int> enums = Enum.GetValues(typeof(OperateTypeEnum)).Cast<int>().ToList();
                            int index = 0;
                            foreach (var item in enums)
                            {
                                FieldInfo? fieldInfo = typeof(OperateTypeEnum).GetField(((OperateTypeEnum)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++;
                            }
                        }
                        #endregion
                        result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data };
                    }
                    break;
                case "LocationState":
                    {
                        List<object> data = new List<object>();
                        #region LocationEnum
                        {
                            Type type = typeof(LocationEnum);
                            List<int> enums = Enum.GetValues(typeof(LocationEnum)).Cast<int>().ToList();
                            int index = 0;
                            foreach (var item in enums)
                            {
                                FieldInfo? fieldInfo = typeof(LocationEnum).GetField(((LocationEnum)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++;
                            }
                        }
                        #endregion
                        result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data };
                    }
                    break;
                case "StockStateEmun":
                    {
                        List<object> data = new List<object>();
                        #region StockStateEmun
                        {
                            Type type = typeof(StockStateEmun);
                            List<int> enums = Enum.GetValues(typeof(StockStateEmun)).Cast<int>().ToList();
                            int index = 0;
                            foreach (var item in enums)
                            {
                                FieldInfo? fieldInfo = typeof(StockStateEmun).GetField(((StockStateEmun)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++;
                            }
                        }
                        #endregion
                        result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data };
                    }
                    break;
                case "EnableEnum":
                    {
                        List<object> data = new List<object>();
                        #region EnableEnum
                        {
                            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++;
                            }
                        }
                        #endregion
                        result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data };
                    }
                    break;
                case "OrderStateEmun":
                    {
                        List<object> data = new List<object>();
                        #region OrderStateEmun
                        {
                            Type type = typeof(OrderStateEmun);
                            List<int> enums = Enum.GetValues(typeof(OrderStateEmun)).Cast<int>().ToList();
                            int index = 0;
                            foreach (var item in enums)
                            {
                                FieldInfo? fieldInfo = typeof(OrderStateEmun).GetField(((OrderStateEmun)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++;
                            }
                        }
                        #endregion
                        result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data };
                    }
                    break;
                case "OrderTypeEmun":
                    {
                        List<object> data = new List<object>();
                        #region OrderTypeEmun
                        {
                            Type type = typeof(OrderTypeEmun);
                            List<int> enums = Enum.GetValues(typeof(OrderTypeEmun)).Cast<int>().ToList();
                            int index = 0;
                            foreach (var item in enums)
                            {
                                FieldInfo? fieldInfo = typeof(OrderTypeEmun).GetField(((OrderTypeEmun)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++;
                            }
                        }
                        #endregion
                        result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data };
                    }
                    break;
                case "OrderCreateTypeEmun":
                    {
                        List<object> data = new List<object>();
                        #region OrderCreateTypeEmun
                        {
                            Type type = typeof(OrderCreateTypeEmun);
                            List<int> enums = Enum.GetValues(typeof(OrderCreateTypeEmun)).Cast<int>().ToList();
                            int index = 0;
                            foreach (var item in enums)
                            {
                                FieldInfo? fieldInfo = typeof(OrderCreateTypeEmun).GetField(((OrderCreateTypeEmun)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++;
                            }
                        }
                        #endregion
                        result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data };
                    }
                    break;
                case "InventoryStatus":
                    {
                        List<object> data = new List<object>();
                        #region InventoryStatus
                        {
                            Type type = typeof(InventoryStatus);
                            List<int> enums = Enum.GetValues(typeof(InventoryStatus)).Cast<int>().ToList();
                            int index = 0;
                            foreach (var item in enums)
                            {
                                FieldInfo? fieldInfo = typeof(InventoryStatus).GetField(((InventoryStatus)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++;
                            }
                        }
                        #endregion
                        result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data };
                    }
                    break;
            }
            return result;
        }