|
@@ -6,8 +6,10 @@ using HTEXLib.COMM.Helpers;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
+using Microsoft.Azure.Amqp.Framing;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.Options;
|
|
using Microsoft.Extensions.Options;
|
|
|
|
+using StackExchange.Redis;
|
|
using System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations;
|
|
@@ -66,6 +68,58 @@ namespace TEAMModelOS.Controllers
|
|
_converter = converter;
|
|
_converter = converter;
|
|
_httpTrigger = httpTrigger;
|
|
_httpTrigger = httpTrigger;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 轮询获取报告生成进度。
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="request"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
|
+ [AuthToken(Roles = "teacher,admin")]
|
|
|
|
+ [HttpPost("gen-pdf-process")]
|
|
|
|
+ //[Authorize(Roles = "IES")]
|
|
|
|
+ public async Task<IActionResult> GenPDFProcess(JsonElement request) {
|
|
|
|
+
|
|
|
|
+ if (!request.TryGetProperty("artId", out JsonElement _artId))
|
|
|
|
+ {
|
|
|
|
+ return BadRequest();
|
|
|
|
+ }
|
|
|
|
+ List<RedisValue> studentIds = new List<RedisValue>();
|
|
|
|
+ if (request.TryGetProperty("studentIds", out JsonElement _studentIds) && _studentIds.ValueKind.Equals(JsonValueKind.Array))
|
|
|
|
+ {
|
|
|
|
+ var studentIdS = _studentIds.ToObject<List<string>>();
|
|
|
|
+ studentIdS.ForEach(z => { studentIds.Add(z); }) ;
|
|
|
|
+ }
|
|
|
|
+ string key = $"ArtPDF:{_artId}";
|
|
|
|
+ List<StudentArtResult> results= new List<StudentArtResult>();
|
|
|
|
+ if (studentIds.IsNotEmpty())
|
|
|
|
+ {
|
|
|
|
+ var values = _azureRedis.GetRedisClient(8).HashGet(key, studentIds.ToArray());
|
|
|
|
+ if (values != null)
|
|
|
|
+ {
|
|
|
|
+ foreach (var rcd in values)
|
|
|
|
+ {
|
|
|
|
+ var value = rcd.ToString().ToObject<StudentArtResult>();
|
|
|
|
+ results.Add(value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ var values = _azureRedis.GetRedisClient(8).HashGetAll(key);
|
|
|
|
+ if (values != null)
|
|
|
|
+ {
|
|
|
|
+ foreach (var rcd in values)
|
|
|
|
+ {
|
|
|
|
+ var value = rcd.Value.ToString().ToObject<StudentArtResult>();
|
|
|
|
+ results.Add(value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ var finish = results.Where(z => z.pdf != null && z.pdf.prime == true);
|
|
|
|
+ var finishData = finish.Select(z => new { z.studentId, z.artId, z.studentName, z.pdf.url, z.pdf.blob, z.pdf.createTime });
|
|
|
|
+ return Ok(new { total= results.Count ,finishCount= finish.Count(), finishData = finishData });
|
|
|
|
+ }
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
///
|
|
///
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -107,7 +161,7 @@ namespace TEAMModelOS.Controllers
|
|
{
|
|
{
|
|
studentIds = _studentIds.ToObject<List<string>>();
|
|
studentIds = _studentIds.ToObject<List<string>>();
|
|
}
|
|
}
|
|
- await ArtService.GenArtPDF(studentIds, $"{_artId}", $"{_schoolId}", head_lang, _azureCosmos, _environment, _coreAPIHttpService, _dingDing, _serviceBus, _configuration);
|
|
|
|
|
|
+ await ArtService.GenArtPDF(studentIds, $"{_artId}", $"{_schoolId}", head_lang, _serviceBus, _configuration);
|
|
return Ok(new {code=0,msg="加入PDF报告生成队列中。" });
|
|
return Ok(new {code=0,msg="加入PDF报告生成队列中。" });
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -388,7 +442,7 @@ namespace TEAMModelOS.Controllers
|
|
await client.GetContainer(Constant.TEAMModelOS, Constant.Student).ReplaceItemAsync(rs, rs.id, new PartitionKey(rs.code));
|
|
await client.GetContainer(Constant.TEAMModelOS, Constant.Student).ReplaceItemAsync(rs, rs.id, new PartitionKey(rs.code));
|
|
}
|
|
}
|
|
if (artResults.Any()) {
|
|
if (artResults.Any()) {
|
|
- await ArtService.GenArtPDF(artResults.Select(z=>z.studentId).ToList(), $"{_artId}", $"{school}", head_lang, _azureCosmos, _environment, _coreAPIHttpService, _dingDing, _serviceBus, _configuration);
|
|
|
|
|
|
+ await ArtService.GenArtPDF(artResults.Select(z=>z.studentId).ToList(), $"{_artId}", $"{school}", head_lang, _serviceBus, _configuration);
|
|
}
|
|
}
|
|
return Ok(new { results = studentArtResults, status = 1 });
|
|
return Ok(new { results = studentArtResults, status = 1 });
|
|
}
|
|
}
|