|
@@ -387,102 +387,104 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
|
|
+ jsonElement.TryGetProperty("tmdId", out JsonElement assistId);
|
|
jsonElement.TryGetProperty("schoolCode", out JsonElement _schoolCode);
|
|
jsonElement.TryGetProperty("schoolCode", out JsonElement _schoolCode);
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
- List<SchoolAssist> schoolAssists = new();
|
|
|
|
|
|
+ List<AssistSchool> schoolAssists = new();
|
|
//StringBuilder stringBuilder = new StringBuilder("select value(c) from c");
|
|
//StringBuilder stringBuilder = new StringBuilder("select value(c) from c");
|
|
- StringBuilder stringBuilder = new StringBuilder("select c.id,c.code,c.schoolCode,c.name,c.region,c.province,c.city,c.dist,c.size,c.address,c.picture,c.type,c.scale,c.areaId,c.standard from c");
|
|
|
|
|
|
+ StringBuilder stringBuilder = new("select c.id,c.code,c.schoolCode,c.name,c.region,c.province,c.city,c.dist,c.size,c.address,c.picture,c.type,c.scale,c.areaId,c.standard from c");
|
|
|
|
|
|
if (!string.IsNullOrEmpty($"{_schoolCode}"))
|
|
if (!string.IsNullOrEmpty($"{_schoolCode}"))
|
|
{
|
|
{
|
|
stringBuilder.Append($" where c.id='{_schoolCode}'");
|
|
stringBuilder.Append($" where c.id='{_schoolCode}'");
|
|
}
|
|
}
|
|
|
|
|
|
- //await foreach (var itemSchool in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: stringBuilder.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
|
|
- //{
|
|
|
|
- // SchoolAssist schoolAssist = new()
|
|
|
|
- // {
|
|
|
|
- // id = itemSchool.id,
|
|
|
|
- // code = itemSchool.code,
|
|
|
|
- // schoolCode = itemSchool.schoolCode,
|
|
|
|
- // name = itemSchool.name,
|
|
|
|
- // region = itemSchool.region,
|
|
|
|
- // province = itemSchool.province,
|
|
|
|
- // city = itemSchool.city,
|
|
|
|
- // dist = itemSchool.dist,
|
|
|
|
- // size = itemSchool.size,
|
|
|
|
- // address = itemSchool.address,
|
|
|
|
- // picture = itemSchool.picture,
|
|
|
|
- // type = itemSchool.type,
|
|
|
|
- // scale = itemSchool.scale,
|
|
|
|
- // areaId = itemSchool.areaId,
|
|
|
|
- // standard = itemSchool.standard
|
|
|
|
- // };
|
|
|
|
-
|
|
|
|
- // var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(itemSchool.id, new PartitionKey("ProductSum"));
|
|
|
|
- // if (response.Status == 200)
|
|
|
|
- // {
|
|
|
|
- // using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
|
- // schoolAssist.serial = json.RootElement.GetProperty("serial").GetArrayLength();
|
|
|
|
- // schoolAssist.service = json.RootElement.GetProperty("service").GetArrayLength();
|
|
|
|
- // schoolAssist.hard = json.RootElement.GetProperty("hard").GetArrayLength();
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- // schoolAssist.assists = await CommonFind.FindSchoolRoles(cosmosClient, itemSchool.id, "assist");
|
|
|
|
-
|
|
|
|
- // schoolAssists.Add(schoolAssist);
|
|
|
|
- //}
|
|
|
|
- //return Ok(new { state = 200, schoolAssists });
|
|
|
|
-
|
|
|
|
- await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: stringBuilder.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
|
|
|
|
+ List<string> schools = new();
|
|
|
|
+ if (!string.IsNullOrEmpty($"{assistId}"))
|
|
|
|
+ schools = await CommonFind.FindSchoolIds(cosmosClient, $"{assistId}");
|
|
|
|
+ if (schools.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ schoolAssists = await CommonFind.FindAssistSchools(cosmosClient, schools);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
{
|
|
{
|
|
- using var jsonSchool = await JsonDocument.ParseAsync(itemSchool.ContentStream);
|
|
|
|
- foreach (var objSchool in jsonSchool.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
|
|
|
+ await foreach (var itemSchool in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<AssistSchool>(queryText: stringBuilder.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
{
|
|
{
|
|
- var schoolId = objSchool.GetProperty("id").GetString();
|
|
|
|
- SchoolAssist schoolAssist = new()
|
|
|
|
- {
|
|
|
|
- id = schoolId,
|
|
|
|
- code = objSchool.GetProperty("code").GetString(),
|
|
|
|
- schoolCode = objSchool.GetProperty("schoolCode").GetString(),
|
|
|
|
- name = objSchool.GetProperty("name").GetString(),
|
|
|
|
- region = objSchool.GetProperty("region").GetString(),
|
|
|
|
- province = objSchool.GetProperty("province").GetString(),
|
|
|
|
- city = objSchool.GetProperty("city").GetString(),
|
|
|
|
- dist = objSchool.GetProperty("dist").GetString(),
|
|
|
|
- size = objSchool.GetProperty("size").GetInt32(),
|
|
|
|
- address = objSchool.GetProperty("address").GetString(),
|
|
|
|
- picture = objSchool.GetProperty("picture").GetString(),
|
|
|
|
- type = objSchool.GetProperty("type").GetInt32(),
|
|
|
|
- //scale = objSchool.GetProperty("scale").GetInt32(),
|
|
|
|
- areaId = objSchool.GetProperty("areaId").GetString(),
|
|
|
|
- standard = objSchool.GetProperty("standard").GetString(),
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- try { schoolAssist.scale = objSchool.GetProperty("scale").GetInt32(); }
|
|
|
|
- catch { schoolAssist.scale = 0; }
|
|
|
|
|
|
+ schoolAssists.Add(itemSchool);
|
|
|
|
+ }
|
|
|
|
|
|
- //var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(schoolId, new PartitionKey("ProductSum"));
|
|
|
|
- //if (response.Status == 200)
|
|
|
|
- //{
|
|
|
|
- // using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
|
- // schoolAssist.serial = json.RootElement.GetProperty("serial").GetArrayLength();
|
|
|
|
- // schoolAssist.service = json.RootElement.GetProperty("service").GetArrayLength();
|
|
|
|
- // schoolAssist.hard = json.RootElement.GetProperty("hard").GetArrayLength();
|
|
|
|
- //}
|
|
|
|
|
|
+ schoolAssists.ForEach(async school =>
|
|
|
|
+ {
|
|
|
|
+ var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(school.id, new PartitionKey("ProductSum"));
|
|
|
|
+ if (response.Status == 200)
|
|
|
|
+ {
|
|
|
|
+ using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
|
+ school.serial = json.RootElement.GetProperty("serial").GetArrayLength();
|
|
|
|
+ school.service = json.RootElement.GetProperty("service").GetArrayLength();
|
|
|
|
+ school.hard = json.RootElement.GetProperty("hard").GetArrayLength();
|
|
|
|
+ }
|
|
|
|
|
|
- //schoolAssist.assists = await CommonFind.FindSchoolRoles(cosmosClient, schoolId, "assist");
|
|
|
|
- schoolAssists.Add(schoolAssist);
|
|
|
|
- }
|
|
|
|
|
|
+ school.assists = await CommonFind.FindSchoolRoles(cosmosClient, school.id, "assist");
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
- List<SchoolAssist> tempSchoolAssists = new();
|
|
|
|
- await foreach (var temp in GetSchools(cosmosClient, schoolAssists))
|
|
|
|
- {
|
|
|
|
- tempSchoolAssists.AddRange(temp);
|
|
|
|
- }
|
|
|
|
|
|
+ return Ok(new { state = 200, schoolAssists });
|
|
|
|
|
|
- return Ok(new { state = 200, schoolAssists = tempSchoolAssists });
|
|
|
|
|
|
+ //if (schools.Count > 0)
|
|
|
|
+ //{
|
|
|
|
+ // schoolAssists = await CommonFind.FindAssistSchools(cosmosClient, schools);
|
|
|
|
+ //}
|
|
|
|
+ //else
|
|
|
|
+ //{
|
|
|
|
+ // await foreach (var itemSchool in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: stringBuilder.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
|
|
+ // {
|
|
|
|
+ // using var jsonSchool = await JsonDocument.ParseAsync(itemSchool.ContentStream);
|
|
|
|
+ // foreach (var objSchool in jsonSchool.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
|
+ // {
|
|
|
|
+ // var schoolId = objSchool.GetProperty("id").GetString();
|
|
|
|
+ // AssistSchool schoolAssist = new()
|
|
|
|
+ // {
|
|
|
|
+ // id = schoolId,
|
|
|
|
+ // code = objSchool.GetProperty("code").GetString(),
|
|
|
|
+ // schoolCode = objSchool.GetProperty("schoolCode").GetString(),
|
|
|
|
+ // name = objSchool.GetProperty("name").GetString(),
|
|
|
|
+ // region = objSchool.GetProperty("region").GetString(),
|
|
|
|
+ // province = objSchool.GetProperty("province").GetString(),
|
|
|
|
+ // city = objSchool.GetProperty("city").GetString(),
|
|
|
|
+ // dist = objSchool.GetProperty("dist").GetString(),
|
|
|
|
+ // size = objSchool.GetProperty("size").GetInt32(),
|
|
|
|
+ // address = objSchool.GetProperty("address").GetString(),
|
|
|
|
+ // picture = objSchool.GetProperty("picture").GetString(),
|
|
|
|
+ // type = objSchool.GetProperty("type").GetInt32(),
|
|
|
|
+ // //scale = objSchool.GetProperty("scale").GetInt32(),
|
|
|
|
+ // areaId = objSchool.GetProperty("areaId").GetString(),
|
|
|
|
+ // standard = objSchool.GetProperty("standard").GetString(),
|
|
|
|
+ // };
|
|
|
|
+
|
|
|
|
+ // try { schoolAssist.scale = objSchool.GetProperty("scale").GetInt32(); }
|
|
|
|
+ // catch { schoolAssist.scale = 0; }
|
|
|
|
+
|
|
|
|
+ // //var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(schoolId, new PartitionKey("ProductSum"));
|
|
|
|
+ // //if (response.Status == 200)
|
|
|
|
+ // //{
|
|
|
|
+ // // using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
|
|
+ // // schoolAssist.serial = json.RootElement.GetProperty("serial").GetArrayLength();
|
|
|
|
+ // // schoolAssist.service = json.RootElement.GetProperty("service").GetArrayLength();
|
|
|
|
+ // // schoolAssist.hard = json.RootElement.GetProperty("hard").GetArrayLength();
|
|
|
|
+ // //}
|
|
|
|
+
|
|
|
|
+ // //schoolAssist.assists = await CommonFind.FindSchoolRoles(cosmosClient, schoolId, "assist");
|
|
|
|
+ // schoolAssists.Add(schoolAssist);
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
|
|
+ //List<AssistSchool> tempSchoolAssists = new();
|
|
|
|
+ //await foreach (var temp in GetSchools(cosmosClient, schoolAssists))
|
|
|
|
+ //{
|
|
|
|
+ // tempSchoolAssists.AddRange(temp);
|
|
|
|
+ //}
|
|
|
|
+
|
|
|
|
+ //return Ok(new { state = 200, schoolAssists = tempSchoolAssists });
|
|
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
@@ -498,9 +500,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
/// <param name="cosmosClient"></param>
|
|
/// <param name="cosmosClient"></param>
|
|
/// <param name="schoolAssists"></param>
|
|
/// <param name="schoolAssists"></param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- private async IAsyncEnumerable<List<SchoolAssist>> GetSchools(CosmosClient cosmosClient,List<SchoolAssist> schoolAssists)
|
|
|
|
|
|
+ private async IAsyncEnumerable<List<AssistSchool>> GetSchools(CosmosClient cosmosClient,List<AssistSchool> schoolAssists)
|
|
{
|
|
{
|
|
- List<SchoolAssist> tempSchoolAssists = new();
|
|
|
|
|
|
+ List<AssistSchool> tempSchoolAssists = new();
|
|
foreach (var temp in schoolAssists)
|
|
foreach (var temp in schoolAssists)
|
|
{
|
|
{
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(temp.id, new PartitionKey("ProductSum"));
|
|
var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(temp.id, new PartitionKey("ProductSum"));
|
|
@@ -846,7 +848,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
public async Task<IActionResult> GetSchools(JsonElement jsonElement)
|
|
public async Task<IActionResult> GetSchools(JsonElement jsonElement)
|
|
{
|
|
{
|
|
//List<School> schools = new List<School>();
|
|
//List<School> schools = new List<School>();
|
|
- List<SchoolAssist> schoolAssists = new List<SchoolAssist>();
|
|
|
|
|
|
+ List<AssistSchool> schoolAssists = new List<AssistSchool>();
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
if (!jsonElement.TryGetProperty("endPosition", out JsonElement endPosition)) return BadRequest();
|
|
if (!jsonElement.TryGetProperty("endPosition", out JsonElement endPosition)) return BadRequest();
|
|
if (!jsonElement.TryGetProperty("pageSize", out JsonElement pageSize)) return BadRequest();
|
|
if (!jsonElement.TryGetProperty("pageSize", out JsonElement pageSize)) return BadRequest();
|
|
@@ -855,7 +857,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
|
|
|
await foreach (var itemSchool in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
await foreach (var itemSchool in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: sqltxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
{
|
|
{
|
|
- SchoolAssist schoolAssist = new SchoolAssist()
|
|
|
|
|
|
+ AssistSchool schoolAssist = new()
|
|
{
|
|
{
|
|
id = itemSchool.id,
|
|
id = itemSchool.id,
|
|
code = itemSchool.code,
|
|
code = itemSchool.code,
|
|
@@ -1011,32 +1013,32 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
|
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
- public class SchoolAssist
|
|
|
|
- {
|
|
|
|
- public string id { get; set; }
|
|
|
|
- public string code { get; set; }
|
|
|
|
- public string schoolCode { get; set; }
|
|
|
|
- public string name { get; set; }
|
|
|
|
- public string region { get; set; }
|
|
|
|
- public string province { get; set; }
|
|
|
|
- public string city { get; set; }
|
|
|
|
- public string dist { get; set; }
|
|
|
|
- public int size { get; set; }
|
|
|
|
- public string address { get; set; }
|
|
|
|
- public string picture { get; set; }
|
|
|
|
- public int type { get; set; }
|
|
|
|
- public int scale { get; set; }
|
|
|
|
- public string standard { get; set; }
|
|
|
|
- public string areaId { get; set; }
|
|
|
|
- public List<SchoolTeacherRoles> assists { get; set; }
|
|
|
|
- public int serial { get; set; } //软体
|
|
|
|
- public int service { get; set; } //服务
|
|
|
|
- public int hard { get; set; } //硬体
|
|
|
|
- //public List<SchoolProductSumData> serial { get; set; } //软体
|
|
|
|
- //public List<SchoolProductSumData> service { get; set; } //服务
|
|
|
|
- //public List<SchoolProductSumDataHard> hard { get; set; } //硬体
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
+ //public class SchoolAssist
|
|
|
|
+ //{
|
|
|
|
+ // public string id { get; set; }
|
|
|
|
+ // public string code { get; set; }
|
|
|
|
+ // public string schoolCode { get; set; }
|
|
|
|
+ // public string name { get; set; }
|
|
|
|
+ // public string region { get; set; }
|
|
|
|
+ // public string province { get; set; }
|
|
|
|
+ // public string city { get; set; }
|
|
|
|
+ // public string dist { get; set; }
|
|
|
|
+ // public int size { get; set; }
|
|
|
|
+ // public string address { get; set; }
|
|
|
|
+ // public string picture { get; set; }
|
|
|
|
+ // public int type { get; set; }
|
|
|
|
+ // public int scale { get; set; }
|
|
|
|
+ // public string standard { get; set; }
|
|
|
|
+ // public string areaId { get; set; }
|
|
|
|
+ // public List<SchoolTeacherRoles> assists { get; set; }
|
|
|
|
+ // public int serial { get; set; } //软体
|
|
|
|
+ // public int service { get; set; } //服务
|
|
|
|
+ // public int hard { get; set; } //硬体
|
|
|
|
+ // //public List<SchoolProductSumData> serial { get; set; } //软体
|
|
|
|
+ // //public List<SchoolProductSumData> service { get; set; } //服务
|
|
|
|
+ // //public List<SchoolProductSumDataHard> hard { get; set; } //硬体
|
|
|
|
+
|
|
|
|
+ //}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|