|
@@ -194,11 +194,11 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
examName = request.name,
|
|
|
examCategory = 1,
|
|
|
- grade = grade,
|
|
|
- term = 1,
|
|
|
+ grade = int.Parse(grade),
|
|
|
+ term = 2,
|
|
|
examType = "单元测试",
|
|
|
examDate = request.startTime,
|
|
|
- schId = request.school,
|
|
|
+ schId = 1,
|
|
|
boeId = "",
|
|
|
subjects = request.subjects.Select(c => c.name).ToList()
|
|
|
};*/
|
|
@@ -1649,98 +1649,70 @@ namespace TEAMModelOS.Controllers
|
|
|
List<string> delIds = new();
|
|
|
if (groups.Count > 0)
|
|
|
{
|
|
|
- string scode = groups[0].school;
|
|
|
+ //string scode = groups[0].school;
|
|
|
if (ids.Count > 0)
|
|
|
{
|
|
|
- List<string> sIds = new();
|
|
|
- List<string> tIds = new();
|
|
|
+ List<string> sIds = members.Where(c => c.type == 2).Select(z => z.id).ToList();
|
|
|
+ List<string> tIds = members.Where(c => c.type == 1).Select(z => z.id).ToList();
|
|
|
List<ufo> students = new List<ufo>();
|
|
|
- if (string.IsNullOrEmpty(scode))
|
|
|
+ if (tIds.Any())
|
|
|
{
|
|
|
- var content = new StringContent(ids.ToJsonString(), Encoding.UTF8, "application/json");
|
|
|
- string json = await _coreAPIHttpService.GetUserInfos(content);
|
|
|
+ var tmds = ids.Intersect(tIds).ToList();
|
|
|
+ delIds.AddRange(ids.Except(tIds).ToList());
|
|
|
+ if (tmds.Any()) {
|
|
|
+ var content = new StringContent(tmds.ToJsonString(), Encoding.UTF8, "application/json");
|
|
|
+ string json = await _coreAPIHttpService.GetUserInfos(content);
|
|
|
|
|
|
- if (!string.IsNullOrWhiteSpace(json))
|
|
|
- {
|
|
|
- try
|
|
|
+ if (!string.IsNullOrWhiteSpace(json))
|
|
|
{
|
|
|
- List<ufo> tmdInfos = json.ToObject<List<ufo>>();
|
|
|
- if (tmdInfos.IsNotEmpty())
|
|
|
+ try
|
|
|
{
|
|
|
- foreach (ufo fo in tmdInfos)
|
|
|
+ List<ufo> tmdInfos = json.ToObject<List<ufo>>();
|
|
|
+ if (tmdInfos.IsNotEmpty())
|
|
|
{
|
|
|
- fo.type = 1;
|
|
|
- tIds.Add(fo.id);
|
|
|
+ foreach (ufo fo in tmdInfos)
|
|
|
+ {
|
|
|
+ fo.type = 1;
|
|
|
+ }
|
|
|
+ ufos.AddRange(tmdInfos);
|
|
|
}
|
|
|
- ufos.AddRange(tmdInfos);
|
|
|
- delIds = ids.Except(tIds).ToList();
|
|
|
}
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- await _dingDing.SendBotMsg($"{_coreAPIHttpService.options.location}用户转换失败:{_coreAPIHttpService.options.coreUrl}{json}\n ", GroupNames.醍摩豆服務運維群組);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select distinct c.id,c.name from c where c.id in ({string.Join(",", ids.Select(o => $"'{o}'"))}) and c.pk = 'Base'",
|
|
|
- requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{scode}") }))
|
|
|
- {
|
|
|
- using var stuJson = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
- if (stuJson.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
- {
|
|
|
- var accounts = stuJson.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
- while (accounts.MoveNext())
|
|
|
+ catch (Exception ex)
|
|
|
{
|
|
|
- JsonElement account = accounts.Current;
|
|
|
- ufo fo = new()
|
|
|
- {
|
|
|
- id = account.GetProperty("id").GetString(),
|
|
|
- name = account.GetProperty("name").GetString(),
|
|
|
- //schoolId = account.GetProperty("schoolId").GetString(),
|
|
|
- type = 2
|
|
|
- };
|
|
|
- students.Add(fo);
|
|
|
+ await _dingDing.SendBotMsg($"{_coreAPIHttpService.options.location}用户转换失败:{_coreAPIHttpService.options.coreUrl}{json}\n ", GroupNames.醍摩豆服務運維群組);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (students.Count > 0)
|
|
|
- {
|
|
|
- ufos.AddRange(students);
|
|
|
- foreach (ufo f in students)
|
|
|
- {
|
|
|
- sIds.Add(f.id);
|
|
|
- }
|
|
|
- if (ids.Count > sIds.Count)
|
|
|
+
|
|
|
+ }
|
|
|
+ if(sIds.Any())
|
|
|
+ {
|
|
|
+ var stus = ids.Intersect(sIds).ToList();
|
|
|
+ delIds.AddRange(ids.Except(sIds).ToList());
|
|
|
+ if (stus.Any()) {
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select distinct c.id,c.name from c where c.id in ({string.Join(",", stus.Select(o => $"'{o}'"))}) and c.pk = 'Base'",
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{school}") }))
|
|
|
{
|
|
|
- tIds = ids.Except(sIds).ToList();
|
|
|
- var content = new StringContent(tIds.ToJsonString(), Encoding.UTF8, "application/json");
|
|
|
- string json = await _coreAPIHttpService.GetUserInfos(content);
|
|
|
-
|
|
|
- if (!string.IsNullOrWhiteSpace(json))
|
|
|
+ using var stuJson = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ if (stuJson.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
{
|
|
|
- try
|
|
|
+ var accounts = stuJson.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
+ while (accounts.MoveNext())
|
|
|
{
|
|
|
- List<ufo> tmdInfos = json.ToObject<List<ufo>>();
|
|
|
- if (tmdInfos.IsNotEmpty())
|
|
|
+ JsonElement account = accounts.Current;
|
|
|
+ ufo fo = new()
|
|
|
{
|
|
|
- foreach (ufo fo in tmdInfos)
|
|
|
- {
|
|
|
- fo.type = 1;
|
|
|
- tIds.Add(fo.id);
|
|
|
- }
|
|
|
- ufos.AddRange(tmdInfos);
|
|
|
- }
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- await _dingDing.SendBotMsg($"{_coreAPIHttpService.options.location}用户转换失败:{_coreAPIHttpService.options.coreUrl}{json}\n ", GroupNames.醍摩豆服務運維群組);
|
|
|
+ id = account.GetProperty("id").GetString(),
|
|
|
+ name = account.GetProperty("name").GetString(),
|
|
|
+ //schoolId = account.GetProperty("schoolId").GetString(),
|
|
|
+ type = 2
|
|
|
+ };
|
|
|
+ students.Add(fo);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- delIds = ids.Except(sIds.Union(tIds)).ToList();
|
|
|
- }
|
|
|
+ ufos.AddRange(students);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|