|
@@ -1,9 +1,12 @@
|
|
|
using Azure.Cosmos;
|
|
|
+using Azure.Storage.Blobs;
|
|
|
+using Azure.Storage.Blobs.Models;
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
using Microsoft.Extensions.Options;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.IO;
|
|
|
using System.Text;
|
|
|
using System.Text.Json;
|
|
|
using System.Threading.Tasks;
|
|
@@ -49,7 +52,7 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
public async Task<IActionResult> GetList(JsonElement jsonElement)
|
|
|
{
|
|
|
if (!jsonElement.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
|
- jsonElement.TryGetProperty("scope", out JsonElement scope);
|
|
|
+ jsonElement.TryGetProperty("scope", out JsonElement _scope);
|
|
|
Dictionary<string, object> dic = new();
|
|
|
if (jsonElement.TryGetProperty("periodId", out JsonElement periodId))
|
|
|
dic.Add("periodId", periodId);
|
|
@@ -69,7 +72,10 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
else
|
|
|
dic.Add("@ASC", "createTime");
|
|
|
}
|
|
|
-
|
|
|
+ string scope = "school";
|
|
|
+ if (string.IsNullOrEmpty($"{_scope}"))
|
|
|
+ scope = $"{_scope}";
|
|
|
+
|
|
|
var cosmosClinet = _azureCosmos.GetCosmosClient();
|
|
|
StringBuilder sql = new("select value(c) from c ");
|
|
|
AzureCosmosQuery cosmosDbQuery = SQLHelper.GetSQL(dic, sql);
|
|
@@ -82,25 +88,6 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
papers.Add(item);
|
|
|
}
|
|
|
}
|
|
|
- else if (scope.ToString().Equals("private"))
|
|
|
- {
|
|
|
- await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Paper>(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{code}") }))
|
|
|
- {
|
|
|
- papers.Add(item);
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<Paper>(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{code}") }))
|
|
|
- {
|
|
|
- papers.Add(item);
|
|
|
- }
|
|
|
- await foreach (var item in cosmosClinet.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Paper>(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{code}") }))
|
|
|
- {
|
|
|
- papers.Add(item);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
return Ok(new { state = RespondCode.Ok,cnt = papers.Count, papers });
|
|
|
}
|
|
|
|
|
@@ -121,13 +108,44 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
foreach (var cItem in papers)
|
|
|
{
|
|
|
Paper paper = await cosmosClinet.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<Paper>(cItem.oldId, new PartitionKey($"Paper-{cItem.oldSc}"));
|
|
|
-
|
|
|
+ paper.periodId = cItem.newPrdId;
|
|
|
+ paper.subjectId = cItem.newSubId;
|
|
|
+ paper.subjectName = cItem.newSubName;
|
|
|
+ paper.gradeIds = cItem.newGrId;
|
|
|
+ paper.code = $"Paper-{cItem.newSc}";
|
|
|
+
|
|
|
+ var resState = await cosmosClinet.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(paper.id, new PartitionKey(paper.code));
|
|
|
+ if (resState.Status == 200)
|
|
|
+ {
|
|
|
+ paper.id = Guid.NewGuid().ToString();
|
|
|
+ }
|
|
|
+
|
|
|
+ //paper = await cosmosClinet.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<Paper>(paper, new PartitionKey(paper.code));
|
|
|
+
|
|
|
+
|
|
|
+ var oldBobCilent = _azureStorage.GetBlobContainerClient(containerName: $"{cItem.oldSc}");
|
|
|
+ var newBobCilent = _azureStorage.GetBlobContainerClient(containerName: $"{cItem.newSc}");
|
|
|
+
|
|
|
+ string blobUrl = $"{paper.blob}";
|
|
|
+
|
|
|
+ await foreach (BlobItem blobItem in oldBobCilent.GetBlobsAsync(BlobTraits.None, BlobStates.None, blobUrl))
|
|
|
+ {
|
|
|
+ if (blobItem.Name.EndsWith(".json"))
|
|
|
+ {
|
|
|
+ BlobClient tempClient = oldBobCilent.GetBlobClient(blobItem.Name);
|
|
|
+ using (var meomoryStream = new MemoryStream())
|
|
|
+ {
|
|
|
+ var response = oldBobCilent.GetBlobClient($"{blobItem.Name}").DownloadTo(meomoryStream);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
return Ok(new { state = RespondCode.Ok});
|
|
|
}
|
|
|
|
|
|
+
|
|
|
|
|
|
/// <summary>
|
|
|
/// 查询试卷的数量统计集合
|
|
@@ -468,13 +486,11 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
{
|
|
|
public string oldId { get; set; }
|
|
|
public string oldSc { get; set; }
|
|
|
- public string newId { get; set; }
|
|
|
public string newSc { get; set; }
|
|
|
public string newPrdId { get; set; }
|
|
|
public string newSubId { get; set; }
|
|
|
- public string newGrId { get; set; }
|
|
|
- public string isKlogger { get; set; }
|
|
|
-
|
|
|
+ public string newSubName { get; set; }
|
|
|
+ public List<string> newGrId { get; set; }
|
|
|
|
|
|
}
|
|
|
|