|
@@ -190,43 +190,43 @@ namespace HTEX.DataETL.Controllers
|
|
|
List<School> schools = new List<School>();
|
|
|
// await Parallel.ForEachAsync(filesLessons, async (fileLesson, _) =>
|
|
|
foreach (var fileLesson in filesLessons)
|
|
|
+ {
|
|
|
+ try
|
|
|
{
|
|
|
- try
|
|
|
+ string localjson = await System.IO.File.ReadAllTextAsync(fileLesson);
|
|
|
+ var lessonLocal = localjson.ToObject<LessonLocal>();
|
|
|
+ List<StudentLessonData> studentLessonDatas = lessonLocal.studentLessonDatas.ToJsonString().ToObject<List<StudentLessonData>>();
|
|
|
+ studentLessonDatas = LessonETLService.GetBaseInfo(lessonLocal.lessonBase!, studentLessonDatas, lessonLocal?.lessonRecord?.id);
|
|
|
+ studentLessonDatas = LessonETLService.GetIRSData(lessonLocal.lessonBase!, lessonLocal.timeLineData!, lessonLocal.irsDatas, studentLessonDatas, lessonLocal.examDatas, lessonLocal?.lessonRecord?.id);
|
|
|
+ studentLessonDatas = LessonETLService.GetCoworkData(lessonLocal.lessonBase!, lessonLocal.timeLineData!, lessonLocal.coworkDatas, studentLessonDatas, lessonLocal.lessonRecord.id);
|
|
|
+ studentLessonDatas = LessonETLService.GetExamData(lessonLocal.lessonBase!, lessonLocal.timeLineData!, lessonLocal.examDatas, studentLessonDatas, Constant.objectiveTypes, lessonLocal.lessonRecord.id);
|
|
|
+ studentLessonDatas = LessonETLService.GetSmartRatingData(lessonLocal.lessonBase!, lessonLocal.timeLineData!, lessonLocal.smartRatingDatas, studentLessonDatas, lessonLocal.lessonRecord.id);
|
|
|
+ studentLessonDatas = LessonETLService.GetTaskData(lessonLocal.lessonBase!, lessonLocal.timeLineData!, lessonLocal.taskDatas, studentLessonDatas, lessonLocal.lessonRecord.id);
|
|
|
+ var pickupData = LessonETLService.GetPickupData(lessonLocal.lessonBase!, lessonLocal.timeLineData!, studentLessonDatas, lessonLocal.lessonRecord.id);
|
|
|
+ studentLessonDatas= pickupData.studentLessonDatas;
|
|
|
+ string owner = lessonLocal.lessonRecord.scope.Equals("school") ? lessonLocal.lessonRecord.school : lessonLocal.lessonRecord.tmdid;
|
|
|
+ var lessonItems = LessonETLService.ProcessStudentDataV2(studentLessonDatas, lessonDataAnalysis);
|
|
|
+ if (lessonLocal.lessonRecord.scope.Equals("school")&& !string.IsNullOrWhiteSpace(lessonLocal.lessonRecord.school))
|
|
|
{
|
|
|
- string localjson = await System.IO.File.ReadAllTextAsync(fileLesson);
|
|
|
- var lessonLocal = localjson.ToObject<LessonLocal>();
|
|
|
- List<StudentLessonData> studentLessonDatas = lessonLocal.studentLessonDatas.ToJsonString().ToObject<List<StudentLessonData>>();
|
|
|
- studentLessonDatas = LessonETLService.GetBaseInfo(lessonLocal.lessonBase!, studentLessonDatas, lessonLocal?.lessonRecord?.id);
|
|
|
- studentLessonDatas = LessonETLService.GetIRSData(lessonLocal.lessonBase!, lessonLocal.timeLineData!, lessonLocal.irsDatas, studentLessonDatas, lessonLocal.examDatas, lessonLocal?.lessonRecord?.id);
|
|
|
- studentLessonDatas = LessonETLService.GetCoworkData(lessonLocal.lessonBase!, lessonLocal.timeLineData!, lessonLocal.coworkDatas, studentLessonDatas, lessonLocal.lessonRecord.id);
|
|
|
- studentLessonDatas = LessonETLService.GetExamData(lessonLocal.lessonBase!, lessonLocal.timeLineData!, lessonLocal.examDatas, studentLessonDatas, Constant.objectiveTypes, lessonLocal.lessonRecord.id);
|
|
|
- studentLessonDatas = LessonETLService.GetSmartRatingData(lessonLocal.lessonBase!, lessonLocal.timeLineData!, lessonLocal.smartRatingDatas, studentLessonDatas, lessonLocal.lessonRecord.id);
|
|
|
- studentLessonDatas = LessonETLService.GetTaskData(lessonLocal.lessonBase!, lessonLocal.timeLineData!, lessonLocal.taskDatas, studentLessonDatas, lessonLocal.lessonRecord.id);
|
|
|
- var pickupData = LessonETLService.GetPickupData(lessonLocal.lessonBase!, lessonLocal.timeLineData!, studentLessonDatas, lessonLocal.lessonRecord.id);
|
|
|
- studentLessonDatas= pickupData.studentLessonDatas;
|
|
|
- string owner = lessonLocal.lessonRecord.scope.Equals("school") ? lessonLocal.lessonRecord.school : lessonLocal.lessonRecord.tmdid;
|
|
|
- var lessonItems = LessonETLService.ProcessStudentDataV2(studentLessonDatas, lessonDataAnalysis);
|
|
|
- if (lessonLocal.lessonRecord.scope.Equals("school")&& !string.IsNullOrWhiteSpace(lessonLocal.lessonRecord.school))
|
|
|
+ var school = schools.Find(x => x.id.Equals(lessonLocal.lessonRecord.school));
|
|
|
+ if (school==null)
|
|
|
{
|
|
|
- var school = schools.Find(x => x.id.Equals(lessonLocal.lessonRecord.school));
|
|
|
- if (school==null)
|
|
|
+ ResponseMessage response = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemStreamAsync(lessonLocal.lessonRecord.school, new PartitionKey("Base"));
|
|
|
+ if (response.IsSuccessStatusCode)
|
|
|
{
|
|
|
- ResponseMessage response = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemStreamAsync(lessonLocal.lessonRecord.school, new PartitionKey("Base"));
|
|
|
- if (response.IsSuccessStatusCode)
|
|
|
- {
|
|
|
- school = JsonDocument.Parse(response.Content).RootElement.ToObject<School>();
|
|
|
- }
|
|
|
+ school = JsonDocument.Parse(response.Content).RootElement.ToObject<School>();
|
|
|
}
|
|
|
- string? periodId = !string.IsNullOrWhiteSpace(lessonLocal.lessonRecord.periodId) ? lessonLocal.lessonRecord.periodId : school.period.FirstOrDefault()?.id;
|
|
|
- var period = school.period.Find(x => x.id.Equals(periodId));
|
|
|
- var semester = SchoolService.GetSemester(period, lessonLocal.lessonRecord.startTime);
|
|
|
- string pre_id = $"{semester.studyYear}-{semester.currSemester.id}";
|
|
|
- string code = $"StudentSemesterRecord-{school.id}";
|
|
|
- foreach (var studentLessonData in studentLessonDatas)
|
|
|
+ }
|
|
|
+ string? periodId = !string.IsNullOrWhiteSpace(lessonLocal.lessonRecord.periodId) ? lessonLocal.lessonRecord.periodId : school.period.FirstOrDefault()?.id;
|
|
|
+ var period = school.period.Find(x => x.id.Equals(periodId));
|
|
|
+ var semester = SchoolService.GetSemester(period, lessonLocal.lessonRecord.startTime);
|
|
|
+ string pre_id = $"{semester.studyYear}-{semester.currSemester.id}";
|
|
|
+ string code = $"StudentSemesterRecord-{school.id}";
|
|
|
+ foreach (var studentLessonData in studentLessonDatas)
|
|
|
+ {
|
|
|
+ StudentSemesterRecord studentSemester = students.Find(x => x.stuid.Equals(studentLessonData.id) &&x.id.Equals($"{pre_id}-{studentLessonData.id}") && x.code.Equals(code));
|
|
|
+ if (studentSemester==null)
|
|
|
{
|
|
|
- StudentSemesterRecord studentSemester = students.Find(x => x.stuid.Equals(studentLessonData.id) &&x.id.Equals($"{pre_id}-{studentLessonData.id}") && x.code.Equals(code));
|
|
|
- if (studentSemester==null)
|
|
|
- {
|
|
|
studentSemester= new StudentSemesterRecord
|
|
|
{
|
|
|
id= $"{pre_id}-{studentLessonData.id}",
|
|
@@ -239,55 +239,55 @@ namespace HTEX.DataETL.Controllers
|
|
|
period= period?.id,
|
|
|
pk="StudentSemesterRecord"
|
|
|
};
|
|
|
- students.Add(studentSemester);
|
|
|
- }
|
|
|
- string lessonId = string.Empty;
|
|
|
- StuLesson lesson = new StuLesson()
|
|
|
+ students.Add(studentSemester);
|
|
|
+ }
|
|
|
+ string lessonId = string.Empty;
|
|
|
+ StuLesson lesson = new StuLesson()
|
|
|
+ {
|
|
|
+ id= lessonLocal.lessonRecord.id,
|
|
|
+ time= lessonLocal.lessonRecord.startTime,
|
|
|
+ attend=0
|
|
|
+ };
|
|
|
+ if (studentLessonData.cooperation>0 || studentLessonData.achieve>0|| studentLessonData.attitude>0 || studentLessonData.cowork>0 || studentLessonData.appraise>0)
|
|
|
+ {
|
|
|
+ lesson.attend=1;
|
|
|
+
|
|
|
+ studentSemester.lessons.Add(new StuLessonLite
|
|
|
{
|
|
|
- id= lessonLocal.lessonRecord.id,
|
|
|
- time= lessonLocal.lessonRecord.startTime,
|
|
|
- attend=0
|
|
|
- };
|
|
|
- if (studentLessonData.cooperation>0 || studentLessonData.achieve>0|| studentLessonData.attitude>0 || studentLessonData.cowork>0 || studentLessonData.appraise>0)
|
|
|
+ id=lessonLocal.lessonRecord.id,
|
|
|
+ tmdid=lessonLocal.lessonRecord.tmdid,
|
|
|
+ sid= lessonLocal.lessonRecord.subjectId,
|
|
|
+ cid= lessonLocal.lessonRecord.courseId,
|
|
|
+ hrate=studentLessonData.cooperation,
|
|
|
+ crate=studentLessonData.achieve,
|
|
|
+ trate=studentLessonData.attitude,
|
|
|
+ xrate=studentLessonData.cowork,
|
|
|
+ prate=studentLessonData.appraise
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (studentLessonData.attend==1)
|
|
|
{
|
|
|
lesson.attend=1;
|
|
|
-
|
|
|
- studentSemester.lessons.Add(new StuLessonLite
|
|
|
- {
|
|
|
- id=lessonLocal.lessonRecord.id,
|
|
|
- tmdid=lessonLocal.lessonRecord.tmdid,
|
|
|
- sid= lessonLocal.lessonRecord.subjectId,
|
|
|
- cid= lessonLocal.lessonRecord.courseId,
|
|
|
- hrate=studentLessonData.cooperation,
|
|
|
- crate=studentLessonData.achieve,
|
|
|
- trate=studentLessonData.attitude,
|
|
|
- xrate=studentLessonData.cowork,
|
|
|
- prate=studentLessonData.appraise
|
|
|
- });
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if (studentLessonData.attend==1)
|
|
|
- {
|
|
|
- lesson.attend=1;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- lesson.attend=0;
|
|
|
- }
|
|
|
+ lesson.attend=0;
|
|
|
}
|
|
|
- studentSemester.les.Add(lesson);
|
|
|
- // studentSemester.lessonIds.Add(lessonId);
|
|
|
}
|
|
|
+ studentSemester.les.Add(lesson);
|
|
|
+ // studentSemester.lessonIds.Add(lessonId);
|
|
|
}
|
|
|
- // await LessonETLService.ExportToExcelAzureBlob(lessonItems, _azureStorage, owner, $"{lessonLocal.lessonRecord.id}/student-analysis.xlsx", xmlDocument);
|
|
|
- // await _azureStorage.GetBlobContainerClient(owner).UploadFileByContainer(studentLessonDatas.ToJsonString(), "records", $"{lessonLocal.lessonRecord.id}/student-analysis.json");
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- throw new Exception($"{fileLesson}", ex);
|
|
|
}
|
|
|
+ // await LessonETLService.ExportToExcelAzureBlob(lessonItems, _azureStorage, owner, $"{lessonLocal.lessonRecord.id}/student-analysis.xlsx", xmlDocument);
|
|
|
+ // await _azureStorage.GetBlobContainerClient(owner).UploadFileByContainer(studentLessonDatas.ToJsonString(), "records", $"{lessonLocal.lessonRecord.id}/student-analysis.json");
|
|
|
}
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ throw new Exception($"{fileLesson}", ex);
|
|
|
+ }
|
|
|
+ }
|
|
|
string studentsPath = $"{lessonBasePath}\\students";
|
|
|
foreach (var stu in students)
|
|
|
{
|