Browse Source

Merge branch 'develop5.0-tmd' of http://52.130.252.100:10000/TEAMMODEL/TEAMModelOS into develop5.0-tmd

CrazyIter_Bin 3 years ago
parent
commit
80a54be85c

+ 6 - 0
TEAMModelOS/ClientApp/src/locale/lang/en-US/jyzx.js

@@ -232,5 +232,11 @@ export default{
         remarks1: "總學時:線上研修 + 校本研修 + 認證材料 + 課堂實錄",
         remarks2: "注:各指標達到要求後,多餘學時不再計入總學時",
         remarks3: "注:45分鐘 = 1學時",
+        summary1: "填寫總結",
+        summary2: "修改總結",
+        message1: "您的研修還未完成,不能填寫總結",
+        message2: "總結已提交",
+        message3: "總結提交失敗",
+        message4: "總結字數不足50字!",
     }
 }

+ 6 - 0
TEAMModelOS/ClientApp/src/locale/lang/zh-CN/jyzx.js

@@ -232,5 +232,11 @@ export default{
         remarks1: "总学时:线上研修 + 校本研修 + 认证材料 + 课堂实录",
         remarks2: "注:各指标达到要求后,多余学时不再计入总学时",
         remarks3: "注:45分钟 = 1学时",
+        summary1: "填写总结",
+        summary2: "修改总结",
+        message1: "您的研修还未完成,不能填写总结",
+        message2: "总结已提交",
+        message3: "总结提交失败",
+        message4: "总结字数不足50字!",
     }
 }

+ 6 - 0
TEAMModelOS/ClientApp/src/locale/lang/zh-TW/jyzx.js

@@ -232,5 +232,11 @@ export default{
         remarks1: "總學時:線上研修 + 校本研修 + 認證材料 + 課堂實錄",
         remarks2: "注:各指標達到要求後,多餘學時不再計入總學時",
         remarks3: "注:45分鐘 = 1學時",
+        summary1: "填寫總結",
+        summary2: "修改總結",
+        message1: "您的研修還未完成,不能填寫總結",
+        message2: "總結已提交",
+        message3: "總結提交失敗",
+        message4: "總結字數不足50字!",
     }
 }

+ 9 - 9
TEAMModelOS/ClientApp/src/view/jyzx/HomePage.vue

@@ -37,8 +37,8 @@
                         </i-circle>
                         <p class="summary" @click="writeSun">
                             <Icon type="md-clipboard" />
-                            <span v-show="!summaryNum.length">填写总结</span>
-                            <span v-show="summaryNum.length">修改总结</span>
+                            <span v-show="wirteOk != 2">{{ $t("jyzx.homePage.summary1") }}</span>
+                            <span v-show="wirteOk === 2">{{ $t("jyzx.homePage.summary2") }}</span>
                         </p>
                     </div>
                     <div class="box-border">
@@ -265,7 +265,7 @@ export default {
 
             setting: undefined,
             videoTime: 0,
-            wirteOk: false, //不能填写总结
+            wirteOk: 0, //0:不能填写总结,1:可以写,还没写,2:已经填过了
             summaryNum: "", //总结
             isModal: false,
         }
@@ -364,7 +364,7 @@ export default {
                     this.areaExamNum = res.teacherTrain.examAreaDone
                     this.areaExamTotal = res.teacherTrain.examAreaJoin
                     if(this.totalTime === res.setting.allTime) {
-                        this.wirteOk = true
+                        this.wirteOk = res.teacherTrain.summary ? 2 : 1
                     }
                     this.summaryNum = res.teacherTrain.summary ? res.teacherTrain.summary : ""
                 }
@@ -377,7 +377,7 @@ export default {
             if(this.wirteOk) {
                 this.isModal = true
             } else {
-                this.$Message.warning("您的研修还未完成,不能填写总结")
+                this.$Message.warning(this.$t("jyzx.homePage.message1"))
             }
         },
         // 发送总结
@@ -385,14 +385,14 @@ export default {
             if(this.summaryNum.length > 50) {
                 this.$api.jyzx.sendSummary({summary: this.summaryNum}).then(res => {
                     if(res.status === 200) {
-                        this.$Message.success("总结已提交")
-                        this.summaryNum = ""
+                        this.$Message.success(this.$t("jyzx.homePage.message2"))
+                        // this.summaryNum = ""
                     } else {
-                        this.$Message.error("总结提交失败")
+                        this.$Message.error(this.$t("jyzx.homePage.message3"))
                     }
                 })
             } else {
-                this.$Message.warning("总结字数不足50字!")
+                this.$Message.warning(this.$t("jyzx.homePage.message4"))
             }
         },
     },

+ 89 - 12
TEAMModelOS/Controllers/Common/StudyController.cs

@@ -437,7 +437,46 @@ namespace TEAMModelOS.Controllers.Common
                 long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
                 List<Dictionary<string, List<string>>> acId = id.ToObject<List<Dictionary<string, List<string>>>>();
                 List<string> value = new List<string>();
