|
@@ -7,6 +7,9 @@ using DocumentFormat.OpenXml.Office2013.Excel;
|
|
using DocumentFormat.OpenXml.Office2016.Excel;
|
|
using DocumentFormat.OpenXml.Office2016.Excel;
|
|
using DocumentFormat.OpenXml.Spreadsheet;
|
|
using DocumentFormat.OpenXml.Spreadsheet;
|
|
using DocumentFormat.OpenXml.Wordprocessing;
|
|
using DocumentFormat.OpenXml.Wordprocessing;
|
|
|
|
+using HTEXLib.COMM.Helpers;
|
|
|
|
+using HTEXLib.Helpers.ShapeHelpers;
|
|
|
|
+using MathNet.Numerics.Distributions;
|
|
using MathNet.Numerics.RootFinding;
|
|
using MathNet.Numerics.RootFinding;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Http;
|
|
@@ -20,16 +23,19 @@ using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Net;
|
|
using System.Reflection;
|
|
using System.Reflection;
|
|
|
|
+using System.Security.Policy;
|
|
using System.Text;
|
|
using System.Text;
|
|
using System.Text.Json;
|
|
using System.Text.Json;
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
using System.Xml.Linq;
|
|
using System.Xml.Linq;
|
|
|
|
+using TEAMModelOS.Controllers.Analysis;
|
|
using TEAMModelOS.Filter;
|
|
using TEAMModelOS.Filter;
|
|
using TEAMModelOS.Models;
|
|
using TEAMModelOS.Models;
|
|
using TEAMModelOS.SDK;
|
|
using TEAMModelOS.SDK;
|
|
using TEAMModelOS.SDK.DI;
|
|
using TEAMModelOS.SDK.DI;
|
|
using TEAMModelOS.SDK.Extension;
|
|
using TEAMModelOS.SDK.Extension;
|
|
using TEAMModelOS.SDK.Models;
|
|
using TEAMModelOS.SDK.Models;
|
|
|
|
+using TEAMModelOS.SDK.Models.Cosmos;
|
|
using TEAMModelOS.SDK.Models.Cosmos.Common;
|
|
using TEAMModelOS.SDK.Models.Cosmos.Common;
|
|
using Survey = TEAMModelOS.SDK.Models.Survey;
|
|
using Survey = TEAMModelOS.SDK.Models.Survey;
|
|
|
|
|
|
@@ -142,30 +148,28 @@ namespace TEAMModelOS.Controllers.Common
|
|
[AuthToken(Roles = "teacher,admin,student")]
|
|
[AuthToken(Roles = "teacher,admin,student")]
|
|
[HttpPost("update-state")]
|
|
[HttpPost("update-state")]
|
|
[Authorize(Roles = "IES")]
|
|
[Authorize(Roles = "IES")]
|
|
- public async Task<IActionResult> UpdateState(ArtRecord request)
|
|
|
|
|
|
+ public async Task<IActionResult> UpdateState(JsonElement request)
|
|
{
|
|
{
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
try
|
|
try
|
|
{
|
|
{
|
|
|
|
+ if (!request.TryGetProperty("id", out JsonElement stuId)) return BadRequest();
|
|
|
|
+ if (!request.TryGetProperty("artId", out JsonElement artId)) return BadRequest();
|
|
|
|
+ if (!request.TryGetProperty("isAnsewer", out JsonElement isAnsewer)) return BadRequest();
|
|
var (userid, name, picture, school) = HttpContext.GetAuthTokenInfo();
|
|
var (userid, name, picture, school) = HttpContext.GetAuthTokenInfo();
|
|
HttpContext.Items.TryGetValue("Scope", out object scope);
|
|
HttpContext.Items.TryGetValue("Scope", out object scope);
|
|
int userType = $"{scope}".Equals(Constant.ScopeStudent) ? 2 : 1;
|
|
int userType = $"{scope}".Equals(Constant.ScopeStudent) ? 2 : 1;
|
|
- request.school = school;
|
|
|
|
- request.stuId = userid;
|
|
|
|
- request.code = "ArtRecord";
|
|
|
|
- long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
|
|
- request.createTime = now;
|
|
|
|
- ArtRecord record;
|
|
|
|
- if (string.IsNullOrEmpty(request.id))
|
|
|
|
|
|
+ StudentArtResult artResult = null;
|
|
|
|
+ //long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
|
|
+ var res = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync(stuId.ToString(), new PartitionKey($"ArtResult-{artId}"));
|
|
|
|
+ if (res.Status == 200)
|
|
{
|
|
{
|
|
- request.id = Guid.NewGuid().ToString();
|
|
|
|
- record = await client.GetContainer("TEAMModelOS", "Student").CreateItemAsync(request, new PartitionKey($"{request.code}"));
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- record = await client.GetContainer("TEAMModelOS", "Student").ReplaceItemAsync(request, request.id, new PartitionKey($"{request.code}"));
|
|
|
|
- }
|
|
|
|
- return Ok(record);
|
|
|
|
|
|
+ using var cJson = await JsonDocument.ParseAsync(res.ContentStream);
|
|
|
|
+ artResult = cJson.ToObject<StudentArtResult>();
|
|
|
|
+ artResult.isAnswer = isAnsewer.GetInt32();
|
|
|
|
+ await client.GetContainer("TEAMModelOS", "Student").ReplaceItemAsync(artResult, artResult.id, new PartitionKey($"{artResult.code}"));
|
|
|
|
+ }
|
|
|
|
+ return Ok(artResult);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
catch (Exception e)
|
|
{
|
|
{
|
|
@@ -199,15 +203,15 @@ namespace TEAMModelOS.Controllers.Common
|
|
{
|
|
{
|
|
classIds.Add(grp.id);
|
|
classIds.Add(grp.id);
|
|
}
|
|
}
|
|
- if (string.IsNullOrEmpty(request.id))
|
|
|
|
- {
|
|
|
|
- request.id = Guid.NewGuid().ToString();
|
|
|
|
- record = await client.GetContainer("TEAMModelOS", "Student").CreateItemAsync(request, new PartitionKey($"{request.code}"));
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- record = await client.GetContainer("TEAMModelOS", "Student").ReplaceItemAsync(request, request.id, new PartitionKey($"{request.code}"));
|
|
|
|
- }
|
|
|
|
|
|
+ /* if (string.IsNullOrEmpty(request.id))
|
|
|
|
+ {
|
|
|
|
+ request.id = Guid.NewGuid().ToString();
|
|
|
|
+ record = await client.GetContainer("TEAMModelOS", "Student").CreateItemAsync(request, new PartitionKey($"{request.code}"));
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ record = await client.GetContainer("TEAMModelOS", "Student").ReplaceItemAsync(request, request.id, new PartitionKey($"{request.code}"));
|
|
|
|
+ }*/
|
|
string rId = string.Format("{0}{1}{2}", request.school, "-", userid);
|
|
string rId = string.Format("{0}{1}{2}", request.school, "-", userid);
|
|
//首先根据大ID获取整个活动得内容
|
|
//首先根据大ID获取整个活动得内容
|
|
var aresponse = await client.GetContainer("TEAMModelOS", "Common").ReadItemStreamAsync(request.artId, new PartitionKey($"Art-{school}"));
|
|
var aresponse = await client.GetContainer("TEAMModelOS", "Common").ReadItemStreamAsync(request.artId, new PartitionKey($"Art-{school}"));
|
|
@@ -274,7 +278,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
await client.GetContainer("TEAMModelOS", "Student").CreateItemAsync(artResult, new PartitionKey($"{artResult.code}"));
|
|
await client.GetContainer("TEAMModelOS", "Student").CreateItemAsync(artResult, new PartitionKey($"{artResult.code}"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return Ok(new { record, code = 200 });
|
|
|
|
|
|
+ return Ok(new { code = 200 });
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
{
|
|
{
|
|
@@ -331,25 +335,25 @@ namespace TEAMModelOS.Controllers.Common
|
|
|
|
|
|
private async IAsyncEnumerable<(int code, string value)> stuTask(List<stuFiles> stuFiles, CosmosClient client, string school, string artId, string classId, string quotaId, string acId, string subject)
|
|
private async IAsyncEnumerable<(int code, string value)> stuTask(List<stuFiles> stuFiles, CosmosClient client, string school, string artId, string classId, string quotaId, string acId, string subject)
|
|
{
|
|
{
|
|
- string queryScore = $" select c.id from c where c.artId ='{artId}' and c.quotaId = '{quotaId}' and c.acId = '{acId}' and c.subject = '{subject}' and c.classId = '{classId}'";
|
|
|
|
- List<string> ids = new();
|
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Student).GetItemQueryStreamIterator
|
|
|
|
- (queryText: queryScore, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("ArtRecord") }))
|
|
|
|
- {
|
|
|
|
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
|
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
|
- {
|
|
|
|
- foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
|
- {
|
|
|
|
- if (obj.TryGetProperty("id", out JsonElement subScore))
|
|
|
|
- {
|
|
|
|
- //string sId = obj.GetProperty("id").GetString();
|
|
|
|
- ids.Add(subScore.GetString());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemsAsync<ArtRecord>(ids, "ArtRecord");
|
|
|
|
|
|
+ /* string queryScore = $" select c.id from c where c.artId ='{artId}' and c.quotaId = '{quotaId}' and c.acId = '{acId}' and c.subject = '{subject}' and c.classId = '{classId}'";
|
|
|
|
+ List<string> ids = new();
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Student).GetItemQueryStreamIterator
|
|
|
|
+ (queryText: queryScore, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("ArtRecord") }))
|
|
|
|
+ {
|
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
|
+ {
|
|
|
|
+ foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
|
+ {
|
|
|
|
+ if (obj.TryGetProperty("id", out JsonElement subScore))
|
|
|
|
+ {
|
|
|
|
+ //string sId = obj.GetProperty("id").GetString();
|
|
|
|
+ ids.Add(subScore.GetString());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemsAsync<ArtRecord>(ids, "ArtRecord");*/
|
|
// await _azureStorage.GetBlobServiceClient().DeleteBlobs(_dingDing, school, new List<string> { $"art/{artId}" });
|
|
// await _azureStorage.GetBlobServiceClient().DeleteBlobs(_dingDing, school, new List<string> { $"art/{artId}" });
|
|
foreach (var request in stuFiles)
|
|
foreach (var request in stuFiles)
|
|
{
|
|
{
|
|
@@ -379,7 +383,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
{
|
|
{
|
|
classIds.Add(grp.id);
|
|
classIds.Add(grp.id);
|
|
}
|
|
}
|
|
- if (string.IsNullOrEmpty(record.id))
|
|
|
|
|
|
+ /*if (string.IsNullOrEmpty(record.id))
|
|
{
|
|
{
|
|
record.id = Guid.NewGuid().ToString();
|
|
record.id = Guid.NewGuid().ToString();
|
|
record = await client.GetContainer("TEAMModelOS", "Student").CreateItemAsync(record, new PartitionKey($"{record.code}"));
|
|
record = await client.GetContainer("TEAMModelOS", "Student").CreateItemAsync(record, new PartitionKey($"{record.code}"));
|
|
@@ -387,7 +391,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
else
|
|
else
|
|
{
|
|
{
|
|
record = await client.GetContainer("TEAMModelOS", "Student").ReplaceItemAsync(record, record.id, new PartitionKey($"{record.code}"));
|
|
record = await client.GetContainer("TEAMModelOS", "Student").ReplaceItemAsync(record, record.id, new PartitionKey($"{record.code}"));
|
|
- }
|
|
|
|
|
|
+ }*/
|
|
string rId = string.Format("{0}{1}{2}", record.school, "-", record.stuId);
|
|
string rId = string.Format("{0}{1}{2}", record.school, "-", record.stuId);
|
|
//首先根据大ID获取整个活动得内容
|
|
//首先根据大ID获取整个活动得内容
|
|
var aresponse = await client.GetContainer("TEAMModelOS", "Common").ReadItemStreamAsync(artId, new PartitionKey($"Art-{school}"));
|
|
var aresponse = await client.GetContainer("TEAMModelOS", "Common").ReadItemStreamAsync(artId, new PartitionKey($"Art-{school}"));
|
|
@@ -561,7 +565,8 @@ namespace TEAMModelOS.Controllers.Common
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- foreach (string artId in artIds) {
|
|
|
|
|
|
+ foreach (string artId in artIds)
|
|
|
|
+ {
|
|
await client.GetContainer("TEAMModelOS", "Common").DeleteItemStreamAsync(artId, new PartitionKey("ArtMusic"));
|
|
await client.GetContainer("TEAMModelOS", "Common").DeleteItemStreamAsync(artId, new PartitionKey("ArtMusic"));
|
|
await client.GetContainer("TEAMModelOS", "Common").DeleteItemStreamAsync(artId, new PartitionKey("ArtExam"));
|
|
await client.GetContainer("TEAMModelOS", "Common").DeleteItemStreamAsync(artId, new PartitionKey("ArtExam"));
|
|
}
|
|
}
|
|
@@ -585,7 +590,8 @@ namespace TEAMModelOS.Controllers.Common
|
|
}
|
|
}
|
|
await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemsAsync<ArtRecord>(ids, "ArtRecord");
|
|
await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemsAsync<ArtRecord>(ids, "ArtRecord");
|
|
}
|
|
}
|
|
- else {
|
|
|
|
|
|
+ else
|
|
|
|
+ {
|
|
string queryScore = $" select c.id from c where c.artId = {art.id})";
|
|
string queryScore = $" select c.id from c where c.artId = {art.id})";
|
|
List<string> ids = new();
|
|
List<string> ids = new();
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Student).GetItemQueryStreamIterator
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Student).GetItemQueryStreamIterator
|
|
@@ -606,7 +612,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
}
|
|
}
|
|
await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemsAsync<ArtRecord>(ids, "ArtRecord");
|
|
await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemsAsync<ArtRecord>(ids, "ArtRecord");
|
|
await client.GetContainer("TEAMModelOS", "Common").DeleteItemStreamAsync(art.id, new PartitionKey("ArtMusic"));
|
|
await client.GetContainer("TEAMModelOS", "Common").DeleteItemStreamAsync(art.id, new PartitionKey("ArtMusic"));
|
|
- }
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -717,7 +723,8 @@ namespace TEAMModelOS.Controllers.Common
|
|
{
|
|
{
|
|
|
|
|
|
}
|
|
}
|
|
- else {
|
|
|
|
|
|
+ else
|
|
|
|
+ {
|
|
List<(string eId, string sId)> ids = new();
|
|
List<(string eId, string sId)> ids = new();
|
|
var examId = art.settings.SelectMany(x => x.task).Where(c => c.type == 1).Select(z => new { z.acId, z.subject }).ToList();
|
|
var examId = art.settings.SelectMany(x => x.task).Where(c => c.type == 1).Select(z => new { z.acId, z.subject }).ToList();
|
|
examId.ForEach(x =>
|
|
examId.ForEach(x =>
|
|
@@ -860,11 +867,11 @@ namespace TEAMModelOS.Controllers.Common
|
|
}
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(ae.id))
|
|
if (!string.IsNullOrWhiteSpace(ae.id))
|
|
{
|
|
{
|
|
- return Ok(new { art, classes, ae, music,count = rmembers.Count, code = 200 });
|
|
|
|
|
|
+ return Ok(new { art, classes, ae, music, count = rmembers.Count, code = 200 });
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- return Ok(new { art, classes, music,count = rmembers.Count, code = 200 });
|
|
|
|
|
|
+ return Ok(new { art, classes, music, count = rmembers.Count, code = 200 });
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -931,7 +938,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
{
|
|
{
|
|
List<StuActivity> stus = new();
|
|
List<StuActivity> stus = new();
|
|
List<string> wIds = new();
|
|
List<string> wIds = new();
|
|
- List<ArtRecord> works = new();
|
|
|
|
|
|
+ List<StudentArtResult> works = new();
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(art.pId))
|
|
if (!string.IsNullOrWhiteSpace(art.pId))
|
|
{
|
|
{
|
|
@@ -952,7 +959,7 @@ namespace TEAMModelOS.Controllers.Common
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var taskType1 = art.settings.SelectMany(z => z.task).Where(t => t.type == 1);
|
|
var taskType1 = art.settings.SelectMany(z => z.task).Where(t => t.type == 1);
|
|
- wIds = art.settings.SelectMany(z => z.task).Where(t => t.type == 2).Select(a => a.acId).ToList();
|
|
|
|
|
|
+ //wIds = art.settings.SelectMany(z => z.task).Where(t => t.type == 2).Select(a => a.acId).ToList();
|
|
if (taskType1 != null && taskType1.Any())
|
|
if (taskType1 != null && taskType1.Any())
|
|
{
|
|
{
|
|
string sql = $"select value c from c where c.id in ({string.Join(",", taskType1.Select(z => $"'{z.acId}'"))})";
|
|
string sql = $"select value c from c where c.id in ({string.Join(",", taskType1.Select(z => $"'{z.acId}'"))})";
|
|
@@ -961,35 +968,12 @@ namespace TEAMModelOS.Controllers.Common
|
|
{
|
|
{
|
|
stus.Add(item);
|
|
stus.Add(item);
|
|
}
|
|
}
|
|
- }
|
|
|
|
- //foreach (var tt in art.settings)
|
|
|
|
- //{
|
|
|
|
- // foreach (var acs in tt.task)
|
|
|
|
- // {
|
|
|
|
- // if (acs.type == 1)
|
|
|
|
- // {
|
|
|
|
- // var response = await client.GetContainer("TEAMModelOS", "Student").ReadItemStreamAsync(acs.acId, new PartitionKey($"Activity-{school}-{userid}"));
|
|
|
|
- // if (response.Status == 200)
|
|
|
|
- // {
|
|
|
|
- // using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
|
- // StuActivity info = json.ToObject<StuActivity>();
|
|
|
|
- // stus.Add(info);
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // if (acs.type == 2)
|
|
|
|
- // {
|
|
|
|
- // wIds.Add(acs.acId);
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- //}
|
|
|
|
- if (wIds.Count > 0)
|
|
|
|
|
|
+ }
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<StudentArtResult>(
|
|
|
|
+ queryText: $"select value(c) from c where c.id = '{code}-{userid}'",
|
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ArtResult-{id}") }))
|
|
{
|
|
{
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<ArtRecord>(
|
|
|
|
- queryText: $"select value(c) from c where c.stuId = '{userid}' and c.acId in ({string.Join(",", wIds.Select(o => $"'{o}'"))})",
|
|
|
|
- requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ArtRecord") }))
|
|
|
|
- {
|
|
|
|
- works.Add(item);
|
|
|
|
- }
|
|
|
|
|
|
+ works.Add(item);
|
|
}
|
|
}
|
|
return Ok(new { art, stus, works, music, code = 200 });
|
|
return Ok(new { art, stus, works, music, code = 200 });
|
|
}
|
|
}
|
|
@@ -1020,23 +1004,57 @@ namespace TEAMModelOS.Controllers.Common
|
|
{
|
|
{
|
|
if (!request.TryGetProperty("classId", out JsonElement classId)) return BadRequest();
|
|
if (!request.TryGetProperty("classId", out JsonElement classId)) return BadRequest();
|
|
if (!request.TryGetProperty("subject", out JsonElement subject)) return BadRequest();
|
|
if (!request.TryGetProperty("subject", out JsonElement subject)) return BadRequest();
|
|
|
|
+ //艺术评测ID
|
|
if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
|
|
if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
|
|
|
|
+ string token = HttpContext.GetToken();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
- var (userid, _, _, school) = HttpContext.GetAuthTokenInfo();
|
|
|
|
- List<object> works = new();
|
|
|
|
|
|
+ //var (userid, _, _, school) = HttpContext.GetAuthTokenInfo();
|
|
|
|
+ List<StudentArtResult> artResults = new();
|
|
|
|
+ string sql = $"select value(c) from c where c.artId = '{id}' and array_contains(c.classIds,'{classId}') ";
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(
|
|
- queryText: $"select c.stuId,c.attachments,c.isAnswer,c.createTime,c.url from c where c.classId = '{classId}' and c.acId = '{id}' and c.subject = '{subject}'",
|
|
|
|
- requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ArtRecord") }))
|
|
|
|
|
|
+ queryText: sql,
|
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ArtResult-{id}") }))
|
|
{
|
|
{
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
{
|
|
{
|
|
foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
{
|
|
{
|
|
- works.Add(obj.ToObject<object>());
|
|
|
|
|
|
+ artResults.Add(obj.ToObject<StudentArtResult>());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ artResults.ForEach(x => x.results.RemoveAll(z => !string.IsNullOrWhiteSpace(z.subjectId) && !subject.GetString().Equals(z.subjectId)));
|
|
|
|
+ artResults.ForEach(x => x.subjectScores.RemoveAll(z => !string.IsNullOrWhiteSpace(z.subjectId) && !subject.GetString().Equals(z.subjectId)));
|
|
|
|
+
|
|
|
|
+ List<(string stuId, string url)> zyUrl = new();
|
|
|
|
+ foreach (StudentArtResult artResult in artResults)
|
|
|
|
+ {
|
|
|
|
+ if (!string.IsNullOrWhiteSpace(artResult.zyanswer.thirdAnswerId))
|
|
|
|
+ {
|
|
|
|
+ byte[] inputBytes = Encoding.UTF8.GetBytes(artResult.zyanswer.thirdAnswerId);
|
|
|
|
+ string base64Str = Convert.ToBase64String(inputBytes);
|
|
|
|
+ //var date = Convert.FromBase64String(base64Str);
|
|
|
|
+ StringBuilder url = new StringBuilder("https://amesopen.aimusic.art?appid=8a68f563f3384662acbc268336b98ae2");
|
|
|
|
+ url.Append($"&data={base64Str}");
|
|
|
|
+ url.Append($"&thirdToken={token}");
|
|
|
|
+ zyUrl.Add((artResult.studentId, url.ToString()));
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ zyUrl.Add((artResult.studentId, string.Empty));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ var works = artResults.Select(x => new
|
|
|
|
+ {
|
|
|
|
+ x.studentId,
|
|
|
|
+ x.studentName,
|
|
|
|
+ x.classIds,
|
|
|
|
+ x.artId,
|
|
|
|
+ x.results,
|
|
|
|
+ zyUrl.Where(c => c.stuId.Equals(x.studentId)).FirstOrDefault().url
|
|
|
|
+ });
|
|
return Ok(new { works, code = 200 });
|
|
return Ok(new { works, code = 200 });
|
|
|
|
|
|
}
|
|
}
|