فهرست منبع

处理。省平台,研修小组平。

CrazyIter_Bin 3 سال پیش
والد
کامیت
832c55b3a9

+ 85 - 0
TEAMModelFunction/ScsApisHttpTrigger.cs

@@ -0,0 +1,85 @@
+using System;
+using System.IO;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Azure.WebJobs;
+using Microsoft.Azure.WebJobs.Extensions.Http;
+using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.Logging;
+using TEAMModelOS.SDK.DI;
+using Azure.Cosmos;
+using System.Text.Json;
+using System.Collections.Generic;
+using TEAMModelOS.SDK.Models;
+using TEAMModelOS.SDK.Extension;
+using TEAMModelOS.SDK;
+using TEAMModelOS.SDK.Models.Cosmos;
+using TEAMModelOS.SDK.Models.Cosmos.Common;
+using System.Linq;
+using TEAMModelOS.Services.Common;
+using TEAMModelOS.SDK.Models.Service;
+using HTEXLib.COMM.Helpers;
+
+
+namespace TEAMModelFunction
+{
+    public class ScsApisHttpTrigger
+    {
+        private readonly AzureCosmosFactory _azureCosmos;
+        private readonly DingDing _dingDing;
+        private readonly AzureStorageFactory _azureStorage;
+        private readonly AzureRedisFactory _azureRedis;
+        private readonly ThirdApisService _thirdApisService;
+        public static string Code { get; set; }
+        public static Dictionary<string, object> parameterMap = null;
+        public ScsApisHttpTrigger(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, ThirdApisService thirdApisService
+             , AzureRedisFactory azureRedis)
+        {
+            _azureCosmos = azureCosmos;
+            _dingDing = dingDing;
+            _azureStorage = azureStorage;
+            _azureRedis = azureRedis;
+            _thirdApisService = thirdApisService;
+        }
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="req"></param>
+        /// <param name="log"></param>
+        /// <returns></returns>
+        [FunctionName("GetDiagnosisListByProject_V2")]
+        public async Task<IActionResult> GetDiagnosisListByProject_V2([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequest req, ILogger log) {
+            List<string> abilityNos = null;
+            string data = await new StreamReader(req.Body).ReadToEndAsync();
+            JsonElement accessConfig=  data.ToObject<JsonElement>().GetProperty("accessConfig");
+            JsonElement pxid = data.ToObject<JsonElement>().GetProperty("pxid");
+            ScAccessConfig config = $"{accessConfig}".ToObject<ScAccessConfig>();
+            Code = "GetDiagnosisListByProject_V2";
+            parameterMap = new Dictionary<string, object>();
+            parameterMap.Add("TrainComID", config.trainComID);
+            //parameterMap.Add("ProjectID", "22");
+            //parameterMap.Add("ProjectItemID", "22");
+            parameterMap.Add("PXID", pxid);
+            ScsResult result = new ScsResult { code = Code, title = "5.3.1.3通过项目编号获取学员测评能力项V2" };
+
+            try
+            {
+                result = await _thirdApisService.Post(config.url, Code, config.passKey, config.privateKey, parameterMap);
+                if (result.result)
+                {
+                    List<ScDiagnosis> diagnoses = result.content.ToObject<List<ScDiagnosis>>();
+                    if (diagnoses != null)
+                    {
+                        abilityNos = diagnoses.Select(x => x.DiagnosisDicNum).ToList();
+                    }
+                }
+                return new  OkObjectResult(abilityNos);
+            }
+            catch (Exception ex)
+            {
+                await _dingDing.SendBotMsg($"IES5.ScApisService:getDiagnosisListByProject_V2\n{ex.Message}{ex.StackTrace}\n{result.ToJsonString()}", GroupNames.成都开发測試群組);
+                return new OkObjectResult(abilityNos);
+            }
+        }
+    }
+}

+ 2 - 0
TEAMModelFunction/Startup.cs

@@ -7,6 +7,7 @@ using System.Configuration;
 using System.IO;
 using System.Reflection;
 using System.Text;
+using TEAMModelOS.SDK;
 using TEAMModelOS.SDK.DI;
 
 [assembly: FunctionsStartup(typeof(TEAMModelFunction.Startup))]
@@ -18,6 +19,7 @@ namespace TEAMModelFunction
         { 
             builder.Services.AddHttpClient();
             builder.Services.AddHttpClient<DingDing>();
+            builder.Services.AddHttpClient<ThirdApisService>();
             builder.Services.AddAzureServiceBus(Environment.GetEnvironmentVariable("Azure:ServiceBus:ConnectionString"));
             builder.Services.AddAzureStorage(Environment.GetEnvironmentVariable("Azure:Storage:ConnectionString"));
             builder.Services.AddAzureCosmos(Environment.GetEnvironmentVariable("Azure:Cosmos:ConnectionString"));

+ 10 - 0
TEAMModelOS.SDK/Models/Cosmos/Common/Homework.cs

@@ -97,7 +97,17 @@ namespace TEAMModelOS.SDK.Models
         public int? status { get; set; } = 0;
         public long? size { get; set; } = 0;
         public string areaId { get; set; }
+        /// <summary>
+        /// 是否允许补交。
+        /// </summary>
         public bool allowSupply { get; set; }
+        /// <summary>
+        /// 是否允许组长提交。
+        /// </summary>
+        public bool leaderSubmit { get; set; }
+        /// <summary>
+        /// 是否允许互评
+        /// </summary>
         public bool allowComment { get; set; }
         public List<string> extLimit { get; set; } = new List<string>();
         public List<Attachment> attachments { get; set; } = new List<Attachment>();

+ 66 - 0
TEAMModelOS.SDK/Models/Service/Third/ScApisService.cs

@@ -0,0 +1,66 @@
+using Azure.Cosmos;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using TEAMModelOS.SDK.DI;
+using TEAMModelOS.SDK.Extension;
+using TEAMModelOS.SDK.Models;
+
+namespace TEAMModelOS.SDK
+{
+    public  static class ScApisService
+    {
+        public static string Code { get; set; }
+        public static Dictionary<string, object> parameterMap = null;
+        public static async Task<List<string>> GetDiagnosisListByProject_V2( string setting,  string PXID) {
+            ScAccessConfig config = setting.ToObject<ScAccessConfig>();
+            List<string> abilityNos = null;
+            Code = "GetDiagnosisListByProject_V2";
+            parameterMap = new Dictionary<string, object>();
+            parameterMap.Add("TrainComID", config.trainComID);
+            //parameterMap.Add("ProjectID", "22");
+            //parameterMap.Add("ProjectItemID", "22");
+            parameterMap.Add("PXID", PXID);
+            ScsResult result = new ScsResult {code=Code,title= "5.3.1.3通过项目编号获取学员测评能力项V2" };
+
+            try {
+               // result = await _thirdApisService.Post(config.url, Code, config.passKey, config.privateKey, parameterMap);
+                if (result.result)
+                {
+                    List<ScDiagnosis> diagnoses = result.content.ToObject<List<ScDiagnosis>>();
+                    if (diagnoses != null)
+                    {
+                        abilityNos = diagnoses.Select(x => x.DiagnosisDicNum).ToList();
+                    }
+                }
+                return abilityNos;
+            } catch (Exception ex) {
+                //await dingDing.SendBotMsg($"IES5.ScApisService:getDiagnosisListByProject_V2\n{ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
+                return abilityNos;
+            }
+        }
+    }
+    public class ScDiagnosis
+    {
+        public string diagnosisName { get; set; }
+        public string DiagnosisDicNum { get; set; }
+        public string ID { get; set; }
+    }
+    public class ScAccessConfig
+    {
+        public string passKey { get; set; }
+        public string trainComID { get; set; }
+        public string privateKey { get; set; }
+        public string url { get; set; }
+    }
+    public class ScsResult
+    {
+        public bool result { get; set; }
+        public string reason { get; set; }
+        public string content { get; set; }
+        public string code { get; set; }
+        public string title { get; set; }
+    }
+}

+ 65 - 0
TEAMModelOS.SDK/Models/Service/Third/ThirdApisService.cs

@@ -0,0 +1,65 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Net.Http.Json;
+using System.Text;
+using System.Threading.Tasks;
+using TEAMModelOS.SDK;
+using TEAMModelOS.SDK.Extension;
+
+namespace TEAMModelOS.SDK
+{
+    public class ThirdApisService
+    {
+       
+        private readonly HttpClient _httpClient;
+        public ThirdApisService(HttpClient httpClient)
+        {
+            _httpClient = httpClient;
+        }
+        public async   Task<ScsResult> Post(string url, string Code, string PassKey,string privateKey, Dictionary<string ,object> data)
+        {
+
+            try {
+                string Content = AESHelper.AESEncrypt(data.ToJsonString(), privateKey);
+                string paramStr = "Code={0}&PassKey={1}&Content={2}";
+                string sendMsg = string.Format(paramStr, Code, PassKey, Content);
+                #region 签名 Signature
+                SortedDictionary<string, string> signatureDC = new SortedDictionary<string, string>();
+                var timeSpan = (DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0));
+                signatureDC["t"] = timeSpan.TotalMilliseconds.ToString();
+                signatureDC["Code"] = Code;
+                signatureDC["PassKey"] = PassKey;
+                string signatureStr = signatureDC.ToJsonString();
+                string signature = AESHelper.AESEncrypt(signatureStr, privateKey);
+                #endregion
+                string result = "";
+                _httpClient.DefaultRequestHeaders.Add("Signature", signature);
+                using (var request = new HttpRequestMessage())
+                {
+                    request.Method = new HttpMethod("POST");
+                    request.RequestUri = new Uri(url);
+                    request.Content = new StringContent(sendMsg);
+                    request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
+                    var response = await _httpClient.SendAsync(request);
+                    result = await response.Content.ReadAsStringAsync();
+                }
+                ScsResult scsResult = result.ToObject<ScsResult>();
+                if (scsResult.result)
+                {
+                    scsResult.content = AESHelper.AESDecrypt(scsResult.content, privateKey);
+
+                }
+                return scsResult;
+            } catch (Exception ex ) {
+                throw new Exception(ex.StackTrace);
+            }
+            
+        }
+
+    }
+   
+}

+ 67 - 0
TEAMModelOS.SDK/Models/Service/Third/ThirdService.cs

@@ -0,0 +1,67 @@
+using Azure.Cosmos;
+using HTEXLib.COMM.Helpers;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.Json;
+using System.Threading.Tasks;
+using TEAMModelOS.SDK.DI;
+using TEAMModelOS.SDK.Extension;
+
+namespace TEAMModelOS.SDK.Models
+{
+    public static class ThirdService
+    {
+        public static async Task<(string accessConfig, Area area, AreaSetting setting)> GetAccessConfig(CosmosClient client,string standard) {
+            Area area = null;
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Normal").
+                   GetItemQueryIterator<Area>($"select value(c) from c where c.standard='{standard}'", requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base-Area") }))
+            {
+                area = item;
+                break;
+            }
+            AreaSetting setting = null;
+            if (area != null)
+            {
+                try
+                {
+                    setting = await client.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemAsync<AreaSetting>(area.id, new PartitionKey("AreaSetting"));
+                }
+                catch (CosmosException)
+                {
+                    setting = null;
+                }
+            }
+            if (setting == null||  string.IsNullOrEmpty(setting.accessConfig))
+            {
+                return (null,null,null);
+            }
+            else {
+                return (setting.accessConfig,area,setting);
+            }
+        }
+        public static async Task<List<Ability>> GetDiagnosisList(CosmosClient client, string standard,DingDing dingDing,  AreaSetting setting, ThirdApisService _thirdApisService,string PXID) {
+            List<string> abilityNos = null ;
+            var config= setting.accessConfig.ToObject<JsonElement>();
+            config.TryGetProperty("config", out JsonElement _config);
+            if ($"{_config}".Equals("scsyxpt"))
+            {
+             //  abilityNos = await ScApisService.GetDiagnosisListByProject_V2(new { accessConfig = setting.accessConfig, pxid = PXID }.ToJsonString());
+            }
+            //获取能力点
+            List<Ability> abilities = null;
+            if (abilityNos.IsNotEmpty()) {
+                abilities = new List<Ability>();
+                StringBuilder sql = new StringBuilder($"select value(c) from c where c.no in {string.Join(",", abilityNos.Select(x => $"'{x}'"))}");
+                await foreach (var item in client.GetContainer("TEAMModelOS", "Normal")
+                         .GetItemQueryIterator<Ability>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Ability-{standard}") }))
+                {
+                    abilities.Add(item);
+                }
+            }
+            return abilities;
+        }
+       
+    }
+}

+ 20 - 17
TEAMModelOS/Controllers/Common/HomeworkController.cs

@@ -82,19 +82,22 @@ namespace TEAMModelOS.Controllers.Learn
                 }
                 homework.creatorId = userid;
                 homework.createTime = now;
-                homework.startTime = now;
+                if (homework.startTime <= 0)
+                {
+                    homework.startTime = now;
+                }
                 homework.ttl = -1;
                 if (string.IsNullOrEmpty(homework.id))
                 {
                     homework.id = Guid.NewGuid().ToString();
-                    //if (homework.startTime > now)
-                    //{
-                    //    homework.progress = "pending";
-                    //}
-                    //else
-                    //{
-                    //    homework.progress = "going";
-                    //}
+                    if (homework.startTime > now)
+                    {
+                        homework.progress = "pending";
+                    }
+                    else
+                    {
+                        homework.progress = "going";
+                    }
                     homework.progress = "going";
                     var messageBlob = new ServiceBusMessage();
                     string blobcntr = null;
@@ -160,14 +163,14 @@ namespace TEAMModelOS.Controllers.Learn
                     }
                     else
                     {
-                        //if (homework.startTime > now)
-                        //{
-                        //    homework.progress = "pending";
-                        //}
-                        //else
-                        //{
-                        //    homework.progress = "going";
-                        //}
+                        if (homework.startTime > now)
+                        {
+                            homework.progress = "pending";
+                        }
+                        else
+                        {
+                            homework.progress = "going";
+                        }
                         homework.progress = "going";
                         homework.recordUrl = $"/homework/{homework.id}/record.json";
                         var cods = new { records = new List<string>(), userids = new List<string>(), question = new List<QuestionRecord>() };

+ 62 - 98
TEAMModelOS/Controllers/Research/AbilityStatisticsController.cs

@@ -30,12 +30,14 @@ namespace TEAMModelOS.Controllers.Research
         private readonly SnowflakeId _snowflakeId;
         private readonly DingDing _dingDing;
         private readonly Option _option;
-        public AbilityStatisticsController(AzureCosmosFactory azureCosmos, SnowflakeId snowflakeId, DingDing dingDing, IOptionsSnapshot<Option> option)
+        private readonly ThirdApisService _thirdApisService;
+        public AbilityStatisticsController(AzureCosmosFactory azureCosmos, SnowflakeId snowflakeId, DingDing dingDing, IOptionsSnapshot<Option> option, ThirdApisService thirdApisService)
         {
             _azureCosmos = azureCosmos;
             _snowflakeId = snowflakeId;
             _dingDing = dingDing;
-            _option = option?.Value; ;
+            _option = option?.Value;
+            _thirdApisService = thirdApisService;
         }
         /// <summary>
         /// 对某个订阅的能力点进行操作
@@ -505,6 +507,43 @@ namespace TEAMModelOS.Controllers.Research
                                     });
                                 }
                             }
