CrazyIter_Bin 2 yıl önce
ebeveyn
işleme
8c3ef65b4d

+ 84 - 0
TEAMModelOS.FunctionV4/HttpTrigger/IESHttpTrigger.cs

@@ -4,6 +4,7 @@ using HTEXLib.COMM.Helpers;
 using Microsoft.Azure.Cosmos.Table;
 using Microsoft.Azure.Functions.Worker;
 using Microsoft.Azure.Functions.Worker.Http;
+using OpenXmlPowerTools;
 using StackExchange.Redis;
 using System;
 using System.Collections.Generic;
@@ -72,6 +73,89 @@ namespace TEAMModelOS.FunctionV4.HttpTrigger
 
 
         }
+
+        /// <summary>
+        /// 区级艺术评价变更,异步同步已开启数据同步的学校。
+        /// </summary>
+        /// <param name="req"></param>
+        /// <param name="log"></param>
+        /// <returns></returns>
+        [Function("area-artsetting-change")]
+        public async Task<HttpResponseData> AreaArtSettingChange([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequestData req) {
+            var response = req.CreateResponse(HttpStatusCode.OK);
+            string data = await new StreamReader(req.Body).ReadToEndAsync();
+            var json = JsonDocument.Parse(data).RootElement;
+            json.TryGetProperty("areaId", out JsonElement _areaId);
+            string schoolSQL = $"select c.id ,c.name ,c.period  from c where c.areaId='{_areaId}'";
+            List<School> schools = new List<School>();
+            await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School)
+                           .GetItemQueryIterator<School>(queryText: schoolSQL, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Base") }))
+            {
+                schools.Add(item);
+            }
+            ArtSetting artSetting= await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemAsync<ArtSetting>($"{_areaId}", new PartitionKey());
+            foreach (var school in schools) {
+                var periods = school.period.Where(p => !string.IsNullOrWhiteSpace(p.type));
+                foreach (var period in periods)
+                {
+                    var dimension = artSetting.dimensions.FindAll(x => x.type.Contains(period.type));
+                    var bindIds = period.subjects.Where(s => !string.IsNullOrWhiteSpace(s.bindId)).Select(x => x.bindId);
+                    //该学段未同步学科的。
+                    var unBindIds = dimension.Where(z => !string.IsNullOrWhiteSpace(z.subjectBind)).Select(x => x.subjectBind).ToHashSet().Except(bindIds);
+                    if (unBindIds.Any())
+                    {
+                        //尝试寻找同名学科且没有设置bindId的
+                        foreach (var unBindId in unBindIds)
+                        {
+                            var subjects = artSetting.dimensions.FindAll(d => !string.IsNullOrWhiteSpace(d.subjectBind) && !string.IsNullOrWhiteSpace(d.subject) && d.subjectBind.Equals(unBindId))?.Select(m => m.subject);
+                            if (subjects != null)
+                            {
+                                foreach (var subject in subjects)
+                                {
+                                    //获取同名学科,且没绑定的
+                                    var sub = period.subjects.FindAll(sub => sub.name.Equals(subject) && string.IsNullOrWhiteSpace(sub.bindId));
+                                    if (sub.IsNotEmpty())
+                                    {
+                                        sub[0].bindId = unBindId;
+                                    }
+                                    else
+                                    {
+                                        period.subjects.Add(new Subject { id = Guid.NewGuid().ToString(), name = subject, bindId = unBindId, type = 1 });
+
+                                    }
+                                    break;
+                                }
+                            }
+                        }
+                    }
+                    var period_subjects = period.subjects.Where(s => !string.IsNullOrWhiteSpace(s.bindId));
+                    foreach (var subject in period_subjects)
+                    {
+                       var dim= dimension.Where(x => x.subjectBind.Equals(subject.bindId));
+                        if (dim.Any()) {
+                            Knowledge old = null;
+                            string sql = $"select value(c) from c where c.periodId = '{period.id}'";
+                            string pk = $"Knowledge-{school.id}-{subject.id}";
+                            await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").
+                                GetItemQueryIterator<Knowledge>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(pk) }))
+                            {
+                                old = item;
+                                break;
+                            }
+                            //同步知识块。
+                            if (old != null)
+                            {
+
+                            }
+                            else { 
+                            
+                            }
+                        }
+                    }
+                }
+            }
+            return response;
+        }
         /// <summary>
         /// 行政班,学生毕业状态变更。
         /// </summary>

+ 32 - 15
TEAMModelOS.SDK/Context/Constant/Constant.cs

@@ -22,6 +22,23 @@ namespace TEAMModelOS.SDK.DI
         public static readonly int private_lesson_limit = 50;
         public static readonly int private_lesson_expire = 7;
         public static readonly int school_lesson_expire = 7;
