瀏覽代碼

Merge branch 'develop' into develop-rc

CrazyIter_Bin 2 年之前
父節點
當前提交
812f82ffd3

+ 2 - 2
TEAMModelBI/Controllers/BINormal/BusinessConfigController.cs

@@ -65,7 +65,7 @@ namespace TEAMModelBI.Controllers.BINormal
                 bizConfig.code = "BizConfig";
                 bizConfig.pk = "BizConfig";
                 bizConfig.createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
-                var auth_token = JwtAuthExtension.CreateBusinessApiToken(_option.Location, bizConfig.id, _option.JwtSecretKey);
+                var auth_token = JwtAuthExtension.CreateBusinessApiToken(_option.Location, bizConfig.id, _option.JwtSecretKey, bizConfig.isCustomize);
                 bizConfig.jti = auth_token.jti;
                 bizConfig.token = auth_token.jwt;
 
@@ -188,7 +188,7 @@ namespace TEAMModelBI.Controllers.BINormal
             {
                 using var json = await JsonDocument.ParseAsync(response.ContentStream);
                 bizConfig = json.ToObject<BizConfig>();
-                var auth_token = JwtAuthExtension.CreateBusinessApiToken(_option.Location, bizConfig.id, _option.JwtSecretKey);
+                var auth_token = JwtAuthExtension.CreateBusinessApiToken(_option.Location, bizConfig.id, _option.JwtSecretKey, bizConfig.isCustomize);
                 bizConfig.jti = auth_token.jti;
                 bizConfig.token = auth_token.jwt;
 

+ 5 - 5
TEAMModelBI/Controllers/BINormal/BusinessUsersController.cs

@@ -55,8 +55,8 @@ namespace TEAMModelBI.Controllers.BINormal
                 sqlTxt.Append($" where c.id='{id}'");
             }
 
-            List<BusinessUsers> bizUsers = new();
-            await foreach (var items in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<BusinessUsers>(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
+            List<BizUsers> bizUsers = new();
+            await foreach (var items in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<BizUsers>(queryText: sqlTxt.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
             {
                 bizUsers.Add(items);
             }
@@ -274,9 +274,9 @@ namespace TEAMModelBI.Controllers.BINormal
             //if ($"{site}".Equals(BIConst.Global))
             //    cosmosClient = _azureCosmos.GetCosmosClient(name: BIConst.Global);
 
-            List<BusinessUsers> businessUsers = new();
-            string sql = $"select value(c) from c join s in c.relation  where c.code='BizUsers' and s.bizId = '80e1bb6c-acba-46ab-9939-4851c4ef2158'";
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<BusinessUsers>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
+            List<BizUsers> businessUsers = new();
+            string sql = $"select value(c) from c join s in c.relation  where c.code='BizUsers' and s.bizId = '{id}'";
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<BizUsers>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
             {
                 businessUsers.Add(item);
             }

+ 65 - 30
TEAMModelBI/Controllers/BITest/TestController.cs

@@ -1183,22 +1183,53 @@ namespace TEAMModelBI.Controllers.BITest
         [HttpPost("get-linqcount")]
         public async Task<IActionResult> GetLinqCount()
         {
-            List<Test> list1 = new();
-            list1.Add(new Test { score = 10, name = "001" });
-            list1.Add(new Test { score = 20, name = "002" });
-            list1.Add(new Test { score = 30, name = "003" });
-            list1.Add(new Test { score = 40, name = "004" });
-            list1.Add(new Test { score = 50, name = "005" });
-            list1.Add(new Test { score = 60, name = "006" });
-
-            List<Test> list2 = new();
-            list2.Add(new Test { score = 40, name = "004" });
-            list2.Add(new Test { score = 50, name = "005" });
-            list2.Add(new Test { score = 60, name = "006" });
-            list2.Add(new Test { score = 70, name = "007" });
-            list2.Add(new Test { score = 80, name = "008" });
-            list2.Add(new Test { score = 90, name = "009" });
-            list2.Add(new Test { score = 100, name = "010" });
+
+            List<linqTest> linqTests = new()
+            {
+                new linqTest  { id = "10110",aresid = "0",name ="明",linq1 =  new linq1 { id ="abc0", times = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),cnt=10 } } ,
+                new linqTest  { id = "10111",aresid = "1",name ="明1",linq1 =  new linq1 { id ="abc1", times = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),cnt=10 } } ,
+                new linqTest  { id = "10112",aresid = "2",name ="明2",linq1 =  new linq1 { id ="abc2", times = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),cnt=10 } } ,
+                new linqTest  { id = "10113",aresid = "3",name ="明3",linq1 = new linq1 { id ="abc3", times = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),cnt=10 } } ,
+                new linqTest  { id = "10114",aresid = "4",name ="明4",linq1 =  new linq1 { id ="abc4", times = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),cnt=10 }  },
+                new linqTest  { id = "10115",aresid = "5",name ="明5",linq1 = new linq1 { id ="abc5", times = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),cnt=10 } } ,
+                new linqTest  { id = "10116",aresid = "6",name ="明6",linq1 =  new linq1 { id ="abc6", times = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),cnt=10 }  },
+                new linqTest  { id = "10117",aresid = "7",name ="明7",linq1 = new linq1 { id ="abc7", times = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),cnt=10 }  },
+                new linqTest  { id = "10118",aresid = "8",name ="明8",linq1 = new linq1 { id ="abc8", times = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),cnt=10 }  },
+                new linqTest  { id = "10119",aresid = "9",name ="明9",linq1 =  new linq1 { id ="abc9", times = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),cnt=10 }  },
+                new linqTest  { id = "10120",aresid = "10",name ="明10",linq1 =  new linq1 { id ="abc10", times = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),cnt=10  } }
+            };
+            for (int i = 0; i < 11; i++)
+            {
+                linqTest linqt = new() { id = $"qwe{i}", aresid = $"{i}", name = $"名字{i}", linq1 = new linq1 { id = $"abc{i}", times = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), cnt = (11 + i) } };
+                linqTests.Add(linqt);
+            }
+
+            var grup = linqTests.GroupBy(g => g.aresid).ToList();
+
+            var grup1 = linqTests.GroupBy(g => g.aresid).Select(s=>new { areid= s.Key,linq1Id = s.Select(sn => sn.linq1.id).ToList(), id = s.Select(sn => sn.id).ToList(), name = s.Select(sn => sn.name).ToList(), linq1Cnt = s.Select(sn => sn.linq1.cnt).ToList(), lescnt = s.Select(sf=>sf.linq1.cnt).Sum()}).ToList();
+
+            return Ok(new { state = RespondCode.Ok, grup1, grup });
+
+            List<Test> list1 = new()
+            {
+                new Test { score = 10, name = "001" },
+                new Test { score = 20, name = "002" },
+                new Test { score = 30, name = "003" },
+                new Test { score = 40, name = "004" },
+                new Test { score = 50, name = "005" },
+                new Test { score = 60, name = "006" }
+            };
+
+            List<Test> list2 = new()
+            {
+                new Test { score = 40, name = "004" },
+                new Test { score = 50, name = "005" },
+                new Test { score = 60, name = "006" },
+                new Test { score = 70, name = "007" },
+                new Test { score = 80, name = "008" },
+                new Test { score = 90, name = "009" },
+                new Test { score = 100, name = "010" }
+            };
 
             //list3 return 2
             List<Test> list3 = list1.Where(x => !list2.Any(x2 => x.score == x2.score && x.name == x2.name)).ToList();
@@ -1239,20 +1270,14 @@ namespace TEAMModelBI.Controllers.BITest
             var (lastWeekStart, lastWeekEnd) = TimeHelper.GetStartOrEnd(DateTimeOffset.UtcNow, "lastweek");
 
 
-            List<linqTest> linqTests = new();
-            for (int i = 0; i < 10; i++)
-            {
-                linqTest linqt = new() { id = $"qwe{i}", name = $"名字{i}", linq1s = new List<linq1> { new linq1 { id = $"abc{i}", times = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() }, new linq1 { id = $"def{i}", times = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() } } };
-                linqTests.Add(linqt);
-            }
 
             //var set = linqTests.Select((x, y) => x.linq1s.Find(l => l.id.Equals($"abc0"))).ToList();
-            var set = linqTests.Where(x => !string.IsNullOrEmpty(x.linq1s.Find(l => l.id.Equals($"abc0")).ToString()));
+            //var set = linqTests.Where(x => !string.IsNullOrEmpty(x.linq1s.Find(l => l.id.Equals($"abc0")).ToString()));
             //var tem220p = linqTests.ForEach(x => {
             //    var coreUser = linqTests.Find(c => c.id.Equals("abc0"));
             //   });  //.Except(linqTests.Select(y => y.linq1s.Find(n => n.times.Equals("abc0"))));
 
-            return Ok(new { state = 200, Mon, Sun, ss, sss, ssss, sssss, lastWeekStart, lastWeekEnd, have, en2, bingji, cha, jiaoji, chaji, list3, list4, temp, list1, linqTests, set });
+            return Ok(new { state = 200, Mon, Sun, ss, sss, ssss, sssss, lastWeekStart, lastWeekEnd, have, en2, bingji, cha, jiaoji, chaji, list3, list4, temp, list1, linqTests });
         }
 
         /// <summary>
@@ -1763,8 +1788,8 @@ namespace TEAMModelBI.Controllers.BITest
             var (DayS, DayE) = TimeHelper.GetStartOrEnd(dateOff);      //今天开始时间结束时间
             var (lastWeekS, lastWeekE) = TimeHelper.GetStartOrEnd(dateOff, "lastweek");   //计算上周开始/结束时间
             var (weekS, weekE) = TimeHelper.GetStartOrEnd(dateOff, "week");             //计算本周开始/结束时间
-            var (lastMonthS, lastMonthE) = TimeHelper.GetStartOrEnd(dateOff, "lastMonth");   //计算上月开始/结束时间
-            var (monthS, monthE) = TimeHelper.GetStartOrEnd(dateOff, "month");             //计算本月开始/结束时间
+            var (lastMonthS, lastMonthE) = TimeHelper.GetStartOrEnd(dateOff, "lastMonth");   //上月开始/结束时间
+            var (monthS, monthE) = TimeHelper.GetStartOrEnd(dateOff, "month");             //本月开始/结束时间
             var (lastTermS, lastTermE) = TimeHelper.GetStartOrEnd(dateOff, "lastterm");   //计算上学期开始/结束时间
             var (termS, termE) = TimeHelper.GetStartOrEnd(dateOff, "term");   //计算本学期开始/结束时间
             var (lastYearS, lastYearE) = TimeHelper.GetStartOrEnd(dateOff, "lastYear"); //计算去年开始/结束时间
