Browse Source

团组操作
建团时 按岗位配团组模块操作权限

leiy 11 months ago
parent
commit
82b9dc7b19

+ 3 - 27
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -508,7 +508,7 @@ namespace OASystem.API.Controllers
         {
             try
             {
-                
+                await GeneralMethod.PostGroupAuthAddInit(dto.UserId, 100);
                 var groupData = await _groupRepository.GroupOperation(dto);
                 if (groupData.Code != 0)
                 {
@@ -524,6 +524,7 @@ namespace OASystem.API.Controllers
                     await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
 
                     //默认分配权限
+                    await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
 
                     //消息提示 王鸽 主管号
                     List<int> _managerIds = new List<int>() { 22, 32 };
@@ -543,7 +544,6 @@ namespace OASystem.API.Controllers
                         string title = $"新建团组";
                         string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
                         await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
-
                     }
 
                 }
@@ -633,29 +633,6 @@ namespace OASystem.API.Controllers
             }
         }
 
-        /// <summary>
-        /// 建团添加默认工作人员团组权限测试
-        /// </summary>
-        /// <param name="dto"></param>
-        /// <returns></returns>
-        [HttpPost]
-        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> PostGroupAuthAddInit(int userId, int diId)
-        {
-            try
-            {
-                GeneralMethod.PostGroupAuthAddInit(userId, diId);
-
-                return Ok(JsonView(true));
-            }
-            catch (Exception ex)
-            {
-
-                Logs(ex.Message);
-                return Ok(JsonView(false, ex.Message));
-            }
-        }
-
         /// <summary>
         /// 接团信息 操作(删除)
         /// </summary>
@@ -726,8 +703,6 @@ namespace OASystem.API.Controllers
             return Ok(JsonView(true, "操作成功!", groupData.Data));
         }
 
-
-
         /// <summary>
         /// 获取团组名称data  And 签证国别Data
         /// </summary>
@@ -746,6 +721,7 @@ namespace OASystem.API.Controllers
 
             return Ok(JsonView(groupData.Data));
         }
+       
         /// <summary>
         /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
         /// </summary>

+ 138 - 7
OASystem/OASystem.Api/OAMethodLib/GeneralMethod.cs

@@ -465,13 +465,144 @@ namespace OASystem.API.OAMethodLib
                 return result;
             }
 
