黄贺彬 7 ay önce
ebeveyn
işleme
d2a653f078

+ 51 - 48
HTEX.DataETL/Controllers/LessonRecordController.cs

@@ -219,65 +219,68 @@ namespace HTEX.DataETL.Controllers
                         }
                         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)
+                        if (period!=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)
+                            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)
                             {
-                                studentSemester=  new StudentSemesterRecord
+                                StudentSemesterRecord studentSemester = students.Find(x => x.stuid.Equals(studentLessonData.id) &&x.id.Equals($"{pre_id}-{studentLessonData.id}") && x.code.Equals(code));
+                                if (studentSemester==null)
                                 {
-                                    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
+                                    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,
-                                    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)
+                                    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
                                 {
-                                    lesson.attend=0;
+                                    if (studentLessonData.attend==1)
+                                    {
+                                        lesson.attend=1;
+                                    }
+                                    else
+                                    {
+                                        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);

+ 61 - 24
TEAMModelOS.Extension/HTEX.Lib/ETL/Lesson/LessonETLService.cs

@@ -121,42 +121,79 @@ namespace HTEX.Lib.ETL.Lesson
                                     period= period?.id,
                                 };
                             }
-                            studentSemester.les.Find(x => x.id.Equals(lessonLocal.lessonRecord.id));
-
-                            StuLesson lesson = new StuLesson()
+                            var les =  studentSemester.les.Find(x => x.id.Equals(lessonLocal.lessonRecord.id));
+                            if (les==null)
                             {
-                                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)
+                                  les = new StuLesson()
+                                {
+                                    id= lessonLocal.lessonRecord.id,
+                                    time= lessonLocal.lessonRecord.startTime,
+                                    attend=0
+                                };
+                                studentSemester.les.Add(les);
+                            }
+                            else {
+                                les.time= lessonLocal.lessonRecord.startTime;
+                            }
+                            var lesson = studentSemester.lessons.Find(x => x.id.Equals(lessonLocal.lessonRecord.id));
+                            if (lesson!=null)
                             {
-                                lesson.attend=1;
-                                studentSemester.lessons.Add(new StuLessonLite
+                                if (studentLessonData.cooperation>0 || studentLessonData.achieve>0|| studentLessonData.attitude>0 || studentLessonData.cowork>0 ||  studentLessonData.appraise>0)
                                 {
-                                    
-                                    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
-                                });
+                                    les.attend=1;
+                                    lesson.tmdid = lessonLocal.lessonRecord.tmdid;
+                                    lesson.sid = lessonLocal.lessonRecord.subjectId;
+                                    lesson.cid = lessonLocal.lessonRecord.courseId;
+                                    lesson.hrate = studentLessonData.cooperation;
+                                    lesson.crate = studentLessonData.achieve;
+                                    lesson.trate = studentLessonData.attitude;
+                                    lesson.xrate = studentLessonData.cowork;
+                                    lesson.prate = studentLessonData.appraise;
+                                }
+                                else
+                                {
+                                    if (studentLessonData.attend==1)
+                                    {
+                                        les.attend=1;
+                                    }
+                                    else
+                                    {
+                                        les.attend=0;
+                                    }
+                                }
                             }
                             else
                             {
-                                if (studentLessonData.attend==1)
+                                if (studentLessonData.cooperation>0 || studentLessonData.achieve>0|| studentLessonData.attitude>0 || studentLessonData.cowork>0 ||  studentLessonData.appraise>0) 
                                 {
-                                    lesson.attend=1;
+                                    les.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
                                 {
-                                    lesson.attend=0;
+                                    if (studentLessonData.attend==1)
+                                    {
+                                        les.attend=1;
+                                    }
+                                    else
+                                    {
+                                        les.attend=0;
+                                    }
                                 }
                             }
-                            studentSemester.les.Add(lesson);
+                            
+                           
                         }
                     }
                 }