CrazyIter_Bin 3 years ago
parent
commit
15e2cfa47e

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

@@ -22,6 +22,7 @@ namespace TEAMModelOS.SDK
         }
         public async   Task<ScsResult> Post(string url, string Code, string PassKey,string privateKey, Dictionary<string ,object> data)
         {
+            string result = "";
             HttpResponseMessage response=null;
             try {
                 string json = data.ToJsonString();
@@ -37,7 +38,7 @@ namespace TEAMModelOS.SDK
                 string signatureStr = signatureDC.ToJsonString();
                 string signature = AESHelper.AESEncrypt(signatureStr, privateKey);
                 #endregion
-                string result = "";
+             
                 _httpClient.DefaultRequestHeaders.Add("Signature", signature);
                 using (var request = new HttpRequestMessage())
                 {
@@ -59,7 +60,7 @@ namespace TEAMModelOS.SDK
                 }
                 return scsResult;
             } catch (Exception ex ) {
-                throw new Exception($"{ex.Message}\n{ex.StackTrace}\n\n{data.ToJsonString()}\n{url}\n {Code}\n{PassKey}\n{privateKey}\n{response?.StatusCode}\n{response?.Content}");
+                throw new Exception($"{ex.Message}\n{ex.StackTrace}\n\n{data.ToJsonString()}\n{url}\n {Code}\n{PassKey}\n{privateKey}\n{response?.StatusCode}\n{response?.Content}\n{result}");
             }
             
         }

+ 42 - 7
TEAMModelOS.SDK/Models/Service/Third/ThirdService.cs

@@ -421,12 +421,13 @@ namespace TEAMModelOS.SDK.Models
             return (t53112OK, msgs);
         }
         //5.3.1.13学员能力点测评结果批量回写-UpdateTeacherListDiagnosis
-        public  async static Task<(int t53113OK, List<KeyValuePair<string, string>> msgs, List<AbilitySub> abilitySubs)> check53113(AzureCosmosFactory _azureCosmos,TeacherTrain teacherTrain, ScTeacherDiagnosis diagnosis, 
+        public  async static Task<(int t53113OK, List<KeyValuePair<string, string>> msgs, List<AbilitySub> abilitySubs, List<AbilitySub>  allRightAbility)> check53113(AzureCosmosFactory _azureCosmos,TeacherTrain teacherTrain, ScTeacherDiagnosis diagnosis, 
             List<KeyValuePair<string, string>> msgs, string school,
             string schoolPrefix, string sas, AzureStorageFactory _azureStorage)
         {
             //校验 基本情况是否满足
             int t53113OK = 1;
+            List<AbilitySub> allRightAbility = new List<AbilitySub>();
             List<AbilitySub> abilitySubs = new List<AbilitySub>();
             if (teacherTrain.currency.videoTime < 0)
             {
@@ -501,6 +502,36 @@ namespace TEAMModelOS.SDK.Models
                                         //msgs.Add(new KeyValuePair<string, string>("xzscore", $"认证材料,没有完成小组评:{x.no},{x.name},{x.xzscore}"));
                                     }
                                 });
+
+                                foreach (AbilitySub abilitySub in abilitySubs)
+                                {
+                                    //当前能力点上传的文件是否完全有效
+                                    bool isAllRight = true;
+                                    List<string> urlUn = new List<string>();
+                                    foreach (var subUpload in abilitySub.uploads)
+                                    {
+                                        foreach (var url in subUpload.urls)
+                                        {
+                                            string blobItem = url.url.Replace($"{schoolPrefix}/", "");
+                                            bool Exist = await _azureStorage.GetBlobContainerClient(school).GetBlobClient(blobItem).ExistsAsync();
+                                            if (!Exist)
+                                            {
+                                                isAllRight = false;
+                                                urlUn.Add($"{url.url}?{sas}");
+                                            }
+                                        }
+                                    }
+                                    if (isAllRight)
+                                    {
+                                        allRightAbility.Add(abilitySub);
+                                    }
+                                    else
+                                    {
+                                        t53113OK = 0;
+                                        var x = teacherTrain.currency.teacherAilities.Find(x => x.id.Equals(abilitySub.id));
+                                        msgs.Add(new KeyValuePair<string, string>("uploads-url", $"{x.no},{x.name}上传的认证材料文件失效:{string.Join("   ,   ", urlUn)}"));
+                                    }
+                                }
                             }
                             else {
                                 //一个都没上传
@@ -543,8 +574,9 @@ namespace TEAMModelOS.SDK.Models
                                             }
                                         });
                                     }
+                                    
                                      //检查已经上传的文件是否正确。