-                await foreach (var s in AuditTask(acId, client, type.GetInt32(), now, standard, school)) ;
+                List<Task> tasks = new();
+                List<Task<ItemResponse<StudyRecord>>> tasky = new();
+                foreach (var aId in acId)
+                {
+                    foreach (KeyValuePair<string, List<string>> pair in aId)
+                    {
+                        foreach (var teacId in pair.Value)
+                        {
+                            var response = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync(pair.Key, new PartitionKey($"StudyRecord-{teacId}"));
+                            if (response.Status == 200)
+                            {
+                                var json = await JsonDocument.ParseAsync(response.ContentStream);
+                                StudyRecord study = json.ToObject<StudyRecord>();
+                                if (study.tId.Equals(teacId))
+                                {
+                                    study.status = type.GetInt32();
+                                    study.aTime = now;
+                                }
+                                tasky.Add(client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(study, study.id, new PartitionKey($"{study.code}")));
+                            }
+                            else
+                            {
+                                StudyRecord setting = new()
+                                {
+                                    id = pair.Key,
+                                    tId = teacId,
+                                    code = "StudyRecord-" + teacId,
+                                    status = type.GetInt32(),
+                                    aTime = now
+                                };
+                                tasky.Add(client.GetContainer("TEAMModelOS", "Teacher").CreateItemAsync(setting, new PartitionKey($"{setting.code}")));
+                            }
+                            tasks.Add(StatisticsService.SendServiceBus($"{standard}", $"{teacId}", $"{school}", StatisticsService.OfflineRecord, 1, _configuration, _serviceBus));
+                        }
+
+                    }
+                }
+                await Task.WhenAll(tasks);
+                await Task.WhenAll(tasky);
+                //await foreach (var s in AuditTask(acId, client, type.GetInt32(), now, standard, school)) ;
                 return Ok(new { code = HttpStatusCode.OK });
             }
             catch (Exception ex)
@@ -449,16 +488,51 @@ namespace TEAMModelOS.Controllers.Common
         }
         private async IAsyncEnumerable<(string op, string tId)> AuditTask(List<Dictionary<string, List<string>>> ids, CosmosClient client, int type, long now, object standard, string school)
         {
-
+            List<Task> tasks = new();
+            List<Task<ItemResponse<StudyRecord>>> tasky = new();
             foreach (var id in ids)
             {
                 foreach (KeyValuePair<string, List<string>> pair in id)
                 {
-                    await foreach (var s in TeacTask(pair.Key, pair.Value, client, type, now, standard, school));
+                    foreach (var teacId in pair.Value)
+                    {
+                        //var response = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync(pair.Key, new PartitionKey($"StudyRecord-{teacId}"));
+                        List<StudyRecord> studyRecords = new();
+                        await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<StudyRecord>(queryText: $"select value(c) from c where c.id = '{pair.Key}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StudyRecord-{teacId}") }))
+                        {
+                            studyRecords.Add(item);
+                        }
+                        if (studyRecords.Count > 0)
+                        {
+
+                            if (studyRecords[0].tId.Equals(teacId))
+                            {
+                                studyRecords[0].status = type;
+                                studyRecords[0].aTime = now;
+                            }
+                            tasky.Add(client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(studyRecords[0], studyRecords[0].id, new PartitionKey($"{studyRecords[0].code}")));
+                        }
+                        else
+                        {
+                            StudyRecord setting = new()
+                            {
+                                id = pair.Key,
+                                tId = teacId,
+                                code = "StudyRecord-" + teacId,
+                                status = type,
+                                aTime = now
+                            };
+                            tasky.Add(client.GetContainer("TEAMModelOS", "Teacher").CreateItemAsync(setting, new PartitionKey($"{setting.code}")));
+                        }
+                        tasks.Add(StatisticsService.SendServiceBus($"{standard}", $"{teacId}", $"{school}", StatisticsService.OfflineRecord, 1, _configuration, _serviceBus));
+                    }
+                    yield return ("", "");
 
                 }
-                yield return ("", "");
+
             }
+            await Task.WhenAll(tasks);
+            await Task.WhenAll(tasky);
         }
         private async IAsyncEnumerable<(string op, string tId)> TeacTask(string id,List<string> ids, CosmosClient client, int type, long now, object standard, string school)
         {
@@ -466,19 +540,22 @@ namespace TEAMModelOS.Controllers.Common
             List<Task> tasks = new();
             foreach (var teacId in ids)
             {
-                var response = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync(id, new PartitionKey($"StudyRecord-{teacId}"));
+                /* var response = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemStreamAsync(id, new PartitionKey($"StudyRecord-{teacId}"));*/
+                List<StudyRecord> studyRecords = new();
+                await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<StudyRecord>(queryText: $"select value(c) from c where c.id = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StudyRecord-{teacId}") }))
+                {
+                    studyRecords.Add(item);
+                }
                 string op;
-                if (response.Status == (int)HttpStatusCode.OK)
+                if (studyRecords.Count > 0)
                 {
-                    var json = await JsonDocument.ParseAsync(response.ContentStream);
-                    StudyRecord study = json.ToObject<StudyRecord>();
-                    if (study.tId.Equals(teacId))
+                    if (studyRecords[0].tId.Equals(teacId))
                     {
-                        study.status = type;
-                        study.aTime = now;
+                        studyRecords[0].status = type;
+                        studyRecords[0].aTime = now;
                     }
                     op = "update";
-                    await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(study, study.id, new PartitionKey($"{study.code}"));
+                    await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(studyRecords[0], studyRecords[0].id, new PartitionKey($"{studyRecords[0].code}"));
                 }
                 else
                 {