Эх сурвалжийг харах

Merge branch 'release' of http://git.12345lm.cn/Fengwo/hotline into release

qinchaoyue 6 сар өмнө
parent
commit
c5e956cde7

+ 32 - 41
src/Hotline.Api/Controllers/OldHotlineController.cs

@@ -44,17 +44,17 @@ namespace Hotline.Api.Controllers
         private readonly IOrderScreenRepository _orderScreenRepository;
         private readonly IRepository<OrderSendBackAudit> _orderSendBackAuditRepository;
         private readonly IRepository<OrderVisitDetail> _orderVisitedDetailRepository;
-        private readonly ISessionContextProvider _sessionContextProvider;
+        private readonly ISessionContext _sessionContext;
         private readonly IRepository<Account> _accountRepository;
         private readonly IHttpClientFactory _httpClientFactory;
         private readonly ISystemSettingCacheManager _systemSettingCacheManager;
+        private readonly IOrderDomainService _orderDomainService;
 
         public OldHotlineController(IIdentityAppService identityAppService, ISystemLogApplication iSystemLogApplication,
             IOrderRepository orderRepository, IOrderVisitRepository orderVisitRepository,
             IOrderDelayRepository orderDelayRepository, IOrderScreenRepository orderScreenRepository,
             IRepository<OrderSendBackAudit> orderSendBackAuditRepository, IRepository<OrderVisitDetail> orderVisitedDetailRepository,
-            ISessionContextProvider sessionContextProvider,
-            IRepository<Account> accountRepository, IHttpClientFactory httpClientFactory, ISystemSettingCacheManager systemSettingCacheManager)
+            IRepository<Account> accountRepository, IHttpClientFactory httpClientFactory, ISystemSettingCacheManager systemSettingCacheManager, ISessionContext sessionContext, IOrderDomainService orderDomainService)
         {
             _identityAppService = identityAppService;
             _iSystemLogApplication = iSystemLogApplication;
@@ -64,10 +64,11 @@ namespace Hotline.Api.Controllers
             _orderScreenRepository = orderScreenRepository;
             _orderSendBackAuditRepository = orderSendBackAuditRepository;
             _orderVisitedDetailRepository = orderVisitedDetailRepository;
-            _sessionContextProvider = sessionContextProvider;
             _accountRepository = accountRepository;
             _httpClientFactory = httpClientFactory;
             _systemSettingCacheManager = systemSettingCacheManager;
+            _sessionContext = sessionContext;
+            _orderDomainService = orderDomainService;
         }
 
         /// <summary>
@@ -75,6 +76,7 @@ namespace Hotline.Api.Controllers
         /// </summary>
         /// <param name="dto"></param>
         /// <returns></returns>
+        [AllowAnonymous]
         [HttpPost("loing-oldtonew")]
         [LogFilter("",false)]
         public async Task<string> HotlineLoginOldToNew([FromBody] HotlineLoginOldToNewDto dto)
@@ -98,23 +100,12 @@ namespace Hotline.Api.Controllers
         /// <param name="dto"></param>
         /// <returns></returns>
         [HttpGet("ishas_canhandler")]
