CrazyIter_Bin 6 månader sedan
förälder
incheckning
0ff30037b1

+ 182 - 60
HTEX.DataETL/Controllers/LessonRecordController.cs

@@ -1,11 +1,14 @@
 using DocumentFormat.OpenXml.Drawing.Charts;
 using DocumentFormat.OpenXml.Drawing.Charts;
+using DocumentFormat.OpenXml.Spreadsheet;
 using HTEX.Lib.ETL.Lesson;
 using HTEX.Lib.ETL.Lesson;
 using MathNet.Numerics.Distributions;
 using MathNet.Numerics.Distributions;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Azure.Cosmos;
 using Microsoft.Azure.Cosmos;
 using StackExchange.Redis;
 using StackExchange.Redis;
 using System.Collections.Generic;
 using System.Collections.Generic;
+using System.Reflection;
 using System.Text.Json;
 using System.Text.Json;
+using System.Text.RegularExpressions;
 using System.Xml;
 using System.Xml;
 using TEAMModelOS.SDK;
 using TEAMModelOS.SDK;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.DI;
@@ -189,8 +192,6 @@ namespace HTEX.DataETL.Controllers
         [HttpPost("process-history-students")]
         [HttpPost("process-history-students")]
         public async Task<IActionResult> ProcessHistoryStudents(JsonElement json)
         public async Task<IActionResult> ProcessHistoryStudents(JsonElement json)
         {
         {
-
-          
             string? lessonBasePath = _configuration.GetValue<string>("LessonPath");
             string? lessonBasePath = _configuration.GetValue<string>("LessonPath");
             string? pathLessons = $"{lessonBasePath}\\lessons";
             string? pathLessons = $"{lessonBasePath}\\lessons";
             string? pathAnalysis = $"{lessonBasePath}\\analysis";
             string? pathAnalysis = $"{lessonBasePath}\\analysis";
@@ -205,60 +206,143 @@ namespace HTEX.DataETL.Controllers
             List<string> localIds = new List<string>();
             List<string> localIds = new List<string>();
             foreach (var file in filesLessons)
             foreach (var file in filesLessons)
             {
             {
-                if (file.EndsWith("-local.json"))
-                {
-                    string lessonId = file.Split("\\").Last().Replace("-local.json", "");
-                    localIds.Add(lessonId);
-                }
+                string lessonId = file.Split("\\").Last().Replace("-local.json", "");
+                localIds.Add(lessonId);
+            }
+            List<LessonRecord> lessonRecords = new List<LessonRecord>();
+            string recordsPtah = $"{lessonBasePath}\\records\\records.json";
+            long stime = 0;//2023-09-01 00:00:00
+            long etime = 0;//2024-11-13 23:59:59
+            if (System.IO.File.Exists(recordsPtah))
+            {
+                string jsonData = await System.IO.File.ReadAllTextAsync(recordsPtah);
+                lessonRecords= jsonData.ToObject<List<LessonRecord>>();
+                stime= lessonRecords.Max(x => x.startTime);
+                etime= lessonRecords.Max(x => x.startTime);
             }
             }
-            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.startTime<={etime} and   c.expire<=0  and c.status<>404  and c.duration>300 and c.pk='LessonRecord' ");
+            if (stime==0) 
+            {
+                stime = 1693497600000;//2023-09-01 00:00:00
+            }
+            if (etime==0) 
+            {
+                etime = 1731513599000;//2024-11-13 23:59:59
+            }
+            var resultSchools = 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.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" };
             List<string> ignore = new List<string>() { "PgJump", "PgRcv", "PgAdd" };
             int index = 0;
             int index = 0;
-            if (resultSchool.list.IsNotEmpty())
+            if (resultSchools.list.IsNotEmpty()) 
+            {
+                lessonRecords.AddRange(resultSchools.list);
+            }
+            if (lessonRecords.IsNotEmpty())
             {
             {
+                
+                await System.IO.File.WriteAllTextAsync(recordsPtah, lessonRecords.ToJsonString());
                 List<StudentSemesterRecord>  studentSemesterRecords= new List<StudentSemesterRecord>();
                 List<StudentSemesterRecord>  studentSemesterRecords= new List<StudentSemesterRecord>();
                 List<OverallEducation> overallEducations= new List<OverallEducation>();
                 List<OverallEducation> overallEducations= new List<OverallEducation>();
                 List<Student> studentsBase = new List<Student>();
                 List<Student> studentsBase = new List<Student>();
                 List<LessonLocal>lessonLocals = new List<LessonLocal>();
                 List<LessonLocal>lessonLocals = new List<LessonLocal>();
-                await Parallel.ForEachAsync(resultSchool.list, async (lessonRecord, cancellationToken) =>
+                foreach (var lessonRecord in lessonRecords) 
                 {
                 {
-                    var  item = await LessonETLService.GetLessonLocal(lessonRecord,localIds,_azureStorage,pathLessons);
+                    var item = await LessonETLService.GetLessonLocal(lessonRecord, localIds, _azureStorage, pathLessons);
                     lessonLocals.Add(item);
                     lessonLocals.Add(item);
                     index++;
                     index++;
-                });
-                
-                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()) 
+                }
+              
+                string schoolPtah = $"{lessonBasePath}\\schools\\school.json";
+                if (System.IO.File.Exists(schoolPtah))
+                {
+                    string jsonData = await System.IO.File.ReadAllTextAsync(schoolPtah);
+                    schools= jsonData.ToObject<List<School>>();
+                }
+                var schoolGroup = lessonLocals.Where(x => !string.IsNullOrWhiteSpace(x.lessonRecord?.school)).GroupBy(x => x.lessonRecord?.school).Select(x => new { key = x.Key, list = x.ToList() });
+                var newschoolIds = schoolGroup.Select(x=>x.key).ExceptBy(schools.Select(x => x.id), x => x);
+                if (newschoolIds!=null && newschoolIds.Count()>0) 
                 {
                 {
-                    schools.AddRange(schoolResults.list);
+                    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);
+                    }
                 }
                 }
+                await System.IO.File.WriteAllTextAsync($"{lessonBasePath}\\schools\\school.json", schools.ToJsonString());
                 foreach (var group in schoolGroup) 
                 foreach (var group in schoolGroup) 
                 {
                 {
+                    string students_path = $"{lessonBasePath}\\students\\{group.key}\\students.json";
+                    string records_path = $"{lessonBasePath}\\students\\{group.key}\\records.json";
+                    string overall_path = $"{lessonBasePath}\\students\\{group.key}\\overall.json";
+                    if (!Directory.Exists($"{lessonBasePath}\\students\\{group.key}")) 
+                    {
+                        Directory.CreateDirectory($"{lessonBasePath}\\students\\{group.key}");
+                    }
                     var studentIds = group.list.SelectMany(x => x.studentLessonDatas).Where(x=>!string.IsNullOrWhiteSpace(x.id)).Select(x => x.id).Distinct();
                     var studentIds = group.list.SelectMany(x => x.studentLessonDatas).Where(x=>!string.IsNullOrWhiteSpace(x.id)).Select(x => x.id).Distinct();
-                    string studentSql = $"select value c from c where c.id in ({string.Join(",", studentIds.Select(x => $"'{x}'"))})";
-                    var  studentResults=  await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).GetList<Student>(studentSql, $"Base-{group.key}");
-                    if (studentResults.list.IsNotEmpty()) 
+                    List<Student> schoolStudent = new List<Student>();
+                    if (System.IO.File.Exists(students_path)) 
+                    {
+                        string jsonData = await System.IO.File.ReadAllTextAsync(students_path);
+                        schoolStudent= jsonData.ToObject<List<Student>>();
+                        studentsBase.AddRange(schoolStudent);
+                    }
+                    var newIds= studentIds.ExceptBy(schoolStudent.Where(x=>x.schoolId.Equals(group.key)).Select(x=>x.id),x=>x);
+                    if (newIds!=null  && newIds.Count()>0)
                     {
                     {
-                        studentsBase.AddRange(studentResults.list);
+                        string studentSql = $"select value c from c where c.id in ({string.Join(",", newIds.Select(x => $"'{x}'"))})";
+                        var studentResults = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).GetList<Student>(studentSql, $"Base-{group.key}");
+                        if (studentResults.list.IsNotEmpty())
+                        {
+                            schoolStudent.AddRange(studentResults.list);
+                            studentsBase.AddRange(studentResults.list);
+                        }
+                    }
+                    await System.IO.File.WriteAllTextAsync(students_path, schoolStudent.ToJsonString());
+
+                    List<StudentSemesterRecord>  schoolStudentSemesterRecords=new List<StudentSemesterRecord>();
+                    if (System.IO.File.Exists(records_path))
+                    {
+                        string jsonData = await System.IO.File.ReadAllTextAsync(records_path);
+                        schoolStudentSemesterRecords= jsonData.ToObject<List<StudentSemesterRecord>>();
+                        studentSemesterRecords.AddRange(schoolStudentSemesterRecords);
+                    }
+                    var newstuIds = studentIds.ExceptBy(studentSemesterRecords.Where(x => x.school.Equals(group.key)).Select(x => x.stuid), x => x);
+                    if (newstuIds!=null  && newstuIds.Count()>0) 
+                    {
+                        string studentSemesterRecordSql = $"select value c from c where c.stuid in ({string.Join(",", newstuIds.Distinct().Select(x => $"'{x}'"))}) and c.studyYear>=2023";
+                        var studentSemesterRecordResults = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).GetList<StudentSemesterRecord>(studentSemesterRecordSql, $"StudentSemesterRecord-{group.key}");
+                        if (studentSemesterRecordResults.list.IsNotEmpty())
+                        {
+                            schoolStudentSemesterRecords.AddRange(studentSemesterRecordResults.list);
+                            studentSemesterRecords.AddRange(studentSemesterRecordResults.list);
+                        }
                     }
                     }
