|
@@ -760,15 +760,18 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
[HttpPost("get-teacher-ability-files")]
|
|
|
public async Task<IActionResult> GetScteacher(JsonElement json) {
|
|
|
-
|
|
|
+ if (!json.TryGetProperty("areaId", out JsonElement _areaId)) { return BadRequest(); }
|
|
|
+ Area area= await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemAsync<Area>($"{_areaId}", new PartitionKey("Base-Area"));
|
|
|
List<string> teachers = new List<string>();
|
|
|
+ //获取这个区的教师
|
|
|
string schoolSql = "SELECT value c.id FROM c join a in c.schools where a.areaId='870a5a6b-1ab3-461a-bdeb-baec19780ddb' and c.code='Base' ";
|
|
|
await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher)
|
|
|
.GetItemQueryIterator<string>(schoolSql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
|
|
|
{
|
|
|
teachers.Add(item);
|
|
|
}
|
|
|
- string tr =$"SELECT value(c) FROM c where c.id in ({string.Join(",", teachers.Select(x=>$"'{x}'"))}) and c.pk='TeacherTrain' ";
|
|
|
+ //获取这些老师的研修记录
|
|
|
+ string tr =$"SELECT distinct value(c) FROM c join a in c.currency.teacherAilities where c.id in ({string.Join(",", teachers.Select(x=>$"'{x}'"))}) and c.pk='TeacherTrain' and a.videoTime<300 ";
|
|
|
List<TeacherTrain> teacherTrains = new List<TeacherTrain>();
|
|
|
await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher)
|
|
|
.GetItemQueryIterator<TeacherTrain>(tr, requestOptions: new QueryRequestOptions { }))
|
|
@@ -777,118 +780,112 @@ namespace TEAMModelOS.Controllers
|
|
|
teacherTrains.Add(item);
|
|
|
}
|
|
|
}
|
|
|
- string sql = $" select distinct value(b.id ) from c join b in c.children where c.code='AbilityTask-standard10' ";
|
|
|
+ //获取这个区的能力点树状结构
|
|
|
+ string sql = $" select distinct value(b.id ) from c join b in c.children where c.code='AbilityTask-{area.standard}' ";
|
|
|
List<string> nodeIdsDB = new List<string>();
|
|
|
await foreach (var y in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).GetItemQueryIterator<string>
|
|
|
- (sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"AbilityTask-standard10") }))
|
|
|
+ (sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"AbilityTask-{area.standard}") }))
|
|
|
{
|
|
|
nodeIdsDB.Add(y);
|
|
|
}
|
|
|
- List<string> right=new List<string>();
|
|
|
- List<string> left=new List<string>();
|
|
|
foreach (var item in teacherTrains)
|
|
|
{
|
|
|
- if (item.onlineTime > 2)
|
|
|
+ List<TeacherAbility> teacherAbility = new List<TeacherAbility>();
|
|
|
+ if (item.currency.teacherAilities.Count() > 3)
|
|
|
+ {
|
|
|
+ //如果选择了大于三个能力点的教师,则优先获取上传了认证材料的的能力点,
|
|
|
+ var uploadHas= item.currency.teacherAilities.FindAll(x => x.uploadHas == 1);
|
|
|
+ if (uploadHas.Any()) {
|
|
|
+ teacherAbility.AddRange(uploadHas);
|
|
|
+ }
|
|
|
+ // 如果仍然未满足数量。则再去获取 没有上传认证材料,但是又有学习时间长的能力点。
|
|
|
+ var hasVideoTime = item.currency.teacherAilities.FindAll(x => x.uploadHas != 1);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ teacherAbility.AddRange(item.currency.teacherAilities);
|
|
|
+ }
|
|
|
+
|
|
|
+ TeacherFile teacherFile = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReadItemAsync<TeacherFile>(item.id, new PartitionKey($"TeacherFile-{item.code.Replace("TeacherTrain-", "")}"));
|
|
|
+ foreach (var x in item.currency.teacherAilities)
|
|
|
{
|
|
|
- TeacherFile teacherFile = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReadItemAsync<TeacherFile>(item.id, new PartitionKey($"TeacherFile-{item.code.Replace("TeacherTrain-", "")}"));
|
|
|
- var nodeIds= teacherFile.fileRecords.SelectMany(x => x.files).Select(x => x.nodeId).ToHashSet();
|
|
|
- bool expect = false;
|
|
|
- if (nodeIds.Any())
|
|
|
+ //某个能力点大于300
|
|
|
+ if (x.videoTime >= 300) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ string sqls = $" select value(c) from c where c.abilityId='{x.id}' and c.code='AbilityTask-{area.standard}'";
|
|
|
+ List<AbilityTask> abilityTasks = new List<AbilityTask>();
|
|
|
+ Dictionary<string, RecordFileAbility> valuePairs = new Dictionary<string, RecordFileAbility>();
|
|
|
+ await foreach (var y in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).GetItemQueryIterator<AbilityTask>
|
|
|
+ (sqls, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"AbilityTask-{area.standard}") }))
|
|
|
{
|
|
|
- var exp= nodeIds.Except(nodeIdsDB);
|
|
|
- if (exp.Any())
|
|
|
- {
|
|
|
- expect = true;
|
|
|
- List<FileAbility> dels = new List<FileAbility>();
|
|
|
- teacherFile.fileRecords.ForEach(x => {
|
|
|
- x.files.RemoveAll(z => exp.Contains(z.nodeId));
|
|
|
- });
|
|
|
- }
|
|
|
+ abilityTasks.Add(y);
|
|
|
}
|
|
|
- if (expect)
|
|
|
+ // double limit = 0;
|
|
|
+ abilityTasks.ForEach(x =>
|
|
|
{
|
|
|
- left.Add(item.id);
|
|
|
- foreach (var x in item.currency.teacherAilities)
|
|
|
+ x.children.ForEach(y =>
|
|
|
{
|
|
|
- string sqls = $" select value(c) from c where c.abilityId='{x.id}' and c.code='AbilityTask-standard10'";
|
|
|
- List<AbilityTask> abilityTasks = new List<AbilityTask>();
|
|
|
- Dictionary<string, RecordFileAbility> valuePairs = new Dictionary<string, RecordFileAbility>();
|
|
|
- await foreach (var y in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).GetItemQueryIterator<AbilityTask>
|
|
|
- (sqls, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"AbilityTask-standard10") }))
|
|
|
+ y.rnodes.ForEach(r =>
|
|
|
{
|
|
|
- abilityTasks.Add(y);
|
|
|
- }
|
|
|
- // double limit = 0;
|
|
|
- abilityTasks.ForEach(x =>
|
|
|
- {
|
|
|
- x.children.ForEach(y =>
|
|
|
- {
|
|
|
- y.rnodes.ForEach(r =>
|
|
|
- {
|
|
|
|
|
|
- if (valuePairs.ContainsKey(r.hash))
|
|
|
- {
|
|
|
- valuePairs.TryGetValue(r.hash, out var value);
|
|
|
- var ablt= value.fileAbilities.Find(z => z.abilityId.Equals(x.abilityId) && z.taskId.Equals(x.id) && z.nodeId.Equals(y.id) );
|
|
|
- if (ablt == null) {
|
|
|
- value.fileAbilities.Add(new FileAbility { url = r.link, abilityId = x.abilityId, taskId = x.id, nodeId = y.id });
|
|
|
- // limit = limit + r.duration;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- valuePairs.Add(r.hash, new RecordFileAbility
|
|
|
- {
|
|
|
- fileRecord =
|
|
|
- new FileRecord { hash = r.hash, size = r.size.Value, duration = r.duration, view = (int)r.duration, type = r.type, done = true },
|
|
|
- fileAbilities = new List<FileAbility> { new FileAbility { url = r.link, abilityId = x.abilityId, taskId = x.id, nodeId = y.id } }
|
|
|
- });
|
|
|
- // limit = limit + r.duration;
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- });
|
|
|
-
|
|
|
- foreach (var ps in valuePairs)
|
|
|
- {
|
|
|
- var fils = teacherFile.fileRecords.Find(x => x.hash.Equals(ps.Key));
|
|
|
- if (fils != null)
|
|
|
+ if (valuePairs.ContainsKey(r.hash))
|
|
|
{
|
|
|
- ps.Value.fileAbilities.ForEach(x =>
|
|
|
+ valuePairs.TryGetValue(r.hash, out var value);
|
|
|
+ var ablt = value.fileAbilities.Find(z => z.abilityId.Equals(x.abilityId) && z.taskId.Equals(x.id) && z.nodeId.Equals(y.id));
|
|
|
+ if (ablt == null)
|
|
|
{
|
|
|
- var a = fils.files.Find(z => z.nodeId.Equals(x.nodeId) && z.abilityId.Equals(x.abilityId));
|
|
|
- if (a == null)
|
|
|
- {
|
|
|
- fils.files.Add(new FileAbility { url = x.url, abilityId = x.abilityId, taskId = x.taskId, nodeId = x.nodeId });
|
|
|
- }
|
|
|
- });
|
|
|
+ value.fileAbilities.Add(new FileAbility { url = r.link, abilityId = x.abilityId, taskId = x.id, nodeId = y.id });
|
|
|
+ // limit = limit + r.duration;
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- teacherFile.fileRecords.Add(new FileRecord
|
|
|
+ valuePairs.Add(r.hash, new RecordFileAbility
|
|
|
{
|
|
|
- hash = ps.Value.fileRecord.hash,
|
|
|
- size = ps.Value.fileRecord.size,
|
|
|
- duration = ps.Value.fileRecord.duration,
|
|
|
- view = (int)ps.Value.fileRecord.view,
|
|
|
- type = ps.Value.fileRecord.type,
|
|
|
- done = true,
|
|
|
- files = ps.Value.fileAbilities
|
|
|
+ fileRecord =
|
|
|
+ new FileRecord { hash = r.hash, size = r.size.Value, duration = r.duration, view = (int)r.duration, type = r.type, done = true },
|
|
|
+ fileAbilities = new List<FileAbility> { new FileAbility { url = r.link, abilityId = x.abilityId, taskId = x.id, nodeId = y.id } }
|
|
|
});
|
|
|
+ // limit = limit + r.duration;
|
|
|
}
|
|
|
- }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ foreach (var ps in valuePairs)
|
|
|
+ {
|
|
|
+ var fils = teacherFile.fileRecords.Find(x => x.hash.Equals(ps.Key));
|
|
|
+ if (fils != null)
|
|
|
+ {
|
|
|
+ ps.Value.fileAbilities.ForEach(x =>
|
|
|
+ {
|
|
|
+ var a = fils.files.Find(z => z.nodeId.Equals(x.nodeId) && z.abilityId.Equals(x.abilityId));
|
|
|
+ if (a == null)
|
|
|
+ {
|
|
|
+ fils.files.Add(new FileAbility { url = x.url, abilityId = x.abilityId, taskId = x.taskId, nodeId = x.nodeId });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ teacherFile.fileRecords.Add(new FileRecord
|
|
|
+ {
|
|
|
+ hash = ps.Value.fileRecord.hash,
|
|
|
+ size = ps.Value.fileRecord.size,
|
|
|
+ duration = ps.Value.fileRecord.duration,
|
|
|
+ view = (int)ps.Value.fileRecord.view,
|
|
|
+ type = ps.Value.fileRecord.type,
|
|
|
+ done = true,
|
|
|
+ files = ps.Value.fileAbilities
|
|
|
+ });
|
|
|
}
|
|
|
- teacherFile = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReplaceItemAsync<TeacherFile>(teacherFile, teacherFile.id, new PartitionKey(teacherFile.code));
|
|
|
- item.update.Add(StatisticsService.TeacherAbility);
|
|
|
- await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReplaceItemAsync<TeacherTrain>(item, item.id, new PartitionKey(item.code));
|
|
|
-
|
|
|
- }
|
|
|
- else {
|
|
|
- right.Add(item.id);
|
|
|
}
|
|
|
}
|
|
|
+ teacherFile = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReplaceItemAsync<TeacherFile>(teacherFile, teacherFile.id, new PartitionKey(teacherFile.code));
|
|
|
+ item.update.Add(StatisticsService.TeacherAbility);
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReplaceItemAsync<TeacherTrain>(item, item.id, new PartitionKey(item.code));
|
|
|
}
|
|
|
- return Ok(new { right,left});
|
|
|
+ return Ok(new {});
|
|
|
}
|
|
|
|
|
|
|
|
@@ -918,6 +915,9 @@ namespace TEAMModelOS.Controllers
|
|
|
|
|
|
return Ok();
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
[HttpPost("fix-teacher-ability-files")]
|
|
|
public async Task<IActionResult> TestScteacher(JsonElement json) {
|
|
|
if (!json.TryGetProperty("ids", out JsonElement _ids)) return BadRequest();
|