Przeglądaj źródła

研修数据结构更新。

CrazyIter_Bin 3 lat temu
rodzic
commit
b54b90f8cd

+ 3 - 2
TEAMModelOS.FunctionV4/HttpTrigger/ScsYxptApis.cs

@@ -523,8 +523,9 @@ namespace TEAMModelOS.FunctionV4.HttpTrigger
             var response = req.CreateResponse(HttpStatusCode.OK);
             var client = _azureCosmos.GetCosmosClient();
             string data = await new StreamReader(req.Body).ReadToEndAsync();
-            JsonElement accessConfig = data.ToObject<JsonElement>().GetProperty("accessConfig");
-            ScAccessConfig config = $"{accessConfig}".ToObject<ScAccessConfig>();
+            JsonElement areaIdJson = data.ToObject<JsonElement>().GetProperty("areaId");
+            AreaSetting areaSetting= await  _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemAsync<AreaSetting>($"{areaIdJson}", new PartitionKey("AreaSetting"));
+            ScAccessConfig config = areaSetting.accessConfig.ToObject<ScAccessConfig>();
             JsonElement school = data.ToObject<JsonElement>().GetProperty("school");
             List<string> pushTeachers = data.ToObject<JsonElement>().GetProperty("pushTeachers").ToObject<List<string>>();
             StringBuilder queryText = new StringBuilder($"SELECT distinct value(c) FROM c where c.type='yxtrain'");

+ 20 - 3
TEAMModelOS.FunctionV4/ServiceBus/ActiveTaskTopic.cs

@@ -679,6 +679,7 @@ namespace TEAMModelOS.FunctionV4.ServiceBus
                     await  _dingDing.SendBotMsg($"校本研修生成PDF时,区级id为空\n{msg}",GroupNames.成都开发測試群組);
                     return;
                 }
+                var blobclient = _azureStorage.GetBlobContainerClient($"teammodelos");
                 foreach (string id in tIds)
                 {
                     List<Study> studies = new();
@@ -884,9 +885,25 @@ namespace TEAMModelOS.FunctionV4.ServiceBus
                     Azure.Response teacherTrainRes = await client.GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReadItemStreamAsync(id, new PartitionKey($"TeacherTrain-{code}"));
                     if (teacherTrainRes.Status == 200) {
                         TeacherTrain teacherTrain = JsonDocument.Parse(teacherTrainRes.Content).RootElement.Deserialize<TeacherTrain>();
-                        if (string.IsNullOrWhiteSpace(teacherTrain.offlineUrl)) {
-                            teacherTrain.offlineUrl = url;
-                            await client.GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReplaceItemAsync<TeacherTrain>(teacherTrain, id, new PartitionKey($"TeacherTrain-{code}"));
+                        try {
+                            BlobDownloadInfo blobDownload = await blobclient.GetBlobClient(url).DownloadAsync(range: new HttpRange(0, 4 * 1048576), rangeGetContentHash: true);
+                            if (blobDownload.Details.ContentHash != null)
+                            {
+
+                                string hash = Md5Hash.GetbyteToString(blobDownload.Details.ContentHash);
+                                teacherTrain.offlineReport = new Attachment
+                                {
+                                    hash = hash,
+                                    url = url,
+                                    blob = $"{blobclient.Uri}/{url}",
+                                    extension = "pdf",
+                                    name = $"{teacherTrain.nickname}-校本研修汇总报告.pdf",
+                                    type = "doc",
+                                    size = blobDownload.ContentLength
+                                };
+                                await client.GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReplaceItemAsync<TeacherTrain>(teacherTrain, id, new PartitionKey($"TeacherTrain-{code}"));
+                            }
+                            } catch { 
                         }
                     }
                 }

+ 6 - 1
TEAMModelOS.SDK/Models/Cosmos/Teacher/Research/TeacherTrain.cs

@@ -124,8 +124,13 @@ namespace TEAMModelOS.SDK.Models
         /// 待更新的属性
         /// </summary>
         public HashSet<string> update { get; set; } = new HashSet<string>();
-        public string push { get; set; } 
+        public string push { get; set; }
+        public Attachment offlineReport { get; set; }
+       
     }
+
+
+
     public class TeacherTrainChange {
         /// <summary>
         /// 能力点标准

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

@@ -296,5 +296,248 @@ namespace TEAMModelOS.SDK.Models
             }
             return null ;
         }