-                                     foreach(AbilitySub abilitySub in uploaded)
+                                    foreach(AbilitySub abilitySub in uploaded)
                                     {
                                         //当前能力点上传的文件是否完全有效
                                         bool isAllRight = true;
@@ -555,7 +587,6 @@ namespace TEAMModelOS.SDK.Models
                                             {
                                                 string blobItem = url.url.Replace($"{schoolPrefix}/", "");
                                                 bool Exist = await _azureStorage.GetBlobContainerClient(school).GetBlobClient(blobItem).ExistsAsync();
-                                                // List<string> items = await _azureStorage.GetBlobContainerClient(item.school).ExistsAsync(blobItem);
                                                 if (!Exist)
                                                 {
                                                     isAllRight = false;
@@ -565,7 +596,7 @@ namespace TEAMModelOS.SDK.Models
                                         }
                                         if (isAllRight)
                                         {
-
+                                            allRightAbility.Add(abilitySub);
                                         }
                                         else
                                         {
@@ -574,10 +605,10 @@ namespace TEAMModelOS.SDK.Models
                                             msgs.Add(new KeyValuePair<string, string>("uploads-url", $"{x.no},{x.name}上传的认证材料文件失效:{string.Join("   ,   ",urlUn)}"));
                                         }
                                     }
+                                   
                                 }
 
                             }
-                            
                             if (t53113OK != 1)
                             {
                                 msgs.Add(new KeyValuePair<string, string>("diagnosisNos", $"省平台勾选的能力点编号为学习完成:省平台:{string.Join(",", nos.OrderBy(x => x))}" + $" ,已学习:{string.Join(",", teacherTrain.currency.teacherAilities.Select(x => x.no).OrderBy(x => x))} "));
@@ -601,9 +632,13 @@ namespace TEAMModelOS.SDK.Models
                 msgs.Add(new KeyValuePair<string, string>("teacherAilities", $"未同步省平台挑选的能力点"));
                 t53113OK = 0;
             }
+            if (allRightAbility.Count < 3)
+            {
+                t53113OK = 0;
+                msgs.Add(new KeyValuePair<string, string>("uploads-count", $"完整上传且有效的认证材料的 能力点数量小于3,当前数量:{allRightAbility.Count}"));
+            }
 
-
-            return (t53113OK, msgs, abilitySubs);
+            return (t53113OK, msgs, abilitySubs, allRightAbility);
         }
     }
 }

+ 15 - 12
TEAMModelOS/Controllers/Third/Sc/ScDataPushController.cs

@@ -93,13 +93,13 @@ namespace TEAMModelOS.Controllers
             List<ScsResult> results = new List<ScsResult>();
             Dictionary<string, Dictionary<string, object>> pushDatas = new Dictionary<string, Dictionary<string, object>>();
             List<Dictionary<string, object>> dicts = new List<Dictionary<string, object>>();
