|
@@ -4,6 +4,7 @@ using Azure.Storage.Sas;
|
|
|
using DocumentFormat.OpenXml.Drawing.Charts;
|
|
|
using DocumentFormat.OpenXml.Office2010.Excel;
|
|
|
using DocumentFormat.OpenXml.Office2021.DocumentTasks;
|
|
|
+using DocumentFormat.OpenXml.Presentation;
|
|
|
using DocumentFormat.OpenXml.Spreadsheet;
|
|
|
using DocumentFormat.OpenXml.Wordprocessing;
|
|
|
using HTEXLib.COMM.Helpers;
|
|
@@ -888,51 +889,6 @@ namespace TEAMModelOS.Controllers
|
|
|
arts = result.list;
|
|
|
token = result.continuationToken;
|
|
|
}
|
|
|
- //await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: stringBuilder.ToString(), continuationToken: token, requestOptions: new QueryRequestOptions() { MaxItemCount = topcout, PartitionKey = new PartitionKey($"Art-{code}") }))
|
|
|
- //{
|
|
|
-
|
|
|
- // 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())
|
|
|
- // {
|
|
|
- // arts.Add(obj.ToObject<ArtEvaluation>());
|
|
|
- // }
|
|
|
- // }
|
|
|
- // if (iscontinuation)
|
|
|
- // {
|
|
|
- // continuationToken = item.GetContinuationToken();
|
|
|
- // break;
|
|
|
- // }
|
|
|
- //}
|
|
|
- // arts = arts.Where((x, i) => arts.FindIndex(z => z.id == x.id) == i).ToList();
|
|
|
- //List<(string artId, double count)> attachments = new();
|
|
|
- /* foreach (ArtEvaluation art in arts) {
|
|
|
- List<StudentArtResult> artResults = new();
|
|
|
- string stu = string.Format("{0}{1}{2}", code.GetString(), "-", stuId.GetString());
|
|
|
- string sql = $"select value(c) from c where c.artId = '{art.id}' and c.id = '{stu}' and c.pk = 'ArtResult'";
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(
|
|
|
- queryText: sql))
|
|
|
- {
|
|
|
- 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())
|
|
|
- {
|
|
|
- artResults.Add(obj.ToObject<StudentArtResult>());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (artResults.Count > 0)
|
|
|
- {
|
|
|
- var attCount = artResults[0].results.Where(z => z.files != null).SelectMany(c => c.files).ToList().Count;
|
|
|
- attachments.Add((art.id, attCount));
|
|
|
- }
|
|
|
- else {
|
|
|
- attachments.Add((art.id, 0));
|
|
|
- }
|
|
|
-
|
|
|
- }*/
|
|
|
List<string> artIds = new();
|
|
|
artIds = arts.Select(c => c.id).ToList();
|
|
|
List<ArtAttachment> artAttachments = new();
|
|
@@ -972,7 +928,95 @@ namespace TEAMModelOS.Controllers
|
|
|
return BadRequest("500错误");
|
|
|
}
|
|
|
}
|
|
|
+ /// <summary>
|
|
|
+ /// 获取当前老师所在范围的活动列表
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="json"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [HttpPost("find-teacher-activity")]
|
|
|
+#if !DEBUG
|
|
|
+ [Authorize(Roles = "AClassONE")]
|
|
|
+#endif
|
|
|
+ public async Task<IActionResult> getTeacherActivity(JsonElement request)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (!request.TryGetProperty("studentId", out JsonElement teacId)) return BadRequest();
|
|
|
+ if (!request.TryGetProperty("classIds", out JsonElement classIds)) return BadRequest();
|
|
|
+ if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();//学校编码
|
|
|
+ List<string> cIds = classIds.ToObject<List<string>>();
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
+ StringBuilder stringBuilder = new($"select value(c) from c where (c.status<>404 or IS_DEFINED(c.status) = false )");
|
|
|
+ string continuationToken = string.Empty;
|
|
|
+ string token = default;
|
|
|
+ stringBuilder.Append("order by c.createTime desc");
|
|
|
+ //是否需要进行分页查询,默认不分页
|
|
|
+ if (request.TryGetProperty("token", out JsonElement token_1))
|
|
|
+ {
|
|
|
+ token = token_1.GetString();
|
|
|
+ };
|
|
|
+ //默认不指定返回大小
|
|
|
+ int? topcout = null;
|
|
|
+ if (request.TryGetProperty("count", out JsonElement jcount))
|
|
|
+ {
|
|
|
+ if (!jcount.ValueKind.Equals(JsonValueKind.Undefined) && !jcount.ValueKind.Equals(JsonValueKind.Null) && jcount.TryGetInt32(out int data))
|
|
|
+ {
|
|
|
+ topcout = data;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ List<ArtEvaluation> arts = new();
|
|
|
+ var result = await client.GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<ArtEvaluation>(stringBuilder.ToString(), $"Art-{code}", token, 5);
|
|
|
+ if (result.list.IsNotEmpty())
|
|
|
+ {
|
|
|
+ arts = result.list;
|
|
|
+ token = result.continuationToken;
|
|
|
+ }
|
|
|
+ arts = arts.Where(c => c.classes.Intersect(cIds).Any()).Where((x, i) => arts.FindIndex(z => z.id == x.id) == i).ToList();
|
|
|
+ List<string> artIds = new();
|
|
|
+ artIds = arts.Select(c => c.id).ToList();
|
|
|
+ List<ArtAttachment> artAttachments = new();
|
|
|
+ string sqlTask = $"select value(c) from c where c.studentId = '{teacId}' and c.artId in ({string.Join(",", artIds.Select(s => $"'{s}'"))})";
|
|
|
+ await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).
|
|
|
+ GetItemQueryIterator<ArtAttachment>(queryText: sqlTask, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"ArtAttachment-{code}") }))
|
|
|
+ {
|
|
|
+ artAttachments.Add(item);
|
|
|
+ }
|
|
|
+ var newArts = arts.Select(c => new {
|
|
|
+
|
|
|
+ c.id,
|
|
|
+ c.name,
|
|
|
+ c.school,
|
|
|
+ c.createTime,
|
|
|
+ c.type,
|
|
|
+ c.classes,
|
|
|
+ c.progress,
|
|
|
+ c.scope,
|
|
|
+ c.areaId,
|
|
|
+ c.pId,
|
|
|
+ c.topic,
|
|
|
+ c.startTime,
|
|
|
+ c.endTime,
|
|
|
+ c.uploadSTime,
|
|
|
+ c.uploadETime,
|
|
|
+ c.publish,
|
|
|
+ c.subjects,
|
|
|
+ c.period,
|
|
|
+ c.periodType,
|
|
|
+ c.zymusicstds,
|
|
|
+ c.code,
|
|
|
+ count = artAttachments.Where(z => z.artId.Equals(c.id)).ToList().Count
|
|
|
+
|
|
|
+ });
|
|
|
+ return Ok(new { arts = newArts, token });
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ await _dingDing.SendBotMsg($"OS,{_option.Location},art/find-children-activity()\n{e.Message}\n{e.StackTrace}\n", GroupNames.醍摩豆服務運維群組);
|
|
|
+ return BadRequest("500错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
[ProducesDefaultResponseType]
|
|
|
[HttpPost("find-summary-activity")]
|