|
@@ -21,16 +21,20 @@ namespace HTEX.DataETL.Controllers
|
|
|
private readonly AzureStorageFactory _azureStorage;
|
|
|
private readonly IConfiguration _configuration;
|
|
|
private readonly IWebHostEnvironment _webHostEnvironment;
|
|
|
+ private readonly DingDing _dingDing;
|
|
|
+ private readonly AzureRedisFactory _azureRedis;
|
|
|
|
|
|
|
|
|
- public LessonRecordController(ILogger<LessonRecordController> logger, AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage
|
|
|
- , IConfiguration configuration, IWebHostEnvironment environment)
|
|
|
+
|
|
|
+ public LessonRecordController(ILogger<LessonRecordController> logger, AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage , IConfiguration configuration, IWebHostEnvironment environment,DingDing dingDing,AzureRedisFactory azureRedis )
|
|
|
{
|
|
|
_logger = logger;
|
|
|
_azureCosmos = azureCosmos;
|
|
|
_azureStorage = azureStorage;
|
|
|
_configuration = configuration;
|
|
|
_webHostEnvironment = environment;
|
|
|
+ _dingDing = dingDing;
|
|
|
+ _azureRedis = azureRedis;
|
|
|
|
|
|
}
|
|
|
[HttpPost("process-local")]
|
|
@@ -195,115 +199,14 @@ namespace HTEX.DataETL.Controllers
|
|
|
{
|
|
|
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)
|
|
|
- {
|
|
|
- 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>();
|
|
|
- }
|
|
|
- }
|
|
|
- string? periodId = !string.IsNullOrWhiteSpace(lessonLocal.lessonRecord.periodId) ? lessonLocal.lessonRecord.periodId : school.period.FirstOrDefault()?.id;
|
|
|
- var period = school.period.Find(x => x.id.Equals(periodId));
|
|
|
- if (period!=null)
|
|
|
- {
|
|
|
- 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)
|
|
|
- {
|
|
|
- studentSemester= new StudentSemesterRecord
|
|
|
- {
|
|
|
- id= $"{pre_id}-{studentLessonData.id}",
|
|
|
- code=code,
|
|
|
- stuid= studentLessonData.id,
|
|
|
- userType=Constant.ScopeStudent,
|
|
|
- school=school.id,
|
|
|
- studyYear=semester.studyYear,
|
|
|
- semesterId=semester.currSemester.id,
|
|
|
- period= period?.id,
|
|
|
- pk="StudentSemesterRecord"
|
|
|
- };
|
|
|
- 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,
|
|
|
- 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;
|
|
|
- }
|
|
|
- }
|
|
|
- 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");
|
|
|
+ await LessonETLService.DoStudentLessonData(Constant.objectiveTypes, _azureStorage, lessonLocal, _dingDing, _azureCosmos.GetCosmosClient(), "China", _azureRedis);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
throw new Exception($"{fileLesson}", ex);
|
|
|
}
|
|
|
}
|
|
|
- string studentsPath = $"{lessonBasePath}\\students";
|
|
|
- foreach (var stu in students)
|
|
|
- {
|
|
|
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).UpsertItemAsync(stu, new PartitionKey(stu.code));
|
|
|
- // string path = $"{studentsPath}\\{stu.school}\\{stu.studyYear}\\{stu.semesterId}";
|
|
|
- // if (!Directory.Exists(path))
|
|
|
- {
|
|
|
- // Directory.CreateDirectory(path);
|
|
|
- }
|
|
|
- // await System.IO.File.WriteAllTextAsync($"{path}\\{stu.stuid}.json", stu.ToJsonString());
|
|
|
- }
|
|
|
- string schoolsPath = $"{lessonBasePath}\\schools";
|
|
|
- await System.IO.File.WriteAllTextAsync($"{schoolsPath}\\school.json", schools.ToJsonString());
|
|
|
+
|
|
|
return Ok();
|
|
|
}
|
|
|
|