-            int pages = (trains.Count + 19) / 20; //pages = (total + max -1) / max;
+            int pages = (trains.Count + 49) / 50; //pages = (total + max -1) / max;
 
             var teammodelossas= _azureStorage.GetBlobContainerSAS99Year("teammodelos", Azure.Storage.Sas.BlobContainerSasPermissions.Read);
             var schoolsas = _azureStorage.GetBlobContainerSAS99Year($"{school}", Azure.Storage.Sas.BlobContainerSasPermissions.Read);
             for (int i = 0; i < pages; i++)
             {
-                List<TeacherTrain> lists = trains.Skip((i) * 20).Take(20).ToList();
+                List<TeacherTrain> lists = trains.Skip((i) * 50).Take(50).ToList();
                 //5.3.1.12学员培训基本情况批量回写-UpdateTeacherListSituation
                 List<TeacherTrain> trains53112OK = new List<TeacherTrain>();
                 ScsResult UpdateTeacherListSituation = null;
@@ -148,7 +148,7 @@ namespace TEAMModelOS.Controllers
                         string jsonTech = scTeacherDiagnoses.ToJsonString();
                         ScTeacherDiagnosis diagnosis = scTeacherDiagnoses.Find(x => x.RowKey.Equals($"{t.PXID}"));
                         (int t53112OK, List<KeyValuePair<string, string>> msgs53112) = ThirdService. check53112(x, msgs);
-                        (int t53113OK, List<KeyValuePair<string, string>> msgs53113, List<AbilitySub> abilitySubs) = await ThirdService.check53113(_azureCosmos,x, diagnosis, msgs, $"{school}", schoolsas.uri, schoolsas.sas, _azureStorage);
+                        (int t53113OK, List<KeyValuePair<string, string>> msgs53113, List<AbilitySub> abilitySubs, List<AbilitySub> allRightAbility) = await ThirdService.check53113(_azureCosmos,x, diagnosis, msgs, $"{school}", schoolsas.uri, schoolsas.sas, _azureStorage);
                         (int t53117OK, List<KeyValuePair<string, string>> msgs53117) = await ThirdService.check53117(x, msgs, $"{school}", schoolsas.uri, schoolsas.sas, _azureStorage);
                         (int t53122OK, List<KeyValuePair<string, string>> msgs53122) = await ThirdService.check53122(x, msgs,$"{school}",schoolsas.uri,schoolsas.sas,_azureStorage);
 
@@ -209,17 +209,18 @@ namespace TEAMModelOS.Controllers
                                 List<Dictionary<string, object>> pfiles = new List<Dictionary<string, object>>();
                                 parameterMapData.Add("pfiles", pfiles);
 
-                                AbilitySub abilitySub = abilitySubs.Find(sub => sub.id.Equals(a.id));
-                                if (abilitySub != null)
+                                AbilitySub allRight = allRightAbility.Find(sub => sub.id.Equals(a.id));
+                                if (allRight != null)
                                 {
-                                    abilitySub.uploads.ForEach(upload => {
+                                    allRight.uploads.ForEach(upload => {
                                         upload.urls.ForEach(url => {
                                             Dictionary<string, object> pfileMap = new Dictionary<string, object>();
+                                            string fileext = url.url.Substring(url.url.LastIndexOf(".") > 0 ? url.url.LastIndexOf(".") + 1 : 0);
                                             pfileMap.Add("url", $"{url.url}?{schoolsas.sas}");
-                                            pfileMap.Add("fileName", url.name);
+                                            pfileMap.Add("fileName", url.name.Length>95?$"{url.name.Substring(0, 95)}.{fileext}":url.name);
                                             pfileMap.Add("fileSize", $"{url.size}");
                                             pfileMap.Add("md5", url.hash);
-                                            string fileext = url.url.Substring(url.url.LastIndexOf(".") > 0 ? url.url.LastIndexOf(".") + 1 : 0);
+                                           
                                             pfileMap.Add("fileType", fileext);
                                             pfiles.Add(pfileMap);
                                         });
@@ -316,14 +317,15 @@ namespace TEAMModelOS.Controllers
                             x.teacherClasses.ForEach(clss =>
                             {
                                 Dictionary<string, object> parameterMapData = new Dictionary<string, object>();
+                                string fileext = clss.url.Substring(clss.url.LastIndexOf(".") > 0 ? clss.url.LastIndexOf(".") + 1 : 0);
                                 parameterMapData.Add("PXID", $"{t.PXID}");
                                 parameterMapData.Add("TID", $"{t.TID}");
                                 parameterMapData.Add("url", $"{clss.url}?{schoolsas.sas}");//添加访问授权
                                 parameterMapData.Add("url2", $"{clss.url}?{schoolsas.sas}");
-                                parameterMapData.Add("fileName", clss.name);
+                                parameterMapData.Add("fileName",    clss.name.Length > 95 ? $"{clss.name.Substring(0, 95)}.{fileext}" : clss.name);
                                 parameterMapData.Add("fileSize", $"{clss.size}");
                                 parameterMapData.Add("md5", clss.hash);
-                                string fileext = clss.url.Substring(clss.url.LastIndexOf(".") > 0 ? clss.url.LastIndexOf(".") + 1 : 0);
+                              
                                 parameterMapData.Add("fileType", fileext);
                                 list53117.Add(parameterMapData);
                                 parameterMapDatas.Add(parameterMapData);
@@ -346,11 +348,12 @@ namespace TEAMModelOS.Controllers
                                 if (!string.IsNullOrWhiteSpace(record.url))
                                 {
                                     Dictionary<string, object> fileMap = new Dictionary<string, object>();
+                                    string fileext = record.url.Substring(record.url.LastIndexOf(".") > 0 ? record.url.LastIndexOf(".") + 1 : 0);
                                     fileMap.Add("url", $"{record.url}?{schoolsas.sas}");
-                                    fileMap.Add("fileName", record.name);
+                                    fileMap.Add("fileName", record.name.Length > 95 ? $"{record.name.Substring(0, 95)}.{fileext}" : record.name);
                                     fileMap.Add("fileSize", $"{record.size}");
                                     fileMap.Add("md5", record.hash);
-                                    string fileext = record.url.Substring(record.url.LastIndexOf(".") > 0 ? record.url.LastIndexOf(".") + 1 : 0);
+                                  
                                     fileMap.Add("fileType", fileext);
                                     files.Add(fileMap);
                                 }