+                            else if (other.roleType.Equals("leader"))
+                            {
+                                //学校的身份不管是谁,只能以学校的身份进行一次评论
+                                abilitySub.allDone = true;
+                                var otherScore = abilitySub.otherScore.Find(x => x.roleType.Equals(other.roleType));
+                                if (otherScore != null)
+                                {
+                                    otherScore.tmdname = other.tmdname;
+                                    otherScore.score = other.score;
+                                    if (!string.IsNullOrEmpty(replyId))
+                                    {
+                                        if (otherScore.replyIds.IsNotEmpty())
+                                        {
+                                            otherScore.replyIds.Add(replyId);
+                                        }
+                                        else
+                                        {
+                                            otherScore.replyIds = new List<string>() { replyId };
+                                        }
+                                    }
+                                    otherScore.scoreUploads = other.scoreUploads;
+                                    otherScore.time = nowTime;
+                                }
+                                else
+                                {
+                                    abilitySub.otherScore.Add(new OtherScore
+                                    {
+                                        roleType = other.roleType,
+                                        tmdid = other.tmdid,
+                                        tmdname = other.tmdname,
+                                        score = other.score,
+                                        replyIds = new List<string>() { replyId },
+                                        scoreUploads = other.scoreUploads,
+                                        time = nowTime
+                                    });
+                                }
+                            }
                             else
                             {
                                 //其他身份的同一个人可以以不同身份进行点评
@@ -1238,7 +1277,7 @@ namespace TEAMModelOS.Controllers.Research
         /// <returns></returns>
         [ProducesDefaultResponseType]
         [HttpPost("get-group-subs")]
-        [AuthToken(Roles = "teacher,student,admin,area")]
+        [AuthToken(Roles = "teacher,admin,area")]
         public async Task<IActionResult> GetGroupSubs(JsonElement request)
         {
             try
@@ -1286,14 +1325,12 @@ namespace TEAMModelOS.Controllers.Research
                     ids.Add("default");
                 }
                 (List<RMember> tmdInfos, List<RGroupList> classInfos) = await GroupListService.GetStutmdidListids(client, _dingDing, ids, $"{_school}");
-                // (List<TmdInfo> tmdInfos, List<ClassListInfo> classInfos) = await TriggerStuActivity.GetTchList(client, _dingDing, ids, $"{school}");
-                //(List<TmdInfo> tmdInfos, List<ClassListInfo> classInfos) = await TriggerStuActivity.GetTchList(client, _dingDing, ids, $"{_school}");
                 List<GroupMember> teachers = new List<GroupMember>();
                 foreach (var classInfo in classInfos)
                 {
                     foreach (var tmdinfo in classInfo.members)
                     {
-                        teachers.Add(new GroupMember { groupId = classInfo.id, groupName = classInfo.name, tmdid = tmdinfo.id, tmdname = tmdinfo.name, picture = tmdinfo.picture });
+                        teachers.Add(new GroupMember { groupId = classInfo.id, groupName = classInfo.name, tmdid = tmdinfo.id, tmdname = tmdinfo.name, picture = tmdinfo.picture ,tag=tmdinfo.tag});
                     }
                 }
                 if ($"{_all}".Equals("1"))
@@ -1335,54 +1372,19 @@ namespace TEAMModelOS.Controllers.Research
                         }
                         catch (CosmosException ex) { }
                     }
