CrazyIter_Bin 2 years ago
parent
commit
c37e6d345c

+ 111 - 0
TEAMModelOS.SDK/Models/Service/LessonService.cs

@@ -17,6 +17,117 @@ namespace TEAMModelOS.SDK.Models.Service
 {
 {
     public class LessonService
     public class LessonService
     {
     {
+        public static readonly DateTime dateTime1970 = new DateTime(1970, 1, 1).ToLocalTime();
+
+        public static  Dictionary<string, object> GetLessonCond(JsonElement request)
+        {
+            Dictionary<string, object> dict = new Dictionary<string, object>();
+
+            if (request.TryGetProperty("tmdid", out JsonElement tmdid) && !string.IsNullOrWhiteSpace($"{tmdid}"))
+            {
+                dict.Add("tmdid", tmdid);
+            }
+            if (request.TryGetProperty("courseId", out JsonElement courseId) && !string.IsNullOrWhiteSpace($"{courseId}"))
+            {
+                dict.Add("courseId", courseId);
+            }
+            if (request.TryGetProperty("courseIds", out JsonElement courseIds))
+            {
+                dict.Add("courseId[*]", courseIds);
+            }
+            if (request.TryGetProperty("periodId", out JsonElement periodId) && !string.IsNullOrWhiteSpace($"{periodId}"))
+            {
+                dict.Add("periodId", periodId);
+            }
+            if (request.TryGetProperty("subjectId", out JsonElement subjectId))
+            {
+                dict.Add("subjectId", subjectId);
+            }
+            if (request.TryGetProperty("groupIds", out JsonElement groupIds))
+            {
+                dict.Add("groupIds[*]", groupIds);
+            }
+            if (request.TryGetProperty("grade", out JsonElement grade))
+            {
+                dict.Add("grade[*]", grade);
+            }
+            if (request.TryGetProperty("category", out JsonElement category))
+            {
+                dict.Add("category[*]", category);
+            }
+            if (request.TryGetProperty("doubleGreen", out JsonElement doubleGreen) && doubleGreen.GetBoolean())
+            {
+                dict.Add(">=.tScore", 70);
+                dict.Add(">=.pScore", 70);
+            }
+            if (request.TryGetProperty("quality", out JsonElement quality) && quality.GetBoolean())
+            {
+                dict.Add(">=.discuss", 1);
+            }
+            if (request.TryGetProperty("excellent", out JsonElement excellent) && excellent.GetBoolean())
+            {
+                dict.Add(">=.excellent", 1);
+            }
+            if (request.TryGetProperty("name", out JsonElement name) && !string.IsNullOrWhiteSpace($"{name}"))
+            {
+                dict.Add("$.name", name);
+            }
+            if (request.TryGetProperty("today", out JsonElement today) && today.GetBoolean())
+            {
+                DateTime dateTimeA = Convert.ToDateTime(DateTimeOffset.UtcNow.ToString("D"));
+                DateTime dateTimeB = Convert.ToDateTime(DateTimeOffset.UtcNow.ToString("D")).AddDays(1);
+                double dayOf00_00_00 = (dateTimeA - dateTime1970).TotalMilliseconds;
+                double day1Of00_00_00 = (dateTimeB - dateTime1970).TotalMilliseconds;
+                dict.Add(">=.startTime", dayOf00_00_00);
+                dict.Add("<.startTime", day1Of00_00_00);
+            }
+
+            if (request.TryGetProperty("week", out JsonElement week) && week.GetBoolean())
+            {
+                // DateTime dateTimeA = Convert.ToDateTime(DateTimeOffset.UtcNow.ToString("D"));
+                DateTime dateTimeB = Convert.ToDateTime(DateTimeOffset.UtcNow.ToString("D")).AddDays(-7);
+                double now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
+                double dayB = (dateTimeB - dateTime1970).TotalMilliseconds;
+                dict.Add("<=.startTime", now);
+                dict.Add(">=.startTime", dayB);
+            }
+
+            if (request.TryGetProperty("month", out JsonElement month) && month.GetBoolean())
+            {
+                //DateTime dateTimeA = Convert.ToDateTime(DateTimeOffset.UtcNow.ToString("D"));
+                DateTime dateTimeB = Convert.ToDateTime(DateTimeOffset.UtcNow.ToString("D")).AddDays(-30);
+                double now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
+                double dayB = (dateTimeB - dateTime1970).TotalMilliseconds;
+                dict.Add("<=.startTime", now);
+                dict.Add(">=.startTime", dayB);
+            }
+            if (request.TryGetProperty("stime", out JsonElement stime) && !string.IsNullOrWhiteSpace($"{stime}"))
+            {
+                dict.Add(">=.startTime", stime);
+            }
+            if (request.TryGetProperty("etime", out JsonElement etime) && !string.IsNullOrWhiteSpace($"{etime}"))
+            {
+                dict.Add("<=.startTime", etime);
+            }
+            if (request.TryGetProperty("conds", out JsonElement conds) && conds.ValueKind.Equals(JsonValueKind.Array))
+            {
+                List<LessonSettingCond> settingConds = conds.Deserialize<List<LessonSettingCond>>();
+                foreach (var item in settingConds)
+                {
+                    dict.TryAdd($"{item.type}.{item.key}", item.val);
+                    //switch (item.type)
+                    //{
+                    //    case ">=":
+                    //        dict.TryAdd($">=.{item.key}",item.val);
+                    //        break;
+                    //    case "<=":
+                    //        dict.TryAdd($"<=.{item.key}", item.val);
+                    //        break;
+                    //}
+                }
+            }
+            return dict;
+        }
         public static async void DoLessonStudentRecord(DingDing _dingding, SnowflakeId snowflakeId, LessonRecord lessonRecord, string scope, CosmosClient client, string school, string tmdid,
         public static async void DoLessonStudentRecord(DingDing _dingding, SnowflakeId snowflakeId, LessonRecord lessonRecord, string scope, CosmosClient client, string school, string tmdid,
             Teacher teacher, NotificationService _notificationService, AzureServiceBusFactory _serviceBus, AzureStorageFactory _azureStorage, IConfiguration _configuration, LessonBase lessonBase)
             Teacher teacher, NotificationService _notificationService, AzureServiceBusFactory _serviceBus, AzureStorageFactory _azureStorage, IConfiguration _configuration, LessonBase lessonBase)
         {
         {

+ 7 - 114
TEAMModelOS/Controllers/Both/LessonRecordController.cs

@@ -21,7 +21,7 @@ using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.DI.AzureCosmos.Inner;
 using TEAMModelOS.SDK.DI.AzureCosmos.Inner;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models;
-
+using TEAMModelOS.SDK.Models.Service;
 
 
 namespace TEAMModelOS.Controllers
 namespace TEAMModelOS.Controllers
 {
 {
@@ -36,7 +36,7 @@ namespace TEAMModelOS.Controllers
     public class LessonRecordController : ControllerBase
     public class LessonRecordController : ControllerBase
     {
     {
 
 
-        public static readonly DateTime dateTime1970= new DateTime(1970,1,1).ToLocalTime();
+       
         private readonly AzureCosmosFactory _azureCosmos;
         private readonly AzureCosmosFactory _azureCosmos;
         private readonly SnowflakeId _snowflakeId;
         private readonly SnowflakeId _snowflakeId;
         private readonly AzureServiceBusFactory _serviceBus;
         private readonly AzureServiceBusFactory _serviceBus;
@@ -294,7 +294,7 @@ namespace TEAMModelOS.Controllers
             }
             }
             StringBuilder sql = new StringBuilder();
             StringBuilder sql = new StringBuilder();
             sql.Append("select c.id,c.groupIds,c.courseId from c   ");
             sql.Append("select c.id,c.groupIds,c.courseId from c   ");
-            Dictionary<string ,object> dict =  GetLessonCond(request);
+            Dictionary<string ,object> dict = LessonService.GetLessonCond(request);
             AzureCosmosQuery cosmosDbQuery = SQLHelper.GetSQL(dict, sql);
             AzureCosmosQuery cosmosDbQuery = SQLHelper.GetSQL(dict, sql);
             string tbname = "";
             string tbname = "";
             string code = "";
             string code = "";
@@ -446,7 +446,7 @@ namespace TEAMModelOS.Controllers
             StringBuilder sql = new StringBuilder();
             StringBuilder sql = new StringBuilder();
             sql.Append("select   value(c) from c ");
             sql.Append("select   value(c) from c ");
             
             
-            Dictionary<string, object> dict = GetLessonCond(request);
+            Dictionary<string, object> dict = LessonService.GetLessonCond(request);
              
              
             if (request.TryGetProperty("DESC", out JsonElement desc))
             if (request.TryGetProperty("DESC", out JsonElement desc))
             {
             {
@@ -638,7 +638,7 @@ namespace TEAMModelOS.Controllers
             StringBuilder sql = new StringBuilder();
             StringBuilder sql = new StringBuilder();
             sql.Append("select   value(c) from c ");
             sql.Append("select   value(c) from c ");
             int pageCount = 10;
             int pageCount = 10;
-            Dictionary<string, object> dict = GetLessonCond(request);
+            Dictionary<string, object> dict = LessonService.GetLessonCond(request);
             if (request.TryGetProperty("pageCount", out JsonElement _pageCount))
             if (request.TryGetProperty("pageCount", out JsonElement _pageCount))
             {
             {
                 int.TryParse($"{_pageCount}", out int pcount);
                 int.TryParse($"{_pageCount}", out int pcount);
@@ -1010,7 +1010,7 @@ namespace TEAMModelOS.Controllers
         private async Task<List<LessonRecord>> GetOtherLessonCond(JsonElement request,string code ,string tbname,string sqlPrivate) {
         private async Task<List<LessonRecord>> GetOtherLessonCond(JsonElement request,string code ,string tbname,string sqlPrivate) {
             StringBuilder sql = new StringBuilder();
             StringBuilder sql = new StringBuilder();
             sql.Append("select value(c) from c ");
             sql.Append("select value(c) from c ");
-            Dictionary<string, object> dict = GetLessonCond(request);
+            Dictionary<string, object> dict = LessonService.GetLessonCond(request);
             AzureCosmosQuery cosmosDbQuery = SQLHelper.GetSQL(dict, sql);
             AzureCosmosQuery cosmosDbQuery = SQLHelper.GetSQL(dict, sql);
             List<LessonRecord> lessonRecords = new List<LessonRecord>();
             List<LessonRecord> lessonRecords = new List<LessonRecord>();
             cosmosDbQuery.QueryText = cosmosDbQuery.QueryText.Replace("where", $" where (c.status<>404 or IS_DEFINED(c.status) = false )  and  array_length(c.groupIds)>0 {sqlPrivate}  and  ");
             cosmosDbQuery.QueryText = cosmosDbQuery.QueryText.Replace("where", $" where (c.status<>404 or IS_DEFINED(c.status) = false )  and  array_length(c.groupIds)>0 {sqlPrivate}  and  ");
@@ -1030,113 +1030,6 @@ namespace TEAMModelOS.Controllers
             return lessonRecords;
             return lessonRecords;
         }
         }
 
 
-        private Dictionary<string, object> GetLessonCond(JsonElement request)
-        {
-            Dictionary<string, object> dict = new Dictionary<string, object>();
-
-            if (request.TryGetProperty("tmdid", out JsonElement tmdid) && !string.IsNullOrWhiteSpace($"{tmdid}"))
-            {
-                dict.Add("tmdid", tmdid);
-            }
-            if (request.TryGetProperty("courseId", out JsonElement courseId) && !string.IsNullOrWhiteSpace($"{courseId}"))
-            {
-                dict.Add("courseId", courseId);
-            }
-            if (request.TryGetProperty("courseIds", out JsonElement courseIds))
-            {
-                dict.Add("courseId[*]", courseIds);
-            }
-            if (request.TryGetProperty("periodId", out JsonElement periodId) && !string.IsNullOrWhiteSpace($"{periodId}"))
-            {
-                dict.Add("periodId", periodId);
-            }
-            if (request.TryGetProperty("subjectId", out JsonElement subjectId))
-            {
-                dict.Add("subjectId", subjectId);
-            }
-            if (request.TryGetProperty("groupIds", out JsonElement groupIds))
-            {
-                dict.Add("groupIds[*]", groupIds);
-            }
-            if (request.TryGetProperty("grade", out JsonElement grade))
-            {
-                dict.Add("grade[*]", grade);
-            }
-            if (request.TryGetProperty("category", out JsonElement category))
-            {
-                dict.Add("category[*]", category);
-            }
-            if (request.TryGetProperty("doubleGreen", out JsonElement doubleGreen) && doubleGreen.GetBoolean())
-            {
-                dict.Add(">=.tScore", 70);
-                dict.Add(">=.pScore", 70);
-            }
-            if (request.TryGetProperty("quality", out JsonElement quality) && quality.GetBoolean())
-            {
-                dict.Add(">=.discuss", 1);
-            }
-            if (request.TryGetProperty("excellent", out JsonElement excellent) && excellent.GetBoolean())
-            {
-                dict.Add(">=.excellent", 1);
-            }
-            if (request.TryGetProperty("name", out JsonElement name) && !string.IsNullOrWhiteSpace($"{name}"))
-            {
-                dict.Add("$.name", name);
-            }
-            if (request.TryGetProperty("today", out JsonElement today) && today.GetBoolean())
-            {
-                DateTime dateTimeA= Convert.ToDateTime(DateTimeOffset.UtcNow.ToString("D"));
-                DateTime dateTimeB = Convert.ToDateTime(DateTimeOffset.UtcNow.ToString("D")).AddDays(1);
-                double dayOf00_00_00= (dateTimeA - dateTime1970).TotalMilliseconds;
-                double day1Of00_00_00 = (dateTimeB - dateTime1970).TotalMilliseconds;
-                dict.Add(">=.startTime", dayOf00_00_00);
-                dict.Add("<.startTime", day1Of00_00_00);
-            }
-
-            if (request.TryGetProperty("week", out JsonElement week) && week.GetBoolean())
-            {
-               // DateTime dateTimeA = Convert.ToDateTime(DateTimeOffset.UtcNow.ToString("D"));
-                DateTime dateTimeB = Convert.ToDateTime(DateTimeOffset.UtcNow.ToString("D")).AddDays(-7);
-                double now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
-                double dayB = (dateTimeB - dateTime1970).TotalMilliseconds;
-                dict.Add("<=.startTime", now);
-                dict.Add(">=.startTime", dayB);
-            }
-
-            if (request.TryGetProperty("month", out JsonElement month) && month.GetBoolean())
-            {
-                //DateTime dateTimeA = Convert.ToDateTime(DateTimeOffset.UtcNow.ToString("D"));
-                DateTime dateTimeB = Convert.ToDateTime(DateTimeOffset.UtcNow.ToString("D")).AddDays(-30);
-                double now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
-                double dayB = (dateTimeB - dateTime1970).TotalMilliseconds;
-                dict.Add("<=.startTime", now);
-                dict.Add(">=.startTime", dayB);
-            }
-            if (request.TryGetProperty("stime", out JsonElement stime) && !string.IsNullOrWhiteSpace($"{stime}"))
-            {
-                dict.Add(">=.startTime", stime);
-            }
-            if (request.TryGetProperty("etime", out JsonElement etime) && !string.IsNullOrWhiteSpace($"{etime}"))
-            {
-                dict.Add("<=.startTime", etime);
-            }
-            if (request.TryGetProperty("conds", out JsonElement conds) && conds.ValueKind.Equals(JsonValueKind.Array)) {
-                List<LessonSettingCond> settingConds = conds.Deserialize<List<LessonSettingCond>>();
-                foreach (var item in settingConds)
-                {
-                    dict.TryAdd($"{item.type}.{item.key}", item.val);
-                    //switch (item.type)
-                    //{
-                    //    case ">=":
-                    //        dict.TryAdd($">=.{item.key}",item.val);
-                    //        break;
-                    //    case "<=":
-                    //        dict.TryAdd($"<=.{item.key}", item.val);
-                    //        break;
-                    //}
-                }
-            }
-            return dict;
-        }
+      
     }
     }
 }
 }

+ 68 - 0
TEAMModelOS/Controllers/OpenApi/Business/BizLessonRecordController.cs

@@ -0,0 +1,68 @@
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Options;
+using System.Text.Json;
+using System.Threading.Tasks;
+using TEAMModelOS.Filter;
+using TEAMModelOS.Models;
+using TEAMModelOS.SDK;
+using TEAMModelOS.SDK.DI;
+using TEAMModelOS.SDK.Extension;
+namespace TEAMModelOS.Controllers
+{
+    [Route("business")]
+    [ApiController]
+    public class BizLessonRecordController : ControllerBase
+    {
+        public AzureCosmosFactory _azureCosmos;
+        private readonly AzureStorageFactory _azureStorage;
+        private readonly AzureRedisFactory _azureRedis;
+        private readonly DingDing _dingDing;
+        private readonly Option _option;
+        private readonly IConfiguration _configuration;
+        private readonly CoreAPIHttpService _coreAPIHttpService;
+        private readonly AzureServiceBusFactory _serviceBus;
+        public BizLessonRecordController(CoreAPIHttpService coreAPIHttpService, AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage, AzureServiceBusFactory serviceBus, AzureRedisFactory azureRedis, DingDing dingDing, IOptionsSnapshot<Option> option, IConfiguration configuration)
+        {
+            _serviceBus = serviceBus;
+            _azureCosmos = azureCosmos;
+            _azureStorage = azureStorage;
+            _azureRedis = azureRedis;
+            _dingDing = dingDing;
+            _option = option?.Value;
+            _configuration = configuration;
+            _coreAPIHttpService = coreAPIHttpService;
+        }
+        /// <summary>
+        /// 获取开课/课例记录
+        /// </summary>
+        /// <param name="json"></param>
+        /// <returns></returns>
+        [ProducesDefaultResponseType]
+        [HttpPost("get-lesson-record")]
+        [ApiToken(Auth = "1801", Name = " 获取开课/课例记录", RWN = "R", Limit = false)]
+        public async Task<IActionResult> GetLessonRecord(JsonElement json)
+        {
+            var (id, school) = HttpContext.GetApiTokenInfo();
+            var responseData = await OpenApiService.GetLessonRecord(_azureCosmos,   _configuration,   _serviceBus,
+             _option,  _dingDing, id, school, json);
+            return Ok(new { responseData });
+        }  
+        /// <summary>
+        /// 获取开课/课例记录
+        /// </summary>
+        /// <param name="json"></param>
+        /// <returns></returns>
+        [ProducesDefaultResponseType]
+        [HttpPost("get-lesson-record-count")]
+        [ApiToken(Auth = "1802", Name = " 获取开课/课例记录数量", RWN = "R", Limit = false)]
+        public async Task<IActionResult> GetLessonRecordCount(JsonElement json)
+        {
+            var (id, school) = HttpContext.GetApiTokenInfo();
+            var responseData = await OpenApiService.GetLessonRecord(_azureCosmos, _configuration, _serviceBus,
+             _option, _dingDing, id, school, json);
+            return Ok(new { responseData });
+        }
+    }
+}

+ 203 - 0
TEAMModelOS/Controllers/OpenApi/OpenApiService.cs

@@ -23,6 +23,11 @@ using TEAMModelOS.SDK.Helper.Common.ReflectorExtensions;
 using TEAMModelOS.SDK.Context.Constant;
 using TEAMModelOS.SDK.Context.Constant;
 using TEAMModelOS.SDK.Models.Dtos;
 using TEAMModelOS.SDK.Models.Dtos;
 using TEAMModelOS.SDK.Services;
 using TEAMModelOS.SDK.Services;
+using TEAMModelOS.SDK.DI.AzureCosmos.Inner;
+using Microsoft.Extensions.Configuration;
+using Azure.Messaging.ServiceBus;
+using TEAMModelOS.Models;
+using TEAMModelOS.SDK.Models.Service;
 
 
 namespace TEAMModelOS.Controllers
 namespace TEAMModelOS.Controllers
 {
 {
@@ -70,6 +75,204 @@ namespace TEAMModelOS.Controllers
             }
             }
         }
         }
 
 
+        /// <summary>
+        /// josn:
+        /// {
+        ///     "roles":"",
+        ///     "scope":""
+        ///     "pageCount":"",
+        ///     "DESC":"",
+        ///     "ASC":"",
+        ///     "continuationToken":"",
+        ///     "school":"",
+        ///     "tmdid":""
+        /// }
+        /// </summary>
+        /// <param name="azureCosmos"></param>
+        /// <param name="dingDing"></param>
+        /// <param name="id"></param>
+        /// <param name="school"></param>
+        /// <param name="json"></param>
+        /// <returns></returns>
+        /// <exception cref="NotImplementedException"></exception>
+        public static async Task<ResponseData<dynamic>> GetLessonRecord(AzureCosmosFactory _azureCosmos, IConfiguration _configuration, AzureServiceBusFactory _serviceBus,
+           Option _option,  DingDing _dingDing, string id, string school, JsonElement json)
+        {
+
+            json.TryGetProperty("roles", out JsonElement _roles);
+            List<string> roles = new List<string>();
+            if (_roles.ValueKind.Equals(JsonValueKind.Array))
+            {
+                roles = _roles.ToJsonString().ToObject<List<string>>();
+            }
+           
+            json.TryGetProperty("managePage", out JsonElement _managePage);
+            bool managePage = false;
+            if (_managePage.ValueKind.Equals(JsonValueKind.True))
+            {
+                managePage = true;
+            }
+            StringBuilder sql = new StringBuilder();
+            sql.Append("select   value(c) from c ");
+            int pageCount = 10;
+            Dictionary<string, object> dict = LessonService.GetLessonCond(json);
+            if (json.TryGetProperty("pageCount", out JsonElement _pageCount))
+            {
+                int.TryParse($"{_pageCount}", out int pcount);
+                if (pcount > 0)
+                {
+                    pageCount = pcount;
+                }
+            }
+            if (json.TryGetProperty("DESC", out JsonElement desc))
+            {
+                dict.Add("@DESC", desc.ToString());
+            }
+            if (json.TryGetProperty("ASC", out JsonElement asc))
+            {
+                dict.Add("@ASC", asc.ToString());
+            }
+            string continuationToken = null;
+            if (json.TryGetProperty("continuationToken", out JsonElement _continuationToken))
+            {
+                if (!string.IsNullOrEmpty($"{_continuationToken}"))
+                {
+                    continuationToken = $"{_continuationToken}";
+                }
+            }
+            AzureCosmosQuery cosmosDbQuery = SQLHelper.GetSQL(dict, sql);
+            string tbname = "";
+            string code = "";
+             
+            string sqlPrivate = "";
+            List<string> autoTch = new List<string>();
+            code = $"LessonRecord-{school}";
+            tbname = "School";
+           
+            List<string> ids = new List<string>();
+            //只查询某个老师的课例
+            if (json.TryGetProperty("tmdid", out JsonElement tmdid) && !string.IsNullOrWhiteSpace($"{tmdid}"))
+            {
+                ids.Add($"{tmdid}");
+            }
+            else
+            {
+                string sqltch = "select distinct value(c.id) from c ";
+                await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School)
+                    .GetItemQueryIterator<string>(queryText: sqltch, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Teacher-{school}") }))
+                {
+                    ids.Add(item);
+                }
+            }
+            if (ids.Any())
+            {
+                string sqlTechbase = $"select distinct value(c.id) from c  where c.id in ({string.Join(",", ids.Select(x => $"'{x}'"))})  and (array_contains(c.lessonShow,'student') or array_contains(c.lessonShow,'all')) ";
+                await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher)
+                   .GetItemQueryIterator<string>(queryText: sqlTechbase, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Base") }))
+                {
+                    autoTch.Add(item);
+                }
+            }
+            List<LessonRecord> lessonRecords = new List<LessonRecord>();
+            try
+            {
+                string sqlShow = "";
+                if (roles.Count == 1 && roles.Contains("student"))
+                {
+                    string autoSql = "";
+                    if (autoTch.Any())
+                    {
+                        autoSql = $" or c.tmdid in ({string.Join(",", autoTch.Select(x => $"'{x}'"))})";
+                    }
+                    sqlShow = $" and (array_contains(c.show,'student') or array_contains(c.show,'all')  {autoSql} ) ";
+                }
+
+                string sql_status_managePage = "(c.status<>404 or IS_DEFINED(c.status) = false ) and  ";
+                if (managePage)
+                {
+                    sql_status_managePage = "";
+                }
+                cosmosDbQuery.QueryText = cosmosDbQuery.QueryText.Replace("where", $" where  {sql_status_managePage}  array_length(c.groupIds)>0 {sqlPrivate}  {sqlShow} and  ");
+                await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname)
+                   .GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, continuationToken: continuationToken,
+                   requestOptions: new QueryRequestOptions() { MaxItemCount = pageCount, PartitionKey = new PartitionKey(code) }))
+                {
+                    using var jsonData = await JsonDocument.ParseAsync(item.ContentStream);
+                    if (jsonData.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
+                    {
+                        foreach (var obj in jsonData.RootElement.GetProperty("Documents").EnumerateArray())
+                        {
+                            lessonRecords.Add(obj.ToObject<LessonRecord>());
+                        }
+                        continuationToken = item.GetContinuationToken();
+                        break;
+                    }
+                }
+                long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
+                //查询时处理已经过期的课例。防止ServiceBus未触发的。
+                var expireRecords = lessonRecords.Where(x => x.expire > 0 && now > x.expire);
+                try
+                {
+                    foreach (var item in expireRecords)
+                    {
+                        //item.status = 404;
+                        //await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, tbname).ReplaceItemAsync(item, item.id, new PartitionKey(item.code));
+                        var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
+                        var messageChange = new ServiceBusMessage(new { delete_id = item.id, tmdid = item.tmdid, scope = item.scope, opt = "delete", school = item.school }.ToJsonString());
+                        messageChange.ApplicationProperties.Add("name", "LessonRecordEvent");
+                        await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageChange);
+                    }
+                }
+                catch (Exception ex)
+                {
+                    await _dingDing.SendBotMsg($"{_option.Location},ServiceBus ,LessonRecordEvent 发送消息失败,检查是否配置正常。", GroupNames.成都开发測試群組);
+                }
+                var tmdids = lessonRecords.Select(x => x.tmdid).ToHashSet();
+                if (tmdids != null && tmdids.Count > 0)
+                {
+                    List<IdNameCode> codes = new List<IdNameCode>();
+                    string sqltmd = $"select c.id,c.name,c.picture from c where c.id in ({string.Join(",", tmdids.Select(x => $"'{x}'"))})";
+                    await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<IdNameCode>(queryText: sqltmd, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
+                    {
+                        codes.Add(item);
+                    }
+                    if (codes.IsNotEmpty())
+                    {
+                        lessonRecords.ForEach(x => {
+                            var tmd = codes.Find(z => z.id.Equals(x.tmdid));
+                            if (tmd != null)
+                            {
+                                x.tmdname = tmd.name;
+                                x.tmdpicture = tmd.picture;
+                            }
+                        });
+                    }
+                }
+                var groupIds = lessonRecords.SelectMany(x => x.groupIds);
+                if (groupIds.Any())
+                {
+                    List<GroupListDto> groupLists = await GroupListService.GetGroupListListids(_azureCosmos.GetCosmosClient(), _dingDing, groupIds.ToList(), school);
+                    lessonRecords.ForEach(x => {
+                        List<string> groupNmae = new List<string>();
+                        x.groupIds.ForEach(y => {
+                            var dto = groupLists.Find(z => z.id.Equals(y));
+                            string name = dto != null ? dto.name : "-";
+                            groupNmae.Add(name);
+                        });
+                        x.groupNames = groupNmae;
+                    });
+                }
+                ResponseData<dynamic> resDate = new ResponseData<dynamic> { code= RespondCode.Ok,msg="成功", data =new  { currCount = lessonRecords.Count, continuationToken, lessonRecords } };
+                return resDate;
+            }
+            catch (Exception)
+            {
+                continuationToken = null;
+                ResponseData<dynamic> resDate = new ResponseData<dynamic> { code = RespondCode.Ok, msg = "成功", data = new { currCount = 0, continuationToken = continuationToken, lessonRecords } };
+                return resDate;
+            }
+        }
+
         /// <summary>
         /// <summary>
         /// 学校基本信息
         /// 学校基本信息
         /// //[ApiToken(Auth = "1001", Name = "学校基本信息", RWN = "R", Limit = false)]
         /// //[ApiToken(Auth = "1001", Name = "学校基本信息", RWN = "R", Limit = false)]

+ 246 - 17
TEAMModelOS/Controllers/Third/Sc/ScDataPushController.cs

@@ -168,10 +168,248 @@ namespace TEAMModelOS.Controllers
             _configuration = configuration;
             _configuration = configuration;
             _thirdApisService = thirdApisService;
             _thirdApisService = thirdApisService;
         }
         }
-     
         [ProducesDefaultResponseType]
         [ProducesDefaultResponseType]
-        [HttpPost("check")]
+        [HttpPost("push-leave")]
+        public async Task<IActionResult> PushLeave(JsonElement json) {
+            var client = _azureCosmos.GetCosmosClient();
+            JsonElement areaIdJson = json.GetProperty("areaId");
+            // JsonElement school = json.GetProperty("school");
+            Dictionary<string, Dictionary<string, object>> pushDatas = new Dictionary<string, Dictionary<string, object>>();
+            List<string> pushTeachers = json.GetProperty("leaveTeacher").ToObject<List<string>>();
+            List<string> pushPxids = json.GetProperty("pushPxids").ToObject<List<string>>();
+            AreaSetting areaSetting = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemAsync<AreaSetting>($"{areaIdJson}", new PartitionKey("AreaSetting"));
+            ScAccessConfig config = areaSetting.accessConfig.ToObject<ScAccessConfig>();
+            Dictionary<string, dynamic> checkDatas = new Dictionary<string, dynamic>();
+            var table = _azureStorage.GetCloudTableClient().GetTableReference("ScYxpt");
+            List<ScTeacher> scTeachers = new List<ScTeacher>();
+           
+           
+            List<string> Codes = new List<string>();
+            if (pushTeachers.IsNotEmpty())
+            {
+                pushTeachers.ForEach(tch => {
+                    Codes.Add($" tmdid {QueryComparisons.Equal} '{tch}' ");
+                });
+            }
+            if (pushPxids.IsNotEmpty())
+            {
+                pushPxids.ForEach(pxid => {
+                    Codes.Add($"RowKey  {QueryComparisons.Equal} '{pxid}' ");
+                });
+            }
+            string tbqurey = $"PartitionKey {QueryComparisons.Equal} 'ScTeacher' and areaId {QueryComparisons.Equal} '{areaIdJson}' and ( {string.Join(" or ", Codes)} )  ";
+            var result = await table.ExecuteQuerySegmentedAsync(new TableQuery<ScTeacher>().Where(tbqurey), null);
+            scTeachers = result.Results;
+            
+            HashSet<TeacherTrain> updatePush = new HashSet<TeacherTrain>();
+            //5.3.1.12学员培训基本情况批量回写-UpdateTeacherListSituation
+            List<TeacherTrain> trains53112OK = new List<TeacherTrain>();
+            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);
+            foreach (var t in scTeachers) {
+                Dictionary<string, object> pushData = new Dictionary<string, object>();
+                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", $"0");
+                parameterMapData.Add("ResearchText","");
+                /// <summary>
+                ///省上标准  最终结果 0未认定,1合格,2优秀,3不合格,4其他
+                ///系统标准 -2 其他 -1 未认定,0不合格,1合格,2优秀
+                /// </summary>
+                string ComPassed = "3";
+                parameterMapData.Add("ComPassed", ComPassed);//0、未认定  1、合格  2、优秀  3、不合格  4、其他
+                pushData.Add("success-UpdateTeacherListSituation", parameterMapData);
+                list53112.Add(parameterMapData);
+                if (!string.IsNullOrWhiteSpace(t.tmdid)) {
+                    TeacherTrain teacherTrain= await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS,Constant.Teacher).ReadItemAsync<TeacherTrain>(t.tmdid,new PartitionKey($"TeacherTrain-{t.schoolCode}"));
+                    teacherTrain.pushes.Add("53112"); 
+                    teacherTrain.pushes.Add("53113");
+                    teacherTrain.pushes.Add("53117");
+                    teacherTrain.pushes.Add("53122");
+                    trains53112OK.Add(teacherTrain);
+                }
+            }
+            ScsResult UpdateTeacherListSituation = null;
+            if (list53112.IsNotEmpty())
+            {
+                UpdateTeacherListSituation = await _thirdApisService.Post(config.url, "UpdateTeacherListSituation", config.passKey, config.privateKey, parameterContent53112);
+                UpdateTeacherListSituation.bizcode = "UpdateTeacherListSituation";
+                UpdateTeacherListSituation.title = "5.3.1.12学员培训基本情况批量回写";
+                if (UpdateTeacherListSituation.result) {
+                    foreach (var teacherTrain in trains53112OK)
+                    {
+                        await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReplaceItemAsync(teacherTrain, teacherTrain.id, new PartitionKey(teacherTrain.code));
+                    }
+                }
+            }
+           
+           
+            return Ok(UpdateTeacherListSituation);
+        }
+
+        [ProducesDefaultResponseType]
+        [HttpPost("push-check")]
         public async Task<IActionResult> PushCheck(JsonElement json) {
         public async Task<IActionResult> PushCheck(JsonElement json) {
+            var client = _azureCosmos.GetCosmosClient();
+            JsonElement areaIdJson = json.GetProperty("areaId");
+            // JsonElement school = json.GetProperty("school");
+            JsonElement schoolsJson = json.GetProperty("schools");
+            Dictionary<string, Dictionary<string, object>> pushDatas = new Dictionary<string, Dictionary<string, object>>();
+            List<string> pushTeachers = json.GetProperty("pushTeachers").ToObject<List<string>>();
+         
+            AreaSetting areaSetting = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemAsync<AreaSetting>($"{areaIdJson}", new PartitionKey("AreaSetting"));
+            ScAccessConfig config = areaSetting.accessConfig.ToObject<ScAccessConfig>();
+            Dictionary<string, dynamic> checkDatas = new Dictionary<string, dynamic>();
+            var table = _azureStorage.GetCloudTableClient().GetTableReference("ScYxpt");
+            List<ScTeacher> scTeachers = new List<ScTeacher>();
+            List<ScTeacherDiagnosis> scTeacherDiagnoses = new List<ScTeacherDiagnosis>();
+            if (pushTeachers.IsNotEmpty())
+            {
+                List<string> Codes = new List<string>();
+                pushTeachers.ForEach(tch => {
+                    Codes.Add($" tmdid {QueryComparisons.Equal} '{tch}' ");
+                });
+                string tbqurey = $"PartitionKey {QueryComparisons.Equal} 'ScTeacher' and areaId {QueryComparisons.Equal} '{areaIdJson}' and ( {string.Join(" or ", Codes)} )  ";
+                var result = await table.ExecuteQuerySegmentedAsync(new TableQuery<ScTeacher>().Where(tbqurey), null);
+                scTeachers = result.Results;
+
+                List<string> Pxids = new List<string>();
+                scTeachers.ForEach(tch => {
+                    Pxids.Add($" RowKey {QueryComparisons.Equal} '{tch.PXID}' ");
+                });
+                string ditbqurey = $"PartitionKey {QueryComparisons.Equal} 'ScTeacherDiagnosis' and areaId {QueryComparisons.Equal} '{areaIdJson}' and ( {string.Join(" or ", Pxids)} )  ";
+                var diresult = await table.ExecuteQuerySegmentedAsync(new TableQuery<ScTeacherDiagnosis>().Where(ditbqurey), null);
+                scTeacherDiagnoses = diresult.Results;
+
+            }
+            else
+            {
+                scTeachers = await table.FindListByDict<ScTeacher>(new Dictionary<string, object> { { "PartitionKey", "ScTeacher" }, { "areaId", $"{areaIdJson}" } });
+                scTeacherDiagnoses = await table.FindListByDict<ScTeacherDiagnosis>(new Dictionary<string, object> { { "PartitionKey", "ScTeacherDiagnosis" }, { "areaId", $"{areaIdJson}" } });
+            }
+            var teammodelossas = _azureStorage.GetBlobContainerSAS99Year("teammodelos", Azure.Storage.Sas.BlobContainerSasPermissions.Read);
+
+
+            List<PushFail> failse = new List<PushFail>();
+            List<string> schools = schoolsJson.ToObject<List<string>>();
+            foreach (var school in schools)
+            {
+                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);
+                    }
+                }
+                int pages = (trains.Count + 99) / 100; //pages = (total + max -1) / max;
+                var schoolsas = _azureStorage.GetBlobContainerSAS99Year($"{school}", Azure.Storage.Sas.BlobContainerSasPermissions.Read);
+                HashSet<TeacherTrain> updatePush = new HashSet<TeacherTrain>();
+                for (int i = 0; i < pages; i++)
+                {
+                    List<TeacherTrain> lists = trains.Skip((i) * 50).Take(50).ToList();
+                    //5.3.1.12学员培训基本情况批量回写-UpdateTeacherListSituation
+                    List<TeacherTrain> trains53112OK = new List<TeacherTrain>();
+                    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>();
+                    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>();
+                    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>();
+                    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);
+                    //装载数据
+                    List<Task> tasks = new List<Task>();
+                    lists.ForEach(x =>
+                    {
+                        tasks.Add(CheckTeacher(x, scTeachers, scTeacherDiagnoses, $"{school}", schoolsas, list53112, list53113, list53117, list53122, teammodelossas, pushDatas, failse, updatePush));
+                    });
+                    await Task.WhenAll(tasks);
+                    //推送数据
+                }
+                pushDatas.Keys.ToList().ForEach(x => {
+                    if (pushDatas[x].Keys.Any())
+                    {
+                        Dictionary<string, dynamic> dict = new Dictionary<string, dynamic>();
+                        dict.Add($"tmdid", x);
+
+                        List<string> types = new List<string>();
+                        pushDatas[x].Keys.ToList().ForEach(y => {
+                            if (y.Contains("fail-"))
+                            {
+                                types.Add(y);
+                            }
+                        });
+                        dict.Add($"msg", pushDatas[x][pushDatas[x].Keys.First()]);
+                        dict.Add($"types", types);
+                        if (types.Any())
+                        {
+                            checkDatas[x] = dict;
+                        }
+                    }
+                });
+            }
+            List<PushFail> fails = new List<PushFail>();
+            failse.ForEach(x =>
+            {
+                var f = fails.FindAll(y => y.tmdid.Equals(x.tmdid));
+                if (f.IsNotEmpty())
+                {
+                    f.ForEach(ff => {
+                        ff.type = $"{ff.type},{x.type}";
+                    });
+                }
+                else
+                {
+                    x.msgs.ForEach(msg =>
+                    {
+                        fails.Add(new PushFail { tmdid = x.tmdid, name = x.name, school = x.school, schoolname = x.schoolname, code = msg.code, msg = msg.value, type = x.type });
+                    });
+                }
+            });
+            return Ok(new { data = new {   fails } });
+        }
+
+        [ProducesDefaultResponseType]
+        [HttpPost("push")]
+        public async Task<IActionResult> Push(JsonElement json) {
              
              
             var client = _azureCosmos.GetCosmosClient();
             var client = _azureCosmos.GetCosmosClient();
             JsonElement areaIdJson = json.GetProperty("areaId");
             JsonElement areaIdJson = json.GetProperty("areaId");
@@ -752,7 +990,7 @@ namespace TEAMModelOS.Controllers
 
 
         [ProducesDefaultResponseType]
         [ProducesDefaultResponseType]
         [HttpPost("sc-check")]
         [HttpPost("sc-check")]
-        public async Task<IActionResult> css(JsonElement json) 
+        public async Task<IActionResult> ScCheck(JsonElement json) 
         {
         {
             var client = _azureCosmos.GetCosmosClient();
             var client = _azureCosmos.GetCosmosClient();
             JsonElement areaIdJson = json.GetProperty("areaId");
             JsonElement areaIdJson = json.GetProperty("areaId");
@@ -792,12 +1030,10 @@ namespace TEAMModelOS.Controllers
                 else {
                 else {
                     scTeachers = await table.FindListByDict<ScTeacher>(new Dictionary<string, object> { { "PartitionKey", "ScTeacher" }, { "areaId", $"{areaIdJson}" } });
                     scTeachers = await table.FindListByDict<ScTeacher>(new Dictionary<string, object> { { "PartitionKey", "ScTeacher" }, { "areaId", $"{areaIdJson}" } });
                 }
                 }
-                
             }
             }
             List<PushData> ycData=   new List<PushData>();
             List<PushData> ycData=   new List<PushData>();
             List<PushData> datas = new List<PushData>();
             List<PushData> datas = new List<PushData>();
             List<Task> tasks = new List<Task>();
             List<Task> tasks = new List<Task>();
-
             scTeachers.ForEach(sc =>
             scTeachers.ForEach(sc =>
             {
             {
                 tasks.Add(GetYxData(config, sc, datas));
                 tasks.Add(GetYxData(config, sc, datas));
@@ -805,6 +1041,7 @@ namespace TEAMModelOS.Controllers
             await tasks.TaskPage(100);
             await tasks.TaskPage(100);
             List<KeyValuePair<string, string>> htmls = new List<KeyValuePair<string, string>>();
             List<KeyValuePair<string, string>> htmls = new List<KeyValuePair<string, string>>();
             var group= datas.GroupBy(x => x.teacherInfo.SchoolName);
             var group= datas.GroupBy(x => x.teacherInfo.SchoolName);
+            List<dynamic> okd = new List<dynamic>();
             foreach (var groupData in group) {
             foreach (var groupData in group) {
                 int joinCount = groupData.ToList().Count();
                 int joinCount = groupData.ToList().Count();
                 //0、未认定  1、合格  2、优秀  3、不合格  4、其他
                 //0、未认定  1、合格  2、优秀  3、不合格  4、其他
@@ -812,14 +1049,7 @@ namespace TEAMModelOS.Controllers
                 int hgCount = groupData.ToList().Where(x => x.teacherInfo.ComPassed == 1).Count();
                 int hgCount = groupData.ToList().Where(x => x.teacherInfo.ComPassed == 1).Count();
                 var yc =  groupData.ToList().Where(x => x.teacherInfo.ComPassed != 2 && x.teacherInfo.ComPassed != 1);
                 var yc =  groupData.ToList().Where(x => x.teacherInfo.ComPassed != 2 && x.teacherInfo.ComPassed != 1);
                 int ycCount = yc.Count();
                 int ycCount = yc.Count();
-                string shtml = html;
-                shtml= shtml.Replace("{{projectItemTitle}}", config.p.First().pit)
-                    .Replace("{{schoolName}}",groupData.Key)
-                    .Replace("{{joinCount}}",$"{joinCount}")
-                    .Replace("{{yxCount}}", $"{yxCount}")
-                    .Replace("{{hgCount}}", $"{hgCount}")
-                    .Replace("{{ycCount}}", $"{ycCount}");
-                StringBuilder eachData = new StringBuilder();
+                okd.Add(new { schoolName = groupData.Key, joinCount, yxCount, hgCount, ycCount });
                 if (yc.Any()) {
                 if (yc.Any()) {
                     foreach (var bu in yc)
                     foreach (var bu in yc)
                     {
                     {
@@ -851,9 +1081,9 @@ namespace TEAMModelOS.Controllers
                     ycData.AddRange(yc);
                     ycData.AddRange(yc);
                 }
                 }
             }
             }
-            List<dynamic> dynamics = new List<dynamic>();
+            List<dynamic> ycd = new List<dynamic>();
             ycData.ForEach(data => {
             ycData.ForEach(data => {
-                dynamics.Add(new {
+                ycd.Add(new {
                     data.teacherInfo.TeacherName,
                     data.teacherInfo.TeacherName,
                     data.teacherInfo.tmdid,
                     data.teacherInfo.tmdid,
                     data.teacherInfo.SchoolName,
                     data.teacherInfo.SchoolName,
@@ -863,9 +1093,8 @@ namespace TEAMModelOS.Controllers
                     data.teacherInfo.ComPassedTime
                     data.teacherInfo.ComPassedTime
                 });
                 });
             });
             });
-            return Ok(dynamics);
+            return Ok(new { ycData= ycd, okData = okd });
         }
         }
-      
     }
     }
 
 
     public class DiagnosisInfoItem
     public class DiagnosisInfoItem