-                    string studentSemesterRecordSql = $"select value c from c where c.stuid in ({string.Join(",", studentIds.Select(x => $"'{x}'"))}) and c.studyYear>=2023";
-                    var studentSemesterRecordResults = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).GetList<StudentSemesterRecord>(studentSemesterRecordSql, $"StudentSemesterRecord-{group.key}");
-                    if (studentSemesterRecordResults.list.IsNotEmpty())
+                   
+                    await System.IO.File.WriteAllTextAsync(records_path, schoolStudentSemesterRecords.ToJsonString());
+
+
+                    List<OverallEducation> schoolOverallEducations = new List<OverallEducation>();
+
+                    if (System.IO.File.Exists(overall_path))
                     {
                     {
-                        studentSemesterRecords.AddRange(studentSemesterRecordResults.list);
+                        string jsonData = await System.IO.File.ReadAllTextAsync(overall_path);
+                        schoolOverallEducations= jsonData.ToObject<List<OverallEducation>>();
+                        overallEducations.AddRange(schoolOverallEducations);
                     }
                     }
-                    string overallEducationSql = $"select value c from c where c.studentId in ({string.Join(",", studentIds.Select(x => $"'{x}'"))}) and c.year>=2023";
-                    var overallEducationResults = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).GetList<OverallEducation>(overallEducationSql, $"OverallEducation-{group.key}");
-                    if (overallEducationResults.list.IsNotEmpty())
+                    var newstuoIds = studentIds.ExceptBy(schoolOverallEducations.Where(x => x.schoolCode.Equals(group.key)).Select(x => x.studentId), x => x);
+                    if (newstuIds!=null  && newstuIds.Count()>0) 
                     {
                     {
-                        overallEducations.AddRange(overallEducationResults.list);
+                        string overallEducationSql = $"select value c from c where c.studentId in ({string.Join(",", newstuoIds.Select(x => $"'{x}'"))}) and c.year>=2023";
+                        var overallEducationResults = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).GetList<OverallEducation>(overallEducationSql, $"OverallEducation-{group.key}");
+                        if (overallEducationResults.list.IsNotEmpty())
+                        {
+                            schoolOverallEducations.AddRange(overallEducationResults.list);
+                            overallEducations.AddRange(overallEducationResults.list);
+                        }
                     }
                     }
