Browse Source

update 研修调整

CrazyIter_Bin 3 years ago
parent
commit
48a2304858

+ 2 - 0
TEAMModelOS.FunctionV4/ServiceBus/ActiveTaskTopic.cs

@@ -1394,6 +1394,8 @@ namespace TEAMModelOS.FunctionV4.ServiceBus
                         var messageChange = new ServiceBusMessage(new   { delete_id =lessonId, tmdid =tmdid,scope=scope,opt="delete",school=school}.ToJsonString());
                         var messageChange = new ServiceBusMessage(new   { delete_id =lessonId, tmdid =tmdid,scope=scope,opt="delete",school=school}.ToJsonString());
                         messageChange.ApplicationProperties.Add("name", "LessonRecordEvent");
                         messageChange.ApplicationProperties.Add("name", "LessonRecordEvent");
                         await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageChange);
                         await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageChange);
+                        await _dingDing.SendBotMsg($"课例因【{lessonRecord.name}】,【{lessonRecord.id}】时间到期,即将被自动删除,到期时间:" +
+                            $"{lessonRecord.expire}\n{lessonRecord.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
                     }
                     }
                 }
                 }
                 string biz = "expire";
                 string biz = "expire";

+ 1 - 1
TEAMModelOS.SDK/Context/Constant/Constant.cs

@@ -19,7 +19,7 @@ namespace TEAMModelOS.SDK.DI
         public static readonly string Common = "Common";
         public static readonly string Common = "Common";
         public static readonly string Teacher = "Teacher";
         public static readonly string Teacher = "Teacher";
         public static readonly string Student = "Student";
         public static readonly string Student = "Student";
-        public static readonly int private_lesson_limit =30;
+        public static readonly int private_lesson_limit =50;
         public static readonly int private_lesson_expire = 7;
         public static readonly int private_lesson_expire = 7;
     }
     }
 }
 }

+ 1 - 1
TEAMModelOS.SDK/DI/HttpTrigger/HttpTrigger.cs

@@ -38,7 +38,7 @@ namespace TEAMModelOS.SDK.DI
             string domain = "";
             string domain = "";
             if (location.Equals("China-Dep"))
             if (location.Equals("China-Dep"))
             {
             {
-                domain = keys[0];
+                domain = keys[2];
             }
             }
             else if (location.Equals("China-Test"))
             else if (location.Equals("China-Test"))
             {
             {

+ 0 - 16
TEAMModelOS.SDK/Models/Service/Third/Nx/OAuthModel.cs

@@ -1,16 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace TEAMModelOS.SDK.Models
-{
-    public class OAuthModel
-    {
-    }
-    public record OAuth {
-        public string code { get; set; }
-        public string state { get; set; }
-    }
-}

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

@@ -294,7 +294,9 @@ namespace TEAMModelOS.Controllers
                     };
                     };
                     dynamics.Add(dynamic);
                     dynamics.Add(dynamic);
                 });
                 });
-
+                //var table = _azureStorage.GetCloudTableClient().GetTableReference("ScYxpt");
+                //var ScTeachers = await table.FindListByDict<ScTeacher>(new Dictionary<string, object>() { { "PartitionKey", "ScTeacher" }, { "areaId", $"{setting.id}" } });
+                //var ttt = ScTeachers.Select(x => x.tmdid).Except(teacherTrains.Select(x => x.id));
 
 
                 return Ok(new { teacherTrains= dynamics, setting, schools = schoolInfos, totalTime, hgcount, teacherCount = countArea, appraiseCount = appraiseArea });
                 return Ok(new { teacherTrains= dynamics, setting, schools = schoolInfos, totalTime, hgcount, teacherCount = countArea, appraiseCount = appraiseArea });
             }
             }
@@ -439,6 +441,7 @@ namespace TEAMModelOS.Controllers
                         y.debateOrther = y.debateOrther > 0 ? y.debateOrther : 0;
                         y.debateOrther = y.debateOrther > 0 ? y.debateOrther : 0;
                     });
                     });
                 });
                 });
