Bladeren bron

update 错题调整以及杉达接口

zhouj1203@hotmail.com 2 jaren geleden
bovenliggende
commit
5ea059d264

+ 11 - 8
TEAMModelOS.FunctionV4/CosmosDB/TriggerExam.cs

@@ -1465,9 +1465,10 @@ namespace TEAMModelOS.FunctionV4
                     table = "Teacher";
                     table = "Teacher";
                 }
                 }
                 // 获取整体的题目ID集合
                 // 获取整体的题目ID集合
-               /* List<string> ids = new();
-                List<(string id, string pid, int level, string type)> itemInfos = new();
-                foreach (string url in urls) {
+                List<string> ids = new();
+                List<(string id, string pid, int level, string type, List<string> knows)> itemInfos = new();
+                foreach (string url in urls)
+                {
                     string id = url.Replace(".json", "");
                     string id = url.Replace(".json", "");
                     BlobDownloadResult index_item_json;
                     BlobDownloadResult index_item_json;
                     if (info.scope.Equals("school"))
                     if (info.scope.Equals("school"))
@@ -1479,11 +1480,12 @@ namespace TEAMModelOS.FunctionV4
                         index_item_json = await _azureStorage.GetBlobContainerClient($"{info.creatorId}").GetBlobClient($"{info.papers[no].blob}/{url}").DownloadContentAsync();
                         index_item_json = await _azureStorage.GetBlobContainerClient($"{info.creatorId}").GetBlobClient($"{info.papers[no].blob}/{url}").DownloadContentAsync();
                     }
                     }
                     JObject keys = JObject.Parse(index_item_json.Content.ToString());
                     JObject keys = JObject.Parse(index_item_json.Content.ToString());
-                    string type =  keys["exercise"].Value<string>("type");
+                    string type = keys["exercise"].Value<string>("type");
                     int level = keys["exercise"].Value<int>("level");
                     int level = keys["exercise"].Value<int>("level");
+                    var knowledge = keys["exercise"].Value<List<string>>("knowledge");
                     string pid = keys.Value<string>("pid");
                     string pid = keys.Value<string>("pid");
-                    itemInfos.Add((id,pid,level,type));
-                }*/
+                    itemInfos.Add((id, pid, level, type, knowledge));
+                }
 
 
 
 
                 /*await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, table).GetItemQueryStreamIterator(
                 /*await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, table).GetItemQueryStreamIterator(
@@ -1536,9 +1538,10 @@ namespace TEAMModelOS.FunctionV4
                             blob = info.papers[no].blob
                             blob = info.papers[no].blob
                            
                            
                         };
                         };
-                      /*  items.level = itemInfos.Where(c => c.id.Equals(items.id)).FirstOrDefault().level;
+                        items.level = itemInfos.Where(c => c.id.Equals(items.id)).FirstOrDefault().level;
                         items.type = itemInfos.Where(c => c.id.Equals(items.id)).FirstOrDefault().type;
                         items.type = itemInfos.Where(c => c.id.Equals(items.id)).FirstOrDefault().type;
-                        items.pId = itemInfos.Where(c => c.id.Equals(items.id)).FirstOrDefault().pid;*/
+                        items.pId = itemInfos.Where(c => c.id.Equals(items.id)).FirstOrDefault().pid;
+                        items.knowledge = itemInfos.Where(c => c.id.Equals(items.id)).FirstOrDefault().knows;
                         error.its.Add(items);
                         error.its.Add(items);
                     }
                     }
                     n++;
                     n++;

+ 1 - 0
TEAMModelOS.SDK/Models/Cosmos/Student/ErrorItems.cs

@@ -29,6 +29,7 @@ namespace TEAMModelOS.SDK.Models.Cosmos.Student
         public string blob { get; set; }
         public string blob { get; set; }
         public int level { get; set; }
         public int level { get; set; }
         public string type { get; set; }
         public string type { get; set; }
+        public List<string> knowledge { get; set; } = new();
         //如果是小题则会存在大题ID
         //如果是小题则会存在大题ID
         public string pId { get; set; }     
         public string pId { get; set; }     
         //熟练度 后续扩展
         //熟练度 后续扩展

+ 1 - 0
TEAMModelOS/Controllers/Analysis/ClassAnalysisController.cs

@@ -663,6 +663,7 @@ namespace TEAMModelOS.Controllers.Analysis
                         sc = json.ToObject<School>();
                         sc = json.ToObject<School>();
                     }
                     }
                     List<(string time, double count)> counts = new()
                     List<(string time, double count)> counts = new()
