Browse Source

[BI]每日統計TMID及DeviceID機制 (途中)

jeff 1 năm trước cách đây
mục cha
commit
38d16d247d

+ 2 - 2
TEAMModelBI/Controllers/RepairApi/SchoolRepController.cs

@@ -581,7 +581,7 @@ namespace TEAMModelBI.Controllers.RepairApi
         public async Task<IActionResult> SetAllProdAnalysis()
         {
             var _azureCosmosClient = _azureCosmos.GetCosmosClient();
-            var _azureCosmosClientCsv1 = _azureCosmos.GetCosmosClient(name: "CoreServiceV1");
+            var _azureCosmosClientCsv2Read = _azureCosmos.GetCosmosClient(name: "CoreServiceV2CnRead");
             var datetime = DateTimeOffset.UtcNow;
             var y = $"{datetime.Year}";
             var redisClinet2 = _azureRedis.GetRedisClient(2);
@@ -608,7 +608,7 @@ namespace TEAMModelBI.Controllers.RepairApi
                     {
                         string m = date.Substring(0, 2);
                         string d = date.Substring(2, 2);
-                        await BIProdAnalysis.BICreatDailyAnalData(_azureRedis, _azureCosmosClient, _azureCosmosClientCsv1, _dingDing, y, m, d);
+                        await BIProdAnalysis.BICreatDailyAnalData(_azureRedis, _azureCosmosClient, _azureCosmosClientCsv2Read, _dingDing, y, m, d);
                         resultKeys.Add($"{key}");
                     }
                 }

+ 1 - 0
TEAMModelBI/Startup.cs

@@ -107,6 +107,7 @@ namespace TEAMModelBI
             cosmosDBConnects.Add(("Global", Configuration.GetValue<string>("GlobalAzure:Cosmos:ConnectionString"))); //国际站ConnectString
             cosmosDBConnects.Add(("CoreServiceV1", Configuration.GetValue<string>("CoreServiceV1:Cosmos:ConnectionString"))); //CoreService V1 read only
             cosmosDBConnects.Add(("CoreServiceV2", Configuration.GetValue<string>("CoreServiceV2:Cosmos:ConnectionString"))); //CoreService V2
+            cosmosDBConnects.Add(("CoreServiceV2CnRead", Configuration.GetValue<string>("CoreServiceV2:CosmosCnRead:ConnectionString"))); //CoreService V2 read only
             services.AddMultipleAzureCosmos(cosmosDBConnects);
 
             //redis注入

+ 1 - 0
TEAMModelOS.FunctionV4/Program.cs

@@ -64,6 +64,7 @@ namespace TEAMModelOS.FunctionV4
                List<(string name, string connectionString)> cosmosDBConnects = new();
                cosmosDBConnects.Add(("Default", context.Configuration.GetSection("Azure:Cosmos:ConnectionString").Get<string>()));
                cosmosDBConnects.Add(("CoreServiceV1", context.Configuration.GetSection("CoreServiceV1:Cosmos:ConnectionString").Get<string>())); //CoreService V1 read only
+               cosmosDBConnects.Add(("CoreServiceV2CnRead", context.Configuration.GetSection("CoreServiceV2:CosmosCnRead:ConnectionString").Get<string>())); //CoreService V2 CN read only
                services.AddMultipleAzureCosmos(cosmosDBConnects);
                //services.AddAzureCosmos(context.Configuration.GetSection("Azure:Cosmos:ConnectionString").Get<string>());
                services.AddAzureServiceBus(context.Configuration.GetSection("Azure:ServiceBus:ConnectionString").Get<string>());

+ 3 - 3
TEAMModelOS.FunctionV4/TimeTrigger/IESTimerTrigger.cs

@@ -423,16 +423,16 @@ namespace TEAMModelOS.FunctionV4.TimeTrigger
         //0 1 0 * * * 一天中00的第 1 分钟
         //0 1 * * * * 一天中每小时的第 1 分钟
         //0 */10 * * * *  每五分钟一次