+             
                 return Ok(new { teacherTrains, setting, schools = schoolInfos, totalTime, hgcount, teacherAilities, teacherCount = countArea, appraiseCount = appraiseArea });
                 return Ok(new { teacherTrains, setting, schools = schoolInfos, totalTime, hgcount, teacherAilities, teacherCount = countArea, appraiseCount = appraiseArea });
             }
             }
             catch (Exception ex)
             catch (Exception ex)

+ 5 - 0
TEAMModelOS/Controllers/Student/StudentCommonController.cs

@@ -8,6 +8,7 @@ using System.Linq;
 using System.Text.Json;
 using System.Text.Json;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using TEAMModelOS.Filter;
 using TEAMModelOS.Filter;
+using TEAMModelOS.SDK;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models;
@@ -287,7 +288,11 @@ namespace TEAMModelOS.Controllers
                     try
                     try
                     {
                     {
                         course = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Course>(cos.id, new Azure.Cosmos.PartitionKey(cos.scode));
                         course = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Course>(cos.id, new Azure.Cosmos.PartitionKey(cos.scode));
+                        var list = course.schedule.Where(x => string.IsNullOrWhiteSpace(x.stulist)).Select(x => x.stulist);
+
+                        
                     }
                     }
+                    //需要处理 当前这个老师已经不在相关名单内。
                     catch (CosmosException ex) { course = null; }
                     catch (CosmosException ex) { course = null; }
                     sc.Add(new CourseDto { course = course, stuCourse = cos });
                     sc.Add(new CourseDto { course = course, stuCourse = cos });
                 }
                 }

+ 0 - 104
TEAMModelOS/Controllers/Third/OAuth2Controller.cs

@@ -1,104 +0,0 @@
-using Microsoft.AspNetCore.Mvc;
-using System;
-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 TEAMModelOS.SDK.DI.AzureCosmos.Inner;
-using Microsoft.Extensions.Options;
-using Azure.Messaging.ServiceBus;
-using Microsoft.Extensions.Configuration;
-using HTEXLib.COMM.Helpers;
-using TEAMModelOS.SDK;
-using System.IdentityModel.Tokens.Jwt;
-using TEAMModelOS.Services;
-using TEAMModelOS.SDK.Models.Service;
-using System.IO;
-using System.Dynamic;
-using Microsoft.AspNetCore.Authorization;
-using Azure.Storage.Blobs.Models;
-using static TEAMModelOS.SDK.Models.Teacher;
-using System.Web;
-using static TEAMModelOS.Controllers.FixDataController;
-using static TEAMModelOS.SDK.SchoolService;
-using Microsoft.AspNetCore.Hosting;
-namespace TEAMModelOS.Controllers
-{
-    // <summary>
-    ///  标准OAuth2
-    /// </summary>
-    ///  
-    [ProducesResponseType(StatusCodes.Status200OK)]
-    [ProducesResponseType(StatusCodes.Status400BadRequest)]
-    //
-    //[Route("")]
-    //[Route("api/[controller]")]
-    [ApiController]
-    public class OAuth2Controller : ControllerBase
-    {
-        private readonly SnowflakeId _snowflakeId;
-        private readonly AzureCosmosFactory _azureCosmos;
-        private readonly DingDing _dingDing;
-        private readonly Option _option;
-        private readonly AzureStorageFactory _azureStorage;
-        private readonly AzureServiceBusFactory _serviceBus;
-        private readonly AzureRedisFactory _azureRedis;
-        private readonly CoreAPIHttpService _coreAPIHttpService;
-        private readonly ThirdApisService _scsApisService;
-        private readonly HttpTrigger _httpTrigger;
-        private readonly IWebHostEnvironment _environment;
-        /// <summary>
-        /// 机构安全码
-        /// </summary>
-        public string _sc_passKey;
-        /// <summary>
-        /// 机构ID
-        /// </summary>
-        public string _sc_trainComID;
-        /// <summary>
-        /// 机构 AES 密钥
-        /// </summary>
-        public string _sc_privateKey;
-        /// <summary>
-        /// 访问地址
-        /// </summary>
-        public string _sc_url;
-        public IConfiguration _configuration { get; set; }
-        public OAuth2Controller(IWebHostEnvironment environment, AzureCosmosFactory azureCosmos, SnowflakeId snowflakeId, DingDing dingDing, IOptionsSnapshot<Option> option, AzureStorageFactory azureStorage,
-          AzureRedisFactory azureRedis, AzureServiceBusFactory serviceBus, IConfiguration configuration, CoreAPIHttpService coreAPIHttpService, ThirdApisService scsApisService, HttpTrigger httpTrigger)
-        {
-            _azureCosmos = azureCosmos;
-            _snowflakeId = snowflakeId;
-            _dingDing = dingDing;
-            _option = option?.Value;
-            _azureStorage = azureStorage;
-            _serviceBus = serviceBus;
-            _configuration = configuration;
-            _azureRedis = azureRedis;
-            _coreAPIHttpService = coreAPIHttpService;
-            _scsApisService = scsApisService;
-            _httpTrigger = httpTrigger;
-            _environment = environment;
-        }
-
-        /// <summary>
-        ///  标准OAuth2  方式的回调地址。
-        /// </summary>D:\VisualStudioProjects\TEAMModelOS\TEAMModelOS.SDK\Models\Service\Third\ScYxptModel.cs
-        /// <param name="request"></param>
-        /// <returns></returns>
-
-        [HttpGet("{path}/oauth2")]
-        [AllowAnonymous]
-        public async Task<IActionResult> Oauth2([FromQuery] OAuth oauth2, string path) {
-            //https://ssoserviceurl/oauth2/authorize?client_id=APPKEY&openid=OPENID=&service=SERVICE
-            return Ok(new { oauth2, path });
-        }
-    }
-}