+
+
+
+        //5.3.1.22学员校本教研PDF(每人可以返回多条)批量回写-UploadSBTARPDFListV2
+        public   static (int t53122OK, List<KeyValuePair<string, string>> msgs) check53122(TeacherTrain teacherTrain, List<KeyValuePair<string, string>> msgs)
+        {
+            int t53122OK = 1;
+            if (teacherTrain.offlineRecords.Count <= 0)
+            {
+                t53122OK = 0;
+                msgs.Add(new KeyValuePair<string, string>("offlineRecord-count", $"文件个数为0"));
+            }
+            var hasUrl = teacherTrain.offlineRecords.Where(x => !string.IsNullOrWhiteSpace(x.url) && x.size > 0);
+            if (!hasUrl.Any())
+            {
+                t53122OK = 0;
+                msgs.Add(new KeyValuePair<string, string>("offlineRecord-url", $"需要上传的校本研修作业至少有一个。"));
+            }
+            if (teacherTrain.offlineReport==null) {
+                t53122OK = 0;
+                msgs.Add(new KeyValuePair<string, string>("offlineReport", $"校本研修汇总报告未生成。"));
+            }
+            //不需要检查每一个校本研修的文件记录。
+            //teacherTrain.offlineRecords.ForEach(x => {
+            //    if (string.IsNullOrEmpty(x.url)) {
+            //        msgs.Add(new KeyValuePair<string, string>("offlineRecord-url", $"链接为空"));
+            //    }
+            //    if (x.size<=0)
+            //    {
+            //        msgs.Add(new KeyValuePair<string, string>("offlineRecord-size", $"文件大小"));
+            //    }
+            //});
+                return (t53122OK, msgs);
+        }
+
+        //5.3.1.17学员课堂实录批量回写-UploadKTSLList
+        public   static (int t53117OK, List<KeyValuePair<string, string>> msgs) check53117(TeacherTrain teacherTrain, List<KeyValuePair<string, string>> msgs)
+        {
+            //校验 基本情况是否满足
+            int t53117OK = 1;
+            if (teacherTrain.classTime <= 0)
+            {
+                msgs.Add(new KeyValuePair<string, string>("classTime", $"未获得学时:{teacherTrain.classTime}"));
+                t53117OK = 0;
+            }
+            if (teacherTrain.teacherClasses.Count() <= 0)
+            {
+                msgs.Add(new KeyValuePair<string, string>("teacherClasses", $"未上传课堂实录:{teacherTrain.teacherClasses.Count()}个视频"));
+                t53117OK = 0;
+            }
+
+            teacherTrain.teacherClasses.ForEach(x => {
+                if (string.IsNullOrWhiteSpace(x.url))
+                {
+                    t53117OK = 0;
+                    msgs.Add(new KeyValuePair<string, string>("teacherClasses", $"课堂实录链接无效"));
+                }
+            });
+            return (t53117OK, msgs);
+        }
+        //5.3.1.12学员培训基本情况批量回写-UpdateTeacherListSituation
+        public   static (int t53112OK, List<KeyValuePair<string, string>> msgs) check53112(TeacherTrain teacherTrain, List<KeyValuePair<string, string>> msgs)
+        {
+            //校验 基本情况是否满足
+            int t53112OK = 1;
+            if (teacherTrain.finalScore < 0)
+            {
+                //总体认定结果0、未认定  1、合格  2、优秀  3、不合格  4、其他
+                msgs.Add(new KeyValuePair<string, string>("finalScore", $"最终评定结果参数:{teacherTrain.finalScore}"));
+                t53112OK = 0;
+            }
+            //if (string.IsNullOrEmpty(teacherTrain.summary) || teacherTrain.summary.Length > 300)
+            //{
+            //    string msg = string.IsNullOrEmpty(teacherTrain.summary) ? "未填写" : teacherTrain.summary.Length > 300 ? "字数超过300." : "";
+            //    msgs.Add(new KeyValuePair<string, string>("summary", $"教师培训总结:{msg}"));
+            //    t53112OK = 0;
+            //}
+
+            if (!string.IsNullOrEmpty(teacherTrain.summary) && teacherTrain.summary.Length > 300)
+            {
+                //string msg = string.IsNullOrEmpty(teacherTrain.summary) ? "未填写" : teacherTrain.summary.Length > 300 ? "字数超过300." : "";
+                msgs.Add(new KeyValuePair<string, string>("summary", $"教师培训总结:字数超过300."));
+                t53112OK = 0;
+            }
+            if (teacherTrain.totalTime <= 0)
+            {
+                msgs.Add(new KeyValuePair<string, string>("totalTime", $"未获得学时:{teacherTrain.totalTime}"));
+                t53112OK = 0;
+            }
+            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, List<KeyValuePair<string, string>> msgs)
+        {
+            //校验 基本情况是否满足
+            int t53113OK = 1;
+            List<AbilitySub> abilitySubs = new List<AbilitySub>();
+            if (teacherTrain.currency.videoTime < 0)
+            {
+                msgs.Add(new KeyValuePair<string, string>("videoTime", $"视频学习时长:{teacherTrain.currency.videoTime}"));
+                t53113OK = 0;
+            }
+            if (teacherTrain.currency.submitTime < 0)
+            {
+                msgs.Add(new KeyValuePair<string, string>("submitTime", $"认证材料学习:{teacherTrain.currency.submitTime}"));
+                t53113OK = 0;
+            }
+            if (teacherTrain.currency.teacherAilities.Count <= 0)
+            {
+
+                msgs.Add(new KeyValuePair<string, string>("teacherAilities", $"已学习能力点:0"));
+                t53113OK = 0;
+            }
+            if (diagnosis != null)
+            {
+                if (!string.IsNullOrWhiteSpace(diagnosis.abilityNos))
+                {
+                    List<string> nos = diagnosis.abilityNos.ToObject<List<string>>();
+                    if (nos.Count > 0 && teacherTrain.currency.teacherAilities.Count > 0)
+                    {
+                        var notin = nos.Except(teacherTrain.currency.teacherAilities.Select(x => x.no).Where(z => !string.IsNullOrWhiteSpace(z)));
+                        if (notin.Any())
+                        {
+                            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))} "));
+                            t53113OK = 0;
+                        }
+                        else
+                        {
+                            string insql = "";
+                            if (teacherTrain.currency.teacherAilities.IsNotEmpty())
+                            {
+                                var abilites = teacherTrain.currency.teacherAilities.Where(c => !string.IsNullOrWhiteSpace(c.no) && nos.Contains(c.no));
+                                insql = $" where c.id in ({string.Join(",", abilites.Select(o => $"'{o.id}'"))})";
+                            }
+                            //认证材料
+                            await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher")
+                                     .GetItemQueryIterator<AbilitySub>(queryText: $"select value(c) from c {insql}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilitySub-{teacherTrain.school}-{teacherTrain.id}") }))
+                            {
+                                abilitySubs.Add(item);
+                            }
+
+                            if (abilitySubs.Count() <= 3)
+                            {
+                                teacherTrain.currency.teacherAilities.ForEach(x =>
+                                {
+                                    var abilitySub = abilitySubs.Find(z => z.id.Equals(x.id));
+                                    if (abilitySub == null || !abilitySub.uploads.Any())
+                                    {
+                                        t53113OK = 0;
+                                        msgs.Add(new KeyValuePair<string, string>("uploads", $"未上传认证材料:{x.no},{x.name}"));
+                                    }
+                                    if (x.zpscore <= 0)
+                                    {
+                                        t53113OK = 0;
+                                        msgs.Add(new KeyValuePair<string, string>("zpscore", $"认证材料,没有完成自评:{x.no},{x.name},{x.zpscore}"));
+                                    }
+                                    if (x.hpscore <= 0)
+                                    {
+                                        //t53113OK = 0;
+                                        //如果只有三个,且互评为未评状态,则直接为合格。
+                                        x.hpscore = 1;
+                                       // msgs.Add(new KeyValuePair<string, string>("hpscore", $"认证材料,没有完成互评:{x.no},{x.name},{x.hpscore}"));
+                                    }
+                                    if (x.xzscore <= 0)
+                                    {
+                                        //t53113OK = 0;
+                                        x.xzscore = 1;
+                                        //msgs.Add(new KeyValuePair<string, string>("xzscore", $"认证材料,没有完成小组评:{x.no},{x.name},{x.xzscore}"));
+                                    }
+                                });
+                            }
+                            else {
+                                //一个都没上传
+                                if (!abilitySubs.SelectMany(upsl => upsl.uploads).Any())
+                                {
+                                    t53113OK = 0;
+                                    msgs.Add(new KeyValuePair<string, string>("uploads-all", $"没有上传认证材料。"));
+                                }
+                                else {
+                                    //检查上传了认证材料的能力点,超过三个的。
+                                    var uploaded = abilitySubs.FindAll(x => x.uploads.Count > 0);
+                                    //不足三个的则需要记录
+                                    if (uploaded.Count < 3) {
+                                        t53113OK = 0;
+                                        abilitySubs.RemoveAll(x => x.uploads.Count > 0);
+                                        abilitySubs.ForEach(ab => {
+                                           var x =  teacherTrain.currency.teacherAilities.Find(x => x.id.Equals(ab.id));
+                                            if (x == null || !ab.uploads.Any())
+                                            {
+                                                t53113OK = 0;
+                                                msgs.Add(new KeyValuePair<string, string>("uploads", $"未上传认证材料:{x.no},{x.name}"));
+                                            }
+                                            if (x.zpscore <= 0)
+                                            {
+                                                t53113OK = 0;
+                                                msgs.Add(new KeyValuePair<string, string>("zpscore", $"认证材料,没有完成自评:{x.no},{x.name},{x.zpscore}"));
+                                            }
+                                            if (x.hpscore <= 0)
+                                            {
+                                                t53113OK = 0;
+                                                //如果只有三个,且互评为未评状态,则直接为合格。
+                                                x.hpscore = 1;
+                                                msgs.Add(new KeyValuePair<string, string>("hpscore", $"认证材料,没有完成互评:{x.no},{x.name},{x.hpscore}"));
+                                            }
+                                            if (x.xzscore <= 0)
+                                            {
+                                                t53113OK = 0;
+                                                msgs.Add(new KeyValuePair<string, string>("xzscore", $"认证材料,没有完成小组评:{x.no},{x.name},{x.xzscore}"));
+                                            }
+                                        });
+
+                                    }
+                                }
+
+                            }
+                            
+                            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))} "));
+                            }
+                        }
+                    }
+                    else
+                    {
+                        msgs.Add(new KeyValuePair<string, string>("teacherAilities", $"未同步省平台挑选的能力点"));
+                        t53113OK = 0;
+                    }
+                }
+                else
+                {
+                    msgs.Add(new KeyValuePair<string, string>("teacherAilities", $"未同步省平台挑选的能力点"));
+                    t53113OK = 0;
+                }
+            }
+            else
+            {
+                msgs.Add(new KeyValuePair<string, string>("teacherAilities", $"未同步省平台挑选的能力点"));
+                t53113OK = 0;
+            }
+
+
+            return (t53113OK, msgs, abilitySubs);
+        }
     }
 }