-                    //foreach (var comid in comids)
-                    //{
-                    //    try
-                    //    {
-                    //        Debate debate = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").ReadItemAsync<Debate>(comid, new PartitionKey($"Debate-{school}"));
-                    //        debates.Add(debate);
-                    //    }
-                    //    catch (CosmosException ex)
-                    //    {
-                    //        continue;
-                    //    }
-                    //}
-                    // List<DebateReply> debateReplies = debates.SelectMany(x => x.replies).ToList();
-                    //groupMembers.ForEach(groupMember =>
-                    //{
-                    //    groupMember.sub.otherScore.ForEach(y =>
-                    //    {
-                    //        List<string> replyIds = new List<string>();
-                    //        y.replyIds.ForEach(reply =>
-                    //        {
-                    //            if (reply != null)
-                    //            {
-                    //                DebateReply replies = debateReplies.Find(x => reply.Equals(x.id));
-                    //                if (replies != null)
-                    //                {
-                    //                    replyIds.Add(replies.comment);
-                    //                }
-                    //            }
-                    //        });
-                    //        y.replyIds = replyIds;
-                    //    });
-
-                    //});
                     return Ok(new { groupMembers, abilities });
                 }
                 else
                 {
-                    var teacer = teachers.Find(x => x.tmdid.Equals($"{_tmdid}"));
+                    var teacer = teachers.FindAll(x => x.tmdid.Equals($"{_tmdid}"));
                     if (teacer != null)
                     {
-                        //List<Debate> debates = new List<Debate>();
                         List<SubGroupMember> groupMembers = new List<SubGroupMember>();
-                        //   HashSet<string> comids = new HashSet<string>();
-                        var tecs = teachers.Where(x => x.groupId.Equals(teacer.groupId)).ToList();
+                        var tecs = teachers.Where(x => teacer.Select(y=>y.groupId).Contains(x.groupId)).ToList();
                         foreach (var t in tecs)
                         {
-                            //排除自己
-                            if (t.tmdid.Equals($"{_tmdid}")) { continue; }
+                            //排除自己,如果不是组长则不排除
+                            if (t.tmdid.Equals($"{_tmdid}")&&string.IsNullOrEmpty(t.tag)) { continue; }
                             await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher")
                                 .GetItemQueryIterator<AbilitySub>(queryText: $"select value(c) from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilitySub-{school}-{t.tmdid}") }))
                             {
@@ -1401,43 +1403,11 @@ namespace TEAMModelOS.Controllers.Research
                                         otherScore = item.otherScore,
                                         comid = item.comid,
                                         self = item.self
-                                    }
+                                    },
+                                    tag=t.tag
                                 });
                             }
                         }
