瀏覽代碼

优化BI所有接口的,站点的参数信息,并添加BI的Blob访问文件

Li 3 年之前
父節點
當前提交
64c1268538
共有 33 個文件被更改,包括 643 次插入201 次删除
  1. 4 1
      TEAMModelBI/Controllers/BIAbility/AbilityMgmtController.cs
  2. 4 1
      TEAMModelBI/Controllers/BIAbility/AbilityTaskMgmtController.cs
  3. 84 32
      TEAMModelBI/Controllers/BIHome/HomeStatisController.cs
  4. 11 3
      TEAMModelBI/Controllers/BISchool/AreaRelevantController.cs
  5. 38 12
      TEAMModelBI/Controllers/BISchool/BatchAreaController.cs
  6. 43 14
      TEAMModelBI/Controllers/BISchool/BatchSchoolController.cs
  7. 5 0
      TEAMModelBI/Controllers/BISchool/ProductController.cs
  8. 6 1
      TEAMModelBI/Controllers/BISchool/RoomController.cs
  9. 43 5
      TEAMModelBI/Controllers/BISchool/SchoolController.cs
  10. 7 1
      TEAMModelBI/Controllers/BIStudent/StuActivityController.cs
  11. 4 0
      TEAMModelBI/Controllers/BIStudent/StudentController.cs
  12. 9 1
      TEAMModelBI/Controllers/BITeacher/TeacherController.cs
  13. 34 1
      TEAMModelBI/Controllers/BITest/TestController.cs
  14. 29 3
      TEAMModelBI/Controllers/Census/ActivitySticsController.cs
  15. 5 1
      TEAMModelBI/Controllers/Census/BlobLogController.cs
  16. 16 0
      TEAMModelBI/Controllers/Census/ItemSticsController.cs
  17. 28 2
      TEAMModelBI/Controllers/Census/LessonSticsController.cs
  18. 21 5
      TEAMModelBI/Controllers/Census/PaperController.cs
  19. 15 2
      TEAMModelBI/Controllers/Census/ProductStatisController.cs
  20. 15 2
      TEAMModelBI/Controllers/Census/SchoolController.cs
  21. 5 0
      TEAMModelBI/Controllers/Census/StudyController.cs
  22. 1 0
      TEAMModelBI/Controllers/Core/BlobController.cs
  23. 17 3
      TEAMModelBI/Controllers/DingDingStruc/DDStructController.cs
  24. 65 8
      TEAMModelBI/Controllers/DingDingStruc/TableDingDingInfoController.cs
  25. 13 9
      TEAMModelBI/Controllers/LoginController.cs
  26. 10 0
      TEAMModelBI/Controllers/OperateRecord/OperateLogController.cs
  27. 6 0
      TEAMModelBI/DI/BIAzureStorage/BIAzureStorageBlobExtensions.cs
  28. 1 1
      TEAMModelBI/DI/BIAzureStorageFactoryExtensions.cs
  29. 1 2
      TEAMModelBI/Startup.cs
  30. 2 2
      TEAMModelBI/Tool/Extension/JwtAuth.cs
  31. 94 84
      TEAMModelBI/Tool/TimeHelper.cs
  32. 4 3
      TEAMModelBI/appsettings.Development.json
  33. 3 2
      TEAMModelBI/appsettings.json

+ 4 - 1
TEAMModelBI/Controllers/BIAbility/AbilityMgmtController.cs

@@ -17,6 +17,7 @@ using TEAMModelOS.SDK.Models.Cosmos.BI;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelBI.Filter;
 using TEAMModelBI.Tool.Extension;
