|
@@ -16,6 +16,7 @@ using TEAMModelOS.SDK.Models.Service;
|
|
|
using System.Text.RegularExpressions;
|
|
|
using TEAMModelOS.SDK.Models;
|
|
|
using System.Net.Http;
|
|
|
+using DocumentFormat.OpenXml.Wordprocessing;
|
|
|
|
|
|
namespace TEAMModelOS.SDK
|
|
|
{
|
|
@@ -188,7 +189,7 @@ namespace TEAMModelOS.SDK
|
|
|
/// <param name="type"></param>
|
|
|
/// <param name="school"></param>
|
|
|
/// <returns></returns>
|
|
|
- public static async Task<(int status, GroupList stuList,Member member)> CodeJoinList(CosmosClient client, string _stuListNo, string userid, int type, string school)
|
|
|
+ public static async Task<(int status, GroupList stuList,Member member)> CodeJoinList(CosmosClient client, string _stuListNo, string userid, int type, string school,int year)
|
|
|
{
|
|
|
var queryNo = $"SELECT value(c) FROM c where c.no ='{_stuListNo}'";
|
|
|
(int status, GroupList stuList,Member member) data = (-1, null,null);
|
|
@@ -197,7 +198,7 @@ namespace TEAMModelOS.SDK
|
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<GroupList>(queryText: queryNo,
|
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"GroupList-{school}") }))
|
|
|
{
|
|
|
- data = JoinList(item, userid, type, school);
|
|
|
+ data = JoinList(item, userid, type, school,year);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -209,12 +210,12 @@ namespace TEAMModelOS.SDK
|
|
|
//状态=4 表示未开放加入。
|
|
|
return (4, item, null) ;
|
|
|
}
|
|
|
- data = JoinList(item, userid, type, school);
|
|
|
+ data = JoinList(item, userid, type, school,year);
|
|
|
break;
|
|
|
}
|
|
|
return data;
|
|
|
}
|
|
|
- public static (int status, GroupList stuList, Member member) JoinList(GroupList stuList, string userid, int type, string school)
|
|
|
+ public static (int status, GroupList stuList, Member member) JoinList(GroupList stuList, string userid, int type, string school,int year)
|
|
|
{
|
|
|
int status = -1;
|
|
|
if (!string.IsNullOrWhiteSpace(stuList.school) && !string.IsNullOrWhiteSpace(school))
|
|
@@ -271,7 +272,7 @@ namespace TEAMModelOS.SDK
|
|
|
{
|
|
|
//加入成功
|
|
|
status = 0;
|
|
|
- member = new Member { id = userid, type = type, irs = irs, no = irs };
|
|
|
+ member = new Member { id = userid, type = type, irs = irs, no = irs,year=year };
|
|
|
stuList.members.Add(member);
|
|
|
}
|
|
|
}
|
|
@@ -286,7 +287,7 @@ namespace TEAMModelOS.SDK
|
|
|
else
|
|
|
{
|
|
|
status = 0;
|
|
|
- member = new Member { id = userid, code = school, type = type, irs = irs, no = irs };
|
|
|
+ member = new Member { id = userid, code = school, type = type, irs = irs, no = irs, year = year };
|
|
|
stuList.members.Add(member);
|
|
|
}
|
|
|
}
|
|
@@ -306,6 +307,28 @@ namespace TEAMModelOS.SDK
|
|
|
string tbname = list.scope.Equals("private") ? "Teacher" : "School";
|
|
|
var tmembers = list.members.Where(x => x.type == 1);
|
|
|
var smembers = list.members.Where(x => x.type == 2);
|
|
|
+ //处理年级
|
|
|
+ HashSet<string> grades = new HashSet<string>();
|
|
|
+ if (smembers.Any() && !string.IsNullOrWhiteSpace(list.periodId) ) {
|
|
|
+ var hasyear = smembers.Where(z => z.year > 0 && !string.IsNullOrWhiteSpace(z.code));
|
|
|
+ if (hasyear.Any()) {
|
|
|
+ var schoolIds = hasyear.Select(z => z.code).ToHashSet();
|
|
|
+ if (schoolIds.Any()) {
|
|
|
+ List<School> schools = new List<School>();
|
|
|
+ string sql = $"select value c from c where c.id in ({string.Join(",", schoolIds.Select(z=>$"'{z}'"))})";
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.School).GetItemQueryIterator<School>(queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
|
|
|
+ {
|
|
|
+ schools.Add(item);
|
|
|
+ }
|
|
|
+ var codeYears = hasyear.GroupBy(z => z.code).Select(z => new { key = z.Key, years = z.Select(z => z.year).ToHashSet() });
|
|
|
+ foreach (var cy in codeYears)
|
|
|
+ {
|
|
|
+ var school = schools.Find(z => z.id.Equals(cy.key));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
list.scount = smembers.Count();
|
|
|
list.tcount = tmembers.Count();
|
|
|
//if (smembers.Count() > 0 && smembers.Select(x => x.code).ToHashSet().Count()>=2) {
|
|
@@ -1055,7 +1078,7 @@ namespace TEAMModelOS.SDK
|
|
|
var ids = item.list.Select(x => x.id).ToList();
|
|
|
if (ids.IsNotEmpty())
|
|
|
{
|
|
|
- StringBuilder stuSql = new StringBuilder($"SELECT distinct c.name,c.id,c.code,c.picture,c.no,c.irs,c.classId ,c.graduate FROM c ");
|
|
|
+ StringBuilder stuSql = new StringBuilder($"SELECT distinct c.name,c.id,c.code,c.picture,c.no,c.irs,c.classId ,c.graduate,c.year FROM c ");
|
|
|
string insql = string.Join(",", ids.Select(x => $"'{x}'"));
|
|
|
stuSql.Append($"where c.id in ({insql})");
|
|
|
await foreach (var student in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<Student>(queryText: stuSql.ToString(),
|
|
@@ -1171,7 +1194,7 @@ namespace TEAMModelOS.SDK
|
|
|
|
|
|
if (tmdids.IsNotEmpty() && _coreAPIHttpService.check) {
|
|
|
///获取真实的名称 ,大于50则不处理
|
|
|
- if (tmdids.Count < 50)
|
|
|
+ if (tmdids.Count < 60)
|
|
|
{
|
|
|
var content = new StringContent(tmdids.Select(x => x.id).ToHashSet().ToJsonString(), Encoding.UTF8, "application/json");
|
|
|
string json = null;
|
|
@@ -1226,11 +1249,15 @@ namespace TEAMModelOS.SDK
|
|
|
students.ForEach(x =>
|
|
|
{
|
|
|
var student = studentsData.Find(y => y.id.Equals(x.id) && y.schoolId.Equals(x.code));
|
|
|
- x.name = student?.name;
|
|
|
- // x.nickname = string.IsNullOrWhiteSpace(x.nickname) ? student?.name:x.nickname;
|
|
|
- x.picture = student?.picture;
|
|
|
- x.classId = student?.classId;
|
|
|
- x.graduate = student.graduate;
|
|
|
+ if (student != null)
|
|
|
+ {
|
|
|
+ x.name = student?.name;
|
|
|
+ // x.nickname = string.IsNullOrWhiteSpace(x.nickname) ? student?.name:x.nickname;
|
|
|
+ x.picture = student?.picture;
|
|
|
+ x.classId = student?.classId;
|
|
|
+ x.graduate = student.graduate;
|
|
|
+ x.year = student.year;
|
|
|
+ }
|
|
|
});
|
|
|
var mbs = tmdids;
|
|
|
mbs.AddRange(students);
|
|
@@ -1244,25 +1271,43 @@ namespace TEAMModelOS.SDK
|
|
|
await client.GetContainer(Constant.TEAMModelOS, groupTbname).ReplaceItemAsync(group, group.id, new PartitionKey(group.code));
|
|
|
}
|
|
|
}
|
|
|
- groups.ForEach(x => x.members.ForEach(y => {
|
|
|
- if (y.type == 1)
|
|
|
- {
|
|
|
- var tmd = tmdids.Find(t => t.id.Equals(y.id));
|
|
|
- y.name = tmd?.name;
|
|
|
- //y.nickname = string.IsNullOrWhiteSpace(y.nickname) ? tmd?.nickname : y.nickname;
|
|
|
- y.picture = tmd?.picture;
|
|
|
- }
|
|
|
- if (y.type == 2)
|
|
|
+ groups.ForEach(x =>
|
|
|
+ {
|
|
|
+ x.members.ForEach(y =>
|
|
|
{
|
|
|
- var student = students.Find(t => t.id.Equals(y.id) && t.code.Equals(y.code));
|
|
|
- y.name = student?.name;
|
|
|
- // y.nickname = string.IsNullOrWhiteSpace(y.nickname) ? student?.nickname : y.nickname;
|
|
|
- y.picture = student?.picture;
|
|
|
- y.classId = student?.classId;
|
|
|
- y.graduate = student.graduate;
|
|
|
+ if (y.type == 1)
|
|
|
+ {
|
|
|
+ var tmd = tmdids.Find(t => t.id.Equals(y.id));
|
|
|
+ y.name = tmd?.name;
|
|
|
+ //y.nickname = string.IsNullOrWhiteSpace(y.nickname) ? tmd?.nickname : y.nickname;
|
|
|
+ y.picture = tmd?.picture;
|
|
|
+ }
|
|
|
+ if (y.type == 2)
|
|
|
+ {
|
|
|
+ var student = students.Find(t => t.id.Equals(y.id) && t.code.Equals(y.code));
|
|
|
+ if (student != null)
|
|
|
+ {
|
|
|
+ y.name = student?.name;
|
|
|
+ // y.nickname = string.IsNullOrWhiteSpace(y.nickname) ? student?.nickname : y.nickname;
|
|
|
+ y.picture = student?.picture;
|
|
|
+ y.classId = student?.classId;
|
|
|
+ y.graduate = student.graduate;
|
|
|
+ y.year = student.year;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (!x.type.Equals("class")) {
|
|
|
+ var yearc = x.members.Where(z => z.type == 2).GroupBy(g => g.year).Select(k => new { key = k.Key, count = k.Count() }).OrderByDescending(z => z.count);
|
|
|
+ if (yearc.Any())
|
|
|
+ {
|
|
|
+ //有一半的人是同一个班的,则以
|
|
|
+ if (yearc.First().count * 1.0 / x.members.Count > 0.51)
|
|
|
+ {
|
|
|
+ x.year = yearc.First().key;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- }));
|
|
|
-
|
|
|
+ });
|
|
|
HashSet<string> schoolCodes = groups.SelectMany(x => x.members).Where(y => !string.IsNullOrEmpty(y.code)).Select(z => z.code).ToHashSet();
|
|
|
if (schoolCodes != null && schoolCodes.Count > 0)
|
|
|
{
|
|
@@ -1278,6 +1323,7 @@ namespace TEAMModelOS.SDK
|
|
|
var school = schools.Find(j => j.id.Equals(z.code));
|
|
|
z.schoolName = school?.name;
|
|
|
});
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
if (graduate >= 0)
|
|
@@ -1290,12 +1336,12 @@ namespace TEAMModelOS.SDK
|
|
|
});
|
|
|
}
|
|
|
mbs.RemoveAll(z => z.graduate != graduate);
|
|
|
+ return (groups, mbs);
|
|
|
}
|
|
|
//直接返回
|
|
|
else {
|
|
|
return (groups, mbs);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|