From 70f22c9c06c7dfe2a2a83c0d2fcc79892dba7d8f Mon Sep 17 00:00:00 2001
From: hutongqing <hutongqing@hnkhzn.com>
Date: 星期三, 18 十二月 2024 17:08:29 +0800
Subject: [PATCH] 1

---
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_SystemService/Sys_DictionaryService.cs |  175 +++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 143 insertions(+), 32 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_SystemService/Sys_DictionaryService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_SystemService/Sys_DictionaryService.cs"
index 469aaf4..be7f5d1 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_SystemService/Sys_DictionaryService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_SystemService/Sys_DictionaryService.cs"
@@ -1,5 +1,6 @@
 锘縰sing Newtonsoft.Json;
 using OfficeOpenXml.FormulaParsing.Excel.Functions.Information;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
@@ -19,7 +20,9 @@
 using WIDESEA_Core.DB;
 using WIDESEA_Core.Enums;
 using WIDESEA_Core.Helper;
+using WIDESEA_Core.Utilities;
 using WIDESEA_DTO.System;
+using WIDESEA_IBasicRepository;
 using WIDESEA_ISystemRepository;
 using WIDESEA_ISystemService;
 using WIDESEA_Model.Models;
@@ -30,19 +33,31 @@
     {
         private readonly IUnitOfWorkManage _unitOfWorkManage;
         private readonly ICacheService _cacheService;
+        private readonly IBasicRepository _basicRepository;
+        private readonly ISys_RoleDataPermissionRepository _roleDataPermissionRepository;
 
-        public Sys_DictionaryService(ISys_DictionaryRepository BaseDal, IUnitOfWorkManage unitOfWorkManage, ICacheService cacheService) : base(BaseDal)
+        public Sys_DictionaryService(ISys_DictionaryRepository BaseDal, IUnitOfWorkManage unitOfWorkManage, ICacheService cacheService, IBasicRepository basicRepository, ISys_RoleDataPermissionRepository roleDataPermissionRepository) : base(BaseDal)
         {
             _unitOfWorkManage = unitOfWorkManage;
             _cacheService = cacheService;
+            _basicRepository = basicRepository;
+            _roleDataPermissionRepository = roleDataPermissionRepository;
         }
 
         public ISys_DictionaryRepository Repository => BaseDal;
 
         public override WebResponseContent AddData(SaveModel saveModel)
         {
+            string validResult = typeof(Sys_Dictionary).ValidateDicInEntity(saveModel.MainData, true, TProperties);
+
+            if (!string.IsNullOrEmpty(validResult))
+            {
+                return WebResponseContent.Instance.Error(validResult);
+            }
+
             Sys_Dictionary dictionary = saveModel.MainData.DicToModel<Sys_Dictionary>();
-            _cacheService.Remove(dictionary.DicNo);
+            if (!string.IsNullOrEmpty(_cacheService.Get(dictionary.DicNo)))
+                _cacheService.Remove(dictionary.DicNo);
             return base.AddData(saveModel);
         }
 
@@ -80,12 +95,13 @@
                     DicNo = s.DicNo,
                     Config = s.Config,
                     //dbSql = s.Sql,
-                    Data = s.DicList.OrderByDescending(o => o.OrderNo).Select(list => new { key = list.DicValue, value = list.DicName })
+                    Data = s.DicList.OrderByDescending(o => o.OrderNo).Select(list => new { key = list.DicValue, value = list.DicName }),
+                    SaveCache = false
                 }).ToList();
 
                 foreach (var item in selectDics)
                 {
-                    if (!_cacheService.Exists(item.DicNo))
+                    if (!_cacheService.Exists(item.DicNo) && item.SaveCache)
                     {
                         _cacheService.Add(item.DicNo, item.Serialize());
                     }
@@ -122,8 +138,11 @@
 
                         foreach (var item in dics)
                         {
-                            dicList.Remove(item);
-                            cusDics.Add(item);
+                            if (dicNos.Contains(item) && !cacheDicNos.Contains(item))
+                            {
+                                dicList.Remove(item);
+                                cusDics.Add(item);
+                            }
                         }
 
                         foreach (var item in cusDics)
@@ -132,7 +151,7 @@
                             if (vueDictionaryDTO != null)
                             {
                                 vueDictionaryDTOs.Add(vueDictionaryDTO);
-                                if (!_cacheService.Exists(item))
+                                if (!_cacheService.Exists(item) && vueDictionaryDTO.SaveCache)
                                 {
                                     _cacheService.Add(item, vueDictionaryDTO.Serialize());
                                 }
@@ -423,25 +442,25 @@
                         {
                             List<object> data = new List<object>();
 
-                            {
-                                Type type = typeof(TaskTypeEnum);
-                                List<int> enums = Enum.GetValues(typeof(TaskTypeEnum)).Cast<int>().ToList();
-                                int index = 0;
-                                foreach (var item in enums)
-                                {
-                                    FieldInfo? fieldInfo = typeof(TaskTypeEnum).GetField(((TaskTypeEnum)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++;
-                                }
-                            }
+                            //{
+                            //    Type type = typeof(TaskTypeEnum);
+                            //    List<int> enums = Enum.GetValues(typeof(TaskTypeEnum)).Cast<int>().ToList();
+                            //    int index = 0;
+                            //    foreach (var item in enums)
+                            //    {
+                            //        FieldInfo? fieldInfo = typeof(TaskTypeEnum).GetField(((TaskTypeEnum)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 };
                         }
@@ -451,12 +470,12 @@
                             List<object> data = new List<object>();
 
                             {
-                                Type type = typeof(InTaskStatusEnum);
-                                List<int> enums = Enum.GetValues(typeof(InTaskStatusEnum)).Cast<int>().ToList();
+                                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(InTaskStatusEnum).GetField(((InTaskStatusEnum)item).ToString());
+                                    FieldInfo? fieldInfo = typeof(TaskInStatusEnum).GetField(((TaskInStatusEnum)item).ToString());
                                     DescriptionAttribute? description = fieldInfo.GetCustomAttribute<DescriptionAttribute>();
                                     if (description != null)
                                     {
@@ -471,12 +490,12 @@
                             }
 
                             {
-                                Type type = typeof(OutTaskStatusEnum);
-                                List<int> enums = Enum.GetValues(typeof(OutTaskStatusEnum)).Cast<int>().ToList();
+                                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(OutTaskStatusEnum).GetField(((OutTaskStatusEnum)item).ToString());
+                                    FieldInfo? fieldInfo = typeof(TaskOutStatusEnum).GetField(((TaskOutStatusEnum)item).ToString());
                                     DescriptionAttribute? description = fieldInfo.GetCustomAttribute<DescriptionAttribute>();
                                     if (description != null)
                                     {
@@ -564,6 +583,98 @@
                             result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data };
                         }
                         break;
+                    case "receiveOrderTypeEnum":
+                        {
+                            List<object> data = new List<object>();
+
+                            {
+                                Type type = typeof(ReceiveOrderTypeEnum);
+                                List<int> enums = Enum.GetValues(typeof(ReceiveOrderTypeEnum)).Cast<int>().ToList();
+                                int index = 0;
+                                foreach (var item in enums)
+                                {
+                                    FieldInfo? fieldInfo = typeof(ReceiveOrderTypeEnum).GetField(((ReceiveOrderTypeEnum)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 "authorityScope":
+                        {
+                            if (App.User.IsSuperAdmin)
+                            {
+                                List<Dt_Warehouse> warehouses = _basicRepository.WarehouseRepository.QueryData(x => true);
+                                var data = warehouses.Select(x => new { key = x.WarehouseId, value = x.WarehouseName });
+                                result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data };
+                            }
+                            else
+                            {
+                                List<Sys_RoleDataPermission> roleDataPermissions = _roleDataPermissionRepository.QueryData(x => x.RoleId == App.User.RoleId);
+                                var data = roleDataPermissions.Select(x => new { key = x.WarehouseId, value = x.WarehouseName });
+                                result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data };
+                            }
+                        }
+                        break;
+                    case "authorityScopes":
+                        {
+                            List<Sys_Role> roles = Repository.Db.Queryable<Sys_Role>().ToList();
+                            List<object> data = new List<object>();
+                            foreach (var item in roles)
+                            {
+                                List<Sys_RoleDataPermission> roleDataPermissions = _roleDataPermissionRepository.QueryData(x => x.RoleId == item.RoleId);
+                                string value = "";
+                                foreach (var roleDataPermission in roleDataPermissions)
+                                {
+                                    value += (roleDataPermission.WarehouseName + ",");
+                                }
+                                if (roleDataPermissions.Count > 0)
+                                    data.Add(new { key = item.RoleId, value = value.Substring(0, value.Length - 1) });
+                                else
+                                    data.Add(new { key = item.RoleId, value = "鏃犳潈闄�" });
+                            }
+                            data.Add(new { key = -1, value = "鏃犳潈闄�" });
+                            result = new VueDictionaryDTO { DicNo = key, Config = "", Data = data, SaveCache = false };
+                        }
+
+                        break;
+                    case "locationChangeType":
+                        {
+                            List<object> data = new List<object>();
+
+                            {
+                                Type type = typeof(LocationChangeType);
+                                List<int> enums = Enum.GetValues(typeof(LocationChangeType)).Cast<int>().ToList();
+                                int index = 0;
+                                foreach (var item in enums)
+                                {
+                                    FieldInfo? fieldInfo = typeof(LocationChangeType).GetField(((LocationChangeType)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