CrazyIter_Bin 3 年之前
父节点
当前提交
0ebb39f898

+ 7 - 2
TEAMModelFunction/MonitorServicesBus.cs

@@ -565,7 +565,9 @@ namespace TEAMModelFunction
                         };
                         };
                         items.ForEach(z =>
                         items.ForEach(z =>
                         {
                         {
-                            ItemService.CountItemCond(z, null, itemCond);
+                            if (!string.IsNullOrEmpty(z.type)) {
+                                ItemService.CountItemCond(z, null, itemCond);
+                            }
                         });
                         });
                         await _azureRedis.GetRedisClient(8).HashSetAsync($"ItemCond:{itemCondDto.key}", $"{itemCondDto.filed}", itemCond.ToJsonString());
                         await _azureRedis.GetRedisClient(8).HashSetAsync($"ItemCond:{itemCondDto.key}", $"{itemCondDto.filed}", itemCond.ToJsonString());
                     }
                     }
@@ -581,7 +583,10 @@ namespace TEAMModelFunction
                         itemCond = new ItemCond() { id = $"{itemCondDto.filed}", code = $"ItemCond", pk = "ItemCond", ttl = -1, count = items.Count };
                         itemCond = new ItemCond() { id = $"{itemCondDto.filed}", code = $"ItemCond", pk = "ItemCond", ttl = -1, count = items.Count };
                         items.ForEach(z =>
                         items.ForEach(z =>
                         {
                         {
-                            ItemService.CountItemCond(z, null, itemCond);
+                            if (!string.IsNullOrEmpty(z.type))
+                            {
+                                ItemService.CountItemCond(z, null, itemCond);
+                            }
                         });
                         });
                         await _azureRedis.GetRedisClient(8).HashSetAsync($"ItemCond:ItemCond", $"{itemCondDto.filed}", itemCond.ToJsonString());
                         await _azureRedis.GetRedisClient(8).HashSetAsync($"ItemCond:ItemCond", $"{itemCondDto.filed}", itemCond.ToJsonString());
                     }
                     }

+ 3 - 1
TEAMModelOS.SDK/Models/Cosmos/Common/Inner/BaseItem.cs

@@ -3,7 +3,7 @@ using System.Collections.Generic;
 using System.ComponentModel.DataAnnotations;
 using System.ComponentModel.DataAnnotations;
 using System.Text;
 using System.Text;
 
 
