Browse Source

将研修平台Function函数,改成异步方法,并修改相关调用方式

Li 2 years ago
parent
commit
daf86197f0

+ 1 - 1
TEAMModelOS.SDK/DI/StudyAPI/ScsStudyApisService.cs

@@ -518,7 +518,7 @@ namespace TEAMModelOS.SDK.DI
         /// <param name="school"></param>
         /// <param name="pushTeachers"></param>
         /// <returns></returns>
-        public async Task<(int state, string json)> SchoolDataPush(string areaId, string accessConfig, string school, List<string> pushTeachers)
+        public async Task<(int state, string json)> SchoolDataPush(string accessConfig, string school, List<string> pushTeachers)
         {
             dynamic dynamic = null;
             ScAccessConfig config = accessConfig.ToObject<JsonElement>().ToObject<ScAccessConfig>();

+ 3 - 2
TEAMModelOS.SDK/Models/Service/Third/ThirdService.cs

@@ -289,13 +289,14 @@ namespace TEAMModelOS.SDK.Models
             return abilities;
         }
 
-        public static async Task<string> SchoolDataPush(  AreaSetting setting, HttpTrigger httpTrigger, List<string> pushTeachers, Option _option, string school)
+        public static async Task<string> SchoolDataPush( AreaSetting setting, ScsStudyApisService _scsStudyApisService, List<string> pushTeachers, Option _option, string school)
         {
             setting.accessConfig.ToObject<JsonElement>().TryGetProperty("config", out JsonElement _config);
             if ($"{_config}".Equals("scsyxpt")) {
 
                 Dictionary<string, object> dict = new Dictionary<string, object>() { { "accessConfig", setting.accessConfig }, { "pushTeachers", pushTeachers }, { "school", school } };
-                (int status, string json) = await httpTrigger.RequestHttpTrigger(dict, _option.Location, "SchoolDataPush");
+                //(int status, string json) = await httpTrigger.RequestHttpTrigger(dict, _option.Location, "SchoolDataPush");
+                (int status, string json) = await _scsStudyApisService.SchoolDataPush(setting.accessConfig, school, pushTeachers);
                 return json;
             }
             return null ;

+ 4 - 2
TEAMModelOS/Controllers/Normal/AbilityStatisticsController.cs

@@ -41,7 +41,8 @@ namespace TEAMModelOS.Controllers
         private readonly AzureStorageFactory _azureStorage;
         public IConfiguration _configuration { get; set; }
         private readonly AzureServiceBusFactory _serviceBus;
-        public AbilityStatisticsController(AzureStorageFactory azureStorage, HttpTrigger httpTrigger, CoreAPIHttpService coreAPIHttpService, AzureCosmosFactory azureCosmos, SnowflakeId snowflakeId, DingDing dingDing, IOptionsSnapshot<Option> option,
+        private readonly ScsStudyApisService _scsStudyApisService;
+        public AbilityStatisticsController(ScsStudyApisService scsStudyApisService, AzureStorageFactory azureStorage, HttpTrigger httpTrigger, CoreAPIHttpService coreAPIHttpService, AzureCosmosFactory azureCosmos, SnowflakeId snowflakeId, DingDing dingDing, IOptionsSnapshot<Option> option,
             AzureServiceBusFactory serviceBus, IConfiguration configuration)
         {
             _azureCosmos = azureCosmos;
@@ -52,6 +53,7 @@ namespace TEAMModelOS.Controllers
             _azureStorage = azureStorage; 
             _serviceBus = serviceBus;
             _configuration = configuration;
+            _scsStudyApisService = scsStudyApisService;
         }
         /// <summary>
         /// 更新教师最终学习分数。
@@ -662,7 +664,7 @@ namespace TEAMModelOS.Controllers
             School school= await client.GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<School>($"{_school}",new PartitionKey("Base"));
             if (setting.id.Equals($"{school.areaId}"))
             {
-                string  json = await ThirdService.SchoolDataPush(setting, _httpTrigger, pushTeachers, _option, $"{_school}");
+                string  json = await ThirdService.SchoolDataPush(setting, _scsStudyApisService, pushTeachers, _option, $"{_school}");
                 if (!string.IsNullOrWhiteSpace(json)) {
                     JsonElement element = json.ToObject<JsonElement>();
                     return Ok(new { element });

+ 5 - 2
TEAMModelOS/Controllers/Third/Sc/ScController.cs

@@ -57,9 +57,10 @@ namespace TEAMModelOS.Controllers
         public readonly string type = "scsyxpt";
         private readonly HttpTrigger _httpTrigger;
         private readonly IWebHostEnvironment _environment;
+        private readonly ScsStudyApisService _scsStudyApisService;
 
         public IConfiguration _configuration { get; set; }
-        public ScController(IWebHostEnvironment environment, AzureCosmosFactory azureCosmos, SnowflakeId snowflakeId, DingDing dingDing, IOptionsSnapshot<Option> option, AzureStorageFactory azureStorage,
+        public ScController(ScsStudyApisService scsStudyApisService, IWebHostEnvironment environment, AzureCosmosFactory azureCosmos, SnowflakeId snowflakeId, DingDing dingDing, IOptionsSnapshot<Option> option, AzureStorageFactory azureStorage,
           AzureRedisFactory azureRedis, AzureServiceBusFactory serviceBus, IConfiguration configuration, CoreAPIHttpService coreAPIHttpService, ThirdApisService scsApisService, HttpTrigger httpTrigger)
         {
             _azureCosmos = azureCosmos;
@@ -74,6 +75,7 @@ namespace TEAMModelOS.Controllers
             _scsApisService = scsApisService;
             _httpTrigger = httpTrigger;
             _environment = environment;
+            _scsStudyApisService = scsStudyApisService;
         }
 
         /// <summary>
@@ -603,7 +605,8 @@ namespace TEAMModelOS.Controllers
                 }
                 if (string.IsNullOrWhiteSpace(SchoolID))
                 {
-                    (int status, string json) = await _httpTrigger.RequestHttpTrigger(dict, _option.Location, "GetSingleTeacherByProject");
+                    //(int status, string json) = await _httpTrigger.RequestHttpTrigger(dict, _option.Location, "GetSingleTeacherByProject");
+                    (int status, string json) = await _scsStudyApisService.GetSingleTeacherByProject(setting.id, accessConfig, scsso.Pxid, scsso.tid);
                     if (status == 200)
                     {
                         ScTeacher scTeacher = json.ToObject<ScTeacher>(new JsonSerializerOptions { PropertyNameCaseInsensitive = false });

+ 10 - 6
TEAMModelOS/Controllers/Third/Sc/ScDataInitController.cs

@@ -223,7 +223,8 @@ namespace TEAMModelOS.Controllers.Third
             var ScSchools = await table.FindListByDict<ScSchool>(new Dictionary<string, object>() { { "PartitionKey", "ScSchool" }, { "areaId", $"{areaId}" } });
             Dictionary<string, object> dict = new Dictionary<string, object> { { "accessConfig", $"{accessConfig}" }, { "areaId", $"{areaId}" } };
             //获取当前期,所有区所有学校的教师
-            (int status, string json) = await _httpTrigger.RequestHttpTrigger(dict, _option.Location, "GetTeachersListByProject");
+            //(int status, string json) = await _httpTrigger.RequestHttpTrigger(dict, _option.Location, "GetTeachersListByProject");
+            (int status, string json) = await _scsStudyApisService.GetTeachersListByProject($"{areaId}", $"{accessConfig}");
             //序列化
             List<ScTeacher> teachers = json.ToObject<List<ScTeacher>>(new JsonSerializerOptions { PropertyNameCaseInsensitive = false });
             // 处理省平台后补的教师,教师的学校不在当前区的学校列表中。
@@ -329,7 +330,8 @@ namespace TEAMModelOS.Controllers.Third
             var ScTeachers = await table.FindListByDict<ScTeacher>(new Dictionary<string, object>() { { "PartitionKey", "ScTeacher" }, { "areaId", $"{areaId}" } });
             var ScSchools = await table.FindListByDict<ScSchool>(new Dictionary<string, object>() { { "PartitionKey", "ScSchool" }, { "areaId", $"{areaId}" } });
             Dictionary<string, object> dict = new Dictionary<string, object> { { "accessConfig", $"{accessConfig}" }, { "areaId", $"{areaId}" } };
-            (int status, string json) = await _httpTrigger.RequestHttpTrigger(dict, _option.Location, "GetTeachersListByProject");
+            //(int status, string json) = await _httpTrigger.RequestHttpTrigger(dict, _option.Location, "GetTeachersListByProject");
+            (int status, string json) = await _scsStudyApisService.GetTeachersListByProject($"{areaId}", $"{accessConfig}");
             ///
             var teachers = json.ToObject<List<ScTeacher>>(new JsonSerializerOptions { PropertyNameCaseInsensitive = false });
             // 处理省平台后补的教师,教师的学校不在当前区的学校列表中。
@@ -545,7 +547,8 @@ namespace TEAMModelOS.Controllers.Third
             {
                 ignore.Add(item);
             }
-            (status, json) = await _httpTrigger.RequestHttpTrigger(dict, _option.Location, "GetSchoolList");
+            //(status, json) = await _httpTrigger.RequestHttpTrigger(dict, _option.Location, "GetSchoolList");
+            (status, json) = await _scsStudyApisService.GetSchoolList($"{areaId}", $"{accessConfig}");
             if (status == 200)
             {
                 schools = json.ToObject<List<ScSchool>>(new JsonSerializerOptions { PropertyNameCaseInsensitive = false });
@@ -611,9 +614,9 @@ namespace TEAMModelOS.Controllers.Third
             Dictionary<string, object> dict = new Dictionary<string, object> { { "accessConfig", $"{accessConfig}" }, { "areaId", $"{areaId}" } };
             int status = -1; string json = null;
             //5.3.1.1获取项目列表
-            (status, json) = await _httpTrigger.RequestHttpTrigger(dict, _option.Location, "GetProjectInfoByTrainComID");
+            //(status, json) = await _httpTrigger.RequestHttpTrigger(dict, _option.Location, "GetProjectInfoByTrainComID");
             //新的方式  5.3.1.1获取项目列表
-            //(status, json) = await _scsStudyApisService.GetProjectInfoByTrainComID($"{areaId}", $"{accessConfig}"); 
+            (status, json) = await _scsStudyApisService.GetProjectInfoByTrainComID($"{areaId}", $"{accessConfig}"); 
             List<ScProject> projects = null;
             List<ScSchool> saveschools = null;
             List<ScSchool> schools = null;
@@ -626,7 +629,8 @@ namespace TEAMModelOS.Controllers.Third
             var table = _azureStorage.GetCloudTableClient().GetTableReference("ScYxpt");
 
             // 5.3.1.18根据机构ID、项目ID、子项目ID返回学校列表
-            (status, json) = await _httpTrigger.RequestHttpTrigger(dict, _option.Location, "GetSchoolList");           
+            //(status, json) = await _httpTrigger.RequestHttpTrigger(dict, _option.Location, "GetSchoolList");
+            (status, json) = await _scsStudyApisService.GetSchoolList($"{areaId}", $"{accessConfig}");
             if (status == 200)
             {               
                 schools = json.ToObject<List<ScSchool>>(new JsonSerializerOptions { PropertyNameCaseInsensitive = false });

File diff suppressed because it is too large
+ 10 - 4
TEAMModelOS/Controllers/XTest/FixDataController.cs