+ 403 - 0
TEAMModelOS/Controllers/Third/Sc/ScDataPushController.cs

@@ -0,0 +1,403 @@
+
+using Microsoft.AspNetCore.Mvc;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using TEAMModelOS.Models;
+using TEAMModelOS.SDK.DI;
+using System.Text.Json;
+using TEAMModelOS.SDK.Models;
+using Microsoft.AspNetCore.Http;
+using TEAMModelOS.SDK.Extension;
+using Azure.Cosmos;
+using System.Text;
+using Microsoft.Extensions.Options;
+using Microsoft.Extensions.Configuration;
+using HTEXLib.COMM.Helpers;
+using TEAMModelOS.SDK;
+
+namespace TEAMModelOS.Controllers
+{
+    [ProducesResponseType(StatusCodes.Status200OK)]
+    [ProducesResponseType(StatusCodes.Status400BadRequest)]
+    [ApiController]
+    [Route("data-push")]
+    public class ScDataPushController : ControllerBase
+    {
+        private readonly AzureCosmosFactory _azureCosmos;
+        private readonly AzureStorageFactory _azureStorage;
+  
+        public readonly string type = "scsyxpt";
+ 
+        public IConfiguration _configuration { get; set; }
+
+        //private readonly ThirdApisService _thirdApisService;
+        public ScDataPushController( AzureCosmosFactory azureCosmos,   AzureStorageFactory azureStorage,  IConfiguration configuration)
+        {
+            _azureCosmos = azureCosmos;
+           
+            _azureStorage = azureStorage;
+          
+            _configuration = configuration;
+           // _thirdApisService = thirdApisService;
+        }
+     
+        [ProducesDefaultResponseType]
+        [HttpPost("check")]
+        public async Task<IActionResult> PushCheck(JsonElement json) {
+             
+            var client = _azureCosmos.GetCosmosClient();
+            JsonElement areaIdJson = json.GetProperty("areaId");
+            AreaSetting areaSetting = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemAsync<AreaSetting>($"{areaIdJson}", new PartitionKey("AreaSetting"));
+            ScAccessConfig config = areaSetting.accessConfig.ToObject<ScAccessConfig>();
+            JsonElement school = json.GetProperty("school");
+            List<string> pushTeachers = json.GetProperty("pushTeachers").ToObject<List<string>>();
+            StringBuilder queryText = new StringBuilder($"SELECT distinct value(c) FROM c where c.type='yxtrain'");
+            List<GroupList> yxtrain = new List<GroupList>();
+            await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<GroupList>(queryText: queryText.ToString(),
+            requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"GroupList-{school}") }))
+            {
+                yxtrain.Add(item);
+            }
+            List<TeacherTrain> trains = new List<TeacherTrain>();
+            var members = yxtrain.SelectMany(x => x.members).ToList();
+            //指定推送一部分的教师 
+            if (pushTeachers.IsNotEmpty())
+            {
+                members = members.FindAll(x => pushTeachers.Contains(x.id));
+            }
+            if (members.IsNotEmpty())
+            {
+                queryText = new StringBuilder($"SELECT distinct value(c) FROM c where 1=1  " +
+                    $"and  c.id in ({string.Join(",", members.Select(x => $"'{x.id}'"))}) ");
+                await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<TeacherTrain>(queryText: queryText.ToString(),
+                requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"TeacherTrain-{school}") }))
+                {
+                    trains.Add(item);
+                }
+            }
+
+            //string sql = $" SELECT value(c) FROM c join a in c.binds where ARRAY_LENGTH(c.binds)>0 and a.type='{config.config}' ";
+            //List<Teacher> teachers = new List<Teacher>();
+            //await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Teacher>(queryText: sql,
+            //    requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
+            //{
+            //    teachers.Add(item);
+            //}
+            var table = _azureStorage.GetCloudTableClient().GetTableReference("ScYxpt");
+            List<ScTeacher> scTeachers = await table.FindListByDict<ScTeacher>(new Dictionary<string, object> { { "PartitionKey", "ScTeacher" }, { "schoolCode", $"{school}" } });
+            List<ScTeacherDiagnosis> scTeacherDiagnoses = await table.FindListByDict<ScTeacherDiagnosis>(new Dictionary<string, object> { { "PartitionKey", "ScTeacherDiagnosis" }, { "schoolCode", $"{school}" } });
+
+            List<KeyValuePair<TeacherTrain, string>> trainsNO = new List<KeyValuePair<TeacherTrain, string>>();
+
+            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;
+            for (int i = 0; i < pages; i++)
+            {
+                List<TeacherTrain> lists = trains.Skip((i) * 20).Take(20).ToList();
+                //5.3.1.12学员培训基本情况批量回写-UpdateTeacherListSituation
+                List<TeacherTrain> trains53112OK = new List<TeacherTrain>();
+                ScsResult UpdateTeacherListSituation = null;
+                Dictionary<string, object> parameterContent53112 = new Dictionary<string, object>();
+                List<Dictionary<string, object>> list53112 = new List<Dictionary<string, object>>();
+                parameterContent53112.Add("TrainComID", config.trainComID);
+                parameterContent53112.Add("List", list53112);
+
+                //5.3.1.13学员能力点测评结果批量回写-UpdateTeacherListDiagnosis  300条限制 
+                List<TeacherTrain> trains53113OK = new List<TeacherTrain>();
+                ScsResult UpdateTeacherListDiagnosis = null;
+                Dictionary<string, object> parameterContent53113 = new Dictionary<string, object>();
+                List<Dictionary<string, object>> list53113 = new List<Dictionary<string, object>>();
+                parameterContent53113.Add("TrainComID", config.trainComID);
+                parameterContent53113.Add("List", list53113);
+
+                //5.3.1.17学员课堂实录批量回写-UploadKTSLList     300条限制 
+                List<TeacherTrain> trains53117OK = new List<TeacherTrain>();
+                ScsResult UploadKTSLList = null;
+                Dictionary<string, object> parameterContent53117 = new Dictionary<string, object>();
+                List<Dictionary<string, object>> list53117 = new List<Dictionary<string, object>>();
+                parameterContent53117.Add("TrainComID", config.trainComID);
+                parameterContent53117.Add("List", list53117);
+
+                //5.3.1.22学员校本教研PDF(每人可以返回多条)批量回写-UploadSBTARPDFListV2   100条限制
+                List<TeacherTrain> trains53122OK = new List<TeacherTrain>();
+                ScsResult UploadSBTARPDFListV2 = null;
+                Dictionary<string, object> parameterContent53122 = new Dictionary<string, object>();
+                List<Dictionary<string, object>> list53122 = new List<Dictionary<string, object>>();
+                parameterContent53122.Add("TrainComID", config.trainComID);
+                parameterContent53122.Add("List", list53122);
+                //装载数据
+                dicts.Add(parameterContent53112);
+                dicts.Add(parameterContent53113);
+                dicts.Add(parameterContent53117);
+                dicts.Add(parameterContent53122);
+                foreach (var x in lists)
+                {
+                    List<KeyValuePair<string, string>> msgs = new List<KeyValuePair<string, string>>();
+                    List<ScTeacher> teacher = scTeachers.FindAll(t => !string.IsNullOrWhiteSpace(t.tmdid) && t.tmdid.Equals(x.id));
+                    foreach (var t in teacher)
+                    {
+                        List<PushFail> fails = new List<PushFail>();
+                        Dictionary<string, object> pushData = new Dictionary<string, object>();
+                        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);
+                        (int t53117OK, List<KeyValuePair<string, string>> msgs53117) = ThirdService.check53117(x, msgs);
+                        (int t53122OK, List<KeyValuePair<string, string>> msgs53122) = ThirdService.check53122(x, msgs);
+
+                        //5.3.1.12学员培训基本情况批量回写-UpdateTeacherListSituation
+                        if (t53112OK == 1)
+                        {
+                            Dictionary<string, object> parameterMapData = new Dictionary<string, object>();
+                            parameterMapData.Add("PXID", $"{t.PXID}");
+                            parameterMapData.Add("TID", $"{t.TID}");
+                            parameterMapData.Add("TeacherName", $"{t.TeacherName}");
+                            parameterMapData.Add("CourseHour", $"{x.totalTime}");
+                            parameterMapData.Add("ResearchText", $"{x.summary}");
+                            /// <summary>
+                            ///省上标准  最终结果 0未认定,1合格,2优秀,3不合格,4其他
+                            ///系统标准 -2 其他 -1 未认定,0不合格,1合格,2优秀
+                            /// </summary>
+                            string ComPassed = "0";
+                            switch (x.finalScore)
+                            {
+                                case -2:
+                                    ComPassed = "4";
+                                    break;
+                                case -1:
+                                    ComPassed = "0";
+                                    break;
+                                case 0:
+                                    ComPassed = "3";
+                                    break;
+                                case 1:
+                                    ComPassed = "1";
+                                    break;
+                                case 2:
+                                    ComPassed = "2";
+                                    break;
+                                default:
+                                    ComPassed = "4";
+                                    break;
+                            }
+                            parameterMapData.Add("ComPassed", ComPassed);//0、未认定  1、合格  2、优秀  3、不合格  4、其他
+                            pushData.Add("success-UpdateTeacherListSituation", parameterMapData);
+                            list53112.Add(parameterMapData);
+                        }
+                        else
+                        {
+                            pushData.Add("fail-UpdateTeacherListSituation", new PushFail { tmdid = t.tmdid, name = t.TeacherName, msgs = msgs53112 });
+                            fails.Add(new PushFail { tmdid = t.tmdid, name = t.TeacherName, msgs = msgs53112 });
+                        }
+                        //5.3.1.13学员能力点测评结果批量回写-UpdateTeacherListDiagnosis
+                        if (t53113OK == 1)
+                        {
+                            List<Dictionary<string, object>> parameterMapDatas = new List<Dictionary<string, object>>();
+                            var uploadedAbility= abilitySubs.FindAll(ab => ab.uploads.Count > 0);
+                            x.currency.teacherAilities.ForEach(a => {
+                                Dictionary<string, object> parameterMapData = new Dictionary<string, object>();
+                                parameterMapData.Add("PXID", $"{t.PXID}");
+                                parameterMapData.Add("TID", $"{t.TID}");
+                                parameterMapData.Add("DiagnosisNum", $"{a.no}");
+                                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.uploads.ForEach(upload => {
+                                        upload.urls.ForEach(url => {
+                                            Dictionary<string, object> pfileMap = new Dictionary<string, object>();
+                                            pfileMap.Add("url", url.url);
+                                            pfileMap.Add("fileName", 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);
+                                        });
+                                    });
+                                }
+
+
+                                //0"未认定", 1"合格", 2"优秀", 3"不合格"
+                                //系统 -1 未认定,0 不合格,1 合格,2 优秀
+                                string zpscore = "0";
+                                switch (a.zpscore)
+                                {
+                                    case -1:
+                                        zpscore = "0";
+                                        break;
+                                    case 0:
+                                        zpscore = "3";
+                                        break;
+                                    case 1:
+                                        zpscore = "1";
+                                        break;
+                                    case 2:
+                                        zpscore = "2";
+                                        break;
+                                    default:
+                                        zpscore = "4";
+                                        break;
+                                }
+                                string hpscore = "0";
+                                switch (a.hpscore)
+                                {
+                                    case -1:
+                                        hpscore = "0";
+                                        break;
+                                    case 0:
+                                        hpscore = "3";
+                                        break;
+                                    case 1:
+                                        hpscore = "1";
+                                        break;
+                                    case 2:
+                                        hpscore = "2";
+                                        break;
+                                    default:
+                                        hpscore = "4";
+                                        break;
+                                }
+                                string xzpresult = "0";
+                                switch (a.xzscore)
+                                {
+                                    case -1:
+                                        xzpresult = "0";
+                                        break;
+                                    case 0:
+                                        xzpresult = "3";
+                                        break;
+                                    case 1:
+                                        xzpresult = "1";
+                                        break;
+                                    case 2:
+                                        xzpresult = "2";
+                                        break;
+                                    default:
+                                        xzpresult = "4";
+                                        break;
+                                }
+                                ///上传了三个,且当前没有上传的能力点,标记为为学习状态。
+                                if (uploadedAbility.Count >=3) {
+                                    if (pfiles.Count == 0) {
+                                        zpscore = "4";
+                                        hpscore = "4";
+                                        xzpresult = "4";
+                                    }
+                                }
+                                parameterMapData.Add("zpresult", zpscore);
+                                parameterMapData.Add("hpresult", hpscore);
+                                parameterMapData.Add("xzpresult", xzpresult);
+                               
+                                list53113.Add(parameterMapData);
+                                parameterMapDatas.Add(parameterMapData);
+                            });
+                            pushData.Add("success-UpdateTeacherListDiagnosis", parameterMapDatas);
+
+                        }
+                        else
+                        {
+                            pushData.Add("fail-UpdateTeacherListDiagnosis", new PushFail { tmdid = t.tmdid, name = t.TeacherName, msgs = msgs53113 });
+                            fails.Add(new PushFail { tmdid = t.tmdid, name = t.TeacherName, msgs = msgs53113 });
+                        }
+                        //5.3.1.17学员课堂实录批量回写-UploadKTSLList
+                        if (t53117OK == 1)
+                        {
+                            List<Dictionary<string, object>> parameterMapDatas = new List<Dictionary<string, object>>();
+                            x.teacherClasses.ForEach(clss =>
+                            {
+                                Dictionary<string, object> parameterMapData = new Dictionary<string, object>();
+                                parameterMapData.Add("PXID", $"{t.PXID}");
+                                parameterMapData.Add("TID", $"{t.TID}");
+                                parameterMapData.Add("url", clss.url);//添加访问授权
+                                parameterMapData.Add("url2", clss.url);
+                                parameterMapData.Add("fileName", 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);
+                            });
+                            pushData.Add("success-UploadKTSLList", parameterMapDatas);
+                        }
+                        else
+                        {
+                            pushData.Add("fail-UploadKTSLList", new PushFail { tmdid = t.tmdid, name = t.TeacherName, msgs = msgs53117 });
+                            fails.Add(new PushFail { tmdid = t.tmdid, name = t.TeacherName, msgs = msgs53117 });
+                        }
+                        //5.3.1.22学员校本教研PDF(每人可以返回多条)批量回写-UploadSBTARPDFListV2
+                        if (t53122OK == 1)
+                        {
+                            Dictionary<string, object> parameterMapData = new Dictionary<string, object>();
+                            parameterMapData.Add("PXID", $"{t.PXID}");
+                            parameterMapData.Add("TID", $"{t.TID}");
+                            List<Dictionary<string, object>> files = new List<Dictionary<string, object>>();
+                            x.offlineRecords.ForEach(record => {
+                                if (!string.IsNullOrWhiteSpace(record.url))
+                                {
+                                    Dictionary<string, object> fileMap = new Dictionary<string, object>();
+                                    fileMap.Add("url", record.url);
+                                    fileMap.Add("fileName", 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);
+                                }
+                            });
+                            if (x.offlineReport != null) {
+                                Dictionary<string, object> fileMap = new Dictionary<string, object>();
+                                fileMap.Add("url", x.offlineReport.blob);
+                                fileMap.Add("fileName", x.offlineReport.name);
+                                fileMap.Add("fileSize", x.offlineReport.size);
+                                fileMap.Add("md5", x.offlineReport.hash);
+                                string fileext = x.offlineReport.extension;
+                                fileMap.Add("fileType", fileext);
+                                files.Add(fileMap);
+                            }
+                            parameterMapData.Add("files", files);
+                            list53122.Add(parameterMapData);
+                            pushData.Add("success-UploadSBTARPDFListV2", parameterMapData);
+                        }
+                        else
+                        {
+                            pushData.Add("fail-UploadSBTARPDFListV2", new PushFail { tmdid = t.tmdid, name = t.TeacherName, msgs = msgs53122 });
+                            fails.Add(new PushFail { tmdid = t.tmdid, name = t.TeacherName, msgs = msgs53122 });
+                        }
+                        pushDatas.Add(t.tmdid, pushData);
+                    }
+                }
+                //推送数据
+                //UpdateTeacherListSituation = await _thirdApisService.Post(config.url, "UpdateTeacherListSituation", config.passKey, config.privateKey, parameterContent53112);
+                //UpdateTeacherListSituation.code = "UpdateTeacherListSituation";
+                //UpdateTeacherListSituation.title = "5.3.1.12学员培训基本情况批量回写";
+
+                //UpdateTeacherListDiagnosis = await _thirdApisService.Post(config.url, "UpdateTeacherListDiagnosis", config.passKey, config.privateKey, parameterContent53113);
+                //UpdateTeacherListDiagnosis.code = "UpdateTeacherListDiagnosis";
+                //UpdateTeacherListDiagnosis.title = "5.3.1.13学员能力点测评结果批量回写";
+
+                //UploadKTSLList = await _thirdApisService.Post(config.url, "UploadKTSLList", config.passKey, config.privateKey, parameterContent53117);
+                //UploadKTSLList.code = "UploadKTSLList";
+                //UploadKTSLList.title = "5.3.1.17学员课堂实录批量回写";
+
+                //UploadSBTARPDFListV2 = await _thirdApisService.Post(config.url, "UploadSBTARPDFListV2", config.passKey, config.privateKey, parameterContent53122);
+                //UploadSBTARPDFListV2.code = "UploadSBTARPDFListV2";
+                //UploadSBTARPDFListV2.title = "5.3.1.22学员校本教研PDF(每人可以返回多条)批量回写";
+                //results.Add(UpdateTeacherListSituation);
+                //results.Add(UpdateTeacherListDiagnosis);
+                //results.Add(UploadKTSLList);
+                //results.Add(UploadSBTARPDFListV2);
+            }
+         
+            return Ok(new { data = new { results, pushDatas, dicts } });        
+        }
+
+      
+    }
+}

