|
@@ -1432,11 +1432,32 @@ namespace TEAMModelBI.Controllers.Census
|
|
|
}
|
|
|
|
|
|
//List<string> scId = await CommonFind.FindScIds(cosmosClient, "select value(c.id) from c ", "Base");
|
|
|
-
|
|
|
+ //取得學校BI統計中間件
|
|
|
List<BIRelation> scInfos = new();
|
|
|
+ List<string> schIds = new();
|
|
|
await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<BIRelation>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
|
|
|
{
|
|
|
scInfos.Add(item);
|
|
|
+ schIds.Add(item.id);
|
|
|
+ }
|
|
|
+ //取得學校產品列表
|
|
|
+ if(schIds.Count > 0)
|
|
|
+ {
|
|
|
+ string schIdListStr = JsonSerializer.Serialize(schIds);
|
|
|
+ StringBuilder sqlPSum = new($"SELECT * FROM c WHERE ARRAY_CONTAINS({schIdListStr}, c.id, true)");
|
|
|
+ await foreach (SchoolProductSum item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<SchoolProductSum>(queryText: sqlPSum.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ProductSum") }))
|
|
|
+ {
|
|
|
+ List<string> serialProdList = item.serial.Select(s => s.prodCode).ToList();
|
|
|
+ List<string> serviceProdList = item.service.Select(s => s.prodCode).ToList();
|
|
|
+ List<string> hardProdList = item.hard.Select(s => s.prodCode).ToList();
|
|
|
+ BIRelation scInfo = scInfos.Where(s => s.id.Equals(item.id)).FirstOrDefault();
|
|
|
+ if(scInfo != null)
|
|
|
+ {
|
|
|
+ scInfo.serial = serialProdList;
|
|
|
+ scInfo.service = serviceProdList;
|
|
|
+ scInfo.hard = hardProdList;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//虛擬學校
|