CrazyIter_Bin 1 anno fa
parent
commit
75fb594531

+ 53 - 0
TEAMModelOS.SDK/Models/Service/GroupListService.cs

@@ -18,6 +18,7 @@ using TEAMModelOS.SDK.Models;
 using System.Net.Http;
 using DocumentFormat.OpenXml.Wordprocessing;
 using static TEAMModelOS.SDK.GroupListService;
+using DocumentFormat.OpenXml.Drawing.Charts;
 
 namespace TEAMModelOS.SDK
 {
@@ -1088,6 +1089,58 @@ namespace TEAMModelOS.SDK
                 return (members, groupLists);
             }
         }
+        /// <summary>
+        /// 根据名单类型获取名单及成员信息。
+        /// </summary>
+        /// <param name="_coreAPIHttpService"></param>
+        /// <param name="client"></param>
+        /// <param name="type"></param>
+        /// <param name="scopes"></param>
+        /// <param name="school"></param>
+        /// <param name="_dingDing"></param>
+        /// <param name="graduate">毕业类型0在校,1毕业 , -1查全部。</param>
+        /// <returns></returns>
+        public static async Task<List<GroupListDto>> GetGroupListByType(CosmosClient client, string type, School school, Models.Period period, int graduate = -1)
+        {
+            List<GroupListDto> classes = new List<GroupListDto>();
+            List<int> grd = new List<int> ();
+            int index = 0;
+            period.grades.ForEach(z => { grd.Add(index); index+=1; });
+            var yearsdata = SchoolService.GetYears(school, period.id, grd);
+            List<int> years = yearsdata.years.ToList();
+          
+            if (years.IsNotEmpty()) {
+                StringBuilder sql = new StringBuilder($"select  c.id,c.code,c.name,c.no,c.periodId,c.scope,c.school,c.creatorId,c.type,c.year,c.tcount,c.scount,c.teacher.id as leader  ,c.graduate from  c where c.year in ({string.Join(",", years)}) and c.periodId='{period.id}' ");
+                if (graduate!=-1) {
+                    sql.Append($" and c.graduate={graduate} ");
+                }
+                var result = await client.GetContainer(Constant.TEAMModelOS, Constant.School).GetList<RGroupList>(sql.ToString(), $"Class-{school}");
+
+                foreach (var item in result.list)
+                {
+                    GroupListDto group = new GroupListDto
+                    {
+                        id = item.id,
+                        code = $"GroupList-{school}",
+                        name = item.name,
+                        periodId = item.periodId,
+                        scope = "school",
+                        school = school.id,
+                        type = "class",
+                        expire= item.expire,
+                        year = item.year,
+                        no = item.no,
+                        leader = item.leader,
+                        pk = "GroupList",
+                        graduate = item.graduate,
+                        grades= new HashSet<int> { item.year }
+                    };
+                    classes.Add(group);
+                }
+            }
+            return classes;
+        }
+
         /// <summary>
         /// 根据名单类型获取名单及成员信息。
         /// </summary>

+ 7 - 2
TEAMModelOS/Controllers/Client/AClassONEController.cs

@@ -399,13 +399,18 @@ namespace TEAMModelOS.Controllers
             HashSet<string> hashGroupIds = new HashSet<string>();
             List<Class> classes = new List<Class>();
             Period periodSchool = null;
+            //所有行政版
+            List<GroupListDto> allClasses = new List<GroupListDto>();
             if (!string.IsNullOrWhiteSpace(school))
             {
+
                 JsonElement year = default, semesterId = default, _periodId = default;
                 School schoolBase = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<School>(school, new PartitionKey("Base"));
-
                 if (!json.TryGetProperty("periodId", out _periodId)) return BadRequest();
                 var period = schoolBase.period.Find(x => x.id.Equals($"{_periodId}"));
+
+                allClasses=  await GroupListService.GetGroupListByType(_azureCosmos.GetCosmosClient(), "class", schoolBase, period, 0);
+
                 //班主任
                 string sqlClassTeacher = $"select value c from c where c.teacher.id='{tmdid}' and c.periodId='{_periodId}'";
                 var resultClass =   await  _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).GetList<Class>(sqlClassTeacher, $"Class-{school}");
@@ -701,7 +706,7 @@ namespace TEAMModelOS.Controllers
                 }
             }
             //暂时先注释不需要的
-            return Ok(new {/* teahcerCourses, schoolCourses, groupIdsRel, */groupLists });
+            return Ok(new {/* teahcerCourses, schoolCourses, groupIdsRel, */groupLists, allClasses });
         }