+
                     {
                     {
                         ("total", records.Count),
                         ("total", records.Count),
                         ("today", records.Where(c => c.startTime >= tt && c.startTime <= endtime).ToList().Count),
                         ("today", records.Where(c => c.startTime >= tt && c.startTime <= endtime).ToList().Count),

+ 14 - 1
TEAMModelOS/Controllers/OpenApi/Business/BizCustomizeController.cs

@@ -23,6 +23,7 @@ using TEAMModelOS.SDK.Models.Cosmos.Common;
 using DocumentFormat.OpenXml.Office2016.Excel;
 using DocumentFormat.OpenXml.Office2016.Excel;
 using DocumentFormat.OpenXml.Wordprocessing;
 using DocumentFormat.OpenXml.Wordprocessing;
 using TEAMModelOS.Controllers.Analysis;
 using TEAMModelOS.Controllers.Analysis;
+using System.Net.Http;
 
 
 namespace TEAMModelOS.Controllers
 namespace TEAMModelOS.Controllers
 {  /// <summary>
 {  /// <summary>
@@ -41,8 +42,9 @@ namespace TEAMModelOS.Controllers
         private readonly CoreAPIHttpService _coreAPIHttpService;
         private readonly CoreAPIHttpService _coreAPIHttpService;
         private readonly AzureServiceBusFactory _serviceBus;
         private readonly AzureServiceBusFactory _serviceBus;
         private readonly SnowflakeId _snowflakeId;
         private readonly SnowflakeId _snowflakeId;
+        private readonly IHttpClientFactory _httpClient;
 
 
-        public BizCustomizeController(AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis, AzureServiceBusFactory serviceBus, DingDing dingDing, CoreAPIHttpService coreAPIHttpService, IOptionsSnapshot<Option> option, IConfiguration configuration, SnowflakeId snowflakeId)
+        public BizCustomizeController(AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis, AzureServiceBusFactory serviceBus, DingDing dingDing, CoreAPIHttpService coreAPIHttpService, IOptionsSnapshot<Option> option, IConfiguration configuration, SnowflakeId snowflakeId, IHttpClientFactory httpClient)
         {
         {
             _azureCosmos = azureCosmos;
             _azureCosmos = azureCosmos;
             _azureStorage = azureStorage;
             _azureStorage = azureStorage;
@@ -53,6 +55,7 @@ namespace TEAMModelOS.Controllers
             _coreAPIHttpService = coreAPIHttpService;
             _coreAPIHttpService = coreAPIHttpService;
             _serviceBus = serviceBus;
             _serviceBus = serviceBus;
             _snowflakeId = snowflakeId;
             _snowflakeId = snowflakeId;
+            _httpClient = httpClient;
         }
         }
         //shasdu
         //shasdu
         #region  杉达公司
         #region  杉达公司
@@ -422,6 +425,16 @@ namespace TEAMModelOS.Controllers
 
 
         }
         }
 
 
+        [ProducesDefaultResponseType]
+        [HttpPost("get-analysis-course")]
+        [ApiToken(Auth = "2008", Name = "分析课列", TName = "结算课列科技应用", EName = "application of accounting technology", RWN = "R", Limit = false)]
+        public async Task<IActionResult> GetAnalysisCourse(JsonElement json)
+        {
+            var (id, school) = HttpContext.GetApiTokenInfo();
+            var responseData = await OpenApiService.getCourseTechnology(_httpClient, _dingDing, id, school, json);
+            return Ok(new { responseData });
+        }
+
         #endregion
         #endregion
 
 
         #region 智音公司
         #region 智音公司

+ 59 - 2
TEAMModelOS/Controllers/OpenApi/OpenApiService.cs

@@ -23,7 +23,6 @@ using TEAMModelOS.SDK.Helper.Common.ReflectorExtensions;
 using TEAMModelOS.SDK.Context.Constant;
 using TEAMModelOS.SDK.Context.Constant;
 using TEAMModelOS.SDK.Models.Dtos;
 using TEAMModelOS.SDK.Models.Dtos;
 using TEAMModelOS.SDK.Services;
 using TEAMModelOS.SDK.Services;
-using TEAMModelOS.SDK.DI;
 using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.Configuration;
 using Azure.Messaging.ServiceBus;
 using Azure.Messaging.ServiceBus;
 using TEAMModelOS.Models;
 using TEAMModelOS.Models;
@@ -38,6 +37,13 @@ using System.IdentityModel.Tokens.Jwt;
 using TEAMModelOS.SDK.Models.Cosmos.OpenEntity;
 using TEAMModelOS.SDK.Models.Cosmos.OpenEntity;
 using Microsoft.OData.UriParser;
 using Microsoft.OData.UriParser;
 using FastJSON;
 using FastJSON;
+using Azure.Core;
+using System.Security.Policy;
+using System.Net.Http.Json;
+using System.Drawing;
+using Microsoft.AspNetCore.DataProtection;
+using Newtonsoft.Json.Linq;
+using DocumentFormat.OpenXml.Drawing.Charts;
 
 
 namespace TEAMModelOS.Controllers
 namespace TEAMModelOS.Controllers
 {
 {
@@ -726,6 +732,51 @@ namespace TEAMModelOS.Controllers
             }
             }
         }
         }
 
 