-        public async Task BICreatDailyAnalData([TimerTrigger("0 1 1 * * *")] TimerInfo myTimer, ILogger log)
+        public async Task BICreatDailyAnalData([TimerTrigger("0 31 9 * * *")] TimerInfo myTimer, ILogger log)
         {
             var _azureCosmosClient = _azureCosmos.GetCosmosClient();
-            var _azureCosmosClientCsv1 = _azureCosmos.GetCosmosClient(name: "CoreServiceV1");
+            var _azureCosmosClientCsv2CnRead = _azureCosmos.GetCosmosClient(name: "CoreServiceV2CnRead");
             var datetime = DateTimeOffset.UtcNow.AddHours(-12); //統計昨天的數據
             var y = $"{datetime.Year}";
             var m = datetime.Month >= 10 ? $"{datetime.Month}" : $"0{datetime.Month}";
             var d = datetime.Day >= 10 ? $"{datetime.Day}" : $"0{datetime.Day}";
             //生成學校IOT數據
-            await BIProdAnalysis.BICreatDailyAnalData(_azureRedis, _azureCosmosClient, _azureCosmosClientCsv1, _dingDing, y, m, d);
+            await BIProdAnalysis.BICreatDailyAnalData(_azureRedis, _azureCosmosClient, _azureCosmosClientCsv2CnRead, _dingDing, y, m, d);
             //刪除三個月以前的Redis數據 [待做]
         }
 

+ 28 - 37
TEAMModelOS.FunctionV4/local.settings.json