@@ -1775,6 +1800,7 @@ namespace TEAMModelBI.Controllers.BITest
             var (termDayS, termDayE) = TimeHelper.GetLongToTime(lastTermS, lastTermE);
             var (lMonthS, lMonthE) = TimeHelper.GetLongToTime(lastMonthS, lastMonthE);
             var lastDay = dateOff.AddDays(-1);
+            var lastMonth = dateOff.AddMonths(-1);
 
             StatsInfo statsInfo = new();
             var resStsInfo = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{dateOff.Year}-{scId}", new PartitionKey("Statistics"));
@@ -1805,19 +1831,20 @@ namespace TEAMModelBI.Controllers.BITest
                 statsInfo.upTime = careDate;
                 //}
             }
-
+            DenseMatrix matris = null;
             switch ($"{type}")
             {
                 case "Exam":
                     statsInfo.activity.year[dateOff.DayOfYear] += all;
                     statsInfo.activity.exam += all;
+                    statsInfo.activity.month += all;
                     statsInfo.activity.lastDay = ((int)statsInfo.activity.year[lastDay.DayOfYear]);
                     statsInfo.activity.dayCnt = ((int)statsInfo.activity.year[dateOff.DayOfYear]);
 
+                    matris = DenseMatrix.OfColumns(new List<List<double>>() { statsInfo.activity.year });
                     if (lastWeekS <= statsInfo.activity.upTime && statsInfo.activity.upTime <= lastWeekE)
                     {
-                        var artWeek = DenseMatrix.OfColumns(new List<List<double>>() { statsInfo.activity.year });
-                        statsInfo.activity.lastWeek = ((int)artWeek.SubMatrix(weekDayS.DayOfYear, 7, 0, artWeek.ColumnCount).ColumnSums().Sum());
+                        statsInfo.activity.lastWeek = ((int)matris.SubMatrix(weekDayS.DayOfYear, 7, 0, matris.ColumnCount).ColumnSums().Sum());
                         //statsInfo.activity.lastWeek = ((int)statsInfo.activity.year.GetRange(weekDayS.DayOfYear, 7).Sum());
                     }
 
@@ -1857,6 +1884,7 @@ namespace TEAMModelBI.Controllers.BITest
                                 statsInfo.activity.term += all;
                         }
                     }
+                    statsInfo.activity.lastWeek = ((int)matris.SubMatrix(lMonthS.DayOfYear, 20, 0, matris.ColumnCount).ColumnSums().Sum());
 
                     statsInfo.activity.upTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
                     statsInfo.activity.all += all;
@@ -1864,6 +1892,7 @@ namespace TEAMModelBI.Controllers.BITest
                 case "Survey":
                     statsInfo.activity.year[dateOff.DayOfYear] += all;
                     statsInfo.activity.survey += all;
+                    statsInfo.activity.month += all;
                     statsInfo.activity.lastDay = ((int)statsInfo.activity.year[lastDay.DayOfYear]);
                     statsInfo.activity.dayCnt = ((int)statsInfo.activity.year[dateOff.DayOfYear]);
 
@@ -1917,6 +1946,7 @@ namespace TEAMModelBI.Controllers.BITest
                 case "Vote":
                     statsInfo.activity.year[dateOff.DayOfYear] += all;
                     statsInfo.activity.vote += all;
+                    statsInfo.activity.month += all;
                     statsInfo.activity.lastDay = ((int)statsInfo.activity.year[lastDay.DayOfYear]);
                     statsInfo.activity.dayCnt = ((int)statsInfo.activity.year[dateOff.DayOfYear]);
 
@@ -1970,6 +2000,7 @@ namespace TEAMModelBI.Controllers.BITest
                 case "Homework":
                     statsInfo.activity.year[dateOff.DayOfYear] += all;
                     statsInfo.activity.homework += all;
+                    statsInfo.activity.month += all;
                     statsInfo.activity.lastDay = ((int)statsInfo.activity.year[lastDay.DayOfYear]);
                     statsInfo.activity.dayCnt = ((int)statsInfo.activity.year[dateOff.DayOfYear]);
 
@@ -2126,6 +2157,7 @@ namespace TEAMModelBI.Controllers.BITest
                     break;
             }
 
+
             if (resStsInfo.Status == 200)
                 statsInfo = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<StatsInfo>(statsInfo, scId, new PartitionKey("Stats"));
             else
@@ -2134,17 +2166,20 @@ namespace TEAMModelBI.Controllers.BITest
             return Ok(new { state = 200, statsInfo });
         }
 
+
         public class linqTest
         {
             public string id { get; set; }
+            public string aresid { get; set; }
             public string name { get; set; }
-            public List<linq1> linq1s { get; set; }
+            public linq1 linq1 { get; set; }
         }
 
         public class linq1
         {
             public string id { get; set; }
             public long times { get; set; }
+            public int cnt { get; set; }
         }
 
         public class Test

+ 68 - 44
TEAMModelBI/Controllers/Census/SchoolController.cs

@@ -25,6 +25,7 @@ using TEAMModelOS.SDK.Models.Cosmos.BI;
 using TEAMModelOS.SDK.Models.Cosmos.BI.BISchool;
 using TEAMModelOS.SDK.Models.Service.BI;
 using TEAMModelOS.SDK.Models.Service.BIStatsWay;
+using static TEAMModelBI.Controllers.Census.ActivitySticsController;
 using static TEAMModelBI.Controllers.Census.SchoolController;
 using LessonStats = TEAMModelOS.SDK.Models.Cosmos.BI.LessonStats;
 
@@ -492,6 +493,8 @@ namespace TEAMModelBI.Controllers.Census
             return Ok(new { state = RespondCode.Ok, scCnt = scIds.Count, tchCnt, stuCnt, allCnt = tLessCnt + tActCnt, tLessCnt, tActCnt });
         }
 
+        #region   新的统计接口
+
         /// <summary>
         /// 学校统计     
         /// 新的数据结构
@@ -593,6 +596,8 @@ namespace TEAMModelBI.Controllers.Census
                     scStats.actStats.week = statsInfo.activity.week;
                     scStats.actStats.lastTerm = statsInfo.activity.lastTerm;
                     scStats.actStats.term = statsInfo.activity.term;
+                    scStats.actStats.lastMonth = statsInfo.activity.lastMonth;
+                    scStats.actStats.month = statsInfo.activity.month;
                     scStats.actStats.lastYear = ((int)BICommonWay.ManyDoubleMerge(lastYear.Select(s => s.activity.year).Where(w => w.Count > 0).ToList()).Sum());
 
                     scStats.actStats.year = TimeHelper.GetYearMonth(statsInfo.activity.year, dateTime.Year, dateTime.Month);
@@ -775,6 +780,8 @@ namespace TEAMModelBI.Controllers.Census
                 areaScStats.actStats.week = statsInfo.activity.week;
                 areaScStats.actStats.lastTerm = statsInfo.activity.lastTerm;
                 areaScStats.actStats.term = statsInfo.activity.term;
+                areaScStats.actStats.lastMonth = statsInfo.activity.lastMonth;
+                areaScStats.actStats.month = statsInfo.activity.month;
                 areaScStats.actStats.lastYear = ((int)BICommonWay.ManyDoubleMerge(lastYear.Select(s => s.activity.year).Where(w => w.Count > 0).ToList()).Sum());
                 areaScStats.actStats.year = TimeHelper.GetYearMonth(statsInfo.activity.year, dateTime.Year, dateTime.Month);
                 if (statsInfo.study != null)
@@ -965,6 +972,8 @@ namespace TEAMModelBI.Controllers.Census
                 areaScStats.actStats.week = statsInfo.activity.week;
                 areaScStats.actStats.lastTerm = statsInfo.activity.lastTerm;
                 areaScStats.actStats.term = statsInfo.activity.term;
+                areaScStats.actStats.lastMonth = statsInfo.activity.lastMonth;
+                areaScStats.actStats.month = statsInfo.activity.month;
                 areaScStats.actStats.lastYear = ((int)BICommonWay.ManyDoubleMerge(lastYear.Select(s => s.activity.year).Where(w => w.Count > 0).ToList()).Sum());
                 areaScStats.actStats.year = TimeHelper.GetYearMonth(statsInfo.activity.year, dateTime.Year, dateTime.Month);
                 if (statsInfo.study != null)
@@ -1000,52 +1009,11 @@ namespace TEAMModelBI.Controllers.Census
             return Ok(new { state = RespondCode.Ok, areaScStats, schoolInfos, weekLess, assists = assits.Where((w, i) => assits.FindIndex(s => s.id.Equals(w.id)) == i).ToList(), saless = saless.Where((w, i) => saless.FindIndex(f => f.id.Equals(w.id)) == i).ToList() });
         }
 
-
         /// <summary>
-        /// 学校信息中间件查询接口
+        /// 所有区级的统计
         /// </summary>
         /// <param name="jsonElement"></param>
         /// <returns></returns>
-        [ProducesDefaultResponseType]
-        [HttpPost("get-scinfos")]
-        public async Task<IActionResult> GetScInfos(JsonElement jsonElement)
-        {
-            var cosmosClient = _azureCosmos.GetCosmosClient();
-            jsonElement.TryGetProperty("role", out JsonElement role);
-            jsonElement.TryGetProperty("tmdId", out JsonElement tmdId);
-            jsonElement.TryGetProperty("areaId", out JsonElement areaId);
-
-            StringBuilder sql = new($"select value(c) from c");
-
-            if (!string.IsNullOrEmpty($"{role}") && !string.IsNullOrEmpty($"{tmdId}") && string.IsNullOrEmpty($"{areaId}"))
-            {
-                switch ($"{role}")
-                {
-                    case "assist":
-                        sql.Append($" join a in c.assist where a.id='{tmdId}'");
-                        break;
-                    case "sales":
-                        sql.Append($" join a in c.sales where a.id='{tmdId}'");
-                        break;
-                }
-            }
-
-            if (!string.IsNullOrEmpty($"{areaId}") && !string.IsNullOrEmpty($"{role}"))
-            {
-                sql.Append($" where c.areaId ='{areaId}'");
-            }
-
-            //List<string> scId = await CommonFind.FindScIds(cosmosClient, "select value(c.id) from c ", "Base");
-
-            List<BIRelation> scInfos = new();
-            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<BIRelation>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
-            {
-                scInfos.Add(item);
-            }
-
-            return Ok(new { state = RespondCode.Ok, allCnt = scInfos.Count, scInfos });
-        }
-
         [ProducesDefaultResponseType]
         [HttpPost("get-allscstats")]
         public async Task<IActionResult> GetAllAreaStats(JsonElement jsonElement)