+                    await System.IO.File.WriteAllTextAsync(overall_path, schoolOverallEducations.ToJsonString());
                 }
                 }
+                
                 List<(string id,string owner, List<StudentLessonData> studentLessonData)> studentLessonDatas= new List<(string id, string owner, List<StudentLessonData>)>();
                 List<(string id,string owner, List<StudentLessonData> studentLessonData)> studentLessonDatas= new List<(string id, string owner, List<StudentLessonData>)>();
                 List<(string id, string owner, List<StudentLessonItem> studentLessons,List<CodeBool> codeBools, List<StudentLessonData> studentLessonData)> lessonItems = new List<(string id, string owner, List<StudentLessonItem> studentLessons, List<CodeBool> codeBools, List<StudentLessonData> studentLessonData)>();
                 List<(string id, string owner, List<StudentLessonItem> studentLessons,List<CodeBool> codeBools, List<StudentLessonData> studentLessonData)> lessonItems = new List<(string id, string owner, List<StudentLessonItem> studentLessons, List<CodeBool> codeBools, List<StudentLessonData> studentLessonData)>();
                 int n = 0;
                 int n = 0;
@@ -273,37 +357,75 @@ namespace HTEX.DataETL.Controllers
                     }
                     }
                     n++;
                     n++;
                 }
                 }
