From b7da1f32d5d9997378b5ac535593a3f6144af46b Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期三, 15 十月 2025 17:15:38 +0800
Subject: [PATCH] 新增AGV与堆垛机移库判断及缓存优化
---
项目代码/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/System/Sys_DictionaryController.cs | 338 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 335 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..aa8a92b 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,351 @@
-锘縩amespace WIDESEA_WMSServer.Controllers;
+锘縰sing Newtonsoft.Json;
+using System.ComponentModel;
+using System.Reflection;
+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;
+ }
+ return result;
+ }
+ catch (Exception ex)
+ {
+ return null;
+ }
}
}
\ No newline at end of file
--
Gitblit v1.9.3