| | |
| | | using Newtonsoft.Json; |
| | | using Microsoft.AspNetCore.Mvc.ViewFeatures; |
| | | using Newtonsoft.Json; |
| | | using OfficeOpenXml.FormulaParsing.Excel.Functions.Information; |
| | | using System; |
| | | using System.Collections.Generic; |
| | |
| | | using System.Reflection; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_Common.OrderEnum; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.BaseRepository; |
| | | using WIDESEA_Core.BaseServices; |
| | |
| | | using WIDESEA_Core.DB; |
| | | using WIDESEA_Core.Enums; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_Core.TaskEnum; |
| | | using WIDESEA_DTO.System; |
| | | using WIDESEA_IBasicRepository; |
| | | using WIDESEA_ISystemRepository; |
| | | using WIDESEA_ISystemService; |
| | | using WIDESEA_Model.Models; |
| | |
| | | { |
| | | private readonly IUnitOfWorkManage _unitOfWorkManage; |
| | | private readonly ICacheService _cacheService; |
| | | private readonly IBasicRepository _basicRepository; |
| | | |
| | | public Sys_DictionaryService(ISys_DictionaryRepository BaseDal, IUnitOfWorkManage unitOfWorkManage, ICacheService cacheService) : base(BaseDal) |
| | | public Sys_DictionaryService(ISys_DictionaryRepository BaseDal, IUnitOfWorkManage unitOfWorkManage, ICacheService cacheService, IBasicRepository basicRepository) : base(BaseDal) |
| | | { |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | _cacheService = cacheService; |
| | | _basicRepository = basicRepository; |
| | | } |
| | | |
| | | public ISys_DictionaryRepository Repository => BaseDal; |
| | |
| | | { |
| | | switch (key) |
| | | { |
| | | case "warehouses": |
| | | { |
| | | List<object> data = new List<object>(); |
| | | |
| | | { |
| | | List<Dt_Warehouse> warehouses = _basicRepository.WarehouseRepository.QueryData(); |
| | | int index = 0; |
| | | foreach (var item in warehouses) |
| | | { |
| | | data.Add(new { key = item.WarehouseId, value = item.WarehouseName }); |
| | | index++; |
| | | } |
| | | } |
| | | |
| | | result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data }; |
| | | } |
| | | break; |
| | | case "inboundState": |
| | | { |
| | | List<object> data = new List<object>(); |
| | |
| | | foreach (var item in enums) |
| | | { |
| | | FieldInfo? fieldInfo = typeof(InboundStatusEnum).GetField(((InboundStatusEnum)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 "inoutType": |
| | | { |
| | | List<object> data = new List<object>(); |
| | | Type type = typeof(InoutTypeEnum); |
| | | List<int> enums = Enum.GetValues(typeof(InoutTypeEnum)).Cast<int>().ToList(); |
| | | int index = 0; |
| | | foreach (var item in enums) |
| | | { |
| | | FieldInfo? fieldInfo = typeof(InoutTypeEnum).GetField(((InoutTypeEnum)item).ToString()); |
| | | DescriptionAttribute? description = fieldInfo.GetCustomAttribute<DescriptionAttribute>(); |
| | | if (description != null) |
| | | { |
| | |
| | | List<object> data = new List<object>(); |
| | | |
| | | { |
| | | Type type = typeof(InOrderTypeEnum); |
| | | List<int> enums = Enum.GetValues(typeof(InOrderTypeEnum)).Cast<int>().ToList(); |
| | | Type type = typeof(OrderTypeEnum); |
| | | List<int> enums = Enum.GetValues(typeof(OrderTypeEnum)).Cast<int>().ToList(); |
| | | int index = 0; |
| | | foreach (var item in enums) |
| | | { |
| | | FieldInfo? fieldInfo = typeof(InOrderTypeEnum).GetField(((InOrderTypeEnum)item).ToString()); |
| | | FieldInfo? fieldInfo = typeof(OrderTypeEnum).GetField(((OrderTypeEnum)item).ToString()); |
| | | DescriptionAttribute? description = fieldInfo.GetCustomAttribute<DescriptionAttribute>(); |
| | | if (description != null) |
| | | { |
| | |
| | | List<object> data = new List<object>(); |
| | | |
| | | { |
| | | Type type = typeof(InTaskStatusEnum); |
| | | List<int> enums = Enum.GetValues(typeof(InTaskStatusEnum)).Cast<int>().ToList(); |
| | | Type type = typeof(TaskStatusEnum); |
| | | List<int> enums = Enum.GetValues(typeof(TaskStatusEnum)).Cast<int>().ToList(); |
| | | int index = 0; |
| | | foreach (var item in enums) |
| | | { |
| | | FieldInfo? fieldInfo = typeof(InTaskStatusEnum).GetField(((InTaskStatusEnum)item).ToString()); |
| | | FieldInfo? fieldInfo = typeof(TaskStatusEnum).GetField(((TaskStatusEnum)item).ToString()); |
| | | DescriptionAttribute? description = fieldInfo.GetCustomAttribute<DescriptionAttribute>(); |
| | | if (description != null) |
| | | { |
| | |
| | | result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data }; |
| | | } |
| | | break; |
| | | case "inoutTypeEnum": |
| | | { |
| | | List<object> data = new List<object>(); |
| | | Type enumType = typeof(InoutTypeEnum); |
| | | |
| | | // 获取所有枚举成员的字段信息 |
| | | foreach (var field in enumType.GetFields(BindingFlags.Public | BindingFlags.Static)) |
| | | { |
| | | // 字段名称就是枚举成员的字符标识(如"StandardCount") |
| | | string enumName = field.Name; |
| | | |
| | | // 获取描述属性 |
| | | var descriptionAttr = field.GetCustomAttribute<DescriptionAttribute>(); |
| | | string description = descriptionAttr?.Description ?? enumName; |
| | | int enumValue = (int)field.GetValue(null); |
| | | |
| | | data.Add(new |
| | | { |
| | | key = enumName, // 使用枚举名称作为key |
| | | value = description, |
| | | enumValue = enumValue // 可选:保留整数value |
| | | }); |
| | | } |
| | | result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data }; |
| | | } |
| | | break; |
| | | case "takeStockStatusEnum": |
| | | { |
| | | List<object> data = new List<object>(); |
| | | Type type = typeof(TakeStockStatusEnum); |
| | | List<int> enums = Enum.GetValues(typeof(TakeStockStatusEnum)).Cast<int>().ToList(); |
| | | int index = 0; |
| | | foreach (var item in enums) |
| | | { |
| | | FieldInfo? fieldInfo = typeof(TakeStockStatusEnum).GetField(((TakeStockStatusEnum)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 "takeStockDetailStatusEnum": |
| | | { |
| | | List<object> data = new List<object>(); |
| | | Type type = typeof(TakeStockDetailStatusEnum); |
| | | List<int> enums = Enum.GetValues(typeof(TakeStockDetailStatusEnum)).Cast<int>().ToList(); |
| | | int index = 0; |
| | | foreach (var item in enums) |
| | | { |
| | | FieldInfo? fieldInfo = typeof(TakeStockDetailStatusEnum).GetField(((TakeStockDetailStatusEnum)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; |
| | | } |