-                int p = 0;
-                //XmlDocument xmlDocument = new XmlDocument();
-                //var runtimePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
-                //xmlDocument.Load($"{runtimePath}\\summary.xml");
-                await Parallel.ForEachAsync(lessonItems, async (lessonItem, cancellationToken) =>
-                {
-                    lessonItem.studentLessons = LessonETLService.ProcessStudentDataV2(lessonItem.studentLessonData, lessonDataAnalysis, lessonItem.codeBools);
-                    await LessonETLService.ExportToExcelAzureBlob(lessonItem.studentLessons, _azureStorage, lessonItem.owner, $"{lessonItem.id}/student-analysis.xlsx", xmlDocument);
-                    p++;
-                });
-                int s = 0;
-                await Parallel.ForEachAsync(studentLessonDatas, async (studentLessonData, cancellationToken) =>
-                {
-                    await _azureStorage.GetBlobContainerClient(studentLessonData.owner).UploadFileByContainer(studentLessonData.studentLessonData.ToJsonString(), "records", $"{studentLessonData.id}/student-analysis.json");
-                    s++;
-                });
 
 
-                int m   =0;
-                await Parallel.ForEachAsync(studentSemesterRecords, async (studentSemester, cancellationToken) => 
+
+                foreach (var group in schoolGroup)
                 {
                 {
-                    await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).UpsertItemAsync(studentSemester, new PartitionKey(studentSemester.code));
-                    m++;
-                });
+                    string students_path = $"{lessonBasePath}\\students\\{group.key}\\students.json";
+                    string records_path = $"{lessonBasePath}\\students\\{group.key}\\records.json";
+                    string overall_path = $"{lessonBasePath}\\students\\{group.key}\\overall.json";
+                    if (!Directory.Exists($"{lessonBasePath}\\students\\{group.key}"))
+                    {
+                        Directory.CreateDirectory($"{lessonBasePath}\\students\\{group.key}");
+                    }
+                    var schoolStudent = studentsBase.FindAll(x => x.schoolId.Equals(group.key));
+                    var schoolStudentSemesterRecords=  studentSemesterRecords.FindAll(x => x.school.Equals(group.key));
+                    var schoolOverallEducations = overallEducations.FindAll(x => x.schoolCode.Equals(group.key));
+                    await System.IO.File.WriteAllTextAsync(students_path, schoolStudent.ToJsonString());
+                    await System.IO.File.WriteAllTextAsync(records_path, schoolStudentSemesterRecords.ToJsonString());
+                    await System.IO.File.WriteAllTextAsync(overall_path, schoolOverallEducations.ToJsonString());
+                }
+                int m = 0;
+                var grpdata = studentSemesterRecords.GroupBy(x => x.code).Select(x => new { key = x.Key, list = x.ToList() });
+                foreach (var group in grpdata)
+                {
+                    var pages = group.list.Page(66);
+                   
+                    foreach (var page in pages)
+                    {
+                        List<Task<ItemResponse<StudentSemesterRecord>>> list = new();
+                        foreach (var studentSemester in page) 
+                        {
+                            list.Add(_azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).UpsertItemAsync(studentSemester, new PartitionKey(studentSemester.code)))  ;
+                            m++;
+                        }
+                       await Task.WhenAll(list);
+                    }
+                }
                 int k = 0;
                 int k = 0;