-        public async Task<bool> IsHasCanHandler([FromQuery] HotlineLoginOldToNewDto dto)
+        public async Task<bool> IsHasCanHandler()
         {
-            try
-            {
-                dto.UserName = RSA.RSADecrypt(dto.UserName, RSA_Create.RSA_PRIVATE_KEY, "PEM");
-            }
-            catch
-            {
-                throw UserFriendlyException.SameMessage("帐号解密失败");
-            }
-
-
             var isHas = false;
-
-            var (isAdmin, isCenter, user) = await _identityAppService.IsCheckAdmin(dto.UserName);
-            List<string> Roles = user.Roles.Select(x => x.Name).ToList();
-            if (isCenter)
+            var isAdmin = _orderDomainService.IsCheckAdmin();
+            var IsCenter = _sessionContext.OrgIsCenter;
+            if (IsCenter)
             {
                 #region 待办
                 //待办
@@ -122,9 +113,9 @@ namespace Hotline.Api.Controllers
                     .Queryable(hasHandled: false, isAdmin: isAdmin)
                     .Where(d => SqlFunc.Subqueryable<WorkflowStep>()
                         .Where(step => step.ExternalId == d.Id && step.Status != EWorkflowStepStatus.Handled &&
-                                       ((step.FlowAssignType == EFlowAssignType.User && !string.IsNullOrEmpty(step.HandlerId) && step.HandlerId == user.Id) ||
-                                        (step.FlowAssignType == EFlowAssignType.Org && !string.IsNullOrEmpty(step.HandlerOrgId) && step.HandlerOrgId == user.OrgId) ||
-                                        (step.FlowAssignType == EFlowAssignType.Role && !string.IsNullOrEmpty(step.RoleId) && Roles.Contains(step.RoleId))))
+                                       ((step.FlowAssignType == EFlowAssignType.User && !string.IsNullOrEmpty(step.HandlerId) && step.HandlerId == _sessionContext.RequiredUserId) ||
+                                        (step.FlowAssignType == EFlowAssignType.Org && !string.IsNullOrEmpty(step.HandlerOrgId) && step.HandlerOrgId == _sessionContext.RequiredOrgId) ||
+                                        (step.FlowAssignType == EFlowAssignType.Role && !string.IsNullOrEmpty(step.RoleId) && _sessionContext.Roles.Contains(step.RoleId))))
                         .Any())
                     .Includes(d => d.OrderSpecials)
                     .Where(d => d.Status != EOrderStatus.WaitForAccept && d.Status != EOrderStatus.BackToUnAccept && d.Status != EOrderStatus.SpecialToUnAccept && d.Status != EOrderStatus.HandOverToUnAccept)
@@ -169,7 +160,7 @@ namespace Hotline.Api.Controllers
                 #region 回访待办
                 //回访待办
                 isHas = await _orderVisitRepository.Queryable()
-                    .AnyAsync(d => (d.VisitState == EVisitState.WaitForVisit || d.VisitState == EVisitState.NoSatisfiedWaitForVisit) && d.EmployeeId == user.Id);
+                    .AnyAsync(d => (d.VisitState == EVisitState.WaitForVisit || d.VisitState == EVisitState.NoSatisfiedWaitForVisit) && d.EmployeeId == _sessionContext.RequiredUserId);
 
                 //回访待办是否有数据
                 if (isHas)
@@ -204,12 +195,12 @@ namespace Hotline.Api.Controllers
 
                 #region 部门即将超期
                 //部门即将超期
-                isHas = await _orderRepository.Queryable(canView: !isCenter)
+                isHas = await _orderRepository.Queryable(canView: !IsCenter)
                 .AnyAsync(d => SqlFunc.Subqueryable<WorkflowStep>()
                         .Where(step => step.ExternalId == d.Id && step.Status != EWorkflowStepStatus.Handled &&
-                                       ((step.FlowAssignType == EFlowAssignType.User && !string.IsNullOrEmpty(step.HandlerId) && step.HandlerId == user.Id) ||
-                                        (step.FlowAssignType == EFlowAssignType.Org && !string.IsNullOrEmpty(step.HandlerOrgId) && step.HandlerOrgId == user.OrgId) ||
-                                        (step.FlowAssignType == EFlowAssignType.Role && !string.IsNullOrEmpty(step.RoleId) && Roles.Contains(step.RoleId))))
+                                       ((step.FlowAssignType == EFlowAssignType.User && !string.IsNullOrEmpty(step.HandlerId) && step.HandlerId == _sessionContext.RequiredUserId) ||
+                                        (step.FlowAssignType == EFlowAssignType.Org && !string.IsNullOrEmpty(step.HandlerOrgId) && step.HandlerOrgId == _sessionContext.RequiredOrgId) ||
+                                        (step.FlowAssignType == EFlowAssignType.Role && !string.IsNullOrEmpty(step.RoleId) && _sessionContext.Roles.Contains(step.RoleId))))
                         .Any()
                     && d.Status < EOrderStatus.Filed && DateTime.Now > d.NearlyExpiredTime && DateTime.Now < d.ExpiredTime);
 
@@ -224,7 +215,7 @@ namespace Hotline.Api.Controllers
                 //甄别待审批
                 isHas = await _orderScreenRepository.Queryable(hasHandled: !true, isAdmin: isAdmin)
                     .Includes(d => d.Order)
-                    .Includes(d => d.ScreenDetails.Where(sd => sd.AuditUserId == user.Id).OrderByDescending(sd => sd.AuditTime).Take(1).ToList())
+                    .Includes(d => d.ScreenDetails.Where(sd => sd.AuditUserId == _sessionContext.RequiredUserId).OrderByDescending(sd => sd.AuditTime).Take(1).ToList())
                     .AnyAsync(d => (d.Status == EScreenStatus.Apply || d.Status == EScreenStatus.Approval || (d.Status == EScreenStatus.SendBack && d.SendBackApply == false)));
 
                 //甄别待审批是否有数据
