CrazyIter_Bin 1 рік тому
батько
коміт
ed2d9368a8
1 змінених файлів з 49 додано та 55 видалено
  1. 49 55
      TEAMModelOS.SDK/Models/Service/SchoolService.cs

+ 49 - 55
TEAMModelOS.SDK/Models/Service/SchoolService.cs

@@ -30,7 +30,7 @@ namespace TEAMModelOS.SDK
 
         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")
@@ -74,7 +74,6 @@ namespace TEAMModelOS.SDK
                         subject.bindId="subject_chemistry";
                         change= true;
                     }
-
                     if (string.IsNullOrWhiteSpace(subject.bindId)  && subject.name.Contains("生物"))
                     {
                         subject.bindId="subject_biology";
@@ -122,59 +121,54 @@ namespace TEAMModelOS.SDK
                         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);
-                //            }
-                //        }
-                //    }
-                //}
+                {
+                    foreach (var period in school.period)
+                    {
+                        if (string.IsNullOrWhiteSpace(period.periodType)) 
+                        {
+                            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 = "pre";
+                            }
+                            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 (change)
                 {
                     School schoolSelf = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).UpsertItemAsync<School>(school, new PartitionKey("Base"));