-                await Parallel.ForEachAsync(overallEducations, async (overallEducation, cancellationToken) =>
+                var gpover = overallEducations.GroupBy(x => x.code).Select(x => new { key = x.Key, list = x.ToList() });
+                foreach (var item in gpover)
                 {
                 {
-                    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));
-                    k++;
+                    var pages = item.list.Page(66);
+                    foreach (var page in pages)
+                    {
+                        List<Task<ItemResponse<OverallEducation>>> list = new();
+                        foreach (var overallEducation in page) 
+                        {
+                            list.Add(_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));
+                          
+                        }
+                       await Task.WhenAll(list);
+                    }
+                }
+
+                int p = 0;
+                // 获取类的属性
+                PropertyInfo[] properties = typeof(StudentLessonItem).GetProperties();
+                List<string> summaryes= new List<string>();
+                for (int i = 0; i < properties.Length; i++)
+                {
+                    string summary = Regex.Replace(LessonETLService.GetPropertySummary(properties[i], xmlDocument), @"\s+", "");
+                    summaryes.Add(summary);
+                }
+                await Parallel.ForEachAsync(lessonItems, async (lessonItem, _) => {
+                    await _azureStorage.GetBlobContainerClient(lessonItem.owner).UploadFileByContainer(lessonItem.studentLessonData.ToJsonString(), "records", $"{lessonItem.id}/student-analysis.json");
+                    await LessonETLService.ExportToExcelAzureBlob(lessonItem.studentLessons, _azureStorage, lessonItem.owner, $"{lessonItem.id}/student-analysis.xlsx", xmlDocument, summaryes, properties);
+                    p++;
                 });
                 });
             }
             }
             return Ok();
             return Ok();

+ 47 - 26
TEAMModelOS.Extension/HTEX.Lib/ETL/Lesson/LessonETLService.cs

@@ -145,11 +145,19 @@ namespace HTEX.Lib.ETL.Lesson
                             lessonDataAnalysis = blobDownload.Content.ToObjectFromJson<LessonDataAnalysisModel>();
                             lessonDataAnalysis = blobDownload.Content.ToObjectFromJson<LessonDataAnalysisModel>();
                         }
                         }
 
 
-                        lessonItems = LessonETLService.ProcessStudentDataV2(studentLessonDatas, lessonDataAnalysis, codeBools);
+                        
                         XmlDocument xmlDocument = new XmlDocument();
                         XmlDocument xmlDocument = new XmlDocument();
                         var runtimePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                         var runtimePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                         xmlDocument.Load($"{runtimePath}\\summary.xml");
                         xmlDocument.Load($"{runtimePath}\\summary.xml");
-                        await LessonETLService.ExportToExcelAzureBlob(lessonItems, azureStorage, owner, $"{lessonLocal.lessonRecord.id}/student-analysis.xlsx", xmlDocument);
+                        // 获取类的属性
+                        PropertyInfo[] properties = typeof(StudentLessonItem).GetProperties();
+                        List<string> summaryes= new List<string>();
+                        for (int i = 0; i < properties.Length; i++)
+                        {
+                            string summary = Regex.Replace(LessonETLService.GetPropertySummary(properties[i], xmlDocument), @"\s+", "");
+                            summaryes.Add(summary);
+                        }
+                        await LessonETLService.ExportToExcelAzureBlob(lessonItems, azureStorage, owner, $"{lessonLocal.lessonRecord.id}/student-analysis.xlsx", xmlDocument,summaryes,properties);
                     }
                     }
                 }
                 }
                 catch (Exception ex)
                 catch (Exception ex)