@@ -1080,12 +1048,15 @@ namespace TEAMModelBI.Controllers.Census
             {
                 statsInfos.Add(item);
             }
-            var areaGrup = statsInfos.GroupBy(g => g.areaId).ToList().Select(s => s.Where(w => w.areaId.Equals(s.Key)));
+            var areaGrup = statsInfos.GroupBy(p => p.areaId).Select(s => new { areaId = s.Key, lessAct = (s.Select(sl => sl.lesson.all).Sum() + s.Select(sa => sa.activity.all).Sum()), lessCnt = s.Select(sl => sl.lesson.all).Sum(), actCnt = s.Select(sa => sa.activity.all).Sum() }).ToList();
 
             StatsInfo statsInfo = null;
             statsInfo = SchoolStatsWay.GetAreaStats(cosmosClient, _httpTrigger, _option, statsInfos);
             if (statsInfo != null)
             {
+                allScStats.sc = statsInfos.Count;
+                allScStats.weekSc = statsInfos.FindAll(f=>f.scCreateTime  >= weekS && f.scCreateTime <= weekE).Count;
+                allScStats.monthSc = statsInfos.FindAll(f => f.scCreateTime >= mthS && f.scCreateTime <= mthE).Count;
                 allScStats.tch = statsInfo.tch;
                 allScStats.dayTch = statsInfo.dayTch;
                 allScStats.weekTch = statsInfo.weekTch;
@@ -1125,6 +1096,8 @@ namespace TEAMModelBI.Controllers.Census
                 allScStats.actStats.week = statsInfo.activity.week;
                 allScStats.actStats.lastTerm = statsInfo.activity.lastTerm;
                 allScStats.actStats.term = statsInfo.activity.term;
+                allScStats.actStats.lastMonth = statsInfo.activity.lastMonth;
+                allScStats.actStats.month = statsInfo.activity.month;
                 if (statsInfo.study != null)
                 {
                     allScStats.srStats.learnTime = statsInfo.study.learnTime;
@@ -1138,9 +1111,55 @@ namespace TEAMModelBI.Controllers.Census
                 }
             }
 
-            return Ok(new { state = RespondCode.Ok, allScStats });
+            return Ok(new { state = RespondCode.Ok, allScStats, areaGrup });
         }
 
+        #endregion   新的统计接口
+
+        /// <summary>
+        /// 学校信息中间件查询接口
+        /// </summary>
+        /// <param name="jsonElement"></param>
+        /// <returns></returns>
+        [ProducesDefaultResponseType]
+        [HttpPost("get-scinfos")]
+        public async Task<IActionResult> GetScInfos(JsonElement jsonElement)
+        {
+            var cosmosClient = _azureCosmos.GetCosmosClient();
+            jsonElement.TryGetProperty("role", out JsonElement role);
+            jsonElement.TryGetProperty("tmdId", out JsonElement tmdId);
+            jsonElement.TryGetProperty("areaId", out JsonElement areaId);
+
+            StringBuilder sql = new($"select value(c) from c");
+
+            if (!string.IsNullOrEmpty($"{role}") && !string.IsNullOrEmpty($"{tmdId}") && string.IsNullOrEmpty($"{areaId}"))
+            {
+                switch ($"{role}")
+                {
+                    case "assist":
+                        sql.Append($" join a in c.assist where a.id='{tmdId}'");
+                        break;
+                    case "sales":
+                        sql.Append($" join a in c.sales where a.id='{tmdId}'");
+                        break;
+                }
+            }
+
+            if (!string.IsNullOrEmpty($"{areaId}") && !string.IsNullOrEmpty($"{role}"))
+            {
+                sql.Append($" where c.areaId ='{areaId}'");
+            }
+
+            //List<string> scId = await CommonFind.FindScIds(cosmosClient, "select value(c.id) from c ", "Base");
+
+            List<BIRelation> scInfos = new();
+            await foreach (var item in cosmosClient.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<BIRelation>(queryText: sql.ToString(), requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BIRel") }))
+            {
+                scInfos.Add(item);
+            }
+
+            return Ok(new { state = RespondCode.Ok, allCnt = scInfos.Count, scInfos });
+        }
 
 
         /// <summary>
@@ -1262,6 +1281,9 @@ namespace TEAMModelBI.Controllers.Census
         /// </summary>
         public record AllScStats
         {
+            public int sc { get; set; }
+            public int weekSc { get; set; }
+            public int monthSc { get; set; }
             public int tch { get; set; }
             public int dayTch { get; set; }
             public int weekTch { get; set; }
@@ -1329,6 +1351,8 @@ namespace TEAMModelBI.Controllers.Census
             public int week { get; set; }
             public int lastTerm { get; set; }
             public int term { get; set; }
+            public int lastMonth { get; set; }
+            public int month { get; set; }
 
         }
 

+ 12 - 3
TEAMModelBI/Controllers/LoginController.cs

@@ -559,8 +559,8 @@ namespace TEAMModelBI.Controllers
                 loginSql = $"select value(c) from c where c.mail ={mail}";
             else return Ok(new { state = RespondCode.ParamsError, msg = "手机号/和邮箱为空" });
 
-            List<BusinessUsers> bizUsers = new();
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<BusinessUsers>(queryText:loginSql,requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
+            List<BizUsers> bizUsers = new();
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<BizUsers>(queryText:loginSql,requestOptions:new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
             {
                 bizUsers.Add(item);
             }
@@ -572,7 +572,16 @@ namespace TEAMModelBI.Controllers
                     var hashedPw = Utils.HashedPassword(password.ToString(), item.salt.ToString());
                     if (hashedPw.Equals(item.pwd))
                     {
-                        businessUsers = item;
+                        businessUsers = new()
+                        {
+                            id = item.id,
+                            code = item.code,
+                            name = item.name,
+                            picture = item.picture,
+                            mobile = item.mobile,
+                            mail = item.mail,
+                            relation = item.relation,
+                        };
                         //string id_token = JwtAuth.CreateAuthTokenBI(_option.HostName, bizUser.RowKey?.ToString(), bizUser.name?.ToString(), bizUser.picture?.ToString(), _option.JwtSecretKey, scope: "company", webSite: Website, expire: 3);
                         openid_token = JwtAuthExtension.CreateBizLoginAuthToken(_option.HostName, businessUsers.id?.ToString(), businessUsers.name?.ToString(), businessUsers.picture?.ToString(), $"{_option.Location}-Open", _option.JwtSecretKey, expire: 3);
 

+ 3 - 0
TEAMModelBI/Controllers/RepairApi/SchoolRepController.cs

@@ -511,7 +511,10 @@ namespace TEAMModelBI.Controllers.RepairApi
             DateTimeOffset dateTime = DateTimeOffset.UtcNow;
             int year = dateTime.Year;
             if (!string.IsNullOrEmpty($"{_year}"))
+            {
                 year = _year.GetInt32();
+                dateTime = dateTime.AddYears(-1);
+            }
 
             List<StatsInfo> statsInfos = new();
             List<Task<ItemResponse<StatsInfo>>> taskStss = new();

+ 17 - 1
TEAMModelBI/Tool/CosmosBank/StatsWay.cs

@@ -220,6 +220,9 @@ namespace TEAMModelBI.Tool.CosmosBank
             var (lastTermS, lastTermE) = TimeHelper.GetStartOrEnd(dateTime, "lastterm");   //计算上学期开始/结束时间
             var (termS, termE) = TimeHelper.GetStartOrEnd(dateTime, "term");   //计算本学期开始/结束时间
 
+            var (lastMonthS, lastMonthE) = TimeHelper.GetStartOrEnd(dateTime, "lastMonth");   //上月开始/结束时间
+            var (monthS, monthE) = TimeHelper.GetStartOrEnd(dateTime, "month");   //本月开始/结束时间
+
             var (lastYearS, lastYearE) = TimeHelper.GetStartOrEnd(DateTimeOffset.Parse($"{dateTime.Year - 1}-1-1"), "year"); //计算去年开始/结束时间
             var (yearS, yearE) = TimeHelper.GetStartOrEnd(dateTime, "year");         //计算今年开始/结束时间
 
@@ -236,6 +239,8 @@ namespace TEAMModelBI.Tool.CosmosBank
             int week = 0;
             int lastTerm = 0;
             int term = 0;
+            int lastMonth = 0;
+            int month = 0;
 
             DateTimeOffset lyearDay = new(DateTimeOffset.UtcNow.Year - 1, DateTimeOffset.UtcNow.Month, DateTimeOffset.UtcNow.Day, DateTimeOffset.UtcNow.Hour, DateTimeOffset.UtcNow.Minute, DateTimeOffset.UtcNow.Second, TimeSpan.Zero);
             List<StartEndTime> leveryDay = TimeHelper.GetYearEveryDay(lyearDay);
@@ -292,6 +297,8 @@ namespace TEAMModelBI.Tool.CosmosBank
                 week += examSts.FindAll(f => f.createTime >= weekS && f.createTime <= weekE).ToList().Count;
                 lastTerm += examSts.FindAll(f => f.createTime >= lastTermS && f.createTime <= lastTermE).ToList().Count;
                 term += examSts.FindAll(f => f.createTime >= termS && f.createTime <= termE).ToList().Count;
+                lastMonth += examSts.FindAll(f => f.createTime >= lastMonthS && f.createTime <= lastMonthE).ToList().Count;
+                month += examSts.FindAll(f => f.createTime >= monthS && f.createTime <= monthE).ToList().Count;
             }
             
             if (surveySts.Count > 0)
@@ -302,7 +309,9 @@ namespace TEAMModelBI.Tool.CosmosBank
                 lastWeek += surveySts.FindAll(f => f.createTime >= lastWeekS && f.createTime <= lastWeekE).ToList().Count;
                 week += surveySts.FindAll(f => f.createTime >= weekS && f.createTime <= weekE).ToList().Count;
                 lastTerm += surveySts.FindAll(f => f.createTime >= lastTermS && f.createTime <= lastTermE).ToList().Count;
-                term += surveySts.FindAll(f => f.createTime >= termS && f.createTime <= termE).ToList().Count;                
+                term += surveySts.FindAll(f => f.createTime >= termS && f.createTime <= termE).ToList().Count;
+                lastMonth += examSts.FindAll(f => f.createTime >= lastMonthS && f.createTime <= lastMonthE).ToList().Count;
+                month += examSts.FindAll(f => f.createTime >= monthS && f.createTime <= monthE).ToList().Count;
             }
 
             if (voteSts.Count > 0)
@@ -314,6 +323,8 @@ namespace TEAMModelBI.Tool.CosmosBank
                 week += voteSts.FindAll(f => f.createTime >= weekS && f.createTime <= weekE).ToList().Count;
                 lastTerm += voteSts.FindAll(f => f.createTime >= lastTermS && f.createTime <= lastTermE).ToList().Count;
                 term += voteSts.FindAll(f => f.createTime >= termS && f.createTime <= termE).ToList().Count;
+                lastMonth += examSts.FindAll(f => f.createTime >= lastMonthS && f.createTime <= lastMonthE).ToList().Count;
+                month += examSts.FindAll(f => f.createTime >= monthS && f.createTime <= monthE).ToList().Count;
             }
 
             if (homeworkSts.Count > 0)
@@ -325,6 +336,8 @@ namespace TEAMModelBI.Tool.CosmosBank
                 week += homeworkSts.FindAll(f => f.createTime >= weekS && f.createTime <= weekE).ToList().Count;
                 lastTerm += homeworkSts.FindAll(f => f.createTime >= lastTermS && f.createTime <= lastTermE).ToList().Count;
                 term += homeworkSts.FindAll(f => f.createTime >= termS && f.createTime <= termE).ToList().Count;
+                lastMonth += examSts.FindAll(f => f.createTime >= lastMonthS && f.createTime <= lastMonthE).ToList().Count;
+                month += examSts.FindAll(f => f.createTime >= monthS && f.createTime <= monthE).ToList().Count;
             }
 
             if (tempAll.Count > 0) 
@@ -406,6 +419,9 @@ namespace TEAMModelBI.Tool.CosmosBank
             actStats.week = week;
             actStats.lastTerm = lastTerm;
             actStats.term = term;
+            actStats.lastMonth = lastMonth;
+            actStats.month = month;
+            actStats.upTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
 
             return actStats;
         }

