|
@@ -4,7 +4,6 @@ using System.Collections.Generic;
|
|
|
using System.Threading.Tasks;
|
|
|
using TEAMModelOS.SDK.DI;
|
|
|
using TEAMModelOS.SDK.Extension;
|
|
|
-using TEAMModelOS.SDK.Models.Cosmos.Common;
|
|
|
using HTEXLib.COMM.Helpers;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
@@ -12,13 +11,12 @@ using System.Text.Json;
|
|
|
using TEAMModelOS.Models;
|
|
|
using Azure.Messaging.ServiceBus;
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
-using TEAMModelOS.SDK.Models.Service;
|
|
|
using System.Text.RegularExpressions;
|
|
|
using TEAMModelOS.SDK.Models;
|
|
|
using System.Net.Http;
|
|
|
-using DocumentFormat.OpenXml.Wordprocessing;
|
|
|
-using static TEAMModelOS.SDK.GroupListService;
|
|
|
using DocumentFormat.OpenXml.Drawing.Charts;
|
|
|
+using System.Reflection;
|
|
|
+
|
|
|
|
|
|
namespace TEAMModelOS.SDK
|
|
|
{
|
|
@@ -76,8 +74,8 @@ namespace TEAMModelOS.SDK
|
|
|
/// <param name="groupTypes">过滤名单的类型集合,不传则是全部</param>
|
|
|
/// <param name="graduate">毕业类型0在校,1毕业 , -1查全部。</param>
|
|
|
/// <returns></returns>
|
|
|
- public static async Task<List<GroupListGrp>> GetMemberInGroupList(CoreAPIHttpService _coreAPIHttpService, CosmosClient client, DingDing _dingDing, string memberId, int memberType, string school,List<string> groupTypes,int graduate =-1) {
|
|
|
-
|
|
|
+ public static async Task<List<GroupListGrp>> GetMemberInGroupList(CoreAPIHttpService _coreAPIHttpService, CosmosClient client, DingDing _dingDing, string memberId, int memberType, string school,List<string> groupTypes,int graduate =-1,long time =-1)
|
|
|
+ {
|
|
|
List<GroupListGrp> groupLists = new List<GroupListGrp>();
|
|
|
if (groupTypes.IsEmpty() || groupTypes.Contains("class")) {
|
|
|
if (!string.IsNullOrWhiteSpace(school) && memberType == 2)
|
|
@@ -93,6 +91,8 @@ namespace TEAMModelOS.SDK
|
|
|
}
|
|
|
if (!string.IsNullOrWhiteSpace(student.classId))
|
|
|
{
|
|
|
+
|
|
|
+
|
|
|
try
|
|
|
{
|
|
|
Class clazz = await client.GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<Class>(student.classId, new PartitionKey($"Class-{school}"));
|
|
@@ -180,6 +180,53 @@ namespace TEAMModelOS.SDK
|
|
|
groupLists.Add(new GroupListGrp(item, groupName));
|
|
|
}
|
|
|
}
|
|
|
+ List<GroupListSemester> groupListSemesters = new List<GroupListSemester>();
|
|
|
+ List<RMember> rmembers = new List<RMember>();
|
|
|
+ List<RGroupList> rgroupList = new List<RGroupList>();
|
|
|
+ List<GroupListDto> groupListDtos = new List<GroupListDto>();
|
|
|
+ if (!string.IsNullOrWhiteSpace(school) && time>0 && groupLists.IsNotEmpty())
|
|
|
+ {
|
|
|
+ School schoolBase = await client.GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<School>(school, new PartitionKey("Base"));
|
|
|
+ foreach (var period in schoolBase.period)
|
|
|
+ {
|
|
|
+ var dataSemester = SchoolService.GetSemester(period,time);
|
|
|
+ //string id = $"{dataSemester.studyYear}-{dataSemester.currSemester.id}-{student.classId}";
|
|
|
+ string code = $"GroupListSemester-{school}";
|
|
|
+ string sql = $"select value c from c join m in c.members where m.id='{memberId}' and m.type={memberType} and c.studyYear={dataSemester.studyYear} and c.semesterId='{dataSemester.currSemester.id}' and c.groupListId not in({string.Join(",", groupLists.Select(c => $"'{c.id}'"))}) ";
|
|
|
+ var result = await client.GetContainer(Constant.TEAMModelOS, Constant.School).GetList<GroupListSemester>(sql, code);
|
|
|
+ if (result.list.IsNotEmpty())
|
|
|
+ {
|
|
|
+ foreach (var x in result.list) {
|
|
|
+ HashSet<string> groupName = x.members.Where(x => !string.IsNullOrEmpty(x.groupName)).Select(y => y.groupName).ToHashSet();
|
|
|
+ groupLists.Add(new GroupListGrp {
|
|
|
+ id = x.id,
|
|
|
+ code = x.code,
|
|
|
+ periodId = x.periodId,
|
|
|
+ pk = x.pk,
|
|
|
+ name = x.name,
|
|
|
+ school = x.school,
|
|
|
+ creatorId = x.creatorId,
|
|
|
+ no = x.no,
|
|
|
+ scope = x.scope,
|
|
|
+ type = x.type,
|
|
|
+ scount = x.scount,
|
|
|
+ tcount = x.tcount,
|
|
|
+ leader = x.leader,
|
|
|
+ year = x.year,
|
|
|
+ expire = x.expire,
|
|
|
+ groupName = groupName,
|
|
|
+ froms = x.froms,
|
|
|
+ joinLock = x.joinLock,
|
|
|
+ qrcodeExpire = x.qrcodeExpire,
|
|
|
+ qrcodeDays = x.qrcodeDays,
|
|
|
+ review=x.review,
|
|
|
+ limitCount = x.limitCount,
|
|
|
+ grades = x.grades,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
return groupLists;
|
|
|
}
|
|
|
|
|
@@ -242,7 +289,6 @@ namespace TEAMModelOS.SDK
|
|
|
groupName= item.name,
|
|
|
applyTime=now
|
|
|
};
|
|
|
- string sql = "select value c from c join b in c.schedules where b.groupId='60f92012-72cf-4d5c-a66a-552678303fad'";
|
|
|
string key = $"GroupList:GroupWaitingList:{item.scope}:{item.id}";
|
|
|
string filed = !string.IsNullOrWhiteSpace(school) ? $"{school}_{userid}" : userid;
|
|
|
await _azureRedis.GetRedisClient(8).HashSetAsync(key, filed, waitingList.ToJsonString());
|
|
@@ -623,9 +669,9 @@ namespace TEAMModelOS.SDK
|
|
|
/// <param name="graduate">毕业类型0在校,1毕业 , -1查全部。</param>
|
|
|
/// <returns></returns>
|
|
|
public static async Task<List<GroupListDto>> GetGroupListByListids(CosmosClient client, DingDing _dingDing, List<string> classes, string school,
|
|
|
- string SummarySql = " 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.leader ,c.froms ,c.joinLock ,c.review,c.limitCount ,c.expire ,c.qrcodeExpire,c.qrcodeDays ,c.grades ", int graduate = -1)
|
|
|
+ string SummarySql = " 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.leader ,c.froms ,c.joinLock ,c.review,c.limitCount ,c.expire ,c.qrcodeExpire,c.qrcodeDays ,c.grades ", int graduate = -1,long time=-1)
|
|
|
{
|
|
|
- List<GroupListDto> groupLists = null;
|
|
|
+ List<GroupListDto> groupLists = new List<GroupListDto>();
|
|
|
try
|
|
|
{
|
|
|
classes.RemoveAll(x => x == null);
|
|
@@ -652,74 +698,81 @@ namespace TEAMModelOS.SDK
|
|
|
else
|
|
|
{
|
|
|
Dictionary<string, List<GroupListDto>> groups = new Dictionary<string, List<GroupListDto>>();
|
|
|
- //List<Student> students = new List<Student>();
|
|
|
- string sql = string.Join(",", classes.Select(x => $"'{x}'"));
|
|
|
- if (!string.IsNullOrEmpty(school))
|
|
|
+ var semesterGroupList = await GetGroupListSemester(client, classes, school, type: null, periodId: null, no: null, time);
|
|
|
+ groupLists.AddRange(semesterGroupList.groupListDtos);
|
|
|
+ classes = classes.Except(semesterGroupList.rgroupList.Select(y => y.id)).ToList();
|
|
|
+ if (classes.IsNotEmpty())
|
|
|
{
|
|
|
- List<GroupListDto> schoolList = new List<GroupListDto>();
|
|
|
-
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<GroupListDto>(queryText: $"select {SummarySql} from c where c.id in ({sql})",
|
|
|
- requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"GroupList-{school}") }))
|
|
|
- {
|
|
|
- schoolList.Add(item);
|
|
|
- }
|
|
|
- if (schoolList.IsNotEmpty())
|
|
|
- {
|
|
|
- groups.Add("School", schoolList);
|
|
|
- }
|
|
|
- //取差集,减少二次搜寻
|
|
|
- classes = classes.Except(schoolList.Select(y => y.id)).ToList();
|
|
|
- if (classes.IsNotEmpty())
|
|
|
+
|
|
|
+ //List<Student> students = new List<Student>();
|
|
|
+ string sql = string.Join(",", classes.Select(x => $"'{x}'"));
|
|
|
+ if (!string.IsNullOrEmpty(school))
|
|
|
{
|
|
|
- if (!groupLists.IsNotEmpty())
|
|
|
+ List<GroupListDto> schoolList = new List<GroupListDto>();
|
|
|
+
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<GroupListDto>(queryText: $"select {SummarySql} from c where c.id in ({sql})",
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"GroupList-{school}") }))
|
|
|
{
|
|
|
- groupLists = new List<GroupListDto>();
|
|
|
+ schoolList.Add(item);
|
|
|
}
|
|
|
- string insql = string.Join(",", classes.Select(x => $"'{x}'"));
|
|
|
- //搜寻没有关联学生的行政班
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<GroupListDto>(queryText:
|
|
|
- $"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.id in ({insql})",
|
|
|
- requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Class-{school}") }))
|
|
|
+ if (schoolList.IsNotEmpty())
|
|
|
{
|
|
|
- ///行政班(学生搜寻classId动态返回)class
|
|
|
- GroupListDto group = new GroupListDto
|
|
|
- {
|
|
|
- id = item.id,
|
|
|
- code = $"GroupList-{school}",
|
|
|
- name = item.name,
|
|
|
- periodId = item.periodId,
|
|
|
- scope = "school",
|
|
|
- school = school,
|
|
|
- type = "class",
|
|
|
- year = item.year,
|
|
|
- expire = item.expire,
|
|
|
- leader = item.leader,
|
|
|
- no = item.no,
|
|
|
- pk = "GroupList",
|
|
|
- graduate = item.graduate,
|
|
|
- grades= new HashSet<int> { item.year }
|
|
|
- };
|
|
|
- //graduate传入的状态>=0 表示指定状态查询,且传入的状态与数据库的状态一致。
|
|
|
- if (graduate >= 0)
|
|
|
+ groups.Add("School", schoolList);
|
|
|
+ }
|
|
|
+ //取差集,减少二次搜寻
|
|
|
+ classes = classes.Except(schoolList.Select(y => y.id)).ToList();
|
|
|
+ if (classes.IsNotEmpty())
|
|
|
+ {
|
|
|
+ string insql = string.Join(",", classes.Select(x => $"'{x}'"));
|
|
|
+ //搜寻没有关联学生的行政班
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<GroupListDto>(queryText:
|
|
|
+ $"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.id in ({insql})",
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Class-{school}") }))
|
|
|
{
|
|
|
- if (group.graduate == graduate)
|
|
|
+ ///行政班(学生搜寻classId动态返回)class
|
|
|
+ GroupListDto group = new GroupListDto
|
|
|
+ {
|
|
|
+ id = item.id,
|
|
|
+ code = $"GroupList-{school}",
|
|
|
+ name = item.name,
|
|
|
+ periodId = item.periodId,
|
|
|
+ scope = "school",
|
|
|
+ school = school,
|
|
|
+ type = "class",
|
|
|
+ year = item.year,
|
|
|
+ expire = item.expire,
|
|
|
+ leader = item.leader,
|
|
|
+ no = item.no,
|
|
|
+ pk = "GroupList",
|
|
|
+ graduate = item.graduate,
|
|
|
+ grades= new HashSet<int> { item.year }
|
|
|
+ };
|
|
|
+ //graduate传入的状态>=0 表示指定状态查询,且传入的状态与数据库的状态一致。
|
|
|
+ if (graduate >= 0)
|
|
|
+ {
|
|
|
+ if (group.graduate == graduate)
|
|
|
+ {
|
|
|
+ groupLists.Add(group);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //全部。
|
|
|
+ else
|
|
|
{
|
|
|
groupLists.Add(group);
|
|
|
}
|
|
|
+ // groupLists.Add(group);
|
|
|
}
|
|
|
- //全部。
|
|
|
- else
|
|
|
- {
|
|
|
- groupLists.Add(group);
|
|
|
- }
|
|
|
- // groupLists.Add(group);
|
|
|
+ //取差集,减少二次搜寻
|
|
|
+ classes = classes.Except(groupLists.Select(y => y.id)).ToList();
|
|
|
}
|
|
|
- //取差集,减少二次搜寻
|
|
|
- classes = classes.Except(groupLists.Select(y => y.id)).ToList();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
if (classes.IsNotEmpty())
|
|
|
{
|
|
|
+ string sql = string.Join(",", classes.Select(x => $"'{x}'"));
|
|
|
List<GroupListDto> privateList = new List<GroupListDto>();
|
|
|
sql = string.Join(",", classes.Select(x => $"'{x}'"));
|
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<GroupListDto>(queryText: $"select {SummarySql} from c where c.id in ({sql})",
|
|
@@ -762,13 +815,106 @@ namespace TEAMModelOS.SDK
|
|
|
groupLists = groups.SelectMany(x => x.Value).ToList();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
} catch (Exception ex ) {
|
|
|
await _dingDing.SendBotMsg($"{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
}
|
|
|
return groupLists;
|
|
|
}
|
|
|
+ public static async Task<(List<GroupListSemester> groupListSemesters, List<RMember> rmembers, List<RGroupList> rgroupList, List<GroupListDto> groupListDtos)>
|
|
|
+ GetGroupListSemester(CosmosClient client, List<string> classes, string school,string type,string periodId,string no , long time =-1) {
|
|
|
+ List<GroupListSemester> groupListSemesters = new List<GroupListSemester>();
|
|
|
+ List<RMember> rmembers = new List<RMember>();
|
|
|
+ List<RGroupList> rgroupList = new List<RGroupList>();
|
|
|
+ List<GroupListDto> groupListDtos = new List<GroupListDto>();
|
|
|
+ if (!string.IsNullOrWhiteSpace(school) && classes.IsNotEmpty() && time>0) {
|
|
|
+ School schoolBase = await client.GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<School>(school, new PartitionKey("Base"));
|
|
|
+ foreach (var period in schoolBase.period) {
|
|
|
+ var dataSemester = SchoolService.GetSemester(period, time);
|
|
|
+ //string id = $"{dataSemester.studyYear}-{dataSemester.currSemester.id}-{student.classId}";
|
|
|
+ string code = $"GroupListSemester-{school}";
|
|
|
+ StringBuilder sql =new StringBuilder($"select value c from c where c.studyYear={dataSemester.studyYear} and c.semesterId='{dataSemester.currSemester.id}' ");
|
|
|
+ if (classes.IsNotEmpty())
|
|
|
+ {
|
|
|
+ sql.Append($" and c.groupListId in({string.Join(",", classes.Select(c => $"'{c}'"))})");
|
|
|
+ }
|
|
|
+ if (!string.IsNullOrWhiteSpace(type)) {
|
|
|
+ sql.Append($" and c.type ='{type}'");
|
|
|
+ }
|
|
|
+ if (!string.IsNullOrWhiteSpace(periodId))
|
|
|
+ {
|
|
|
+ sql.Append($" and c.periodId ='{periodId}'");
|
|
|
+ }
|
|
|
+ if (!string.IsNullOrWhiteSpace(no))
|
|
|
+ {
|
|
|
+ sql.Append($" and c.no ='{no}'");
|
|
|
+ }
|
|
|
+ var result = await client.GetContainer(Constant.TEAMModelOS, Constant.School).GetList<GroupListSemester>(sql.ToString(), code);
|
|
|
+ if (result.list.IsNotEmpty()) {
|
|
|
+ groupListSemesters.AddRange(result.list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (groupListSemesters.IsNotEmpty()) {
|
|
|
+ rmembers.AddRange(groupListSemesters.SelectMany(x => x.members));
|
|
|
+ rmembers= rmembers.FindAll(x => x.type == 2).Where((x, i) => rmembers.FindAll(x => x.type == 2).FindIndex(n => n.id.Equals(x.id) && n.code.Equals(x.code)) == i).ToList();
|
|
|
+ rgroupList.AddRange(groupListSemesters.Select(z => new RGroupList
|
|
|
+ {
|
|
|
+ id = z.groupListId,
|
|
|
+ code= $"GroupList-{school}",
|
|
|
+ pk="GroupList",
|
|
|
+ name=z.name,
|
|
|
+ no=z.no,
|
|
|
+ periodId=z.periodId,
|
|
|
+ school=z.school,
|
|
|
+ scope=z.scope,
|
|
|
+ creatorId=z.creatorId,
|
|
|
+ type=z.type,
|
|
|
+ year=z.year,
|
|
|
+ expire=z.expire,
|
|
|
+ tcount=z.tcount,
|
|
|
+ scount=z.scount,
|
|
|
+ members=z.members,
|
|
|
+ leader=z.leader,
|
|
|
+ froms=z.froms,
|
|
|
+ joinLock=z.joinLock,
|
|
|
+ graduate=z.graduate,
|
|
|
+ review=z.review,
|
|
|
+ limitCount=z.limitCount,
|
|
|
+ qrcodeDays=z.qrcodeDays,
|
|
|
+ qrcodeExpire=z.qrcodeExpire,
|
|
|
+ grades =z.grades,
|
|
|
+ }));
|
|
|
+ groupListDtos.AddRange(groupListSemesters.Select(z => new GroupListDto
|
|
|
+ {
|
|
|
+ id = z.groupListId,
|
|
|
+ code= $"GroupList-{school}",
|
|
|
+ pk="GroupList",
|
|
|
+ name=z.name,
|
|
|
+ no=z.no,
|
|
|
+ periodId=z.periodId,
|
|
|
+ school=z.school,
|
|
|
+ scope=z.scope,
|
|
|
+ creatorId=z.creatorId,
|
|
|
+ type=z.type,
|
|
|
+ year=z.year,
|
|
|
+ expire=z.expire,
|
|
|
+ tcount=z.tcount,
|
|
|
+ scount=z.scount,
|
|
|
+ leader=z.leader,
|
|
|
+ froms=z.froms,
|
|
|
+ joinLock=z.joinLock,
|
|
|
+ graduate=z.graduate,
|
|
|
+ review=z.review,
|
|
|
+ limitCount=z.limitCount,
|
|
|
+ qrcodeDays=z.qrcodeDays,
|
|
|
+ qrcodeExpire=z.qrcodeExpire,
|
|
|
+ grades =z.grades,
|
|
|
+ }));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return (groupListSemesters,rmembers, rgroupList,groupListDtos);
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 根据任意名单id获取成员信息。rmembers是去重的信息,groups是名单及人员信息,同一个人可能在不同的名单内。
|
|
|
/// </summary>
|
|
@@ -781,7 +927,7 @@ namespace TEAMModelOS.SDK
|
|
|
/// <param name="graduate">毕业类型0在校,1毕业 , -1查全部。</param>
|
|
|
/// <returns></returns>
|
|
|
public static async Task<(List<RMember>rmembers, List<RGroupList> groups)> GetMemberByListids(CoreAPIHttpService _coreAPIHttpService, CosmosClient client, DingDing _dingDing,
|
|
|
- List<string> classes, string school, List<(string, List<string>)> groupids = null, int graduate = -1)
|
|
|
+ List<string> classes, string school, List<(string, List<string>)> groupids = null, int graduate = -1,long time =-1)
|
|
|
{
|
|
|
List<RMember> members = new List<RMember>();
|
|
|
List<RGroupList> groupLists = new List<RGroupList>();
|
|
@@ -793,11 +939,14 @@ namespace TEAMModelOS.SDK
|
|
|
{
|
|
|
return (members, groupLists);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
string periodId = string.Empty;
|
|
|
if (classes.Count == 1 && classes.First().Equals("TeacherAll") && !string.IsNullOrEmpty(school))
|
|
|
{
|
|
|
//默认的教研组
|
|
|
- members = new List<RMember>();
|
|
|
+ // members = new List<RMember>();
|
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").
|
|
|
GetItemQueryIterator<TmdInfo>(queryText: $"SELECT c.id,c.name,c.picture FROM c ",
|
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school}") }))
|
|
@@ -827,58 +976,177 @@ namespace TEAMModelOS.SDK
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- Dictionary<string, List<RGroupList>> groups = new Dictionary<string, List<RGroupList>>();
|
|
|
- List<Student> students = new List<Student>();
|
|
|
- string sql = string.Join(",", classes.Select(x => $"'{x}'"));
|
|
|
- if (!string.IsNullOrEmpty(school))
|
|
|
- {
|
|
|
- List<RGroupList> schoolList = new List<RGroupList>();
|
|
|
- string queryText = $"select value(c) from c where c.id in ({sql})";
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<RGroupList>(queryText: queryText,
|
|
|
- requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"GroupList-{school}") }))
|
|
|
- {
|
|
|
- schoolList.Add(item);
|
|
|
- }
|
|
|
- if (schoolList.IsNotEmpty())
|
|
|
- {
|
|
|
- groups.Add("School", schoolList);
|
|
|
- }
|
|
|
- //取差集,减少二次搜寻
|
|
|
- classes = classes.Except(schoolList.Select(y => y.id)).ToList();
|
|
|
- if (classes.IsNotEmpty())
|
|
|
+ var semesterGroupList = await GetGroupListSemester(client, classes, school,type:null,periodId:null ,no:null, time);
|
|
|
+ classes = classes.Except(semesterGroupList.rgroupList.Select(y => y.id)).ToList();
|
|
|
+ if (classes.IsNotEmpty()) {
|
|
|
+ Dictionary<string, List<RGroupList>> groups = new Dictionary<string, List<RGroupList>>();
|
|
|
+ List<Student> students = new List<Student>();
|
|
|
+ string sql = string.Join(",", classes.Select(x => $"'{x}'"));
|
|
|
+ if (!string.IsNullOrEmpty(school))
|
|
|
{
|
|
|
- sql = string.Join(",", classes.Select(x => $"'{x}'"));
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<Student>(queryText: $"select value(c) from c where c.classId in ({sql})",
|
|
|
- requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Base-{school}") }))
|
|
|
+
|
|
|
+
|
|
|
+ List<RGroupList> schoolList = new List<RGroupList>();
|
|
|
+ string queryText = $"select value(c) from c where c.id in ({sql})";
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<RGroupList>(queryText: queryText,
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"GroupList-{school}") }))
|
|
|
{
|
|
|
- //graduate传入的状态>=0 表示指定状态查询,且传入的状态与数据库的状态一致。
|
|
|
- if (graduate >= 0)
|
|
|
+ schoolList.Add(item);
|
|
|
+ }
|
|
|
+ if (schoolList.IsNotEmpty())
|
|
|
+ {
|
|
|
+ groups.Add("School", schoolList);
|
|
|
+ }
|
|
|
+ //取差集,减少二次搜寻
|
|
|
+ classes = classes.Except(schoolList.Select(y => y.id)).ToList();
|
|
|
+ if (classes.IsNotEmpty())
|
|
|
+ {
|
|
|
+ sql = string.Join(",", classes.Select(x => $"'{x}'"));
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<Student>(queryText: $"select value(c) from c where c.classId in ({sql})",
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Base-{school}") }))
|
|
|
{
|
|
|
- if (item.graduate == graduate)
|
|
|
+ //graduate传入的状态>=0 表示指定状态查询,且传入的状态与数据库的状态一致。
|
|
|
+ if (graduate >= 0)
|
|
|
+ {
|
|
|
+ if (item.graduate == graduate)
|
|
|
+ {
|
|
|
+ students.Add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //全部。
|
|
|
+ else
|
|
|
{
|
|
|
students.Add(item);
|
|
|
}
|
|
|
+ // students.Add(item);
|
|
|
}
|
|
|
- //全部。
|
|
|
- else
|
|
|
+ //取差集,减少二次搜寻
|
|
|
+ classes = classes.Except(students.Select(y => y.classId)).ToList();
|
|
|
+ }
|
|
|
+ if (classes.IsNotEmpty())
|
|
|
+ {
|
|
|
+ string insql = string.Join(",", classes.Select(x => $"'{x}'"));
|
|
|
+ //搜寻没有关联学生的行政班
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School")
|
|
|
+ .GetItemQueryIterator<RGroupList>(queryText: $"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.id in ({insql})",
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Class-{school}") }))
|
|
|
{
|
|
|
- students.Add(item);
|
|
|
+ ///行政班(学生搜寻classId动态返回)class
|
|
|
+ List<RMember> smembers = new List<RMember>();
|
|
|
+ RGroupList group = new RGroupList
|
|
|
+ {
|
|
|
+ id = item.id,
|
|
|
+ code = $"GroupList-{school}",
|
|
|
+ name = item.name,
|
|
|
+ periodId = item.periodId,
|
|
|
+ scope = "school",
|
|
|
+ school = school,
|
|
|
+ type = "class",
|
|
|
+ year = item.year,
|
|
|
+ expire = item.expire,
|
|
|
+ members = smembers,
|
|
|
+ scount = smembers.Count,
|
|
|
+ pk = "GroupList",
|
|
|
+ leader = item.leader,
|
|
|
+ no = item.no,
|
|
|
+ graduate = item.graduate,
|
|
|
+ grades= new HashSet<int>() { item.year }
|
|
|
+ };
|
|
|
+
|
|
|
+ //graduate传入的状态>=0 表示指定状态查询,且传入的状态与数据库的状态一致。
|
|
|
+ if (graduate >= 0)
|
|
|
+ {
|
|
|
+ if (group.graduate == graduate)
|
|
|
+ {
|
|
|
+ groupLists.Add(group);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //全部。
|
|
|
+ else
|
|
|
+ {
|
|
|
+ groupLists.Add(group);
|
|
|
+ }
|
|
|
+
|
|
|
+ //groupLists.Add(group);
|
|
|
}
|
|
|
- // students.Add(item);
|
|
|
+ //取差集,减少二次搜寻
|
|
|
+ classes = classes.Except(groupLists.Select(y => y.id)).ToList();
|
|
|
}
|
|
|
- //取差集,减少二次搜寻
|
|
|
- classes = classes.Except(students.Select(y => y.classId)).ToList();
|
|
|
+
|
|
|
}
|
|
|
if (classes.IsNotEmpty())
|
|
|
{
|
|
|
- string insql = string.Join(",", classes.Select(x => $"'{x}'"));
|
|
|
- //搜寻没有关联学生的行政班
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School")
|
|
|
- .GetItemQueryIterator<RGroupList>(queryText: $"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.id in ({insql})",
|
|
|
- requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Class-{school}") }))
|
|
|
+ List<RGroupList> privateList = new List<RGroupList>();
|
|
|
+ sql = string.Join(",", classes.Select(x => $"'{x}'"));
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<RGroupList>(queryText: $"select value(c) from c where c.id in ({sql})",
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"GroupList") }))
|
|
|
+ {
|
|
|
+ privateList.Add(item);
|
|
|
+ //if (string.IsNullOrWhiteSpace(school))
|
|
|
+ //{
|
|
|
+ // privateList.Add(item);
|
|
|
+ //}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // if (!string.IsNullOrWhiteSpace(item.school))
|
|
|
+ // {
|
|
|
+ // if (item.school.Equals(school))
|
|
|
+ // {
|
|
|
+ // privateList.Add(item);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // privateList.Add(item);
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ }
|
|
|
+ if (privateList.IsNotEmpty())
|
|
|
+ {
|
|
|
+ groups.Add("Teacher", privateList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ foreach (var item in groups)
|
|
|
+ {
|
|
|
+ var list = item.Value.GroupBy(x => x.type).Select(y => new { key = y.Key, list = y.ToList() });
|
|
|
+ foreach (var group in list)
|
|
|
+ {
|
|
|
+ (List<RGroupList> rgroups, List<RMember> rmembers) = await GetGroupListMemberInfo(_coreAPIHttpService, client, group.key, group.list, item.Key, _dingDing, school, graduate);
|
|
|
+ members.AddRange(rmembers);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ groupLists.AddRange(groups.SelectMany(x => x.Value).ToList());
|
|
|
+
|
|
|
+ if (students.IsNotEmpty())
|
|
|
+ {
|
|
|
+ List<string> sqlList = students.Select(x => x.classId).ToList();
|
|
|
+ string insql = string.Join(",", sqlList.Select(x => $"'{x}'"));
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").
|
|
|
+ GetItemQueryIterator<RGroupList>(queryText: $"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.id in ({insql})",
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Class-{school}") }))
|
|
|
{
|
|
|
///行政班(学生搜寻classId动态返回)class
|
|
|
- List<RMember> smembers = new List<RMember>();
|
|
|
+ List<RMember> smembers = students.Where(x => x.classId.Equals(item.id))
|
|
|
+ .Select(y => new RMember
|
|
|
+ {
|
|
|
+ id = y.id,
|
|
|
+ code = school,
|
|
|
+ name = y.name,
|
|
|
+ //nickname = y.name,
|
|
|
+ type = 2,
|
|
|
+ picture = y.picture,
|
|
|
+ no = y.no,
|
|
|
+ classId = y.classId,
|
|
|
+ groupId = y.groupId,
|
|
|
+ groupName = y.groupName,
|
|
|
+ irs = y.irs,
|
|
|
+ year= y.year,
|
|
|
+ graduate = y.graduate,
|
|
|
+ gender= y.gender,
|
|
|
+ periodId=y.periodId,
|
|
|
+ }).ToList();
|
|
|
+ members.AddRange(smembers);
|
|
|
+
|
|
|
RGroupList group = new RGroupList
|
|
|
{
|
|
|
id = item.id,
|
|
@@ -888,17 +1156,16 @@ namespace TEAMModelOS.SDK
|
|
|
scope = "school",
|
|
|
school = school,
|
|
|
type = "class",
|
|
|
+ expire= item.expire,
|
|
|
year = item.year,
|
|
|
- expire = item.expire,
|
|
|
members = smembers,
|
|
|
scount = smembers.Count,
|
|
|
- pk = "GroupList",
|
|
|
- leader = item.leader,
|
|
|
no = item.no,
|
|
|
+ leader = item.leader,
|
|
|
+ pk = "GroupList",
|
|
|
graduate = item.graduate,
|
|
|
- grades= new HashSet<int>() { item.year }
|
|
|
+ grades= new HashSet<int> { item.year }
|
|
|
};
|
|
|
-
|
|
|
//graduate传入的状态>=0 表示指定状态查询,且传入的状态与数据库的状态一致。
|
|
|
if (graduate >= 0)
|
|
|
{
|
|
@@ -908,128 +1175,17 @@ namespace TEAMModelOS.SDK
|
|
|
}
|
|
|
}
|
|
|
//全部。
|
|
|
- else
|
|
|
+ else
|
|
|
{
|
|
|
groupLists.Add(group);
|
|
|
}
|
|
|
-
|
|
|
- //groupLists.Add(group);
|
|
|
+ // groupLists.Add(group);
|
|
|
}
|
|
|
- //取差集,减少二次搜寻
|
|
|
- classes = classes.Except(groupLists.Select(y => y.id)).ToList();
|
|
|
+ //去重。
|
|
|
+ members = members.FindAll(x => x.type == 2).Where((x, i) => members.FindAll(x => x.type == 2).FindIndex(n => n.id.Equals(x.id) && n.code.Equals(x.code)) == i).ToList();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- if (classes.IsNotEmpty())
|
|
|
- {
|
|
|
- List<RGroupList> privateList = new List<RGroupList>();
|
|
|
- sql = string.Join(",", classes.Select(x => $"'{x}'"));
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<RGroupList>(queryText: $"select value(c) from c where c.id in ({sql})",
|
|
|
- requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"GroupList") }))
|
|
|
- {
|
|
|
- privateList.Add(item);
|
|
|
- //if (string.IsNullOrWhiteSpace(school))
|
|
|
- //{
|
|
|
- // privateList.Add(item);
|
|
|
- //}
|
|
|
- //else
|
|
|
- //{
|
|
|
- // if (!string.IsNullOrWhiteSpace(item.school))
|
|
|
- // {
|
|
|
- // if (item.school.Equals(school))
|
|
|
- // {
|
|
|
- // privateList.Add(item);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // else
|
|
|
- // {
|
|
|
- // privateList.Add(item);
|
|
|
- // }
|
|
|
- //}
|
|
|
- }
|
|
|
- if (privateList.IsNotEmpty())
|
|
|
- {
|
|
|
- groups.Add("Teacher", privateList);
|
|
|
- }
|
|
|
- }
|
|
|
- foreach (var item in groups)
|
|
|
- {
|
|
|
- var list = item.Value.GroupBy(x => x.type).Select(y => new { key = y.Key, list = y.ToList() });
|
|
|
- foreach (var group in list)
|
|
|
- {
|
|
|
- (List<RGroupList> rgroups, List<RMember> rmembers) = await GetGroupListMemberInfo(_coreAPIHttpService, client, group.key, group.list, item.Key, _dingDing, school,graduate);
|
|
|
- members.AddRange(rmembers);
|
|
|
- }
|
|
|
- }
|
|
|
- groupLists.AddRange(groups.SelectMany(x => x.Value).ToList());
|
|
|
-
|
|
|
- if (students.IsNotEmpty())
|
|
|
- {
|
|
|
- List<string> sqlList = students.Select(x => x.classId).ToList();
|
|
|
- string insql = string.Join(",", sqlList.Select(x => $"'{x}'"));
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").
|
|
|
- GetItemQueryIterator<RGroupList>(queryText: $"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.id in ({insql})",
|
|
|
- requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Class-{school}") }))
|
|
|
- {
|
|
|
- ///行政班(学生搜寻classId动态返回)class
|
|
|
- List<RMember> smembers = students.Where(x => x.classId.Equals(item.id))
|
|
|
- .Select(y => new RMember
|
|
|
- {
|
|
|
- id = y.id,
|
|
|
- code = school,
|
|
|
- name = y.name,
|
|
|
- //nickname = y.name,
|
|
|
- type = 2,
|
|
|
- picture = y.picture,
|
|
|
- no = y.no,
|
|
|
- classId = y.classId,
|
|
|
- groupId = y.groupId,
|
|
|
- groupName = y.groupName,
|
|
|
- irs = y.irs,
|
|
|
- year= y.year,
|
|
|
- graduate = y.graduate,
|
|
|
- gender= y.gender,
|
|
|
- periodId=y.periodId,
|
|
|
- }).ToList();
|
|
|
- members.AddRange(smembers);
|
|
|
-
|
|
|
- RGroupList group = new RGroupList
|
|
|
- {
|
|
|
- id = item.id,
|
|
|
- code = $"GroupList-{school}",
|
|
|
- name = item.name,
|
|
|
- periodId = item.periodId,
|
|
|
- scope = "school",
|
|
|
- school = school,
|
|
|
- type = "class",
|
|
|
- expire= item.expire,
|
|
|
- year = item.year,
|
|
|
- members = smembers,
|
|
|
- scount = smembers.Count,
|
|
|
- no = item.no,
|
|
|
- leader = item.leader,
|
|
|
- pk = "GroupList",
|
|
|
- graduate = item.graduate,
|
|
|
- grades= new HashSet<int> { item.year}
|
|
|
- };
|
|
|
- //graduate传入的状态>=0 表示指定状态查询,且传入的状态与数据库的状态一致。
|
|
|
- if (graduate >= 0)
|
|
|
- {
|
|
|
- if (group.graduate == graduate)
|
|
|
- {
|
|
|
- groupLists.Add(group);
|
|
|
- }
|
|
|
- }
|
|
|
- //全部。
|
|
|
- else
|
|
|
- {
|
|
|
- groupLists.Add(group);
|
|
|
- }
|
|
|
- // groupLists.Add(group);
|
|
|
- }
|
|
|
- //去重。
|
|
|
- members = members.FindAll(x => x.type == 2).Where((x, i) => members.FindAll(x => x.type == 2).FindIndex(n => n.id.Equals(x.id) && n.code.Equals(x.code)) == i).ToList();
|
|
|
- }
|
|
|
}
|
|
|
if (groupids.IsNotEmpty())
|
|
|
{
|
|
@@ -1152,7 +1308,7 @@ namespace TEAMModelOS.SDK
|
|
|
/// <param name="_dingDing"></param>
|
|
|
/// <param name="graduate">毕业类型0在校,1毕业 , -1查全部。</param>
|
|
|
/// <returns></returns>
|
|
|
- public static async Task<List<RGroupList>> GetGroupListMemberByType(CoreAPIHttpService _coreAPIHttpService, CosmosClient client, string type, List<string> scopes, string school, DingDing _dingDing, int graduate = -1)
|
|
|
+ public static async Task<List<RGroupList>> GetGroupListMemberByType(CoreAPIHttpService _coreAPIHttpService, CosmosClient client, string type, List<string> scopes, string school, DingDing _dingDing, int graduate = -1,long time =-1)
|
|
|
{
|
|
|
StringBuilder sql = new StringBuilder($"SELECT distinct value(c) FROM c where c.type='{type}'");
|
|
|
|
|
@@ -1168,6 +1324,53 @@ namespace TEAMModelOS.SDK
|
|
|
groupLists.Add(item);
|
|
|
}
|
|
|
groups.Add("School", groupLists);
|
|
|
+
|
|
|
+ if (!string.IsNullOrWhiteSpace(school) && time>0 && groupLists.IsNotEmpty())
|
|
|
+ {
|
|
|
+ School schoolBase = await client.GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<School>(school, new PartitionKey("Base"));
|
|
|
+ foreach (var period in schoolBase.period)
|
|
|
+ {
|
|
|
+ var dataSemester = SchoolService.GetSemester(period, time);
|
|
|
+ //string id = $"{dataSemester.studyYear}-{dataSemester.currSemester.id}-{student.classId}";
|
|
|
+ string code = $"GroupListSemester-{school}";
|
|
|
+ string sqlSem = $"select value c from c where c.type='{type}' and c.studyYear={dataSemester.studyYear} and c.semesterId='{dataSemester.currSemester.id}' and c.groupListId not in({string.Join(",", groupLists.Select(c => $"'{c.id}'"))}) ";
|
|
|
+ var result = await client.GetContainer(Constant.TEAMModelOS, Constant.School).GetList<GroupListSemester>(sqlSem, code);
|
|
|
+ if (result.list.IsNotEmpty())
|
|
|
+ {
|
|
|
+ foreach (var x in result.list)
|
|
|
+ {
|
|
|
+ HashSet<string> groupName = x.members.Where(x => !string.IsNullOrEmpty(x.groupName)).Select(y => y.groupName).ToHashSet();
|
|
|
+ groupLists.Add(new RGroupList
|
|
|
+ {
|
|
|
+ id = x.groupListId,
|
|
|
+ code = $"GroupList-{school}",
|
|
|
+ periodId = x.periodId,
|
|
|
+ pk = x.pk,
|
|
|
+ name = x.name,
|
|
|
+ school = x.school,
|
|
|
+ creatorId = x.creatorId,
|
|
|
+ no = x.no,
|
|
|
+ scope = x.scope,
|
|
|
+ type = x.type,
|
|
|
+ scount = x.scount,
|
|
|
+ tcount = x.tcount,
|
|
|
+ leader = x.leader,
|
|
|
+ year = x.year,
|
|
|
+ expire = x.expire,
|
|
|
+ graduate = x.graduate,
|
|
|
+ members = x.members,
|
|
|
+ froms = x.froms,
|
|
|
+ joinLock = x.joinLock,
|
|
|
+ qrcodeExpire = x.qrcodeExpire,
|
|
|
+ qrcodeDays = x.qrcodeDays,
|
|
|
+ review=x.review,
|
|
|
+ limitCount = x.limitCount,
|
|
|
+ grades = x.grades,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
else if (scopes.Contains("private"))
|