-                        //foreach (var comid in comids)
-                        //{
-                        //    try
-                        //    {
-                        //        Debate debate = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").ReadItemAsync<Debate>(comid, new PartitionKey($"Debate-{school}"));
-                        //        debates.Add(debate);
-                        //    }
-                        //    catch (CosmosException ex)
-                        //    {
-                        //        continue;
-                        //    }
-                        //}
-                        //List<DebateReply> debateReplies = debates.SelectMany(x => x.replies).ToList();
-                        //groupMembers.ForEach(groupMember =>
-                        //{
-                        //    groupMember.sub.otherScore.ForEach(y =>
-                        //    {
-                        //        List<string> replyIds = new List<string>();
-                        //        y.replyIds.ForEach(reply =>
-                        //        {
-                        //            if (reply != null)
-                        //            {
-                        //                DebateReply replies = debateReplies.Find(x => reply.Equals(x.id));
-                        //                if (replies != null)
-                        //                {
-                        //                    replyIds.Add(replies.comment);
-                        //                }
-                        //            }
-                        //        });
-                        //        y.replyIds = replyIds;
-                        //    });
-
-                        //});
                         return Ok(new { groupMembers, abilities });
                     }
                     else
@@ -1468,6 +1438,7 @@ namespace TEAMModelOS.Controllers.Research
             public string picture { get; set; }
             public string groupName { get; set; }
             public string groupId { get; set; }
