CrazyIter_Bin 1 năm trước cách đây
mục cha
commit
b10820def6

+ 95 - 87
TEAMModelOS/Controllers/School/SchoolTeacherController.cs

@@ -545,101 +545,109 @@ namespace TEAMModelOS.Controllers
                     }
                     Teacher teacher = await client.GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReadItemAsync<Teacher>(id, new PartitionKey($"Base"));
                     var schoolData= teacher.schools.Find(z => z.schoolId.Equals($"{school_code}"));
-                    List<string> addAuthority = new List<string>();
-                    List<string> rmvAuthority = new List<string>();
-                    if (permission.IsNotEmpty())
-                    {
-                        st.permissions = permission;
-                       // addAuthority.AddRange(permission);
-                    }
-                    if (addPm.IsNotEmpty())
-                    {
-                        st.permissions.AddRange(addPm);
-                        //addAuthority.AddRange(addPm);
-                    }
-                    if (rmvPm.IsNotEmpty())
-                    {
-                        st.permissions.RemoveAll(x => rmvPm.Contains(x));
-                        //rmvAuthority.AddRange(rmvPm);
-                    }
-                    if (hasjob)
-                    {
-                        st.job = $"{_job}";
-                    }
-                    //清除权限标记。
-                    if (_pmClean.ValueKind.Equals(JsonValueKind.True)) {
-                        st.permissions = new List<string>();
-                        //rmvAuthority.AddRange(st.permissions);
-                    }
-                    //再次确认已经移除的权限。
-                    if (oldper != null)
-                    {
-                        var rmper = oldper.Except(st.permissions);
-                        if (rmper != null)
+                    if (schoolData!=null) {
+                        List<string> addAuthority = new List<string>();
+                        List<string> rmvAuthority = new List<string>();
+                        if (permission.IsNotEmpty())
                         {
-                            var rm = rmper.Except(rmvAuthority);
-                            rmvAuthority.AddRange(rm);
+                            st.permissions = permission;
+                            // addAuthority.AddRange(permission);
                         }
-                        var adper = st.permissions.Except(oldper);
-                        if (adper != null)
+                        if (addPm.IsNotEmpty())
                         {
-                            var ad = adper.Except(addAuthority);
-                            addAuthority.AddRange(ad);
+                            st.permissions.AddRange(addPm);
+                            //addAuthority.AddRange(addPm);
                         }
-                    }
-                    else {
-                        if (st.permissions.IsNotEmpty()) {
-                            addAuthority.AddRange(st.permissions);
+                        if (rmvPm.IsNotEmpty())
+                        {
+                            st.permissions.RemoveAll(x => rmvPm.Contains(x));
+                            //rmvAuthority.AddRange(rmvPm);
                         }
-                    }
-                    List<IdNameCode> nameCodes = new List<IdNameCode> { new IdNameCode { id = teacher.id, name = teacher.name, code = teacher.lang } };
-                   
-                    nameCodes.FindAll(x => string.IsNullOrWhiteSpace(x.code) || (!x.code.Equals("zh-cn") && !x.code.Equals("zh-tw") && !x.code.Equals("en-us"))).ForEach(x => { x.code = lang; });
-                    string path = Path.Combine("", $"Lang/{nameCodes.First().code}.json");
-                    var jsonAuth =System.IO. File.ReadAllText(path,Encoding.UTF8);
-                    var jsonData = jsonAuth.ToObject<JsonElement>();
-                    List<string> addText = new List<string>();
-                    List<string> rmvText = new List<string>();
-                    var authority =jsonData.GetProperty("authority");
-                    string none = nameCodes.First().code.Equals("zh-cn") ? "无" : nameCodes.First().code.Equals("zh-tw") ? "無" : "none";
-                    if (addAuthority.IsNotEmpty())
-                    {
-                        addAuthority.ForEach(z => {
-                            if (authority.TryGetProperty(z, out JsonElement text)) {
-                                addText.Add($"{text}");
+                        if (hasjob)
+                        {
+                            st.job = $"{_job}";
+                        }
+                        //清除权限标记。
+                        if (_pmClean.ValueKind.Equals(JsonValueKind.True))
+                        {
+                            st.permissions = new List<string>();
+                            //rmvAuthority.AddRange(st.permissions);
+                        }
+                        //再次确认已经移除的权限。
+                        if (oldper != null)
+                        {
+                            var rmper = oldper.Except(st.permissions);
+                            if (rmper != null)
+                            {
+                                var rm = rmper.Except(rmvAuthority);
+                                rmvAuthority.AddRange(rm);
                             }
-                            
-                        });
-                    }
-                    else {
-                        addText.Add($"{none}");  
-                    }
-                    if (rmvAuthority.IsNotEmpty())
-                    {
-                        rmvAuthority.ForEach(z => {
-                            if (authority.TryGetProperty(z, out JsonElement text))
+                            var adper = st.permissions.Except(oldper);
+                            if (adper != null)
                             {
-                                rmvText.Add($"{text}");
+                                var ad = adper.Except(addAuthority);
+                                addAuthority.AddRange(ad);
                             }
-                        });
-                    }
-                    else {
-                        rmvText.Add($"{none}");
-                    }
-                   
-                    await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<SchoolTeacher>(st, id, new PartitionKey($"Teacher-{school_code}"));
-                    _coreAPIHttpService.PushNotify(nameCodes, "authority-change", Constant.NotifyType_IES5_Management,
-                      new Dictionary<string, object> { { "tmdname", teacher.name }, { "tmdid", teacher.id }, { "schoolName", schoolData.name }, { "addAuthority", $"[{string.Join(",", addText)}]" }, { "rmvAuthority", $"[{string.Join(",", rmvText)}]" } }
-                      , _option.Location, _configuration, _dingDing, _environment.ContentRootPath);
-                    schoolTeachers.Add(st);
-                    //标记
-                    if (addAuthority.Contains("teacher-upd"))
-                    {
-                        adminChange.adminAdd.Add(id);
-                    }
-                    if (rmvAuthority.Contains("teacher-upd"))
-                    {
-                        adminChange.adminRmv.Add(id);
+                        }
+                        else
+                        {
+                            if (st.permissions.IsNotEmpty())
+                            {
+                                addAuthority.AddRange(st.permissions);
+                            }
+                        }
+                        List<IdNameCode> nameCodes = new List<IdNameCode> { new IdNameCode { id = teacher.id, name = teacher.name, code = teacher.lang } };
+
+                        nameCodes.FindAll(x => string.IsNullOrWhiteSpace(x.code) || (!x.code.Equals("zh-cn") && !x.code.Equals("zh-tw") && !x.code.Equals("en-us"))).ForEach(x => { x.code = lang; });
+                        string path = Path.Combine("", $"Lang/{nameCodes.First().code}.json");
+                        var jsonAuth = System.IO.File.ReadAllText(path, Encoding.UTF8);
+                        var jsonData = jsonAuth.ToObject<JsonElement>();
+                        List<string> addText = new List<string>();
+                        List<string> rmvText = new List<string>();
+                        var authority = jsonData.GetProperty("authority");
+                        string none = nameCodes.First().code.Equals("zh-cn") ? "无" : nameCodes.First().code.Equals("zh-tw") ? "無" : "none";
+                        if (addAuthority.IsNotEmpty())
+                        {
+                            addAuthority.ForEach(z => {
+                                if (authority.TryGetProperty(z, out JsonElement text))
+                                {
+                                    addText.Add($"{text}");
+                                }
+
+                            });
+                        }
+                        else
+                        {
+                            addText.Add($"{none}");
+                        }
+                        if (rmvAuthority.IsNotEmpty())
+                        {
+                            rmvAuthority.ForEach(z => {
+                                if (authority.TryGetProperty(z, out JsonElement text))
+                                {
+                                    rmvText.Add($"{text}");
+                                }
+                            });
+                        }
+                        else
+                        {
+                            rmvText.Add($"{none}");
+                        }
+
+                        await client.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<SchoolTeacher>(st, id, new PartitionKey($"Teacher-{school_code}"));
+                        _coreAPIHttpService.PushNotify(nameCodes, "authority-change", Constant.NotifyType_IES5_Management,
+                          new Dictionary<string, object> { { "tmdname", teacher.name }, { "tmdid", teacher.id }, { "schoolName", schoolData.name }, { "addAuthority", $"[{string.Join(",", addText)}]" }, { "rmvAuthority", $"[{string.Join(",", rmvText)}]" } }
+                          , _option.Location, _configuration, _dingDing, _environment.ContentRootPath);
+                        schoolTeachers.Add(st);
+                        //标记
+                        if (addAuthority.Contains("teacher-upd"))
+                        {
+                            adminChange.adminAdd.Add(id);
+                        }
+                        if (rmvAuthority.Contains("teacher-upd"))
+                        {
+                            adminChange.adminRmv.Add(id);
+                        }
                     }
                 }
                 await _coreAPIHttpService.AdminChange(adminChange, _option.Location, _configuration, _dingDing);

+ 41 - 39
TEAMModelOS/Controllers/Student/OverallEducationController.cs

@@ -564,45 +564,8 @@ namespace TEAMModelOS.Controllers
                 double rate90 = Math.Round(data_count > 0 ? dimensions.Where(x => x.score >= 90).Count() * 1.0 / data_count * 100 : 0, 2);
                 double rate60 = Math.Round(data_count > 0 ? dimensions.Where(x => x.score >= 60).Count() * 1.0 / data_count * 100 : 0, 2);
                 OverallEducation studentOverallEducation = null;
-                dynamic studentInClassAndGrade = new ExpandoObject();
-                if (!string.IsNullOrWhiteSpace($"{_studentId}")) {
-                    var student = students.Find(z => z.id.Equals($"{_studentId}"));
-                    var studentDimension =  dimensions.Find(z => z.studentId.Equals($"{_studentId}"));
-                    if (studentDimension==null) {
-                        studentDimension=new StudentDimensionScore
-                        {
-                            art=60,
-                            classId=student.classId,
-                            className=student.classId,
-                            classRanking=0,
-                            exam=60,
-                            gradeRanking=0,
-                            gscore=60,
-                            intelligence=60,
-                            labour=60,
-                            level="",
-                            picture=student.picture,
-                            pscore=60,
-                            score=60,
-                            sports=60,
-                            studentId=student.id,
-                            studentName=student.name,
-                            subject_music=0,
-                            subject_painting=0,
-                            tscore=60, 
-                            virtue=60,
-                        };
-                    }
-                    var  classDimension=  classDimensions.Find(z => z.classId.Equals(student.classId));
-                    studentInClassAndGrade= new { studentDimension, inClass= classDimension, inGrade=new { grade_gscore_avg, grade_pscore_avg, grade_tscore_avg } };
-                    studentOverallEducation = overallEducations.FindAll(x => x.studentId.Equals($"{_studentId}")).FirstOrDefault();
-                    if (studentOverallEducation==null) {
-                      
-                        studentOverallEducation = new OverallEducation() { studentId=student.id, name= student.name, classId=student.classId, picture = student.picture, schoolCode= student.schoolId };
-                    }
-                }
+               
                 var studyYear =  int.Parse($"{_studyYear}");
-                
                 var semesterData=  SchoolService.GetSemester(period, time: SchoolService.GetOpensByStudyYearAndSemester(period.semesters,studyYear,$"{_semesterId}"));
                 var examData =  await ExamService.getGradeScore(_coreAPIHttpService, _dingDing,_azureCosmos.GetCosmosClient(), grade_classes.Select(x=>x.id).ToList(), $"{_periodId}", school.id,   semesterData.date.ToUnixTimeMilliseconds(), semesterData.nextSemester.ToUnixTimeMilliseconds());
               
@@ -661,11 +624,50 @@ namespace TEAMModelOS.Controllers
                         z.value
                     })
                 });
