黄贺彬 6 ヶ月 前
コミット
4892286279

+ 9 - 3
HTEX.DataETL/Controllers/LessonRecordController.cs

@@ -365,7 +365,7 @@ namespace HTEX.DataETL.Controllers
             {
                 List<LessonRecord> lessonRecords = new List<LessonRecord>();
                 var resultSchool = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School)
-                    .GetList<LessonRecord>($"SELECT value c FROM   c  where c.startTime>={stime} and c.expire<=0  and c.status<>404  and c.duration>300 and c.pk='LessonRecord' ", null);
+                    .GetList<LessonRecord>($"SELECT value c FROM   c  where   ( c.analysis>=0 or IS_DEFINED(c.analysis) = false ) and  c.startTime>={stime} and c.expire<=0  and c.status<>404  and c.duration>300 and c.pk='LessonRecord' ", null);
                 if (resultSchool.list.IsNotEmpty())
                 {
                     newest= resultSchool.list.Max(x => x.startTime);
@@ -376,7 +376,7 @@ namespace HTEX.DataETL.Controllers
                     newest=stime;
                 }
                 var resultTeacher = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher)
-                   .GetList<LessonRecord>($"SELECT value c FROM   c  where c.startTime>={stime} and c.expire<=0  and c.status<>404  and c.duration>300 and c.pk='LessonRecord'   ", null);
+                   .GetList<LessonRecord>($"SELECT value c FROM   c  where   ( c.analysis>=0 or IS_DEFINED(c.analysis) = false ) and  c.startTime>={stime} and c.expire<=0  and c.status<>404  and c.duration>300 and c.pk='LessonRecord'   ", null);
                 if (resultTeacher.list.IsNotEmpty())
                 {
                     long max = resultTeacher.list.Max(x => x.startTime);
@@ -392,6 +392,12 @@ namespace HTEX.DataETL.Controllers
                     await foreach (var item in LessonETLService.GetLessonLocal(lessonRecords, localIds, _azureStorage, pathLessons))
                     {
                         string yearMonthPath = DateTimeOffset.FromUnixTimeMilliseconds(item.lessonRecord.startTime).ToString("yyyyMM");
+                        item.lessonRecord.learningCategory= item.lessonBase?.summary?.learningCategory;
+                        if (item.lessonRecord.learningCategory == null)
+                        {
+
+                            item. lessonRecord.learningCategory = new LearningCategory();
+                        }
                         await System.IO.File.WriteAllTextAsync($"{pathLessons}\\MM{yearMonthPath}\\{item.lessonRecord!.id}-local.json", item.ToJsonString());
                         //if (item.lessonBase!=null && item.lessonBase.student!=null)
                         //{
@@ -433,7 +439,7 @@ namespace HTEX.DataETL.Controllers
                 }
                 List<TechCount> techCounts = new List<TechCount>();
                 filesLessons = FileHelper.ListAllFiles(pathLessons, "-local.json");
-                await foreach (var item in LessonETLService.GetTeachCount(lessonRecords, filesLessons, pathLessons, ignore, Constant.objectiveTypes, _azureStorage, force))
+                await foreach (var item in LessonETLService.GetTeachCount(_azureCosmos,lessonRecords, filesLessons, pathLessons, ignore, Constant.objectiveTypes, _azureStorage, force))
                 {
                     techCounts.Add(item);
                 }

+ 27 - 4
TEAMModelOS.Extension/HTEX.Lib/ETL/Lesson/LessonETLService.cs

@@ -498,7 +498,7 @@ namespace HTEX.Lib.ETL.Lesson
             System.IO.File.WriteAllText(Path.Combine(pathAnalysis, "analysis.json"), lessonDataAnalysisCluster.ToJsonString());
         }
 
