|
@@ -684,93 +684,25 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 学校信息
|
|
|
+ /// 学校信息中间件查询接口
|
|
|
/// </summary>
|
|
|
/// <param name="jsonElement"></param>
|
|
|
/// <returns></returns>
|
|
|
[ProducesDefaultResponseType]
|
|
|
[HttpPost("get-scinfos")]
|
|
|
- public async Task<IActionResult> GetScInfos(JsonElement jsonElement)
|
|
|
+ public async Task<IActionResult> GetScInfos(JsonElement jsonElement)
|
|
|
{
|
|
|
- try
|
|
|
- {
|
|
|
- var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
- List<string> scId = await CommonFind.FindScIds(cosmosClient, "select value(c.id) from c ", "Base");
|
|
|
- List<BIRelation> scInfos = new();
|
|
|
- foreach (var itemId in scId)
|
|
|
- {
|
|
|
- BIRelation bIRelation = null;
|
|
|
- var resRel = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(itemId, new PartitionKey("BIRel"));
|
|
|
- if (resRel.Status == 200)
|
|
|
- {
|
|
|
- using var fileJson = await JsonDocument.ParseAsync(resRel.ContentStream);
|
|
|
- bIRelation = fileJson.ToObject<BIRelation>();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- ScBaseInfo scBaseInfo = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<ScBaseInfo>(itemId, new PartitionKey("Base"));
|
|
|
- string areaName = null;
|
|
|
- if (!string.IsNullOrEmpty(scBaseInfo.areaId))
|
|
|
- {
|
|
|
- await foreach (var itemName in cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<string>(queryText: $"select value(c.name) from c where c.pk='Area' and c.id='{scBaseInfo.areaId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base-Area") }))
|
|
|
- {
|
|
|
- areaName = itemName;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- bIRelation = new BIRelation()
|
|
|
- {
|
|
|
- id = scBaseInfo.id,
|
|
|
- name = scBaseInfo.name,
|
|
|
- picture = scBaseInfo.picture,
|
|
|
- size = scBaseInfo.size,
|
|
|
- createDate = scBaseInfo.createTime,
|
|
|
- region = scBaseInfo.region,
|
|
|
- province = scBaseInfo.province,
|
|
|
- city = scBaseInfo.city,
|
|
|
- dist = scBaseInfo.dist,
|
|
|
- address = scBaseInfo.address,
|
|
|
- areaId = scBaseInfo.areaId,
|
|
|
- scale = scBaseInfo.scale,
|
|
|
- areaName = areaName,
|
|
|
- upDate = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
|
|
|
- };
|
|
|
-
|
|
|
- var response = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(itemId, new PartitionKey("ProductSum"));
|
|
|
- if (response.Status == 200)
|
|
|
- {
|
|
|
- using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
- if (json.RootElement.TryGetProperty("serial", out JsonElement serial) && !serial.ValueKind.Equals(JsonValueKind.Null))
|
|
|
- {
|
|
|
- List<string> serials = serial.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
|
|
|
- bIRelation.serial = serials;
|
|
|
- }
|
|
|
- if (json.RootElement.TryGetProperty("service", out JsonElement service) && !service.ValueKind.Equals(JsonValueKind.Null))
|
|
|
- {
|
|
|
- List<string> services = service.ToObject<List<SchoolProductSumData>>().Select(x => x.prodCode).ToList();
|
|
|
- bIRelation.service = services;
|
|
|
- }
|
|
|
- if (json.RootElement.TryGetProperty("hard", out JsonElement hard) && !hard.ValueKind.Equals(JsonValueKind.Null))
|
|
|
- {
|
|
|
- List<string> hards = hard.ToObject<List<SchoolProductSumDataHard>>().Select(x => x.prodCode).ToList();
|
|
|
- bIRelation.hard = hards;
|
|
|
- }
|
|
|
- }
|
|
|
- bIRelation = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<BIRelation>(bIRelation, new PartitionKey("BIRel"));
|
|
|
- }
|
|
|
-
|
|
|
- scInfos.Add(bIRelation);
|
|
|
- }
|
|
|
+ var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
+ List<string> scId = await CommonFind.FindScIds(cosmosClient, "select value(c.id) from c ", "Base");
|
|
|
|
|
|
- return Ok(new { state = RespondCode.Ok, cnt = scId.Count, scInfos });
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
+ List<BIRelation> scInfos = new();
|
|
|
+ await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<BIRelation>(queryText:$"select value(c) from c",requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
|
|
|
{
|
|
|
- await _dingDing.SendBotMsg($"BI,{_option.Location},/school/get-scinfos \n{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
- return BadRequest();
|
|
|
+ scInfos.Add(item);
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
+ return Ok(new { state = RespondCode.Ok, allCnt = scId.Count, scInfos });
|
|
|
+ }
|
|
|
|
|
|
/// <summary>
|
|
|
/// 依据Id查询School容器 数据管理工具——查询工具
|