+                dynamic studentInClassAndGrade = new ExpandoObject();
+                if (!string.IsNullOrWhiteSpace($"{_studentId}"))
+                {
+                    var student = students.Find(z => z.id.Equals($"{_studentId}"));
+                    var studentDimension = dimensions.Find(z => z.studentId.Equals($"{_studentId}"));
+                    if (studentDimension==null)
+                    {
+                        studentDimension=new StudentDimensionScore
+                        {
+                            art=60,
+                            classId=student.classId,
+                            className=student.classId,
+                            classRanking=0,
+                            exam=60,
+                            gradeRanking=0,
+                            gscore=60,
+                            intelligence=60,
+                            labour=60,
+                            level="",
+                            picture=student.picture,
+                            pscore=60,
+                            score=60,
+                            sports=60,
+                            studentId=student.id,
+                            studentName=student.name,
+                            subject_music=0,
+                            subject_painting=0,
+                            tscore=60,
+                            virtue=60,
+                        };
+                    }
+                    var classDimension = classDimensions.Find(z => z.classId.Equals(student.classId));
+                    studentInClassAndGrade= new { studentDimension, inClass = classDimension, inGrade = new { grade_gscore_avg, grade_pscore_avg, grade_tscore_avg } };
+                    studentOverallEducation = overallEducations.FindAll(x => x.studentId.Equals($"{_studentId}")).FirstOrDefault();
+                    if (studentOverallEducation==null)
+                    {
+
+                        studentOverallEducation = new OverallEducation() { studentId=student.id, name= student.name, classId=student.classId, picture = student.picture, schoolCode= student.schoolId };
+                    }
+                }
                 #endregion
                 return Ok(new
                 {
                     newExam3Scores,
-                    examData,
                     sports_count60,
                     sports_count90,
                     labour_count60,