CrazyIter_Bin 3 years ago
parent
commit
d7e7fca692

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

@@ -8,6 +8,7 @@ using System.Collections.Generic;
 using System.IO;
 using System.Linq;
 using System.Net;
+using System.Reflection;
 using System.Text;
 using System.Text.Json;
 using System.Threading.Tasks;
@@ -30,6 +31,39 @@ namespace TEAMModelOS.FunctionV4.HttpTrigger
             _dingDing = dingDing;
             _azureStorage = azureStorage;
             _azureRedis = azureRedis;
+        }
+        /// <summary>
+        /// 数据推送接口
+        /// </summary>
+        /// <param name="req"></param>
+        /// <param name="log"></param>
+        /// <returns></returns>
+        [Function("system-info-function")]
+        public async Task<HttpResponseData> SystemInfo([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequestData req) {
+            var response = req.CreateResponse(HttpStatusCode.OK);
+            Type attr = this.GetType();
+            string currentDirectory = Path.GetDirectoryName(attr.Assembly.Location);
+            Assembly assembly = Assembly.LoadFrom($"{currentDirectory}\\TEAMModelOS.FunctionV4.dll");
+            var description = assembly.GetCustomAttribute<AssemblyDescriptionAttribute>().Description;
+            //var v1 = Assembly.GetEntryAssembly().GetName().Version;
+            //var v2 = Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyFileVersionAttribute>().Version;
+            // var description = Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyDescriptionAttribute>().Description;
+            var version = Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyFileVersionAttribute>().Version;
+            long nowtime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
+            //Console.WriteLine($"Assembly.GetEntryAssembly().GetName().Version: " +
+
+            //                  $"{Assembly.GetEntryAssembly().GetName().Version}");5.2107.12.1
+
+            //Console.WriteLine($"Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyFileVersionAttribute>().Version:" +
+            //                  $"{Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyFileVersionAttribute>().Version}");5.2107.12.1
+
+            //Console.WriteLine($"Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion:" +
+
+            //                  $"{Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion}");5.2107.12
+            await response.WriteAsJsonAsync(new { version, description, nowtime });
+            return response;
+
+           
         }
         /// <summary>
         /// 数据推送接口

+ 9 - 0
TEAMModelOS.FunctionV4/TEAMModelOS.FunctionV4.csproj

@@ -5,6 +5,15 @@
 		<OutputType>Exe</OutputType>
 		<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
 		<SignAssembly>true</SignAssembly>
+		<AssemblyVersion>5.2203.11.1</AssemblyVersion>
+		<FileVersion>5.2203.11.1</FileVersion>
+		<Version>5.2203.11</Version>
+		<PackageId>TEAMModelOS.FunctionV4</PackageId>
+		<Authors>teammodel</Authors>
+		<Company>醍摩豆(成都)信息技术有限公司</Company>
+		<Product>IES5</Product>
+		<Description>事件触发中心</Description>
+		<PackageProjectUrl>https://www.teammodel.cn/</PackageProjectUrl>
 	</PropertyGroup>
 	<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
 		<DefineConstants>DEBUG;TRACE</DefineConstants>

+ 34 - 4
TEAMModelOS.SDK/Models/Service/GroupListService.cs

@@ -44,6 +44,13 @@ namespace TEAMModelOS.SDK
         }
         public static (int status, GroupList stuList) JoinList(GroupList stuList, string userid,   int type,  string school)
         {
+            int status = -1;
+            if (!string.IsNullOrWhiteSpace(stuList.school) && !string.IsNullOrWhiteSpace(school)) {
+                if (!stuList.school.Equals(school)) {
+                    status = 3;//不允许跨校加入名单
+                    return (status, stuList);
+                }
+            }
             string irs=string.Empty;
             List<string> irsOrder= stuList.members.Select(x => x.irs)?.Where(y => !string.IsNullOrEmpty(y)&& Regex.IsMatch(y, @"^\d*$")).OrderBy(x => int.Parse(x)).ToList();
             if (!irsOrder.Contains("0"))
@@ -70,7 +77,7 @@ namespace TEAMModelOS.SDK
                     }
                 }
             }
-            int status = -1;
+            
             if (string.IsNullOrEmpty($"{userid}"))
             {
                 //加入学生或醍摩豆ID为空
@@ -88,6 +95,7 @@ namespace TEAMModelOS.SDK
                     }
                     else
                     {
+                        //加入成功
                         status = 0;
                         stuList.members.Add(new Member { id = userid,type = type, irs = irs, no = irs });
                     }
@@ -120,8 +128,29 @@ namespace TEAMModelOS.SDK
                 isnew = true;
             }
             string tbname = list.scope.Equals("private") ? "Teacher" : "School";
