Browse Source

PostMarketingSalesGroupList 增加用户、公司条件

leiy 9 months ago
parent
commit
1118c81713

+ 16 - 1
OASystem/OASystem.Api/Controllers/StatisticsController.cs

@@ -2321,6 +2321,21 @@ FROM
 
             #endregion
 
+            string userSql = "";
+            List<int> userIds = new List<int>();
+            if (_dto.CompanyId > 0)
+            {
+                userIds = _sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.CompanyId == _dto.CompanyId).Select(it => it.Id).ToList();
+            }
+
+            if (_dto.UserId > 0) userIds.Add(_dto.UserId);
+
+            if (userIds.Count > 0)
+            {
+                userSql = @$" And di.JietuanOperator In ({string.Join(",",userIds)})";
+            }
+
+
             string beginDt = $"{_dto.BeginDt} 00:00:00", endDt = $"{_dto.EndDt} 23:59:59";
 
             string sql = string.Format(@$"Select
@@ -2339,7 +2354,7 @@ From(
 	DATEADD(DAY, 7, di.VisitEndDate) As CollectionDays
 	From Grp_DelegationInfo di
 	Left Join Sys_Users u On di.JietuanOperator = u.Id
-	Where di.Isdel = 0 
+	Where di.Isdel = 0 {userSql}
 	And VisitDate Between '{beginDt}' And  '{endDt}'
 ) Temp ");
 

+ 4 - 2
OASystem/OASystem.Api/Program.cs

@@ -120,12 +120,14 @@ builder.Services.AddScoped(options =>
         new ConnectionConfig() {
             ConfigId = DBEnum.OA2023DB,
             ConnectionString = _config.GetConnectionString("OA2023DB"),
-            DbType = DbType.SqlServer, IsAutoCloseConnection = true },
+            DbType = DbType.SqlServer, 
+            IsAutoCloseConnection = true },
         new ConnectionConfig()
         {
             ConfigId = DBEnum.OA2014DB,
             ConnectionString = _config.GetConnectionString("OA2014DB"),
-            DbType = DbType.SqlServer, IsAutoCloseConnection = true },
+            DbType = DbType.SqlServer, 
+            IsAutoCloseConnection = true },
     });
 });
 #endregion