CrazyIter_Bin 3 anni fa
parent
commit
2d10be5bf7

+ 4 - 0
TEAMModelFunction/MonitorServicesBus.cs

@@ -781,6 +781,7 @@ namespace TEAMModelFunction
         /// <returns></returns>
         [FunctionName("LessonRecordEvent")]
         public async Task LessonRecordFunc([ServiceBusTrigger("%Azure:ServiceBus:ActiveTask%", "lesson-record-event", Connection = "Azure:ServiceBus:ConnectionString")] string msg) {
+            
             JsonElement  data =  msg.ToObject<JsonElement>();
             if (!data.TryGetProperty("lesson_id", out JsonElement _lessonId)) return;
             if (!data.TryGetProperty("tmdid", out JsonElement _tmdid)) return ;
@@ -827,6 +828,7 @@ namespace TEAMModelFunction
                             case "up-tScore":
                                 var tScore = int.Parse($"{update.data}");
                                 lessonRecord.tScore = tScore;
+
                                 msgs.Add(update);
                                 break;
                             //更新课P分
@@ -863,6 +865,8 @@ namespace TEAMModelFunction
                                 break;
                         }
                     }
+
+
                   await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname).ReplaceItemAsync<LessonRecord>(lessonRecord,$"{_lessonId}", new PartitionKey(code));
                 }
             }

+ 32 - 2
TEAMModelFunction/ScsApisHttpTrigger.cs

@@ -287,6 +287,16 @@ namespace TEAMModelFunction
                             if (diagnoses.IsNotEmpty())
                             {
                                 projects.Add(new ScsProjectDiagnosis { project = ps, diagnoses = diagnoses });
+                                await _azureStorage.SaveOrUpdate<ScProjectDiagnosis>(new ScProjectDiagnosis { RowKey = $"{ps.pid}-{schoolCode}", PartitionKey = "ScSchoolDiagnosis", abilityNos = diagnoses.ToJsonString() });
+                            }
+                        }
+                        else
+                        {
+                            List<ScProjectDiagnosis> teacherDiagnoses = await _azureStorage.FindListByDict<ScProjectDiagnosis>(new Dictionary<string, object> { { "PartitionKey", "ScSchoolDiagnosis" }, { "RowKey", $"{ps.pid}-{schoolCode}" } });
+                            if (teacherDiagnoses.IsNotEmpty())
+                            {
+                                projects.Add(new ScsProjectDiagnosis { project = ps, diagnoses = teacherDiagnoses[0].abilityNos.ToObject<List<ScPDiagnosis>>() });
+
                             }
                         }
                         results.Add(result);
@@ -328,9 +338,19 @@ namespace TEAMModelFunction
                         result = await _thirdApisService.Post(config.url, Code, config.passKey, config.privateKey, parameterMap);
                         if (result.result)
                         {
-                            List<ScPDiagnosis> diagnoses  = result.content.ToObject<List<ScPDiagnosis>>();
-                            if (diagnoses.IsNotEmpty()) {
+                            List<ScPDiagnosis> diagnoses = result.content.ToObject<List<ScPDiagnosis>>();
+                            if (diagnoses.IsNotEmpty())
+                            {
                                 projects.Add(new ScsProjectDiagnosis { project = ps, diagnoses = diagnoses });
+                                await _azureStorage.SaveOrUpdate<ScProjectDiagnosis>(new ScProjectDiagnosis { RowKey = $"{ps.pid}", PartitionKey = "ScProjectDiagnosis", abilityNos = diagnoses.ToJsonString() });
+                            }
+                        }
+                        else {
+                            List<ScProjectDiagnosis> teacherDiagnoses = await _azureStorage.FindListByDict<ScProjectDiagnosis>(new Dictionary<string, object> { { "PartitionKey", "ScProjectDiagnosis" }, { "RowKey", $"{ps.pid}" } });
+                            if (teacherDiagnoses.IsNotEmpty())
+                            {
+                                projects.Add(new ScsProjectDiagnosis { project = ps, diagnoses  = teacherDiagnoses[0].abilityNos.ToObject<List<ScPDiagnosis>>() });
+                                
                             }
                         }
                         results.Add(result);
@@ -373,6 +393,16 @@ namespace TEAMModelFunction
                     {
                         abilityNos = diagnoses.Select(x => x.DiagnosisDicNum).ToList();
                     }
+                    if (abilityNos .IsNotEmpty()) {
+                        await _azureStorage.SaveOrUpdate<ScTeacherDiagnosis>(new ScTeacherDiagnosis { RowKey = $"{pxid}", PartitionKey = "ScTeacherDiagnosis",abilityNos=abilityNos.ToJsonString() });
+                    }
+                }
+                else {
+
+                    List<ScTeacherDiagnosis> teacherDiagnoses = await _azureStorage.FindListByDict<ScTeacherDiagnosis>(new Dictionary<string, object> { { "PartitionKey", "ScTeacherDiagnosis" },  { "RowKey", $"{pxid}" } });
+                    if (teacherDiagnoses.IsNotEmpty()) {
+                        abilityNos = teacherDiagnoses[0].abilityNos.ToObject<List<string>>();
+                    }
                 }
                 return new  OkObjectResult(new { data= abilityNos .ToJsonString()});
             }