@@ -160,6 +168,8 @@ namespace HTEX.Lib.ETL.Lesson
                     }
                     }
                 }
                 }
                 await azureStorage.GetBlobContainerClient(owner).UploadFileByContainer(studentLessonDatas.ToJsonString(), "records", $"{lessonLocal.lessonRecord.id}/student-analysis.json");
                 await azureStorage.GetBlobContainerClient(owner).UploadFileByContainer(studentLessonDatas.ToJsonString(), "records", $"{lessonLocal.lessonRecord.id}/student-analysis.json");
+#else
+                lessonItems = LessonETLService.ProcessStudentDataV2(studentLessonDatas, lessonDataAnalysis, codeBools);
 #endif
 #endif
                 if (lessonLocal.lessonRecord.scope.Equals("school")&& !string.IsNullOrWhiteSpace(lessonLocal.lessonRecord.school)  && location.Equals("China", StringComparison.OrdinalIgnoreCase))
                 if (lessonLocal.lessonRecord.scope.Equals("school")&& !string.IsNullOrWhiteSpace(lessonLocal.lessonRecord.school)  && location.Equals("China", StringComparison.OrdinalIgnoreCase))
                 {
                 {
@@ -941,7 +951,7 @@ namespace HTEX.Lib.ETL.Lesson
             string owner = lessonRecord.scope.Equals("school") ? lessonRecord.school : lessonRecord.tmdid;
             string owner = lessonRecord.scope.Equals("school") ? lessonRecord.school : lessonRecord.tmdid;
 
 
             string yearMonthPath = DateTimeOffset.FromUnixTimeMilliseconds(lessonRecord.startTime).ToString("yyyyMM");
             string yearMonthPath = DateTimeOffset.FromUnixTimeMilliseconds(lessonRecord.startTime).ToString("yyyyMM");
-            LessonLocal lessonLocal = new LessonLocal { lessonRecord=lessonRecord };
+            LessonLocal lessonLocal = null;
             if (System.IO.File.Exists($"{pathLessons}\\MM{yearMonthPath}\\{lessonRecord.id}-local.json"))
             if (System.IO.File.Exists($"{pathLessons}\\MM{yearMonthPath}\\{lessonRecord.id}-local.json"))
             {
             {
                 string jsonp = await System.IO.File.ReadAllTextAsync($"{pathLessons}\\MM{yearMonthPath}\\{lessonRecord.id}-local.json");
                 string jsonp = await System.IO.File.ReadAllTextAsync($"{pathLessons}\\MM{yearMonthPath}\\{lessonRecord.id}-local.json");
@@ -949,6 +959,7 @@ namespace HTEX.Lib.ETL.Lesson
             }
             }
             else
             else
             {
             {
+                lessonLocal= new LessonLocal { lessonRecord=lessonRecord };
                 List<string> files = new List<string>()
                 List<string> files = new List<string>()
                     {
                     {
                         $"/records/{lessonRecord.id}/IES/TimeLine.json",
                         $"/records/{lessonRecord.id}/IES/TimeLine.json",
@@ -961,16 +972,17 @@ namespace HTEX.Lib.ETL.Lesson
                     };
                     };
                 lessonLocal  = new LessonLocal { lessonRecord=lessonRecord };
                 lessonLocal  = new LessonLocal { lessonRecord=lessonRecord };
                 lessonLocal =  await GetLessonFiles(lessonLocal, files, owner, _azureStorage);
                 lessonLocal =  await GetLessonFiles(lessonLocal, files, owner, _azureStorage);
+                if (lessonLocal.lessonBase!=null  &&  lessonLocal.lessonBase.student!=null)
+                {
+                    var baseData = GetBaseData(lessonLocal.lessonBase!);
+                    lessonLocal.studentLessonDatas= baseData.studentLessonDatas;
+                    List<ExamData> examDatas = await GetExamInfo(lessonRecord, lessonLocal.timeLineData, _azureStorage, owner);
+                    lessonLocal.examDatas = examDatas;
+                    lessonLocal.sokratesDatas= lessonLocal.sokratesDatas.IsNotEmpty() ? lessonLocal.sokratesDatas : lessonLocal.timeLineData!=null ? lessonLocal.timeLineData.events : new List<TimeLineEvent>();
+                }
             }
             }
 
 
-            if (lessonLocal.lessonBase!=null  &&  lessonLocal.lessonBase.student!=null)
-            {
-                var baseData = GetBaseData(lessonLocal.lessonBase!);
-                lessonLocal.studentLessonDatas= baseData.studentLessonDatas;
-                List<ExamData> examDatas = await GetExamInfo(lessonRecord, lessonLocal.timeLineData, _azureStorage, owner);
-                lessonLocal.examDatas = examDatas;
-                lessonLocal.sokratesDatas= lessonLocal.sokratesDatas.IsNotEmpty() ? lessonLocal.sokratesDatas : lessonLocal.timeLineData!=null ? lessonLocal.timeLineData.events : new List<TimeLineEvent>();
-            }
+            
             return lessonLocal;
             return lessonLocal;
         }
         }
         public static async IAsyncEnumerable<LessonLocal> GetLessonLocal(List<LessonRecord> lessonRecords, List<string> localIds, AzureStorageFactory _azureStorage, string pathLessons)
         public static async IAsyncEnumerable<LessonLocal> GetLessonLocal(List<LessonRecord> lessonRecords, List<string> localIds, AzureStorageFactory _azureStorage, string pathLessons)