+            public string tag { get; set; }
         }
         public class SubGroupMember
         {
@@ -1477,6 +1448,7 @@ namespace TEAMModelOS.Controllers.Research
             public string groupName { get; set; }
             public string groupId { get; set; }
             public SubGroup sub { get; set; }
+            public string tag { get; set; }
         }
         /// <summary>
         /// 保存
@@ -1570,7 +1542,7 @@ namespace TEAMModelOS.Controllers.Research
                 List<AbilitySub> rcdSubs = new List<AbilitySub>();
                 //必修
                 List<Ability> currencyAb1 = new List<Ability>();
-                //选修
+                //通识
                 List<Ability> currencyAb2 = new List<Ability>();
                 //tmdid
                 if (!request.TryGetProperty("tmdid", out JsonElement tmdid)) return Ok(new { error = 400 });
@@ -1617,28 +1589,19 @@ namespace TEAMModelOS.Controllers.Research
                 else { 
                     return Ok(new { error = 400 });
                 };
-
-                Area area = null;
-                try
-                {
-                       client.GetContainer(Constant.TEAMModelOS, "Normal").GetItemQueryIterator<Area>($"", requestOptions:new QueryRequestOptions { PartitionKey=new PartitionKey("Base-Area") });
-                }
-                catch (CosmosException ex)
-                {
-                    return Ok(new { error = 404, msg = "区域不存在!" });
-                }
-                AreaSetting setting = null;
-                if (area != null)
-                {
-                    try
+                (string accessConfig, Area area, AreaSetting setting) =  await ThirdService.GetAccessConfig(client, $"{standard}");
+                //未对接其他平台。有对接其他平台则必修。
+                if (!string.IsNullOrEmpty(accessConfig)) {
+                    var abilitys = await ThirdService.GetDiagnosisList(client, $"{standard}", _dingDing, setting,   _thirdApisService,   $"PXID");
+                    if (abilitys != null)
                     {
-                        setting = await client.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemAsync<AreaSetting>(area.id, new PartitionKey("AreaSetting"));
+                        abilitys.ForEach(x => { x.currency = 1; });
                     }
-                    catch (CosmosException)
-                    {
-                        return Ok(new { error = 404, msg = "设置不存在!" });
+                    else {
+                        currencyAb1 = null;
                     }
                 }
+                //通识
                 foreach (var item in currencyAb2) {
                     var had = hadSubs.Where(x => x.id.Equals(item.id)).FirstOrDefault();
                     if (had == null) {
@@ -1657,6 +1620,7 @@ namespace TEAMModelOS.Controllers.Research
                         await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").CreateItemAsync(abilitySub, new PartitionKey(abilitySub.code));
                     }
                 }
+                //必修
                 foreach (var item in currencyAb1)
                 {
                     var had = hadSubs.Where(x => x.id.Equals(item.id)).FirstOrDefault();

+ 3 - 9
TEAMModelOS/Controllers/Third/ScController.cs

@@ -49,7 +49,7 @@ namespace TEAMModelOS.Controllers.Third
         private readonly AzureServiceBusFactory _serviceBus;
         private readonly AzureRedisFactory _azureRedis;
         private readonly CoreAPIHttpService _accountHttpService;
-        private readonly ScsApisService _scsApisService;
+        private readonly ThirdApisService _scsApisService;
         public readonly string type = "scsyxpt";
         /// <summary>
         /// 机构安全码
@@ -69,7 +69,7 @@ namespace TEAMModelOS.Controllers.Third
         public   string _sc_url;
         public IConfiguration _configuration { get; set; }
         public ScController(AzureCosmosFactory azureCosmos, SnowflakeId snowflakeId, DingDing dingDing, IOptionsSnapshot<Option> option, AzureStorageFactory azureStorage,
-          AzureRedisFactory azureRedis, AzureServiceBusFactory serviceBus, IConfiguration configuration, CoreAPIHttpService accountHttpService, ScsApisService scsApisService)
+          AzureRedisFactory azureRedis, AzureServiceBusFactory serviceBus, IConfiguration configuration, CoreAPIHttpService accountHttpService, ThirdApisService scsApisService)
         {
             _azureCosmos = azureCosmos;
             _snowflakeId = snowflakeId;
@@ -562,13 +562,7 @@ namespace TEAMModelOS.Controllers.Third
             //return Ok(GetProjectInfoByTrainComID);
         }
 
-        public class ScsResult {
-            public bool result { get; set; }
-            public string reason { get; set; }
-            public string content { get; set; }
-            public string code { get; set; }
-            public string title { get; set; }
-        }
+       
         /// <summary>
         /// 
         /// </summary>

+ 0 - 60
TEAMModelOS/Controllers/Third/ScsApisService.cs

@@ -1,60 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Net;
-using System.Net.Http;
-using System.Net.Http.Headers;
-using System.Net.Http.Json;
-using System.Text;
-using System.Threading.Tasks;
-using TEAMModelOS.SDK;
-using TEAMModelOS.SDK.Extension;
-using static TEAMModelOS.Controllers.Third.ScController;
-
-namespace TEAMModelOS.Controllers
-{
-    public class ScsApisService
-    {
-       
-        private readonly HttpClient _httpClient;
-        public ScsApisService(HttpClient httpClient)
-        {
-            _httpClient = httpClient;
-        }
-        public async   Task<ScsResult> Post(string url, string Code, string PassKey,string privateKey, Dictionary<string ,object> data)
-        {
-           
-            string Content = AESHelper.AESEncrypt(data.ToJsonString(), privateKey);
-            string paramStr = "Code={0}&PassKey={1}&Content={2}";
-            string sendMsg = string.Format(paramStr, Code, PassKey, Content);
-            #region 签名 Signature
-            SortedDictionary<string, string> signatureDC = new SortedDictionary<string, string>();
-            var timeSpan = (DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0));
-            signatureDC["t"] = timeSpan.TotalMilliseconds.ToString();
-            signatureDC["Code"] = Code;
-            signatureDC["PassKey"] = PassKey;
-            string signatureStr = signatureDC.ToJsonString();
-            string signature = AESHelper.AESEncrypt(signatureStr, privateKey);
-            #endregion
-            string result = "";
-            _httpClient.DefaultRequestHeaders.Add("Signature",signature);
-            using (var request = new HttpRequestMessage())
-            {
-                request.Method = new HttpMethod("POST");
-                request.RequestUri = new Uri(url);
-                request.Content = new StringContent(sendMsg);
-                request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
-                var response = await _httpClient.SendAsync(request);
-                result = await response.Content.ReadAsStringAsync();
-            }
-            ScsResult scsResult = result.ToObject<ScsResult>();
-            if (scsResult.result)
-            {
-                scsResult.content = AESHelper.AESDecrypt(scsResult.content, privateKey);
-                
-            }
-            return scsResult;
-            
-        }
-    }
-}

+ 1 - 1
TEAMModelOS/Startup.cs

@@ -106,7 +106,7 @@ namespace TEAMModelOS
             services.AddHttpClient<DingDing>();
             services.AddHttpClient<NotificationService>();
             services.AddHttpClient<CoreAPIHttpService>();
-            services.AddHttpClient<ScsApisService>();
+            services.AddHttpClient<ThirdApisService>();
             services.AddMemoryCache();
             services.AddSpaStaticFiles(opt => opt.RootPath = "ClientApp/dist");
             services.AddControllers().AddJsonOptions(options => { options.JsonSerializerOptions.IgnoreNullValues = false; });

+ 0 - 1
TEAMModelOS/appsettings.Development.json

@@ -61,7 +61,6 @@
       "trainComID": "2065", //机构ID 2065 65324
       "privateKey": "4DB15444DEEDBB28B718ACB09217B5FC", //机构 AES 密钥
       "url": "http://testscts.scedu.com.cn/webservice/EduService.asmx/RequestService"
-      //"url": "https://scts.scedu.com.cn/webservice/EduService.asmx/RequestService" 
     }
     //"scsyxpt": {
     //  "passKey": "fst4clhyXqrhXblY", //机构安全码