CrazyIter_Bin 3 سال پیش
والد
کامیت
5b2bf94cdf

+ 3 - 2
TEAMModelOS.SDK/Models/Cosmos/Research/TeacherFile.cs

@@ -7,7 +7,7 @@ namespace TEAMModelOS.SDK.Models
     public class TeacherFile : CosmosEntity
     {
         /// <summary>
-        /// id="tmdid",code":"VideoRecord:hbcn"
+        /// id="tmdid",code":"TeacherFile:hbcn"
         /// </summary>
         public TeacherFile() {
         }
@@ -46,11 +46,12 @@ namespace TEAMModelOS.SDK.Models
         public long duration { get; set; }
         public long view { get; set; }
         public bool  done { get; set; }
+        public string abilityId { get; set; }
         public string taskId { get; set; }
         public string nodeId { get; set; }
         public string url { get; set; }
         public string type { get; set; }
-        public string size { get; set; }
+        public long size { get; set; }
     }
     public class FileAbility { 
         /// <summary>

+ 4 - 0
TEAMModelOS.SDK/Models/Cosmos/Research/TeacherTrain.cs

@@ -175,6 +175,10 @@ namespace TEAMModelOS.SDK.Models
         /// </summary>
         public string no { get; set; }
         /// <summary>
+        /// 能力点名称
+        /// </summary>
+        public string name { get; set; }
+        /// <summary>
         /// 能力点维度
         /// </summary>
         public string dimension { get; set; }

+ 5 - 4
TEAMModelOS.SDK/Models/Service/StatisticsService.cs

@@ -55,7 +55,7 @@ namespace TEAMModelOS.SDK
             List<TeacherTrain> trains = new List<TeacherTrain>();
             await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher")
              .GetItemQueryIterator<TeacherTrain>(queryText: $"select value(c) from c  ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"TeacherTrain-{school}") })) {
-                trains.Add(item);
+                //trains.Add(item);
             }
             var update = trains.FindAll(x => x.updateProperty.Count() > 0);
             var noupdate = trains.FindAll(x => x.updateProperty.Count() <=0);
@@ -405,19 +405,19 @@ namespace TEAMModelOS.SDK
             TeacherFile file = null;
             try
             {
-                file = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<TeacherFile>(_tmdid, new PartitionKey($"VideoRecord-{_school}"));
+                file = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<TeacherFile>(_tmdid, new PartitionKey($"TeacherFile-{_school}"));
             }
             catch (CosmosException )
             {
                 file = new TeacherFile
                 {
                     id = _tmdid,
-                    code = $"VideoRecord-{_school}",
+                    code = $"TeacherFile-{_school}",
                     pk = "TeacherFile",
                     ttl = -1,
 
                 };
-                await client.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<TeacherFile>(file, new PartitionKey($"VideoRecord-{_school}"));
+                await client.GetContainer(Constant.TEAMModelOS, "Teacher").CreateItemAsync<TeacherFile>(file, new PartitionKey($"TeacherFile-{_school}"));
             }
 
             List<AbilitySub> abilitySubs= new List<AbilitySub> ();
@@ -475,6 +475,7 @@ namespace TEAMModelOS.SDK
                     id = ability.id,
                     currency = currency,
                     no = ability.no,
+                    name = ability.name,
                     dimension = ability.dimension,
                     zpscore = item.self,
                     hprecord = hprecords,

+ 54 - 3
TEAMModelOS/Controllers/Research/AbilitySubController.cs

@@ -610,9 +610,60 @@ namespace TEAMModelOS.Controllers
                     case "SaveFileRcd":
                         //保存线上学习记录
                         if (!request.TryGetProperty("fileRcd", out JsonElement _fileRcd)) return BadRequest();
-                        AbilityVideoRcd fileRcd = _fileRcd.ToObject<AbilityVideoRcd>();
-                       
-                        return Ok(new { status, abilitySub.videoRcds });
+                        TeacherFileRcd fileRcd = _fileRcd.ToObject<TeacherFileRcd>();
+                        TeacherFile teacherFile = null;
+                        try
+                        {
+                            teacherFile = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<TeacherFile>($"{_tmdid}", new PartitionKey($"TeacherFile-{_school}"));
+                            var file= teacherFile.fileRecords.Find(x => x.hash.Equals(fileRcd.hash));
+                            if (file != null)
+                            {
+                                file.hash = fileRcd.hash;
+                                file.view = fileRcd.view;
+                                FileAbility ability= file.files.Find(x => x.abilityId.Equals(fileRcd.abilityId) && x.url.Equals(fileRcd.url) && x.taskId.Equals(fileRcd.taskId));
+                                if (ability != null)
+                                {
+                                    ability.url = fileRcd.url;
+                                    ability.abilityId = fileRcd.abilityId;
+                                    ability.taskId = fileRcd.taskId;
+                                    ability.nodeId = fileRcd.nodeId;
+                                    ability.done = fileRcd.done;
+                                }
+                                else {
+                                    file.files.Add(new FileAbility { url = fileRcd.url, abilityId = fileRcd.abilityId, taskId = fileRcd.taskId, nodeId = fileRcd.nodeId, done = fileRcd.done });
+                                }
+                            }
+                            else {
+                                teacherFile.fileRecords.Add(new FileRecord
+                                {
+                                    hash = fileRcd.hash,
+                                    size = fileRcd.size,
+                                    duration = fileRcd.duration,
+                                    view = fileRcd.view,
+                                    type = fileRcd.type,
+                                    files = new List<FileAbility> { new FileAbility { url = fileRcd.url, abilityId = fileRcd.abilityId, taskId = fileRcd.taskId, nodeId = fileRcd.nodeId, done = fileRcd.done } }
+                                });
+                            }
+                            await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<TeacherFile>(teacherFile, teacherFile.id, new PartitionKey($"TeacherFile-{_school}"));
+                        }
+                        catch (CosmosException)
+                        {
+                            teacherFile = new TeacherFile
+                            {
+                                id =$"{_tmdid}",
+                                code= $"TeacherFile-{_school}",
+                                fileRecords=new List<FileRecord> { new FileRecord {
+                                    hash= fileRcd.hash,
+                                    size=fileRcd.size,
+                                    duration=fileRcd.duration,
+                                    view=fileRcd.view,
+                                    type=fileRcd.type,
+                                    files= new List<FileAbility> { new FileAbility { url=fileRcd.url,abilityId=fileRcd.abilityId,taskId=fileRcd.taskId,nodeId=fileRcd.nodeId,done=fileRcd.done} }
+                                } },
+                            };
+                         await client.GetContainer("TEAMModelOS", "Teacher").CreateItemAsync<TeacherFile>(teacherFile, new PartitionKey($"TeacherFile-{_school}"));
+                        }
+                        return Ok(new { status, teacherFile });
                     case "ReadSelfVideoRcd":
                         //获取视频学习记录
                         return Ok(new { abilitySub.videoRcds });