@@ -238,7 +229,7 @@ namespace Hotline.Api.Controllers
                 //退回待审批
                 isHas = await _orderSendBackAuditRepository.Queryable()
                     .Where(d => d.State == ESendBackAuditState.Apply)
-                    .WhereIF(Roles.Contains("role_sysadmin") == false, x => x.SendBackOrgId == user.Id) // 123 系统管理员;
+                    .WhereIF(_sessionContext.Roles.Contains("role_sysadmin") == false, x => x.SendBackOrgId == _sessionContext.RequiredUserId) // 123 系统管理员;
                     .AnyAsync();
 
                 if (isHas)
@@ -255,9 +246,9 @@ namespace Hotline.Api.Controllers
                     .Queryable(hasHandled: false, isAdmin: isAdmin)
                     .Where(d => SqlFunc.Subqueryable<WorkflowStep>()
                         .Where(step => step.ExternalId == d.Id && step.Status != EWorkflowStepStatus.Handled &&
-                                       ((step.FlowAssignType == EFlowAssignType.User && !string.IsNullOrEmpty(step.HandlerId) && step.HandlerId == user.Id) ||
-                                        (step.FlowAssignType == EFlowAssignType.Org && !string.IsNullOrEmpty(step.HandlerOrgId) && step.HandlerOrgId == user.OrgId) ||
-                                        (step.FlowAssignType == EFlowAssignType.Role && !string.IsNullOrEmpty(step.RoleId) && Roles.Contains(step.RoleId))))
+                                       ((step.FlowAssignType == EFlowAssignType.User && !string.IsNullOrEmpty(step.HandlerId) && step.HandlerId == _sessionContext.RequiredUserId) ||
+                                        (step.FlowAssignType == EFlowAssignType.Org && !string.IsNullOrEmpty(step.HandlerOrgId) && step.HandlerOrgId == _sessionContext.RequiredOrgId) ||
+                                        (step.FlowAssignType == EFlowAssignType.Role && !string.IsNullOrEmpty(step.RoleId) && _sessionContext.Roles.Contains(step.RoleId))))
                         .Any())
                     .Includes(d => d.OrderSpecials)
                     .Where(d => d.Status != EOrderStatus.WaitForAccept && d.Status != EOrderStatus.BackToUnAccept && d.Status != EOrderStatus.SpecialToUnAccept && d.Status != EOrderStatus.HandOverToUnAccept)
@@ -311,7 +302,7 @@ namespace Hotline.Api.Controllers
                 //甄别待审批
                 isHas = await _orderScreenRepository.Queryable(hasHandled: !true, isAdmin: isAdmin)
                     .Includes(d => d.Order)
-                    .Includes(d => d.ScreenDetails.Where(sd => sd.AuditUserId == user.Id).OrderByDescending(sd => sd.AuditTime).Take(1).ToList())
+                    .Includes(d => d.ScreenDetails.Where(sd => sd.AuditUserId == _sessionContext.RequiredUserId).OrderByDescending(sd => sd.AuditTime).Take(1).ToList())
                     .AnyAsync(d => (d.Status == EScreenStatus.Apply || d.Status == EScreenStatus.Approval || (d.Status == EScreenStatus.SendBack && d.SendBackApply == false)));
 
                 if (isHas)
@@ -341,7 +332,7 @@ namespace Hotline.Api.Controllers
                 .Includes(x => x.OrderScreens)
                 .Where(x => x.OrderScreens.Any(s => s.Status == EScreenStatus.SendBack && s.SendBackApply == true) || x.OrderScreens.Any(s => (s.Status != EScreenStatus.SendBack && s.SendBackApply != true)) == false)
                 .Where(x => x.OrderVisit.VisitState == EVisitState.Visited && x.OrderVisit.IsCanHandle)