@@ -1001,16 +1013,17 @@ namespace HTEX.Lib.ETL.Lesson
                     };
                     };
                     lessonLocal  = new LessonLocal { lessonRecord=lessonRecord };
                     lessonLocal  = new LessonLocal { lessonRecord=lessonRecord };
                     lessonLocal =  await GetLessonFiles(lessonLocal, files, owner, _azureStorage);
                     lessonLocal =  await GetLessonFiles(lessonLocal, files, owner, _azureStorage);
+                    if (lessonLocal.lessonBase!=null  &&  lessonLocal.lessonBase.student!=null)
+                    {
+                        var baseData = GetBaseData(lessonLocal.lessonBase!);
+                        lessonLocal.studentLessonDatas= baseData.studentLessonDatas;
+                        List<ExamData> examDatas = await GetExamInfo(lessonRecord, lessonLocal.timeLineData, _azureStorage, owner);
+                        lessonLocal.examDatas = examDatas;
+                        lessonLocal.sokratesDatas= lessonLocal.sokratesDatas.IsNotEmpty() ? lessonLocal.sokratesDatas : lessonLocal.timeLineData!=null ? lessonLocal.timeLineData.events : new List<TimeLineEvent>();
+                    }
                 }
                 }
 
 
-                if (lessonLocal.lessonBase!=null  &&  lessonLocal.lessonBase.student!=null)
-                {
-                    var baseData = GetBaseData(lessonLocal.lessonBase!);
-                    lessonLocal.studentLessonDatas= baseData.studentLessonDatas;
-                    List<ExamData> examDatas = await GetExamInfo(lessonRecord, lessonLocal.timeLineData, _azureStorage, owner);
-                    lessonLocal.examDatas = examDatas;
-                    lessonLocal.sokratesDatas= lessonLocal.sokratesDatas.IsNotEmpty() ? lessonLocal.sokratesDatas : lessonLocal.timeLineData!=null ? lessonLocal.timeLineData.events : new List<TimeLineEvent>();
-                }
+                
                 yield return lessonLocal;
                 yield return lessonLocal;
             }
             }
         }
         }
@@ -2920,7 +2933,7 @@ namespace HTEX.Lib.ETL.Lesson
         /// <param name="items"></param>
         /// <param name="items"></param>
         /// <param name="filePath"></param>
         /// <param name="filePath"></param>
         /// <returns></returns>
         /// <returns></returns>