+ 86 - 47
TEAMModelOS/Controllers/XTest/FixDataController.cs

@@ -2291,6 +2291,57 @@ namespace TEAMModelOS.Controllers
             }
             }
             return Ok(new { lessonRecords });
             return Ok(new { lessonRecords });
         }
         }
+        /// <summary>
+        /// 修复学校课例及blob计算
+        /// </summary>
+        /// <param name="jsonElement"></param>
+        /// <returns></returns>
+        [HttpPost("check-scteacher")]
+        public async Task<IActionResult> CheckScTeacher(JsonElement request) {
+            if (!request.TryGetProperty("accessConfig", out JsonElement accessConfig)) return BadRequest();
+            if (!request.TryGetProperty("city", out JsonElement city)) return BadRequest();
+            if (!request.TryGetProperty("dist", out JsonElement dist)) return BadRequest();
+            if (!request.TryGetProperty("areaId", out JsonElement areaId)) return BadRequest();
+            if (!request.TryGetProperty("standard", out JsonElement standard)) return BadRequest();
+            var table = _azureStorage.GetCloudTableClient().GetTableReference("ScYxpt");
+            var ScTeachers = await table.FindListByDict<ScTeacher>(new Dictionary<string, object>() { { "PartitionKey", "ScTeacher" }, { "areaId", $"{areaId}" } });
+            Dictionary<string, object> dict = new Dictionary<string, object> { { "accessConfig", $"{accessConfig}" }, { "areaId", $"{areaId}" } };
+            (int status, string json) = await _httpTrigger.RequestHttpTrigger(dict, _option.Location, "GetTeachersListByProject");
+            var teachers = json.ToObject<List<ScTeacher>>(new JsonSerializerOptions { PropertyNameCaseInsensitive = false });
+            var dbIds = ScTeachers.Select(x => x.PXID);
+            var scIds = teachers.Select(x => x.PXID);
+            var dbMore= dbIds.Except(scIds);
+            List<ScTeacher> dbtech = new List<ScTeacher>();
+            foreach (var item in dbMore) {
+                dbtech.Add(ScTeachers.Find(x => x.PXID==item));
+            }
+            List<ScTeacher> sctech = new List<ScTeacher>();
+            var scMore = scIds.Except(dbIds);
+            foreach (var item in scMore)
+            {
+                sctech.Add(teachers.Find(x => x.PXID == item));
+            }
+            List<string> tmdids = new List<string>();
+            var group=  ScTeachers.Where(x => !string.IsNullOrWhiteSpace(x.tmdid)).GroupBy(x => x.tmdid).Select(x => new { x.Key,list= x.ToList() });
+            group.ToList().ForEach(x =>
+            {
+                if (x.list.Count > 1) {
+                    tmdids.Add(x.Key);
+                }
+            });
+            List<string> teacherTrainsIds = new List<string>();
+            string insql = $"where c.id in ({string.Join(",", ScTeachers.Select(x => $"'{x.tmdid}'"))})";
+            string selsql = $"select value(c.id) from c {insql}  and c.pk='TeacherTrain' ";
+            await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<string>(queryText: selsql,
+                  requestOptions: new QueryRequestOptions() { }))
+            {
+                teacherTrainsIds.Add(item);
+            }
+            var bindids=  ScTeachers.Where(x => !string.IsNullOrWhiteSpace(x.tmdid)).Select(x => x.tmdid);
+            var noTrains= bindids.Except(teacherTrainsIds);
+            return Ok(new { dbtech , sctech,ScCount= teachers .Count, DBCount= ScTeachers.Count , ScTeachers, tmdids, noTrains });
+        }
+
         /// <summary>
         /// <summary>
         /// 修复学校课例及blob计算
         /// 修复学校课例及blob计算
         /// </summary>
         /// </summary>
