|
@@ -1,6 +1,8 @@
|
|
|
using Azure.Cosmos;
|
|
|
using Azure.Storage.Blobs.Models;
|
|
|
using DocumentFormat.OpenXml.Drawing.Charts;
|
|
|
+using DocumentFormat.OpenXml.Office2010.Excel;
|
|
|
+using DocumentFormat.OpenXml.Spreadsheet;
|
|
|
using HTEXLib.COMM.Helpers;
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
using Microsoft.AspNetCore.Http;
|
|
@@ -310,9 +312,12 @@ namespace TEAMModelOS.Controllers
|
|
|
/// <returns></returns>
|
|
|
[ProducesDefaultResponseType]
|
|
|
[HttpPost("find-children-activity")]
|
|
|
+#if !DEBUG
|
|
|
+ [Authorize(Roles = "AClassONE")]
|
|
|
+#endif
|
|
|
public async Task<IActionResult> getActivity(JsonElement request) {
|
|
|
try {
|
|
|
- //if (!request.TryGetProperty("studentId", out JsonElement stuId)) return BadRequest();
|
|
|
+ if (!request.TryGetProperty("studentId", out JsonElement stuId)) return BadRequest();
|
|
|
if (!request.TryGetProperty("classId", out JsonElement classId)) return BadRequest();
|
|
|
if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();//学校编码
|
|
|
|
|
@@ -326,11 +331,9 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
stringBuilder.Append("order by c.createTime desc");
|
|
|
//是否需要进行分页查询,默认不分页
|
|
|
- bool iscontinuation = false;
|
|
|
if (request.TryGetProperty("token", out JsonElement token_1))
|
|
|
{
|
|
|
token = token_1.GetString();
|
|
|
- iscontinuation = true;
|
|
|
};
|
|
|
//默认不指定返回大小
|
|
|
int? topcout = null;
|
|
@@ -365,14 +368,107 @@ namespace TEAMModelOS.Controllers
|
|
|
// break;
|
|
|
// }
|
|
|
//}
|
|
|
- // arts = arts.Where((x, i) => arts.FindIndex(z => z.id == x.id) == i).ToList();
|
|
|
- return Ok(new { arts ,token});
|
|
|
+ // 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));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ 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,
|
|
|
+ attachments.Where(z => z.artId.Equals(c.id))?.FirstOrDefault().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")]
|
|
|
+#if !DEBUG
|
|
|
+ [Authorize(Roles = "AClassONE")]
|
|
|
+#endif
|
|
|
+ public async Task<IActionResult> findSummaryActivity(JsonElement request)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (!request.TryGetProperty("studentId", out JsonElement stuId)) return BadRequest();
|
|
|
+ if (!request.TryGetProperty("artId", out JsonElement artId)) return BadRequest();
|
|
|
+ //if (!request.TryGetProperty("acId", out JsonElement taskId)) return BadRequest();
|
|
|
+ if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();//学校编码
|
|
|
+
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
+ StudentArtResult result = new();
|
|
|
+ ArtEvaluation art = new();
|
|
|
+ string stu = string.Format("{0}{1}{2}", code.GetString(), "-", stuId.GetString());
|
|
|
+ var res = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemStreamAsync(stu.ToString(), new PartitionKey($"ArtResult-{artId}"));
|
|
|
+ if (res.Status == 200)
|
|
|
+ {
|
|
|
+ using var json = await JsonDocument.ParseAsync(res.ContentStream);
|
|
|
+ result = json.ToObject<StudentArtResult>();
|
|
|
+
|
|
|
+ }
|
|
|
+ var resArt = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync(artId.ToString(), new PartitionKey($"Art-{code}"));
|
|
|
+ if (resArt.Status == 200)
|
|
|
+ {
|
|
|
+ using var json = await JsonDocument.ParseAsync(res.ContentStream);
|
|
|
+ art = json.ToObject<ArtEvaluation>();
|
|
|
+
|
|
|
+ }
|
|
|
+ return Ok(new { result,art });
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ await _dingDing.SendBotMsg($"OS,{_option.Location},art/find-summary-activity()\n{e.Message}\n{e.StackTrace}\n", GroupNames.醍摩豆服務運維群組);
|
|
|
+ return BadRequest("500错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
[ProducesDefaultResponseType]
|
|
|
[HttpPost("upload-all")]
|
|
|
#if !DEBUG
|