Преглед изворни кода

优化审核人逻辑及出入境费用权限判断

在 `GroupsController.cs` 中调整审核人名称的逻辑,简化条件判断并重组代码结构。
修改 `SystemController.cs` 的构造函数参数以引入新依赖。
在 `EnterExitCostDraftRepository.cs` 和 `EnterExitCostRepository.cs` 中添加出入境费用查看权限的逻辑,针对特定用户和城市进行权限判断。
Lyyyi пре 2 недеља
родитељ
комит
dd575b9c0a

+ 11 - 7
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -3883,15 +3883,19 @@ FROM
                     /*
                     * 审核人
                     */
-                    string auditOperatorName = "Unknown";
-                    if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
-                    else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
-                    else
+                    string auditOperatorName = " - ";
+
+                    if (entity.IsAuditGM != 0)
                     {
-                        var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
-                        if (_adUser != null)
+                        if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
+                        else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
+                        else
                         {
-                            auditOperatorName = _adUser.CnName;
+                            var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
+                            if (_adUser != null)
+                            {
+                                auditOperatorName = _adUser.CnName;
+                            }
                         }
                     }
                     _detail.AuditOperatorName = auditOperatorName;

+ 0 - 1
OASystem/OASystem.Api/Controllers/SystemController.cs

@@ -40,7 +40,6 @@ namespace OASystem.API.Controllers
         private readonly List<int> _taskTypeList = new() { 6 };//任务通知 TaskNotification
         private readonly ApprovalProcessRepository _approvalProcessRep;
 
-
         public SystemController(
             CompanyRepository syscom,
             DepartmentRepository sysDepRep,

+ 32 - 4
OASystem/OASystem.Infrastructure/Repositories/Groups/EnterExitCostDraftRepository.cs

@@ -1,16 +1,17 @@
-using OASystem.Domain.Dtos.Groups;
+using AutoMapper;
+using EyeSoft.Collections.Generic;
+using OASystem.Domain;
+using OASystem.Domain.Dtos.Groups;
 using OASystem.Domain.Entities.Groups;
 using OASystem.Domain.ViewModels.Groups;
-using OASystem.Domain;
 using OASystem.Infrastructure.Repositories.System;
 using OASystem.Infrastructure.Tools;
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
+using System.Text.RegularExpressions;
 using System.Threading.Tasks;
-using AutoMapper;
-using EyeSoft.Collections.Generic;
 
 namespace OASystem.Infrastructure.Repositories.Groups
 {
@@ -111,6 +112,33 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 feeBasePermIds.AddRange(intlDplmcyBasePerm.Select(x => x.Id).ToList());
             }
 
+            /*
+             * 市场部 朱姝 默认添加贵州、重庆、云南的出入境费用查看权限
+             */
+            if (currUserId == 380)
+            {
+                var cityPerm = new List<string>()
+                {
+                    "贵州", "重庆", "云南"
+                };
+                var draftInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(x => x.Id == draftId && x.IsDel == 0);
+                if (draftInfo != null)
+                {
+                    //1.通过团组名称判断是否包含城市
+                    if (cityPerm.Any(x => draftInfo.DraftName.Contains(x)))
+                    {
+                        feeBasePermIds.Add(currUserId);
+                    }
+                    //2.通过城市Id判断是否包含城市
+                    else
+                    {
+                        var draftProvince = await _sqlSugar.Queryable<Sys_Cities>()
+                                .FirstAsync(x => x.Id == draftInfo.ProvinceId && cityPerm.Contains(x.Name_CN) && x.IsDel == 0);
+                        if (draftProvince != null) feeBasePermIds.Add(currUserId);
+                    }
+                }
+            }
+
             if (feeBasePermIds.Any())
             {
                 var permissions = new List<Grp_EnterExitCostDraftPermission>();

+ 31 - 0
OASystem/OASystem.Infrastructure/Repositories/Groups/EnterExitCostRepository.cs

@@ -118,6 +118,37 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 feeBasePermIds.AddRange(intlDplmcyBasePerm.Select(x => x.Id).ToList());
             }
 
+            /*
+             * 市场部 朱姝 默认添加贵州、重庆、云南的出入境费用查看权限
+             */
+            if (currUserId == 380)
+            {
+                var cityPerm = new List<string>()
+                {
+                    "贵州", "重庆", "云南"
+                };
+                var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == groupId && x.IsDel == 0);
+                if (groupInfo != null)
+                {
+                    //1.通过团组名称判断是否包含城市
+                    if (cityPerm.Any(x => groupInfo.TeamName.Contains(x)))
+                    {
+                        feeBasePermIds.Add(currUserId);
+                    }
+                    //2.通过城市Id判断是否包含城市
+                    else 
+                    {
+                        var groupCity = await _sqlSugar.Queryable<Sys_Cities>().FirstAsync(x => x.Id == groupInfo.CityId && x.IsDel == 0);
+                        if (groupCity != null)
+                        {
+                            var groupProvince = await _sqlSugar.Queryable<Sys_Cities>()
+                                .FirstAsync(x => x.Id == groupCity.ParentId && cityPerm.Contains(x.Name_CN) && x.IsDel == 0);
+                            if (groupProvince != null) feeBasePermIds.Add(currUserId);
+                        }
+                    }    
+                }
+            }
+
             if (feeBasePermIds.Any())
             {
                 var permissions = new List<Grp_EnterExitCostPermission>();