+using TEAMModelBI.Tool.Context;
 
 namespace TEAMModelBI.Controllers.BIAbility
 {
@@ -154,7 +155,7 @@ namespace TEAMModelBI.Controllers.BIAbility
         [ProducesDefaultResponseType]
         [AuthToken(Roles = "admin,assist")]
         [HttpPost("upd-ability")]
-        public async Task<IActionResult> UpdAbility(Ability ability)
+        public async Task<IActionResult> UpdAbility(Ability ability, [FromHeader] string site)
         {
             try
             {
@@ -175,6 +176,8 @@ namespace TEAMModelBI.Controllers.BIAbility
                 else return Ok(new { state = 0, message = "参数异常" });
 
                 var azureClient = _azureCosmos.GetCosmosClient();
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    azureClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
                 string tempType = "";
                 //新增册别
                 if (string.IsNullOrEmpty(ability.id))

+ 4 - 1
TEAMModelBI/Controllers/BIAbility/AbilityTaskMgmtController.cs

@@ -18,6 +18,7 @@ using TEAMModelBI.Filter;
 using TEAMModelOS.SDK.Services;
 using TEAMModelBI.Tool.Extension;
 using TEAMModelOS.SDK.Extension;
+using TEAMModelBI.Tool.Context;
 
 namespace TEAMModelBI.Controllers.BIAbility
 {
@@ -120,12 +121,14 @@ namespace TEAMModelBI.Controllers.BIAbility
         [ProducesDefaultResponseType]
         [AuthToken(Roles= "admin,assist")]
         [HttpPost("upd-abilitytask")]
-        public async Task<IActionResult> UpdAbilityTask(RecordAbilityTask recordAbilityTask)//AbilityTask abilityTask) 
+        public async Task<IActionResult> UpdAbilityTask(RecordAbilityTask recordAbilityTask, [FromHeader] string site)//AbilityTask abilityTask) 
         {
             try
             {
                 var cosmosClient = _azureCosmos.GetCosmosClient();
                 var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
 
                 StringBuilder msgBuilder = new StringBuilder($"{_tmdName}【{_tmdId}】");
                 string type = null;

+ 84 - 32
TEAMModelBI/Controllers/BIHome/HomeStatisController.cs

@@ -14,6 +14,7 @@ using System.Text;
 using StackExchange.Redis;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelBI.Tool;
+using TEAMModelBI.Tool.Context;
 
 namespace TEAMModelBI.Controllers.BIHome
 {
@@ -43,11 +44,14 @@ namespace TEAMModelBI.Controllers.BIHome
         /// <returns></returns>
         [ProducesDefaultResponseType]
         [HttpPost("get-allnumber")]
-        public async Task<IActionResult> GetAllNumber()
+        public async Task<IActionResult> GetAllNumber(JsonElement jsonElement)
         {
             try
             {
+                jsonElement.TryGetProperty("site", out JsonElement site);
                 var client = _azureCosmos.GetCosmosClient();;
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    client = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
 
                 //查询全部教师人数
                 long teacherCount = await CommonFind.FindTotals(client, "select count(c.id) as totals from c where c.code='Base'", new List<string>() { "Teacher" });
@@ -79,6 +83,10 @@ namespace TEAMModelBI.Controllers.BIHome
             try
             {
                 if (!jsonElement.TryGetProperty("tmdid", out JsonElement _tmdid)) return BadRequest();
+                jsonElement.TryGetProperty("site", out JsonElement site);
+                var cosmosClient = _azureCosmos.GetCosmosClient(); 
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
 
                 int surveyJoinCount = 0;        //调查参加数量
                 int surveyDoneCount = 0;        //调查完成数量
@@ -94,7 +102,7 @@ namespace TEAMModelBI.Controllers.BIHome
                 int voteAreaDoneCount = 0;      //投票区域完成数量
 
                 //问卷调查
-                await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher")
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher")
                  .GetItemQueryIterator<StuActivity>(queryText: $"select c.owner, c.taskStatus from c where c.type = 'Survey' ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Activity-{_tmdid}") }))
                 {
                     if (!string.IsNullOrEmpty(item.owner))
@@ -119,7 +127,7 @@ namespace TEAMModelBI.Controllers.BIHome
                 }
 
                 //评量检测
-                await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher")
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher")
                   .GetItemQueryIterator<StuActivity>(queryText: $"select c.owner, c.taskStatus from c where c.type = 'ExamLite' ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Activity-{_tmdid}") }))
                 {
                     if (!string.IsNullOrEmpty(item.owner))
@@ -144,7 +152,7 @@ namespace TEAMModelBI.Controllers.BIHome
                 }
 
                 //投票活动
-                await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher")
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher")
                  .GetItemQueryIterator<StuActivity>(queryText: $"select c.owner, c.taskStatus from c where c.type = 'Vote' ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Activity-{_tmdid}") }))
                 {
                     if (!string.IsNullOrEmpty(item.owner))
@@ -184,11 +192,15 @@ namespace TEAMModelBI.Controllers.BIHome
         /// <returns></returns>
         [ProducesDefaultResponseType]
         [HttpPost("get-alldiststics")]
-        public async Task<IActionResult> GetAllDistStics() 
+        public async Task<IActionResult> GetAllDistStics(JsonElement jsonElement) 
         {
             try
             {
+                jsonElement.TryGetProperty("site", out JsonElement site);
                 var cosmosClient = _azureCosmos.GetCosmosClient();
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+
                 List<SticsCity> standards = new();
                 StringBuilder stringBuder = new("select c.id,c.name,c.provName,c.cityName,c.standard from c");
                 //查询省份区域
@@ -266,8 +278,11 @@ namespace TEAMModelBI.Controllers.BIHome
             try
             {
                 if(!jsonElement.TryGetProperty("cityCode", out JsonElement _cityCode))  return BadRequest();
-
+                jsonElement.TryGetProperty("site", out JsonElement site);
                 var cosmosClient = _azureCosmos.GetCosmosClient();
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+
                 List<string> areaStandard = new();
                 //查询省份区域
                 await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select c.name,c.cityName,c.standard from c where c.cityCode='{_cityCode}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
@@ -311,11 +326,15 @@ namespace TEAMModelBI.Controllers.BIHome
         /// <returns></returns>
         [ProducesDefaultResponseType]
         [HttpPost("get-provincestics")]
-        public async Task<IActionResult> GetProvinceStics() 
+        public async Task<IActionResult> GetProvinceStics(JsonElement jsonElement) 
         {
             try
             {
+                jsonElement.TryGetProperty("site", out JsonElement site);
                 var cosmosClient = _azureCosmos.GetCosmosClient();
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+
                 List<ProvinceStandard> standards = new();
                 await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryStreamIterator(queryText: $"select c.provCode,c.provName,c.standard from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
                 {
@@ -416,11 +435,14 @@ namespace TEAMModelBI.Controllers.BIHome
         /// <returns></returns>
         [ProducesDefaultResponseType]
         [HttpPost("get-cityschool")]
-        public async Task<IActionResult> GetCitySchool() 
+        public async Task<IActionResult> GetCitySchool(JsonElement jsonElement) 
         {
             try
             {
+                jsonElement.TryGetProperty("site", out JsonElement site);
                 var cosmosClient = _azureCosmos.GetCosmosClient();
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
 
                 List<CityStandard> standards = new();
                 //查询省份区域
@@ -486,7 +508,10 @@ namespace TEAMModelBI.Controllers.BIHome
             try
             {
                 if (!jsonElement.TryGetProperty("cityCode", out JsonElement _cityCode)) return BadRequest();
+                jsonElement.TryGetProperty("site", out JsonElement site);
                 var cosmosClient = _azureCosmos.GetCosmosClient();
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
 
                 List<DistrictStandard> districtStandards = new();
                 //查询省份区域
@@ -537,7 +562,6 @@ namespace TEAMModelBI.Controllers.BIHome
                     districtSticss.Add(districtStics);
                 }
                 return Ok(new { state = 200, districtSticss });
-
             }
             catch (Exception ex)
             {
@@ -558,7 +582,11 @@ namespace TEAMModelBI.Controllers.BIHome
         {
             try
             {
+                jsonElement.TryGetProperty("site", out JsonElement site);
                 var cosmosClient = _azureCosmos.GetCosmosClient();
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+
                 List<AllCityStics> tempAllCityStics = new();
                 //查询省份区域
                 await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select c.id,c.name,c.cityCode,c.cityName,c.standard from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
@@ -641,7 +669,6 @@ namespace TEAMModelBI.Controllers.BIHome
 
                                 //查询学校学生人数
                                 districtStics.studentCount += await CommonFind.FindTotals(cosmosClient, $"select count(c.id) as totals from c", "Student","Base");
-
                             }
                             tempDistrictStics.Add(districtStics);
                         }
@@ -666,15 +693,22 @@ namespace TEAMModelBI.Controllers.BIHome
         /// <returns></returns>
         [ProducesDefaultResponseType]
         [HttpPost("get-sticsbipower")]
-        public async Task<IActionResult> GetSticsBIPower()
+        public async Task<IActionResult> GetSticsBIPower(JsonElement jsonElement)
         {
             try
             {
+                jsonElement.TryGetProperty("site", out JsonElement site);
                 Dictionary<string, object> dic = new() { { "PartitionKey", "authority-bi" } };
+                var cosmosClient = _azureCosmos.GetCosmosClient();
                 var table = _azureStorage.GetCloudTableClient().GetTableReference("SchoolSetting");
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                {
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+                    table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("SchoolSetting");
+                }
+
                 List<Authority> authorityBIList = await table.FindListByDict<Authority>(dic);
 
-                var cosmosClient = _azureCosmos.GetCosmosClient();
                 List<PowerStics> powerStics = new(); 
                 foreach (var temp in authorityBIList)
                 {
@@ -708,10 +742,12 @@ namespace TEAMModelBI.Controllers.BIHome
         /// </summary>
         /// <returns></returns>
         [HttpPost("get-datatypestics")]
-        public async Task<IActionResult> GetDataTypeStics() 
+        public async Task<IActionResult> GetDataTypeStics(JsonElement jsonElement) 
         {
             try
             {
+                jsonElement.TryGetProperty("site", out JsonElement site);
+
                 long totalSize = 0; //总空间
                 long useSize = 0; //已使用空间                
                 long teach = 0;  //学校已经分配给所有教师的空间大小GB。
@@ -720,6 +756,13 @@ namespace TEAMModelBI.Controllers.BIHome
 
                 List<string> schoolId = new();
                 var cosmosClient = _azureCosmos.GetCosmosClient();
+                var redisClinet = _azureRedis.GetRedisClient(8);
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                {
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+                    redisClinet = _azureRedis.GetRedisClient(dbnum: 8, name: BIConst.GlobalSite);
+                }
+
 
                 //查询学校空间和学校Id
                 totalSize = await CommonFind.FindTotals(cosmosClient, "select sum(c.size) as totals from c", "School", "Base");
@@ -728,7 +771,7 @@ namespace TEAMModelBI.Controllers.BIHome
                 //查询学校已使用空间大小
                 foreach (var itemId in schoolId)
                 {
-                    await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT sum(c.size) as size FROM c ",
+                    await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT sum(c.size) as size FROM c ",
                         requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{itemId}") }))
                     {
                         var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -744,7 +787,7 @@ namespace TEAMModelBI.Controllers.BIHome
 
                     long blobsize = 0;
                     RedisValue value = default;
-                    value = _azureRedis.GetRedisClient(8).HashGet($"Blob:Record", itemId);
+                    value = redisClinet.HashGet($"Blob:Record", itemId);
                     if (value != default && !value.IsNullOrEmpty)
                     {
                         JsonElement record = value.ToString().ToObject<JsonElement>();
@@ -753,12 +796,16 @@ namespace TEAMModelBI.Controllers.BIHome
                     else
                     {
                         var client = _azureStorage.GetBlobContainerClient(itemId);
+                        if ($"{site}".Equals(BIConst.GlobalSite))
+                        {
+                            client = _azureStorage.GetBlobContainerClient(containerName: itemId, name: BIConst.GlobalSite);
+                        }
                         var size = await client.GetBlobsCatalogSize();
-                        await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", itemId, size.Item1);
+                        await redisClinet.HashSetAsync($"Blob:Record", itemId, size.Item1);
                         foreach (var key in size.Item2.Keys)
                         {
-                            await _azureRedis.GetRedisClient(8).SortedSetRemoveAsync($"Blob:Catalog:{itemId}", key);
-                            await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Blob:Catalog:{itemId}", key, size.Item2[key].HasValue ? size.Item2[key].Value : 0);
+                            await redisClinet.SortedSetRemoveAsync($"Blob:Catalog:{itemId}", key);
+                            await redisClinet.SortedSetIncrementAsync($"Blob:Catalog:{itemId}", key, size.Item2[key].HasValue ? size.Item2[key].Value : 0);
                         }
                         useSize += size.Item1.Value;
                         typeStics1 = typeStics1.Concat(size.Item2).GroupBy(g => g.Key).ToDictionary(k => k.Key, k => k.Sum(kvp => kvp.Value));  //lamebda表达式
@@ -766,7 +813,7 @@ namespace TEAMModelBI.Controllers.BIHome
                         continue;
                     }
 
-                    SortedSetEntry[] Scores = _azureRedis.GetRedisClient(8).SortedSetRangeByScoreWithScores($"Blob:Catalog:{itemId}");
+                    SortedSetEntry[] Scores = redisClinet.SortedSetRangeByScoreWithScores($"Blob:Catalog:{itemId}");
                     if (Scores != null)
                     {
                         Dictionary<string, double?> schoolStics = new(); //学校空间
@@ -786,12 +833,16 @@ namespace TEAMModelBI.Controllers.BIHome
                     else
                     {
                         var client = _azureStorage.GetBlobContainerClient(itemId);
+                        if ($"{site}".Equals(BIConst.GlobalSite))
+                        {
+                            client = _azureStorage.GetBlobContainerClient(containerName: itemId, name: BIConst.GlobalSite);
+                        }
                         var size = await client.GetBlobsCatalogSize();
-                        await _azureRedis.GetRedisClient(8).HashSetAsync($"Blob:Record", itemId, size.Item1);
+                        await redisClinet.HashSetAsync($"Blob:Record", itemId, size.Item1);
                         foreach (var key in size.Item2.Keys)
                         {
-                            await _azureRedis.GetRedisClient(8).SortedSetRemoveAsync($"Blob:Catalog:{itemId}", key);
-                            await _azureRedis.GetRedisClient(8).SortedSetIncrementAsync($"Blob:Catalog:{itemId}", key, size.Item2[key].HasValue ? size.Item2[key].Value : 0);
+                            await redisClinet.SortedSetRemoveAsync($"Blob:Catalog:{itemId}", key);
+                            await redisClinet.SortedSetIncrementAsync($"Blob:Catalog:{itemId}", key, size.Item2[key].HasValue ? size.Item2[key].Value : 0);
                         }
 
                         useSize += size.Item1.Value;
@@ -955,15 +1006,22 @@ namespace TEAMModelBI.Controllers.BIHome
         /// </summary>
         /// <returns></returns>
         [HttpPost("get-teachetypestics")]
-        public async Task<IActionResult> GetTeachDataTypeStics() 
+        public async Task<IActionResult> GetTeachDataTypeStics(JsonElement jsonElement) 
         {
             try
             {
+                jsonElement.TryGetProperty("site", out JsonElement site);
                 long teacheSize = 0; //教师空间
                 long sizeT = 0; //教师空间
                 List<string> teacherId = new(); //教师Id集合
                 Dictionary<string, long> typeStics = new(); //所有类型
                 var cosmosClient = _azureCosmos.GetCosmosClient();
+                var redisClinet = _azureRedis.GetRedisClient(8);
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                {
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+                    redisClinet = _azureRedis.GetRedisClient(dbnum: 8, name: BIConst.GlobalSite);
+                }
 
                 //查询教师的大小和教师集合信息
                 await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"select c.id,c.size from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
@@ -979,7 +1037,7 @@ namespace TEAMModelBI.Controllers.BIHome
                 //查询教师已使用空间大小
                 foreach (var itemTeach in teacherId)
                 {
-                    RedisValue tempValue = _azureRedis.GetRedisClient(8).HashGet($"Blob:Record", itemTeach);
+                    RedisValue tempValue = redisClinet.HashGet($"Blob:Record", itemTeach);
                     if (!tempValue.IsNullOrEmpty)
                     {
                         sizeT += Convert.ToInt64(tempValue);
@@ -991,7 +1049,7 @@ namespace TEAMModelBI.Controllers.BIHome
                         //}
                     }
 
-                    SortedSetEntry[] tempSorted = await _azureRedis.GetRedisClient(8).SortedSetRangeByRankWithScoresAsync($"Blob:Catalog:{itemTeach}");
+                    SortedSetEntry[] tempSorted = await redisClinet.SortedSetRangeByRankWithScoresAsync($"Blob:Catalog:{itemTeach}");
                     if (tempSorted != null)
                     {
                         foreach (var itemSorted in tempSorted)
@@ -1011,11 +1069,8 @@ namespace TEAMModelBI.Controllers.BIHome
                 await _dingDing.SendBotMsg($"BI,{_option.Location}   /homestatis/get-datatypestics   \n  {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
                 return BadRequest();
             }
-
         }
 
-
-
         /// <summary>
         /// 存放的类型
         /// </summary>
@@ -1099,13 +1154,10 @@ namespace TEAMModelBI.Controllers.BIHome
             public string standard { get; set; }
         }
 
-
         public record PowerStics 
         {
             public string powerName { get; set; }
-
-            public int powerCount { get; set; }
-        
+            public int powerCount { get; set; }        
         }
 
         /// <summary>

+ 11 - 3
TEAMModelBI/Controllers/BISchool/AreaRelevantController.cs

@@ -8,6 +8,7 @@ using System.Linq;
 using System.Text.Json;
 using System.Threading.Tasks;
 using TEAMModelBI.Filter;
+using TEAMModelBI.Tool.Context;
 using TEAMModelBI.Tool.Extension;
 using TEAMModelOS.Models;
 using TEAMModelOS.SDK.DI;
@@ -48,8 +49,12 @@ namespace TEAMModelBI.Controllers.BISchool
             try
             {
                 jsonElement.TryGetProperty("areaId", out JsonElement _areaId);
-                var cosmosClient = _azureCosmos.GetCosmosClient();
-                List<JoinAreaSchool> joinAreaSchools = new List<JoinAreaSchool>();
+                jsonElement.TryGetProperty("site", out JsonElement site);
+                var cosmosClient = _azureCosmos.GetCosmosClient(); 
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+
+                List<JoinAreaSchool> joinAreaSchools = new();
                 string sqltxt = $"SELECT c.id,c.name,c.schoolCode,c.province,c.city,c.dist,c.picture,c.period,c.areaId,c.standard,c.manyAreas FROM c WHERE c.areaId='{_areaId}'";
 
                 if (!string.IsNullOrEmpty($"{_areaId}"))
@@ -114,10 +119,13 @@ namespace TEAMModelBI.Controllers.BISchool
                 jsonElement.TryGetProperty("areaId", out JsonElement areaId);
                 jsonElement.TryGetProperty("standard", out JsonElement standard);
                 jsonElement.TryGetProperty("isDefault", out JsonElement isDefault);
+                jsonElement.TryGetProperty("site", out JsonElement site);
 
                 var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
-
                 var cosmosClient = _azureCosmos.GetCosmosClient();
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+
                 School tempSchool = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>($"{schoolId}", new PartitionKey("Base"));
                 if (bool.Parse($"{isDefault}") == true)
                 {

+ 38 - 12
TEAMModelBI/Controllers/BISchool/BatchAreaController.cs

@@ -20,6 +20,7 @@ using TEAMModelOS.SDK.Models.Service;
 using TEAMModelBI.Filter;
 using TEAMModelBI.Tool.Extension;
 using TEAMModelBI.Tool;
+using TEAMModelBI.Tool.Context;
 
 namespace TEAMModelBI.Controllers.BISchool
 {
@@ -52,13 +53,20 @@ namespace TEAMModelBI.Controllers.BISchool
         /// <returns></returns>
         [ProducesDefaultResponseType]
         [HttpPost("get-areas")]
-        public async Task<IActionResult> GetArea()
+        public async Task<IActionResult> GetArea(JsonElement jsonElement)
         {
             try
             {
+                jsonElement.TryGetProperty("site", out JsonElement site);
                 List<RecArea> areas = new();
                 var table = _azureStorage.GetCloudTableClient().GetTableReference("IESLogin");
                 var azureClient = _azureCosmos.GetCosmosClient();
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                {
+                    azureClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+                    table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("IESLogin");
+                }
+
                 await foreach (var item in azureClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<RecArea>(queryText: $"select c.id,c.code,c.pk,c.name,c.provCode,c.provName,c.cityCode,c.cityName,c.standard,c.standardName,c.institution from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
                 {
                     areas.Add(item);
@@ -161,21 +169,30 @@ namespace TEAMModelBI.Controllers.BISchool
                 jsonElement.TryGetProperty("oldId", out JsonElement _oldId);
                 jsonElement.TryGetProperty("oldStandard", out JsonElement oldStandard);
                 jsonElement.TryGetProperty("oldName", out JsonElement oldName);
+                jsonElement.TryGetProperty("site", out JsonElement site);
 
                 var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
-                var table = _azureStorage.GetCloudTableClient().GetTableReference("IESLogin");
 
                 //操作记录实体
                 var tempStandard = !string.IsNullOrEmpty($"{oldStandard}") && !string.IsNullOrEmpty($"{_oldId}") ? $"{oldStandard}" : "standard2";
 
+                var table = _azureStorage.GetCloudTableClient().GetTableReference("IESLogin");
                 var cosmosClient = _azureCosmos.GetCosmosClient();//数据库连接
+                var serBusClient = _serviceBus.GetServiceBusClient();
+                var activeTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");//秘钥地址
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                {
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+                    table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("IESLogin");
+                    //serBusClient = _serviceBus.GetServiceBusClient(BIConst.GlobalSite);  //暂未确定使用默认
+                    //activeTask = _configuration.GetValue<string>("GlobalAzure:ServiceBus:ActiveTask");   //暂未确定使用默认
+                }
+
                 //查询新的是否存在
                 await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: $"select value(c) from c where c.standard='{standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
                 {
                     if (item.standard.Equals($"{standard}"))
-                    {
                         return Ok(new { state = 1, message = "新创区的standard已存在请检查" });
-                    }
                 }
 
                 //区级的ID
@@ -469,8 +486,9 @@ namespace TEAMModelBI.Controllers.BISchool
                 batchCopyFile.tmdName = $"{_tmdName}";
                 var messageBatchCopyFile = new ServiceBusMessage(batchCopyFile.ToJsonString());
                 messageBatchCopyFile.ApplicationProperties.Add("name", "CopyStandardFile");
-                var activeTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
-                await _serviceBus.GetServiceBusClient().SendMessageAsync(activeTask, messageBatchCopyFile);
+                //var activeTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
+                //await  _serviceBus.GetServiceBusClient().SendMessageAsync(activeTask, messageBatchCopyFile);
+                await serBusClient.SendMessageAsync(activeTask, messageBatchCopyFile);
 
                 //发送消息实体
                 Notification notification = new Notification
@@ -519,17 +537,26 @@ namespace TEAMModelBI.Controllers.BISchool
                 if (!jsonElement.TryGetProperty("newId", out JsonElement _newId)) return BadRequest();
                 if (!jsonElement.TryGetProperty("newStandard", out JsonElement _newStandard)) return BadRequest();
                 jsonElement.TryGetProperty("newName", out JsonElement newName);
+                jsonElement.TryGetProperty("site", out JsonElement site);
 
                 var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
+                //操作记录实体
+                string blobOrTable = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
                 var table = _azureStorage.GetCloudTableClient().GetTableReference("IESLogin");
+                var cosmosClient = _azureCosmos.GetCosmosClient();
+                var serBusClient = _serviceBus.GetServiceBusClient();
+                var activeTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");//秘钥地址
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                {
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+                    table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("IESLogin");
+                    //serBusClient = _serviceBus.GetServiceBusClient(BIConst.GlobalSite);    //暂未确定使用默认 
+                    //activeTask = _configuration.GetValue<string>("GlobalAzure:ServiceBus:ActiveTask");  //暂未确定使用默认
+                }
 
                 //保存引用记录
                 await table.SaveOrUpdate<AreaQuoteRecord>(new AreaQuoteRecord() { PartitionKey = "QuoteRecord", RowKey = $"{DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}", areaId = $"{_oldId}", quoteId = $"{_newId}", quoteName = $"{newName}", standard = $"{_newStandard}" });
 
-                //操作记录实体
-                string blobOrTable = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString();
-                var cosmosClient = _azureCosmos.GetCosmosClient();
-
                 List<string> abilityIds = new List<string>();  //册别的ID集合
 
                 //查询册别信息
@@ -706,8 +733,7 @@ namespace TEAMModelBI.Controllers.BISchool
                 batchCopyFile.tmdName = $"{_tmdName}";
                 var messageBatchCopyFile = new ServiceBusMessage(batchCopyFile.ToJsonString());
                 messageBatchCopyFile.ApplicationProperties.Add("name", "CopyStandardFile");   //Function暂时还未写
-                var activeTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
-                await _serviceBus.GetServiceBusClient().SendMessageAsync(activeTask, messageBatchCopyFile);  //先执行删除操作,在执行复制
+                await serBusClient.SendMessageAsync(activeTask, messageBatchCopyFile);  //先执行删除操作,在执行复制
 
                 //发送消息实体
                 Notification notification = new Notification

+ 43 - 14
TEAMModelBI/Controllers/BISchool/BatchSchoolController.cs

@@ -26,6 +26,7 @@ using TEAMModelBI.Filter;
 using TEAMModelBI.Tool.Extension;
 using TEAMModelBI.Tool;
 using TEAMModelBI.Models;
+using TEAMModelBI.Tool.Context;
 
 namespace TEAMModelBI.Controllers.BISchool
 {
@@ -60,10 +61,14 @@ namespace TEAMModelBI.Controllers.BISchool
         /// <returns></returns>
         [ProducesDefaultResponseType]
         [HttpPost("get-teacher-authoritybilist")]
-        public async Task<IActionResult> GetAuthorityBIList()
+        public async Task<IActionResult> GetAuthorityBIList(JsonElement jsonElement)
         {
+            jsonElement.TryGetProperty("site", out JsonElement site);
             Dictionary<string, object> dic = new Dictionary<string, object> { { "PartitionKey", "authority-bi" } };
             var table = _azureStorage.GetCloudTableClient().GetTableReference("SchoolSetting");
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("SchoolSetting");
+
             List<Authority> authorityBIList = await table.FindListByDict<Authority>(dic);
 
             return Ok(new { authorityBIList });
@@ -82,14 +87,17 @@ namespace TEAMModelBI.Controllers.BISchool
             {
                 if (!jsonElement.TryGetProperty("id", out JsonElement id)) return Ok(new { state = 1, message = "参数错误!" });
                 if (!jsonElement.TryGetProperty("schoolcode", out JsonElement schoolcode)) return Ok(new { state = 1, message = "参数错误!" });
+                jsonElement.TryGetProperty("site", out JsonElement site);
 
                 var client = _azureCosmos.GetCosmosClient();
                 string sqltxt = $"select * from c where c.id='{id}'";
-
                 List<string> roles = new List<string>();//角色列表
                 List<string> permissions = new List<string>();//权限列表
+                var cosmosClient = _azureCosmos.GetCosmosClient();
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
 
-                var schoolRoles = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{id}", new PartitionKey($"Teacher-{schoolcode}"));
+                var schoolRoles = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{id}", new PartitionKey($"Teacher-{schoolcode}"));
                 if (schoolRoles.Status == 200)
                 {
                     using var json = await JsonDocument.ParseAsync(schoolRoles.ContentStream);
@@ -132,13 +140,14 @@ namespace TEAMModelBI.Controllers.BISchool
             try
             {
                 var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
-
                 List<BISchool> schools = new List<BISchool>();
                 StringBuilder stringBuilder = new StringBuilder($"{_tmdName}【{_tmdId}】使用批量创校功能:");
+                var cosmosClient = _azureCosmos.GetCosmosClient();
+                if (foundSchools.site.Equals(BIConst.GlobalSite))
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
 
                 if (foundSchools.biSchools.Count > 0)
                 {
-                    var cosmosClient = _azureCosmos.GetCosmosClient();
                     foreach (BISchool bischool in foundSchools.biSchools)
                     {
                         List<string> scName = new();
@@ -321,7 +330,11 @@ namespace TEAMModelBI.Controllers.BISchool
             {
                 jsonElement.TryGetProperty("tmdId", out JsonElement tmdId);
                 jsonElement.TryGetProperty("schoolCode", out JsonElement _schoolCode);
-                var cosmosClient = _azureCosmos.GetCosmosClient();                
+                jsonElement.TryGetProperty("site", out JsonElement site);
+                var cosmosClient = _azureCosmos.GetCosmosClient();
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+
                 int? pageSize = null;      //默认不指定返回大小        
                 string continuationToken = string.Empty;     //返给前端分页token           
                 string pageToken = default;//接受前端的分页Tolen
@@ -465,6 +478,7 @@ namespace TEAMModelBI.Controllers.BISchool
         {
             try
             {
+                jsonElement.TryGetProperty("site", out JsonElement site);
                 string schoolId = (jsonElement.TryGetProperty("schoolId", out JsonElement _schoolId)) ? _schoolId.GetString() : string.Empty;
 
                 Dictionary<string, List<Dictionary<string, string>>> haveSchoolManger = new Dictionary<string, List<Dictionary<string, string>>>();
@@ -472,8 +486,10 @@ namespace TEAMModelBI.Controllers.BISchool
                 string managerWhereOption = (!string.IsNullOrWhiteSpace(schoolId)) ? $" AND c.code = 'Teacher-{schoolId}'" : string.Empty;
                 //查询学校的顾问
                 string managerSql = $"SELECT DISTINCT REPLACE(c.code, 'Teacher-', '') AS schoolId, c.id, c.name FROM c WHERE ARRAY_CONTAINS(c.roles, 'assist', true) AND c.pk = 'Teacher' AND c.status = 'join'{managerWhereOption}";
-                var cosmosClent = _azureCosmos.GetCosmosClient();
-                await foreach (var item in cosmosClent.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: managerSql, requestOptions: new QueryRequestOptions() { }))
+                var cosmosClient = _azureCosmos.GetCosmosClient();
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: managerSql, requestOptions: new QueryRequestOptions() { }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -500,7 +516,7 @@ namespace TEAMModelBI.Controllers.BISchool
                 //管理模组学校
                 List<string> baseModuleSchoos = new List<string>();
                 string baseWhereOption = (!string.IsNullOrEmpty(schoolId)) ? $" and c.id='{schoolId}'" : string.Empty;
-                await foreach (var item in cosmosClent.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c join serviceProduct in c.service.product where serviceProduct.prodCode = 'IPDYZYLC' {baseWhereOption}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Product") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c join serviceProduct in c.service.product where serviceProduct.prodCode = 'IPDYZYLC' {baseWhereOption}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Product") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -513,7 +529,7 @@ namespace TEAMModelBI.Controllers.BISchool
                 //学校信息
                 List<object> schools = new List<object>();
                 string schoolWhereOption = (!string.IsNullOrEmpty(schoolId)) ? $" where c.id='{schoolId}'" : string.Empty;
-                await foreach (var item in cosmosClent.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id,c.name,c.period,c.schoolCode,c.region,c.province,c.city,c.picture from c {schoolWhereOption}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id,c.name,c.period,c.schoolCode,c.region,c.province,c.city,c.picture from c {schoolWhereOption}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
                     foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
@@ -573,15 +589,18 @@ namespace TEAMModelBI.Controllers.BISchool
                 if (!jsonElement.TryGetProperty("scale", out JsonElement scale)) return BadRequest();
                 if (!jsonElement.TryGetProperty("assistId", out JsonElement _assistId)) return BadRequest();
                 if (!jsonElement.TryGetProperty("type", out JsonElement _type)) return BadRequest();
+                jsonElement.TryGetProperty("site", out JsonElement site);
 
                 var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
 
                 List<string> assistId = _assistId.ToObject<List<string>>();
                 //List<string> periodS = period.ToObject<List<string>>();
-
                 Dictionary<string, List<Dictionary<string, string>>> haveSchoolManger = new Dictionary<string, List<Dictionary<string, string>>>();
-
                 var cosmosClient = _azureCosmos.GetCosmosClient();
+
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+
                 School tempShool = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>($"{_schoolId}", new PartitionKey("Base"));
                 if (tempShool != null)
                 {
@@ -753,8 +772,12 @@ namespace TEAMModelBI.Controllers.BISchool
             try
             {
                 if (!jsonElement.TryGetProperty("dist", out JsonElement _dist)) return BadRequest();
+                jsonElement.TryGetProperty("site", out JsonElement site);
 
                 var cosmosClient = _azureCosmos.GetCosmosClient();
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+
                 string sqltxt = $"SELECT * FROM c where c.dist='{_dist}'";
 
                 List<School> schools = new List<School>();
@@ -783,10 +806,13 @@ namespace TEAMModelBI.Controllers.BISchool
         {
             //List<School> schools = new List<School>();
             List<AssistSchool> schoolAssists = new List<AssistSchool>();
-            var cosmosClient = _azureCosmos.GetCosmosClient();
             if (!jsonElement.TryGetProperty("endPosition", out JsonElement endPosition)) return BadRequest();
             if (!jsonElement.TryGetProperty("pageSize", out JsonElement pageSize)) return BadRequest();
+            jsonElement.TryGetProperty("site", out JsonElement site);
 
+            var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
             string sqltxt = $"SELECT * FROM c order by c.id offset {endPosition} limit {pageSize}";
 
             await foreach (var itemSchool in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
@@ -984,7 +1010,10 @@ namespace TEAMModelBI.Controllers.BISchool
             /// 语系
             /// </summary>
             public string lang { get; set; }
-
+            /// <summary>
+            /// 站点
+            /// </summary>
+            public string site { get; set; }
             /// <summary>
             /// 批量创校的数据结构
             /// </summary>

+ 5 - 0
TEAMModelBI/Controllers/BISchool/ProductController.cs

@@ -6,6 +6,7 @@ using Microsoft.Extensions.Options;
 using System.Collections.Generic;
 using System.Text.Json;
 using System.Threading.Tasks;
+using TEAMModelBI.Tool.Context;
 using TEAMModelOS.Models;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
@@ -45,8 +46,12 @@ namespace TEAMModelBI.Controllers.BISchool
         public async Task<IActionResult> GetSchoolSum(JsonElement jsonElement)
         {
             if (!jsonElement.TryGetProperty("schoolCode", out JsonElement schoolCode)) return BadRequest();
+            jsonElement.TryGetProperty("site", out JsonElement site);
             var clientContainer = _azureCosmos.GetCosmosClient();
 
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                clientContainer = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+
             List<SchoolProductSerial> serials = new List<SchoolProductSerial>(); //软体
             List<SchoolProductService> services = new List<SchoolProductService>(); //服务
             List<SchoolProductHard> hards = new List<SchoolProductHard>(); //硬体

+ 6 - 1
TEAMModelBI/Controllers/BISchool/RoomController.cs

@@ -8,6 +8,7 @@ using System.Text;
 using System.Text.Json;
 using System.Threading.Tasks;
 using TEAMModelBI.Filter;
+using TEAMModelBI.Tool.Context;
 using TEAMModelBI.Tool.Extension;
 using TEAMModelOS.Models;
 using TEAMModelOS.SDK.DI;
@@ -53,10 +54,14 @@ namespace TEAMModelBI.Controllers.BISchool
                 if (!jsonElement.TryGetProperty("roomId", out JsonElement roomId)) return BadRequest();
                 if (!jsonElement.TryGetProperty("roomCode", out JsonElement roomCode)) return BadRequest();
                 jsonElement.TryGetProperty("serial", out JsonElement serial);
+                jsonElement.TryGetProperty("site", out JsonElement site);
                 var s = string.IsNullOrEmpty($"{serial}") ? null : $"{serial}";
 
                 Room room = new Room();
-                var cosmosClient = _azureCosmos.GetCosmosClient();
+                var cosmosClient = _azureCosmos.GetCosmosClient(); 
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+
                 var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{roomId}", new PartitionKey($"{roomCode}"));
                 if (response.Status == 200)
                 {

+ 43 - 5
TEAMModelBI/Controllers/BISchool/SchoolController.cs

@@ -14,6 +14,7 @@ using System.Text.Json;
 using System.Threading.Tasks;
 using TEAMModelBI.Filter;
 using TEAMModelBI.Tool;
+using TEAMModelBI.Tool.Context;
 using TEAMModelBI.Tool.CosmosBank;
 using TEAMModelBI.Tool.Extension;
 using TEAMModelOS.Models;
@@ -62,7 +63,10 @@ namespace TEAMModelBI.Controllers.BISchool
             try
             {
                 jsonElement.TryGetProperty("areaId", out JsonElement areaId);
+                jsonElement.TryGetProperty("site", out JsonElement site);
                 var cosmosClient = _azureCosmos.GetCosmosClient();
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
                 //默认不指定返回大小
                 int? pageSize = null;
                 string continuationToken = string.Empty;
@@ -164,18 +168,21 @@ namespace TEAMModelBI.Controllers.BISchool
                 if (!jsonElement.TryGetProperty("schoolCode", out JsonElement _schoolCode)) return BadRequest();
                 if (!jsonElement.TryGetProperty("areaId", out JsonElement _areaId)) return BadRequest();
                 jsonElement.TryGetProperty("isDefault", out JsonElement isDefault);
+                jsonElement.TryGetProperty("site", out JsonElement site);
 
                 var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
 
                 List<string> schoolCodes = _schoolCode.ToObject<List<string>>();
 
-                var cosmosCliet = _azureCosmos.GetCosmosClient();
+                var cosmosClient = _azureCosmos.GetCosmosClient();
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
 
                 if (schoolCodes.Count > 0)
                 {
                     foreach (var tempCode in schoolCodes)
                     {
-                        School school = await cosmosCliet.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(tempCode, new PartitionKey("Base"));
+                        School school = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(tempCode, new PartitionKey("Base"));
                         if (school != null)
                         {
                             if (bool.Parse($"{isDefault}") == true)
@@ -195,7 +202,7 @@ namespace TEAMModelBI.Controllers.BISchool
                                 if (marea == null)
                                     school.manyAreas.Add(new ManyArea() { areaId = $"{_areaId}", standard = $"{standard}" });
                             }
-                            await cosmosCliet.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<School>(school, school.id, new PartitionKey(school.code));
+                            await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<School>(school, school.id, new PartitionKey(school.code));
                         }
                     }
                 }
@@ -223,9 +230,12 @@ namespace TEAMModelBI.Controllers.BISchool
             try
             {
                 if (!jsonElement.TryGetProperty("tmdId", out JsonElement tmdId)) return BadRequest();
+                jsonElement.TryGetProperty("site", out JsonElement site);
 
                 List<object> schools = new List<object>();
                 var cosmosClient = _azureCosmos.GetCosmosClient();
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
                 //List<string> schoolIds = new List<string>();
                 //string sqlTxt = $"SELECT DISTINCT REPLACE(c.code, 'Teacher-', '') AS schoolId FROM c WHERE c.pk = 'Teacher' AND c.status = 'join' AND ARRAY_CONTAINS(c.roles, 'assist', true) AND c.id='{tmdId}' ";
                 //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { }))
@@ -271,8 +281,11 @@ namespace TEAMModelBI.Controllers.BISchool
             try
             {
                 if (!jsonElement.TryGetProperty("schoolId", out JsonElement schoolId)) return BadRequest();
+                jsonElement.TryGetProperty("site", out JsonElement site);
 
                 var cosmosClient = _azureCosmos.GetCosmosClient();
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
 
                 var rsponse = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{schoolId}", new PartitionKey("Base"));
                 if (rsponse.Status == 200)
@@ -386,7 +399,10 @@ namespace TEAMModelBI.Controllers.BISchool
         public async Task<IActionResult> GetAssistSchoolSpace(JsonElement jsonElement)
         {
             if (!jsonElement.TryGetProperty("tmdId", out JsonElement tmdId)) return BadRequest();
+            jsonElement.TryGetProperty("site", out JsonElement site);
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
 
             List<string> schools = await CommonFind.FindSchoolIds(cosmosClient, $"{tmdId}");
             List<SchoolSpace> schoolSpaces = new();
@@ -496,8 +512,12 @@ namespace TEAMModelBI.Controllers.BISchool
             if (!jsonElement.TryGetProperty("school", out JsonElement _school)) return BadRequest();
             //if (!jsonElement.TryGetProperty("teacher", out JsonElement _teacher)) return BadRequest();
             if (!jsonElement.TryGetProperty("shiftTeacher", out JsonElement _shiftTeacher)) return BadRequest();
+            jsonElement.TryGetProperty("site", out JsonElement site);
 
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+
             SchoolTeacher schoolTeacher = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemAsync<SchoolTeacher>($"{_tmdId}", new PartitionKey($"Teacher-{_school}"));
             if (schoolTeacher.roles.IsNotEmpty() && schoolTeacher.roles.Contains("assist"))
             {
@@ -559,11 +579,14 @@ namespace TEAMModelBI.Controllers.BISchool
                 jsonElement.TryGetProperty("tmdId", out JsonElement tmdId);
                 if (!jsonElement.TryGetProperty("schoolIds", out JsonElement jsSchoolIds)) return BadRequest();
                 if (!jsonElement.TryGetProperty("busy", out JsonElement busy)) return BadRequest();
+                jsonElement.TryGetProperty("site", out JsonElement site);
 
                 List<string> schoolIds = jsSchoolIds.ToObject<List<string>>();
                 var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
                 var cosmosClient = _azureCosmos.GetCosmosClient();
                 string divide = _option.Location;
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
 
                 Dictionary<string, object> dic = new() { { "PartitionKey", $"{parKey}" } };
                 if (!string.IsNullOrEmpty($"{userId}"))
@@ -650,7 +673,10 @@ namespace TEAMModelBI.Controllers.BISchool
         {
             if (!jsonElement.TryGetProperty("schoolCode", out JsonElement schoolCode)) return BadRequest();
             if (!jsonElement.TryGetProperty("isAdmin", out JsonElement isAdmin)) return BadRequest();
+            jsonElement.TryGetProperty("site", out JsonElement site);
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
             List<SchoolTeacher> schoolTeachers = new List<SchoolTeacher>();
             //string sqlTxt = "select value(c) from c where array_contains(c.roles,'admin')";
             string sqlTxt = "select value(c) from c";
@@ -699,7 +725,10 @@ namespace TEAMModelBI.Controllers.BISchool
                 if (!jsonElement.TryGetProperty("manageId", out JsonElement _adminTmdId)) return BadRequest();
                 if (!jsonElement.TryGetProperty("manageName", out JsonElement _adminTmdName)) return BadRequest();
                 if (!jsonElement.TryGetProperty("schoolId", out JsonElement _schoolId)) return BadRequest();
+                jsonElement.TryGetProperty("site", out JsonElement site);
                 var cosmosClient = _azureCosmos.GetCosmosClient();
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
 
                 var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{_adminTmdId}", new PartitionKey($"Teacher-{_schoolId}"));
                 if (response.Status == 200)
@@ -761,9 +790,12 @@ namespace TEAMModelBI.Controllers.BISchool
             try
             {
                 if (!jsonElement.TryGetProperty("schoolId", out JsonElement schoolId)) return BadRequest();
+                jsonElement.TryGetProperty("site", out JsonElement site);
                 string _auth = HttpContext.GetXAuth("AuthToken");
                 var (tmdId, tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(_auth, _option);
                 var cosmosClient = _azureCosmos.GetCosmosClient();
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
                 StringBuilder msg = new();
                 List<DelSchoolRel> delSchoolRels = new();
 
@@ -827,7 +859,10 @@ namespace TEAMModelBI.Controllers.BISchool
         public async Task<IActionResult> GetSchool(JsonElement jsonElement)
         {
             jsonElement.TryGetProperty("schoolId", out JsonElement schoolId);
-            var clientCosmosDB = _azureCosmos.GetCosmosClient();
+            jsonElement.TryGetProperty("site", out JsonElement site);
+            var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
             StringBuilder sqlTxt = new StringBuilder("select * from c");
             if (!string.IsNullOrEmpty($"{schoolId}"))
             {
@@ -836,7 +871,7 @@ namespace TEAMModelBI.Controllers.BISchool
 
             List<School> schools = new();
 
-            await foreach (var item in clientCosmosDB.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
             {
                 using var json = await JsonDocument.ParseAsync(item.ContentStream);
                 if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -862,7 +897,10 @@ namespace TEAMModelBI.Controllers.BISchool
         {
             jsonElement.TryGetProperty("areaId", out JsonElement areaId);
             jsonElement.TryGetProperty("schoolId", out JsonElement schoolId);
+            jsonElement.TryGetProperty("site", out JsonElement site);
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
             long allSize = 0;    //全部大小
             int teacherSpace = 0;  //学校分配给教师的空间
             long useSize = 0;   //已使用大小 

+ 7 - 1
TEAMModelBI/Controllers/BIStudent/StuActivityController.cs

@@ -7,6 +7,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text.Json;
 using System.Threading.Tasks;
+using TEAMModelBI.Tool.Context;
 using TEAMModelOS.Models;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
@@ -38,11 +39,16 @@ namespace TEAMModelBI.Controllers.BIStudent
         /// <param name="jsonElement"></param>
         /// <returns></returns>
         [HttpPost("get-classIds")]
-        public async Task<IActionResult> CorrectActivityClassIds()
+        public async Task<IActionResult> CorrectActivityClassIds(JsonElement jsonElement)
         {
             try
             {
+                jsonElement.TryGetProperty("site", out JsonElement site);
                 var cosmosClient = _azureCosmos.GetCosmosClient();
+
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+
                 //string sqlTxt = "SELECT select c.id,c.code,c.classIds FROM c  where c.pk='Activity' and c.classIds <> []";
                 string sqlTxt = "select c.id,c.code,c.classIds from c where c.school='cswznb' and c.classIds <> []";
                 List<CorrectStu> correctStus = new List<CorrectStu>();

+ 4 - 0
TEAMModelBI/Controllers/BIStudent/StudentController.cs

@@ -5,6 +5,7 @@ using Microsoft.Extensions.Options;
 using System.Collections.Generic;
 using System.Text.Json;
 using System.Threading.Tasks;
+using TEAMModelBI.Tool.Context;
 using TEAMModelOS.Models;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Models;
@@ -38,7 +39,10 @@ namespace TEAMModelBI.Controllers.BIStudent
         {
             if (!jsonElement.TryGetProperty("studentId", out JsonElement studentId)) return BadRequest();
             jsonElement.TryGetProperty("code", out JsonElement code);
+            jsonElement.TryGetProperty("site", out JsonElement site);
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
             List<object> objs = new List<object>();
             await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(queryText: $"select value(c) from c where c.id='{studentId}'", requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
             {

+ 9 - 1
TEAMModelBI/Controllers/BITeacher/TeacherController.cs

@@ -9,6 +9,7 @@ using TEAMModelOS.Models;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models;
+using TEAMModelBI.Tool.Context;
 
 namespace TEAMModelBI.Controllers.BITeacher
 {
@@ -39,7 +40,11 @@ namespace TEAMModelBI.Controllers.BITeacher
         {
             jsonElement.TryGetProperty("tmdId", out JsonElement tmdId);
             jsonElement.TryGetProperty("schoolCode", out JsonElement schoolCode);
+            jsonElement.TryGetProperty("site", out JsonElement site);
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+            
             List<SchoolTeacher> teachers = new List<SchoolTeacher>();
             string sqlTxt = "";
             if (!string.IsNullOrEmpty($"{tmdId}")) 
@@ -81,8 +86,11 @@ namespace TEAMModelBI.Controllers.BITeacher
         {
             if (!jsonElement.TryGetProperty("teacherId", out JsonElement teacherId)) return BadRequest();
             jsonElement.TryGetProperty("code", out JsonElement code);
-            var cosmosClient = _azureCosmos.GetCosmosClient();
+            jsonElement.TryGetProperty("site", out JsonElement site);
 
+            var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
             List<object> objs = new List<object>();
 
             await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: $"select value(c) from c where c.id='{teacherId}'", requestOptions: string.IsNullOrEmpty($"{code}") ? new QueryRequestOptions() { } : new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))

+ 34 - 1
TEAMModelBI/Controllers/BITest/TestController.cs

@@ -46,6 +46,7 @@ using System.Net;
 using TEAMModelBI.Tool.CosmosBank;
 using System.Diagnostics;
 using StackExchange.Redis;
+using TEAMModelBI.Tool.Context;
 
 namespace TEAMModelBI.Controllers.BITest
 {
@@ -1271,8 +1272,19 @@ namespace TEAMModelBI.Controllers.BITest
         /// </summary>
         /// <returns></returns>
         [HttpPost("get-manydb")]
-        public async Task<IActionResult> GetMany()
+        public async Task<IActionResult> GetMany(JsonElement jsonElement)
         {
+            jsonElement.TryGetProperty("site", out JsonElement site);
+            var cosmosClient = _azureCosmos.GetCosmosClient();
+            var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
+            var redisClinet = _azureRedis.GetRedisClient(8);
+            if ($"{site}".Equals(BIConst.GlobalSite))
+            {
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+                table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("");
+                redisClinet = _azureRedis.GetRedisClient(dbnum: 8, name: BIConst.GlobalSite);
+            }
+
 
             #region  依赖注入的方式 
 
@@ -1359,6 +1371,27 @@ namespace TEAMModelBI.Controllers.BITest
             #endregion
         }
 
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="linqTestm"></param>
+        /// <param name="site"></param>
+        /// <returns></returns>
+        [HttpPost("parameter")]
+        public async Task<IActionResult> parameter(linqTest linqTestm, [FromHeader]string site)
+        {
+            var cosmosClient = _azureCosmos.GetCosmosClient();
+
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+            linqTest linqTest = new linqTest();
+            linqTest.id = linqTestm.id; linqTest.name = linqTestm.name;
+
+            var resp = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{linqTestm.id}", new PartitionKey("Base"));
+
+            return Ok(new { state = 200, linqTest,cosmosClient,site });
+        }
+
         public class linqTest
         {
             public string id{ get; set; }

+ 29 - 3
TEAMModelBI/Controllers/Census/ActivitySticsController.cs

@@ -16,6 +16,7 @@ using TEAMModelOS.SDK.Extension;
 using TEAMModelBI.Models;
 using TEAMModelOS.SDK;
 using TEAMModelBI.Tool.CosmosBank;
+using TEAMModelBI.Tool.Context;
 
 namespace TEAMModelBI.Controllers.Census
 {
@@ -49,13 +50,16 @@ namespace TEAMModelBI.Controllers.Census
         {
             jsonElement.TryGetProperty("tmdId", out JsonElement tmdId);
             if(!jsonElement.TryGetProperty("term", out JsonElement term)) return BadRequest();
+            jsonElement.TryGetProperty("site", out JsonElement site);
             long start = 0, end = 0;
             if (bool.Parse($"{term}") == true) 
             {
                 (start, end) = TimeHelper.GetTermStartOrEnd(DateTime.Now);
             }
             var cosmosClient = _azureCosmos.GetCosmosClient();
-            List<object> activityCount = new List<object>();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+             List<object> activityCount = new List<object>();
 
             if (!string.IsNullOrEmpty($"{tmdId}"))
             {
@@ -111,11 +115,14 @@ namespace TEAMModelBI.Controllers.Census
         /// </summary>
         /// <returns></returns>
         [HttpPost("get-allactivity")]
-        public async Task<IActionResult> GetAllActivity() 
+        public async Task<IActionResult> GetAllActivity(JsonElement jsonElement) 
         {
             try
             {
+                jsonElement.TryGetProperty("site", out JsonElement site);
                 var cosmosClient = _azureCosmos.GetCosmosClient();
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
                 List<KeyValuePair<string, long>> typeCount = new List<KeyValuePair<string, long>>();
                 foreach (var type in StaticValue.activityTypes)
                 {
@@ -146,7 +153,11 @@ namespace TEAMModelBI.Controllers.Census
         public async Task<IActionResult> GetAssistSchoolActivity(JsonElement jsonElement)
         {
             if (!jsonElement.TryGetProperty("tmdId", out JsonElement tmdId)) return BadRequest();
+            jsonElement.TryGetProperty("site", out JsonElement site);
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+
             List<string> schoolIds = await CommonFind.FindSchoolIds(cosmosClient, $"{tmdId}");
 
             List<ActivityCount> activityCounts = new List<ActivityCount>();
@@ -183,7 +194,10 @@ namespace TEAMModelBI.Controllers.Census
         public async Task<IActionResult> GetTermActivity(JsonElement jsonElement) 
         {
             jsonElement.TryGetProperty("tmdId", out JsonElement tmdId);
+            jsonElement.TryGetProperty("site", out JsonElement site);
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
 
             var (start, end) = TimeHelper.GetTermStartOrEnd(DateTime.Now);
 
@@ -239,7 +253,10 @@ namespace TEAMModelBI.Controllers.Census
         public async Task<IActionResult> GetAreaActovoty(JsonElement jsonElement) 
         {
             if (!jsonElement.TryGetProperty("areaId", out JsonElement areaId)) return BadRequest();
+            jsonElement.TryGetProperty("site", out JsonElement site);
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
             List<RecSchool> schools = new();
 
             await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<RecSchool>(queryText: $"select c.id,c.name,c.picture,c.scale from c where c.areaId='{areaId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
@@ -295,12 +312,15 @@ namespace TEAMModelBI.Controllers.Census
         public async Task<IActionResult> GetAreaStics(JsonElement jsonElement) 
         {
             if (!jsonElement.TryGetProperty("areaId", out JsonElement areaId)) return BadRequest();
+            jsonElement.TryGetProperty("site", out JsonElement site);
             var (dayStart, dayEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow);
             var (weekStart, weekEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "week");
             var (monthStart, monthEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "month");
             var (termStart, termEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "term");
 
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
             List<RecSchool> schools = new();
 
 
@@ -473,9 +493,12 @@ namespace TEAMModelBI.Controllers.Census
         /// </summary>
         /// <returns></returns>
         [HttpPost("get-all")]
-        public async Task<IActionResult> GetAll() 
+        public async Task<IActionResult> GetAll(JsonElement jsonElement)
         {
+            jsonElement.TryGetProperty("site", out JsonElement site);
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
 
             List<AreaInfo> areaInfos = new();
             await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<AreaInfo>(queryText: $"select c.id,c.name,c.standard,c.standardName from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
@@ -574,9 +597,12 @@ namespace TEAMModelBI.Controllers.Census
             if (!jsonElement.TryGetProperty("id", out JsonElement id)) return BadRequest();
             jsonElement.TryGetProperty("activity", out JsonElement activity);
             jsonElement.TryGetProperty("isPersonal", out JsonElement isPersonal);
+            jsonElement.TryGetProperty("site", out JsonElement site);
             //if (jsonElement.TryGetProperty("", out JsonElement code)) return BadRequest();
 
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
             List<object> infos = new List<object>();
             StringBuilder sqlTxt = new StringBuilder($"select * from c where c.id='{id}'");
             if (!string.IsNullOrEmpty($"{activity}"))

+ 5 - 1
TEAMModelBI/Controllers/Census/BlobLogController.cs

@@ -9,6 +9,7 @@ using System.Text;
 using System.Text.Json;
 using System.Threading.Tasks;
 using TEAMModelBI.Tool;
+using TEAMModelBI.Tool.Context;
 using TEAMModelOS.Models;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
@@ -41,10 +42,13 @@ namespace TEAMModelBI.Controllers.Census
         /// <returns></returns>
         [ProducesDefaultResponseType]
         [HttpPost("get-area")]
-        public async Task<IActionResult> GetArea(JsonElement jsonElement) 
+        public async Task<IActionResult> GetArea(JsonElement jsonElement)
         {
+            jsonElement.TryGetProperty("site", out JsonElement site);
             jsonElement.TryGetProperty("areaId", out JsonElement areaId);
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
             StringBuilder sqlSize = new($"select sum(c.size) as totals from c ");
             long useSize = 0;  //使用大小
             List<RecBlobFile> blobFiles = new();

+ 16 - 0
TEAMModelBI/Controllers/Census/ItemSticsController.cs

@@ -12,6 +12,7 @@ using System;
 using System.Text;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Extension;
+using TEAMModelBI.Tool.Context;
 
 namespace TEAMModelBI.Controllers.Census
 {
@@ -41,7 +42,10 @@ namespace TEAMModelBI.Controllers.Census
         public async Task<IActionResult> GetTotals(JsonElement jsonElement)
         {
             jsonElement.TryGetProperty("tmdId", out JsonElement tmdId);
+            jsonElement.TryGetProperty("site", out JsonElement site);
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
 
             if (!string.IsNullOrEmpty($"{tmdId}"))
             {
@@ -85,10 +89,13 @@ namespace TEAMModelBI.Controllers.Census
         {
             jsonElement.TryGetProperty("tmdId", out JsonElement tmdId);
             if (!jsonElement.TryGetProperty("term", out JsonElement term)) return BadRequest();
+            jsonElement.TryGetProperty("site", out JsonElement site);
 
             var (start, end) = TimeHelper.GetTermStartOrEnd(DateTime.Now);
 
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
             List<string> itemType = new List<string> { "single", "multiple", "judge", "complete", "subjective", "connector", "correct", "compose" };
             List<object> typeCount = new List<object>();
 
@@ -151,7 +158,10 @@ namespace TEAMModelBI.Controllers.Census
         {
             jsonElement.TryGetProperty("tmdId", out JsonElement tmdId);
             if(!jsonElement.TryGetProperty("term", out JsonElement term)) return BadRequest();
+            jsonElement.TryGetProperty("site", out JsonElement site);
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
             var (start, end) = TimeHelper.GetTermStartOrEnd(DateTime.Now);
 
             List<object> levelCount = new List<object>();
@@ -216,11 +226,14 @@ namespace TEAMModelBI.Controllers.Census
         [HttpPost("get-layer")]
         public async Task<IActionResult> GetLayerCount(JsonElement jsonElement)
         {
+            jsonElement.TryGetProperty("site", out JsonElement site);
             jsonElement.TryGetProperty("tmdId", out JsonElement tmdId);
             if (!jsonElement.TryGetProperty("term", out JsonElement term)) return BadRequest();
 
             var (start, end) = TimeHelper.GetTermStartOrEnd(DateTime.Now);
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
             List<object> layerCount = new List<object>();
 
             if (!string.IsNullOrEmpty($"{tmdId}"))
@@ -285,7 +298,10 @@ namespace TEAMModelBI.Controllers.Census
         {
             if (!jsonElement.TryGetProperty("itemId", out JsonElement itemId)) return BadRequest();
             jsonElement.TryGetProperty("isPersonal", out JsonElement isPersonal);
+            jsonElement.TryGetProperty("site", out JsonElement site);
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
 
             List<object> objItems = new List<object>();
             string sqlTxt = $"select * from c where c.id='{itemId}' and c.pk='Item'";

+ 28 - 2
TEAMModelBI/Controllers/Census/LessonSticsController.cs

@@ -17,6 +17,7 @@ using System.Text;
 using TEAMModelBI.Tool;
 using MathNet.Numerics.LinearAlgebra.Double;
 using TEAMModelBI.Tool.CosmosBank;
+using TEAMModelBI.Tool.Context;
 
 namespace TEAMModelBI.Controllers.Census
 {
@@ -47,7 +48,10 @@ namespace TEAMModelBI.Controllers.Census
         {
             jsonElement.TryGetProperty("tmdId", out JsonElement tmdId);
             if (!jsonElement.TryGetProperty("term", out JsonElement term)) return BadRequest();
+            jsonElement.TryGetProperty("site", out JsonElement site);
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
             var (start, end) = TimeHelper.GetTermStartOrEnd(DateTime.Now);
             object totals = new();
             StringBuilder sqlTxt = new($"select COUNT(c.id) AS totals  from c where c.pk='LessonRecord'");
@@ -103,11 +107,15 @@ namespace TEAMModelBI.Controllers.Census
         /// </summary>
         /// <returns></returns>
         [HttpPost("get-total")]
-        public async Task<IActionResult> GetCount()
+        public async Task<IActionResult> GetAllCount(JsonElement jsonElement)
         {
             try
             {
+                jsonElement.TryGetProperty("site", out JsonElement site);
+
                 var cosmosClient = _azureCosmos.GetCosmosClient();
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
                 string lessonSql = $"select COUNT(c.id) AS totals from c where c.pk='LessonRecord'";
                 long total = await CommonFind.FindTotals(cosmosClient, lessonSql, new List<string>() { "School","Teacher" });
 
@@ -132,7 +140,10 @@ namespace TEAMModelBI.Controllers.Census
             try
             {
                 if (!jsonElement.TryGetProperty("tmdId", out JsonElement tmdId)) return BadRequest();
+                jsonElement.TryGetProperty("site", out JsonElement site);
                 var cosmosClient = _azureCosmos.GetCosmosClient();
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
                 List<SchoolLen> schoolLens = new();
 
                 List<string> schoolIds = await CommonFind.FindSchoolIds(cosmosClient, $"{tmdId}");
@@ -171,8 +182,10 @@ namespace TEAMModelBI.Controllers.Census
         public async Task<IActionResult> GetDicCount(JsonElement jsonElement)
         {
             jsonElement.TryGetProperty("tmdId", out JsonElement tmdId);
+            jsonElement.TryGetProperty("site", out JsonElement site);
             var cosmosClient = _azureCosmos.GetCosmosClient();
-
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
             if (!string.IsNullOrEmpty($"{tmdId}"))
             {
                 jsonElement.TryGetProperty("years", out JsonElement _years);
@@ -230,7 +243,11 @@ namespace TEAMModelBI.Controllers.Census
         public async Task<IActionResult> GetTermCount(JsonElement jsonElement) 
         {
             if (jsonElement.TryGetProperty("tmdId", out JsonElement tmdId)) BadRequest();
+            jsonElement.TryGetProperty("site", out JsonElement site);
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+
             List<SchoolLen> schoolLens = new();
             List<string> schoolIds = await CommonFind.FindSchoolIds(cosmosClient, $"{tmdId}");
             foreach (var scid in schoolIds)
@@ -329,8 +346,11 @@ namespace TEAMModelBI.Controllers.Census
         public async Task<IActionResult> GetAreaCount(JsonElement jsonElement) 
         {
             if(!jsonElement.TryGetProperty("areaId", out JsonElement areaId)) return BadRequest();
+            jsonElement.TryGetProperty("site", out JsonElement site);
             List<string> schools = new();
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
 
             StringBuilder scSqlTxt = new("select c.id from c");
             if (!string.IsNullOrEmpty($"{areaId}"))
@@ -396,10 +416,13 @@ namespace TEAMModelBI.Controllers.Census
         public async Task<IActionResult> GetWeekCount(JsonElement jsonElement) 
         {
             jsonElement.TryGetProperty("areaId", out JsonElement areaId);
+            jsonElement.TryGetProperty("site", out JsonElement site);
 
             //Dictionary<int, double> weeks = new();
             List<double> weeks = new();
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
 
             int year = DateTimeOffset.UtcNow.Year;
             int dayOfweek = (int)DateTimeOffset.Parse($"{year}-1-1").DayOfWeek;
@@ -540,7 +563,10 @@ namespace TEAMModelBI.Controllers.Census
         public async Task<IActionResult> GetInfo(JsonElement jsonElement) 
         {
             if (!jsonElement.TryGetProperty("lessonId", out JsonElement lessonId)) return BadRequest();
+            jsonElement.TryGetProperty("site", out JsonElement site);
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
             List<object> lessons = new();
             string sqlTxt = $"select * from c where c.id='{lessonId}'";
             await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { })) 

+ 21 - 5
TEAMModelBI/Controllers/Census/PaperController.cs

@@ -9,6 +9,7 @@ using System.Text.Json;
 using System.Threading.Tasks;
 using TEAMModelBI.Models;
 using TEAMModelBI.Tool;
+using TEAMModelBI.Tool.Context;
 using TEAMModelOS.Models;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
@@ -46,11 +47,12 @@ namespace TEAMModelBI.Controllers.Census
         {
             jsonElement.TryGetProperty("tmdId", out JsonElement tmdId);
             if(!jsonElement.TryGetProperty("term", out JsonElement term)) return BadRequest();
+            jsonElement.TryGetProperty("site", out JsonElement site);
             var (start, end) = TimeHelper.GetTermStartOrEnd(DateTime.Now);
             var cosmosClient = _azureCosmos.GetCosmosClient();
-            object paperCount = new object();
-
-            
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+            object paperCount = new object();            
 
             if (!string.IsNullOrEmpty($"{tmdId}"))
             {
@@ -111,9 +113,12 @@ namespace TEAMModelBI.Controllers.Census
         /// </summary>
         /// <returns></returns>
         [HttpPost("get-total")]
-        public async Task<IActionResult> GetTotal()
+        public async Task<IActionResult> GetTotal(JsonElement jsonElement)
         {
+            jsonElement.TryGetProperty("site", out JsonElement site);
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
             string sqlTxt = $"select COUNT(c.id) AS totals from c where c.pk='Paper'";
 
             long totals = await CommonFind.FindTotals(cosmosClient, sqlTxt.ToString(), new List<string>() { "School" });       
@@ -131,7 +136,10 @@ namespace TEAMModelBI.Controllers.Census
         public async Task<IActionResult> GetAssistSchool(JsonElement jsonElement)
         {
             if (!jsonElement.TryGetProperty("tmdId", out JsonElement tmdId)) return BadRequest();
+            jsonElement.TryGetProperty("site", out JsonElement site);
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
             List<string> schoolIds = new List<string>();
             List<SchoolPaper> schoolPapers = new List<SchoolPaper>();
 
@@ -166,7 +174,10 @@ namespace TEAMModelBI.Controllers.Census
         public async Task<IActionResult> GetNewYear(JsonElement jsonElement) 
         {
             jsonElement.TryGetProperty("tmdId", out JsonElement tmdId);
+            jsonElement.TryGetProperty("site", out JsonElement site);
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
             List<MonthStartEnd> endList1 = TimeHelper.GetYearMonthlyStartEnd13(DateTimeOffset.UtcNow.Year);
             if (string.IsNullOrEmpty($"{tmdId}"))
             {
@@ -224,7 +235,10 @@ namespace TEAMModelBI.Controllers.Census
         public async Task<IActionResult> GetTermPaper(JsonElement jsonElement) 
         {
             jsonElement.TryGetProperty("tmdId", out JsonElement tmdId);
+            jsonElement.TryGetProperty("site", out JsonElement site);
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
             var (start, end) = TimeHelper.GetTermStartOrEnd(DateTime.Now);
 
              var totals = new object();
@@ -289,8 +303,10 @@ namespace TEAMModelBI.Controllers.Census
         {
             if (!jsonElement.TryGetProperty("paperId", out JsonElement paperId)) return BadRequest();
             jsonElement.TryGetProperty("isPersonal", out JsonElement isPersonal);
-
+            jsonElement.TryGetProperty("site", out JsonElement site);
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
 
             List<object> paperInfos = new List<object>();
             string sqlTxt = $"select * from c where c.id='{paperId}' and c.pk='Paper'";

+ 15 - 2
TEAMModelBI/Controllers/Census/ProductStatisController.cs

@@ -8,6 +8,7 @@ using System.Linq;
 using System.Text.Json;
 using System.Threading.Tasks;
 using TEAMModelBI.Tool;
+using TEAMModelBI.Tool.Context;
 using TEAMModelOS.Models;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
@@ -48,9 +49,12 @@ namespace TEAMModelBI.Controllers.Census
         /// <returns></returns>
         [ProducesDefaultResponseType]
         [HttpPost("get-allcount")]
-        public async Task<IActionResult> GetProductSum()
+        public async Task<IActionResult> GetProductSum(JsonElement jsonElement)
         {
+            jsonElement.TryGetProperty("site", out JsonElement site);
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
             List<ProductStatis> productStatis = new List<ProductStatis>();
             await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"SELECT c.serial,c.service FROM c",requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
             {
@@ -169,7 +173,10 @@ namespace TEAMModelBI.Controllers.Census
         public async Task<IActionResult> GetAssistSchoolId(JsonElement jsonElement)
         {
             if (!jsonElement.TryGetProperty("tmdId", out JsonElement tmdId)) return BadRequest();
+            jsonElement.TryGetProperty("site", out JsonElement site);
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
 
             List<string> schoolIds = await CommonFind.FindSchoolIds(cosmosClient, $"{tmdId}");
             List<SchoolProduct> schoolProducts = new List<SchoolProduct>();
@@ -276,7 +283,10 @@ namespace TEAMModelBI.Controllers.Census
         public async Task<IActionResult> GetModuleAnalys(JsonElement jsonElement)
         {
             jsonElement.TryGetProperty("tmdId", out JsonElement tmdId);
+            jsonElement.TryGetProperty("site", out JsonElement site);
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
 
             long buyServiceCount = 0; //所有购买服务数量
             long buySerialsCount = 0; //所有购买软体数量
@@ -393,6 +403,10 @@ namespace TEAMModelBI.Controllers.Census
         public async Task<IActionResult> GetAdviserSchool(JsonElement jsonElement) 
         {
             if (!jsonElement.TryGetProperty("tmdId", out JsonElement tmdId)) return BadRequest();
+            jsonElement.TryGetProperty("site", out JsonElement site);
+            var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
 
             long buyServiceCount = 0;  //购买服务数量
             long buySerialsCount = 0;  //购买软体数量
@@ -406,7 +420,6 @@ namespace TEAMModelBI.Controllers.Census
             var (lastYearStart, lastYearEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.Parse($"{DateTimeOffset.UtcNow.Year - 1}-1-1"), "year", false); //计算去年开始/结束时间
             var (yearStart, yearEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "year", false);                                     //计算今年开始/结束时间
 
-            var cosmosClient = _azureCosmos.GetCosmosClient();
             List<string> schoolIds = await CommonFind.FindSchoolIds(cosmosClient, $"{tmdId}");
 
             foreach (var scId in schoolIds)

+ 15 - 2
TEAMModelBI/Controllers/Census/SchoolController.cs

@@ -10,6 +10,7 @@ using System.Text.Json;
 using System.Threading.Tasks;
 using TEAMModelBI.Models;
 using TEAMModelBI.Tool;
+using TEAMModelBI.Tool.Context;
 using TEAMModelBI.Tool.CosmosBank;
 using TEAMModelOS.Models;
 using TEAMModelOS.SDK.DI;
@@ -41,9 +42,12 @@ namespace TEAMModelBI.Controllers.Census
         /// <param name="jsonElement"></param>
         /// <returns></returns>
         [HttpPost("get-all")]
-        public async Task<IActionResult> GetAll() 
+        public async Task<IActionResult> GetAll(JsonElement jsonElement)
         {
+            jsonElement.TryGetProperty("site", out JsonElement site);
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
 
             long schoolCount = 0;   //学校数量
             int tecCount = 0;  //教师数量
@@ -137,6 +141,7 @@ namespace TEAMModelBI.Controllers.Census
         public async Task<IActionResult> GetAssistStatis(JsonElement jsonElement) 
         {
             if (!jsonElement.TryGetProperty("tmdId", out JsonElement tmdId)) return BadRequest();
+            jsonElement.TryGetProperty("site", out JsonElement site);
 
             int tecCount = 0;   //教师数量
             int stuCount = 0;   //学校数量
@@ -161,6 +166,8 @@ namespace TEAMModelBI.Controllers.Census
             long weekActivity = 0;  //本周学校所有活动
 
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
             List<string> schoolIds = await CommonFind.FindSchoolIds(cosmosClient, $"{tmdId}");
 
             var (lastWeekStart, lastWeekEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "lastweek");   //计算上周开始/结束时间
@@ -232,7 +239,8 @@ namespace TEAMModelBI.Controllers.Census
         [HttpPost("get-idstatis")]
         public async Task<IActionResult> GetIdStatis(JsonElement jsonElement) 
         {
-            if (!jsonElement.TryGetProperty("schoolId", out JsonElement schoolId)) return BadRequest();        
+            if (!jsonElement.TryGetProperty("schoolId", out JsonElement schoolId)) return BadRequest();
+            jsonElement.TryGetProperty("site", out JsonElement site);
 
             int tecCount = 0;  //学校教师数量
             int stuCount = 0;  //学校学生数量
@@ -258,6 +266,8 @@ namespace TEAMModelBI.Controllers.Census
             int yearBlob = 0;  //去年的资源
 
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
             var (lastWeekStart, lastWeekEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "lastweek");   //计算上周开始/结束时间
             var (weekStart, weekEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "week");             //计算本周开始/结束时间
             var (lastTermStart, lastTermEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "lastterm");   //计算上学期开始/结束时间
@@ -345,7 +355,10 @@ namespace TEAMModelBI.Controllers.Census
         public async Task<IActionResult> GetSchool(JsonElement jsonElement) 
         {
             if (!jsonElement.TryGetProperty("id", out JsonElement id)) return BadRequest();
+            jsonElement.TryGetProperty("site", out JsonElement site);
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
             List<object> infos = new List<object>();
 
             string sqlTxt = $"select value(c) from c where c.id='{id}'";

+ 5 - 0
TEAMModelBI/Controllers/Census/StudyController.cs

@@ -6,6 +6,7 @@ using System.Collections.Generic;
 using System.Text.Json;
 using System.Threading.Tasks;
 using TEAMModelBI.Tool;
+using TEAMModelBI.Tool.Context;
 using TEAMModelOS.Models;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Models;
@@ -39,6 +40,8 @@ namespace TEAMModelBI.Controllers.Census
         public async Task<IActionResult> GetArea(JsonElement jsonElement)
         {
             if (!jsonElement.TryGetProperty("areaId", out JsonElement areaId)) return BadRequest();
+            jsonElement.TryGetProperty("site", out JsonElement site);
+
             int onLineCount = 0;    //线上研修人数
             int offlineCount = 0;   //线下研修人数
             int classRoomCount = 0;  //课堂实录人数
@@ -50,6 +53,8 @@ namespace TEAMModelBI.Controllers.Census
 
             List<TeacherTrain> trains = new();
             var cosmosClient = _azureCosmos.GetCosmosClient();
+            if ($"{site}".Equals(BIConst.GlobalSite))
+                cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
             List<string> schoolIds = await CommonFind.FindSchoolIds(cosmosClient, $"select c.id from c where c.areaId='{areaId}'", "Base");
 
             AreaSetting setting = null;

+ 1 - 0
TEAMModelBI/Controllers/Core/BlobController.cs

@@ -56,6 +56,7 @@ namespace TEAMModelBI.Controllers.Core
         {
             var (id, _, _, school) = HttpContext.GetAuthTokenInfo();
             string fileExt = FileType.GetExtention(file.FileName).ToLower();
+
             if (ContentTypeDict.dict.ContainsKey($".{fileExt}"))
             {
                 var url = await _azureStorage.UploadFileByContainer("0-public", file.OpenReadStream(), "school", $"{Guid.NewGuid()}.{fileExt}", false);

+ 17 - 3
TEAMModelBI/Controllers/DingDingStruc/DDStructController.cs

@@ -20,6 +20,7 @@ using TEAMModelBI.Controllers.BISchool;
 using TEAMModelOS.SDK.Models.Cosmos.BI;
 using Microsoft.Azure.Cosmos.Table;
 using TEAMModelOS.SDK;
+using TEAMModelBI.Tool.Context;
 
 namespace TEAMModelBI.Controllers.DingDingStruc
 {
@@ -245,6 +246,7 @@ namespace TEAMModelBI.Controllers.DingDingStruc
             try
             {
                 jsonElement.TryGetProperty("deptId", out JsonElement deptId);
+                jsonElement.TryGetProperty("site", out JsonElement site);
                 string tempDeptId = string.IsNullOrEmpty($"{deptId}") ? "67863053" : $"{deptId}";
 
                 string appKey = _configuration["DingDingAuth:appKey"];
@@ -281,7 +283,10 @@ namespace TEAMModelBI.Controllers.DingDingStruc
 
                 List<DingDingUserInfo> ddUserInfos = new();
 
-                var tabledd = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");                
+                var tabledd = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("BIDDUserInfo");
+
                 if (rspV2UserList1.Result.List != null)
                 {
                     foreach (var itemUser in rspV2UserList1.Result.List)
@@ -469,10 +474,12 @@ namespace TEAMModelBI.Controllers.DingDingStruc
             try
             {
                 if (!jsonElement.TryGetProperty("userids", out JsonElement userIds)) return Ok(new { state = 1, message = "参数问题" });
+                jsonElement.TryGetProperty("site", out JsonElement site);
                 List<DDUserInfoAndTMD> dDUserInfoAndTMDs = new List<DDUserInfoAndTMD>();//返回钉钉信息和查询的醍摩豆信息
                 string appKey = _configuration["DingDingAuth:appKey"];
                 string appSecret = _configuration["DingDingAuth:appSecret"];
 
+
                 //获取access_token
                 DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
                 OapiGettokenRequest request = new OapiGettokenRequest();
@@ -491,6 +498,13 @@ namespace TEAMModelBI.Controllers.DingDingStruc
 
                 Dictionary<string, object> dic = new Dictionary<string, object> { { "PartitionKey", "authority-bi" } };
                 var table = _azureStorage.GetCloudTableClient().GetTableReference("SchoolSetting");
+                var cosmosClient = _azureCosmos.GetCosmosClient();
+                if ($"{site}".Equals(BIConst.GlobalSite)) 
+                {
+                    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+                    table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("SchoolSetting");
+                }
+
                 List<Authority> authorityBIList = await table.FindListByDict<Authority>(dic);
 
                 if (!string.IsNullOrEmpty($"{userIds}"))
@@ -520,14 +534,14 @@ namespace TEAMModelBI.Controllers.DingDingStruc
                             string sqltxt = $"select distinct value(c) from c join A1 in c.ddbinds where A1.userid ='{tempid}'";
                             try
                             {
-                                await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Teacher>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+                                await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Teacher>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
                                 {
                                     dDUserInfoAndTMD.tmdId = item.id;
                                     dDUserInfoAndTMD.isexist = true;
 
                                     if (!string.IsNullOrEmpty($"{item.defaultSchool}"))
                                     {
-                                        var schoolRoles = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(item.id, new PartitionKey($"Teacher-{item.defaultSchool}"));
+                                        var schoolRoles = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(item.id, new PartitionKey($"Teacher-{item.defaultSchool}"));
                                         if (schoolRoles.Status == 200)
                                         {
                                             using var json = await JsonDocument.ParseAsync(schoolRoles.ContentStream);

+ 65 - 8
TEAMModelBI/Controllers/DingDingStruc/TableDingDingInfoController.cs

@@ -25,6 +25,7 @@ using TEAMModelBI.Filter;
 using TEAMModelBI.Tool.Extension;
 using TEAMModelBI.Models;
 using TEAMModelBI.Tool.CosmosBank;
+using TEAMModelBI.Tool.Context;
 
 namespace TEAMModelBI.Controllers.DingDingStruc
 {
@@ -64,6 +65,13 @@ namespace TEAMModelBI.Controllers.DingDingStruc
         {
             try
             {
+                jsonElement.TryGetProperty("site", out JsonElement site);
+                var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                {
+                    table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("BIDDUserInfo");
+                }
+
                 string appKey = _configuration["DingDingAuth:appKey"];
                 string appSecret = _configuration["DingDingAuth:appSecret"];
                 //string divide = _configuration["CustomParam:SiteScope"];
@@ -72,7 +80,6 @@ namespace TEAMModelBI.Controllers.DingDingStruc
                 var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
 
                 HttpClient httpClient = _http.CreateClient();
-                var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
                 string url = _configuration.GetValue<string>("HaBookAuth:CoreId:userinfo");
 
                 //获取access_token
@@ -206,8 +213,13 @@ namespace TEAMModelBI.Controllers.DingDingStruc
             try
             {
                 jsonElement.TryGetProperty("busy", out JsonElement busy);
+                jsonElement.TryGetProperty("site", out JsonElement site);
                 var cosmosCliet = _azureCosmos.GetCosmosClient();
                 var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                {
+                    table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("BIDDUserInfo");
+                }
                 //string divide = _configuration["CustomParam:SiteScope"];
                 string divide = _option.Location;
                 List<DDUserInfo> ddUserInfos = new();
@@ -322,7 +334,12 @@ namespace TEAMModelBI.Controllers.DingDingStruc
         {
             try
             {
+                jsonElement.TryGetProperty("site", out JsonElement site);
                 var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                {
+                    table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("BIDDUserInfo");
+                }
 
                 string appKey = _configuration["DingDingAuth:appKey"];
                 string appSecret = _configuration["DingDingAuth:appSecret"];
@@ -397,7 +414,12 @@ namespace TEAMModelBI.Controllers.DingDingStruc
         {
             try
             {
+                jsonElement.TryGetProperty("site", out JsonElement site);
                 var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                {
+                    table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("BIDDUserInfo");
+                }
 
                 string appKey = _configuration["DingDingAuth:appKey"];
                 string appSecret = _configuration["DingDingAuth:appSecret"];
@@ -465,9 +487,15 @@ namespace TEAMModelBI.Controllers.DingDingStruc
                 jsonElement.TryGetProperty("tmdId", out JsonElement tmdId);
                 if (!jsonElement.TryGetProperty("permissions", out JsonElement _permissions)) return BadRequest();
                 if (!jsonElement.TryGetProperty("roles", out JsonElement _roles)) return BadRequest();
-                var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
+                jsonElement.TryGetProperty("site", out JsonElement site);
 
                 var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                {
+                    table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("BIDDUserInfo");
+                }
+                var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
+
                 List<DingDingUserInfo> ddUserInfo = new();
                 List<string> listper = _permissions.ToObject<List<string>>();
                 List<string> listroles = _roles.ToObject<List<string>>();
@@ -531,11 +559,18 @@ namespace TEAMModelBI.Controllers.DingDingStruc
             {
                 var cosmosCliet = _azureCosmos.GetCosmosClient();
                 if (!jsonElement.TryGetProperty("deptId", out JsonElement deptId)) return BadRequest();
+                jsonElement.TryGetProperty("site", out JsonElement site);
+
+                var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                {
+                    table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("BIDDUserInfo");
+                    cosmosCliet = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+                };
                 //string divide = _configuration["CustomParam:SiteScope"];
                 string divide = _option.Location;
-
                 Dictionary<string, object> dic = new Dictionary<string, object> { { "PartitionKey", $"{divide}" } };
-                var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
+
                 List<DingDingUserInfo> tempUserInfos = await table.FindListByDict<DingDingUserInfo>(dic);
 
                 List<DingDingUserInfo> userInfo = new();
@@ -676,9 +711,14 @@ namespace TEAMModelBI.Controllers.DingDingStruc
             {
                 if (!jsonElement.TryGetProperty("rowKey", out JsonElement rowKey)) return BadRequest();
                 if (!jsonElement.TryGetProperty("mobile", out JsonElement mobile)) return BadRequest();
+                jsonElement.TryGetProperty("site", out JsonElement site);
 
                 var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
                 var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                {
+                    table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("BIDDUserInfo");
+                }
 
                 List<DingDingUserInfo> tempddUsers = null;
                 List<DingDingUserInfo> ddUsers = new();
@@ -763,9 +803,13 @@ namespace TEAMModelBI.Controllers.DingDingStruc
                 if (!jsonElement.TryGetProperty("partitionKey", out JsonElement partitionKey)) return BadRequest();
                 if (!jsonElement.TryGetProperty("rowKey", out JsonElement rowKey)) return BadRequest();
                 if (!jsonElement.TryGetProperty("isAdmin", out JsonElement isAdmin)) return BadRequest();
-
+                jsonElement.TryGetProperty("site", out JsonElement site);
                 var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
                 var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                {
+                    table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("BIDDUserInfo");
+                }
                 var tempUser = await table.FindListByDict<DingDingUserInfo>(new Dictionary<string, object> { { "PartitionKey", $"{partitionKey}" }, { "RowKey", $"{rowKey}" } });
                 
                 List<DDUserInfo> ddUserInfos = new();
@@ -865,15 +909,22 @@ namespace TEAMModelBI.Controllers.DingDingStruc
                 if (!jsonElement.TryGetProperty("mobile", out JsonElement mobile)) return BadRequest();
                 jsonElement.TryGetProperty("picture ", out JsonElement picture);
                 jsonElement.TryGetProperty("mail ", out JsonElement mail);
-                var cosmosCliet = _azureCosmos.GetCosmosClient();
+                jsonElement.TryGetProperty("site", out JsonElement site);
                 var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
+                var cosmosCliet = _azureCosmos.GetCosmosClient();
+                var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                {
+                    cosmosCliet = _azureCosmos.GetCosmosClient(name: BIConst.GlobalSite);
+                    table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("BIDDUserInfo");
+                }
+
 
                 List<DDUserInfo> ddUserInfos = new();
                 List<string> roles = new();//角色列表
                 List<string> permissions = new();//权限列表
 
                 StringBuilder msg = new($"{_tmdName}【{_tmdId}】");
-                var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
                 //string divide = _configuration["CustomParam:SiteScope"];
                 string divide = _option.Location;
 
@@ -1002,6 +1053,13 @@ namespace TEAMModelBI.Controllers.DingDingStruc
         public async Task<IActionResult> SetUnbind(JsonElement jsonElement) 
         {
             jsonElement.TryGetProperty("mobile", out JsonElement mobile);
+            jsonElement.TryGetProperty("site", out JsonElement site);
+            var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
+            if ($"{site}".Equals(BIConst.GlobalSite))
+            {
+                table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("BIDDUserInfo");
+            }
+
             //string divide = _configuration["CustomParam:SiteScope"];
             string divide = _option.Location;
             Dictionary<string, object> dic = new Dictionary<string, object> { { "PartitionKey", $"{divide}" } };
@@ -1010,7 +1068,6 @@ namespace TEAMModelBI.Controllers.DingDingStruc
             else
                 dic.Add("tmdMobile", "18281911681");
 
-            var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
             List<DingDingUserInfo> ddUserInfoList = await table.FindListByDict<DingDingUserInfo>(dic);
 
             List<DingDingUserInfo> tempDDUI = new();

+ 13 - 9
TEAMModelBI/Controllers/LoginController.cs

@@ -86,6 +86,7 @@ namespace TEAMModelBI.Controllers
                 //string divide = _configuration["CustomParam:SiteScope"];
                 string divide = _option.Location;
                 var cosmosClient = _azureCosmos.GetCosmosClient();
+                string Website = "China";
 
                 if (string.IsNullOrWhiteSpace(appKey) || string.IsNullOrWhiteSpace(appSecret))
                 {
@@ -196,7 +197,7 @@ namespace TEAMModelBI.Controllers
                             strMsg.Append($"{item.tmdName}【{item.tmdId}】醍摩豆账号和{item.name}【{item.userId}】钉钉账户绑定成功");
 
                             //保存操作记录
-                            await _azureStorage.SaveBILog("tabledd-update", strMsg?.ToString(), _dingDing, httpContext: HttpContext, twebsite: "BI", tid: item.tmdId, tname: item.tmdName);
+                            await _azureStorage.SaveBILog("tabledd-update", strMsg?.ToString(), _dingDing, httpContext: HttpContext, twebsite: Website, tid: item.tmdId, tname: item.tmdName);
                             saveInfo.Add(item);
                         }
 
@@ -214,7 +215,7 @@ namespace TEAMModelBI.Controllers
                         if (item.pid == long.Parse($"{proDeptId}")) isExploit = true;
 
                         //自己写的
-                        id_token = JwtAuth.CreateAuthTokenBI(_option.HostName, item.tmdId?.ToString(), item.tmdName?.ToString(), item.picture?.ToString(), _option.JwtSecretKey, scope: "assist", Website: "BI", isex: isExploit, item.userId?.ToString(), item.name?.ToString(), item.avatar?.ToString(), roles: roles?.ToArray(), permissions: permissions?.ToArray(), expire: 3);
+                        id_token = JwtAuth.CreateAuthTokenBI(_option.HostName, item.tmdId?.ToString(), item.tmdName?.ToString(), item.picture?.ToString(), _option.JwtSecretKey, scope: "assist", webSite: Website, isex: isExploit, item.userId?.ToString(), item.name?.ToString(), item.avatar?.ToString(), roles: roles?.ToArray(), permissions: permissions?.ToArray(), expire: 3);
 
                         (osblob_uri, osblob_sas) = roles.Contains("assist") ? _azureStorage.GetBlobContainerSAS("teammodelos", BlobContainerSasPermissions.Write | BlobContainerSasPermissions.Read | BlobContainerSasPermissions.List | BlobContainerSasPermissions.Delete) : _azureStorage.GetBlobContainerSAS("teammodelos", BlobContainerSasPermissions.Read | BlobContainerSasPermissions.List);
                     }
@@ -281,7 +282,7 @@ namespace TEAMModelBI.Controllers
                     ddUserInfo = await table.Save<DingDingUserInfo>(ddUserInfo);
 
                     //保存操作记录
-                    await _azureStorage.SaveBILog("tabledd-update", $"{ddUserInfo.tmdName}【{ddUserInfo.tmdId}】醍摩豆账号和{ddUserInfo.name}【{ddUserInfo.RowKey}】钉钉账户绑定成功", _dingDing, httpContext: HttpContext, tid: ddUserInfo.tmdId, tname: ddUserInfo.tmdName, twebsite: "BI");
+                    await _azureStorage.SaveBILog("tabledd-update", $"{ddUserInfo.tmdName}【{ddUserInfo.tmdId}】醍摩豆账号和{ddUserInfo.name}【{ddUserInfo.RowKey}】钉钉账户绑定成功", _dingDing, httpContext: HttpContext, tid: ddUserInfo.tmdId, tname: ddUserInfo.tmdName, twebsite: Website);
 
                     roles = !string.IsNullOrEmpty($"{ddUserInfo.roles}") ? new List<string>(ddUserInfo.roles.Split(",")) : new List<string>();
                     permissions = !string.IsNullOrEmpty($"{ddUserInfo.permissions}") ? new List<string>(ddUserInfo.permissions.Split(",")) : new List<string>();
@@ -290,7 +291,7 @@ namespace TEAMModelBI.Controllers
                     if (ddUserInfo.pid == long.Parse($"{proDeptId}")) isExploit = true;
 
                     //自己写的
-                    id_token = JwtAuth.CreateAuthTokenBI(_option.HostName, ddUserInfo.tmdId?.ToString(), ddUserInfo.tmdName?.ToString(), ddUserInfo.picture?.ToString(), _option.JwtSecretKey, scope: "assist", Website: "BI", isex: isExploit, ddUserInfo.userId?.ToString(), ddUserInfo.name?.ToString(), ddUserInfo.avatar?.ToString(), roles: roles?.ToArray(), permissions: permissions?.ToArray(), expire: 3);
+                    id_token = JwtAuth.CreateAuthTokenBI(_option.HostName, ddUserInfo.tmdId?.ToString(), ddUserInfo.tmdName?.ToString(), ddUserInfo.picture?.ToString(), _option.JwtSecretKey, scope: "assist", webSite: Website, isex: isExploit, ddUserInfo.userId?.ToString(), ddUserInfo.name?.ToString(), ddUserInfo.avatar?.ToString(), roles: roles?.ToArray(), permissions: permissions?.ToArray(), expire: 3);
 
                     (osblob_uri, osblob_sas) = roles.Contains("assist") ? _azureStorage.GetBlobContainerSAS("teammodelos", BlobContainerSasPermissions.Write | BlobContainerSasPermissions.Read | BlobContainerSasPermissions.List | BlobContainerSasPermissions.Delete) : _azureStorage.GetBlobContainerSAS("teammodelos", BlobContainerSasPermissions.Read | BlobContainerSasPermissions.List);
                 }
@@ -319,6 +320,7 @@ namespace TEAMModelBI.Controllers
                 jsonElement.TryGetProperty("id_token", out JsonElement idtoken);
                 jsonElement.TryGetProperty("mobile", out JsonElement mobile);
 
+                string Website = "China";
                 HttpClient httpClient = _http.CreateClient();
                 string url = _configuration.GetValue<string>("HaBookAuth:CoreId:userinfo");
                 var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
@@ -376,9 +378,9 @@ namespace TEAMModelBI.Controllers
                         roles = !string.IsNullOrEmpty($"{itemUser.roles}") ? new List<string>(itemUser.roles.Split(",")) : new List<string>();
 
                         //保存操作记录
-                        await _azureStorage.SaveBILog("tabledd-update", $"{itemUser.tmdName}【{itemUser.tmdId}】醍摩豆账号和{itemUser.name}【{itemUser.userId}】钉钉账户绑定成功", _dingDing, tid: itemUser.tmdId, tname: itemUser.name, twebsite: "BI", httpContext: HttpContext);
+                        await _azureStorage.SaveBILog("tabledd-update", $"{itemUser.tmdName}【{itemUser.tmdId}】醍摩豆账号和{itemUser.name}【{itemUser.userId}】钉钉账户绑定成功", _dingDing, tid: itemUser.tmdId, tname: itemUser.name, twebsite: Website, httpContext: HttpContext);
 
-                        id_token = JwtAuth.CreateAuthTokenBI(_option.HostName, itemUser.tmdId?.ToString(), itemUser.tmdName?.ToString(), itemUser.picture?.ToString(), _option.JwtSecretKey, scope: "assist", Website: "BI", isex: false, itemUser.userId?.ToString(), itemUser.name?.ToString(), itemUser.avatar?.ToString(), roles: roles?.ToArray(), permissions: permissions?.ToArray(), expire: 3);
+                        id_token = JwtAuth.CreateAuthTokenBI(_option.HostName, itemUser.tmdId?.ToString(), itemUser.tmdName?.ToString(), itemUser.picture?.ToString(), _option.JwtSecretKey, scope: "assist", webSite: Website, isex: false, itemUser.userId?.ToString(), itemUser.name?.ToString(), itemUser.avatar?.ToString(), roles: roles?.ToArray(), permissions: permissions?.ToArray(), expire: 3);
                     }
                 }
 
@@ -410,6 +412,7 @@ namespace TEAMModelBI.Controllers
                 if (!jsonElement.TryGetProperty("mobile", out JsonElement moile)) return BadRequest();
                 if (!jsonElement.TryGetProperty("partitionKey", out JsonElement partitionKey)) return BadRequest();
                 if (!jsonElement.TryGetProperty("rowKey", out JsonElement userId)) return BadRequest();
+                string Website = "China";
                 var table = _azureStorage.GetCloudTableClient().GetTableReference("BIDDUserInfo");
                 var tempUser = await table.FindListByDict<DingDingUserInfo>(new Dictionary<string, object> { { "PartitionKey", $"{partitionKey}" }, { "userId", $"{userId}" } });
 
@@ -459,14 +462,14 @@ namespace TEAMModelBI.Controllers
                                 ddUserInfos = await table.UpdateAll<DingDingUserInfo>(ddUserInfos);
 
                                 //保存操作记录
-                                await _azureStorage.SaveBILog("tabledd-update", $"{tmdName}【{tmdId}】醍摩豆账号和{itemUser.name}【{itemUser.userId}】钉钉账户绑定成功", _dingDing, tid: itemUser.tmdId, tname: itemUser.name, twebsite: "BI", httpContext: HttpContext);
+                                await _azureStorage.SaveBILog("tabledd-update", $"{tmdName}【{tmdId}】醍摩豆账号和{itemUser.name}【{itemUser.userId}】钉钉账户绑定成功", _dingDing, tid: itemUser.tmdId, tname: itemUser.name, twebsite: Website, httpContext: HttpContext);
                             }
                             else return Ok(new { state = 400, message = "该手机没有注册醍摩豆账号信息" });
                         }
                         else return Ok(new { state = responseMessage.StatusCode });
                     }
                     //自己写的
-                    id_token = JwtAuth.CreateAuthTokenBI(_option.HostName, itemUser.tmdId?.ToString(), itemUser.tmdName?.ToString(), itemUser.picture?.ToString(), _option.JwtSecretKey, scope: "assist", Website: "BI", isex: false, itemUser.userId?.ToString(), itemUser.name?.ToString(), itemUser.avatar?.ToString(), roles: roles?.ToArray(), permissions: permissions?.ToArray(), expire: 3);
+                    id_token = JwtAuth.CreateAuthTokenBI(_option.HostName, itemUser.tmdId?.ToString(), itemUser.tmdName?.ToString(), itemUser.picture?.ToString(), _option.JwtSecretKey, scope: "assist", webSite: Website, isex: false, itemUser.userId?.ToString(), itemUser.name?.ToString(), itemUser.avatar?.ToString(), roles: roles?.ToArray(), permissions: permissions?.ToArray(), expire: 3);
                 }
 
                 var (osblob_uri, osblob_sas) = roles.Contains("assist") ? _azureStorage.GetBlobContainerSAS("teammodelos", BlobContainerSasPermissions.Write | BlobContainerSasPermissions.Read | BlobContainerSasPermissions.List | BlobContainerSasPermissions.Delete) : _azureStorage.GetBlobContainerSAS("teammodelos", BlobContainerSasPermissions.Read | BlobContainerSasPermissions.List);
@@ -492,6 +495,7 @@ namespace TEAMModelBI.Controllers
             if (!jsonElement.TryGetProperty("account", out JsonElement accout)) return BadRequest();
             if (!jsonElement.TryGetProperty("password", out JsonElement password)) return BadRequest();
 
+            string Website = "China";
             StringBuilder sqlTxt = new($"select value(c) from c");
             var cosmosClient = _azureCosmos.GetCosmosClient();
             var temps = $"{accout}".Contains($"@");
@@ -515,7 +519,7 @@ namespace TEAMModelBI.Controllers
                     if (hashedPw.Equals(item.password))
                     {
                         company = item;
-                        id_token = JwtAuth.CreateAuthTokenBI(_option.HostName, item.id?.ToString(), item.name?.ToString(), company.picture?.ToString(), _option.JwtSecretKey, scope: "company", Website: "BI", expire: 3);
+                        id_token = JwtAuth.CreateAuthTokenBI(_option.HostName, item.id?.ToString(), item.name?.ToString(), company.picture?.ToString(), _option.JwtSecretKey, scope: "company", webSite: Website, expire: 3);
                     }
                 }
             }

+ 10 - 0
TEAMModelBI/Controllers/OperateRecord/OperateLogController.cs

@@ -15,6 +15,7 @@ using TEAMModelOS.SDK.Models.Table;
 using TEAMModelBI.Filter;
 using TEAMModelBI.Tool.Extension;
 using TEAMModelOS.SDK.Extension;
+using TEAMModelBI.Tool.Context;
 
 namespace TEAMModelBI.Controllers.OperateRecord
 {
@@ -48,6 +49,7 @@ namespace TEAMModelBI.Controllers.OperateRecord
                 jsonElement.TryGetProperty("endDate", out JsonElement endDate);
                 jsonElement.TryGetProperty("platform", out JsonElement platform);
                 if(!jsonElement.TryGetProperty("reorder", out JsonElement orderby)) return BadRequest();
+                jsonElement.TryGetProperty("site", out JsonElement site);
 
                 List<BIOptLog> operateLogs = new();
                 StringBuilder tableSql = new StringBuilder();
@@ -62,6 +64,8 @@ namespace TEAMModelBI.Controllers.OperateRecord
                     tableSql.Append(!string.IsNullOrEmpty(tableSql.ToString()) ? $" and platform eq '{platform}' " : $" platform eq '{platform}' ");
                 
                 var table = _azureStorage.GetCloudTableClient().GetTableReference("BIOptLog");
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("BIOptLog");
 
                 //lambda 表达式排序
                 operateLogs = await table.QueryWhereString<BIOptLog>(tableSql.ToString());
@@ -101,6 +105,7 @@ namespace TEAMModelBI.Controllers.OperateRecord
                 jsonElement.TryGetProperty("startDate", out JsonElement startDate);
                 jsonElement.TryGetProperty("endDate", out JsonElement endDate);
                 jsonElement.TryGetProperty("rowKey", out JsonElement rowKey);
+                jsonElement.TryGetProperty("site", out JsonElement site);
 
                 var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
                 //var temp = await _azureStorage.Delete<OperateLog>(partitionKey: "OperateLog-BI", rowKey: $"{startDate}");  //删除单个
@@ -117,6 +122,8 @@ namespace TEAMModelBI.Controllers.OperateRecord
                     operateStr.Append($"删除的时间戳,开始——结束时间戳:{startDate}-{endDate}");
                 }
                 var table = _azureStorage.GetCloudTableClient().GetTableReference("BIOptLog");
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("BIOptLog");
                 var temp = await table.DeleteStringWhere<BIOptLog>(rowKey: tableStrWhere.ToString());
 
                 //保存操作记录
@@ -148,6 +155,7 @@ namespace TEAMModelBI.Controllers.OperateRecord
             {
                 if (!jsonElement.TryGetProperty("tmdId", out JsonElement tmdId)) return BadRequest();
                 jsonElement.TryGetProperty("platform", out JsonElement platform);
+                jsonElement.TryGetProperty("site", out JsonElement site);
 
                 string storageSql = null;
                 if (!string.IsNullOrEmpty($"{platform}"))
@@ -155,6 +163,8 @@ namespace TEAMModelBI.Controllers.OperateRecord
                 else storageSql = $"tmdId eq '{tmdId}'";
 
                 var table = _azureStorage.GetCloudTableClient().GetTableReference("BIOptLog");
+                if ($"{site}".Equals(BIConst.GlobalSite))
+                    table = _azureStorage.GetCloudTableClient(BIConst.GlobalSite).GetTableReference("BIOptLog");
                 var optLogs = await table.QueryWhereString<BIOptLog>(storageSql);
 
                 return Ok(new { state = 200, optLogs });

+ 6 - 0
TEAMModelBI/DI/BIAzureStorage/BIAzureStorageBlobExtensions.cs

@@ -0,0 +1,6 @@
+namespace TEAMModelBI.DI.BIAzureStorage
+{
+    public class BIAzureStorageBlobExtensions
+    {
+    }
+}

+ 1 - 1
TEAMModelBI/DI/BIAzureStorageFactoryExtensions.cs

@@ -5,7 +5,7 @@ using System.Collections.Generic;
 using System.Text;
 using TEAMModelOS.SDK.DI;
 
-namespace TEAMModelBI.DI
+namespace TEAMModelBI.DI.BIAzureStorage
 {
     public static class BIAzureStorageFactoryExtensions
     {

+ 1 - 2
TEAMModelBI/Startup.cs

@@ -3,12 +3,10 @@ using Microsoft.AspNetCore.Authentication.JwtBearer;
 using Microsoft.AspNetCore.Builder;
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.SpaServices;
 using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.Hosting;
-using Microsoft.Extensions.Logging;
 using Microsoft.IdentityModel.Tokens;
 using System;
 using System.Collections.Generic;
@@ -16,6 +14,7 @@ using System.IdentityModel.Tokens.Jwt;
 using System.Linq;
 using System.Threading.Tasks;
 using TEAMModelBI.DI;
+using TEAMModelBI.DI.BIAzureStorage;
 using TEAMModelBI.Models;
 using TEAMModelOS.Models;
 using TEAMModelOS.SDK;

+ 2 - 2
TEAMModelBI/Tool/Extension/JwtAuth.cs

@@ -27,7 +27,7 @@ namespace TEAMModelBI.Models.Extension
         /// <param name="permissions">权限</param>
         /// <param name="expire">到期时间</param>
         /// <returns></returns>
-        public static string CreateAuthTokenBI(string issuser, string id, string name, string picture, string salt, string scope, string Website, bool isex = false, string did = null, string dname = null, string dpicture = null, string[] roles = null, string[] permissions = null, int expire = 1)
+        public static string CreateAuthTokenBI(string issuser, string id, string name, string picture, string salt, string scope, string webSite, bool isex = false, string did = null, string dname = null, string dpicture = null, string[] roles = null, string[] permissions = null, int expire = 1)
         {
             var payload = new JwtPayload
             {
@@ -43,7 +43,7 @@ namespace TEAMModelBI.Models.Extension
                 { "ddname",dname } ,  //登陆者的钉钉用户名称
                 { "ddpicture",dpicture },  //登陆者的钉钉用户头像
                 { "scope",scope}, //
-                { JwtRegisteredClaimNames.Website,Website}, // 平台站点
+                { JwtRegisteredClaimNames.Website,webSite}, // 平台站点
             };
 
             // 建立加密的秘钥

+ 94 - 84
TEAMModelBI/Tool/TimeHelper.cs

@@ -182,52 +182,25 @@ namespace TEAMModelBI.Tool
         /// <returns></returns>
         public static (long start, long end) GetStartOrEnd(DateTimeOffset dateTime, string type = "", bool dateLenth = true)
         {
-            long start = 0;
-            long end = 0;
-            int year = dateTime.Year;
-            int month = dateTime.Month;
-            int day = dateTime.Day;
-            int hour = dateTime.Hour;
-            DateTimeOffset tempStrart = new();
-            DateTimeOffset tempEnd = new();
-            switch (type) 
+            try
             {
-                case "year":
-                    tempStrart = new DateTime(year, 1, 1);
-                    tempEnd = new DateTime(year, 12, DateTime.DaysInMonth(year, 12), 23, 59, 59);
-                    break;
-
-                case "term":
-                    if (month <= 8 && month >= 3)
-                    {
-                        tempStrart = new DateTime(year, 3, 1);
-                        tempEnd = new DateTime(year, 8, 31, 23, 59, 59);
-                    }
-                    else
-                    {
-                        //计算当前月份
-                        int days = 0;
-                        if (month >= 9)
-                        {
-                            tempStrart = new DateTime(year, 9, 1);
-                            tempEnd = new DateTime(year + 1, 2, (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) ? days = 29 : days = 28, 23, 59, 59);                        }
-                        else
-                        {
-                            tempStrart = new DateTime(year - 1, 9, 1);
-                            tempEnd = new DateTime(year, 2, (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) ? days = 29 : days = 28, 23, 59, 59);
-                        }
-                    }
-
-                    break;
-                case "lastterm":
-                    DateTimeOffset tempDate = new();
-                    if (dateTime.Month > 9)
-                        tempDate = new DateTime(year, dateTime.Month - 4, 1);
-                    else tempDate = new DateTime(year - 1, 9, 1);
-                    if (!string.IsNullOrEmpty($"{tempDate}"))
-                    {
-                        year = tempDate.Year;
-                        month = tempDate.Month;
+
+                long start = 0;
+                long end = 0;
+                int year = dateTime.Year;
+                int month = dateTime.Month;
+                int day = dateTime.Day;
+                int hour = dateTime.Hour;
+                DateTimeOffset tempStrart = new();
+                DateTimeOffset tempEnd = new();
+                switch (type)
+                {
+                    case "year":
+                        tempStrart = new DateTime(year, 1, 1);
+                        tempEnd = new DateTime(year, 12, DateTime.DaysInMonth(year, 12), 23, 59, 59);
+                        break;
+
+                    case "term":
                         if (month <= 8 && month >= 3)
                         {
                             tempStrart = new DateTime(year, 3, 1);
@@ -248,47 +221,84 @@ namespace TEAMModelBI.Tool
                                 tempEnd = new DateTime(year, 2, (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) ? days = 29 : days = 28, 23, 59, 59);
                             }
                         }
-                    }
-
-                    break;
-                case "month":
-                    tempStrart = new DateTime(year, month, 1);
-                    tempEnd = new DateTime(year, month, DateTime.DaysInMonth(year, month), 23, 59, 59);
-
-                    break;
-                case "week":
-                    DateTimeOffset weekStrart = dateTime.AddDays(-(int)(dateTime.DayOfWeek) + 1);
-                    DateTimeOffset weekEnd  = dateTime.AddDays(7-(int)(dateTime.DayOfWeek));
-                    tempStrart = new DateTime(weekStrart.Year, weekStrart.Month, weekStrart.Day);
-                    tempEnd = new DateTime(weekEnd.Year, weekEnd.Month, weekEnd.Day, 23, 59, 59); 
-
-                    break;
-                case "lastweek":
-                    var m = (dateTime.DayOfWeek == DayOfWeek.Sunday ? (DayOfWeek)7 : dateTime.DayOfWeek) - DayOfWeek.Monday;
-                    var s = (dateTime.DayOfWeek == DayOfWeek.Sunday ? (DayOfWeek)7 : dateTime.DayOfWeek) - (DayOfWeek)7;
-                    var Mon = dateTime.AddDays((-7 - m));//星期一
-                    var Sun = dateTime.AddDays((-7 - s));  //星期日
-                    tempStrart = new DateTime(Mon.Year, Mon.Month, Mon.Day);
-                    tempEnd = new DateTime(Sun.Year, Sun.Month, Sun.Day, 23, 59, 59);
-
-                    break;
-                case "hour":
-                    tempStrart = new DateTime(year, month, day, hour, 0, 0);
-                    tempEnd = new DateTime(year, month, day, hour, 59, 59);
-
-                    break;
-                default:
-                    tempStrart = new DateTime(year, month, day);
-                    tempEnd = new DateTime(year, month, day, 23, 59, 59);
-                    //start = dateLenth ? DateTimeOffset.Parse($"{dayStart}").ToUnixTimeMilliseconds() : DateTimeOffset.Parse($"{dayStart}").ToUnixTimeSeconds();
-                    //end = dateLenth ? DateTimeOffset.Parse($"{dayEnd}").ToUnixTimeMilliseconds() : DateTimeOffset.Parse($"{dayEnd}").ToUnixTimeSeconds();
-                    break;            
-            }
 
-            start = dateLenth ? DateTimeOffset.Parse($"{tempStrart}").ToUnixTimeMilliseconds() : DateTimeOffset.Parse($"{tempStrart}").ToUnixTimeSeconds();
-            end = dateLenth ? DateTimeOffset.Parse($"{tempEnd}").ToUnixTimeMilliseconds() : DateTimeOffset.Parse($"{tempEnd}").ToUnixTimeSeconds();
+                        break;
+                    case "lastterm":
+                        DateTimeOffset tempDate = new();
+                        if (dateTime.Month > 9)
+                            tempDate = new DateTime(year, dateTime.Month - 4, 1);
+                        else tempDate = new DateTime(year - 1, 9, 1);
+                        if (!string.IsNullOrEmpty($"{tempDate}"))
+                        {
+                            year = tempDate.Year;
+                            month = tempDate.Month;
+                            if (month <= 8 && month >= 3)
+                            {
+                                tempStrart = new DateTime(year, 3, 1);
+                                tempEnd = new DateTime(year, 8, 31, 23, 59, 59);
+                            }
+                            else
+                            {
+                                //计算当前月份
+                                int days = 0;
+                                if (month >= 9)
+                                {
+                                    tempStrart = new DateTime(year, 9, 1);
+                                    tempEnd = new DateTime(year + 1, 2, (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) ? days = 29 : days = 28, 23, 59, 59);
+                                }
+                                else
+                                {
+                                    tempStrart = new DateTime(year - 1, 9, 1);
+                                    tempEnd = new DateTime(year, 2, (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) ? days = 29 : days = 28, 23, 59, 59);
+                                }
+                            }
+                        }
+
+                        break;
+                    case "month":
+                        tempStrart = new DateTime(year, month, 1);
+                        tempEnd = new DateTime(year, month, DateTime.DaysInMonth(year, month), 23, 59, 59);
+
+                        break;
+                    case "week":
+                        DateTimeOffset weekStrart = dateTime.AddDays(-(int)(dateTime.DayOfWeek) + 1);
+                        DateTimeOffset weekEnd = dateTime.AddDays(7 - (int)(dateTime.DayOfWeek));
+                        tempStrart = new DateTime(weekStrart.Year, weekStrart.Month, weekStrart.Day);
+                        tempEnd = new DateTime(weekEnd.Year, weekEnd.Month, weekEnd.Day, 23, 59, 59);
+
+                        break;
+                    case "lastweek":
+                        var m = (dateTime.DayOfWeek == DayOfWeek.Sunday ? (DayOfWeek)7 : dateTime.DayOfWeek) - DayOfWeek.Monday;
+                        var s = (dateTime.DayOfWeek == DayOfWeek.Sunday ? (DayOfWeek)7 : dateTime.DayOfWeek) - (DayOfWeek)7;
+                        var Mon = dateTime.AddDays((-7 - m));//星期一
+                        var Sun = dateTime.AddDays((-7 - s));  //星期日
+                        tempStrart = new DateTime(Mon.Year, Mon.Month, Mon.Day);
+                        tempEnd = new DateTime(Sun.Year, Sun.Month, Sun.Day, 23, 59, 59);
+
+                        break;
+                    case "hour":
+                        tempStrart = new DateTime(year, month, day, hour, 0, 0);
+                        tempEnd = new DateTime(year, month, day, hour, 59, 59);
+
+                        break;
+                    default:
+                        tempStrart = new DateTime(year, month, day);
+                        tempEnd = new DateTime(year, month, day, 23, 59, 59);
+                        //start = dateLenth ? DateTimeOffset.Parse($"{dayStart}").ToUnixTimeMilliseconds() : DateTimeOffset.Parse($"{dayStart}").ToUnixTimeSeconds();
+                        //end = dateLenth ? DateTimeOffset.Parse($"{dayEnd}").ToUnixTimeMilliseconds() : DateTimeOffset.Parse($"{dayEnd}").ToUnixTimeSeconds();
+                        break;
+                }
 
-            return (start, end);
+                start = dateLenth ? DateTimeOffset.Parse($"{tempStrart}").ToUnixTimeMilliseconds() : DateTimeOffset.Parse($"{tempStrart}").ToUnixTimeSeconds();
+                end = dateLenth ? DateTimeOffset.Parse($"{tempEnd}").ToUnixTimeMilliseconds() : DateTimeOffset.Parse($"{tempEnd}").ToUnixTimeSeconds();
+
+                return (start, end);
+            }
+            catch (Exception ex)
+            {
+
+                throw;
+            }
         }
 
         /// <summary>

+ 4 - 3
TEAMModelBI/appsettings.Development.json

@@ -19,7 +19,7 @@
     "HttpTrigger": "https://teammodelosfunction-test.chinacloudsites.cn/api/"
     //"HttpTrigger": "http://localhost:7071/api/"
   },
-  //大陆站连接字符串
+  //大陆站连接字符串 现在是测试站
   "Azure": {
     "Storage": {
       "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodeltest;AccountKey=O2W2vadCqexDxWO+px+QK7y1sHwsYj8f/WwKLdOdG5RwHgW/Dupz9dDUb4c1gi6ojzQaRpFUeAAmOu4N9E+37A==;EndpointSuffix=core.chinacloudapi.cn"
@@ -45,10 +45,11 @@
   //国际站连接字符串  暂时是本地
   "GlobalAzure": {
     "Storage": {
-      "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodelstorage;AccountKey=Yq7D4dE6cFuer2d2UZIccTA/i0c3sJ/6ITc8tNOyW+K5f+/lWw9GCos3Mxhj47PyWQgDL8YbVD63B9XcGtrMxQ==;EndpointSuffix=core.chinacloudapi.cn" // 之前未删除
+      "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodelstorage;AccountKey=Yq7D4dE6cFuer2d2UZIccTA/i0c3sJ/6ITc8tNOyW+K5f+/lWw9GCos3Mxhj47PyWQgDL8YbVD63B9XcGtrMxQ==;EndpointSuffix=core.chinacloudapi.cn" // 之前未删除连接字符
     },
     "Cosmos": {
-      "ConnectionString": "AccountEndpoint=https://localhost:8081/;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==" //本地
+      //"ConnectionString": "AccountEndpoint=https://localhost:8081/;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==", //本地
+      "ConnectionString": "AccountEndpoint=https://cdhabookdep-free.documents.azure.cn:443/;AccountKey=JTUVk92Gjsx17L0xqxn0X4wX2thDPMKiw4daeTyV1HzPb6JmBeHdtFY1MF1jdctW1ofgzqkDMFOtcqS46by31A==;"  //测试站
     },
     "Redis": {
       "ConnectionString": "52.130.252.100:6379,password=habook,ssl=false,abortConnect=False,writeBuffer=10240"

+ 3 - 2
TEAMModelBI/appsettings.json

@@ -51,10 +51,11 @@
   //国际站连接字符串
   "GlobalAzure": {
     "Storage": {
-      "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodelstorage;AccountKey=Yq7D4dE6cFuer2d2UZIccTA/i0c3sJ/6ITc8tNOyW+K5f+/lWw9GCos3Mxhj47PyWQgDL8YbVD63B9XcGtrMxQ==;EndpointSuffix=core.chinacloudapi.cn" // 之前未删除
+      "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodelstorage;AccountKey=Yq7D4dE6cFuer2d2UZIccTA/i0c3sJ/6ITc8tNOyW+K5f+/lWw9GCos3Mxhj47PyWQgDL8YbVD63B9XcGtrMxQ==;EndpointSuffix=core.chinacloudapi.cn" // 之前未删除连接字符
     },
     "Cosmos": {
-      "ConnectionString": "AccountEndpoint=https://localhost:8081/;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==" //本地
+      //"ConnectionString": "AccountEndpoint=https://localhost:8081/;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==", //本地
+      "ConnectionString": "AccountEndpoint=https://cdhabookdep-free.documents.azure.cn:443/;AccountKey=JTUVk92Gjsx17L0xqxn0X4wX2thDPMKiw4daeTyV1HzPb6JmBeHdtFY1MF1jdctW1ofgzqkDMFOtcqS46by31A==;" //测试站
     },
     "Redis": {
       "ConnectionString": "52.130.252.100:6379,password=habook,ssl=false,abortConnect=False,writeBuffer=10240"