+ 12 - 0
TEAMModelOS.SDK/Models/Service/Third/ScYxptModel.cs

@@ -16,6 +16,18 @@ namespace TEAMModelOS.SDK.Models
         public string accessConfig { get; set; }
         public string pxid { get; set; }
     }
+    [TableName(Name = "ScYxpt")]
+    public class ScTeacherDiagnosis :TableEntity
+    {
+       public string abilityNos { get; set; }
+    }
+
+    [TableName(Name = "ScYxpt")]
+    public class ScProjectDiagnosis : TableEntity
+    {
+        public string abilityNos { get; set; }
+        public string pd { get; set; }
+    }
     public class ScDiagnosis
     {
         public string diagnosisName { get; set; }

+ 10 - 2
TEAMModelOS/Controllers/Research/AbilitySubController.cs

@@ -266,7 +266,13 @@ namespace TEAMModelOS.Controllers
                                 from=from,
                                 currency = item.currency
                             };
-                            await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").CreateItemAsync(abilitySub, new PartitionKey(abilitySub.code));
+                            try
+                            {
+                                await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").CreateItemAsync(abilitySub, new PartitionKey(abilitySub.code));
+                            }
+                            catch (CosmosException ex) when (ex.Status == 409) {
+                                continue;
+                            }
                         }
                     }
                 }
@@ -835,7 +841,9 @@ namespace TEAMModelOS.Controllers
                                     file.hash = fileRcd.hash;
                                     file.view = fileRcd.view;
                                     file.done = fileRcd.done;
-                                    FileAbility ability = file.files.Find(x => x.abilityId.Equals(fileRcd.abilityId) && x.url.Equals(fileRcd.url) && x.taskId.Equals(fileRcd.taskId) && x.nodeId.Equals(fileRcd.nodeId));
+                                    FileAbility ability = file.files.Find(x => x.abilityId.Equals(fileRcd.abilityId) 
+                                    && x.url.Equals(fileRcd.url)// && x.taskId.Equals(fileRcd.taskId) 
+                                    && x.nodeId.Equals(fileRcd.nodeId));
                                     if (ability != null)
                                     {
                                         ability.url = fileRcd.url;

+ 23 - 6
TEAMModelOS/Controllers/Third/ScController.cs

@@ -893,12 +893,12 @@ namespace TEAMModelOS.Controllers.Third
                 }
                 string accessConfig = setting.accessConfig;
                 Dictionary<string, object> dict = new Dictionary<string, object> { { "accessConfig", accessConfig }, { "pxid", scsso.Pxid }, { "tid", scsso.tid } };
-                string SchoolName = "", SchoolID = "", ProjectID = "", ProjectItemID = "", TeacherName = "" , Account=""; 
+                string SchoolName = "", SchoolID = "", ProjectID = "", ProjectItemID = "", TeacherName = "" , Account="";
 
