yuanrf 7 meses atrás
pai
commit
cdef536aac
1 arquivos alterados com 14 adições e 14 exclusões
  1. 14 14
      OASystem/OASystem.Api/Controllers/FinancialController.cs

+ 14 - 14
OASystem/OASystem.Api/Controllers/FinancialController.cs

@@ -4967,20 +4967,20 @@ Group by PriceType ", dto.diId);
                 return Ok(jw);
             }
 
-            //机票 职位表id 24
-            int[] AirTicket = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0 && x.JobPostId == 24).Select(x => x.Id).ToArray();
-
-            //酒店 职位表id 25
-            int[] Hotel = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0 && x.JobPostId == 25).Select(x => x.Id).ToArray();
-
-            //OP 职位表id 28 
-            int[] OP = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0 && x.JobPostId == 28).Select(x => x.Id).ToArray();
-
-            //商邀 职位表id 27
-            int[] Invitation = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0 && x.JobPostId == 27).Select(x => x.Id).ToArray();
-
-            //签证 职位表id 26
-            int[] Visa = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0 && x.JobPostId == 26).Select(x => x.Id).ToArray();
+            int[] jobPostIds = { 24, 25, 26, 27, 28 };
+
+            var userGroups = _sqlSugar.Queryable<Sys_Users>()
+                .Where(x => x.IsDel == 0 && jobPostIds.Contains(x.JobPostId))
+                .Select(x => new { x.Id, x.JobPostId })
+                .ToArray()
+                .GroupBy(x => x.JobPostId)
+                .ToDictionary(g => g.Key, g => g.Select(x => x.Id).ToArray());
+
+            int[] AirTicket = userGroups.ContainsKey(24) ? userGroups[24] : Array.Empty<int>();
+            int[] Hotel = userGroups.ContainsKey(25) ? userGroups[25] : Array.Empty<int>();
+            int[] OP = userGroups.ContainsKey(28) ? userGroups[28] : Array.Empty<int>();
+            int[] Invitation = userGroups.ContainsKey(27) ? userGroups[27] : Array.Empty<int>();
+            int[] Visa = userGroups.ContainsKey(26) ? userGroups[26] : Array.Empty<int>();
 
             //主管职位
             //string[] Manager = { "149", "283" };