@@ -1,40 +1,31 @@
 {
   "IsEncrypted": false,
-  "Values": {
-    "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=teammodellog;AccountKey=lxVDrgs+6rKtmASL3k1WrarrEd5Rk42wS1Mu5+sqQlPya1JLSlFDtnZUvMPeHHe7zlESfn/1NY7CZdGviy2UCw==;EndpointSuffix=core.chinacloudapi.cn",
-    "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
-    "Azure:Storage:ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodeltest;AccountKey=O2W2vadCqexDxWO+px+QK7y1sHwsYj8f/WwKLdOdG5RwHgW/Dupz9dDUb4c1gi6ojzQaRpFUeAAmOu4N9E+37A==;EndpointSuffix=core.chinacloudapi.cn",
-    "Azure:LogStorage:ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodellog;AccountKey=lxVDrgs+6rKtmASL3k1WrarrEd5Rk42wS1Mu5+sqQlPya1JLSlFDtnZUvMPeHHe7zlESfn/1NY7CZdGviy2UCw==;EndpointSuffix=core.chinacloudapi.cn",
-    "Azure:ServiceBus:ConnectionString": "Endpoint=sb://teammodelos.servicebus.chinacloudapi.cn/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=Sy4h4EQ8zP+7w/lOLi1X3tGord/7ShFHimHs1vC50Dc=",
-    "Azure:Cosmos:ConnectionString": "AccountEndpoint=https://cdhabookdep-free.documents.azure.cn:443/;AccountKey=JTUVk92Gjsx17L0xqxn0X4wX2thDPMKiw4daeTyV1HzPb6JmBeHdtFY1MF1jdctW1ofgzqkDMFOtcqS46by31A==;",
-    "Azure:Redis:ConnectionString": "52.130.252.100:6379,password=habook,ssl=false,abortConnect=False,writeBuffer=10240",
-    "Azure:ServiceBus:ActiveTask": "dep-active-task",
-    "Azure:ServiceBus:ItemCondQueue": "dep-itemcond",
-    "Azure:ServiceBus:GenPdfQueue": "dep-genpdf",
-    "Option:Location": "China-Dep",
-    "HaBookAuth:CoreService:sendnotification": "https://api2.teammodel.cn/service/sendnotification",
-    "HaBookAuth:CoreAPI": "https://api2.teammodel.cn",
-    "HaBookAuth:CoreService:clientID": "c7317f88-7cea-4e48-ac57-a16071f7b884",
-    "HaBookAuth:CoreService:clientSecret": "kguxh:V.PLmxBdaI@jnrTrDSth]A3346",
-	"CoreServiceV1:Cosmos:ConnectionString": "AccountEndpoint=https://corecosmosdbcn.documents.azure.cn:443/;AccountKey=WIFUWgnC6HiPb4yYba5iLR4ZghcA2fqrEvnX00YTA5B4sd7o89sxtbvgFDDUqT2VRkeWrWVTWZ8VbApQtwkJKQ==;", //CSV1大陸正式站(唯讀)
-    "Option:LocationNum": 1
-  }
-  //"Values": {
-  //  "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=teammodellog;AccountKey=lxVDrgs+6rKtmASL3k1WrarrEd5Rk42wS1Mu5+sqQlPya1JLSlFDtnZUvMPeHHe7zlESfn/1NY7CZdGviy2UCw==;EndpointSuffix=core.chinacloudapi.cn",
-  //  "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
-  //  "Azure:Storage:ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodelos;AccountKey=Dl04mfZ9hE9cdPVO1UtqTUQYN/kz/dD/p1nGvSq4tUu/4WhiKcNRVdY9tbe8620nPXo/RaXxs+1F9sVrWRo0bg==;EndpointSuffix=core.chinacloudapi.cn",
-  //  "Azure:LogStorage:ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodellog;AccountKey=lxVDrgs+6rKtmASL3k1WrarrEd5Rk42wS1Mu5+sqQlPya1JLSlFDtnZUvMPeHHe7zlESfn/1NY7CZdGviy2UCw==;EndpointSuffix=core.chinacloudapi.cn",
-  //  "Azure:ServiceBus:ConnectionString": "Endpoint=sb://coreiotservicebuscnpro.servicebus.chinacloudapi.cn/;SharedAccessKeyName=TEAMModelOS;SharedAccessKey=llRPBMDJG9w1Nnifj+pGhV0g4H2REcq0PjvX2qqpcOg=",
-  //  "Azure:Cosmos:ConnectionString": "AccountEndpoint=https://cdhabookdep-free.documents.azure.cn:443/;AccountKey=JTUVk92Gjsx17L0xqxn0X4wX2thDPMKiw4daeTyV1HzPb6JmBeHdtFY1MF1jdctW1ofgzqkDMFOtcqS46by31A==;",
-  //  "Azure:Redis:ConnectionString": "52.130.252.100:6379,password=habook,ssl=false,abortConnect=False,writeBuffer=10240",
-  //  "Azure:ServiceBus:ActiveTask": "active-task",
-  //  "Azure:ServiceBus:ItemCondQueue": "itemcond",
-  //  "Azure:ServiceBus:GenPdfQueue": "genpdf",
-  //  "Option:Location": "China",
-  //  "HaBookAuth:CoreService:sendnotification": "https://api2.teammodel.cn/service/sendnotification",
-  //  "HaBookAuth:CoreAPI": "https://api2.teammodel.cn",
-  //  "HaBookAuth:CoreService:clientID": "c7317f88-7cea-4e48-ac57-a16071f7b884",
-  //  "HaBookAuth:CoreService:clientSecret": "kguxh:V.PLmxBdaI@jnrTrDSth]A3346",
-  //  "Option:LocationNum": 1
-  //}
+	"Values": {
+		"AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=teammodeltest;AccountKey=t6XZuachzUBJDSN8RLtoeVqSE6HcXrFZFBmlF1n3G5jA2/Ltvx8jAL4z7C9MdfzLFRHI88/hTBbrK68K0lQeDw==;EndpointSuffix=core.windows.net",
+		"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
+		"Azure:Storage:ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodeltest;AccountKey=t6XZuachzUBJDSN8RLtoeVqSE6HcXrFZFBmlF1n3G5jA2/Ltvx8jAL4z7C9MdfzLFRHI88/hTBbrK68K0lQeDw==;EndpointSuffix=core.windows.net",
+		"Azure:ServiceBus:ConnectionString": "Endpoint=sb://teammodel-test.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=iEA1MP9rYUfhYgMOp40g3SRHVyLrSoQTO7fa7aMWBEg=",
+		"Azure:Cosmos:ConnectionString": "AccountEndpoint=https://teammodel-test.documents.azure.com:443/;AccountKey=W38PnllgIJ3I879l8l4mGgFD1YZpPpYrbTtbBfgZvBavdNzveixvjjXXxFzx4RRDfpTmJuCtst5dXh7cETiSRQ==;",
+		"Azure:Redis:ConnectionString": "teammodel-test.redis.cache.windows.net:6380,password=qRDLVsl6NRkv3tbtlNpXr0568fAMXJH2GAzCaAYYExE=,ssl=True,abortConnect=False",
+		"Azure:ServiceBus:ActiveTask": "dep-active-task",
+		"Azure:ServiceBus:ItemCondQueue": "dep-itemcond",
+		"Azure:ServiceBus:NoticeTask": "dep-notice-task",
+		"Azure:ServiceBus:GenPdfQueue": "dep-genpdf",
+		"Option:Location": "Global-Test",
+		"HaBookAuth:CoreService:sendnotification": "https://api2.teammodel.net/service/sendnotification",
+		"HaBookAuth:CoreAPI": "https://api2.teammodel.net",
+		"HaBookAuth:CoreService:clientID": "531fecd1-b1a5-469a-93ca-7984e1d392f2",
+		"HaBookAuth:CoreService:clientSecret": "iI2cmTIX?fnXrwnffo84/:_X954=sw:.",
+		"CoreServiceV1:Cosmos:ConnectionString": "AccountEndpoint=https://coredocumentdbjp.documents.azure.com:443/;AccountKey=aY6AjEYuPwRJEQRDX6bFN3Z87I7LwZ72dN1qON7j5E3VPpUEc2z0YDVzdCTUDvHzIEuoQosGu8e0AYCHUfcSnw==;", //CSV1國際正式站(唯讀)
+		"CoreServiceV2:CosmosCnRead:ConnectionString": "AccountEndpoint=https://corecosmosdb.documents.azure.cn:443/;AccountKey=12C5n8IvXFqsPARUb2YBOUWiU9PksohESlLHgH6cAVajxWBBJIJ6chJusgfrYhxCKgQgSHHxVgHsFPRakhvlPw==", //CSV2大陸正式站(唯讀)
+
+		"ScanModel": "TEAMModelOS",
+		"Database": "TEAMModelOS",
+		"Azure:CoreService:clientID": "c7317f88-7cea-4e48-ac57-a16071f7b884",
+		"Azure:CoreService:clientSecret": "kguxh:V.PLmxBdaI@jnrTrDSth]A3346",
+		"Azure:CoreService:delnotification": "https://api2.teammodel.net/service/delnotification",
+		"Azure:CoreService:deviceinfo": "https://api2.teammodel.net/oauth2/getdeviceinfos",
+		"Azure:CoreService:getnotification": "https://api2.teammodel.net/service/getnotification",
+		"Azure:CoreService:sendnotification": "https://api2.teammodel.net/service/sendnotification"
+	}  
 }

