CrazyIter_Bin 1 year ago
parent
commit
09bdedb43d

+ 156 - 0
TEAMModelOS.SDK/Models/Service/SchoolService.cs

@@ -27,6 +27,162 @@ namespace TEAMModelOS.SDK
 {
     public class SchoolService
     {
+
+        public static async Task<School> ModifySchool(School school, AzureCosmosFactory _azureCosmos) {
+
+            //修补五育的科目关联
+            var subjects = school.period.SelectMany(x => x.subjects).Where(y => (!string.IsNullOrWhiteSpace(y.bindId) &&
+            (y.bindId.Equals("subject_painting")  || y.bindId.Equals("subject_sport")
+            || y.bindId.Equals("subject_labour") ||  y.bindId.Equals("subject_virtue") || y.bindId.Equals("subject_music")
+
+              || y.bindId.Equals("subject_chinese") ||  y.bindId.Equals("subject_math") || y.bindId.Equals("subject_english")
+                || y.bindId.Equals("subject_physics") ||  y.bindId.Equals("subject_chemistry") || y.bindId.Equals("subject_biology")
+                  || y.bindId.Equals("subject_politics") ||  y.bindId.Equals("subject_history") || y.bindId.Equals("subject_geography")
+
+            ))
+            || y.name.Contains("音乐") || y.name.Contains("美术") || y.name.Contains("劳动") ||  y.name.Contains("德育")  ||  y.name.Contains("体育")
+              || y.name.Contains("语文") || y.name.Contains("数学") || y.name.Contains("英语") ||  y.name.Contains("物理")  ||  y.name.Contains("化学")
+                || y.name.Contains("生物") || y.name.Contains("政治") || y.name.Contains("历史") ||  y.name.Contains("地理")
+            );
+            if (subjects.Any())
+            {
+                bool change = false;
+                foreach (var subject in subjects)
+                {
+                    if (string.IsNullOrWhiteSpace(subject.bindId)  && subject.name.Contains("语文"))
+                    {
+                        subject.bindId="subject_chinese";
+                        change= true;
+                    }
+                    if (string.IsNullOrWhiteSpace(subject.bindId)  && subject.name.Contains("数学"))
+                    {
+                        subject.bindId="subject_math";
+                        change= true;
+                    }
+                    if (string.IsNullOrWhiteSpace(subject.bindId)  && subject.name.Contains("英语"))
+                    {
+                        subject.bindId="subject_english";
+                        change= true;
+                    }
+                    if (string.IsNullOrWhiteSpace(subject.bindId)  && subject.name.Contains("物理"))
+                    {
+                        subject.bindId="subject_physics";
+                        change= true;
+                    }
+                    if (string.IsNullOrWhiteSpace(subject.bindId)  && subject.name.Contains("化学"))
+                    {
+                        subject.bindId="subject_chemistry";
+                        change= true;
+                    }
+
+                    if (string.IsNullOrWhiteSpace(subject.bindId)  && subject.name.Contains("生物"))
+                    {
+                        subject.bindId="subject_biology";
+                        change= true;
+                    }
+                    if (string.IsNullOrWhiteSpace(subject.bindId)  && subject.name.Contains("政治"))
+                    {
+                        subject.bindId="subject_politics";
+                        change= true;
+                    }
+                    if (string.IsNullOrWhiteSpace(subject.bindId)  && subject.name.Contains("历史"))
+                    {
+                        subject.bindId="subject_history";
+                        change= true;
+                    }
+                    if (string.IsNullOrWhiteSpace(subject.bindId)  && subject.name.Contains("地理"))
+                    {
+                        subject.bindId="subject_geography";
+                        change= true;
+                    }
+
+                    if (string.IsNullOrWhiteSpace(subject.bindId)  && subject.name.Contains("音乐"))
+                    {
+                        subject.bindId="subject_music";
+                        change= true;
+                    }
+                    if (string.IsNullOrWhiteSpace(subject.bindId)  && subject.name.Contains("美术"))
+                    {
+                        subject.bindId="subject_painting";
+                        change= true;
+                    }
+                    if (string.IsNullOrWhiteSpace(subject.bindId)  && subject.name.Contains("劳动"))
+                    {
+                        subject.bindId="subject_labour";
+                        change= true;
+                    }
+                    if (string.IsNullOrWhiteSpace(subject.bindId)  && subject.name.Contains("德育"))
+                    {
+                        subject.bindId="subject_virtue";
+                        change= true;
+                    }
+                    if (string.IsNullOrWhiteSpace(subject.bindId)  && subject.name.Contains("体育"))
+                    {
+                        subject.bindId="subject_sport";
+                        change= true;
+                    }
+                }
+                //{
+                //    List<Period> periods = new List<Period>();
+                //    var hastype_period = school.period.Where(p => !string.IsNullOrWhiteSpace(p.periodType));
+                //    if (hastype_period.Any())
+                //    {
+                //        periods.AddRange(hastype_period);
+                //    }
+                //    var nottype_period = school.period.Where(p => string.IsNullOrWhiteSpace(p.periodType));
+                //    if (nottype_period!=null && nottype_period.Count()>0)
+                //    {
+                //        foreach (var period in nottype_period)
+                //        {
+                //            if (period.name.Contains("小学"))
+                //            {
+                //                change= true;
+                //                period.periodType= "primary";
+                //            }
+                //            if (period.name.Contains("初中"))
+                //            {
+                //                change= true;
+                //                period.periodType = "junior";
+                //            }
+                //            if (period.name.Contains("高中"))
+                //            {
+                //                change= true;
+                //                period.periodType = "senior";
+                //            }
+                //            if (string.IsNullOrWhiteSpace(period.periodType) && school.period.Count == 1)
+                //            {
+                //                if (school.name.Contains("小学"))
+                //                {
+                //                    change= true;
+                //                    period.periodType = "primary";
+
+                //                }
+                //                if (school.name.Contains("初中"))
+                //                {
+                //                    change= true;
+                //                    period.periodType = "junior";
+                //                }
+                //                if (school.name.Contains("高中"))
+                //                {
+                //                    change= true;
+                //                    period.periodType = "senior";
+                //                }
+                //            }
+                //            if (!string.IsNullOrWhiteSpace(period.periodType))
+                //            {
+                //                periods.Add(period);
+                //            }
+                //        }
+                //    }
+                //}
+                if (change)
+                {
+                    School schoolSelf = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).UpsertItemAsync<School>(school, new PartitionKey("Base"));
+                }
+            }
+            return school;
+        }
+
         public static async Task<(int code, string msg, object data)> JoinScool(string school, string id, string name, string picture, long ts,
             AzureCosmosFactory _azureCosmos,AzureStorageFactory _azureStorage,CoreAPIHttpService _coreAPIHttpService,DingDing _dingDing,Option _option,IConfiguration _configuration, IWebHostEnvironment _environment)
         {

+ 18 - 1
TEAMModelOS/Controllers/Normal/ArtSettingController.cs

@@ -84,9 +84,26 @@ namespace TEAMModelOS.Controllers
                 }
                 List<dynamic> papersData = new List<dynamic>();
                 foreach (var school in schools) {
-                    var subjects = school.period.SelectMany(x => x.subjects).Where(y => !string.IsNullOrWhiteSpace(y.bindId) && (y.bindId.Equals("subject_painting") || y.bindId.Equals("subject_music")));
+                    var subjects = school.period.SelectMany(x => x.subjects).Where(y => (!string.IsNullOrWhiteSpace(y.bindId) && (y.bindId.Equals("subject_painting") 
+                    || y.bindId.Equals("subject_music")))|| y.name.Contains("音乐") || y.name.Contains("美术"));
                     if (subjects.Any())
                     {
+                        bool change = false;
+                        foreach (var subject in subjects)
+                        {
+                            if (string.IsNullOrWhiteSpace(subject.bindId)  && subject.name.Contains("音乐")) {
+                                subject.bindId="subject_music";
+                                change= true;
+                            }
+                            if (string.IsNullOrWhiteSpace(subject.bindId)  && subject.name.Contains("美术"))
+                            {
+                                subject.bindId="subject_painting";
+                                change= true;
+                            }
+                        }
+                        if (change) {
+                            School schoolSelf = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).UpsertItemAsync<School>(school, new PartitionKey("Base"));
+                        }
                         List<Paper> papers = new List<Paper>();
                         string sql = $"select value c  from c where c.subjectId in ({string.Join(",", subjects.Select(x => $"'{x.id}'"))}) ";
                         await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School)

+ 12 - 4
TEAMModelOS/Controllers/School/ArtReviewController.cs

@@ -112,8 +112,13 @@ namespace TEAMModelOS.Controllers
                 {
                     foreach (var rcd in values)
                     {
-                        var value = rcd.ToString().ToObject<StudentArtResult>();
-                        results.Add(value);
+                        
+                        if (!rcd.IsNullOrEmpty)
+                        {
+                            var value = rcd.ToString().ToObject<StudentArtResult>();
+                            results.Add(value);
+                        }
+                       
                     }
                 }
             }