+ 46 - 11
TEAMModelOS/Controllers/XTest/FixDataController.cs

@@ -2718,20 +2718,55 @@ namespace TEAMModelOS.Controllers
             return Ok();
         }
 
-        [HttpPost("deleet-arr")]
-        public async Task<IActionResult> deleetArr(JsonElement json)
+        [HttpPost("restore-teacher-pdf")]
+        public async Task<IActionResult> restoreteacherpdf(JsonElement json)
         {
-            List<string> s =   await _azureStorage.GetBlobContainerClient("teammodelos").List() ;
-            List<string> dele = new List<string>();
-            s.ForEach(x => {
-                if (x.Contains("offline-report.pdf")) {
-                    string[] ss = x.Split("/");
-                    if (ss.Length == 2) {
-                        dele.Add(x);
+            var client = _azureStorage.GetBlobContainerClient($"teammodelos");
+
+            string sql = $"SELECT  distinct  c.id,s.schoolId as code , c.name as nickname, s.name as name     FROM c  join s in  c.schools where s.areaId='f35e0031-a53f-45e5-b307-1cd39446a2cf'" +
+            $" and array_length(c.binds)>0  ";
+            List<IdNameCode> tmdidSchooCode = new List<IdNameCode>();
+            await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetItemQueryIterator<IdNameCode>(queryText: sql,
+                requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
+            {
+                tmdidSchooCode.Add(item);
+            }
+            var blobclient = _azureStorage.GetBlobContainerClient($"teammodelos");
+           var s= _azureStorage.GetBlobContainerSAS99Year("teammodelos", Azure.Storage.Sas.BlobContainerSasPermissions.Read);
+            string sas= s.sas;
+            foreach (var idcode in tmdidSchooCode) {
+
+                Azure.Response teacherTrainRes = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReadItemStreamAsync(idcode.id, new PartitionKey($"TeacherTrain-{idcode.code}"));
+                if (teacherTrainRes.Status == 200)
+                {
+                    TeacherTrain teacherTrain = JsonDocument.Parse(teacherTrainRes.Content).RootElement.Deserialize<TeacherTrain>();
+                    try
+                    {
+                        if (!string.IsNullOrWhiteSpace(teacherTrain.offlineUrl)) {
+                            BlobDownloadInfo blobDownload = await blobclient.GetBlobClient(teacherTrain.offlineUrl).DownloadAsync(range: new HttpRange(0, 4 * 1048576), rangeGetContentHash: true);
+                            if (blobDownload.Details.ContentHash != null)
+                            {
+
+                                string hash = Md5Hash.GetbyteToString(blobDownload.Details.ContentHash);
+                                teacherTrain.offlineReport = new Attachment
+                                {
+                                    hash = hash,
+                                    url = teacherTrain.offlineUrl,
+                                    blob = $"{blobclient.Uri}/{teacherTrain.offlineUrl}",
+                                    extension = "pdf",
+                                    name = $"{teacherTrain.nickname}-校本研修汇总报告.pdf",
+                                    type = "doc",
+                                    size = blobDownload.ContentLength
+                                };
+                                await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReplaceItemAsync<TeacherTrain>(teacherTrain, idcode.id, new PartitionKey($"TeacherTrain-{idcode.code}"));
+                            }
+                        }
+                    }
+                    catch
+                    {
                     }
                 }
-            });
-            await _azureStorage.GetBlobServiceClient().DeleteBlobs(_dingDing, "teammodelos", dele);
+            }
             return Ok();
         }