-                .Where(x => x.VisitTarget == EVisitTarget.Org && x.VisitOrgCode == user.OrgId && (
+                .Where(x => x.VisitTarget == EVisitTarget.Org && x.VisitOrgCode == _sessionContext.RequiredUserId && (
                     SqlFunc.JsonField(x.OrgProcessingResults, "Key") == "1" ||
                     SqlFunc.JsonField(x.OrgProcessingResults, "Key") == "2" ||
                     SqlFunc.JsonField(x.OrgHandledAttitude, "Key") == "1" ||
@@ -359,7 +350,7 @@ namespace Hotline.Api.Controllers
                 //退回待审批
                 isHas = await _orderSendBackAuditRepository.Queryable()
                     .Where(d => d.State == ESendBackAuditState.Apply)
-                    .WhereIF(Roles.Contains("role_sysadmin") == false, x => x.SendBackOrgId == user.OrgId) // 123 系统管理员;
+                    .WhereIF(_sessionContext.Roles.Contains("role_sysadmin") == false, x => x.SendBackOrgId == _sessionContext.RequiredOrgId) // 123 系统管理员;
                     .AnyAsync();
                 if (isHas)
                 {
@@ -370,13 +361,13 @@ namespace Hotline.Api.Controllers
 
                 #region 部门即将超期
                 //部门即将超期
-                isHas = await _orderRepository.Queryable(canView: !isCenter)
+                isHas = await _orderRepository.Queryable(canView: !IsCenter)
                 .Includes(d => d.OrderDelays)
                 .Where(d => SqlFunc.Subqueryable<WorkflowStep>()
                         .Where(step => step.ExternalId == d.Id && step.Status != EWorkflowStepStatus.Handled &&
-                        ((step.FlowAssignType == EFlowAssignType.User && !string.IsNullOrEmpty(step.HandlerId) && step.HandlerId == user.Id) ||
-                        (step.FlowAssignType == EFlowAssignType.Org && !string.IsNullOrEmpty(step.HandlerOrgId) && step.HandlerOrgId == user.OrgId) ||
-                                        (step.FlowAssignType == EFlowAssignType.Role && !string.IsNullOrEmpty(step.RoleId) && Roles.Contains(step.RoleId))))
+                        ((step.FlowAssignType == EFlowAssignType.User && !string.IsNullOrEmpty(step.HandlerId) && step.HandlerId == _sessionContext.RequiredUserId) ||
+                        (step.FlowAssignType == EFlowAssignType.Org && !string.IsNullOrEmpty(step.HandlerOrgId) && step.HandlerOrgId == _sessionContext.RequiredOrgId) ||
+                                        (step.FlowAssignType == EFlowAssignType.Role && !string.IsNullOrEmpty(step.RoleId) && _sessionContext.Roles.Contains(step.RoleId))))
                         .Any())
                     .Where(d => d.Status < EOrderStatus.Filed && DateTime.Now > d.NearlyExpiredTime && DateTime.Now < d.ExpiredTime)
                     .AnyAsync();
@@ -398,7 +389,7 @@ namespace Hotline.Api.Controllers
         [HttpGet("get_rsa_loginname")]
         public async Task<string> GetRASLoginName([FromQuery]bool IsUrlEncode)
         {
-            var account = await _accountRepository.GetAsync(_sessionContextProvider.SessionContext.RequiredUserId,HttpContext.RequestAborted);
+            var account = await _accountRepository.GetAsync(_sessionContext.RequiredUserId,HttpContext.RequestAborted);
             if (account == null)
             {
                 throw UserFriendlyException.SameMessage("获取用户加密失败");
@@ -424,7 +415,7 @@ namespace Hotline.Api.Controllers
         {
             var OldHotlineOrderState = _systemSettingCacheManager.GetSetting(SettingConstants.OldHotlineOrderState).SettingValue[0];
 
-            var account = await _accountRepository.GetAsync(_sessionContextProvider.SessionContext.RequiredUserId, HttpContext.RequestAborted);
+            var account = await _accountRepository.GetAsync(_sessionContext.RequiredUserId, HttpContext.RequestAborted);
             if (account == null)
             {
                 throw UserFriendlyException.SameMessage("获取用户加密失败");

+ 1 - 1
src/Hotline.Api/Controllers/OrderController.cs

@@ -879,7 +879,7 @@ public class OrderController : BaseController
             .WhereIF(dto.IsCountersign != null && dto.IsCountersign == true, d => d.Order.CounterSignType != null)
             .WhereIF(dto.IsCountersign != null && dto.IsCountersign == false, d => d.Order.CounterSignType == null)
             .WhereIF(dto.QuerySelf.HasValue && dto.QuerySelf.Value, d => d.EmployeeId == _sessionContext.RequiredUserId)
-            .WhereIF(!string.IsNullOrEmpty(dto.EmployeeName), d => !string.IsNullOrEmpty(d.EmployeeId) && d.Employee.Name == dto.EmployeeName)
+            .WhereIF(!string.IsNullOrEmpty(dto.EmployeeName), d => !string.IsNullOrEmpty(d.EmployeeId) && d.Employee.Name.Contains(dto.EmployeeName))
             .WhereIF(dto.IsProvince != null && dto.IsProvince == true, d => d.Order.IsProvince == true)
             .WhereIF(dto.IsProvince != null && dto.IsProvince == false, d => d.Order.IsProvince == false)
             .WhereIF(dto.IsEffectiveAiVisit != null, d => d.IsEffectiveAiVisit == dto.IsEffectiveAiVisit)