-                (int status, string json) = await _httpTrigger.RequestHttpTrigger(dict, _option.Location, "GetSingleTeacherByProject");
-                if (status == 200)
+                List<ScTeacher> scTeachers = await _azureStorage.FindListByDict<ScTeacher>(new Dictionary<string, object> { { "PartitionKey", "ScTeacher" }, { "TID", scsso.tid }, { "RowKey", $"{scsso.Pxid}" } });
+                if (scTeachers.IsNotEmpty())
                 {
-                    ScTeacher scTeacher = json.ToObject<ScTeacher>(new JsonSerializerOptions { PropertyNameCaseInsensitive = false });
+                    ScTeacher scTeacher = scTeachers[0];
                     if (scTeacher != null && $"{scTeacher.PXID}".Equals(scsso.Pxid) && $"{scTeacher.TID}".Equals(scsso.tid))
                     {
                         SchoolName = scTeacher.SchoolName;
@@ -909,8 +909,25 @@ namespace TEAMModelOS.Controllers.Third
                         Account = $"{ scTeacher.Account}";
                     }
                 }
-                else {
-                    await _dingDing.SendBotMsg($"OS,{_option.Location}\n省平台教师信息:\nstatus:{status}{json}\n{dict.ToJsonString()} \nGetSingleTeacherByProject", GroupNames.成都开发測試群組);
+                if (string.IsNullOrEmpty(SchoolID)) {
+                    (int status, string json) = await _httpTrigger.RequestHttpTrigger(dict, _option.Location, "GetSingleTeacherByProject");
+                    if (status == 200)
+                    {
+                        ScTeacher scTeacher = json.ToObject<ScTeacher>(new JsonSerializerOptions { PropertyNameCaseInsensitive = false });
+                        if (scTeacher != null && $"{scTeacher.PXID}".Equals(scsso.Pxid) && $"{scTeacher.TID}".Equals(scsso.tid))
+                        {
+                            SchoolName = scTeacher.SchoolName;
+                            SchoolID = $"{scTeacher.SchoolID}";
+                            ProjectID = $"{ scTeacher.ProjectID}";
+                            ProjectItemID = $"{ scTeacher.ProjectItemID}";
+                            TeacherName = $"{ scTeacher.TeacherName}";
+                            Account = $"{ scTeacher.Account}";
+                        }
+                    }
+                    else
+                    {
+                        await _dingDing.SendBotMsg($"OS,{_option.Location}\n省平台教师信息:\nstatus:{status}{json}\n{dict.ToJsonString()} \nGetSingleTeacherByProject", GroupNames.成都开发測試群組);
+                    }
                 }
                 ScBindData bindData = new ScBindData
                 {

+ 1 - 1
TEAMModelOS/appsettings.Development.json

@@ -46,7 +46,7 @@
       "ConnectionString": "CoreRedisCN.redis.cache.chinacloudapi.cn:6380,password=LyJWP1ORJdv+poXWofAF97lhCEQPg1wXWqvtzXGXQuE=,ssl=True,abortConnect=False"
     },
     "ServiceBus": {
-      "ConnectionString": "Endpoint=sb://teammodelos.servicebus.chinacloudapi.cn/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=Sy4h4EQ8zP+7w/lOLi1X3tGord/7ShFHimHs1vC50Dc=",
+      "ConnectionString": "Endpoint=sb://coreiotservicebuscnpro.servicebus.chinacloudapi.cn/;SharedAccessKeyName=TEAMModelOS;SharedAccessKey=llRPBMDJG9w1Nnifj+pGhV0g4H2REcq0PjvX2qqpcOg=",
       "ActiveTask": "active-task",
       "NoticeTask": "notice-task",
       "ItemCondQueue": "itemcond"

+ 1 - 1
TEAMModelOS/appsettings.json

@@ -34,7 +34,7 @@
       "ConnectionString": "CoreRedisCN.redis.cache.chinacloudapi.cn:6380,password=LyJWP1ORJdv+poXWofAF97lhCEQPg1wXWqvtzXGXQuE=,ssl=True,abortConnect=False"
     },
     "ServiceBus": {
-      "ConnectionString": "Endpoint=sb://teammodelos.servicebus.chinacloudapi.cn/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=Sy4h4EQ8zP+7w/lOLi1X3tGord/7ShFHimHs1vC50Dc=",
+      "ConnectionString": "Endpoint=sb://coreiotservicebuscnpro.servicebus.chinacloudapi.cn/;SharedAccessKeyName=TEAMModelOS;SharedAccessKey=llRPBMDJG9w1Nnifj+pGhV0g4H2REcq0PjvX2qqpcOg=",
       "ActiveTask": "active-task",
       "NoticeTask": "notice-task"
     }