|
@@ -702,7 +702,162 @@ namespace TEAMModelOS.Controllers
|
|
|
return Ok(new { data });
|
|
|
}
|
|
|
|
|
|
+ [HttpPost("test-scteacher-dn")]
|
|
|
+ public async Task<IActionResult> TestScteacherDn(JsonElement json) {
|
|
|
+ var table = _azureStorage.GetCloudTableClient().GetTableReference("ScYxpt");
|
|
|
+ string sqls = "select distinct value(c.id )from c where c.code='Base' and IS_DEFINED(c.finalScore)=true ";
|
|
|
+ //https://teammodelos.blob.core.chinacloudapi.cn/teammodelos
|
|
|
+ //https://teammodelos.blob.core.chinacloudapi.cn/teammodelos/yxpt%2Fjinniu%2Fscbind%2F1647432004.json
|
|
|
+ List<ScTeacher> teachers = await table.FindListByDict<ScTeacher>(new Dictionary<string, object>() { { "PartitionKey", "ScTeacher" }, { "areaId", "870a5a6b-1ab3-461a-bdeb-baec19780ddb" } });
|
|
|
+ List<string> ids = new List<string>();
|
|
|
+ await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher)
|
|
|
+ .GetItemQueryIterator<string>(sqls, requestOptions: new QueryRequestOptions {PartitionKey= new PartitionKey("Base") }))
|
|
|
+ {
|
|
|
+ ids.Add(item);
|
|
|
+ }
|
|
|
+ long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
|
+ List<string> erorr = new List<string>();
|
|
|
+ List<ScTeacher> teachersUp = new List<ScTeacher>();
|
|
|
+ foreach (var id in ids) {
|
|
|
+ try {
|
|
|
+ BlobDownloadResult baseblobDownload = await _azureStorage.GetBlobContainerClient("teammodelos").GetBlobClient($"/yxpt/jinniu/scbind/{id}.json").DownloadContentAsync();
|
|
|
+ ScBindData scBindData = baseblobDownload.Content.ToObjectFromJson<ScBindData>();
|
|
|
+ var tcd= teachers.Find(x => x.RowKey.Equals(scBindData.pxid));
|
|
|
+ if (tcd != null)
|
|
|
+ {
|
|
|
+ Teacher teacher = new Teacher
|
|
|
+ {
|
|
|
+ pk="Base",
|
|
|
+ code = "Base",
|
|
|
+ id = id,
|
|
|
+ name = scBindData.username,
|
|
|
+ size = 2,
|
|
|
+ defaultSchool = tcd.schoolCode,
|
|
|
+ schools = new List<TeacherSchool> {
|
|
|
+ new TeacherSchool
|
|
|
+ {
|
|
|
+ schoolId = tcd.schoolCode, status = "join", time = now, name = scBindData.sn, areaId = tcd.areaId
|
|
|
+ }
|
|
|
+ },
|
|
|
+ binds = new List<ThirdBind> {
|
|
|
+ new ThirdBind
|
|
|
+ {
|
|
|
+ type= "scsyxpt",userid=scBindData.userid,username= scBindData.username,account=scBindData.account,data=new List<string>{ scBindData.ToJsonString()}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS,Constant.Teacher).UpsertItemAsync(teacher,new PartitionKey("Base"));
|
|
|
+ tcd.tmdid = id;
|
|
|
+ teachersUp.Add(tcd);
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception ) {
|
|
|
+ erorr.Add(id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ await table.SaveOrUpdateAll(teachersUp);
|
|
|
+ return Ok();
|
|
|
+ }
|
|
|
+ [HttpPost("test-scteacher")]
|
|
|
+ public async Task<IActionResult> TestScteacher(JsonElement json) {
|
|
|
+ var table = _azureStorage.GetCloudTableClient().GetTableReference("ScYxpt");
|
|
|
+ List<TeacherFile> teacherFiles = new List<TeacherFile>();
|
|
|
+ string sqls = "select distinct c.id,c.code from c where c.pk='TeacherFile' and IS_DEFINED(c.fileRecords)=false ";
|
|
|
+ List<IdNameCode> ids = new List<IdNameCode>();
|
|
|
+ await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetItemQueryIterator<IdNameCode>(sqls, requestOptions: new QueryRequestOptions { }))
|
|
|
+ {
|
|
|
+ item.code= item.code.Replace("TeacherFile-", "");
|
|
|
+ ids.Add(item);
|
|
|
+ }
|
|
|
+ var grp = ids.GroupBy(g => g.code).Select(x => new { key = x.Key, list = x.ToList() });
|
|
|
+
|
|
|
+ foreach (var gp in grp) {
|
|
|
+ foreach (var tch in gp.list) {
|
|
|
+ if (!string.IsNullOrWhiteSpace(tch.id)) {
|
|
|
+ var id = ids.Find(x => x.id.Equals(tch.id))?.id;
|
|
|
+ if (id != null) {
|
|
|
+ TeacherFile teacherFile = new TeacherFile { id = id,pk= "TeacherFile",code= $"TeacherFile-{gp.key}",ttl=-1 };
|
|
|
+ List<AbilitySub> abilitySubs = new List<AbilitySub>();
|
|
|
+ string sql = "select value(c) from c ";
|
|
|
+ try {
|
|
|
+ await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetItemQueryIterator<AbilitySub>
|
|
|
+ (sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"AbilitySub-{gp.key}-{id}") }))
|
|
|
+ {
|
|
|
+ abilitySubs.Add(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ Dictionary<string, RecordFileAbility> valuePairs = new Dictionary<string, RecordFileAbility>();
|
|
|
+ var taskids= abilitySubs.SelectMany(x => x.taskRcds).Select(x => x.id).ToHashSet();
|
|
|
+ if (taskids.Any()) {
|
|
|
+
|
|
|
+ List<AbilityTask> abilityTasks = new List<AbilityTask>();
|
|
|
+ string taskSql = $"select distinct value(c) from c join b in c.children where c.code='AbilityTask-standard10' and b.id in ({string.Join(",", taskids.Select(m=>$"'{m}'"))})";
|
|
|
+ await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).GetItemQueryIterator<AbilityTask>
|
|
|
+ (taskSql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"AbilityTask-standard10") }))
|
|
|
+ {
|
|
|
+ abilityTasks.Add(item);
|
|
|
+ }
|
|
|
+ abilityTasks.ForEach(x => {
|
|
|
+ x.children.ForEach(y => {
|
|
|
+ var di= taskids.ToList().Find(z => z.Equals(y.id));
|
|
|
+ if (!string.IsNullOrWhiteSpace(id)) {
|
|
|
+ y.rnodes.ForEach(r => {
|
|
|
+ if (valuePairs.ContainsKey(r.hash))
|
|
|
+ {
|
|
|
+ valuePairs.TryGetValue(r.hash, out var value);
|
|
|
+ value.fileAbilities.Add(new FileAbility { url = r.link, abilityId = x.abilityId, taskId = x.id, nodeId = r.id });
|
|
|
+ }
|
|
|
+ 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=r.id } }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ foreach (var item in valuePairs)
|
|
|
+ {
|
|
|
+ teacherFile.fileRecords.Add(new FileRecord
|
|
|
+ {
|
|
|
+ hash = item.Value.fileRecord.hash,
|
|
|
+ size = item.Value.fileRecord.size,
|
|
|
+ duration = item.Value.fileRecord.duration,
|
|
|
+ view = (int)item.Value.fileRecord.view,
|
|
|
+ type = item.Value.fileRecord.type,
|
|
|
+ done = true,
|
|
|
+ files = item.Value.fileAbilities
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ return BadRequest(new { ex = ex.Message, ms = ex.StackTrace });
|
|
|
+
|
|
|
+ }
|
|
|
+ teacherFiles.Add(teacherFile);
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).UpsertItemAsync(teacherFile, new PartitionKey(teacherFile.code));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return Ok(teacherFiles);
|
|
|
+ }
|
|
|
|
|
|
+
|
|
|
+ public class RecordFileAbility
|
|
|
+ {
|
|
|
+
|
|
|
+ public FileRecord fileRecord { get; set; }
|
|
|
+ public List<FileAbility> fileAbilities { get; set; }
|
|
|
+ }
|
|
|
[HttpPost("test-blob-folder")]
|
|
|
public async Task<IActionResult> TestBlobFolder(JsonElement json)
|
|
|
{
|
|
@@ -731,5 +886,4 @@ namespace TEAMModelOS.Controllers
|
|
|
return Ok(new { lessonIds , ids , notdata, notblob });
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|