Procházet zdrojové kódy

Merge branch 'develop' of http://52.130.252.100:10000/TEAMMODEL/TEAMModelOS into develop

HiITEdenX před 2 roky
rodič
revize
379eea02ab

+ 1 - 0
TEAMModelBI/Controllers/BITest/TestController.cs

@@ -1709,6 +1709,7 @@ namespace TEAMModelBI.Controllers.BITest
         /// </summary>
         /// <param name="jsonElement"></param>
         /// <returns></returns>
+        [HttpPost("set-sc-edittion")]
         public async Task<IActionResult> SetSchoolEdition(JsonElement jsonElement)
         {
             var cosmosClient = _azureCosmos.GetCosmosClient();

+ 10 - 10
TEAMModelOS.SDK/Context/Attributes/Filter/ApiTokenAttribute.cs

@@ -142,8 +142,8 @@ namespace TEAMModelOS.Filter
                         string iss = jwt.Payload.Iss; //iss 检查jwt是否是测试站,正式站的授权key 
                         string tokenScope = jwt.Claims.FirstOrDefault(claim => claim.Type.Equals("scope"))?.Value;
                         //访问的jwt的tokenScope 是否与访问的接口一致。
-                        if (tokenScope.Equals(scope))
-                        {
+                        //if (tokenScope.Equals(scope))
+                        //{
 
                             var keys = OpenApiJtwIssuer.OpenApiJtw签发者.GetDescriptionText().Split(',');
                             string issuer = "";
@@ -175,8 +175,8 @@ namespace TEAMModelOS.Filter
                             {
                                 issuer = keys[3];
                             }
-                            if (iss.Equals(issuer))
-                            {
+                            //if (iss.Equals(issuer))
+                            //{
                                 //aud  受众
                                 id = jwt.Payload.Sub;//主题,又是应用APP,或者企业id 
                                 jti = jwt.Payload.Jti;//jwt唯一标识
@@ -303,12 +303,12 @@ namespace TEAMModelOS.Filter
                                     {
                                     }
                                 }
-                            }
-                        }
-                        else
-                        {
-                            msg = "token的scope与接口的业务类型不匹配!"; code = 401008;
-                        }
+                        //    }
+                        //}
+                        //else
+                        //{
+                        //    msg = "token的scope与接口的业务类型不匹配!"; code = 401008;
+                        //}
                     }
                     else
                     {

+ 0 - 10
TEAMModelOS.SDK/Models/Dtos/OpenApiDto.cs

@@ -109,16 +109,6 @@ namespace TEAMModelOS.SDK.Models.Dtos
         public string school { get; set; }
     }
 
-    /// <summary>
-    /// 教室课程信息
-    /// </summary>
-    public class OCoreUer
-    {
-        public string id { get; set; }
-        public string name { get; set; }
-        public string picture { get; set; }
-        public string searchKey { get; set; }
-    }
 
     /// <summary>
     /// 教师批量数据结构

+ 8 - 8
TEAMModelOS/ClientApp/public/lang/en-US.js

