CrazyIter_Bin hace 6 meses
padre
commit
99fb8bb167

+ 25 - 7
HTEX.DataETL/Controllers/LessonRecordController.cs

@@ -212,8 +212,9 @@ namespace HTEX.DataETL.Controllers
                 }
             }
             long stime = 1693497600000;//2023-08-01 00:00:00
+            long etime = 1731513599000;//2023-08-01 00:00:00
             var resultSchool = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School)
-                 .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' ");
+                 .GetList<LessonRecord>($"SELECT value c FROM   c  where   ( c.analysis>=0 or IS_DEFINED(c.analysis) = false ) and c.startTime>={stime} and c.startTime<={etime} and   c.expire<=0  and c.status<>404  and c.duration>300 and c.pk='LessonRecord' ");
             List<string> ignore = new List<string>() { "PgJump", "PgRcv", "PgAdd" };
             int index = 0;
             if (resultSchool.list.IsNotEmpty())
@@ -221,24 +222,41 @@ namespace HTEX.DataETL.Controllers
                 List<StudentSemesterRecord>  studentSemesterRecords= new List<StudentSemesterRecord>();
                 List<OverallEducation> overallEducations= new List<OverallEducation>();
                 List<Student> studentsBase = new List<Student>();
+                List<LessonLocal>lessonLocals = new List<LessonLocal>();
                 await Parallel.ForEachAsync(resultSchool.list, async (lessonRecord, cancellationToken) =>
                 {
                     var  item = await LessonETLService.GetLessonLocal(lessonRecord,localIds,_azureStorage,pathLessons);
-                    var studata = await LessonETLService.DoStudentLessonData(Constant.objectiveTypes, _azureStorage, item, _dingDing, _azureCosmos.GetCosmosClient(), "China", _azureRedis, studentSemesterRecords, overallEducations, lessonDataAnalysis, studentsBase, schools);
+                    lessonLocals.Add(item);
                     index++;
                 });
-               
+                int n = 0;
+                var  schoolGroup =   lessonLocals.Where(x=>!string.IsNullOrWhiteSpace(x.lessonRecord?.school)).GroupBy(x => x.lessonRecord?.school).Select(x => new { key=x.Key ,list=x.ToList()});
+                string schoolSql = $"select value c from c where c.id in ({string.Join(",", schoolGroup.Select(x => $"'{x.key}'"))})";
+                var schoolResults= await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetList<School>(schoolSql, "Base");
+                if (schoolResults.list.IsNotEmpty()) 
+                {
+                    schools.AddRange(schoolResults.list);
+                }
+
+                foreach (var  item in lessonLocals) 
+                {
+                    var studata = await LessonETLService.DoStudentLessonData(Constant.objectiveTypes, _azureStorage, item, _dingDing, _azureCosmos.GetCosmosClient(), "China", _azureRedis, studentSemesterRecords, overallEducations, lessonDataAnalysis, studentsBase, schools);
+                    n++;
+                }
+                int m   =0;
                 await Parallel.ForEachAsync(studentSemesterRecords, async (studentSemester, cancellationToken) => 
                 {
                     await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).UpsertItemAsync(studentSemester, new PartitionKey(studentSemester.code));
-
+                    m++;
                 });
+                int k = 0;
                 await Parallel.ForEachAsync(overallEducations, async (overallEducation, cancellationToken) =>
                 {
                     await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).UpsertItemAsync(overallEducation, partitionKey: new PartitionKey(overallEducation.code));
-                    string key = $"OverallEducation:{overallEducation.schoolCode}:{overallEducation.periodId}:{overallEducation.year}:{overallEducation.semesterId}:{overallEducation?.classId}";
-                    await _azureRedis.GetRedisClient(8).HashSetAsync(key, overallEducation.studentId, overallEducation.ToJsonString());
-                    await _azureRedis.GetRedisClient(8).KeyExpireAsync(key, new TimeSpan(180 *24, 0, 0));
+                    //string key = $"OverallEducation:{overallEducation.schoolCode}:{overallEducation.periodId}:{overallEducation.year}:{overallEducation.semesterId}:{overallEducation?.classId}";
+                    //await _azureRedis.GetRedisClient(8).HashSetAsync(key, overallEducation.studentId, overallEducation.ToJsonString());
+                    //await _azureRedis.GetRedisClient(8).KeyExpireAsync(key, new TimeSpan(180 *24, 0, 0));
+                    k++;
                 });
             }
             return Ok();

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

@@ -103,8 +103,9 @@ namespace HTEX.Lib.ETL.Lesson
             }
             return codeBools;
         }
-     
 
+      
+       
         /// <summary>
         /// 生成学生student-analysis.json
         /// </summary>