-        public static async IAsyncEnumerable<TechCount> GetTeachCount(List<LessonRecord> lessonRecords, List<string> filesLessons, string pathLessons, List<string> ignore, List<string> objectiveTypes, AzureStorageFactory azureStorage,bool force)
+        public static async IAsyncEnumerable<TechCount> GetTeachCount(AzureCosmosFactory azureCosmos,List<LessonRecord> lessonRecords, List<string> filesLessons, string pathLessons, List<string> ignore, List<string> objectiveTypes, AzureStorageFactory azureStorage,bool force)
         {
             List<TechCount> techCounts = new List<TechCount>();
             foreach (var item in filesLessons)
@@ -535,7 +535,8 @@ namespace HTEX.Lib.ETL.Lesson
                         var pickupData = LessonETLService.GetPickupData(lessonLocal.lessonBase!, lessonLocal.timeLineData!, studentLessonDatas, lessonLocal.lessonRecord.id);
                         studentLessonDatas= pickupData.studentLessonDatas;
                         var codeBools = LessonETLService.GetCodeBools(studentLessonDatas);
-                        if (codeBools.FindAll(x => x.value).IsNotEmpty()) 
+                        string yearMonth=DateTimeOffset.FromUnixTimeMilliseconds(lessonLocal.lessonRecord.startTime).ToString("yyyyMM");
+                        if (codeBools.FindAll(x => x.value).IsNotEmpty())
                         {
                             if (count==null) { count= new TechCount(); }
                             count.lessonId=item.Split("\\").Last().Replace("-local.json", "");
@@ -551,7 +552,7 @@ namespace HTEX.Lib.ETL.Lesson
                             if (lessonLocal.lessonRecord!=null)
                             {
 
-                                count.yearMonth=DateTimeOffset.FromUnixTimeMilliseconds(lessonLocal.lessonRecord.startTime).ToString("yyyyMM");
+                                count.yearMonth=yearMonth;
 
                                 if (lessonLocal?.lessonBase?.summary!=null)
                                 {
@@ -625,7 +626,7 @@ namespace HTEX.Lib.ETL.Lesson
                                     await System.IO.File.WriteAllTextAsync($"{pathLessons}\\MM{count.yearMonth}\\{lessonLocal.lessonRecord.id}-count.json", count.ToJsonString());
                                     //if (force)
                                     //{
-                                       
+
                                     //}
                                     //else
                                     //{
@@ -641,6 +642,28 @@ namespace HTEX.Lib.ETL.Lesson
                                 }
                             }
                         }
+                        else 
+                        {
+                            lessonLocal.lessonRecord.analysis=-1;
+                            if (lessonLocal.lessonRecord.scope.Equals("school"))
+                            {
+                                await azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).UpsertItemAsync(lessonLocal.lessonRecord, new PartitionKey(lessonLocal.lessonRecord.code));
+                            }
+                            else
+                            {
+                                await azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).UpsertItemAsync(lessonLocal.lessonRecord, new PartitionKey(lessonLocal.lessonRecord.code));
+                            }
+                            try
+                            {
+                                System.IO.File.Delete($"{pathLessons}\\MM{yearMonth}\\{lessonLocal.lessonRecord!.id}-local.json");
+                            }
+                            catch (Exception ex) { }
+                            try
+                            {
+                                System.IO.File.Delete($"{pathLessons}\\MM{yearMonth}\\{lessonLocal.lessonRecord!.id}-count.json");
+                            }
+                            catch (Exception ex) { }
+                        }
                     }
 
                     if (count!=null)

+ 4 - 1
TEAMModelOS.SDK/Models/Cosmos/Common/LessonRecord.cs

@@ -230,7 +230,10 @@ namespace TEAMModelOS.SDK.Models
         /// 课例来源 0 本公司  1 第三方公司    是因支持VR/AR那边课例
         /// </summary>
         public int source { get; set; } = 0;
-
+        /// <summary>
+        /// -1 代表不能进行分析的数据。未定义和 0未分析的数据, 1代表已分析的数据
+        /// </summary>
+        public int analysis { get; set; }
     }
 
     /*