@@ -2012,7 +2012,7 @@ const LANG_EN_US = {
             name: 'Homework Name',
             namePlace: 'Please enter homework name',
             target: 'Homework Participant',
-            privateClass: 'Personal Class',
+            privateClass: 'Personal Course',
             schoolClass: 'School Class',
             targetPlace: 'Please select the homework participant',
             noFoundText: 'No class created yet',
@@ -4262,7 +4262,7 @@ const LANG_EN_US = {
         sit23: 'Gender',
         sit24: 'Male',
         sit25: 'Female',
-        sit26: "gender: Required. Student's Gender, M for male, F for female",
+        sit26: "gender: Optional. Student's Gender, M for male, F for female",
 
         // Authorization.vue
         authTitle: 'Service Authorization Management',
@@ -5280,7 +5280,7 @@ const LANG_EN_US = {
             name: 'Survey Name',
             namePlace: 'Please enter survey name',
             target: 'Survey Participant',
-            privateClass: 'Personal Class',
+            privateClass: 'Personal Course',
             schoolClass: 'School Class',
             targetPlace: 'Please select the survey participant',
             noFoundText: 'No class created yet',
@@ -5547,7 +5547,7 @@ const LANG_EN_US = {
             stuMgt: 'Student',
             classMgt: 'Classroom',
             studentDash: 'Student Data Dashboard',
-            techDash: 'Campus Big Data Dashboard',
+            techDash: 'Big Data Dashboard',
             log: 'Operation Log',
             elegant: 'Moral Education Overview',
             cusSetting: 'Course Settings',
@@ -6089,7 +6089,7 @@ const LANG_EN_US = {
         gNameWarning: 'Please enter the team name',
         editOk: 'Modified successfully',
         editErr: 'Failed to modify',
-        batchSetSubj: 'Batch Setting Subject',
+        batchSetSubj: 'Batch Subject Setting',
         setSubjTitle: 'Set Subject',
         sltSubjTips: 'Please select a subject',
         subjectFilter: 'Subject Filter',
@@ -6163,7 +6163,7 @@ const LANG_EN_US = {
         importTips5: "3. email: Teacher's email, optional",
         importTips6: "4. tmdid: Teacher's user ID, optional",
         importTips7: '5. note: Note about the teacher, optional',
-        importTips8: "Tip: If the imported teacher's user ID, cell phone, or email has already registered a TEAM Model account, the system will automatically invite the teacher to join the school.",
+        importTips8: "Note: Only if the imported teacher's user ID, cell phone, or email has already registered a TEAM Model account will the system automatically invite the teacher to join the school.",
         importTips9: 'Select or drag files to this area to import',
         impText: 'Invalid Data (No name):',
         impText1: 'No. of imported:',
@@ -6451,7 +6451,7 @@ const LANG_EN_US = {
         le_title2: 'Cognitive Level Distribution',
         le_title3: 'Scoring Rate Relation Table',
         le_title4: 'Scoring Rate - Cognitive Level Statistics',
-        le_title5: 'Cognitive Level Score Details',
+        le_title5: 'Cognitive Level Scoring Details',
         le_title6: 'Incorrectly Answered Question Rate Relation Table',
         le_title7: 'Cognitive Level Scoring Rate Distribution Chart',
 
@@ -7093,7 +7093,7 @@ const LANG_EN_US = {
             name: 'Poll Name',
             namePlace: 'Please enter poll name',
             target: 'Poll Participant',
-            privateClass: 'Personal Class',
+            privateClass: 'Personal Course',
             schoolClass: 'School Class',
             targetPlace: 'Please select the poll participant',
             noFoundText: 'No class created yet',

+ 5 - 5
TEAMModelOS/ClientApp/public/lang/zh-TW.js

@@ -2014,7 +2014,7 @@ const LANG_ZH_TW = {
             name: '作業名稱',
             namePlace: '請輸入作業名稱',
             target: '作業對象',
-            privateClass: '個人班級',
+            privateClass: '個人課程',
             schoolClass: '學校班級',
             targetPlace: '請選擇作業發布對象',
             noFoundText: '暫未建立班級',
@@ -4134,7 +4134,7 @@ const LANG_ZH_TW = {
         tips2Content4: '個學生',
         tips3: '請選擇需要刪除的學生!',
         sltPdFirst: '請先選擇學制',
-        sltGdFirst: '請先選擇學制',
+        sltGdFirst: '請先選擇年級',
         noClass: '此年級暫無教室',
         noRelClass: '未關聯班級',
         resetPw: '重設密碼',
@@ -4266,7 +4266,7 @@ const LANG_ZH_TW = {
         sit23: '性別',
         sit24: '男',
         sit25: '女',
-        sit26: 'gender: 填,學生性別,"M"代表男,"F"代表女',
+        sit26: 'gender: 填,學生性別,"M"代表男,"F"代表女',
 
         //Authorization.vue
         authTitle: '服務授權管理',
@@ -5285,7 +5285,7 @@ const LANG_ZH_TW = {
             name: '問卷名稱',
             namePlace: '請輸入問卷名稱',
             target: '問卷對象',
-            privateClass: '個人班級',
+            privateClass: '個人課程',
             schoolClass: '學校班級',
             targetPlace: '請選擇問卷發布對象',
             noFoundText: '暫未建立班級',
@@ -7085,7 +7085,7 @@ const LANG_ZH_TW = {
             name: '投票名稱',
             namePlace: '請輸入投票名稱',
             target: '投票對象',
-            privateClass: '個人班級',
+            privateClass: '個人課程',
             schoolClass: '學校班級',
             targetPlace: '請選擇投票發布對象',
             noFoundText: '暫未建立班級',

+ 5 - 6
TEAMModelOS/Controllers/OpenApi/Business/BizStudentController.cs

@@ -12,11 +12,6 @@ using System.Collections.Generic;
 using System.Text.Json;
 using TEAMModelOS.SDK.Extension;
 using TEAMModelOS.Filter;
-using TEAMModelOS.SDK.Models;
-using Azure.Cosmos;
-using TEAMModelOS.SDK.Models.Cosmos.OpenEntity;
-using System;
-using System.Text;
 
 
 namespace TEAMModelOS.Controllers
@@ -59,7 +54,11 @@ namespace TEAMModelOS.Controllers
         {
             var (id, school) = HttpContext.GetApiTokenInfo();
             //if(!jsonElement.TryGetProperty("schoolId",out JsonElement schoolId)) return Ok(new { code = RespondCode.ParamsError, msg = "参数错误:schoolId", data = "" });
-            var responseData = await OpenApiService.GetLoginStuInfo(_azureCosmos, _dingDing, _option, id, school, jsonElement);
+            //var responseData = await OpenApiService.GetLoginStuInfo(_azureCosmos, _dingDing, _option, id, school, jsonElement);
+
+            var cosmosClient = _azureCosmos.GetCosmosClient();
+            var responseData = await OpenApiService.GetStudentInfo(_azureCosmos, _dingDing, id, school, jsonElement);
+            
             return Ok(new { responseData });
         }
     }

+ 63 - 19
TEAMModelOS/Controllers/OpenApi/OpenApiService.cs

@@ -37,6 +37,7 @@ using static TEAMModelOS.Controllers.CourseController;
 using System.IdentityModel.Tokens.Jwt;
 using TEAMModelOS.SDK.Models.Cosmos.OpenEntity;
 using Microsoft.OData.UriParser;
+using FastJSON;
 
 namespace TEAMModelOS.Controllers
 {
@@ -824,8 +825,10 @@ namespace TEAMModelOS.Controllers
             {
                 var client = _azureCosmos.GetCosmosClient();
                 json.TryGetProperty("searchKey", out JsonElement _searchKey);
-                List<CoreUser> coreUsers = new();
+                List<CoreUser> coreUsers = new(); List<CoreUser> unjoined = new();
                 IEnumerable<string> unexist = null;
+                StringBuilder sql = new("select c.id,c.name ,c.picture,c.job ,c.subjectIds,c.roles from c");
+
                 if (_searchKey.ValueKind.Equals(JsonValueKind.Array))
                 {
                     List<string> searchKey = _searchKey.ToObject<List<string>>();
@@ -841,44 +844,47 @@ namespace TEAMModelOS.Controllers
                         if (coreUsers.Any())
                             unexist = searchKey.Except(coreUsers.Select(x => x.searchKey));
                         else
-                            return new ResponseData<dynamic>() { code = RespondCode.NotFound, msg = "没有找到对应的教师信息", data = { null, null, unexist } };
-                    }
-                    else {
-                        return new ResponseData<dynamic>() { code = RespondCode.ParamsError, msg = "searchKey为空", data = { null, null, unexist } };
+                            return new ResponseData<dynamic>() { code = RespondCode.NotFound, msg = "没有找到对应的教师信息", data = _searchKey };
                     }
-                    
                 }
 
                 List<SchoolTeacher> teachers = new();
-                string insql = "";
+                //string insql = "";
                 if (coreUsers.Any())
-                {
-                    insql = $" where  c.id in  ({string.Join(",", coreUsers.Select(x => $"'{x.id}'"))}) ";
-                }
+                    sql.Append($" where  c.id in  ({string.Join(",", coreUsers.Select(x => $"'{x.id}'"))}) ");
 
-                string sql = $"select c.id,c.name ,c.picture,c.job ,c.subjectIds,c.roles from c  {insql}";
                 await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<SchoolTeacher>
-                    (queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Teacher-{school}") }))
+                    (queryText: sql.ToString(), requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Teacher-{school}") }))
                 {
                     teachers.Add(item);
                 }
-                var teacherIds = coreUsers.Select(x => x.id).Except(teachers.Select(x => x.id));
-                List<CoreUser> unjoined = coreUsers.FindAll(x => teacherIds.Contains(x.id));
+
+                if (coreUsers.Count > 0)
+                {
+                    var teacherIds = coreUsers.Select(x => x.id).Except(teachers.Select(x => x.id));
+                    unjoined= coreUsers.FindAll(x => teacherIds.Contains(x.id));
+                }
+
                 List<dynamic> tchs = new List<dynamic>();
                 teachers.Select(x => new { x.id, x.name, x.picture, x.job, x.subjectIds, x.roles }).ToList().ForEach(x =>
                 {
-                    var coreUser = coreUsers.Find(c => c.id.Equals(x.id));
-                    if (coreUser != null)
+                    if (coreUsers.Count > 0) 
                     {
-                        tchs.Add(new { x.id, coreUser.name, coreUser.picture, x.job, x.subjectIds, x.roles, coreUser.searchKey, school });
+                        var coreUser = coreUsers.Find(c => c.id.Equals(x.id));
+                        if (coreUser != null)
+                        {
+                            tchs.Add(new { x.id, coreUser.name, coreUser.picture, x.job, x.subjectIds, x.roles, coreUser.searchKey, school });
+                        }
                     }
+                    else
+                        tchs.Add(new { x.id, x.name, x.picture, x.job, x.subjectIds, x.roles, school });
                 });
 
-                return new ResponseData<dynamic>() { code = RespondCode.Ok, msg = "成功", data = new { tchs, unjoined = unjoined.Select(x => new OCoreUer { id = x.id, name = x.name, picture = x.picture, searchKey = x.searchKey }).ToList(), unexist } };
+                return new ResponseData<dynamic>() { code = RespondCode.Ok, msg = "成功", data = new { tchs, unjoined = unjoined.Select(x => new { id = x.id, name = x.name, picture = x.picture, searchKey = x.searchKey }).ToList(), unexist } };
             }
             catch (Exception ex)
             {
-                await _dingDing.SendBotMsg($"OpenApi,{Environment.GetEnvironmentVariable("Option:Location")} OpenApiService/GetTeacherList()   参数:bizId:{bizId},school:{school},json:{json.ToJsonString()} \n  {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
+                //await _dingDing.SendBotMsg($"OpenApi,{Environment.GetEnvironmentVariable("Option:Location")} OpenApiService/GetTeacherList()   参数:bizId:{bizId},school:{school},json:{json.ToJsonString()} \n  {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
                 return new ResponseData<dynamic>() { code = RespondCode.Error, msg = "服务端异常" };
             }
         }
@@ -1838,5 +1844,43 @@ namespace TEAMModelOS.Controllers
 
         }
 
+        /// <summary>
+        /// 获取学生详细信息
+        /// </summary>
+        /// <param name="_azureCosmos"></param>
+        /// <param name="_dingDing"></param>
+        /// <param name="bizId"></param>
+        /// <param name="school"></param>
+        /// <param name="json"></param>
+        /// <returns></returns>
+        public static async Task<ResponseData<dynamic>> GetStudentInfo(AzureCosmosFactory _azureCosmos, DingDing _dingDing, string bizId, string school, JsonElement json)
+        {
+
+            if (!json.TryGetProperty("ids", out JsonElement _ids)) return new ResponseData<dynamic>() { code = RespondCode.ParamsError, msg = "idToken参数错误", data = null };
+            try                    
+            {
+                List<string> ids = _ids.ToObject<List<string>>();
+                List<OStudent> student = new();
+                //List<OStudent> tmdId = new();
+
+                string sqlStu = $"select value(c) from c where c.id in ({string.Join(",", ids.Select(s => $"'{s}'"))})";
+                await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<OStudent>(queryText: sqlStu, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{school}") }))
+                {
+                    student.Add(item);
+                }
+                //string sqlTmd = $"select value(c) from c join s in c.schools where c.id in ({string.Join(",", ids.Select(s => $"'{s}'"))}) and s.schoolId='{school}'";
+                //await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<OStudent>(queryText: sqlTmd, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
+                //{
+                //    tmdId.Add(item);
+                //}
+
+                return new ResponseData<dynamic>() { code = RespondCode.Ok, msg = "成功", data = student };
+            }
+            catch (Exception ex)
+            {
+                await _dingDing.SendBotMsg($"OpenApi,{Environment.GetEnvironmentVariable("Option:Location")} OpenApiService/GetLoginStuInfo()   参数:学生id集合:{_ids},school:{school},json:{json.ToJsonString()} \n  {ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
+                return new ResponseData<dynamic>() { code = RespondCode.Error, msg = "服务器错误" };
+            }
+        }
     }
 }

+ 7 - 3
TEAMModelOS/Controllers/School/SchoolController.cs

@@ -417,7 +417,7 @@ namespace TEAMModelOS.Controllers
                 deviceBoundExt deviceBoundExt;
                 deviceBound serialDeviceBoundRow;
                 SerialInfoBaseWithdeviceBoundExt serialResultRow;
-                List<SchoolProductSerial> updSchoolProductSerialList = new List<SchoolProductSerial>();
+                List<SchoolProductSerial> updSchoolProductSerialList = new List<SchoolProductSerial>(); //更新學校產品序號用
                 foreach (SchoolProductSerial serialRow in serial)
                 {
                     deviceBoundArray = new List<deviceBoundExt>();
@@ -441,8 +441,12 @@ namespace TEAMModelOS.Controllers
                             deviceBoundExt.pcname = deviceRow.pc_name;
                             deviceBoundExt.osver = deviceRow.os_ver;
                             deviceBoundArray.Add(deviceBoundExt);
-                            //DB更新用
-                            serialDeviceBoundRow = serialRow.deviceBound.Where(d => (d.uuid == deviceBoundRow.uuid1 && d.uuid2 == deviceBoundRow.uuid2) || (d.uuid == deviceBoundRow.uuid2 && d.uuid2 == deviceBoundRow.uuid1)).FirstOrDefault();
+                            //DB更新用序號資料:比對IES5序號硬體列 與 CS拿到的硬體列,若吻合者將IES5序號硬體列的deviceId寫入
+                            //比對法: [IES5]UUID1==[CS]UUID2 || [IES5]UUID2==[CS]UUID1 ※null與空白算為相同
+                            serialDeviceBoundRow = serialRow.deviceBound.Where(d => 
+                                ((d.uuid == deviceBoundRow.uuid1 || (string.IsNullOrEmpty(d.uuid) && string.IsNullOrEmpty(deviceBoundRow.uuid1))) && (d.uuid2 == deviceBoundRow.uuid2 || (string.IsNullOrEmpty(d.uuid2) && string.IsNullOrEmpty(deviceBoundRow.uuid2))) ) || 
+                                ((d.uuid == deviceBoundRow.uuid2 || (string.IsNullOrEmpty(d.uuid) && string.IsNullOrEmpty(deviceBoundRow.uuid2))) && (d.uuid2 == deviceBoundRow.uuid1 || (string.IsNullOrEmpty(d.uuid2) && string.IsNullOrEmpty(deviceBoundRow.uuid1))) )
+                            ).FirstOrDefault(); 
                             if (serialDeviceBoundRow != null)
                             {
                                 serialDeviceBoundRow.deviceId = deviceRow.device_id;