@@ -2346,11 +2347,11 @@ namespace HTEX.Lib.ETL.Lesson
         {
 
             //历史记录的个人计分集合,通过“2倍标准差规则”移除异常值后得到的集合
-            var max_q = lessonDataAnalysis.pscore.Max();
+            //var max_q = lessonDataAnalysis.pscore.Max();
             //历史记录的互动计分集合,通过“2倍标准差规则”移除异常值后得到的集合
-            var max_t = lessonDataAnalysis.tscore.Max();
+            //var max_t = lessonDataAnalysis.tscore.Max();
             //历史记录的小组计分集合,通过“2倍标准差规则”移除异常值后得到的集合
-            var max_h = lessonDataAnalysis.gscore.Max();
+           // var max_h = lessonDataAnalysis.gscore.Max();
             var j = InteractWeight.T1;
             double t = InteractWeight.TT;
             List<StudentLessonItem> lessonItems = new List<StudentLessonItem>();

+ 12 - 9
TEAMModelOS/Controllers/System/BlobController.cs

@@ -951,11 +951,12 @@ namespace TEAMModelOS.Controllers
                 if (exists)
                 {
                     ttl=0;
-                    var ttlVals = await _azureRedis.GetRedisClient(8).KeyExpireTimeAsync($"Blob:ScanResult:{scope}:{containerName}");
+                    var ttlVals = await _azureRedis.GetRedisClient(8).KeyTimeToLiveAsync($"Blob:ScanResult:{scope}:{containerName}");
                     if (ttlVals.HasValue)
                     {
-                        ttl = DateTimeHelper.ToUnixTimestamp(ttlVals.Value);
-                        ttl= ttl- DateTimeOffset.Now.ToUnixTimeMilliseconds();
+                        ttl =(long) ttlVals.Value.TotalMilliseconds;
+                        //ttl = DateTimeHelper.ToUnixTimestamp(ttlVals.Value);
+                        //ttl= ttl- DateTimeOffset.Now.ToUnixTimeMilliseconds();
                     }
                     var result = await _azureRedis.GetRedisClient(8).StringGetAsync($"Blob:ScanResult:{scope}:{containerName}");
                     if (result.HasValue)
@@ -1057,11 +1058,13 @@ namespace TEAMModelOS.Controllers
             bool exists = await _azureRedis.GetRedisClient(8).KeyExistsAsync($"Blob:ScanResult:{scope}:{containerName}");
             if (exists)
             {
-                var ttlVal=  await _azureRedis.GetRedisClient(8).KeyExpireTimeAsync($"Blob:ScanResult:{scope}:{containerName}");
+              //  var ttlVal=  await _azureRedis.GetRedisClient(8).KeyExpireTimeAsync($"Blob:ScanResult:{scope}:{containerName}");
+                var ttlVal = await _azureRedis.GetRedisClient(8).KeyTimeToLiveAsync($"Blob:ScanResult:{scope}:{containerName}");
                 if (ttlVal.HasValue) 
                 {
-                    ttl = DateTimeHelper.ToUnixTimestamp(ttlVal.Value);
-                    ttl= ttl- DateTimeOffset.Now.ToUnixTimeMilliseconds();
+                   // var ttk = ttlVal.Value.TotalMilliseconds;
+                    ttl = (long )ttlVal.Value.TotalMilliseconds;
+                   // ttl= ttl- DateTimeOffset.Now.ToUnixTimeMilliseconds();
                 }
                 var result = await _azureRedis.GetRedisClient(8).StringGetAsync($"Blob:ScanResult:{scope}:{containerName}");
                 if (result.HasValue)
@@ -1449,11 +1452,11 @@ namespace TEAMModelOS.Controllers
 
              _azureRedis.GetRedisClient(8).StringSet($"Blob:ScanResult:{scope}:{containerName}", unLinks.ToJsonString(), expiry: new TimeSpan(0, 3, 0));
  
-            var ttlVals = await _azureRedis.GetRedisClient(8).KeyExpireTimeAsync($"Blob:ScanResult:{scope}:{containerName}");
+            var ttlVals = await _azureRedis.GetRedisClient(8).KeyTimeToLiveAsync($"Blob:ScanResult:{scope}:{containerName}");
             if (ttlVals.HasValue)
             {
-                ttl = DateTimeHelper.ToUnixTimestamp(ttlVals.Value);
-                ttl= ttl- DateTimeOffset.Now.ToUnixTimeMilliseconds();
+                ttl = (long)ttlVals.Value.TotalMilliseconds;
+               // ttl= ttl- DateTimeOffset.Now.ToUnixTimeMilliseconds();
             }
             return Ok(new { status = 1, totalCount, totalSize, summary, unLinks, ttl });
         }