@@ -123,8 +128,11 @@ namespace TEAMModelOS.Controllers
                 {
                     foreach (var rcd in values)
                     {
-                        var value = rcd.Value.ToString().ToObject<StudentArtResult>();
-                        results.Add(value);
+                        if (!rcd.Value.IsNullOrEmpty)
+                        {
+                            var value = rcd.Value.ToString().ToObject<StudentArtResult>();
+                            results.Add(value);
+                        }
                     }
                 }
             }

+ 4 - 1
TEAMModelOS/Controllers/Teacher/InitController.cs

@@ -777,7 +777,10 @@ namespace TEAMModelOS.Controllers
                         }
                     }
                 }
-                string currAreaId = "";
+                
+              
+               
+                    string currAreaId = "";
                 dynamic currArea = new ExpandoObject();
                 if (!string.IsNullOrEmpty(school_base.areaId))
                 {

+ 1 - 1
TEAMModelOS/Controllers/Third/Moofen/MoofenController.cs

@@ -244,7 +244,7 @@ namespace TEAMModelOS.Controllers.Third.Moofen
                         gradeName=x.scope?.grade?.name,
                         subject=subject,
                         pid=pid,
-                        code=!string.IsNullOrWhiteSpace(schoolId)?$"Item-{schoolId}":null,
+                        code=!string.IsNullOrWhiteSpace(schoolId)?$"{schoolId}":null,
                         pk="Item",
                         scope=!string.IsNullOrWhiteSpace(schoolId) ? "school" : null,