-        public static async Task ExportToExcelAzureBlob(List<StudentLessonItem> items, AzureStorageFactory azureStorage,string owner , string path ,  XmlDocument xmlDocument)
+        public static async Task ExportToExcelAzureBlob(List<StudentLessonItem> items, AzureStorageFactory azureStorage,string owner , string path ,  XmlDocument xmlDocument,List<string> summarys, PropertyInfo[] properties)
         {
         {
             ExcelPackage.LicenseContext = OfficeOpenXml.LicenseContext.NonCommercial;
             ExcelPackage.LicenseContext = OfficeOpenXml.LicenseContext.NonCommercial;
             using (var memoryStream = new MemoryStream()) 
             using (var memoryStream = new MemoryStream()) 
@@ -2928,18 +2941,26 @@ namespace HTEX.Lib.ETL.Lesson
                 using (ExcelPackage package = new ExcelPackage())
                 using (ExcelPackage package = new ExcelPackage())
                 {
                 {
                     ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("学生课中数据");
                     ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("学生课中数据");
-
-                    // 获取类的属性
-                    PropertyInfo[] properties = typeof(StudentLessonItem).GetProperties();
-
                     // 添加表头
                     // 添加表头
                     int currentRow = 1;
                     int currentRow = 1;
+
+#if !DEBUG
+                    // 获取类的属性
+                    if(properties==null || properties.Length==0)
+                    {
+                        properties = typeof(StudentLessonItem).GetProperties();
+                    }
                     for (int i = 0; i < properties.Length; i++)
                     for (int i = 0; i < properties.Length; i++)
                     {
                     {
-
                         string summary = Regex.Replace(GetPropertySummary(properties[i], xmlDocument), @"\s+", "");
                         string summary = Regex.Replace(GetPropertySummary(properties[i], xmlDocument), @"\s+", "");
                         worksheet.Cells[currentRow, i + 1].Value = summary;
                         worksheet.Cells[currentRow, i + 1].Value = summary;
                     }
                     }
+#else
+                    for (int i = 0; i < summarys.Count; i++)
+                    {
+                        worksheet.Cells[currentRow, i + 1].Value = summarys[i];
+                    }
+#endif
 
 
                     // 填充数据
                     // 填充数据
                     currentRow = 2;
                     currentRow = 2;
@@ -3009,7 +3030,7 @@ namespace HTEX.Lib.ETL.Lesson
             }
             }
         }
         }
 
 
-        private static string GetPropertySummary(PropertyInfo property, XmlDocument xmlDocument)
+        public static string GetPropertySummary(PropertyInfo property, XmlDocument xmlDocument)
         {
         {
             XmlNodeList? xmlNodeList = xmlDocument.DocumentElement?.SelectNodes("//member[@name='P:" + property.DeclaringType?.FullName + "." + property.Name + "']");
             XmlNodeList? xmlNodeList = xmlDocument.DocumentElement?.SelectNodes("//member[@name='P:" + property.DeclaringType?.FullName + "." + property.Name + "']");
             if (xmlNodeList!= null && xmlNodeList.Count > 0)
             if (xmlNodeList!= null && xmlNodeList.Count > 0)

+ 1 - 1
TEAMModelOS.Extension/HTEX.Lib/summary.xml

@@ -8333,7 +8333,7 @@
             <param name="array"></param>
             <param name="array"></param>
             <returns></returns>
             <returns></returns>
         </member>
         </member>
-        <member name="M:HTEX.Lib.ETL.Lesson.LessonETLService.ExportToExcelAzureBlob(System.Collections.Generic.List{HTEX.Lib.ETL.Lesson.StudentLessonItem},TEAMModelOS.SDK.DI.AzureStorageFactory,System.String,System.String,System.Xml.XmlDocument)">
+        <member name="M:HTEX.Lib.ETL.Lesson.LessonETLService.ExportToExcelAzureBlob(System.Collections.Generic.List{HTEX.Lib.ETL.Lesson.StudentLessonItem},TEAMModelOS.SDK.DI.AzureStorageFactory,System.String,System.String,System.Xml.XmlDocument,System.Collections.Generic.List{System.String},System.Reflection.PropertyInfo[])">
             <summary>
             <summary>
             
             
             </summary>
             </summary>