@@ -2319,9 +2370,11 @@ namespace TEAMModelOS.Controllers
                 List<Task<ItemResponse<Student>>> tasks = new List<Task<ItemResponse<Student>>>();
                 List<Task<ItemResponse<Student>>> tasks = new List<Task<ItemResponse<Student>>>();
                 var groups= students.Where(x => !string.IsNullOrWhiteSpace(x.classId)).GroupBy(y => y.classId).Select(z => new { key = z.Key,list = z.ToList() });
                 var groups= students.Where(x => !string.IsNullOrWhiteSpace(x.classId)).GroupBy(y => y.classId).Select(z => new { key = z.Key,list = z.ToList() });
                 foreach (var group in groups) {
                 foreach (var group in groups) {
-                    foreach (var stu in group.list) {
-                        var lst = DoIrs(group.list, stu);
-                        tasks.Add(_azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).ReplaceItemAsync(stu, stu.id, new PartitionKey($"Base-{id}")));
+                   var list= DoIrs(group.list);
+                    if (list != null) {
+                        list.ForEach(stu => {
+                            tasks.Add(_azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).ReplaceItemAsync(stu, stu.id, new PartitionKey($"Base-{id}")));
+                        });
                     }
                     }
                 }
                 }
                 int pagesize = 1000;
                 int pagesize = 1000;
@@ -2342,54 +2395,40 @@ namespace TEAMModelOS.Controllers
             }
             }
             return Ok(studentsData);
             return Ok(studentsData);
         }
         }