+        public static readonly Dictionary<string, string> DefaultPeriod = new Dictionary<string, string> { 
+            {"pre" ,"瀛﹀墠"},
+            {"primary","灏忓�"},
+            {"junior","鍒濅腑"},
+            {"senior","楂樹腑" },
+            {"secondary","中职(中专,技校,职高)" },
+            {"college","楂樿亴锛堜笓绉戯級"},
+            {"university","澶у�鏈��"},
+            {"special","鐗规畩鏁欒偛"},
+            {"edu-bureau","鏁欒偛灞€"},
+            {"elecedu-dept","鐢垫暀閮ㄩ棬"},
+            // {"master","硕士研究生学段"},
+            // {"doctor","博士研究生学段"},
+            // {"adult-secondary","鎴愪汉涓�笓"},
+            // {"adult-higher","鎴愪汉楂樻暀"},
+            //{"other","鍏跺畠"}
+        };
         public static readonly string html = @"
 <!DOCTYPE html>
 <html>
@@ -29,7 +46,7 @@ namespace TEAMModelOS.SDK.DI
     <meta charset=""UTF-8"">
     <meta http-equiv=""X-UA-Compatible"" content=""IE=edge"">
     <meta name=""viewport"" content=""width=device-width, initial-scale=1.0"">
-    <title>校本研修活动完成情况</title>
+    <title>鏍℃湰鐮斾慨娲诲姩瀹屾垚鎯呭喌</title>
     <style>
         body {
             font-family: ""fangsong"";
@@ -95,13 +112,13 @@ namespace TEAMModelOS.SDK.DI
 </head>
 
 <body>
-    <h1 style=""text-align:center;font-weight: bold;"">校本研修活动完成情况</h1>
-    <p class=""title"">教师信息</p>
+    <h1 style=""text-align:center;font-weight: bold;"">鏍℃湰鐮斾慨娲诲姩瀹屾垚鎯呭喌</h1>
+    <p class=""title"">鏁欏笀淇℃伅</p>
     <table class=""tch-table"" id=""tchTable"">
         <tr>
-            <th style=""width: 33.3%;"">教师姓名</th>
-            <th style=""width: 33.3%;"">机构</th>
-            <th style=""width: 33.3%;"">教研组</th>
+            <th style=""width: 33.3%;"">鏁欏笀濮撳悕</th>
+            <th style=""width: 33.3%;"">鏈烘瀯</th>
+            <th style=""width: 33.3%;"">教研组</th>
         </tr>
         <tr>
             <td>{c.cname}</td>
@@ -109,17 +126,17 @@ namespace TEAMModelOS.SDK.DI
             <td>{c.gname}</td>
         </tr>
     </table>
-    <p class=""title"">活动明细</p>
+    <p class=""title"">娲诲姩鏄庣粏</p>
     <table class=""tch-table"" id=""acTable"">
         <tr>
-            <th style=""width: 25%;"">活动主题</th>
-            <th style=""width: 15%;"">活动类型</th>
-            <th style=""width: 5%;"">任务学时</th>
-            <th style=""width: 5%;"">完成学时</th>
-            <th style=""width: 20%;"">活动时间</th>
-            <th style=""width: 10%;"">活动内容</th>
-            <th style=""width: 10%;"">活动任务</th>
-            <th style=""width: 10%;"">状态</th>
+            <th style=""width: 25%;"">娲诲姩涓婚�</th>
+            <th style=""width: 15%;"">娲诲姩绫诲瀷</th>
+            <th style=""width: 5%;"">浠诲姟瀛︽椂</th>
+            <th style=""width: 5%;"">瀹屾垚瀛︽椂</th>
+            <th style=""width: 20%;"">娲诲姩鏃堕棿</th>
+            <th style=""width: 10%;"">娲诲姩鍐呭�</th>
+            <th style=""width: 10%;"">娲诲姩浠诲姟</th>
+            <th style=""width: 10%;"">状态</th>
         </tr>
         {c.details}
     </table>

+ 24 - 1
TEAMModelOS.SDK/Models/Cosmos/Normal/ArtSetting.cs

@@ -6,7 +6,7 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 
-namespace TEAMModelOS.SDK.Models.Cosmos.Normal
+namespace TEAMModelOS.SDK.Models
 {
     public class ArtSetting : CosmosEntity
     {
@@ -53,6 +53,29 @@ namespace TEAMModelOS.SDK.Models.Cosmos.Normal
         /// 描述
         /// </summary>
         public List<ArtDesc> descs { get; set; } = new List<ArtDesc>();
+        /// <summary>
+        /// '学前'period_pre, '小学'period_primary , '初中'period_junior , '高中'period_high, '中职(中专,技校,职高)'period_juniorvoc '高职(专科)'period_college, '大学本科'period_university,"大学硕士",'大学博士','特殊教育'period_special ,'成人中专','成人高等', '其它',
+        /// 学前教育:托儿所、幼儿园、学前班
+        /// 初等教育:
+        ///     初等普通教育:小学
+        /// 中等教育:
+        ///     中等普通教育:
+        ///         初级中等教育(初中)
+        ///         高级中等教育(高中)
+        ///     初等职业学校(小学毕业,由于九年义务教育,则没有此类学校)
+        ///     中等职业教育:
+        ///         中等职业学校(初中毕业,有中等专业学校:中专,技工学校:技校,职业高级中学:职高)
+        ///     成人中等教育:
+        ///         成人中等专业学校:成人中专。
+        ///              
+        ///高等教育:
+        ///     普通高等教育:本科,硕士研究生,博士研究生 。
+        ///     高等职业教育:专科
+        ///         高等职业学校(高中毕业,职业技术学院,等同于高等专科学校)
+        ///     成人高等教育:成人高等
+        /// 学前 period_pre,小学period_primary,初中period_junior,高中period_senior,中职(中专,技校,职高)period_secondary, 高职(专科)period_college,大学本科period_university,硕士研究生学段period_master,博士研究生学段period_doctor,特殊教育period_special ,成人中专period_adult-secondary,成人高教period_adult-higher,其它period_other
+        /// "学前","小学","初中","高中","中职(中专,技校,职高)"," 高职(专科)","大学本科","硕士研究生学段","博士研究生学段","特殊教育","成人中专","成人高教","其它"
+        /// </summary>
         public List<string> type { get; set; } = new List<string>();
     }
 

+ 2 - 0
TEAMModelOS.SDK/Models/Cosmos/School/Inner/Period.cs

@@ -34,6 +34,8 @@ namespace TEAMModelOS.SDK.Models
         /// 课程计划表
         /// </summary>
         public List<TimeTable> timetable { get; set; } = new List<TimeTable>();
+        //"学前","小学","初中","高中","中职(中专,技校,职高)","高职(专科)","大学本科","特殊教育","教育局","电教部门"
+        public string type { get; set; }
     }
 
     /// <summary>

+ 3 - 3
TEAMModelOS/Controllers/Normal/ArtSettingController.cs

@@ -23,7 +23,7 @@ using TEAMModelOS.SDK.DI.AzureCosmos.Inner;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models.Cosmos.Common;
-using TEAMModelOS.SDK.Models.Cosmos.Normal;
+
 using TEAMModelOS.SDK.Models.Service;
 
 namespace TEAMModelOS.Controllers
@@ -113,7 +113,7 @@ namespace TEAMModelOS.Controllers
             catch (CosmosException ex) when (ex.Status == 404)
             {
                 var table = _azureStorage.GetCloudTableClient().GetTableReference("IESOAuth");
-                string tbqurey = $"PartitionKey {QueryComparisons.Equal} 'OAuthShow' and Domain {QueryComparisons.Equal} '{OAuthShow_domain}' and  Code  {QueryComparisons.Equal} '{_areaId}' ";
+                string tbqurey = $"PartitionKey {QueryComparisons.Equal} 'OAuthShow' and Domain {QueryComparisons.Equal} '{OAuthShow_domain}'and Type {QueryComparisons.Equal} 'art' and  Code  {QueryComparisons.Equal} '{_areaId}' ";
                 var result = await table.ExecuteQuerySegmentedAsync(new TableQuery<OAuthShow>().Where(tbqurey), null);
                 List<OAuthShow> shows = result?.Results;
                 if (shows.IsNotEmpty())
@@ -133,7 +133,7 @@ namespace TEAMModelOS.Controllers
             }
             catch (Exception ex)
             {
-                return Ok(new { error = 500, msg = "艺术评价模组暂未授权。" });
+                return Ok(new { error = 500, msg = "系统服务器错误。" });
             }
             try
             {

+ 1 - 1
TEAMModelOS/Controllers/Teacher/InitController.cs

@@ -755,7 +755,7 @@ namespace TEAMModelOS.Controllers
                     areas.ForEach(x => {
                         area_Codes.Add($" Code {QueryComparisons.Equal} '{x.areaId}' ");
                     });
-                    string area_tbqurey = $"PartitionKey {QueryComparisons.Equal} 'OAuthShow' and Domain {QueryComparisons.Equal} '{OAuthShow_domain}' and ( {string.Join(" or ", area_Codes)} )  ";
+                    string area_tbqurey = $"PartitionKey {QueryComparisons.Equal} 'OAuthShow' and Domain {QueryComparisons.Equal} '{OAuthShow_domain}' and Type {QueryComparisons.Equal} 'art' and ( {string.Join(" or ", area_Codes)} )  ";
                     var area_result = await table.ExecuteQuerySegmentedAsync(new TableQuery<OAuthShow>().Where(area_tbqurey), null);
                     areaShows = area_result.Results;
                 }