-            //var depData = await _teamRateRep._sqlSugar.Queryable<Sys_Department>().Where(it => it.IsDel == 0 && it.CompanyId == companyId && it.DepName.Equals("国交部")).FirstAsync();
-            //if (depData != null)
-            //{
-            //    var userData = await _teamRateRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.CompanyId == companyId && it.DepId == depData.Id).ToListAsync();
-
-            //}
-
+            var userDatas = await _teamRateRep._sqlSugar
+                                              .Queryable<Sys_Users>()
+                                              .LeftJoin<Sys_Department>((su,sd) => su.DepId == sd.Id && sd.IsDel == 0)
+                                              .LeftJoin<Sys_JobPost>((su,sd,sjp) => su.JobPostId == sjp.Id && sjp.IsDel == 0)
+                                              .Where(su => su.IsDel == 0)
+                                              .Select((su,sd,sjp) => new {
+                                                  su.DepId,
+                                                  sd.DepName,
+                                                  su.JobPostId,
+                                                  sjp.JobName,
+                                                  su.Id,
+                                                  su.CnName
+                                              })
+                                              .ToListAsync();
+
+            /*
+             * 76  酒店预订  --> 国交部门 酒店 岗位
+             * 79  车/导游地接  --> 国交部门 OP 岗位
+             * 80  签证  --> 国交部门 签证 岗位
+             * 81  邀请/公务活动 --> 国交部门 商邀 岗位
+             * 82  团组客户保险 --> 国交部 经理,主管 岗位
+             * 85  机票预订  --> 国交部门 机票 岗位
+             * 98  其他款项  --> 总经办部门 总经理 岗位/国交部门(ALL) 岗位/财务部门(ALL) 岗位/策划部门(ALL) 岗位/人事部门 采购 岗位
+             * 1015 超支费用  --> 财务部门(ALL)岗位
+             */
+            List<Grp_GroupsTaskAssignment> _GroupsTaskAssignments = new List<Grp_GroupsTaskAssignment>();
+            // 76  酒店预订  --> 国交部门(7) 酒店(25) 岗位 
+            _GroupsTaskAssignments.AddRange(
+                userDatas
+                .Where(it => it.DepId == 7 && it.JobPostId == 25)
+                .Select(it => new Grp_GroupsTaskAssignment()
+                {
+                    DIId = diId,
+                    CTId = 76,
+                    UId = it.Id,
+                    CreateUserId = userId
+                }).ToList()
+            );
+
+            //79  车/导游地接  --> 国交部门(7) OP(28) 岗位
+            _GroupsTaskAssignments.AddRange(
+                userDatas.Where(it => it.DepId == 7 && it.JobPostId == 28)
+                .Select(it => new Grp_GroupsTaskAssignment()
+                {
+                    DIId = diId,
+                    CTId = 79,
+                    UId = it.Id,
+                    CreateUserId = userId
+                }).ToList()
+            );
+
+
+            //81  邀请/公务活动 --> 国交部门(7) 商邀(27) 岗位
+            _GroupsTaskAssignments.AddRange(
+                userDatas
+                .Where(it => it.DepId == 7 && it.JobPostId == 27)
+                .Select(it => new Grp_GroupsTaskAssignment()
+                {
+                    DIId = diId,
+                    CTId = 81,
+                    UId = it.Id,
+                    CreateUserId = userId
+                }).ToList()
+            );
+            
+            //80  签证  --> 国交部门(7) 签证(26) 岗位
+            _GroupsTaskAssignments.AddRange(
+                userDatas
+                .Where(it => it.DepId == 7 && it.JobPostId == 26)
+                .Select(it => new Grp_GroupsTaskAssignment()
+                {
+                    DIId = diId,
+                    CTId = 80,
+                    UId = it.Id,
+                    CreateUserId = userId
+                }).ToList()
+            );
+
+
+            //82  团组客户保险 --> 国交部(7) 经理(32),主管(22) 岗位
+            _GroupsTaskAssignments.AddRange(
+                userDatas
+                .Where(it => it.DepId == 7 && (it.JobPostId == 22 || it.JobPostId == 32))
+                .Select(it => new Grp_GroupsTaskAssignment()
+                {
+                    DIId = diId,
+                    CTId = 82,
+                    UId = it.Id,
+                    CreateUserId = userId
+                }).ToList()
+            );
+
+            //85  机票预订  --> 国交部门(7) 机票(24) 岗位
+            _GroupsTaskAssignments.AddRange(
+                userDatas
+                .Where(it => it.DepId == 7 && it.JobPostId == 24)
+                .Select(it => new Grp_GroupsTaskAssignment()
+                {
+                    DIId = diId,
+                    CTId = 85,
+                    UId = it.Id,
+                    CreateUserId = userId
+                }).ToList()
+            );
+
+
+            //98  其他款项  --> 总经办部门(1) 总经理(1) 岗位/国交部门(7)(ALL) 岗位/财务部门(3)(ALL) 岗位/策划部门(5)(ALL) 岗位/人事部门(4) 采购(74) 岗位
+            List<int> depIds = new List<int>() { 7,3,5 };
+            List<int> jobIds = new List<int>() { 1,74};
+            _GroupsTaskAssignments.AddRange(
+                userDatas
+                .Where(it => depIds.Contains(it.DepId) || jobIds.Contains(it.JobPostId))
+                .Select(it => new Grp_GroupsTaskAssignment()
+                    {
+                        DIId = diId,
+                        CTId = 98,
+                        UId = it.Id,
+                        CreateUserId = userId
+                    }).ToList()
+            );
+
+            //1015 超支费用  --> 财务部门(3)(ALL)岗位
+            _GroupsTaskAssignments.AddRange(
+                userDatas
+                .Where(it => it.DepId == 3)
+                .Select(it => new Grp_GroupsTaskAssignment()
+                {
+                    DIId = diId,
+                    CTId = 1015,
+                    UId = it.Id,
+                    CreateUserId = userId
+                }).ToList()
+            );
+
+            if (_GroupsTaskAssignments.Count > 0)
+            {
+                var addId =_teamRateRep._sqlSugar.Fastest<Grp_GroupsTaskAssignment>().PageSize(100000).BulkCopy(_GroupsTaskAssignments);
+            }
 
             result.Code = 0;
             result.Msg = string.Format(@"操作成功!");

