Explorar o código

1.統測活動取得統測教師課程及組別API 追加取得可晉級決賽名單
2.統測活動頁面 匯出報名老師資料 追加可晉級決賽欄位
3.修正BI統計計數未執行問題

jeff hai 7 meses
pai
achega
f1ddbc03ff

+ 1 - 1
TEAMModelOS.Function/IESServiceBusTrigger.cs

@@ -3253,7 +3253,7 @@ namespace TEAMModelOS.Function
                                         string scope = "private";
                                         foreach (string jointGroupId in jointGroupIds)
                                         {
-                                            List<JointEventGroupDb> addResult = await JointService.CreatePassJointCourseBySchedule(client, jointEvent.id, jointGroupId, jointEventSchedule.id, scope);
+                                            List<JointEventGroupDb> addResult = await JointService.CreatePassJointCourseBySchedule(client, jointEvent.id, jointGroupId, jointEventSchedule.id, scope, true);
                                         }
                                     }
                                 }

+ 0 - 1
TEAMModelOS.SDK/Models/Service/BI/BIStats.cs

@@ -33,7 +33,6 @@ namespace TEAMModelOS.SDK.Models.Service.BI
         {
             try
             {
-                return; 
                 if (string.IsNullOrEmpty(scId) || scId.Equals("SYSTEM_NO_SCHOOL",StringComparison.OrdinalIgnoreCase))
                     return;
 

+ 6 - 2
TEAMModelOS.SDK/Models/Service/JointService.cs

@@ -287,7 +287,8 @@ namespace TEAMModelOS.SDK.Models.Service
         }
 
         //以JointSchedule為單位,判斷班級/課程名單是否完成並生成決賽名單
-        public static async Task<List<JointEventGroupDb>> CreatePassJointCourseBySchedule(CosmosClient client, string jointEventId, string jointGroupId, string jointScheduleId, string scope)
+        /// <param name="mode">updDb true:更新DB false:不更新DB</param>
+        public static async Task<List<JointEventGroupDb>> CreatePassJointCourseBySchedule(CosmosClient client, string jointEventId, string jointGroupId, string jointScheduleId, string scope, bool updDb)
         {
             List<JointEventGroupDb> result = new List<JointEventGroupDb>();
             //0. 取得jointEvent、JointEventSchedule
@@ -502,7 +503,10 @@ namespace TEAMModelOS.SDK.Models.Service
                 {
                     JointEventGroupDb jointCourseFinalExistRow = jointCourseFinalExist.Where(j => j.creatorId.Equals(jointCourseCreateRow.creatorId)).FirstOrDefault();
                     jointCourseCreateRow.id = (jointCourseFinalExistRow != null) ? jointCourseFinalExistRow.id : Guid.NewGuid().ToString();
-                    await client.GetContainer(Constant.TEAMModelOS, container).UpsertItemAsync(jointCourseCreateRow);
+                    if(updDb)
+                    {
+                        await client.GetContainer(Constant.TEAMModelOS, container).UpsertItemAsync(jointCourseCreateRow);
+                    }
                     result.Add(jointCourseCreateRow);
                 }
             }

+ 1 - 0
TEAMModelOS/ClientApp/public/lang/en-US.js

@@ -8046,6 +8046,7 @@ const LANG_EN_US = {
         check: 'check',
         Warning02: 'The ongoing schedule cannot be edited',
         jointTime: 'Registration time',
+        finalQualification: 'Final Qualification',
         location: 'Location',
         pleaseEnterEventName: 'Please enter the event name',
         pleaseEnterSchedule: 'Please enter the schedule',

+ 1 - 0
TEAMModelOS/ClientApp/public/lang/zh-CN.js

@@ -8047,6 +8047,7 @@ const LANG_ZH_CN = {
         check: '检查',
         Warning02: '进行中时程不可编辑',
         jointTime: '报名时间',
+        finalQualification: '决赛资格',
         location: '位置',
         pleaseEnterEventName: '请输入活动名称',
         pleaseEnterSchedule: '请输入时程',

+ 1 - 0
TEAMModelOS/ClientApp/public/lang/zh-TW.js

@@ -8047,6 +8047,7 @@ const LANG_ZH_TW = {
         check: '檢查',
         Warning02: '進行中時程不可編輯',
         jointTime: '報名時間',
+        finalQualification: '決賽資格',
         location: '位置',
         pleaseEnterEventName: '請輸入活動名稱',
         pleaseEnterSchedule: '請輸入時程',

+ 6 - 3
TEAMModelOS/ClientApp/src/view/htcommunity/htMgtHome.vue

@@ -449,7 +449,8 @@ export default {
           try {
               let param = {
                   jointEventId: activity.id,
-                  type: type
+                  type: type,
+                  getFinal: true
               };
               //  取得報名老師資料API
               this.$api.htcommunity.jointCourseFind(param).then(
@@ -480,6 +481,7 @@ export default {
                                       let countryName = (item.countryName != null) ? item.countryName : "";
                                       let provinceName = (item.provinceName != null) ? item.provinceName : "";
                                       let cityName = (item.cityName != null) ? item.cityName : "";
+                                      let goFinal = (g.goFinal == true) ? "V" : "";
                                       //資料生成
                                       let jointCourseRow = {
                                           id: item.id,
@@ -495,6 +497,7 @@ export default {
                                           groupId: courseGroupId,
                                           groupName: courseGroupName,
                                           stuNum: g.stuNum,
+                                          goFinal: goFinal,
                                           countryId: item.countryId,
                                           countryName: countryName,
                                           provinceId: item.provinceId,
@@ -529,8 +532,8 @@ export default {
       exportExcel(type) {
         //老師報名資料
           if (type == 'teacherCourse') {
-              let titles = [this.$t('htcommunity.jointGroup'), this.$t('htcommunity.location'), this.$t('htcommunity.schoolName'), this.$t('htcommunity.teacherName'), this.$t('htcommunity.tmid'), this.$t('htcommunity.course'), this.$t('htcommunity.courseGroup'), this.$t('htcommunity.stuNumber'), this.$t('htcommunity.jointTime')];
-              let keys = ['jointGroupName', 'location', 'schoolName', 'creatorName', 'creatorId', 'courseName', 'groupName', 'stuNum', 'createTime'];
+              let titles = [this.$t('htcommunity.jointGroup'), this.$t('htcommunity.location'), this.$t('htcommunity.schoolName'), this.$t('htcommunity.teacherName'), this.$t('htcommunity.tmid'), this.$t('htcommunity.course'), this.$t('htcommunity.courseGroup'), this.$t('htcommunity.stuNumber'), this.$t('htcommunity.jointTime'), this.$t('htcommunity.finalQualification')];
+              let keys = ['jointGroupName', 'location', 'schoolName', 'creatorName', 'creatorId', 'courseName', 'groupName', 'stuNum', 'createTime', 'goFinal'];
               const params = {
                   title: titles,
                   key: keys,

+ 32 - 3
TEAMModelOS/Controllers/Teacher/JointEventController.cs

@@ -543,6 +543,7 @@ namespace TEAMModelOS.Controllers.Common
                 string jointEventId = (request.TryGetProperty("jointEventId", out JsonElement _jointEventId)) ? _jointEventId.ToString() : string.Empty;
                 string jointGroupId = (request.TryGetProperty("jointGroupId", out JsonElement _jointGroupId)) ? _jointGroupId.ToString() : string.Empty;
                 string type = (request.TryGetProperty("type", out JsonElement _type)) ? _type.ToString() : "regular"; //預設取得報名名單
+                bool getFinalCourseFlg = (request.TryGetProperty("getFinal", out JsonElement _getFinal)) ? _getFinal.GetBoolean() : false; //是否要取得可晉級名單
                 if (string.IsNullOrWhiteSpace(jointEventId)) return BadRequest();
                 //取得活動
                 JointEvent jointEvent = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<JointEvent>(jointEventId, new PartitionKey("JointEvent"));
@@ -597,6 +598,24 @@ namespace TEAMModelOS.Controllers.Common
                         }
                     }
                 }
+
+                //取得可晉級決賽名單
+                List<JointEventGroupDb> finalCourse = new List<JointEventGroupDb>();
+                if (getFinalCourseFlg)
+                {
+                    string scope = "private";
+                    List<string> jointGroupIds = jointEvent.groups.Select(g => g.id).ToList();
+                    string jointScheduleId = jointEvent.schedule.Where(s => s.type.Equals("exam") && s.examType.Equals("regular")).Select(s => s.id).FirstOrDefault(); //取得熱身賽的行程ID
+                    if (!string.IsNullOrWhiteSpace(jointScheduleId) && jointGroupIds.Count > 0)
+                    {
+                        foreach (string jointGId in jointGroupIds)
+                        {
+                            List<JointEventGroupDb> addResult = await JointService.CreatePassJointCourseBySchedule(client, jointEventId, jointGId, jointScheduleId, scope, false);
+                            finalCourse = finalCourse.Union(addResult).ToList();
+                        }
+                    }
+                }
+
                 //取得各課程名單(班級)人數
                 Dictionary<string, int> groupStuNumDic = new Dictionary<string, int>(); //各課程名單(各班級)人數 key:班級ID val:人數
                 StringBuilder stringBuilderGList = new($"SELECT c.id, ARRAY_LENGTH(c.members) as stuNum FROM c WHERE ARRAY_CONTAINS({JsonSerializer.Serialize(groupIdList)}, c.id) ");
@@ -615,18 +634,27 @@ namespace TEAMModelOS.Controllers.Common
                 }
                 foreach(JointEventGroupDto jointCourse in JointCourseDto)
                 {
-                    foreach(JointEventGroupDto.JointEventGroupCourseDto cInfo in jointCourse.courseLists)
+                    JointEventGroupDb finalJointCourseNow = finalCourse.Where(c => c.jointEventId.Equals(jointCourse.jointEventId) && c.jointGroupId.Equals(jointCourse.jointGroupId) && c.creatorId.Equals(jointCourse.creatorId)).FirstOrDefault(); //取得決賽老師資料
+                    foreach (JointEventGroupDto.JointEventGroupCourseDto cInfo in jointCourse.courseLists)
                     {
+                        JointEventGroupBase.JointEventGroupCourse finalCInfo = (finalJointCourseNow != null) ? finalJointCourseNow.courseLists.Where(c => c.courseId.Equals(cInfo.courseId)).FirstOrDefault() : null;
                         foreach (JointEventGroupDto.JointEventGroupCourseGroupDto gInfo in cInfo.groupLists)
                         {
+                            //班級人數
                             if(groupStuNumDic.ContainsKey(gInfo.id))
                             {
                                 gInfo.stuNum = groupStuNumDic[gInfo.id];
                             }
+                            //是否可晉級決賽
+                            JointEventGroupBase.JointEventGroupCourseGroup finalGInfo = (finalCInfo != null) ? finalCInfo.groupLists.Where(g => g.id.Equals(gInfo.id)).FirstOrDefault() : null;
+                            if(finalGInfo != null)
+                            {
+                                gInfo.goFinal = true;
+                            }
                         }
                     }
                 }
-
+                
                 return Ok(new { data = JointCourseDto });
             }
             catch (Exception e)
@@ -1410,7 +1438,7 @@ namespace TEAMModelOS.Controllers.Common
             {
                 foreach(string jointGroupId in jointGroupIds)
                 {
-                    List<JointEventGroupDb> addResult = await JointService.CreatePassJointCourseBySchedule(client, jointEventId, jointGroupId, jointScheduleId, scope);
+                    List<JointEventGroupDb> addResult = await JointService.CreatePassJointCourseBySchedule(client, jointEventId, jointGroupId, jointScheduleId, scope, true);
                     result = result.Union(addResult).ToList();
                 }
             }
@@ -1633,6 +1661,7 @@ namespace TEAMModelOS.Controllers.Common
                 public string id { get; set; }
                 public string name { get; set; }
                 public int stuNum { get; set; }
+                public bool goFinal { get; set; } //是否可參加決賽
                 public List<object> schedule { get; set; } = new List<object>(); //已完成的行程
             }
         }