|
@@ -45,14 +45,20 @@ namespace TEAMModelOS.Controllers.Research
|
|
[AuthToken(Roles = "teacher,student,admin,area")]
|
|
[AuthToken(Roles = "teacher,student,admin,area")]
|
|
public async Task<IActionResult> GetAreasStatistics(JsonElement request) {
|
|
public async Task<IActionResult> GetAreasStatistics(JsonElement request) {
|
|
var (userid, _, _, _) = HttpContext.GetAuthTokenInfo();
|
|
var (userid, _, _, _) = HttpContext.GetAuthTokenInfo();
|
|
- if (!HttpContext.Items.TryGetValue("Standard", out object standard)) return BadRequest();
|
|
|
|
|
|
+ // if (!HttpContext.Items.TryGetValue("Standard", out object standard)) return BadRequest();
|
|
|
|
+ if (!request.TryGetProperty("areaId", out JsonElement areaId)) return BadRequest();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
|
+ //string sql = $"select value(c) from c where c.standard='{standard}'";
|
|
|
|
+ //await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: sql,
|
|
|
|
+ // requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
|
|
|
|
+ //{
|
|
|
|
+ // area = item;
|
|
|
|
+ //}
|
|
Area area = null;
|
|
Area area = null;
|
|
- string sql = $"select value(c) from c where c.standard='{standard}'";
|
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: sql,
|
|
|
|
- requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
|
|
|
|
- {
|
|
|
|
- area = item;
|
|
|
|
|
|
+ try {
|
|
|
|
+ area = await client.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemAsync<Area>($"{areaId}", new PartitionKey("Base-Area"));
|
|
|
|
+ } catch (CosmosException ex ) {
|
|
|
|
+ return Ok(new { error = 404,msg="区域不存在!" });
|
|
}
|
|
}
|
|
AreaSetting setting = null;
|
|
AreaSetting setting = null;
|
|
if (area != null)
|
|
if (area != null)
|
|
@@ -63,7 +69,7 @@ namespace TEAMModelOS.Controllers.Research
|
|
}
|
|
}
|
|
catch (CosmosException)
|
|
catch (CosmosException)
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+ return Ok(new { error = 404 ,msg="设置不存在!"});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (setting == null)
|
|
if (setting == null)
|
|
@@ -89,7 +95,7 @@ namespace TEAMModelOS.Controllers.Research
|
|
List<Ability> abilities = new List<Ability>();
|
|
List<Ability> abilities = new List<Ability>();
|
|
List<DimensionCount> areaDimensionCount = new List<DimensionCount>();
|
|
List<DimensionCount> areaDimensionCount = new List<DimensionCount>();
|
|
await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Normal")
|
|
await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Normal")
|
|
- .GetItemQueryIterator<Ability>(queryText: $"select c.id, c.name,c.no,c.dimension, c.env from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{standard}") }))
|
|
|
|
|
|
+ .GetItemQueryIterator<Ability>(queryText: $"select c.id, c.name,c.no,c.dimension, c.env from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{area.standard}") }))
|
|
{
|
|
{
|
|
|
|
|
|
dimensions.Add(item.dimension);
|
|
dimensions.Add(item.dimension);
|
|
@@ -636,29 +642,26 @@ namespace TEAMModelOS.Controllers.Research
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- var (userid, _, _, school) = HttpContext.GetAuthTokenInfo();
|
|
|
|
- if (!HttpContext.Items.TryGetValue("Standard", out object standard)) return BadRequest();
|
|
|
|
|
|
+ var (userid, _, _, __school) = HttpContext.GetAuthTokenInfo();
|
|
|
|
+ if (!request.TryGetProperty("school", out JsonElement school)) return BadRequest();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
- Area area = null;
|
|
|
|
- string sql = $"select value(c) from c where c.standard='{standard}'";
|
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>(queryText: sql,
|
|
|
|
- requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-Area") }))
|
|
|
|
- {
|
|
|
|
- area = item;
|
|
|
|
- }
|
|
|
|
AreaSetting setting = null;
|
|
AreaSetting setting = null;
|
|
|
|
+ School schoolBase = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>($"{school}", new PartitionKey("Base"));
|
|
|
|
+ Area area = await client.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemAsync<Area>(schoolBase.areaId, new PartitionKey("Base-Area"));
|
|
if (area != null)
|
|
if (area != null)
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
//优先找校级
|
|
//优先找校级
|
|
- setting = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<AreaSetting>(school, new PartitionKey("AreaSetting"));
|
|
|
|
|
|
+ setting = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<AreaSetting>($"{school}", new PartitionKey("AreaSetting"));
|
|
}
|
|
}
|
|
catch (CosmosException)
|
|
catch (CosmosException)
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- setting = await client.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemAsync<AreaSetting>(area.id, new PartitionKey("AreaSetting"));
|
|
|
|
|
|
+ if (!string.IsNullOrEmpty(schoolBase.areaId)) {
|
|
|
|
+ setting = await client.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemAsync<AreaSetting>(schoolBase.areaId, new PartitionKey("AreaSetting"));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
catch (CosmosException)
|
|
catch (CosmosException)
|
|
{
|
|
{
|
|
@@ -678,13 +681,13 @@ namespace TEAMModelOS.Controllers.Research
|
|
lessonMinutes = 45,
|
|
lessonMinutes = 45,
|
|
};
|
|
};
|
|
}
|
|
}
|
|
- if (!request.TryGetProperty("school", out JsonElement _school)) return BadRequest();
|
|
|
|
|
|
+
|
|
HashSet<string> dimensions = new HashSet<string>();
|
|
HashSet<string> dimensions = new HashSet<string>();
|
|
|
|
|
|
|
|
|
|
List<Ability> abilities = new List<Ability>();
|
|
List<Ability> abilities = new List<Ability>();
|
|
await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Normal")
|
|
await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Normal")
|
|
- .GetItemQueryIterator<Ability>(queryText: $"select c.id, c.name,c.no,c.dimension, c.env from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{standard}") }))
|
|
|
|
|
|
+ .GetItemQueryIterator<Ability>(queryText: $"select c.id, c.name,c.no,c.dimension, c.env from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{area.standard}") }))
|
|
{
|
|
{
|
|
dimensions.Add(item.dimension);
|
|
dimensions.Add(item.dimension);
|
|
abilities.Add(item);
|
|
abilities.Add(item);
|
|
@@ -692,7 +695,7 @@ namespace TEAMModelOS.Controllers.Research
|
|
List<string> abilitieIds = abilities.Select(x => x.id).ToList();
|
|
List<string> abilitieIds = abilities.Select(x => x.id).ToList();
|
|
List<ClassVideo> classVideos = new List<ClassVideo>();
|
|
List<ClassVideo> classVideos = new List<ClassVideo>();
|
|
List<AbilitySub> abilitySubs = new List<AbilitySub>();
|
|
List<AbilitySub> abilitySubs = new List<AbilitySub>();
|
|
- string code = $"ClassVideo-{_school}";
|
|
|
|
|
|
+ string code = $"ClassVideo-{school}";
|
|
await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher")
|
|
await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher")
|
|
.GetItemQueryIterator<ClassVideo>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
|
|
.GetItemQueryIterator<ClassVideo>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(code) }))
|
|
{
|
|
{
|
|
@@ -702,7 +705,7 @@ namespace TEAMModelOS.Controllers.Research
|
|
List<SchoolGroup> groups = new List<SchoolGroup>();
|
|
List<SchoolGroup> groups = new List<SchoolGroup>();
|
|
List<TchList> tchLists = new List<TchList>();
|
|
List<TchList> tchLists = new List<TchList>();
|
|
await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<TchList>(queryText: $"SELECT value(c) FROM c ",
|
|
await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<TchList>(queryText: $"SELECT value(c) FROM c ",
|
|
- requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"TchList-{_school}") }))
|
|
|
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"TchList-{school}") }))
|
|
{
|
|
{
|
|
groups.Add(new SchoolGroup { groupId=item.id,groupName=item.name});
|
|
groups.Add(new SchoolGroup { groupId=item.id,groupName=item.name});
|
|
tchLists.Add(item);
|
|
tchLists.Add(item);
|
|
@@ -753,7 +756,7 @@ namespace TEAMModelOS.Controllers.Research
|
|
{
|
|
{
|
|
ids.Add("default");
|
|
ids.Add("default");
|
|
}
|
|
}
|
|
- (List<TmdInfo> tmdInfos, List<ClassListInfo> classInfos) = await TriggerStuActivity.GetTchList(client, _dingDing, ids, $"{_school}");
|
|
|
|
|
|
+ (List<TmdInfo> tmdInfos, List<ClassListInfo> classInfos) = await TriggerStuActivity.GetTchList(client, _dingDing, ids, $"{school}");
|
|
if (groups.IsEmpty()) {
|
|
if (groups.IsEmpty()) {
|
|
groups.Add(new SchoolGroup { groupId = "default", groupName = "default" });
|
|
groups.Add(new SchoolGroup { groupId = "default", groupName = "default" });
|
|
}
|
|
}
|
|
@@ -841,7 +844,7 @@ namespace TEAMModelOS.Controllers.Research
|
|
foreach (var tmd in tmdInfos)
|
|
foreach (var tmd in tmdInfos)
|
|
{
|
|
{
|
|
await foreach (var sub in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher")
|
|
await foreach (var sub in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher")
|
|
- .GetItemQueryIterator<AbilitySub>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilitySub-{_school}-{tmd.id}") }))
|
|
|
|
|
|
+ .GetItemQueryIterator<AbilitySub>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilitySub-{school}-{tmd.id}") }))
|
|
{
|
|
{
|
|
abilitySubs.Add(sub);
|
|
abilitySubs.Add(sub);
|
|
}
|
|
}
|
|
@@ -980,7 +983,7 @@ namespace TEAMModelOS.Controllers.Research
|
|
});
|
|
});
|
|
}
|
|
}
|
|
List<SubStatistic> subs = new();
|
|
List<SubStatistic> subs = new();
|
|
- abilitySubs.Where(x => x.code.Equals($"AbilitySub-{_school}-{tmd.id}")).ToList().ForEach(item =>
|
|
|
|
|
|
+ abilitySubs.Where(x => x.code.Equals($"AbilitySub-{school}-{tmd.id}")).ToList().ForEach(item =>
|
|
{
|
|
{
|
|
subCount += 1;
|
|
subCount += 1;
|
|
thcSubCount += 1;
|
|
thcSubCount += 1;
|