+        public static async Task<ResponseData<dynamic>> getCourseTechnology(IHttpClientFactory _httpClient, DingDing _dingDing, string bizId, string school, JsonElement json)
+        {
+            try
+            {
+                _httpClient.CreateClient().DefaultRequestHeaders.Add("ContentLength", "0");
+                HttpContent httpContent = new StringContent(new { method = "statistic/data/" }.ToJsonString());
+                /*Dictionary<string, object> data = new Dictionary<string, object>();
+                data.Add("method", "statistic/data/");*/
+                //data.Add("params", new { method = "statistic/data/"});
+                //HttpResponseMessage responseMessage = await _httpClient.CreateClient().PostAsJsonAsync("http://116.204.72.199:81/statistic/data/", data);
+                var response = await _httpClient.CreateClient().PostAsync("http://116.204.72.199:81/statistic/data/", httpContent);
+                List<Events> events = new();
+                if (response.IsSuccessStatusCode)
+                {
+                    string responseBody = response.Content.ReadAsStringAsync().Result;
+                    JObject jo = JObject.Parse(responseBody.ToString());
+                    JArray array = jo.Value<JArray>("base");
+                    foreach (var ne in array)
+                    {
+                        var obj = ne["events"].ToObject<List<Events>>();
+                        //events.Add(obj);
+                        events.AddRange(obj);
+                    }
+                    /*using JsonDocument document = JsonDocument.Parse(responseBody.ToString());
+                    if (document.RootElement.TryGetProperty("base", out JsonElement AccessTokenObj))
+                    {
+                        //AccessToken = AccessTokenObj.ToString();
+                    }*/
+                }
+                return new ResponseData<dynamic>() { code = RespondCode.Ok, msg = "成功", data = new { events } };
+                /*if (period != null)
+                {
+                    return new ResponseData<dynamic>() { code = RespondCode.Ok, msg = "成功", data = new { period.subjects, period.timetable, period.grades, period.majors, weekDays } };
+                }
+                else
+                    return new ResponseData<dynamic>() { code = RespondCode.NotFound, msg = "未找到相关课程" };*/
+
+            }
+            catch (Exception ex)
+            {
+                await _dingDing.SendBotMsg($"OpenApi,{Environment.GetEnvironmentVariable("Option:Location")} OpenApiService/getCourseTechnology()   参数:bizId:{bizId},school:{school},json:{json.ToJsonString()} \n  {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
+                return new ResponseData<dynamic>() { code = RespondCode.Error, msg = "服务端异常" };
+            }
+        }
+        
         /// <summary>
         /// <summary>
         /// 物理教室列表
         /// 物理教室列表
         /// [ApiToken(Auth = "1401", Name = "物理教室列表",TName ="",EName ="", RWN = "R", Limit = false)]
         /// [ApiToken(Auth = "1401", Name = "物理教室列表",TName ="",EName ="", RWN = "R", Limit = false)]
@@ -1880,6 +1931,12 @@ namespace TEAMModelOS.Controllers
                 await _dingDing.SendBotMsg($"OpenApi,{Environment.GetEnvironmentVariable("Option:Location")} OpenApiService/GetLoginStuInfo()   参数:学生id集合:{_ids},school:{school},json:{json.ToJsonString()} \n  {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
                 await _dingDing.SendBotMsg($"OpenApi,{Environment.GetEnvironmentVariable("Option:Location")} OpenApiService/GetLoginStuInfo()   参数:学生id集合:{_ids},school:{school},json:{json.ToJsonString()} \n  {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
                 return new ResponseData<dynamic>() { code = RespondCode.Error, msg = "服务器错误" };
                 return new ResponseData<dynamic>() { code = RespondCode.Error, msg = "服务器错误" };
             }
             }
-        }
+        }     
+    }
+    public class Events
+    {
+        public string @event { get; set; }
+        public int freq { get; set; }
+        public long createTime { get; set; }
     }
     }
 }
 }