123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594 |
- using Microsoft.Azure.Cosmos;
- using StackExchange.Redis;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Text.Json;
- using System.Threading;
- using System.Threading.Tasks;
- using TEAMModelOS.SDK.DI;
- using TEAMModelOS.SDK.Extension;
- using TEAMModelOS.SDK.Models.Cosmos.BI.BISchool;
- using TEAMModelOS.SDK.Models.Cosmos.BI.BITable;
- namespace TEAMModelOS.SDK.Models.Service.BI
- {
- public class BILeesonService
- {
- /// <summary>
- /// 通过时间戳保存开课记录和课例记录统计
- /// 统计数据存储在CosmosDB表中
- /// </summary>
- /// <param name="cosmosClient">cosmosDB连接</param>
- /// <param name="_azureRedis">redis</param>
- /// <param name="_dingDing">错误消息发送</param>
- /// <param name="unix">13位时间戳</param>
- /// <param name="num">数量</param>
- /// <param name="type">类型:0 开课记录 1 课例记录</param>
- /// <param name="schoolId">学校编码</param>
- /// <returns></returns>
- public static async Task SetCosmosDBStats(CosmosClient cosmosClient, AzureRedisFactory _azureRedis, DingDing _dingDing, long unix, int num = 1, int type = 0, string schoolId = null)
- {
- try
- {
- DateTimeOffset dateTime = DateTimeOffset.FromUnixTimeMilliseconds(unix);
- int year, month, day, hour, days;
- year = dateTime.Year;
- month = dateTime.Month;
- day = dateTime.Day;
- hour = dateTime.Hour;
- days = dateTime.DayOfYear;
- var dateDay = dateTime.ToString("yyyyMMdd"); //获取当天的日期
- var yearDays = (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) ? 366 : 365;
- DateTime expireDay = DateTime.UtcNow.AddDays(8); //8天后到期
- DateTime expireYear = DateTime.UtcNow.AddDays(396); //一年后到期
- var redisClient = _azureRedis.GetRedisClient(8);
- string LessType = "Open";
- if (type == 1)
- LessType = "Lesson";
- await redisClient.SortedSetIncrementAsync($"BIStats:Less:All:{LessType}:{dateDay}", $"{hour}", num);//一天24小时课例数 有上传 base.josn 小时为单位
- await redisClient.SortedSetIncrementAsync($"BIStats:Less:All:{LessType}:{year}", $"{days}", num);//一年的课例数量 有上传 base.josn 小时为单位
- var expDay = await _azureRedis.GetRedisClient(8).KeyTimeToLiveAsync($"BIStats:Less:All:{LessType}:{dateDay}");
- if (expDay == null)
- await _azureRedis.GetRedisClient(8).KeyExpireAsync($"BIStats:Less:All:{LessType}:{dateDay}", expireDay); //设置八天后到期
- var expYear = await _azureRedis.GetRedisClient(8).KeyTimeToLiveAsync($"BIStats:Less:All:{LessType}:{year}");
- if (expYear == null)
- await _azureRedis.GetRedisClient(8).KeyExpireAsync($"BIStats:Less:All:{LessType}:{year}", expireYear); //设置一年后到期
- //保存当天的统计 小时
- var dayCnt = redisClient.SortedSetRangeByScoreWithScores($"BIStats:Less:All:{LessType}:{dateDay}");
- if (dayCnt != null && dayCnt.Length > 0)
- {
- double[] daHour = new double[23];
- foreach (var item in dayCnt)
- {
- double val = ((double)item.Score);
- int key = ((int)item.Element);
- daHour[key] = val;
- }
- List<double> lessHours = new(daHour);
- var lessRes = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{dateDay}", new PartitionKey("LessonHour"));
- if (lessRes.StatusCode == System.Net.HttpStatusCode.OK)
- {
- using var json = await JsonDocument.ParseAsync(lessRes.Content);
- LessonStats lessonStats = json.ToObject<LessonStats>();
- lessonStats.code = "LessonHour";
- lessonStats.pk = "LessonHour";
- if (type == 1)
- lessonStats.lesson = lessHours;
- else
- lessonStats.open = lessHours;
- await cosmosClient.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<LessonStats>(lessonStats, lessonStats.id, new PartitionKey("LessonHour"));
- }
- else
- {
- LessonStats lessonStats = new();
- lessonStats.id = $"{dateDay}";
- lessonStats.code = "LessonHour";
- lessonStats.pk = "LessonHour";
- if (type == 1)
- lessonStats.lesson = lessHours;
- else
- lessonStats.open = lessHours;
- await cosmosClient.GetContainer("TEAMModelOS", "School").CreateItemAsync<LessonStats>(lessonStats, new PartitionKey("LessonHour"));
- }
- }
- //保一年的统计 天
- var yearCnt = redisClient.SortedSetRangeByScoreWithScores($"BIStats:Less:All:{LessType}:{year}");
- if (yearCnt != null && yearCnt.Length > 0)
- {
- double[] daYear = new double[yearDays];
- foreach (var item in yearCnt)
- {
- double val = ((double)item.Score);
- int key = ((int)item.Element);
- daYear[key] = val;
- }
- List<double> lessYear = new(daYear);
- var lessRes = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{year}", new PartitionKey("LessonYear"));
- if (lessRes.StatusCode == System.Net.HttpStatusCode.OK)
- {
- using var json = await JsonDocument.ParseAsync(lessRes.Content);
- LessonStats lessonYear = json.ToObject<LessonStats>();
- lessonYear.code = "LessonYear";
- lessonYear.pk = "LessonYear";
- if (type == 1)
- lessonYear.lesson = lessYear;
- else
- lessonYear.open = lessYear;
- await cosmosClient.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<LessonStats>(lessonYear, lessonYear.id, new PartitionKey("LessonYear"));
- }
- else
- {
- LessonStats lessonYear = new();
- lessonYear.id = $"{year}";
- lessonYear.code = "LessonYear";
- lessonYear.pk = "LessonYear";
- if (type == 1)
- lessonYear.lesson = lessYear;
- else
- lessonYear.open = lessYear;
- await cosmosClient.GetContainer("TEAMModelOS", "School").CreateItemAsync<LessonStats>(lessonYear, new PartitionKey("LessonYear"));
- }
- }
- if (!string.IsNullOrEmpty(schoolId))
- {
- await redisClient.SortedSetIncrementAsync($"BIStats:Less:{schoolId}:{LessType}:{dateDay}", $"{hour}", num);//一天24小时课例数 有上传 base.josn 小时为单位
- await redisClient.SortedSetIncrementAsync($"BIStats:Less:{schoolId}:{LessType}:{year}", $"{days}", num);//一年的课例数量 有上传 base.josn 小时为单位
- var scExpDay = await _azureRedis.GetRedisClient(8).KeyTimeToLiveAsync($"BIStats:Less:{schoolId}:{LessType}:{dateDay}");
- if (scExpDay == null)
- await _azureRedis.GetRedisClient(8).KeyExpireAsync($"BIStats:Less:{schoolId}:{LessType}:{dateDay}", expireDay); //设置八天后到期
- var scExpYear = await _azureRedis.GetRedisClient(8).KeyTimeToLiveAsync($"BIStats:Less:{schoolId}:{LessType}:{year}");
- if (scExpYear == null)
- await _azureRedis.GetRedisClient(8).KeyExpireAsync($"BIStats:Less:{schoolId}:{LessType}:{year}", expireYear); //设置一年后到期
- //保存当天的统计 小时
- var dayScCnt = redisClient.SortedSetRangeByScoreWithScores($"BIStats:Less:{schoolId}:{LessType}:{dateDay}");
- if (dayScCnt != null && dayScCnt.Length > 0)
- {
- double[] daHour = new double[23];
- foreach (var item in dayScCnt)
- {
- double val = ((double)item.Score);
- int key = ((int)item.Element);
- daHour[key] = val;
- }
- List<double> lessHours = new(daHour);
- var lessRes = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{dateDay}", new PartitionKey($"LessonHour-{schoolId}"));
- if (lessRes.StatusCode == System.Net.HttpStatusCode.OK)
- {
- using var json = await JsonDocument.ParseAsync(lessRes.Content);
- LessonStats lessonStats = json.ToObject<LessonStats>();
- lessonStats.code = $"LessonHour-{schoolId}";
- lessonStats.pk = "LessonHour";
- if (type == 1)
- lessonStats.lesson = lessHours;
- else
- lessonStats.open = lessHours;
- await cosmosClient.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<LessonStats>(lessonStats, lessonStats.id, new PartitionKey($"LessonHour-{schoolId}"));
- }
- else
- {
- LessonStats lessonStats = new();
- lessonStats.id = $"{dateDay}";
- lessonStats.code = $"LessonHour-{schoolId}";
- lessonStats.pk = "LessonHour";
- if (type == 1)
- lessonStats.lesson = lessHours;
- else
- lessonStats.open = lessHours;
- await cosmosClient.GetContainer("TEAMModelOS", "School").CreateItemAsync<LessonStats>(lessonStats, new PartitionKey($"LessonHour-{schoolId}"));
- }
- }
- //保一年的统计 天
- var scYearCnt = redisClient.SortedSetRangeByScoreWithScores($"BILesson:{schoolId}:{LessType}:{year}");
- if (scYearCnt != null && scYearCnt.Length > 0)
- {
- double[] daYear = new double[yearDays];
- foreach (var item in scYearCnt)
- {
- double val = ((double)item.Score);
- int key = ((int)item.Element);
- daYear[key] = val;
- }
- List<double> lessYear = new(daYear);
- var lessRes = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync($"{year}", new PartitionKey($"LessonYear-{schoolId}"));
- if (lessRes.StatusCode == System.Net.HttpStatusCode.OK)
- {
- using var json = await JsonDocument.ParseAsync(lessRes.Content);
- LessonStats lessonYear = json.ToObject<LessonStats>();
- lessonYear.code = $"LessonYear-{schoolId}";
- lessonYear.pk = "LessonYear";
- if (type == 1)
- lessonYear.lesson = lessYear;
- else
- lessonYear.open = lessYear;
- await cosmosClient.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<LessonStats>(lessonYear, lessonYear.id, new PartitionKey($"LessonYear-{schoolId}"));
- }
- else
- {
- LessonStats lessonYear = new();
- lessonYear.id = $"{year}";
- lessonYear.code = $"LessonYear-{schoolId}";
- lessonYear.pk = "LessonYear";
- if (type == 1)
- lessonYear.lesson = lessYear;
- else
- lessonYear.open = lessYear;
- await cosmosClient.GetContainer("TEAMModelOS", "School").CreateItemAsync<LessonStats>(lessonYear, new PartitionKey($"LessonYear-{schoolId}"));
- }
- }
- }
- }
- catch (Exception ex)
- {
- await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-SetBICosmosDBStats 课例统计异常 {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
- }
- }
- /// <summary>
- /// 通过时间戳保存开课记录和课例记录统计
- /// 统计数据存储在table表中
- /// </summary>
- /// <param name="_azureStorage">table连接池</param>
- /// <param name="_azureRedis">redis连接池</param>
- /// <param name="_dingDing">错误消息发送</param>
- /// <param name="unix">13位时间戳</param>
- /// <param name="num">数量</param>
- /// <param name="type">类型:0 开课记录 1 课例记录</param>
- /// <param name="scope">范围(默认学校范围):学校 school 个人 private</param>
- /// <param name="schoolId">学校编码</param>
- /// <returns></returns>
- public static async Task SetTableStats(AzureStorageFactory _azureStorage, AzureRedisFactory _azureRedis, DingDing _dingDing, long unix, int num = 1, int type = 0,string scope = "private", string schoolId = null)
- {
- try
- {
- //SemaphoreSlim slimlock = new(1, 1); //对可同时访问资源或资源池的线程数加以限制 结束
- //await slimlock.WaitAsync();
- Monitor.TryEnter(unix); //锁对象
- DateTimeOffset dateTime = DateTimeOffset.FromUnixTimeMilliseconds(unix);
- int year, month, day, hour, days;
- year = dateTime.Year;
- month = dateTime.Month;
- day = dateTime.Day;
- hour = dateTime.Hour;
- days = dateTime.DayOfYear;
- var dateDay = dateTime.ToString("yyyyMMdd"); //获取当天的日期
- var yearDays = (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) ? 366 : 365;
- var table = _azureStorage.GetCloudTableClient().GetTableReference("BIStats");
- var redisClient = _azureRedis.GetRedisClient(8);
- DateTime expireDay = DateTime.UtcNow.AddDays(8); //8天后到期
- DateTime expireYear = DateTime.UtcNow.AddDays(396); //一年后到期
- ////保存当天的统计 小时
- //SortedSetEntry[] dayCnt = null;
- ////保一年的统计 天
- //SortedSetEntry[] yearCnt = null;
- string LessType = "Open";
- if (type == 1)
- LessType = "Lesson";
- try
- {
- await redisClient.SortedSetIncrementAsync($"BIStats:Less:All:{LessType}:{dateDay}", $"{hour}", num);//一天24小时课例数 有上传 base.josn 小时为单位
- await redisClient.SortedSetIncrementAsync($"BIStats:Less:All:{LessType}:{year}", $"{days}", num);//一年的课例数量 有上传 base.josn 小时为单位
- var expDay = await _azureRedis.GetRedisClient(8).KeyTimeToLiveAsync($"BIStats:Less:All:{LessType}:{dateDay}");
- if (expDay == null)
- await _azureRedis.GetRedisClient(8).KeyExpireAsync($"BIStats:Less:All:{LessType}:{dateDay}", expireDay); //设置八天后到期
- var expYear = await _azureRedis.GetRedisClient(8).KeyTimeToLiveAsync($"BIStats:Less:All:{LessType}:{year}");
- if (expYear == null)
- await _azureRedis.GetRedisClient(8).KeyExpireAsync($"BIStats:Less:All:{LessType}:{year}", expireYear); //设置一年后到期
- ////保存当天的统计 小时
- //dayCnt = redisClient.SortedSetRangeByScoreWithScores($"BIStats:Less:All:{LessType}:{dateDay}");
- ////保一年的统计 天
- //yearCnt = redisClient.SortedSetRangeByScoreWithScores($"BIStats:Less:All:{LessType}:{year}");
- }
- catch { }
- double[] daHour = new double[23];
- daHour[hour] = num;
- string hourStats = string.Join(',', daHour);
- double[] daYear = new double[yearDays];
- daYear[hour] = num;
- string yearStats = string.Join(',', daYear);
- LessStats lessHour = table.Get<LessStats>("LessonHour", $"{dateDay}");
- if (lessHour != null)
- {
- if (type == 1)
- {
- if (lessHour.lesson != null)
- {
- double[] tempLess = Array.ConvertAll<string, double>(lessHour.lesson.Split(','), s => double.Parse(s));
- tempLess[hour] = tempLess[hour] + num;
- string strLess = string.Join(',', tempLess);
- lessHour.lesson = strLess;
- }
- else
- lessHour.lesson = hourStats;
- }
- else
- {
- if (lessHour.open != null)
- {
- double[] tempOpen = Array.ConvertAll<string, double>(lessHour.open.Split(','), s => double.Parse(s));
- tempOpen[hour] = tempOpen[hour] + num;
- string sOpen = string.Join(',', tempOpen);
- lessHour.open = sOpen;
- }
- else
- lessHour.open = hourStats;
- }
- }
- else
- {
- lessHour = new() { PartitionKey = "LessonHour", RowKey = $"{dateDay}" };
- if (type == 1)
- lessHour.lesson = hourStats;
- else
- lessHour.open = hourStats;
- }
- await table.SaveOrUpdate<LessStats>(lessHour);
- LessStats lessYear = table.Get<LessStats>("LessonYear", $"{year}");
- if (lessYear != null)
- {
- if (type == 1)
- {
- if (lessYear.lesson != null)
- {
- double[] tempLess = Array.ConvertAll<string, double>(lessYear.lesson.Split(','), s => double.Parse(s));
- tempLess[days] = tempLess[days] + num;
- string sLess = string.Join(',', tempLess);
- lessYear.lesson = sLess;
- }
- else
- lessYear.lesson = yearStats;
- }
- else
- {
- if (lessYear.open != null)
- {
- double[] tempOpen = Array.ConvertAll<string, double>(lessYear.open.Split(','), s => double.Parse(s));
- tempOpen[days] = tempOpen[days] + num;
- string sOpen = string.Join(',', tempOpen);
- lessYear.open = sOpen;
- }
- else
- lessYear.open = yearStats;
- }
- }
- else
- {
- lessYear = new() { PartitionKey = "LessonYear", RowKey = $"{year}" };
- if (type == 1)
- lessYear.lesson = yearStats;
- else
- lessYear.open = yearStats;
- }
- try
- {
- await table.SaveOrUpdate<LessStats>(lessYear);
- }
- catch { }
- //保存学校课例数据
- if (!string.IsNullOrEmpty(schoolId) && scope.Equals("school"))
- {
- ////保存学校当天的统计 小时
- //SortedSetEntry[] dayScCnt = null;
- ////保学校一年的统计 天
- //SortedSetEntry[] scYearCnt = null;
- try
- {
- await redisClient.SortedSetIncrementAsync($"BIStats:Less:{schoolId}:{LessType}:{dateDay}", $"{hour}", num);//一天24小时课例数 有上传 base.josn 小时为单位
- await redisClient.SortedSetIncrementAsync($"BIStats:Less:{schoolId}:{LessType}:{year}", $"{days}", num);//一年的课例数量 有上传 base.josn 小时为单位
- var scExpDay = await _azureRedis.GetRedisClient(8).KeyTimeToLiveAsync($"BIStats:Less:{schoolId}:{LessType}:{dateDay}");
- if (scExpDay == null)
- await _azureRedis.GetRedisClient(8).KeyExpireAsync($"BIStats:Less:{schoolId}:{LessType}:{dateDay}", expireDay); //设置八天后到期
- var scExpYear = await _azureRedis.GetRedisClient(8).KeyTimeToLiveAsync($"BIStats:Less:{schoolId}:{LessType}:{year}");
- if (scExpYear == null)
- await _azureRedis.GetRedisClient(8).KeyExpireAsync($"BIStats:Less:{schoolId}:{LessType}:{year}", expireYear); //设置一年后到期
- ////保存学校当天的统计 小时
- //dayScCnt = redisClient.SortedSetRangeByScoreWithScores($"BIStats:Less:{schoolId}:{LessType}:{dateDay}");
- ////保学校一年的统计 天
- //scYearCnt = redisClient.SortedSetRangeByScoreWithScores($"BIStats:Less:{schoolId}:{LessType}:{year}");
- }catch { }
- double[] daScHour = new double[23];
- daScHour[hour] = num;
- string hourScStats = string.Join(',', daScHour);
- double[] daScYear = new double[yearDays];
- daScYear[hour] = num;
- string strYearSc = string.Join(',', daScYear);
- LessStats lessScHour = table.Get<LessStats>("LessonHour", $"{dateDay}-{schoolId}");
- if (lessScHour != null)
- {
- if (type == 1)
- {
- if (lessScHour.lesson != null)
- {
- double[] tempLess = Array.ConvertAll<string, double>(lessScHour.lesson.Split(','), s => double.Parse(s));
- tempLess[hour] = tempLess[hour] + num;
- string strLess = string.Join(',', tempLess);
- lessScHour.lesson = strLess;
- }
- else
- lessScHour.lesson = hourScStats;
- }
- else
- {
- if (lessScHour.open != null)
- {
- double[] tempOpen = Array.ConvertAll<string, double>(lessScHour.open.Split(','), s => double.Parse(s));
- tempOpen[hour] = tempOpen[hour] + num;
- string sOpen = string.Join(',', tempOpen);
- lessScHour.open = sOpen;
- }
- else
- lessScHour.open = hourScStats;
- }
- }
- else
- {
- lessScHour = new() { PartitionKey = "LessonHour", RowKey = $"{dateDay}-{schoolId}" };
- if (type == 1)
- lessScHour.lesson = hourScStats;
- else
- lessScHour.open = hourScStats;
- }
- try
- {
- await table.SaveOrUpdate<LessStats>(lessScHour);
- }
- catch { }
- LessStats lessScYear = table.Get<LessStats>("LessonYear", $"{year}-{schoolId}");
- if (lessScYear != null)
- {
- if (type == 1)
- {
- if (lessScYear.lesson != null)
- {
- double[] tempLess = Array.ConvertAll<string, double>(lessScYear.lesson.Split(','), s => double.Parse(s));
- tempLess[days] = tempLess[days] + num;
- string sLess = string.Join(',', tempLess);
- lessScYear.lesson = sLess;
- }
- else
- lessScYear.lesson = strYearSc;
- }
- else
- {
- if (lessScYear.open != null)
- {
- double[] tempOpen = Array.ConvertAll<string, double>(lessScYear.open.Split(','), s => double.Parse(s));
- tempOpen[days] = tempOpen[days] + num;
- string sOpen = string.Join(',', tempOpen);
- lessScYear.open = sOpen;
- }
- else
- lessScYear.open = strYearSc;
- }
- }
- else
- {
- lessScYear = new() { PartitionKey = "LessonYear", RowKey = $"{year}" };
- if (type == 1)
- lessScYear.lesson = strYearSc;
- else
- lessScYear.open = strYearSc;
- }
- try
- {
- await table.SaveOrUpdate<LessStats>(lessScYear);
- }
- catch { }
- //if (dayScCnt != null && dayScCnt.Length > 0)
- //{
- // double[] daHourSc = new double[23];
- // foreach (var item in dayScCnt)
- // {
- // double val = ((double)item.Score);
- // int key = ((int)item.Element);
- // daHourSc[key] = val;
- // }
- // string hoursStatsSc = string.Join(",", daHourSc);
- // LessStats lessStatsSc = table.Get<LessStats>("LessonHour", $"{dateDay}-{schoolId}");
- // if (lessStatsSc != null)
- // {
- // if (type == 1)
- // lessStatsSc.lesson = hoursStatsSc;
- // else
- // lessStatsSc.open = hoursStatsSc;
- // }
- // else
- // {
- // lessStatsSc = new() { PartitionKey = "LessonHour", RowKey = $"{dateDay}-{schoolId}" };
- // if (type == 1)
- // lessStatsSc.lesson = hoursStatsSc;
- // else
- // lessStatsSc.open = hoursStatsSc;
- // lessStatsSc.time = dateDay;
- // lessStatsSc.school = schoolId;
- // }
- // try
- // {
- // await table.SaveOrUpdate<LessStats>(lessStatsSc);
- // }
- // catch { }
- //}
- //if (scYearCnt != null && scYearCnt.Length > 0)
- //{
- // double[] daYearSc = new double[yearDays];
- // foreach (var item in scYearCnt)
- // {
- // double val = ((double)item.Score);
- // int key = ((int)item.Element);
- // daYearSc[key] = val;
- // }
- // string tempStatsSc = string.Join(",", daYearSc);
- // LessStats lessStatsSc = table.Get<LessStats>("LessonYear", $"{year}-{schoolId}");
- // if (lessStatsSc != null)
- // {
- // if (type == 1)
- // lessStatsSc.lesson = tempStatsSc;
- // else
- // lessStatsSc.open = tempStatsSc;
- // }
- // else
- // {
- // lessStatsSc = new() { PartitionKey = "LessonYear", RowKey = $"{year}-{schoolId}" };
- // if (type == 1)
- // lessStatsSc.lesson = tempStatsSc;
- // else
- // lessStatsSc.open = tempStatsSc;
- // lessStatsSc.time = $"{year}";
- // lessStatsSc.school = schoolId;
- // }
- // try
- // {
- // await table.SaveOrUpdate<LessStats>(lessStatsSc);
- // }
- // catch { }
- //}
- }
- Monitor.Enter(unix); //锁对象 结束
- //slimlock.Release(); // 对可同时访问资源或资源池的线程数加以限制 结束
- }
- catch (Exception ex)
- {
- await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-SetBITableStats BI记录课例统计数据异常!参数:{unix}|{num}|{type}|{scope}|{schoolId} ;错误信息:{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
- }
- }
- }
- }
|