Selaa lähdekoodia

Merge branch 'develop' of http://132.232.92.186:3000/XinXiBu/OA2023 into develop

Lyyyi 3 päivää sitten
vanhempi
commit
dcabd9d92a

+ 5 - 0
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -26734,6 +26734,11 @@ ORDER BY
             return Ok(JsonView(true, "SUCCESS!", count));
         }
 
+        /// <summary>
+        /// 会务成本权限分配
+        /// </summary>
+        /// <param name="Dto"></param>
+        /// <returns></returns>
         [HttpPost]
         public async Task<IActionResult> PermissionSetting(PermissionSettingDto Dto)
         {

+ 22 - 6
OASystem/OASystem.Infrastructure/Repositories/CRM/NewClientDataRepository.cs

@@ -38,6 +38,7 @@ using System.Xml.Linq;
 using System.Runtime.Serialization;
 using static Google.Protobuf.Reflection.SourceCodeInfo.Types;
 using static OASystem.Domain.Dtos.CRM.NewClientDataQueryDto;
+using Autofac;
 
 namespace OASystem.Infrastructure.Repositories.CRM
 {
@@ -48,12 +49,14 @@ namespace OASystem.Infrastructure.Repositories.CRM
     {
         private readonly IMapper _mapper;
         private readonly IRedisHelper _redisHelper;
-        
-        public NewClientDataRepository(SqlSugarClient sqlSugar, IMapper mapper) :
+        private readonly ILifetimeScope _scope;
+
+        public NewClientDataRepository(SqlSugarClient sqlSugar, IMapper mapper, ILifetimeScope scope) :
          base(sqlSugar)
         {
             _mapper = mapper;
             _redisHelper = RedisFactory.CreateRedisRepository();
+            this._scope = scope;
         }
 
         /// <summary>
@@ -95,9 +98,15 @@ namespace OASystem.Infrastructure.Repositories.CRM
                 return cachedData;
             }
 
-            // 缓存未命中,从数据库获取
-            var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
-            
+            var setDatas = new List<Sys_SetData>();
+            using var newScope = _scope.BeginLifetimeScope();
+            using (SqlSugarClient sc = newScope.Resolve<SqlSugarClient>())
+            {
+                setDatas = await sc.Queryable<Sys_SetData>()
+                .Where(x => x.IsDel == 0)
+                .ToListAsync();
+            }
+
             var dropdownData = new DropdownData();
             
             //负责人下拉框
@@ -122,6 +131,7 @@ namespace OASystem.Infrastructure.Repositories.CRM
             List<Sys_SetData> CustomerClass = setDatas
                 .Where(u => u.STid == 37 && u.IsDel == 0)
                 .ToList();
+
             foreach (Sys_SetData item in CustomerClass)
             {
                 customerClassList.Add(new DropdownItem
@@ -286,8 +296,14 @@ namespace OASystem.Infrastructure.Repositories.CRM
                     break;
             }
 
-            var rangeSetDataList = _sqlSugar.SqlQueryable<Sys_SetData>(setDataSql).Select(x => x.Id).ToList();
+            var rangeSetDataList = new List<int>();
+            using var newScope = _scope.BeginLifetimeScope();
+            using (SqlSugarClient sc = newScope.Resolve<SqlSugarClient>())
+            {
+                rangeSetDataList = sc.SqlQueryable<Sys_SetData>(setDataSql).Select(x => x.Id).ToList();
+            }
             
+
             // 缓存1小时
             await _redisHelper.StringSetAsync(cacheKey, rangeSetDataList, TimeSpan.FromHours(1));