From 6c663b92b0078aa89657df22ec188dff65599f04 Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期二, 21 十月 2025 17:24:38 +0800
Subject: [PATCH] 1
---
项目代码/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/System/Sys_DictionaryController.cs | 485 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 482 insertions(+), 3 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/System/Sys_DictionaryController.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/System/Sys_DictionaryController.cs"
index 78815e1..aab3422 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/System/Sys_DictionaryController.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/System/Sys_DictionaryController.cs"
@@ -1,19 +1,498 @@
-锘縩amespace WIDESEA_WMSServer.Controllers;
+锘縰sing Newtonsoft.Json;
+using System.ComponentModel;
+using System.Reflection;
+using WIDESEA_Common;
+using WIDESEA_Core.Caches;
+using WIDESEA_Core.Enums;
+
+namespace WIDESEA_WMSServer.Controllers;
[Route("api/Sys_Dictionary")]
[ApiController]
public class Sys_DictionaryController : ApiBaseController<ISys_DictionaryService, Sys_Dictionary>
{
private readonly IHttpContextAccessor _httpContextAccessor;
+ private readonly ICacheService _cacheService;
- public Sys_DictionaryController(ISys_DictionaryService service, IHttpContextAccessor httpContextAccessor) : base(service)
+ public Sys_DictionaryController(ISys_DictionaryService service, IHttpContextAccessor httpContextAccessor, ICacheService cacheService) : base(service)
{
_httpContextAccessor = httpContextAccessor;
+ _cacheService = cacheService;
}
[HttpPost, Route("GetVueDictionary"), AllowAnonymous]
public IActionResult GetVueDictionary([FromBody] string[] dicNos)
{
- return Content(Service.GetVueDictionary(dicNos).Serialize());
+ 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);
+
+ 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();
+
+ 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
+ {
+
+ }
+ return Json(vueDictionaryDTOs);
+ }
+ private VueDictionaryDTO GetVueDictionary(string key)
+ {
+ VueDictionaryDTO result = null;
+ try
+ {
+ switch (key)
+ {
+ case "taskType":
+ {
+ List<object> data = new List<object>();
+
+ #region TaskInboundTypeEnum
+ {
+ Type type = typeof(TaskInboundTypeEnum);
+ List<int> enums = Enum.GetValues(typeof(TaskInboundTypeEnum)).Cast<int>().ToList();
+ int index = 0;
+ foreach (var item in enums)
+ {
+ FieldInfo? fieldInfo = typeof(TaskInboundTypeEnum).GetField(((TaskInboundTypeEnum)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
+
+ #region TaskOutboundTypeEnum
+ {
+ Type type = typeof(TaskOutboundTypeEnum);
+ List<int> enums = Enum.GetValues(typeof(TaskOutboundTypeEnum)).Cast<int>().ToList();
+ int index = 0;
+ foreach (var item in enums)
+ {
+ FieldInfo? fieldInfo = typeof(TaskOutboundTypeEnum).GetField(((TaskOutboundTypeEnum)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
+
+ #region TaskRelocationTypeEnum
+ {
+ Type type = typeof(TaskRelocationTypeEnum);
+ List<int> enums = Enum.GetValues(typeof(TaskRelocationTypeEnum)).Cast<int>().ToList();
+ int index = 0;
+ foreach (var item in enums)
+ {
+ FieldInfo? fieldInfo = typeof(TaskRelocationTypeEnum).GetField(((TaskRelocationTypeEnum)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
+
+ #region TaskOtherTypeEnum
+ {
+ Type type = typeof(TaskOtherTypeEnum);
+ List<int> enums = Enum.GetValues(typeof(TaskOtherTypeEnum)).Cast<int>().ToList();
+ int index = 0;
+ foreach (var item in enums)
+ {
+ FieldInfo? fieldInfo = typeof(TaskOtherTypeEnum).GetField(((TaskOtherTypeEnum)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
+
+ #region TaskAGVCarryTypeEnum
+ {
+ Type type = typeof(TaskAGVCarryTypeEnum);
+ List<int> enums = Enum.GetValues(typeof(TaskAGVCarryTypeEnum)).Cast<int>().ToList();
+ int index = 0;
+ foreach (var item in enums)
+ {
+ FieldInfo? fieldInfo = typeof(TaskAGVCarryTypeEnum).GetField(((TaskAGVCarryTypeEnum)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
+
+ #region TaskAcrossFloorTypeEnum
+ {
+ Type type = typeof(TaskAcrossFloorTypeEnum);
+ List<int> enums = Enum.GetValues(typeof(TaskAcrossFloorTypeEnum)).Cast<int>().ToList();
+ int index = 0;
+ foreach (var item in enums)
+ {
+ FieldInfo? fieldInfo = typeof(TaskAcrossFloorTypeEnum).GetField(((TaskAcrossFloorTypeEnum)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 "taskState":
+ {
+ List<object> data = new List<object>();
+
+ #region TaskInStatusEnum
+ {
+ Type type = typeof(TaskInStatusEnum);
+ List<int> enums = Enum.GetValues(typeof(TaskInStatusEnum)).Cast<int>().ToList();
+ int index = 0;
+ foreach (var item in enums)
+ {
+ FieldInfo? fieldInfo = typeof(TaskInStatusEnum).GetField(((TaskInStatusEnum)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
+
+ #region TaskOutStatusEnum
+ {
+ Type type = typeof(TaskOutStatusEnum);
+ List<int> enums = Enum.GetValues(typeof(TaskOutStatusEnum)).Cast<int>().ToList();
+ int index = 0;
+ foreach (var item in enums)
+ {
+ FieldInfo? fieldInfo = typeof(TaskOutStatusEnum).GetField(((TaskOutStatusEnum)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
+
+ #region TaskRelocationStatusEnum
+ {
+ Type type = typeof(TaskRelocationStatusEnum);
+ List<int> enums = Enum.GetValues(typeof(TaskRelocationStatusEnum)).Cast<int>().ToList();
+ int index = 0;
+ foreach (var item in enums)
+ {
+ FieldInfo? fieldInfo = typeof(TaskRelocationStatusEnum).GetField(((TaskRelocationStatusEnum)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
+
+ #region TaskAGVCarryStatusEnum
+ {
+ Type type = typeof(TaskAGVCarryStatusEnum);
+ List<int> enums = Enum.GetValues(typeof(TaskAGVCarryStatusEnum)).Cast<int>().ToList();
+ int index = 0;
+ foreach (var item in enums)
+ {
+ FieldInfo? fieldInfo = typeof(TaskAGVCarryStatusEnum).GetField(((TaskAGVCarryStatusEnum)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
+
+ #region TaskAcrossFloorStatusEnum
+ {
+ Type type = typeof(TaskAcrossFloorStatusEnum);
+ List<int> enums = Enum.GetValues(typeof(TaskAcrossFloorStatusEnum)).Cast<int>().ToList();
+ int index = 0;
+ foreach (var item in enums)
+ {
+ FieldInfo? fieldInfo = typeof(TaskAcrossFloorStatusEnum).GetField(((TaskAcrossFloorStatusEnum)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 "StatusChangeType":
+ {
+ List<object> data = new List<object>();
+
+ #region StatusChangeTypeEnum
+ {
+ Type type = typeof(StatusChangeTypeEnum);
+ List<int> enums = Enum.GetValues(typeof(StatusChangeTypeEnum)).Cast<int>().ToList();
+ int index = 0;
+ foreach (var item in enums)
+ {
+ FieldInfo? fieldInfo = typeof(StatusChangeTypeEnum).GetField(((StatusChangeTypeEnum)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 "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;
+
+ }
+ return result;
+ }
+ catch (Exception ex)
+ {
+ return null;
+ }
}
}
\ No newline at end of file
--
Gitblit v1.9.3