+ 2 - 1
OASystem/OASystem.Domain/Entities/Groups/Grp_GroupsTaskAssignment.cs

@@ -35,8 +35,9 @@ namespace OASystem.Domain.Entities.Groups
 
         /// <summary>
         /// 启用标识
+        /// 默认启用  1 
         /// </summary>
         [SugarColumn(IsNullable = true, ColumnDataType = "int")]
-        public int IsEnable { get; set; }
+        public int IsEnable { get; set; } = 1;
     }
 }

+ 4 - 4
OASystem/OASystem.Infrastructure/Repositories/Groups/DelegationInfoRepository.cs

@@ -388,7 +388,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 {
                     dynamic? teamTypeData1 = null;
                     string teamTypeSql = string.Format(@"Select Id,Name From  Sys_SetData Where STid = {0} And IsDel = {1}", 10, 0);
-                    var teamTypeData = _sqlSugar.SqlQueryable<SetDataInfoView>(teamTypeSql).ToList(); ;  //团组分类 10
+                    var teamTypeData = await _sqlSugar.SqlQueryable<SetDataInfoView>(teamTypeSql).ToListAsync(); ;  //团组分类 10
                     if (teamTypeData.Count > 0)
                     {
                         teamTypeData1 = teamTypeData;
@@ -396,7 +396,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
 
                     dynamic? teamLevData1 = null;
                     string teamLevSql = string.Format(@"Select Id,Name From  Sys_SetData Where STid = {0} And IsDel = {1}", 56, 0);
-                    var teamLevData = _sqlSugar.SqlQueryable<SetDataInfoView>(teamLevSql).ToList(); ;  //团组等级 56
+                    var teamLevData = await _sqlSugar.SqlQueryable<SetDataInfoView>(teamLevSql).ToListAsync(); ;  //团组等级 56
                     if (teamLevData.Count > 0)
                     {
                         teamLevData1 = teamLevData;
@@ -404,7 +404,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
 
                     dynamic? userData1 = null;
                     string userSql = string.Format(@"Select Id,CnName From  Sys_Users Where IsDel = {0}", 0);
-                    var userData = _sqlSugar.SqlQueryable<UserNameView>(userSql).ToList(); 
+                    var userData = await _sqlSugar.SqlQueryable<UserNameView>(userSql).ToListAsync(); 
                     if (userData.Count > 0)
                     {
                         userData1 = userData;
@@ -413,7 +413,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     //客户单位数据源 来源市场客户资料
                     dynamic? clientData1 = null;
                     string clientSql = $@"Select Client,Contact,Telephone,WeChat From Crm_NewClientData Where IsDel = 0";
-                    var clientData = _sqlSugar.SqlQueryable<Crm_NewClientData>(clientSql).ToList();
+                    var clientData = await _sqlSugar.SqlQueryable<Crm_NewClientData>(clientSql).ToListAsync();
                     if (clientData.Count > 0)
                     {
                         clientData1 = clientData.Select(it => new { it.Client,it.Contact,it.Telephone,it.Wechat }).ToList();