+ 2 - 152
TEAMModelOS.SDK/Models/Cosmos/School/ProductAnalysis.cs

@@ -1,164 +1,14 @@
 using System;
 using System.Collections.Generic;
 using System.Text;
+using TEAMModelOS.SDK.Models.Cosmos.Common;
 using TEAMModelOS.SDK.Models.Dtos;
 
 namespace TEAMModelOS.SDK.Models
 {
-    /// <summary>
-    /// CS IOT TeachingData (Redis)
-    /// </summary>
-    public class IotTeachingData
-    {
-        public long timestamp { get; set; }
-        public string deviceId { get; set; }
-        public string channel { get; set; }
-        public string tmid { get; set; }
-        public string schoolId { get; set; }
-        /// <summary>
-        /// 開課使用IES課程 0:false 1:true
-        /// </summary>
-        public string useIES { get; set; }
-        /// <summary>
-        /// 課堂中取用IES5資源數
-        /// </summary>
-        public int useIES5Resource { get; set; }
-        /// <summary>
-        /// 課堂中有使用webirs 0:false 1:true
-        /// </summary>
-        public string useWebIrs { get; set; }
-        /// <summary>
-        /// 課堂中有使用硬體IRS 0:false 1:true
-        /// </summary>
-        public string useDeviceIrs { get; set; }
-        /// <summary>
-        /// 課堂中有使用Haboard 0:false 1:true
-        /// </summary>
-        public string useHaboard { get; set; }
-        /// <summary>
-        /// 課堂中有使用HiTA 0:false 1:true
-        /// </summary>
-        public string useHita { get; set; }
-        /// <summary>
-        /// 課堂時間(分鐘整數)
-        /// </summary>
-        public int lessonLengMin { get; set; }
-        /// <summary>
-        /// 學生出席數(整數)
-        /// </summary>
-        public int stuShow { get; set; }
-        /// <summary>
-        /// T指數(整數)
-        /// </summary>
-        public int tPoint { get; set; }
-        /// <summary>
-        /// 學習型態: 合作 0:false 1:true
-        /// </summary>
-        public string lTypeCoop { get; set; }
-        /// <summary>
-        /// 學習型態: 互動 0:false 1:true
-        /// </summary>
-        public string lTypeIact { get; set; }
-        /// <summary>
-        /// 學習型態: 任務 0:false 1:true
-        /// </summary>
-        public string lTypeMis { get; set; }
-        /// <summary>
-        /// 學習型態: 測驗 0:false 1:true
-        /// </summary>
-        public string lTypeTst { get; set; }
-        /// <summary>
-        /// 學習型態: 差異化 0:false 1:true
-        /// </summary>
-        public string lTypeDif { get; set; }
-        /// <summary>
-        /// 授權方式 0:無授權   1:id授權  2:機器授權  3:ID和機器授權
-        /// </summary>
-        public string authType { get; set; }
-        /// <summary>
-        /// 任務數
-        /// </summary>
-        public int mission { get; set; }
-        /// <summary>
-        /// 作品任務完成總數
-        /// </summary>
-        public int missionFin { get; set; }
-        /// <summary>
-        /// 題數
-        /// </summary>
-        public int item { get; set; }
-        /// <summary>
-        /// 互動總次數
-        /// </summary>
-        public int interact { get; set; }
-        /// <summary>
-        /// IP
-        /// </summary>
-        public string ip { get; set; }
-        /// <summary>
-        /// 版本
-        /// </summary>
-        /// [例]ex. 5.0.21.0000 -> 500210000
-        public string version { get; set; }
-        /// <summary>
-        /// 是否送出小數據或SOK服務 0:false 1:true
-        /// </summary>
-        public string sendSok { get; set; }
-    }
-
-
-    public class ProdAnalysisBase
+    public class ProdAnalysis : ProdAnalysisCalItem
     {
         public string schoolId { get; set; } //學校ID
-        public string toolType { get; set; } //HiTeach、HiTeachCC、HiTA
-        public int deviceCnt { get; set; } //機器數(不重複)
-        public int deviceNoAuth { get; set; } //無機器授權數
-        public int deviceAuth { get; set; } //有安裝機器授權數
-        public int tmidCnt { get; set; } //TMID數(不重複)
-        public int lessonRecord { get; set; } //課堂記錄數
-        public int useIES { get; set; } //使用IES課程
-        public int useIES5Resource { get; set; } //課堂中取用IES5資源數
-        public int useWebIrs { get; set; } //課堂中有使用webirs
-        public int useDeviceIrs { get; set; } //課堂中有使用硬體IRS
-        public int useHaboard { get; set; } //課堂中有使用Haboard
-        public int useHita { get; set; } //課堂中有使用HiTA
-        public int lessonLengMin { get; set; } //課堂時間(分鐘整數)
-        public int lessonLeng0 { get; set; } //課堂時間為0的課堂數
-        public int stuShow { get; set; } //學生出席人次
-        public long stuLessonLengMin { get; set; } //學生參與總時數 ※課堂時間x學生出席人次
-        public int tGreen { get; set; } //T綠燈數(T>=70)
-        public int lTypeCoop { get; set; } //學習型態: 合作
-        public int lTypeIact { get; set; } //學習型態: 互動
-        public int lTypeMis { get; set; } //學習型態: 任務
-        public int lTypeTst { get; set; } //學習型態: 測驗
-        public int lTypeDif { get; set; } //學習型態: 差異化
-        public int lTypeNone { get; set; } //學習型態: 無
-        public int lessonCnt928 { get; set; } //使用928授權課堂數
-        public int lessonCntId { get; set; } //僅使用ID授權課堂數
-        public int lessonCntDevice { get; set; } //僅使用機器授權課堂數
-        public int lessonCntIdDevice { get; set; } //使用ID+機器授權課堂數
-        public int mission { get; set; } //任務數
-        public int missionFin { get; set; } //作品任務完成總數
-        public int item { get; set; } //題數
-        public int interact { get; set; } //互動總次數
-        public int sendSok { get; set; } //送出小數據或SOK服務
-    }
-    /// <summary>
-    /// IES5 ProdAnalysis (Redis)
-    /// </summary>
-    public class ProdAnalysis : ProdAnalysisBase
-    {
-        public ProdAnalysis()
-        {
-            deviceList = new List<string>();
-            deviceNoAuthList = new List<string>();
-            deviceAuthList = new List<string>();
-            tmidList = new List<string>();
-        }
-        public List<string> deviceList { get; set; } //機器ID列表
-        public List<string> deviceNoAuthList { get; set; } //無機器授權ID列表
-        public List<string> deviceAuthList { get; set; } //有安裝機器授權ID列表
-        public List<string> tmidList { get; set; } //TMID列表
     }
 
     public class ProdAnalysisApiResult : ProdAnalysis

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 971 - 363
TEAMModelOS.SDK/Models/Service/BI/BIProdAnalysis.cs