-namespace TEAMModelOS.SDK.Models.Cosmos.Common.Inner
+namespace TEAMModelOS.SDK.Models
 {
 {
     public class BaseItem  : CosmosEntity
     public class BaseItem  : CosmosEntity
     {
     {
@@ -19,6 +19,8 @@ namespace TEAMModelOS.SDK.Models.Cosmos.Common.Inner
         /// <summary>
         /// <summary>
         /// 题型  Single单选,Multiple多选,Judge判断,Complete填空,Subjective问答,Compose综合
         /// 题型  Single单选,Multiple多选,Judge判断,Complete填空,Subjective问答,Compose综合
         /// </summary>
         /// </summary>
+         // 题型
+        [Required(ErrorMessage = " 题型{0} 必须填写")]
         public string type { get; set; }
         public string type { get; set; }
         /// <summary>
         /// <summary>
         /// 上级shaCode
         /// 上级shaCode

+ 1 - 1
TEAMModelOS.SDK/Models/Cosmos/Common/Inner/Exercise.cs

@@ -2,7 +2,7 @@ using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Text;
 using System.Text;
 
 
-namespace TEAMModelOS.SDK.Models.Cosmos.Common.Inner
+namespace TEAMModelOS.SDK.Models 
 {
 {
     /// <summary>
     /// <summary>
     /// 用于HTEX json的数据结构
     /// 用于HTEX json的数据结构

+ 1 - 1
TEAMModelOS.SDK/Models/Cosmos/Common/Inner/Repair.cs

@@ -2,7 +2,7 @@ using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Text;
 using System.Text;
 
 
-namespace TEAMModelOS.SDK.Models.Cosmos.Common.Inner
+namespace TEAMModelOS.SDK.Models
 {
 {
     /// <summary>
     /// <summary>
     /// 补救资源
     /// 补救资源

+ 0 - 1
TEAMModelOS.SDK/Models/Cosmos/Common/ItemInfo.cs

@@ -1,6 +1,5 @@
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.ComponentModel.DataAnnotations;
 using System.ComponentModel.DataAnnotations;
-using TEAMModelOS.SDK.Models.Cosmos.Common.Inner;
 
 
 namespace TEAMModelOS.SDK.Models
 namespace TEAMModelOS.SDK.Models
 {
 {

+ 3 - 3
TEAMModelOS.SDK/Models/Cosmos/Common/SheetConfig.cs

@@ -46,9 +46,9 @@ namespace TEAMModelOS.SDK.Models
         /// <summary>
         /// <summary>
         /// 标记是读取填涂黑块还是读取二维码
         /// 标记是读取填涂黑块还是读取二维码
         /// </summary>
         /// </summary>
-        public string infoMode { get; set; }
-        public List<JsonElement> infoPos{ get; set; } = new List<JsonElement>();
-        public List<JsonElement> objectivePos { get; set; } = new List<JsonElement>();
+        //public string infoMode { get; set; }
+        //public List<JsonElement> infoPos{ get; set; } = new List<JsonElement>();
+        //public List<JsonElement> objectivePos { get; set; } = new List<JsonElement>();
         /// <summary>
         /// <summary>
         /// 答题卡是A3 A4纸张
         /// 答题卡是A3 A4纸张
         /// </summary>
         /// </summary>

+ 2 - 0
TEAMModelOS.SDK/Models/Service/ItemService.cs

@@ -18,6 +18,7 @@ namespace TEAMModelOS.Services.Common
         /// <param name="cond"></param>
         /// <param name="cond"></param>
         public static void CountItemCond(ItemInfo newItem, ItemInfo odlItem, ItemCond cond)
         public static void CountItemCond(ItemInfo newItem, ItemInfo odlItem, ItemCond cond)
         {
         {
+            
             if (newItem != null ? newItem.scope.Equals("school") : false || odlItem != null ? odlItem.scope.Equals("school") : false)
             if (newItem != null ? newItem.scope.Equals("school") : false || odlItem != null ? odlItem.scope.Equals("school") : false)
             {
             {
                 //检查两个对象是否是同一条记录
                 //检查两个对象是否是同一条记录
@@ -138,6 +139,7 @@ namespace TEAMModelOS.Services.Common
             }
             }
             var list = cond.subjects.FindAll(x => x.id == key).ToList();
             var list = cond.subjects.FindAll(x => x.id == key).ToList();
             foreach (var y in list) {
             foreach (var y in list) {
+               
                 if (!y.types.ContainsKey(type))
                 if (!y.types.ContainsKey(type))
                 {
                 {
                     var dict = new Dictionary<string, Dictionary<string, int>>
                     var dict = new Dictionary<string, Dictionary<string, int>>

+ 11 - 3
TEAMModelOS/Controllers/Item/ItemController.cs

@@ -91,7 +91,10 @@ namespace TEAMModelOS.Controllers
                         };
                         };
                         items.ForEach(z =>
                         items.ForEach(z =>
                         {
                         {
-                            ItemService.CountItemCond(z, null, itemCond);
+                            if (!string.IsNullOrEmpty(z.type))
+                            {
+                                ItemService.CountItemCond(z, null, itemCond);
+                            }
                         });
                         });
                         await _azureRedis.GetRedisClient(8).HashSetAsync($"ItemCond:{schoolCode}", $"{periodId}", itemCond.ToJsonString());
                         await _azureRedis.GetRedisClient(8).HashSetAsync($"ItemCond:{schoolCode}", $"{periodId}", itemCond.ToJsonString());
                     }
                     }
@@ -132,7 +135,10 @@ namespace TEAMModelOS.Controllers
                             ItemCond cond = new ItemCond() { id = z.key, code = $"ItemCond-{school.id}", pk = "ItemCond", ttl = -1, count = z.list.Count, grades = new List<GradeCount>(), subjects = new List<SubjectCount>() };
                             ItemCond cond = new ItemCond() { id = z.key, code = $"ItemCond-{school.id}", pk = "ItemCond", ttl = -1, count = z.list.Count, grades = new List<GradeCount>(), subjects = new List<SubjectCount>() };
                             z.list.ForEach(y =>
                             z.list.ForEach(y =>
                             {
                             {
-                                ItemService.CountItemCond(y, null, cond);
+                                if (!string.IsNullOrEmpty(y.type))
+                                {
+                                    ItemService.CountItemCond(y, null, cond);
+                                }
                             });
                             });
                             await _azureRedis.GetRedisClient(8).HashSetAsync($"ItemCond:{schoolCode}", $"{z.key}", cond.ToJsonString());
                             await _azureRedis.GetRedisClient(8).HashSetAsync($"ItemCond:{schoolCode}", $"{z.key}", cond.ToJsonString());
                             itemConds.Add(cond);
                             itemConds.Add(cond);
@@ -171,7 +177,9 @@ namespace TEAMModelOS.Controllers
                         itemCond = new ItemCond() { id = $"{tmdid}", code = $"ItemCond", pk = "ItemCond", ttl = -1, count = items.Count };
                         itemCond = new ItemCond() { id = $"{tmdid}", code = $"ItemCond", pk = "ItemCond", ttl = -1, count = items.Count };
                         items.ForEach(z =>
                         items.ForEach(z =>
                         {
                         {
-                            ItemService.CountItemCond(z, null, itemCond);
+                            if (!string.IsNullOrEmpty(z.type)) {
+                                ItemService.CountItemCond(z, null, itemCond);
+                            }
                         });
                         });
                         await _azureRedis.GetRedisClient(8).HashSetAsync($"ItemCond:ItemCond", $"{tmdid}", itemCond.ToJsonString());
                         await _azureRedis.GetRedisClient(8).HashSetAsync($"ItemCond:ItemCond", $"{tmdid}", itemCond.ToJsonString());
                     }
                     }

+ 5 - 3
TEAMModelOS/Controllers/Third/ScController.cs

@@ -546,17 +546,19 @@ namespace TEAMModelOS.Controllers.Third
                 if (status == 200)
                 if (status == 200)
                 {
                 {
                     ScTeacher scTeacher = json.ToObject<ScTeacher>(new JsonSerializerOptions { PropertyNameCaseInsensitive = false });
                     ScTeacher scTeacher = json.ToObject<ScTeacher>(new JsonSerializerOptions { PropertyNameCaseInsensitive = false });
-                    await _dingDing.SendBotMsg($"OS,{_option.Location}\n省平台教师信息:\n{scTeacher.ToJsonString()}",GroupNames.成都开发測試群組);
                     if (scTeacher != null && $"{scTeacher.PXID}".Equals(scsso.Pxid) && $"{scTeacher.TID}".Equals(scsso.tid))
                     if (scTeacher != null && $"{scTeacher.PXID}".Equals(scsso.Pxid) && $"{scTeacher.TID}".Equals(scsso.tid))
                     {
                     {
                         SchoolName = scTeacher.SchoolName;
                         SchoolName = scTeacher.SchoolName;
                         SchoolID = $"{scTeacher.SchoolID}";
                         SchoolID = $"{scTeacher.SchoolID}";
-                        ProjectID =$"{ scTeacher.ProjectID}";
-                        ProjectItemID =$"{ scTeacher.ProjectItemID}";
+                        ProjectID = $"{ scTeacher.ProjectID}";
+                        ProjectItemID = $"{ scTeacher.ProjectItemID}";
                         TeacherName = $"{ scTeacher.TeacherName}";
                         TeacherName = $"{ scTeacher.TeacherName}";
                         Account = $"{ scTeacher.Account}";
                         Account = $"{ scTeacher.Account}";
                     }
                     }
                 }
                 }
+                else {
+                    await _dingDing.SendBotMsg($"OS,{_option.Location}\n省平台教师信息:\nstatus:{status}{json}", GroupNames.成都开发測試群組);
+                }
                 ScBindData bindData = new ScBindData
                 ScBindData bindData = new ScBindData
                 {
                 {
                     sn = SchoolName,
                     sn = SchoolName,

+ 12 - 1
TEAMModelOS/Controllers/XTest/FixDataController.cs

@@ -117,6 +117,7 @@ namespace TEAMModelOS.Controllers
                         
                         
                     }
                     }
                 }
                 }
+                HashSet<Teacher> changeTeacher = new HashSet<Teacher>();
                 List<Teacher> addTeachers = new List<Teacher>();
                 List<Teacher> addTeachers = new List<Teacher>();
                 if (nobinds != null) {
                 if (nobinds != null) {
                     foreach (var tch in nobinds)
                     foreach (var tch in nobinds)
@@ -203,7 +204,14 @@ namespace TEAMModelOS.Controllers
                     foreach (var joinc in tchs) {
                     foreach (var joinc in tchs) {
                         SchoolTeacher schoolTeacher = null;
                         SchoolTeacher schoolTeacher = null;
                         var join = joins.Find(x => x.tmdid.Equals(joinc.id));
                         var join = joins.Find(x => x.tmdid.Equals(joinc.id));
-                       List<string> roles = new List<string> { "teacher" };
+                        joinc.schools.ForEach(x => {
+                            if (x.schoolId.Equals(sch.id) &&x.status.Equals("request") ) {
+                                x.status = "join";
+                                changeTeacher.Add(joinc);
+                            }
+                        });
+
+                        List<string> roles = new List<string> { "teacher" };
                         if (!string.IsNullOrEmpty(join.role) && join.role.Equals("admin"))
                         if (!string.IsNullOrEmpty(join.role) && join.role.Equals("admin"))
                         {
                         {
                             roles.Add("admin");
                             roles.Add("admin");
@@ -244,6 +252,9 @@ namespace TEAMModelOS.Controllers
                         await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").UpsertItemAsync<SchoolTeacher>(schoolTeacher, new PartitionKey(schoolTeacher.code));
                         await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").UpsertItemAsync<SchoolTeacher>(schoolTeacher, new PartitionKey(schoolTeacher.code));
                     }
                     }
                 }
                 }
+                foreach (var tch in changeTeacher) {
+                    await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(tch,tch.id, new PartitionKey("Base"));
+                }
                 return Ok(new { noexist ,update= updTeachers,add= addTeachers });
                 return Ok(new { noexist ,update= updTeachers,add= addTeachers });
             }
             }
             return Ok(new { status=404 });
             return Ok(new { status=404 });

+ 62 - 3
TEAMModelOS/Controllers/XTest/TestController.cs

@@ -222,10 +222,69 @@ namespace TEAMModelOS.Controllers
         /// <returns></returns>
         /// <returns></returns>
         [ProducesDefaultResponseType]
         [ProducesDefaultResponseType]
         [HttpPost("servicebus")]
         [HttpPost("servicebus")]
-        public async Task<IActionResult> Servicebus(ItemCondDto jsonMsg)
+        public async Task<IActionResult> Servicebus(ItemCondDto jsonMsg1)
         {
         {
-            var messageBlob = new ServiceBusMessage(jsonMsg.ToJsonString());
-            await _serviceBus.GetServiceBusClient().SendMessageAsync("itemcond", messageBlob);
+            string msg = "[{\"key\":\"xnygxx\",\"filed\":\"fc476b99-c871-4469-aaae-de951c44ae11\",\"scope\":\"school\"}]";
+            try
+            {
+               
+                var client = _azureCosmos.GetCosmosClient();
+                
+                List<ItemCondDto> itemCondDtos = msg.ToObject<List<ItemCondDto>>();
+                foreach (var itemCondDto in itemCondDtos)
+                {
+                    if (itemCondDto.scope.Equals("school"))
+                    {
+                        ItemCond itemCond = null;
+                        List<ItemInfo> items = new List<ItemInfo>();
+                        var queryslt = $"SELECT c.gradeIds,c.subjectId,c.periodId,c.type,c.level,c.field ,c.scope FROM c where   c.periodId='{itemCondDto.filed}' and c.pid= null  ";
+                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<ItemInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{itemCondDto.key}") }))
+                        {
+                            items.Add(item);
+                        }
+                        itemCond = new ItemCond()
+                        {
+                            id = $"{itemCondDto.filed}",
+                            code = $"ItemCond-{itemCondDto.key}",
+                            pk = "ItemCond",
+                            ttl = -1,
+                            count = items.Count,
+                            grades = new List<GradeCount>(),
+                            subjects = new List<SubjectCount>()
+                        };
+                        items.ForEach(z =>
+                        {
+                            ItemService.CountItemCond(z, null, itemCond);
+                        });
+                        await _azureRedis.GetRedisClient(8).HashSetAsync($"ItemCond:{itemCondDto.key}", $"{itemCondDto.filed}", itemCond.ToJsonString());
+                    }
+                    else
+                    {
+                        ItemCond itemCond = null;
+                        List<ItemInfo> items = new List<ItemInfo>();
+                        var queryslt = $"SELECT c.gradeIds,c.subjectId,c.periodId,c.type,c.level,c.field ,c.scope FROM c where c.pid= null  ";
+                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<ItemInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{itemCondDto.filed}") }))
+                        {
+                            items.Add(item);
+                        }
+                        itemCond = new ItemCond() { id = $"{itemCondDto.filed}", code = $"ItemCond", pk = "ItemCond", ttl = -1, count = items.Count };
+                        items.ForEach(z =>
+                        {
+                            ItemService.CountItemCond(z, null, itemCond);
+                        });
+                        await _azureRedis.GetRedisClient(8).HashSetAsync($"ItemCond:ItemCond", $"{itemCondDto.filed}", itemCond.ToJsonString());
+                    }
+                }
+
+            }
+            catch (CosmosException ex)
+            {
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-ServiceBus,ItemCond()\n{ex.Message}\n{ex.StackTrace}\n{msg}", GroupNames.醍摩豆服務運維群組);
+            }
+            catch (Exception ex)
+            {
+                await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-ServiceBus,ItemCond()\n{ex.Message}\n{ex.StackTrace}\n{msg}", GroupNames.醍摩豆服務運維群組);
+            }
             return Ok();
             return Ok();
         }
         }
 
 

+ 6 - 6
TEAMModelOS/appsettings.Development.json

@@ -21,16 +21,16 @@
   },
   },
   "Azure": {
   "Azure": {
     "Storage": {
     "Storage": {
-      "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodelstorage;AccountKey=Yq7D4dE6cFuer2d2UZIccTA/i0c3sJ/6ITc8tNOyW+K5f+/lWw9GCos3Mxhj47PyWQgDL8YbVD63B9XcGtrMxQ==;EndpointSuffix=core.chinacloudapi.cn"
-      //"ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodelos;AccountKey=Dl04mfZ9hE9cdPVO1UtqTUQYN/kz/dD/p1nGvSq4tUu/4WhiKcNRVdY9tbe8620nPXo/RaXxs+1F9sVrWRo0bg==;EndpointSuffix=core.chinacloudapi.cn"
+      //"ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodelstorage;AccountKey=Yq7D4dE6cFuer2d2UZIccTA/i0c3sJ/6ITc8tNOyW+K5f+/lWw9GCos3Mxhj47PyWQgDL8YbVD63B9XcGtrMxQ==;EndpointSuffix=core.chinacloudapi.cn"
+      "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=teammodelos;AccountKey=Dl04mfZ9hE9cdPVO1UtqTUQYN/kz/dD/p1nGvSq4tUu/4WhiKcNRVdY9tbe8620nPXo/RaXxs+1F9sVrWRo0bg==;EndpointSuffix=core.chinacloudapi.cn"
     },
     },
     "Cosmos": {
     "Cosmos": {
-      "ConnectionString": "AccountEndpoint=https://cdhabookdep-free.documents.azure.cn:443/;AccountKey=JTUVk92Gjsx17L0xqxn0X4wX2thDPMKiw4daeTyV1HzPb6JmBeHdtFY1MF1jdctW1ofgzqkDMFOtcqS46by31A==;"
-      //"ConnectionString": "AccountEndpoint=https://teammodelos.documents.azure.cn:443/;AccountKey=clF73GwPECfP1lKZTCvs8gLMMyCZig1HODFbhDUsarsAURO7TcOjVz6ZFfPqr1HzYrfjCXpMuVD5TlEG5bFGGg==;"
+      //"ConnectionString": "AccountEndpoint=https://cdhabookdep-free.documents.azure.cn:443/;AccountKey=JTUVk92Gjsx17L0xqxn0X4wX2thDPMKiw4daeTyV1HzPb6JmBeHdtFY1MF1jdctW1ofgzqkDMFOtcqS46by31A==;"
+      "ConnectionString": "AccountEndpoint=https://teammodelos.documents.azure.cn:443/;AccountKey=clF73GwPECfP1lKZTCvs8gLMMyCZig1HODFbhDUsarsAURO7TcOjVz6ZFfPqr1HzYrfjCXpMuVD5TlEG5bFGGg==;"
     },
     },
     "Redis": {
     "Redis": {
-      "ConnectionString": "52.130.252.100:6379,password=habook,ssl=false,abortConnect=False,writeBuffer=10240"
-      //"ConnectionString": "CoreRedisCN.redis.cache.chinacloudapi.cn:6380,password=LyJWP1ORJdv+poXWofAF97lhCEQPg1wXWqvtzXGXQuE=,ssl=True,abortConnect=False"
+      //"ConnectionString": "52.130.252.100:6379,password=habook,ssl=false,abortConnect=False,writeBuffer=10240"
+      "ConnectionString": "CoreRedisCN.redis.cache.chinacloudapi.cn:6380,password=LyJWP1ORJdv+poXWofAF97lhCEQPg1wXWqvtzXGXQuE=,ssl=True,abortConnect=False"
     },
     },
     "ServiceBus": {
     "ServiceBus": {
       "ConnectionString": "Endpoint=sb://teammodelos.servicebus.chinacloudapi.cn/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=Sy4h4EQ8zP+7w/lOLi1X3tGord/7ShFHimHs1vC50Dc=",
       "ConnectionString": "Endpoint=sb://teammodelos.servicebus.chinacloudapi.cn/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=Sy4h4EQ8zP+7w/lOLi1X3tGord/7ShFHimHs1vC50Dc=",