|
@@ -187,54 +187,107 @@ namespace TEAMModelOS.Controllers
|
|
|
return Ok(new {code=0,msg="加入PDF报告生成队列中。" });
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ {
|
|
|
+ "artId": "99a946a7-f475-463f-846f-834a276e1b34",
|
|
|
+ "schoolId": "hbcn",
|
|
|
+ "schoolCode":"hbcn",
|
|
|
+ "opt": "gen-pdf",
|
|
|
+ "headLang":"zh-cn",
|
|
|
+ "studentIds": [
|
|
|
+ "202206001", "202206002"
|
|
|
+ ]
|
|
|
+}
|
|
|
+
|
|
|
+ */
|
|
|
+
|
|
|
[ProducesDefaultResponseType]
|
|
|
//[AuthToken(Roles = "teacher,admin")]
|
|
|
- [HttpPost("get-pdf")]
|
|
|
- public async Task<IActionResult> getPdf(JsonElement request)
|
|
|
+ [HttpPost("update-custom-comment")]
|
|
|
+ public async Task<IActionResult> UpdateCustomComment(JsonElement json)
|
|
|
{
|
|
|
- string head_lang = "zh-cn";
|
|
|
- List<string> schools = new List<string>();
|
|
|
- if (request.TryGetProperty("schools", out JsonElement _schools) && _schools.ValueKind.Equals(JsonValueKind.Array))
|
|
|
+ string head_lang = "";
|
|
|
+ if (HttpContext.Request.Headers.TryGetValue("lang", out var _lang))
|
|
|
{
|
|
|
- schools = _schools.ToObject<List<string>>();
|
|
|
+ head_lang = $"{_lang}";
|
|
|
}
|
|
|
- var client = _azureCosmos.GetCosmosClient();
|
|
|
- string sql = "select * from c where c.pk = 'Art' and c.pId in ('2f74d38e-80c1-4c55-9dd0-de0d8f6fdf6d','306fa576-7ae4-4baa-ac24-0b5ad4dd1bc2')";
|
|
|
- List<ArtEvaluation> infos = new();
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Common).GetItemQueryIteratorSql<ArtEvaluation>(queryText: sql))
|
|
|
+ if (string.IsNullOrWhiteSpace(head_lang))
|
|
|
+ {
|
|
|
+ head_lang = _option.Location.Contains("China") ? "zh-cn" : "en-us";
|
|
|
+ }
|
|
|
+ if (!json.TryGetProperty("artId", out JsonElement _artId))
|
|
|
+ {
|
|
|
+ return BadRequest();
|
|
|
+ }
|
|
|
+ if (!json.TryGetProperty("schoolId", out JsonElement _schoolId))
|
|
|
{
|
|
|
- infos.Add(item);
|
|
|
+ return BadRequest();
|
|
|
}
|
|
|
- //List<Task<ItemResponse<ExamInfo>>> tasks = new List<Task<ItemResponse<ExamInfo>>>();
|
|
|
- List<string> ids = infos.Select(x => x.id).ToList();
|
|
|
+ if (!json.TryGetProperty("studentId", out JsonElement _studentId))
|
|
|
+ {
|
|
|
+ return BadRequest();
|
|
|
+ }
|
|
|
+ json.TryGetProperty("comment", out JsonElement _comment);
|
|
|
+ json.TryGetProperty("comment_music", out JsonElement _comment_music);
|
|
|
+ json.TryGetProperty("comment_painting", out JsonElement _comment_painting);
|
|
|
+
|
|
|
+ string query = $" select value c from c where c.school = '{_schoolId}' and c.studentId ='{_studentId}'";
|
|
|
List<StudentArtResult> artResults = new List<StudentArtResult>();
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIteratorSql(
|
|
|
- queryText: $"select value(c) from c where c.pk = 'ArtResult' and c.artId in ({string.Join(",", ids.Select(o => $"'{o}'"))})"))
|
|
|
+ await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).GetItemQueryIteratorSql<StudentArtResult>
|
|
|
+ (queryText: query, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"ArtResult-{_artId}") }))
|
|
|
{
|
|
|
- using var json = await JsonDocument.ParseAsync(item.Content);
|
|
|
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
- {
|
|
|
- foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
+ item.comment=$"{_comment}";
|
|
|
+ item.subjectScores.ForEach(x => {
|
|
|
+ if(x.subjectId.Equals("subject_music"))
|
|
|
{
|
|
|
- artResults.Add(obj.ToObject<StudentArtResult>());
|
|
|
+ x.comment=$"{_comment_music}";
|
|
|
}
|
|
|
- }
|
|
|
+ if (x.subjectId.Equals("subject_painting"))
|
|
|
+ {
|
|
|
+ x.comment = $"{_comment_painting}";
|
|
|
+ }
|
|
|
+ });
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).UpsertItemAsync(item, new PartitionKey($"ArtResult-{_artId}"));
|
|
|
+ artResults.Add(item);
|
|
|
}
|
|
|
- foreach (var item in infos)
|
|
|
+ if (artResults.IsNotEmpty())
|
|
|
{
|
|
|
- if (item.classes.Count == 0)
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
-
|
|
|
- var studentIds = artResults.Where(c => c.artId.Equals(item.id)).Select(z => z.studentId).ToList();
|
|
|
- await ArtService.GenArtPDF(studentIds, item.id, item.school, head_lang, _serviceBus, _configuration);
|
|
|
- await Task.Delay(30000);
|
|
|
- }
|
|
|
+ var data = await GenPDFService.GenArtStudentPdf(_azureRedis, _azureCosmos, _coreAPIHttpService, _dingDing, _azureStorage, _configuration, artResults.Select(x=>x.studentId).ToList(), $"{_artId}", $"{_schoolId}", $"{head_lang}");
|
|
|
+ return Ok(new { code = 0, dataFile = data.studentPdfs.Select(x => new { x.blob, x.blobFullUrl }) });
|
|
|
+ }
|
|
|
+ return Ok(new { code = 1, msg = "没有找到学生数据" });
|
|
|
+ }
|
|
|
+
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ //[AuthToken(Roles = "teacher,admin")]
|
|
|
+ [HttpPost("get-pdf-data")]
|
|
|
+ public async Task<IActionResult> GetPdfData(JsonElement json)
|
|
|
+ {
|
|
|
+ if (!json.TryGetProperty("artId", out JsonElement _artId))
|
|
|
+ {
|
|
|
+ return BadRequest();
|
|
|
+ }
|
|
|
+ if (!json.TryGetProperty("schoolId", out JsonElement _schoolId))
|
|
|
+ {
|
|
|
+ return BadRequest();
|
|
|
+ }
|
|
|
+ List<string> studentIds = new List<string>();
|
|
|
+ if (json.TryGetProperty("studentIds", out JsonElement _studentIds) && _studentIds.ValueKind.Equals(JsonValueKind.Array))
|
|
|
+ {
|
|
|
+ studentIds = _studentIds.ToObject<List<string>>();
|
|
|
+ }
|
|
|
+ string head_lang = string.Empty;
|
|
|
+ if (HttpContext.Request.Headers.TryGetValue("lang", out var _lang))
|
|
|
+ {
|
|
|
+ head_lang = $"{_lang}";
|
|
|
+ }
|
|
|
+ if (string.IsNullOrWhiteSpace(head_lang))
|
|
|
+ {
|
|
|
+ head_lang = _option.Location.Contains("China") ? "zh-cn" : "en-us";
|
|
|
}
|
|
|
- return Ok(new { code = 0, msg = "加入PDF报告生成队列中。", schools= infos.Select(x=>x.school)});
|
|
|
+ var data = await GenPDFService.GenArtStudentPdf(_azureRedis, _azureCosmos, _coreAPIHttpService, _dingDing, _azureStorage, _configuration, studentIds,$"{_artId}",$"{_schoolId}",$"{head_lang}");
|
|
|
+ return Ok(new {code=0, dataFiles= data.studentPdfs.Select(x=>new { x.blob,x.blobFullUrl}) });
|
|
|
}
|
|
|
|
|
|
/// <summary>
|