|
@@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Http;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
using Microsoft.Extensions.Options;
|
|
|
+using NUnit.Framework;
|
|
|
using OpenXmlPowerTools;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
@@ -419,15 +420,71 @@ namespace TEAMModelOS.Controllers.Common
|
|
|
if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
ArtEvaluation art = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ArtEvaluation>(id.GetString(), new PartitionKey($"Art-{code}"));
|
|
|
+
|
|
|
if (art != null)
|
|
|
{
|
|
|
- List<GroupListDto> groups = await GroupListService.GetGroupListByListids(client, _dingDing, art.classes, art.school);
|
|
|
+ (List<RMember> rmembers, List<RGroupList> groups) = await GroupListService.GetMemberByListids( _coreAPIHttpService, client, _dingDing, art.classes, art.school);
|
|
|
var classes = art.classes.Select(c => new
|
|
|
{
|
|
|
id = c,
|
|
|
groups.Where(g => g.id.Equals(c)).FirstOrDefault().name
|
|
|
});
|
|
|
- return Ok(new { art, classes, code = 200 });
|
|
|
+ rmembers.ForEach(x =>
|
|
|
+ {
|
|
|
+ groups.ForEach(z =>
|
|
|
+ {
|
|
|
+ if (z.members.Exists(y => y.id.Equals(x.id) && y.type == x.type))
|
|
|
+ {
|
|
|
+ x.groupListIds.Add(z.id);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ });
|
|
|
+ var students= rmembers.Select(z => new StudentArtResult {
|
|
|
+ studentId = z.id,
|
|
|
+ studentName = z.name,
|
|
|
+ userType = z.type,
|
|
|
+ classIds = z.groupListIds,
|
|
|
+ school = z.schoolId,
|
|
|
+ picture = z.picture,
|
|
|
+ artId = $"{id}",
|
|
|
+ id=$"{z.schoolId}-{z.id}",
|
|
|
+ code=$"ArtResult-{id}",
|
|
|
+ pk= "ArtResult",
|
|
|
+ ttl=-1,
|
|
|
+ }).ToList();
|
|
|
+ if (students.Any()) {
|
|
|
+ string query = $" select c.id from c where c.id in({string.Join(",", students.Select(x => $"'{x.id}'"))}) ";
|
|
|
+ List<string> list = new List<string>();
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Student).GetItemQueryIterator<string>
|
|
|
+ (queryText: query, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"ArtResult-{id}") }))
|
|
|
+ {
|
|
|
+ list.Add(item);
|
|
|
+ }
|
|
|
+ students.RemoveAll(x => list.Contains(x.id));
|
|
|
+ students.ForEach(x => {
|
|
|
+ art.settings.ForEach(a => {
|
|
|
+ a.task.ForEach(z => {
|
|
|
+ ArtQuotaResult quotaResult = new ArtQuotaResult
|
|
|
+ {
|
|
|
+ taskId=z.acId,
|
|
|
+ subjectId=z.subject,
|
|
|
+ quotaId=a.id,
|
|
|
+ quotaType=z.type.Value,
|
|
|
+ };
|
|
|
+ x.results.Add(quotaResult);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
+ if (students.Any()) {
|
|
|
+ List<Task<ItemResponse<StudentArtResult>>> responses = new List<Task<ItemResponse<StudentArtResult>>>();
|
|
|
+ students.ForEach( z => {
|
|
|
+ responses.Add(client.GetContainer(Constant.TEAMModelOS, Constant.Student).CreateItemAsync(z, new PartitionKey(z.code)));
|
|
|
+ });
|
|
|
+ await Task.WhenAll(responses);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Ok(new { art, classes, code = 200 });
|
|
|
}
|
|
|
else
|
|
|
{
|