-        private List<Student> DoIrs(List<Student> students, Student student) {
-            string irs = string.Empty;
-            if (int.TryParse(student.id.Substring(student.id.Length - 2, 2), out int _no2))
-            {
-                irs = $"{_no2}";
-            }
-            if (string.IsNullOrWhiteSpace(irs))
+        private List<Student> DoIrs(List<Student> students) {
+            List<int> ids = new List<int>(students.Count);
+             bool  hasAbc=false;
+            int index = students.Count;
+            if (!students.Select(x => x.irs).Contains("1"))
             {
             {
-                if (int.TryParse(student.id.Substring(student.id.Length - 1, 1), out int _no1))
+                foreach (var stu in students)
                 {
                 {
-                    irs = $"{_no1}";
+                    if (int.TryParse(stu.id, out int id))
+                    {
+                        ids.Add(id);
+                    }
+                    else
+                    {
+                        hasAbc = true;
+                    }
                 }
                 }
+                ids = ids.OrderBy(x => x).ToList();
+                if (!hasAbc)
+                {
+                    for (int i = 0; i < ids.Count; i++)
+                    {
+                        var stu = students.Find(x => x.id.Equals($"{ids[i]}"));
+                        if (stu != null)
+                        {
+                            stu.irs = $"{(i + 1)}";
+                            stu.no = $"{(i + 1)}";
+                        }
+                    }
+                }
+                return students;
             }
             }
-            //if (string.IsNullOrWhiteSpace(irs))
-            //{
-            //    List<string> irsOrder = students.Select(x => x.irs)?.Where(y => !string.IsNullOrEmpty(y) && Regex.IsMatch(y, @"^\d*$")).OrderBy(x => int.Parse(x)).ToList();
-            //    if (!irsOrder.Contains("0"))
-            //    {
-            //        irsOrder.Insert(0, "0");
-            //    }
-            //    if (irsOrder != null)
-            //    {
-            //        if (!irsOrder.Contains("0"))
-            //        {
-            //            irsOrder.Insert(0, "0");
-            //        }
-            //    }
-            //    else { irsOrder = new List<string>() { "0" }; }
-            //    for (int i = 0; i < irsOrder.Count; i++)
-            //    {
-            //        irs = $"{int.Parse(irsOrder[i]) + 1}";
-            //        int index = i + 1;
-            //        if (index <= irsOrder.Count - 1)
-            //        {
-            //            if (!irs.Equals(irsOrder[index]))
-            //            {
-            //                break;
-            //            }
-            //        }
-            //    }
-            //}
-            if (!string.IsNullOrWhiteSpace(irs)) {
-                student.irs = irs;
-                student.no = irs;
-                var stu = students.Find(x => x.id.Equals(student.id));
-                stu.irs = irs; stu.no = irs;
-            }
-            return students;
+            else { return null; }
+            
         }
         }
      
      
 
 

+ 27 - 0
TEAMModelOS/Controllers/XTest/TestController.cs

@@ -891,6 +891,33 @@ namespace TEAMModelOS.Controllers
             return Ok(new { right,left});
             return Ok(new { right,left});
         }
         }
 
 
+
+
+        [HttpPost("get-teacher-video")]
+        public async Task<IActionResult> GetScteacherClassVideo(JsonElement json)
+        {
+            string sql = " SELECT c.id ,c.school as code FROM c  where c.pk='ClassVideo' and c.school<>'SYSTEM_NO_SCHOOL' and ARRAY_LENGTH(c.files)>0  ";
+            List<IdNameCode> idNameCodes = new List<IdNameCode>();
+            await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetItemQueryIterator<IdNameCode>(sql, requestOptions: new QueryRequestOptions { }))
+            {
+                idNameCodes.Add(item);
+            }
+            foreach (var item in idNameCodes) {
+                try
+                {
+                    TeacherTrain teacherTrain = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReadItemAsync<TeacherTrain>(item.id, new PartitionKey($"TeacherTrain-{item.code}"));
+                    if (!teacherTrain.teacherClasses.Any())
+                    {
+                        teacherTrain.update.Add("TeacherClass");
+                        await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReplaceItemAsync<TeacherTrain>(teacherTrain, teacherTrain.id, new PartitionKey($"TeacherTrain-{item.code}"));
+                    }
+                } catch (Exception ex) {
+                    continue;
+                }
+            }
+            
+            return Ok();
+        }
         [HttpPost("fix-teacher-ability-files")]
         [HttpPost("fix-teacher-ability-files")]
         public async Task<IActionResult> TestScteacher(JsonElement json) {
         public async Task<IActionResult> TestScteacher(JsonElement json) {
             if (!json.TryGetProperty("ids", out JsonElement _ids)) return BadRequest();
             if (!json.TryGetProperty("ids", out JsonElement _ids)) return BadRequest();

+ 1 - 1
TEAMModelOS/TEAMModelOS.csproj

@@ -85,5 +85,5 @@
     </ItemGroup>
     </ItemGroup>
   </Target>
   </Target>
 
 
-  <ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JsonSchema="" clientapp_4package_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
+  <ProjectExtensions><VisualStudio><UserProperties appsettings_1development_1json__JsonSchema="https://appsemble.app/api.json" appsettings_1json__JsonSchema="" clientapp_4package_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
 </Project>
 </Project>