+ 3 - 2
TEAMModelOS.SDK/Context/Attributes/Filter/ApiTokenAttribute.cs

@@ -17,6 +17,7 @@ using TEAMModelOS.SDK.Models.Cosmos.BI.BINormal;
 using System.Text.Json;
 using HTEXLib.COMM.Helpers;
 using TEAMModelOS.SDK.Models.Cosmos.OpenEntity;
+using System.Security.AccessControl;
 
 namespace TEAMModelOS.Filter
 {
@@ -129,7 +130,7 @@ namespace TEAMModelOS.Filter
                 }
                 string msg = "";
                 int code = 0;
-                if (scope.Equals("school") || scope.Equals("business"))
+                if (scope.Equals("school") || scope.Equals("business") || scope.Equals("customize"))
                 {
                     string id = string.Empty, school = string.Empty, jti = string.Empty;
 
@@ -216,7 +217,7 @@ namespace TEAMModelOS.Filter
                                     pass = true;
 #endif
                                 }
-                                else if (scope.Equals("business"))
+                                else if (scope.Equals("business") || scope.Equals("customize"))
                                 {
                                     // 同时判断 jti 是否已经轮换,或更新。如果不是则不能授权
                                     //如果是商务合作模式 则需要手动获取学校编码

+ 2 - 0
TEAMModelOS.SDK/DI/CoreAPI/CoreAPIHttpService.cs

@@ -18,6 +18,7 @@ using System.Security.Policy;
 using System.Text;
 using System.Text.Json;
 using System.Threading.Tasks;
+using System.Web;
 using TEAMModelOS.Models;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
@@ -274,6 +275,7 @@ namespace TEAMModelOS.SDK
                                 var  rdata=Convert.ToBase64String(byts);
                                 byte[] bs= Convert.FromBase64String(rdata);
                                 string data1 = Encoding.Unicode.GetString(bs);
+                                rdata = HttpUtility.UrlEncode(rdata, Encoding.UTF8);
                                 urlAction = $"{urlAction}?notifyCode={notifyCode}&data={rdata}";
                                 if (msgs.Count == 3)
                                 {

+ 3 - 1
TEAMModelOS.SDK/Extension/JwtAuthExtension.cs

@@ -56,9 +56,11 @@ namespace TEAMModelOS.SDK.Extension
         /// <param name="salt"></param>
         /// <param name="expire"></param>
         /// <returns></returns>
-        public static (string jwt , string jti) CreateBusinessApiToken(string location, string id, string salt )
+        public static (string jwt , string jti) CreateBusinessApiToken(string location, string id, string salt,int customize = 0 )
         {
             string scope = "business";
+            if (customize != 0)
+                scope = "customize";
             var keys = OpenApiJtwIssuer.OpenApiJtw签发者.GetDescriptionText().Split(',');
             string issuer = "";
             if (location.Equals("China-Dep"))

+ 14 - 5
TEAMModelOS.SDK/Models/Cosmos/BI/BINormal/BizConfig.cs

@@ -14,6 +14,7 @@ namespace TEAMModelOS.SDK.Models.Cosmos.BI.BINormal
     {
         public BizConfig()
         {
+            code = "BizConfig";
             pk = "BizConfig";
         }
         /// <summary>
@@ -55,6 +56,11 @@ namespace TEAMModelOS.SDK.Models.Cosmos.BI.BINormal
 
         public string domain { get; set; }
 
+        /// <summary>
+        /// 是否定制  0 对外开放平台  1 定制开放平台
+        /// </summary>
+        
+        public int isCustomize { get; set; } = 0;
         /// <summary>
         /// webhook  支持多个地址, 逗号隔开 。
         /// </summary>
@@ -194,12 +200,12 @@ namespace TEAMModelOS.SDK.Models.Cosmos.BI.BINormal
         /// <summary>
         /// 密码生成秘钥
         /// </summary>
-        public string salt { get; set; }
+        //public string salt { get; set; }
 
         /// <summary>
         /// 密码
         /// </summary>
-        public string pwd { get; set; }
+        //public string pwd { get; set; }
         /// <summary>
         /// 企业关联信息
         /// </summary>
@@ -260,11 +266,14 @@ namespace TEAMModelOS.SDK.Models.Cosmos.BI.BINormal
         /// </summary>
 
         public string webhook { get; set; }
-
         /// <summary>
-        /// 是否https 0 否,1 是 
+        /// webhook的访问金钥
+        /// </summary>
+        public string webhookToken { get; set; }
+        /// <summary>
+        /// webhook的访问金钥
         /// </summary>
-        public int https { get; set; } = 0;
+        public string webhookHead { get; set; }
 
         /// <summary>
         /// 授权的token ,存放 scope="business",Sub="合作方id",  9e40e436-f958-498d-93cf-4242b77a17ab

+ 8 - 0
TEAMModelOS.SDK/Models/Cosmos/BI/StatsInfo.cs

@@ -283,6 +283,14 @@ namespace TEAMModelOS.SDK.Models.Cosmos.BI
         /// </summary>
         public int lastTerm { get; set; }
         /// <summary>
+        /// 上月活动
+        /// </summary>
+        public int lastMonth { get; set; }
+        /// <summary>
+        /// 本月活动
+        /// </summary>
+        public int month { get; set; }
+        /// <summary>
         /// 本学期活动
         /// </summary>
         public int term { get; set; }

+ 21 - 7
TEAMModelOS.SDK/Models/Service/BIStatsWay/ActivityStatsWay.cs

@@ -1,4 +1,5 @@
 using Azure.Cosmos;
+using DocumentFormat.OpenXml.Bibliography;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -22,9 +23,7 @@ namespace TEAMModelOS.SDK.Models.Service.BIStatsWay
             ActivityStats actStats = new();
 
             DateTimeOffset dateTime = DateTimeOffset.UtcNow;
-            if (year == 0)
-                year = dateTime.Year;
-            else
+            if (year < dateTime.Year)
                 dateTime = new(year, 12, 31, 23, 59, 59, TimeSpan.Zero);
 
             var (lastDayS, lastdayE) = TimeHelper.GetStartOrEnd(dateTime.AddDays(-1));   //昨天开始时间
@@ -36,6 +35,9 @@ namespace TEAMModelOS.SDK.Models.Service.BIStatsWay
             var (lastTermS, lastTermE) = TimeHelper.GetStartOrEnd(dateTime, "lastterm");   //计算上学期开始/结束时间
             var (termS, termE) = TimeHelper.GetStartOrEnd(dateTime, "term");   //计算本学期开始/结束时间
 
+            var (lastMonthS, lastMonthE) = TimeHelper.GetStartOrEnd(dateTime, "lastMonth");   //上月开始/结束时间
+            var (monthS, monthE) = TimeHelper.GetStartOrEnd(dateTime, "month");   //本月开始/结束时间
+
             var (lastYearS, lastYearE) = TimeHelper.GetStartOrEnd(DateTimeOffset.Parse($"{dateTime.Year - 1}-1-1"), "year"); //计算去年开始/结束时间
             var (yearS, yearE) = TimeHelper.GetStartOrEnd(dateTime, "year");         //计算今年开始/结束时间
 
@@ -52,6 +54,8 @@ namespace TEAMModelOS.SDK.Models.Service.BIStatsWay
             int week = 0;
             int lastTerm = 0;
             int term = 0;
+            int lastMonth = 0;
+            int month = 0;
 
             DateTimeOffset lyearDay = new(year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, dateTime.Second, TimeSpan.Zero);
             List<StartEndTime> everyDay = TimeHelper.GetYearEveryDay(lyearDay);
@@ -65,14 +69,14 @@ namespace TEAMModelOS.SDK.Models.Service.BIStatsWay
                 switch (artType)
                 {
                     case "Exam":
-                        exam = await JointlySingleQuery.GetValueInt(cosmosClient, "Common", currSql, $"Exam-{scId}");
+                        exam = await JointlySingleQuery.GetValueInt(cosmosClient, "Common", $"Exam-{scId}", currSql);
                         await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ArtRelStats>(queryText: yearSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Exam-{scId}") }))
                         {
                             examSts.Add(item);
                         }
                         break;
                     case "Survey":
-                        survey = await JointlySingleQuery.GetValueInt(cosmosClient, "Common", currSql, $"Survey-{scId}");
+                        survey = await JointlySingleQuery.GetValueInt(cosmosClient, "Common", $"Survey-{scId}", currSql);
                         await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ArtRelStats>(queryText: yearSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Survey-{scId}") }))
                         {
                             surveySts.Add(item);
@@ -80,14 +84,14 @@ namespace TEAMModelOS.SDK.Models.Service.BIStatsWay
 
                         break;
                     case "Vote":
-                        vote = await JointlySingleQuery.GetValueInt(cosmosClient, "Common", currSql, $"Vote-{scId}");
+                        vote = await JointlySingleQuery.GetValueInt(cosmosClient, "Common", $"Vote-{scId}", currSql);
                         await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ArtRelStats>(queryText: yearSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Vote-{scId}") }))
                         {
                             voteSts.Add(item);
                         }
                         break;
                     case "Homework":
-                        homework = await JointlySingleQuery.GetValueInt(cosmosClient, "Common", currSql, $"Homework-{scId}");
+                        homework = await JointlySingleQuery.GetValueInt(cosmosClient, "Common", $"Homework-{scId}", currSql);
                         await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ArtRelStats>(queryText: yearSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Homework-{scId}") }))
                         {
                             homeworkSts.Add(item);
@@ -106,6 +110,8 @@ namespace TEAMModelOS.SDK.Models.Service.BIStatsWay
                 week += examSts.FindAll(f => f.createTime >= weekS && f.createTime <= weekE).ToList().Count;
                 lastTerm += examSts.FindAll(f => f.createTime >= lastTermS && f.createTime <= lastTermE).ToList().Count;
                 term += examSts.FindAll(f => f.createTime >= termS && f.createTime <= termE).ToList().Count;
+                lastMonth += examSts.FindAll(f => f.createTime >= lastMonthS && f.createTime <= lastMonthE).ToList().Count;
+                month += examSts.FindAll(f => f.createTime >= monthS && f.createTime <= monthE).ToList().Count;
             }
 
             if (surveySts.Count > 0)
@@ -117,6 +123,8 @@ namespace TEAMModelOS.SDK.Models.Service.BIStatsWay
                 week += surveySts.FindAll(f => f.createTime >= weekS && f.createTime <= weekE).ToList().Count;
                 lastTerm += surveySts.FindAll(f => f.createTime >= lastTermS && f.createTime <= lastTermE).ToList().Count;
                 term += surveySts.FindAll(f => f.createTime >= termS && f.createTime <= termE).ToList().Count;
+                lastMonth += examSts.FindAll(f => f.createTime >= lastMonthS && f.createTime <= lastMonthE).ToList().Count;
+                month += examSts.FindAll(f => f.createTime >= monthS && f.createTime <= monthE).ToList().Count;
             }
 
             if (voteSts.Count > 0)
@@ -128,6 +136,8 @@ namespace TEAMModelOS.SDK.Models.Service.BIStatsWay
                 week += voteSts.FindAll(f => f.createTime >= weekS && f.createTime <= weekE).ToList().Count;
                 lastTerm += voteSts.FindAll(f => f.createTime >= lastTermS && f.createTime <= lastTermE).ToList().Count;
                 term += voteSts.FindAll(f => f.createTime >= termS && f.createTime <= termE).ToList().Count;
+                lastMonth += examSts.FindAll(f => f.createTime >= lastMonthS && f.createTime <= lastMonthE).ToList().Count;
+                month += examSts.FindAll(f => f.createTime >= monthS && f.createTime <= monthE).ToList().Count;
             }
 
             if (homeworkSts.Count > 0)
@@ -139,6 +149,8 @@ namespace TEAMModelOS.SDK.Models.Service.BIStatsWay
                 week += homeworkSts.FindAll(f => f.createTime >= weekS && f.createTime <= weekE).ToList().Count;
                 lastTerm += homeworkSts.FindAll(f => f.createTime >= lastTermS && f.createTime <= lastTermE).ToList().Count;
                 term += homeworkSts.FindAll(f => f.createTime >= termS && f.createTime <= termE).ToList().Count;
+                lastMonth += examSts.FindAll(f => f.createTime >= lastMonthS && f.createTime <= lastMonthE).ToList().Count;
+                month += examSts.FindAll(f => f.createTime >= monthS && f.createTime <= monthE).ToList().Count;
             }
 
             if (tempAll.Count > 0)
@@ -220,6 +232,8 @@ namespace TEAMModelOS.SDK.Models.Service.BIStatsWay
             actStats.week = week;
             actStats.lastTerm = lastTerm;
             actStats.term = term;
+            actStats.lastMonth = lastMonth;
+            actStats.month = month;
             actStats.upTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
 
             return actStats;

+ 6 - 8
TEAMModelOS.SDK/Models/Service/BIStatsWay/LessonRecordStatsWay.cs

@@ -22,9 +22,7 @@ namespace TEAMModelOS.SDK.Models.Service.BIStatsWay
         {
             LessonStats lessStats = new();
             DateTimeOffset dateTime = DateTimeOffset.UtcNow;
-            if (year == 0)
-                year = dateTime.Year;
-            else
+            if (year < dateTime.Year)
                 dateTime = new(year, 12, 31, 23, 59, 59, TimeSpan.Zero);
 
             var (lastDayS, lastdayE) = TimeHelper.GetStartOrEnd(dateTime.AddDays(-1));   //昨天开始时间
@@ -43,9 +41,9 @@ namespace TEAMModelOS.SDK.Models.Service.BIStatsWay
             var (yearS, yearE) = TimeHelper.GetStartOrEnd(dateTime, "year");         //计算今年开始/结束时间
 
             string currSql = "select value(count(c.id)) from c  where c.pk='LessonRecord'";
-            lessStats.all = await JointlySingleQuery.GetValueInt(cosmosClient, "School", currSql, $"LessonRecord-{id}");
-            lessStats.open = await JointlySingleQuery.GetValueInt(cosmosClient, "School", $"{currSql} and c.upload = 0", $"LessonRecord-{id}");
-            lessStats.less = await JointlySingleQuery.GetValueInt(cosmosClient, "School", $"{currSql} and c.upload = 1", $"LessonRecord-{id}");
+            lessStats.all = await JointlySingleQuery.GetValueInt(cosmosClient, "School", $"LessonRecord-{id}", currSql);
+            lessStats.open = await JointlySingleQuery.GetValueInt(cosmosClient, "School", $"LessonRecord-{id}", $"{currSql} and c.upload = 0");
+            lessStats.less = await JointlySingleQuery.GetValueInt(cosmosClient, "School", $"LessonRecord-{id}", $"{currSql} and c.upload = 1");
 
             List<LessRelStats> lessRelStats = new();
             string sql = $"select c.id,c.code,c.startTime,c.clientInteractionCount from c where c.pk='LessonRecord' and c.startTime >= {yearS} and c.startTime <= {yearE}";
@@ -67,8 +65,8 @@ namespace TEAMModelOS.SDK.Models.Service.BIStatsWay
             lessStats.dayInter = lessRelStats.FindAll(f => f.startTime >= dayS && f.startTime <= dayS).ToList().Select(s => s.clientInteractionCount).Sum();
             lessStats.lastMonthInter = lessRelStats.FindAll(f => f.startTime >= lastMthS && f.startTime <= LastmthE).ToList().Select(s => s.clientInteractionCount).Sum();
             lessStats.monthInter = lessRelStats.FindAll(f => f.startTime >= mthS && f.startTime <= mthE).ToList().Select(s => s.clientInteractionCount).Sum();
-            lessStats.allInter = await JointlySingleQuery.GetValueInt(cosmosClient, "School", $"select value(sum(c.clientInteractionCount)) from c where c.startTime <= {yearE}", $"LessonRecord-{id}");
-            lessStats.lastYearInter = await JointlySingleQuery.GetValueInt(cosmosClient, "School", $"select value(sum(c.clientInteractionCount)) from c where c.startTime >= {lastYearS} and c.startTime <= {lastYearE}", $"LessonRecord-{id}");
+            lessStats.allInter = await JointlySingleQuery.GetValueInt(cosmosClient, "School", $"LessonRecord-{id}", $"select value(sum(c.clientInteractionCount)) from c where c.startTime <= {yearE}");
+            lessStats.lastYearInter = await JointlySingleQuery.GetValueInt(cosmosClient, "School", $"LessonRecord-{id}", $"select value(sum(c.clientInteractionCount)) from c where c.startTime >= {lastYearS} and c.startTime <= {lastYearE}");
             //lessStats.yearInter = lessRelStats.FindAll(f => f.startTime >= yearS && f.startTime <= yearE).ToList().Select(s => s.clientInteractionCount).Sum();
 
             DateTimeOffset lyearDay = new(year, dateTime.Month, dateTime.Day, dateTime.Hour, dateTime.Minute, dateTime.Second, TimeSpan.Zero);

+ 3 - 3
TEAMModelOS.SDK/Models/Service/BIStatsWay/SchoolStatsWay.cs

@@ -29,9 +29,7 @@ namespace TEAMModelOS.SDK.Models.Service.BIStatsWay
         public static async Task<StatsInfo> GetSingleSc(CosmosClient cosmosClient, string scId, int year = 0)
         {
             DateTimeOffset dateTime = DateTimeOffset.UtcNow;
-            if (year == 0)
-                year = dateTime.Year;
-            else
+            if (year < dateTime.Year)
                 dateTime = new(year, 12, 31, 23, 59, 59, TimeSpan.Zero);
 
             StatsInfo statsInfo = new() { id = $"{year}-{scId}" };
@@ -150,6 +148,8 @@ namespace TEAMModelOS.SDK.Models.Service.BIStatsWay
             areaInfo.activity.week = statsInfos.Select(s => s.activity.week).Sum();
             areaInfo.activity.lastTerm = statsInfos.Select(s => s.activity.lastTerm).Sum();
             areaInfo.activity.term = statsInfos.Select(s => s.activity.term).Sum();
+            areaInfo.activity.lastMonth = statsInfos.Select(s => s.activity.lastMonth).Sum();
+            areaInfo.activity.month = statsInfos.Select(s => s.activity.month).Sum();
             //areaInfo.activity.LastYear = BICommonWay.ManyDoubleMerge(statsInfos.Select(s => s.activity.LastYear).ToList());
             areaInfo.activity.year = BICommonWay.ManyDoubleMerge(statsInfos.Select(s => s.activity.year).Where(w => w.Count > 0).ToList());
 

+ 13 - 0
TEAMModelOS/ClientApp/src/view/auth/Product.less

@@ -98,4 +98,17 @@
     color: #1cc0f3;
     padding-left: 5px;
     line-height: 18px;
+}
+.product-status-tag {
+    font-size: 12px;
+    user-select: none;
+    color: white;
+    background: #ed4014;
+    position: absolute;
+    right: -28px;
+    top: 10px;
+    width: 100px;
+    padding: 2px 0px;
+    text-align: center;
+    transform: rotate(45deg);
 }

+ 16 - 10
TEAMModelOS/ClientApp/src/view/auth/Product.vue

@@ -28,9 +28,12 @@
                     </span>
                     <div>
                         {{$t('auth.authT3')}}
-                        <span style="color: #1890ff;">
+                        <span style="color: #1890ff;" v-if="spaceInfo.avaliableStartDate && spaceInfo.avaliableEndDate">
                             {{`${$jsFn.dateFormat(spaceInfo.avaliableStartDate)}-${$jsFn.dateFormat(spaceInfo.avaliableEndDate)}`}}
                         </span>
+                        <span v-else style="color: #ed4014">
+                            {{$t('learnActivity.createEv.noAuth')}}
+                        </span>
                     </div>
                 </div>
                 <Alert show-icon v-if="spaceStatus == 2" type="warning">
@@ -51,9 +54,12 @@
                     </span>
                     <div>
                         {{$t('auth.authT3')}}
-                        <span style="color: #1890ff;">
+                        <span style="color: #1890ff;" v-if="scaleInfo.avaliableStartDate && scaleInfo.avaliableEndDate">
                             {{`${$jsFn.dateFormat(scaleInfo.avaliableStartDate)}-${$jsFn.dateFormat(scaleInfo.avaliableEndDate)}`}}
                         </span>
+                        <span v-else style="color: #ed4014">
+                            {{$t('learnActivity.createEv.noAuth')}}
+                        </span>
                     </div>
                 </div>
                 <!-- 学校人数规模 -->
@@ -62,7 +68,7 @@
                         {{$t('auth.noBuy')}}
                     </span>
                     <p class="scale-count-num" :style="{background:scaleInfo.avaliable ? '#9bc84d':'#ed4014'}">
-                        {{scaleInfo.avaliable}}
+                        {{scaleInfo.avaliable || 0}}
                         <span style="font-size:14px">
                             {{$t('unit.text7')}}
                         </span>
@@ -88,7 +94,7 @@
                         {{ schoolBase.type == 2 ? $t('auth.periodInfo2') : $t('auth.periodInfo1')}}
                     </p>
                 </div>
-                <!-- 购买记录 -->
+                <!-- 购买记录  -->
                 <!-- <div class="auth-tab-wrap" style="margin-top:30px">
                     <span>
                         {{$t('auth.prodRecord')}}
@@ -278,7 +284,7 @@ export default {
                     image: require("@/assets/image/module2.jpg"),
                     content: this.$t('auth.content4'),
                     isPay: 0,
-                    prodCode: 'ART',
+                    prodCode: 'B6V5J6NP',
                     'zh-cn': '',
                     'zh-tw': '',
                     'en-us': '',
@@ -292,7 +298,7 @@ export default {
                     image: require("@/assets/image/module2.jpg"),
                     content: this.$t('auth.content5'),
                     isPay: 0,
-                    prodCode: 'SPORT',
+                    prodCode: 'LSZYJ6NA',
                     'zh-cn': '',
                     'zh-tw': '',
                     'en-us': '',
@@ -306,11 +312,11 @@ export default {
                     image: require("@/assets/image/module2.jpg"),
                     content: this.$t('auth.content6'),
                     isPay: 0,
-                    prodCode: 'MORAL',
+                    prodCode: 'CVGPJ6NN',
                     'zh-cn': '',
                     'zh-tw': '',
                     'en-us': '',
-                    isShow: this.$store.state.config.srvAdr !== 'China'
+                    isShow: this.$store.state.config.srvAdr == 'China'
                 },
                 {
                     name: this.$t('auth.module7'),
@@ -320,11 +326,11 @@ export default {
                     image: require("@/assets/image/module2.jpg"),
                     content: this.$t('auth.content7'),
                     isPay: 0,
-                    prodCode: 'LABOUR',
+                    prodCode: 'VDPGJ6NC',
                     'zh-cn': '',
                     'zh-tw': '',
                     'en-us': '',
-                    isShow: this.$store.state.config.srvAdr !== 'China'
+                    isShow: this.$store.state.config.srvAdr == 'China'
                 },
             ]
         }

+ 6 - 13
TEAMModelOS/Controllers/OpenApi/Business/BizCustomizeController.cs

@@ -22,7 +22,7 @@ namespace TEAMModelOS.Controllers
 {  /// <summary>
    /// 企业定制化接口
    /// </summary>
-    [Route("business")]
+    [Route("customize")]
     [ApiController]
     public class BizCustomizeController : ControllerBase
     {
@@ -49,8 +49,6 @@ namespace TEAMModelOS.Controllers
             _snowflakeId = snowflakeId;
         }
         
-
-
         #region  杉达公司
         /// <summary>
         /// 开课或者上传课例信息  是因支持VR/AR的公司(杉达)
@@ -62,15 +60,10 @@ namespace TEAMModelOS.Controllers
         [ProducesDefaultResponseType]
         [HttpPost("create-vrar-lesson-shanda")]
         [ApiToken(Auth = "2003", Name = "VR·AR开课/上传课例信息", TName = "VR·AR開課/上傳課例信息", EName = "Start VR·AR lesson/upload VR·AR lesson ", RWN = "W", Limit = false)]
-        public async Task<IActionResult> UpLessonRec(JsonElement jsonElement)
+        public async Task<IActionResult> UpdateLesson(JsonElement jsonElement)
         {
             var (id, school) = HttpContext.GetApiTokenInfo();
 
-
-
-
-
-
             try
             {
                 jsonElement.TryGetProperty("baseJson", out JsonElement baseJson);    //课例基础文件信息json
@@ -298,9 +291,9 @@ namespace TEAMModelOS.Controllers
         /// <param name="jsonElement"></param>
         /// <returns></returns>
         [ProducesDefaultResponseType]
-        [HttpPost("get-lesson-records")]
+        [HttpPost("get-vrar-lessons")]
         [ApiToken(Auth = "2004", Name = "获取学校课例", TName = "獲取學校課例", EName = "Get school lessons", RWN = "R", Limit = false)]
-        public async Task<IActionResult> GetLessonRec(JsonElement jsonElement)
+        public async Task<IActionResult> GetLesson(JsonElement jsonElement)
         {
             var (id, school) = HttpContext.GetApiTokenInfo();
             jsonElement.TryGetProperty("lessonId", out JsonElement lessId);
@@ -326,9 +319,9 @@ namespace TEAMModelOS.Controllers
         /// <param name="jsonElement"></param>
         /// <returns></returns>
         [ProducesDefaultResponseType]
-        [HttpPost("get-lesson-analysis")]
+        [HttpPost("get-vrar-lesson-analysis")]
         [ApiToken(Auth = "2006", Name = "获取学校课例", TName = "獲取學校課例", EName = "Get school lessons", RWN = "R", Limit = false)]
-        public async Task<IActionResult> GetLessonStats(JsonElement jsonElement)
+        public async Task<IActionResult> GetLessonAnslysis(JsonElement jsonElement)
         {
             var (id, school) = HttpContext.GetApiTokenInfo();
             if (!jsonElement.TryGetProperty("lessonId", out JsonElement lessonId)) return Ok(new { responseDate = new ResponseData<dynamic>() { code = RespondCode.ParamsError, msg = "lessId参数错误", data = null } });  //上课人ID  ;

+ 139 - 101
TEAMModelOS/Controllers/OpenApi/Init/BizUsersController.cs

@@ -65,53 +65,73 @@ namespace TEAMModelOS.Controllers
         [HttpPost("get-loginuser")]
         public async Task<IActionResult> GetBizUserLogin(JsonElement jsonElement)
         {
-            jsonElement.TryGetProperty("mobile", out JsonElement mobile);
-            jsonElement.TryGetProperty("mail", out JsonElement mail);
-            if (!jsonElement.TryGetProperty("pwd", out JsonElement password)) return BadRequest();
+            try
+            {
+                jsonElement.TryGetProperty("mobile", out JsonElement mobile);
+                jsonElement.TryGetProperty("mail", out JsonElement mail);
+                if (!jsonElement.TryGetProperty("pwd", out JsonElement password)) return BadRequest();
 
-            var cosmosClient = _azureCosmos.GetCosmosClient();
-            var tableClient = _azureStorage.GetCloudTableClient();
-            var blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public");
+                var cosmosClient = _azureCosmos.GetCosmosClient();
+                var tableClient = _azureStorage.GetCloudTableClient();
+                var blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public");
 
-            string loginSql = null;
-            if (!string.IsNullOrEmpty($"{mobile}"))
-                loginSql = $"select value(c) from c where c.mobile ={mobile}";
-            else if (!string.IsNullOrEmpty($"{mail}"))
-                loginSql = $"select value(c) from c where c.mail ={mail}";
-            else return Ok(new { state = RespondCode.ParamsError, msg = "手机号/和邮箱为空" });
+                string loginSql = null;
+                if (!string.IsNullOrEmpty($"{mobile}"))
+                    loginSql = $"select value(c) from c where c.mobile ={mobile}";
+                else if (!string.IsNullOrEmpty($"{mail}"))
+                    loginSql = $"select value(c) from c where c.mail ={mail}";
+                else return Ok(new { state = RespondCode.ParamsError, msg = "手机号/和邮箱为空" });
 
-            List<BusinessUsers> bizUsers = new();
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<BusinessUsers>(queryText: loginSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
-            {
-                bizUsers.Add(item);
-            }
-            BusinessUsers businessUsers = new(); string openid_token = null;
-            if (bizUsers.Count > 0)
-            {
-                foreach (var item in bizUsers)
+                List<BizUsers> bizUsers = new();
+                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<BizUsers>(queryText: loginSql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
+                {
+                    bizUsers.Add(item);
+                }
+                BusinessUsers businessUsers = new(); string openid_token = null;
+                if (bizUsers.Count > 0)
                 {
-                    var hashedPw = Utils.HashedPassword(password.ToString(), item.salt.ToString());
-                    if (hashedPw.Equals(item.pwd))
+                    foreach (var item in bizUsers)
                     {
-                        businessUsers = item;
-                        //string id_token = JwtAuth.CreateAuthTokenBI(_option.HostName, bizUser.RowKey?.ToString(), bizUser.name?.ToString(), bizUser.picture?.ToString(), _option.JwtSecretKey, scope: "company", webSite: Website, expire: 3);
-                        openid_token = JwtAuthExtension.CreateBizLoginAuthToken(_option.HostName, businessUsers.id?.ToString(), businessUsers.name?.ToString(), businessUsers.picture?.ToString(), $"{_option.Location}-Open", _option.JwtSecretKey, expire: 3);
-
-                        await AzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, "tabledd-update", $"{businessUsers.name}【{businessUsers.id}】登录开放平台", _dingDing, tid: businessUsers.id, tname: businessUsers.name, twebsite: "Open", httpContext: HttpContext);
-                    };
+                        var hashedPw = Utils.HashedPassword(password.ToString(), item.salt.ToString());
+                        if (hashedPw.Equals(item.pwd))
+                        {
+                            //businessUsers = item;
+                            businessUsers = new()
+                            {
+                                id = item.id,
+                                code = item.code,
+                                name = item.name,
+                                picture = item.picture,
+                                mobile = item.mobile,
+                                mail = item.mail,
+                                relation = item.relation,
+                            };
+
+                            //string id_token = JwtAuth.CreateAuthTokenBI(_option.HostName, bizUser.RowKey?.ToString(), bizUser.name?.ToString(), bizUser.picture?.ToString(), _option.JwtSecretKey, scope: "company", webSite: Website, expire: 3);
+                            openid_token = JwtAuthExtension.CreateBizLoginAuthToken(_option.HostName, businessUsers.id?.ToString(), businessUsers.name?.ToString(), businessUsers.picture?.ToString(), $"{_option.Location}-Open", _option.JwtSecretKey, expire: 3);
+
+                            await AzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, "tabledd-update", $"{businessUsers.name}【{businessUsers.id}】登录开放平台", _dingDing, tid: businessUsers.id, tname: businessUsers.name, twebsite: "Open", httpContext: HttpContext);
+                        };
+                    }
+                }
+                else return Ok(new { state = RespondCode.NotFound, msg = "未找到该用户!" });
+                if (businessUsers.id != null)
+                {
+                    var auth_token = JwtAuthExtension.CreateAuthToken(_option.HostName, businessUsers.id, businessUsers.name, businessUsers.picture, _option.JwtSecretKey, scope: "business", Website: "IES", roles: new[] { "business" }, expire: 1);
+                    var clientID = _configuration.GetValue<string>("HaBookAuth:CoreService:clientID");
+                    var clientSecret = _configuration.GetValue<string>("HaBookAuth:CoreService:clientSecret");
+                    var token = await CoreTokenExtensions.CreateAccessToken(clientID, clientSecret, _option.Location.Replace("-Dep", "").Replace("-Test", ""));
+                    return Ok(new { state = RespondCode.Ok, openid_token, auth_token, token = new { access_token = token.AccessToken, expires_in = token.ExpiresOn, id_token = auth_token, token_type = token.TokenType }, businessUsers });
+                    //return Ok(new { state = RespondCode.Ok, openid_token, auth_token, token, businessUsers });
                 }
+                else
+                { return Ok(new { state = RespondCode.ForbiddenPwd, msg = "密码错误" }); }
+
             }
-            else return Ok(new { state = RespondCode.NotFound, msg = "未找到该用户!" });
-            if (businessUsers.id != null)
+            catch (Exception ex)
             {
-                var auth_token = JwtAuthExtension.CreateAuthToken(_option.HostName, businessUsers.id, businessUsers. name, businessUsers. picture, _option.JwtSecretKey, scope: Constant.ScopeStudent, Website: "IES",    roles: new[] { "business" }, expire: 1);
-                var clientID = _configuration.GetValue<string>("HaBookAuth:CoreService:clientID");
-                var clientSecret = _configuration.GetValue<string>("HaBookAuth:CoreService:clientSecret");
-                var token = await CoreTokenExtensions.CreateAccessToken(clientID, clientSecret, _option.Location.Replace("-Dep", "").Replace("-Test", ""));
-                return Ok(new { state = RespondCode.Ok, openid_token, auth_token, token, businessUsers=new { businessUsers .name, businessUsers .id, businessUsers .picture, businessUsers .mobile, businessUsers .mail, businessUsers .relation} });
+                return Ok(new { state = RespondCode.ForbiddenPwd, msg = $"服务器错误{ex.Message}\n{ex.StackTrace}" });
             }
-            else
-            { return Ok(new { state = RespondCode.ForbiddenPwd, msg = "密码错误" }); }
         }
 
         /// <summary>
@@ -180,6 +200,8 @@ namespace TEAMModelOS.Controllers
         /// <returns></returns>
         [ProducesDefaultResponseType]
         [HttpPost("get-info")]
+        [Authorize(Roles = "IES")]
+        [AuthToken(Roles = "business")]
         public async Task<IActionResult> GetInfo(JsonElement jsonElenent)
         {
             try
@@ -208,7 +230,7 @@ namespace TEAMModelOS.Controllers
             }
             catch (Exception e)
             {
-                await _dingDing.SendBotMsg($"OS,{_option.Location} , /biz/get-info   \n {e.Message}\n{e.StackTrace} \n ", GroupNames.成都开发測試群組);
+                await _dingDing.SendBotMsg($"openApi,{_option.Location} , /biz/GetInfo()   \n {e.Message}\n{e.StackTrace} \n ", GroupNames.成都开发測試群組);
                 return BadRequest();
             }
         }
@@ -220,6 +242,8 @@ namespace TEAMModelOS.Controllers
         /// <returns></returns>
         [ProducesDefaultResponseType]
         [HttpPost("reset-secretkey")]
+        [Authorize(Roles = "IES")]
+        [AuthToken(Roles = "business")]
         public async Task<IActionResult> ResetSecretKey(JsonElement jsonElement)
         {
             try
@@ -236,7 +260,7 @@ namespace TEAMModelOS.Controllers
                 {
                     using var json = await JsonDocument.ParseAsync(response.ContentStream);
                     bizConfig = json.ToObject<BizConfig>();
-                    var auth_token = JwtAuthExtension.CreateBusinessApiToken(_option.Location, bizConfig.id, _option.JwtSecretKey );
+                    var auth_token = JwtAuthExtension.CreateBusinessApiToken(_option.Location, bizConfig.id, _option.JwtSecretKey, bizConfig.isCustomize);
                     bizConfig.jti = auth_token.jti;
                     bizConfig.token = auth_token.jwt;
 
@@ -247,7 +271,7 @@ namespace TEAMModelOS.Controllers
             }
             catch (Exception e)
             {
-                await _dingDing.SendBotMsg($"OS,{_option.Location} , /biz/reset-secretkey   \n {e.Message}\n{e.StackTrace} \n ", GroupNames.成都开发測試群組);
+                await _dingDing.SendBotMsg($"openApi,{_option.Location} , /biz/ResetSecretKey()   \n {e.Message}\n{e.StackTrace} \n ", GroupNames.成都开发測試群組);
                 return BadRequest();
             }
         }
@@ -260,6 +284,8 @@ namespace TEAMModelOS.Controllers
         /// <returns></returns>
         [ProducesDefaultResponseType]
         [HttpPost("get-bizid")]
+        [Authorize(Roles = "IES")]
+        [AuthToken(Roles = "business")]
         public async Task<IActionResult> GetBizIdUsers(JsonElement jsonElement)
         {
             try
@@ -268,7 +294,7 @@ namespace TEAMModelOS.Controllers
                 var cosmosClient = _azureCosmos.GetCosmosClient();
 
                 List<BusinessUsers> businessUsers = new();
-                string sql = $"select value(c) from c join s in c.relation  where c.code='BizUsers' and s.bizId = '80e1bb6c-acba-46ab-9939-4851c4ef2158'";
+                string sql = $"select value(c) from c join s in c.relation  where c.code='BizUsers' and s.bizId = '{id}'";
                 await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<BusinessUsers>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
                 {
                     businessUsers.Add(item);
@@ -278,7 +304,7 @@ namespace TEAMModelOS.Controllers
             }
             catch (Exception e)
             {
-                await _dingDing.SendBotMsg($"OS,{_option.Location} , /biz/get-bizid   \n {e.Message}\n{e.StackTrace} \n ", GroupNames.成都开发測試群組);
+                await _dingDing.SendBotMsg($"openApi,{_option.Location} , /biz/GetBizIdUsers()   \n {e.Message}\n{e.StackTrace} \n ", GroupNames.成都开发測試群組);
                 return BadRequest();
             }
         }
@@ -290,6 +316,8 @@ namespace TEAMModelOS.Controllers
         /// <returns></returns>
         [ProducesDefaultResponseType]
         [HttpPost("get-openapi")]
+        [Authorize(Roles = "IES")]
+        [AuthToken(Roles = "business")]
         public async Task<IActionResult> GetOpenApi(JsonElement jsonElement)
         {
             var table = _azureStorage.GetCloudTableClient().GetTableReference("IESOpenApi");
@@ -304,83 +332,93 @@ namespace TEAMModelOS.Controllers
         /// <returns></returns>
         [ProducesDefaultResponseType]
         [HttpPost("set-info")]
+        [Authorize(Roles = "IES")]
+        [AuthToken(Roles = "business")]
         public async Task<IActionResult> SetInfo(BizConfig bizConfig)
         {
-            StringBuilder strMsg = new();
-            var cosmosClient = _azureCosmos.GetCosmosClient();
-            var tableClient = _azureStorage.GetCloudTableClient();
-            var blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public");
-            string salt = Utils.CreatSaltString(8);
-            List<BizUsers> bizUsers = new();
-            string type = "";
-
-            //新增企业信息
-            if (string.IsNullOrEmpty(bizConfig.id))
+            try
             {
-                bizConfig.id = Guid.NewGuid().ToString();
-                bizConfig.code = "BizConfig";
-                bizConfig.pk = "BizConfig";
-                bizConfig.createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
-                var auth_token = JwtAuthExtension.CreateBusinessApiToken(_option.Location, bizConfig.id, _option.JwtSecretKey);
-                bizConfig.jti = auth_token.jti;
-                bizConfig.token = auth_token.jwt;
-
-                await cosmosClient.GetContainer("TEAMModelOS", "Normal").CreateItemAsync<BizConfig>(bizConfig, new PartitionKey("BizConfig"));
+                StringBuilder strMsg = new();
+                var cosmosClient = _azureCosmos.GetCosmosClient();
+                var tableClient = _azureStorage.GetCloudTableClient();
+                var blobClient = _azureStorage.GetBlobContainerClient(containerName: "0-public");
+                string salt = Utils.CreatSaltString(8);
+                List<BizUsers> bizUsers = new();
+                string type = "";
 
-                await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<BizUsers>(queryText: $"select value(c) from c where c.mobile ={bizConfig.mobile}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
+                //新增企业信息
+                if (string.IsNullOrEmpty(bizConfig.id))
                 {
-                    bizUsers.Add(item);
-                }
+                    bizConfig.id = Guid.NewGuid().ToString();
+                    bizConfig.code = "BizConfig";
+                    bizConfig.pk = "BizConfig";
+                    bizConfig.createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
+                    var auth_token = JwtAuthExtension.CreateBusinessApiToken(_option.Location, bizConfig.id, _option.JwtSecretKey, bizConfig.isCustomize);
+                    bizConfig.jti = auth_token.jti;
+                    bizConfig.token = auth_token.jwt;
 
-                BizRel bizRel = new() { bizId = bizConfig.id, role = new List<string>() { "admin" } };
-                if (bizUsers.Count > 0)
-                {
-                    foreach (var item in bizUsers)
+                    await cosmosClient.GetContainer("TEAMModelOS", "Normal").CreateItemAsync<BizConfig>(bizConfig, new PartitionKey("BizConfig"));
+
+                    await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "Normal").GetItemQueryIterator<BizUsers>(queryText: $"select value(c) from c where c.mobile ={bizConfig.mobile}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("BizUsers") }))
                     {
-                        BizRel temp = item.relation.Find(f => f.bizId.Equals(bizConfig.id));
-                        if (temp == null)
+                        bizUsers.Add(item);
+                    }
+
+                    BizRel bizRel = new() { bizId = bizConfig.id, role = new List<string>() { "admin" } };
+                    if (bizUsers.Count > 0)
+                    {
+                        foreach (var item in bizUsers)
                         {
-                            item.relation.Add(bizRel);
-                            await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReplaceItemAsync<BizUsers>(item, item.id, new PartitionKey("BizUsers"));
+                            BizRel temp = item.relation.Find(f => f.bizId.Equals(bizConfig.id));
+                            if (temp == null)
+                            {
+                                item.relation.Add(bizRel);
+                                await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReplaceItemAsync<BizUsers>(item, item.id, new PartitionKey("BizUsers"));
+                            }
                         }
                     }
+                    else
+                    {
+                        BizUsers tBizUsers = new() { id = Guid.NewGuid().ToString(), code = "BizUsers", name = bizConfig.mobile.ToString(), mobile = bizConfig.mobile, salt = salt, pwd = Utils.HashedPassword($"{bizConfig.mobile}", salt), relation = new List<BizRel>() { { bizRel } } };
+
+                        await cosmosClient.GetContainer("TEAMModelOS", "Normal").CreateItemAsync<BizUsers>(tBizUsers, new PartitionKey("BizUsers"));
+                    }
+
+                    strMsg.Append($"{bizConfig.name}【{bizConfig.id}】新增企业基础信息。");
+                    type = "bizconfig-add";
                 }
+                //修改企业信息
                 else
                 {
-                    BizUsers tBizUsers = new() { id = Guid.NewGuid().ToString(), code = "BizUsers", name = bizConfig.mobile.ToString(), mobile = bizConfig.mobile, salt = salt, pwd = Utils.HashedPassword($"{bizConfig.mobile}", salt), relation = new List<BizRel>() { { bizRel } } };
+                    var response = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReadItemStreamAsync(bizConfig.id, new PartitionKey("BizConfig"));
+                    if (response.Status == 200)
+                    {
+                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                        BizConfig tempBizConfig = json.ToObject<BizConfig>();
 
-                    await cosmosClient.GetContainer("TEAMModelOS", "Normal").CreateItemAsync<BizUsers>(tBizUsers, new PartitionKey("BizUsers"));
+                        bizConfig.pk = "BizConfig";
+                        bizConfig.code = "BizConfig";
+                        bizConfig.ttl = -1;
+
+                        bizConfig.createTime = tempBizConfig.createTime;
+                        bizConfig.jti = tempBizConfig.jti;
+                        bizConfig.token = tempBizConfig.token;
+
+                        bizConfig = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReplaceItemAsync<BizConfig>(bizConfig, bizConfig.id, new PartitionKey("BizConfig"));
+                        strMsg.Append($"{bizConfig.name}【{bizConfig.id}】修改企业基础信息。");
+                        type = "bizconfig-update";
+                    }
                 }
 
-                strMsg.Append($"{bizConfig.name}【{bizConfig.id}】新增企业基础信息。");
-                type = "bizconfig-add";
+                //保存操作记录
+                await AzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, type, strMsg.ToString(), _dingDing, httpContext: HttpContext);
+                return Ok(new { state = RespondCode.Ok, bizConfig });
             }
-            //修改企业信息
-            else
+            catch (Exception e)
             {
-                var response = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReadItemStreamAsync(bizConfig.id, new PartitionKey("BizConfig"));
-                if (response.Status == 200)
-                {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
-                    BizConfig tempBizConfig = json.ToObject<BizConfig>();
-
-                    bizConfig.pk = "BizConfig";
-                    bizConfig.code = "BizConfig";
-                    bizConfig.ttl = -1;
-
-                    bizConfig.createTime = tempBizConfig.createTime;
-                    bizConfig.jti = tempBizConfig.jti;
-                    bizConfig.token = tempBizConfig.token;
-
-                    bizConfig = await cosmosClient.GetContainer("TEAMModelOS", "Normal").ReplaceItemAsync<BizConfig>(bizConfig, bizConfig.id, new PartitionKey("BizConfig"));
-                    strMsg.Append($"{bizConfig.name}【{bizConfig.id}】修改企业基础信息。");
-                    type = "bizconfig-update";
-                }
+                await _dingDing.SendBotMsg($"openApi,{_option.Location} , /biz/SetInfo()   \n {e.Message}\n{e.StackTrace} \n ", GroupNames.成都开发測試群組);
+                return BadRequest();
             }
-
-            //保存操作记录
-            await AzureStorageBlobExtensions.SaveBILog(blobClient, tableClient, type, strMsg.ToString(), _dingDing, httpContext: HttpContext);
-            return Ok(new { state = RespondCode.Ok, bizConfig });
         }
 
 

+ 1 - 1
TEAMModelOS/Controllers/OpenApi/Init/OpenApiConfigController.cs

@@ -56,7 +56,7 @@ namespace TEAMModelOS.Controllers
                
                 BizConfig bizConfig = await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Normal").ReadItemAsync<BizConfig>($"{_id}", new PartitionKey("BizConfig"));
                 string jwt = "";
-                var auth_token = JwtAuthExtension.CreateBusinessApiToken(_option.Location, bizConfig.id, _option.JwtSecretKey);
+                var auth_token = JwtAuthExtension.CreateBusinessApiToken(_option.Location, bizConfig.id, _option.JwtSecretKey, bizConfig.isCustomize);
                 jwt = auth_token.jwt;
                 bizConfig.jti = auth_token.jti;
                 bizConfig.token = auth_token.jwt;

+ 3 - 2
TEAMModelOS/Controllers/System/CoreController.cs

@@ -125,7 +125,8 @@ namespace TEAMModelOS.Controllers
                     msg = "参数异常";
                     msg = status.TryGetProperty($"code{code}", out JsonElement text) ? $"{text}" : msg;
                 }
-                var dataByte = Convert.FromBase64String(notifyData.data);
+                var rdata = HttpUtility.UrlDecode(notifyData.data, Encoding.UTF8);
+                var dataByte = Convert.FromBase64String(rdata);
                 string data = Encoding.Unicode.GetString(dataByte);
                 Dictionary<string, object> dict = data.ToObject<Dictionary<string, object>>();
                 dict.TryGetValue("schoolId", out object _schoolId);
@@ -136,7 +137,7 @@ namespace TEAMModelOS.Controllers
                                         .ReadItemStreamAsync($"{_tmdid}", new Azure.Cosmos.PartitionKey("Base"));
                     if (teacherResponse.Status == 200) {
                         var teacher = JsonDocument.Parse(teacherResponse.Content).RootElement.Deserialize<Teacher>();
-                        if (string.IsNullOrWhiteSpace(teacher.lang) || (!teacher.lang.Equals("zh-cn") && !teacher.lang.Equals("zh-tw") && !teacher.lang.Equals("en-us"))) { 
+                        if (!string.IsNullOrWhiteSpace(teacher.lang) &&(teacher.lang.Equals("zh-cn")||teacher.lang.Equals("zh-tw") || teacher.lang.Equals("en-us"))) { 
                             lang= teacher.lang;
                             path = Path.Combine("", $"Lang/{lang}.json");
                             jsonAuth = System.IO.File.ReadAllText(path, Encoding.UTF8);