|
@@ -280,25 +280,29 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
sticsDist.distName = itemStandrds.distName;
|
|
|
sticsDist.standard = itemStandrds.standard;
|
|
|
|
|
|
- List<string> schoolIds = new List<string>();
|
|
|
- int schoolCount = 0;
|
|
|
+ //
|
|
|
+ string sqlTxt = $"select c.id from c where c.standard='{itemStandrds.standard}'";
|
|
|
+ List<string> schoolIds = await CommonFind.FindSchoolIds(cosmosClient, sqlTxt, "Base");
|
|
|
|
|
|
- await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.standard='{itemStandrds.standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
- {
|
|
|
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
- {
|
|
|
- var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
- while (accounts.MoveNext())
|
|
|
- {
|
|
|
- JsonElement account = accounts.Current;
|
|
|
- schoolIds.Add(account.GetProperty("id").GetString());
|
|
|
- schoolCount += 1;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ //List<string> schoolIds = new List<string>();
|
|
|
+ //int schoolCount = 0;
|
|
|
|
|
|
- sticsDist.schoolCount = schoolCount;
|
|
|
+ //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.standard='{itemStandrds.standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
+ //{
|
|
|
+ // using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ // {
|
|
|
+ // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
+ // while (accounts.MoveNext())
|
|
|
+ // {
|
|
|
+ // JsonElement account = accounts.Current;
|
|
|
+ // schoolIds.Add(account.GetProperty("id").GetString());
|
|
|
+ // schoolCount += 1;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+
|
|
|
+ sticsDist.schoolCount = schoolIds.Count;
|
|
|
|
|
|
int teacherCount = 0; //教师数量
|
|
|
int studentCount = 0; //学生数量
|
|
@@ -309,38 +313,44 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
//查询学校下面的教师人数
|
|
|
foreach (var itemSchool in schoolIds)
|
|
|
{
|
|
|
- string sqlTeacherTxt = $"select distinct value(c) from c join a1 in c.schools where a1.schoolId='{itemSchool}'";
|
|
|
//查询全部教师人数
|
|
|
- await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: sqlTeacherTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
- {
|
|
|
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
- {
|
|
|
- var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
- while (accounts.MoveNext())
|
|
|
- {
|
|
|
- //JsonElement account = accounts.Current;
|
|
|
- //teacherIds.Add(account.GetProperty("id").GetString());
|
|
|
- teacherCount += 1;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ string sqlT = $"select count(c.id) as totals from c join a1 in c.schools where a1.schoolId='{itemSchool}'";
|
|
|
+ teacherCount += await CommonFind.FindTotals(cosmosClient, sqlT, "Teacher","Base");
|
|
|
+
|
|
|
+ //string sqlTeacherTxt = $"select distinct value(c) from c join a1 in c.schools where a1.schoolId='{itemSchool}'";
|
|
|
+ //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: sqlTeacherTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
+ //{
|
|
|
+ // using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ // {
|
|
|
+ // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
+ // while (accounts.MoveNext())
|
|
|
+ // {
|
|
|
+ // //JsonElement account = accounts.Current;
|
|
|
+ // //teacherIds.Add(account.GetProperty("id").GetString());
|
|
|
+ // teacherCount += 1;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
|
|
|
//查询全部学生人数
|
|
|
- await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{itemSchool}") }))
|
|
|
- {
|
|
|
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
- {
|
|
|
- var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
- while (accounts.MoveNext())
|
|
|
- {
|
|
|
- //JsonElement account = accounts.Current;
|
|
|
- //studentIds.Add(account.GetProperty("id").GetString());
|
|
|
- studentCount += 1;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ string sqlS = $"select count(c.id) as totals from c";
|
|
|
+ teacherCount += await CommonFind.FindTotals(cosmosClient, sqlS, "Student", $"Base-{itemSchool}");
|
|
|
+
|
|
|
+ //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{itemSchool}") }))
|
|
|
+ //{
|
|
|
+ // using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ // {
|
|
|
+ // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
+ // while (accounts.MoveNext())
|
|
|
+ // {
|
|
|
+ // //JsonElement account = accounts.Current;
|
|
|
+ // //studentIds.Add(account.GetProperty("id").GetString());
|
|
|
+ // studentCount += 1;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
}
|
|
|
|
|
|
sticsDist.teacherCount = teacherCount;
|
|
@@ -380,63 +390,86 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
areaStandard.Add(item.standard);
|
|
|
}
|
|
|
int citySchoolCount = 0;
|
|
|
- List<string> teacherIds = new List<string>();
|
|
|
- List<string> studentIds = new List<string>();
|
|
|
+ int teachCount = 0;
|
|
|
+ int stuCount = 0;
|
|
|
|
|
|
foreach (var tempSatndard in areaStandard)
|
|
|
{
|
|
|
- List<string> schoolIds = new List<string>();
|
|
|
- await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.standard='{tempSatndard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
- {
|
|
|
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
- {
|
|
|
- var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
- while (accounts.MoveNext())
|
|
|
- {
|
|
|
- JsonElement account = accounts.Current;
|
|
|
- schoolIds.Add(account.GetProperty("id").GetString());
|
|
|
- citySchoolCount += 1;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+ string sqlSchool = $"select c.id from c where c.standard='{tempSatndard}'";
|
|
|
+ List<string> schoolIds = await CommonFind.FindSchoolIds(cosmosClient, sqlSchool, "Base");
|
|
|
+ citySchoolCount += schoolIds.Count;
|
|
|
//查询学校下面的教师人数
|
|
|
foreach (var itemSchool in schoolIds)
|
|
|
{
|
|
|
//查询全部教师人数
|
|
|
- await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"select c.id from c join a1 in c.schools where a1.schoolId='{itemSchool}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
- {
|
|
|
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
- {
|
|
|
- var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
- while (accounts.MoveNext())
|
|
|
- {
|
|
|
- JsonElement account = accounts.Current;
|
|
|
- teacherIds.Add(account.GetProperty("id").GetString());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ string sqlT = $"select count(c.id) as totals from c join a1 in c.schools where a1.schoolId='{itemSchool}'";
|
|
|
+ teachCount += await CommonFind.FindTotals(cosmosClient, sqlT, "Teacher", "Base");
|
|
|
|
|
|
//查询全部学生人数
|
|
|
- await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{itemSchool}") }))
|
|
|
- {
|
|
|
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
- {
|
|
|
- var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
- while (accounts.MoveNext())
|
|
|
- {
|
|
|
- JsonElement account = accounts.Current;
|
|
|
- studentIds.Add(account.GetProperty("id").GetString());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ string sqlS = $"select count(c.id) as totals from c";
|
|
|
+ stuCount += await CommonFind.FindTotals(cosmosClient, sqlS, "Student", $"Base-{itemSchool}");
|
|
|
}
|
|
|
}
|
|
|
+ return Ok(new { state = 200, schoolCount = citySchoolCount, teacherCount = teachCount, tudentCount = stuCount });
|
|
|
+
|
|
|
+
|
|
|
+ //List<string> teacherIds = new List<string>();
|
|
|
+ //List<string> studentIds = new List<string>();
|
|
|
+
|
|
|
+ //foreach (var tempSatndard in areaStandard)
|
|
|
+ //{
|
|
|
+ // List<string> schoolIds = new List<string>();
|
|
|
+ // await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.standard='{tempSatndard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
+ // {
|
|
|
+ // using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ // {
|
|
|
+ // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
+ // while (accounts.MoveNext())
|
|
|
+ // {
|
|
|
+ // JsonElement account = accounts.Current;
|
|
|
+ // schoolIds.Add(account.GetProperty("id").GetString());
|
|
|
+ // citySchoolCount += 1;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ // //查询学校下面的教师人数
|
|
|
+ // foreach (var itemSchool in schoolIds)
|
|
|
+ // {
|
|
|
+ // //查询全部教师人数
|
|
|
+ // await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"select c.id from c join a1 in c.schools where a1.schoolId='{itemSchool}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
+ // {
|
|
|
+ // using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ // {
|
|
|
+ // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
+ // while (accounts.MoveNext())
|
|
|
+ // {
|
|
|
+ // JsonElement account = accounts.Current;
|
|
|
+ // teacherIds.Add(account.GetProperty("id").GetString());
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
|
|
|
- return Ok(new { state = 200, schoolCount = citySchoolCount, teacherCount = teacherIds.Count, tudentCount = studentIds.Count });
|
|
|
+ // //查询全部学生人数
|
|
|
+ // await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{itemSchool}") }))
|
|
|
+ // {
|
|
|
+ // using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ // {
|
|
|
+ // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
+ // while (accounts.MoveNext())
|
|
|
+ // {
|
|
|
+ // JsonElement account = accounts.Current;
|
|
|
+ // studentIds.Add(account.GetProperty("id").GetString());
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+
|
|
|
+ //return Ok(new { state = 200, schoolCount = citySchoolCount, teacherCount = teacherIds.Count, tudentCount = studentIds.Count });
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
@@ -481,57 +514,67 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
foreach (var itemStandard in standards)
|
|
|
{
|
|
|
ProvinceStics tempProvinceStics = new ProvinceStics();
|
|
|
+ //ProvinceStics tempCode = new ProvinceStics();
|
|
|
var tempCode = provinceStics.Find(x => x.provCode == itemStandard.provCode);
|
|
|
if (tempCode != null)
|
|
|
{
|
|
|
- List<string> schoolIds = new List<string>();
|
|
|
- await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.standard='{itemStandard.standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
- {
|
|
|
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
- {
|
|
|
- var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
- while (accounts.MoveNext())
|
|
|
- {
|
|
|
- JsonElement account = accounts.Current;
|
|
|
- schoolIds.Add(account.GetProperty("id").GetString());
|
|
|
- tempCode.schoolCount += 1;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ string sqlSc = $"select c.id from c where c.standard='{itemStandard.standard}'";
|
|
|
+ List<string> schoolIds = await CommonFind.FindSchoolIds(cosmosClient, sqlSc, "Base");
|
|
|
+ tempCode.schoolCount += schoolIds.Count;
|
|
|
+ //List<string> schoolIds = new List<string>();
|
|
|
+ //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.standard='{itemStandard.standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
+ //{
|
|
|
+ // using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ // {
|
|
|
+ // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
+ // while (accounts.MoveNext())
|
|
|
+ // {
|
|
|
+ // JsonElement account = accounts.Current;
|
|
|
+ // schoolIds.Add(account.GetProperty("id").GetString());
|
|
|
+ // tempCode.schoolCount += 1;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
if (schoolIds.Count > 0)
|
|
|
{
|
|
|
foreach (var itemSchool in schoolIds)
|
|
|
{
|
|
|
//查询学校教师人数
|
|
|
- await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"select c.id from c join a1 in c.schools where a1.schoolId='{itemSchool}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
- {
|
|
|
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
- {
|
|
|
- var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
- while (accounts.MoveNext())
|
|
|
- {
|
|
|
- JsonElement account = accounts.Current;
|
|
|
- tempCode.teacherCount += 1;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ string sqlT = $"select count(c.id) as totals from c join a1 in c.schools where a1.schoolId='{itemSchool}'";
|
|
|
+ tempCode.teacherCount += await CommonFind.FindTotals(cosmosClient, sqlT, "Teacher", "Base");
|
|
|
+
|
|
|
+ //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"select c.id from c join a1 in c.schools where a1.schoolId='{itemSchool}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
+ //{
|
|
|
+ // using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ // {
|
|
|
+ // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
+ // while (accounts.MoveNext())
|
|
|
+ // {
|
|
|
+ // JsonElement account = accounts.Current;
|
|
|
+ // tempCode.teacherCount += 1;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
|
|
|
//查询学校学生人数
|
|
|
- await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{itemSchool}") }))
|
|
|
- {
|
|
|
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
- {
|
|
|
- var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
- while (accounts.MoveNext())
|
|
|
- {
|
|
|
- JsonElement account = accounts.Current;
|
|
|
- tempCode.studentCount += 1;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ string sqlStu = $"select count(c.id) as totals from c";
|
|
|
+ tempCode.studentCount += await CommonFind.FindTotals(cosmosClient, sqlStu, "Student", $"Base-{itemSchool}");
|
|
|
+
|
|
|
+ //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{itemSchool}") }))
|
|
|
+ //{
|
|
|
+ // using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ // {
|
|
|
+ // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
+ // while (accounts.MoveNext())
|
|
|
+ // {
|
|
|
+ // JsonElement account = accounts.Current;
|
|
|
+ // tempCode.studentCount += 1;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -549,54 +592,64 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
tempProvinceStics.provCode = itemStandard.provCode;
|
|
|
tempProvinceStics.provName = itemStandard.provName;
|
|
|
tempProvinceStics.standardCount += 1;
|
|
|
- List<string> schoolIds = new List<string>();
|
|
|
- await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.standard='{itemStandard.standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
- {
|
|
|
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
- {
|
|
|
- var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
- while (accounts.MoveNext())
|
|
|
- {
|
|
|
- JsonElement account = accounts.Current;
|
|
|
- schoolIds.Add(account.GetProperty("id").GetString());
|
|
|
- tempProvinceStics.schoolCount += 1;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
+ string sqlSc = $"select c.id from c where c.standard='{itemStandard.standard}'";
|
|
|
+ List<string> schoolIds = await CommonFind.FindSchoolIds(cosmosClient, sqlSc, "Base");
|
|
|
+ tempProvinceStics.schoolCount += schoolIds.Count;
|
|
|
+ //List<string> schoolIds = new List<string>();
|
|
|
+ //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.standard='{itemStandard.standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
+ //{
|
|
|
+ // using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ // {
|
|
|
+ // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
+ // while (accounts.MoveNext())
|
|
|
+ // {
|
|
|
+ // JsonElement account = accounts.Current;
|
|
|
+ // schoolIds.Add(account.GetProperty("id").GetString());
|
|
|
+ // tempProvinceStics.schoolCount += 1;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
if (schoolIds.Count > 0)
|
|
|
{
|
|
|
foreach (var itemSchool in schoolIds)
|
|
|
{
|
|
|
//查询学校教师人数
|
|
|
- await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"select c.id from c join a1 in c.schools where a1.schoolId='{itemSchool}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
- {
|
|
|
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
- {
|
|
|
- var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
- while (accounts.MoveNext())
|
|
|
- {
|
|
|
- JsonElement account = accounts.Current;
|
|
|
- tempProvinceStics.teacherCount += 1;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ string sqlT = $"select count(c.id) as totals from c join a1 in c.schools where a1.schoolId='{itemSchool}'";
|
|
|
+ tempProvinceStics.teacherCount += await CommonFind.FindTotals(cosmosClient, sqlT, "Teacher", "Base");
|
|
|
+
|
|
|
+ //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"select c.id from c join a1 in c.schools where a1.schoolId='{itemSchool}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
+ //{
|
|
|
+ // using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ // {
|
|
|
+ // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
+ // while (accounts.MoveNext())
|
|
|
+ // {
|
|
|
+ // JsonElement account = accounts.Current;
|
|
|
+ // tempProvinceStics.teacherCount += 1;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
|
|
|
//查询学校学生人数
|
|
|
- await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{itemSchool}") }))
|
|
|
- {
|
|
|
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
- {
|
|
|
- var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
- while (accounts.MoveNext())
|
|
|
- {
|
|
|
- JsonElement account = accounts.Current;
|
|
|
- tempProvinceStics.studentCount += 1;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ string sqlStu = "select count(c.id) as totals from c";
|
|
|
+ tempProvinceStics.studentCount += await CommonFind.FindTotals(cosmosClient, sqlStu, "Student", $"Base-{itemSchool}");
|
|
|
+
|
|
|
+ //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{itemSchool}") }))
|
|
|
+ //{
|
|
|
+ // using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ // {
|
|
|
+ // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
+ // while (accounts.MoveNext())
|
|
|
+ // {
|
|
|
+ // JsonElement account = accounts.Current;
|
|
|
+ // tempProvinceStics.studentCount += 1;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -608,7 +661,7 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- await _dingDing.SendBotMsg($"BI, {_option.Location} // \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
+ await _dingDing.SendBotMsg($"BI, {_option.Location} /homestatis/get-provincestics \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
|
return BadRequest();
|
|
|
}
|
|
|
}
|
|
@@ -645,19 +698,22 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
var tempCode = citySchools.Find(x => x.cityCode == itemStandrd.cityCode);
|
|
|
if (tempCode != null)
|
|
|
{
|
|
|
- await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.standard='{itemStandrd.standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
- {
|
|
|
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
- {
|
|
|
- var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
- while (accounts.MoveNext())
|
|
|
- {
|
|
|
- JsonElement account = accounts.Current;
|
|
|
- tempCode.schoolCount += 1;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ string sqlTxt = $"select count(c.id) totals from c where c.standard='{itemStandrd.standard}'";
|
|
|
+ tempCode.schoolCount += await CommonFind.FindTotals(cosmosClient, sqlTxt, "School", "Base");
|
|
|
+
|
|
|
+ //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.standard='{itemStandrd.standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
+ //{
|
|
|
+ // using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ // {
|
|
|
+ // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
+ // while (accounts.MoveNext())
|
|
|
+ // {
|
|
|
+ // JsonElement account = accounts.Current;
|
|
|
+ // tempCode.schoolCount += 1;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
var tempModel = citySchools.Where(x => x.cityCode == tempCode.cityCode).FirstOrDefault();
|
|
|
if (tempModel != null)
|
|
|
{
|
|
@@ -668,21 +724,26 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
{
|
|
|
citySchool.cityCode = itemStandrd.cityCode;
|
|
|
citySchool.cityName = itemStandrd.cityName;
|
|
|
- List<string> schoolIds = new List<string>();
|
|
|
- await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.standard='{itemStandrd.standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
- {
|
|
|
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
- {
|
|
|
- var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
- while (accounts.MoveNext())
|
|
|
- {
|
|
|
- JsonElement account = accounts.Current;
|
|
|
- schoolIds.Add(account.GetProperty("id").GetString());
|
|
|
- citySchool.schoolCount += 1;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
+ string sqlTxt = $"select count(c.id) totals from c where c.standard='{itemStandrd.standard}'";
|
|
|
+ citySchool.schoolCount += await CommonFind.FindTotals(cosmosClient, sqlTxt, "School", "Base");
|
|
|
+
|
|
|
+ //List<string> schoolIds = new List<string>();
|
|
|
+ //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.standard='{itemStandrd.standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
+ //{
|
|
|
+ // using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ // {
|
|
|
+ // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
+ // while (accounts.MoveNext())
|
|
|
+ // {
|
|
|
+ // JsonElement account = accounts.Current;
|
|
|
+ // schoolIds.Add(account.GetProperty("id").GetString());
|
|
|
+ // citySchool.schoolCount += 1;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+
|
|
|
citySchools.Add(citySchool);
|
|
|
}
|
|
|
}
|
|
@@ -731,56 +792,67 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
districtStics.cityName = itemStandrd.cityName;
|
|
|
districtStics.distName = itemStandrd.distName;
|
|
|
|
|
|
- List<string> schoolIds = new List<string>();
|
|
|
- //查询区域学校数量
|
|
|
- await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.standard='{itemStandrd.standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
- {
|
|
|
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
- {
|
|
|
- var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
- while (accounts.MoveNext())
|
|
|
- {
|
|
|
- JsonElement account = accounts.Current;
|
|
|
- schoolIds.Add(account.GetProperty("id").GetString());
|
|
|
- districtStics.schoolCount += 1;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ string sqlTxt = $"select c.id from c where c.standard='{itemStandrd.standard}'";
|
|
|
+ List<string> schoolIds = await CommonFind.FindSchoolIds(cosmosClient,sqlTxt, "Base");
|
|
|
+ districtStics.schoolCount += schoolIds.Count;
|
|
|
+
|
|
|
+ //List<string> schoolIds = new List<string>();
|
|
|
+ ////查询区域学校数量
|
|
|
+ //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.standard='{itemStandrd.standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
+ //{
|
|
|
+ // using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ // {
|
|
|
+ // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
+ // while (accounts.MoveNext())
|
|
|
+ // {
|
|
|
+ // JsonElement account = accounts.Current;
|
|
|
+ // schoolIds.Add(account.GetProperty("id").GetString());
|
|
|
+ // districtStics.schoolCount += 1;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
|
|
|
if (schoolIds.Count > 0)
|
|
|
{
|
|
|
foreach (var itemSchool in schoolIds)
|
|
|
{
|
|
|
//查询学校教师人数
|
|
|
- await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"select c.id from c join a1 in c.schools where a1.schoolId='{itemSchool}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
- {
|
|
|
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
- {
|
|
|
- var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
- while (accounts.MoveNext())
|
|
|
- {
|
|
|
- JsonElement account = accounts.Current;
|
|
|
- districtStics.teacherCount += 1;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ string sqlT = $"select count(c.id) as totals from c join a1 in c.schools where a1.schoolId='{itemSchool}'";
|
|
|
+ districtStics.teacherCount += await CommonFind.FindTotals(cosmosClient, sqlT, "Teacher", "Base");
|
|
|
+
|
|
|
+ //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"select c.id from c join a1 in c.schools where a1.schoolId='{itemSchool}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
+ //{
|
|
|
+ // using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ // {
|
|
|
+ // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
+ // while (accounts.MoveNext())
|
|
|
+ // {
|
|
|
+ // JsonElement account = accounts.Current;
|
|
|
+ // districtStics.teacherCount += 1;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
|
|
|
//查询学校学生人数
|
|
|
- await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{itemSchool}") }))
|
|
|
- {
|
|
|
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
- {
|
|
|
- var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
- while (accounts.MoveNext())
|
|
|
- {
|
|
|
- JsonElement account = accounts.Current;
|
|
|
- districtStics.studentCount += 1;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
+ string sqlS = $"select count(c.id) as totals from c ";
|
|
|
+ districtStics.studentCount += await CommonFind.FindTotals(cosmosClient, sqlS, "Student", $"Base-{itemSchool}");
|
|
|
+
|
|
|
+ //await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{itemSchool}") }))
|
|
|
+ //{
|
|
|
+ // using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ // if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ // {
|
|
|
+ // var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
+ // while (accounts.MoveNext())
|
|
|
+ // {
|
|
|
+ // JsonElement account = accounts.Current;
|
|
|
+ // districtStics.studentCount += 1;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
}
|
|
|
}
|
|
|
districtSticss.Add(districtStics);
|
|
@@ -832,26 +904,21 @@ namespace TEAMModelBI.Controllers.BIHome
|
|
|
{
|
|
|
List<string> schoolIds = new List<string>();
|
|
|
|
|
|
- try
|
|
|
+ await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.standard='{itemStandrd.standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
{
|
|
|
- await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.standard='{itemStandrd.standard}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
{
|
|
|
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
+ var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
+ while (accounts.MoveNext())
|
|
|
{
|
|
|
- var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
- while (accounts.MoveNext())
|
|
|
- {
|
|
|
- JsonElement account = accounts.Current;
|
|
|
- schoolIds.Add(account.GetProperty("id").GetString());
|
|
|
- tempCode.schoolCount += 1;
|
|
|
- }
|
|
|
+ JsonElement account = accounts.Current;
|
|
|
+ schoolIds.Add(account.GetProperty("id").GetString());
|
|
|
+ tempCode.schoolCount += 1;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- catch
|
|
|
- {
|
|
|
- }
|
|
|
+
|
|
|
var tempModel = sticsCitys.Where(x => x.cityCode == tempCode.cityCode).FirstOrDefault();
|
|
|
if (tempModel != null)
|
|
|
{
|