-            list.tcount = list.members.Where(x => x.type == 1).Count();
-            list.scount = list.members.Where(x => x.type == 2).Count();
+            var tmembers = list.members.Where(x => x.type == 1);
+            var smembers= list.members.Where(x => x.type == 2);
+            list.scount = smembers.Count();
+            list.tcount = tmembers.Count();
+            //if (smembers.Count() > 0 && smembers.Select(x => x.code).ToHashSet().Count()>=2) {
+            //    //处理移除多个学校的名单,只保留一个学校的。
+            //    if (string.IsNullOrWhiteSpace(list.school))
+            //    {
+            //        HashSet<string> codes = smembers.Select(x => x.code).ToHashSet();
+            //        list.school = codes.First();
+            //        codes.Remove(codes.First());
+            //        list.members.RemoveAll(x => codes.Contains(x.code));
+            //    }
+            //    else {
+            //        list.members.RemoveAll(x => x.code.Equals(list.school));
+            //    }
+            //}
+            if (string.IsNullOrWhiteSpace(list.school) && smembers.Count() >= 1) {
+                list.school = smembers.First().code;
+            }
+            if (!string.IsNullOrWhiteSpace(list.school) && smembers.Count() == 0 && list.scope.Equals("private")) {
+                list.school = null;
+            }
             //学生名单,教研组会触发活动中间表刷新
             if (list.type.Equals("teach") || list.type.Equals("research") || list.type.Equals("yxtrain")|| list.type.Equals("activity"))
             {
@@ -380,7 +409,8 @@ namespace TEAMModelOS.SDK
                     sql = string.Join(",", classes.Select(x => $"'{x}'"));
                     await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<GroupListDto>(queryText: $"select {SummarySql} from c where c.id in ({sql})",
                            requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"GroupList") }))
-                    {
+                    { 
+                       // if(item.school.Equals(""))
                         privateList.Add(item);
                     }
                     if (privateList.IsNotEmpty())

+ 44 - 0
TEAMModelOS/Controllers/XTest/FixDataController.cs

@@ -1410,7 +1410,51 @@ namespace TEAMModelOS.Controllers
             return Ok(new { teachers, schoolsTeachers });
         }
 
+        /// <summary>
+        /// 修复评测publish字段内容
+        /// </summary>
+        /// <param name="req"></param>
+        /// <param name="log"></param>
+        /// <returns></returns>
+        [ProducesDefaultResponseType]
+        //[AuthToken(Roles = "teacher")]
+        [HttpGet("fix-group-list")]
+        public async Task<IActionResult> FixGroupList() {
+            List<GroupList> groupLists = new List<GroupList>();
+            await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetItemQueryIterator<GroupList>
+                (queryText: "select value(c) from c ", requestOptions: new QueryRequestOptions {PartitionKey= new PartitionKey("GroupList") })) {
+                groupLists.Add(item);
+            }
+            List<GroupList> groupLists_up = new List<GroupList>();
 
+            groupLists.ForEach(async list => {
+
+                var smembers = list.members.Where(x => x.type == 2);
+                list.scount = smembers.Count();
+                if (smembers.Count() > 0 && smembers.Select(x => x.code).ToHashSet().Count() >= 2)
+                {
+                    //处理移除多个学校的名单,只保留一个学校的。
+                    if (string.IsNullOrWhiteSpace(list.school))
+                    {
+                        HashSet<string> codes = smembers.Select(x => x.code).ToHashSet();
+                        list.school = codes.First();
+                        codes.Remove(codes.First());
+                        list.members.RemoveAll(x => codes.Contains(x.code));
+                    }
+                    else
+                    {
+                        list.members.RemoveAll(x => x.code.Equals(list.school));
+                    }
+                    groupLists_up.Add(list);
+                }
+                
+            });
+            foreach (var item in groupLists_up)
+            {
+                await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Teacher).ReplaceItemAsync(item, item.id, new PartitionKey(item.code));
+            }
+            return Ok();
+        }
 
 
         /// <summary>

+ 7 - 1
TEAMModelOS/TEAMModelOS.csproj

@@ -34,8 +34,14 @@
     <Version>5.2203.11</Version>
     <AssemblyVersion>5.2203.11.2</AssemblyVersion>
     <FileVersion>5.2203.11.2</FileVersion>
-    <Description>TEAMModelOS(IES5)版本更新。</Description>
+    <Description>TEAMModelOS(IES5)</Description>
     <PackageReleaseNotes>6.0版本说明</PackageReleaseNotes>
+    <PackageId>TEAMModelOS</PackageId>
+    <Authors>teammodel</Authors>
+    <Company>醍摩豆(成都)信息技术有限公司</Company>
+    <Product>TEAMModelOS</Product>
+    <Copyright>© 2021 HABOOK Group 醍摩豆</Copyright>
+    <PackageProjectUrl>https://www.teammodel.cn</PackageProjectUrl>
   </PropertyGroup>
 
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">