Browse Source

课堂观察

SanHQin 4 weeks ago
parent
commit
f876197859

+ 124 - 63
src/components/pages/classroomObservation/dialog/batchCreationClassDialog.vue

@@ -849,15 +849,48 @@ export default {
           //按顺序处理任务
           let _step = _stepList[i];
           console.log(_step);
-          if (!this.nowDoTaskId.includes(_startData.id)) break;
-          if (_step.status === "1") continue;
+          if (!this.nowDoTaskId.includes(_startData.id)){
+            if (
+                this.dataList.find(i => i.id === _startData.id).status == "1"
+              ) {
+                this.dataList.find(i => i.id === _startData.id).status = "0";
+                if (this.dataList.find(i => i.status == "0")) {
+                  let id = this.dataList.find(i => i.status == "0").id;
+                  this.startTask(id);
+                }
+              }
+            break;
+          };
+          if (_step.status == "1") {
+            if (_step.type == "createClass") {
+              if (
+                this.dataList.find(i => i.id === _startData.id).status == "1"
+              ) {
+                this.dataList.find(i => i.id === _startData.id).status = "2";
+                this.updateTask(_startData.id);
+                if (this.dataList.find(i => i.status == "0")) {
+                  let id = this.dataList.find(i => i.status == "0").id;
+                  this.startTask(id);
+                }
+              }
+              break;
+            } else {
+              continue;
+            }
+          }
           if (_step.type === "uploadFile") continue;
           if (_step.type === "getVideoVoice") {
             //视频提取音频
             _stepList[i].status = "2";
+            _stepList[i].startTime =
+              new Date().toLocaleDateString().replaceAll("/", "-") +
+              " " +
+              new Date().toLocaleTimeString();
+
             this.dataList.find(
               i => i.id === _startData.id
             ).jsonData.steps = _stepList;
+            this.$forceUpdate()
             let _fileData = _startData.jsonData.fileData;
             let audioFile = await this.getVideoToVoiceAndUploadMixin(_fileData);
             if (audioFile.data == 3) {
@@ -869,6 +902,10 @@ export default {
               };
 
               this.dataList.find(i => i.id === _startData.id).status = "3";
+              if (this.dataList.find(i => i.status == "0")) {
+                let id = this.dataList.find(i => i.status == "0").id;
+                this.startTask(id);
+              }
               break;
             }
             if (!this.nowDoTaskId.includes(_startData.id)) break;
@@ -901,9 +938,15 @@ export default {
             if (fileData.type === "text/plain") {
               //txt文件
               _stepList[i].status = "2";
+              _stepList[i].startTime =
+                new Date().toLocaleDateString().replaceAll("/", "-") +
+                " " +
+                new Date().toLocaleTimeString();
+
               this.dataList.find(
                 i => i.id === _startData.id
               ).jsonData.steps = _stepList;
+              this.$forceUpdate()
               let { editorBarData } = await this.getTextContentMixin(fileData);
               if (!this.nowDoTaskId.includes(_startData.id)) break;
               this.dataList.find(
@@ -928,10 +971,15 @@ export default {
             ) {
               //mp4与wav文件
               _stepList[i].status = "2";
+              _stepList[i].startTime =
+                new Date().toLocaleDateString().replaceAll("/", "-") +
+                " " +
+                new Date().toLocaleTimeString();
+
               this.dataList.find(
                 i => i.id === _startData.id
               ).jsonData.steps = _stepList;
-
+              this.$forceUpdate()
               let _file = _startData.jsonData.fileData.fileObj;
               if (!_file && JSON.stringify(_file) != "{}") {
                 let fileBody = await this.getFileBody(
@@ -954,15 +1002,28 @@ export default {
                   _file = _data.data;
                 } else {
                   console.log("报错👉", _data);
+                  if (this.dataList.find(i => i.status == "0")) {
+                    let id = this.dataList.find(i => i.status == "0").id;
+                    this.startTask(id);
+                  }
+                  break;
                 }
               }
               console.log("转录文件", _file);
 
               let {
                 transcriptionContent,
-                editorBarData
+                editorBarData,
+                data
               } = await this.wavAudioToTextAndObjMixin(_file);
-
+              if (data === 1) {
+                //转录失败,直接退出
+                if (this.dataList.find(i => i.status == "0")) {
+                  let id = this.dataList.find(i => i.status == "0").id;
+                  this.startTask(id);
+                }
+                break;
+              }
               this.dataList.find(
                 i => i.id === _startData.id
               ).jsonData.baseMessage.transcriptionData = transcriptionContent;
@@ -984,55 +1045,17 @@ export default {
             }
           } else if (_step.type === "automaticCoding") {
             if (_startData.jsonData.automaticCoding) {
-              // const fileData = _startData.jsonData.fileData;
-              // if (fileData.type === "text/plain") {
-              //   _stepList[i].status = "2";
-              //   this.dataList.find(
-              //     i => i.id === _startData.id
-              //   ).jsonData.steps = _stepList;
-              //   //选择了字段编码
-              //   let _content =
-              //     _startData.jsonData.baseMessage.editorBarData.content;
-              //   let _tableList =
-              //     _startData.jsonData.baseMessage.editorBarData.table;
-              //   if (!_content) {
-              //     _content = await this.getFile(
-              //       _startData.jsonData.baseMessage.editorBarData.url
-              //     );
-              //     _content = _content.data;
-              //     this.dataList.find(
-              //       i => i.id === _startData.id
-              //     ).jsonData.baseMessage.editorBarData.content = _content;
-              //   }
-
-              //   if (!_tableList) {
-              //     let _result = [];
-              //     let _data = _content;
-              //     let _div = document.createElement("div");
-              //     _div.innerHTML = _data;
-              //     let _tableRows = _div.querySelectorAll(`table tbody tr`);
-              //     _tableRows.forEach((i, index) => {
-              //       if (index == 0) return;
-              //       let obj = {
-              //         index: i.cells[0].textContent,
-              //         startTime: i.cells[1].textContent,
-              //         endTime: i.cells[2].textContent,
-              //         value: i.cells[3].textContent,
-              //         time: i.cells[4].textContent,
-              //         role: i.cells[5] ? i.cells[5].textContent : "",
-              //         code: i.cells[6] ? i.cells[6].textContent : ""
-              //       };
-              //       _result.push(obj);
-              //     });
-
-              //     _tableList = _result;
-              //   }
-              // } else {
               const fileData = _startData.jsonData.fileData;
               _stepList[i].status = "2";
+              _stepList[i].startTime =
+                new Date().toLocaleDateString().replaceAll("/", "-") +
+                " " +
+                new Date().toLocaleTimeString();
+
               this.dataList.find(
                 i => i.id === _startData.id
               ).jsonData.steps = _stepList;
+              this.$forceUpdate()
               //选择了字段编码
               let _content =
                 _startData.jsonData.baseMessage.editorBarData.content;
@@ -1120,9 +1143,15 @@ export default {
           } else if (_step.type === "getFileIds") {
             //文件获取fileId
             _stepList[i].status = "2";
+            _stepList[i].startTime =
+              new Date().toLocaleDateString().replaceAll("/", "-") +
+              " " +
+              new Date().toLocaleTimeString();
+
             this.dataList.find(
               i => i.id === _startData.id
             ).jsonData.steps = _stepList;
+            this.$forceUpdate()
             let _fileData = _startData.jsonData.baseMessage.editorBarData;
             let { fileId } = await this.getFileIdMixin(_fileData.url);
             if (!this.nowDoTaskId.includes(_startData.id)) break;
@@ -1144,10 +1173,15 @@ export default {
           } else if (_step.type == "getWordCloudMap") {
             //文件获取fileId
             _stepList[i].status = "2";
+            _stepList[i].startTime =
+              new Date().toLocaleDateString().replaceAll("/", "-") +
+              " " +
+              new Date().toLocaleTimeString();
+
             this.dataList.find(
               i => i.id === _startData.id
             ).jsonData.steps = _stepList;
-
+            this.$forceUpdate()
             let _fileData = _startData.jsonData.baseMessage.editorBarData;
 
             let _content = await this.getFile(_fileData.url);
@@ -1171,9 +1205,15 @@ export default {
           } else if (_step.type === "generateReport") {
             //生成报告
             _stepList[i].status = "2";
+            _stepList[i].startTime =
+              new Date().toLocaleDateString().replaceAll("/", "-") +
+              " " +
+              new Date().toLocaleTimeString();
+
             this.dataList.find(
               i => i.id === _startData.id
             ).jsonData.steps = _stepList;
+            this.$forceUpdate()
             let _analysisList = _startData.jsonData.analysisList;
 
             let promises = [];
@@ -1186,6 +1226,7 @@ export default {
               _content = _content.data;
               _startData.jsonData.baseMessage.editorBarData.content = _content;
             }
+            console.log(_analysisList.length)
             promises = _analysisList.map((i, index) => {
               return new Promise(async resolve => {
                 _startData.jsonData.analysisList[index].status = "default"; //默认状态
@@ -1197,7 +1238,7 @@ export default {
                       _startData.jsonData.analysisList[index].status
                     )
                   ) {
-                    return resolve(_startData.jsonData.analysisList[index]);
+                    return resolve();
                   }
                   if (_num >= _maxNum) {
                     _startData.jsonData.analysisList[index].status =
@@ -1225,8 +1266,9 @@ export default {
                     assistantData: _assistantData,
                     baseMessage: _startData.jsonData.baseMessage
                   });
-                  if (!this.nowDoTaskId.includes(_startData.id))
-                    return resolve();
+                  console.log("👉xxx",data,index)
+
+                  if (!this.nowDoTaskId.includes(_startData.id)) return resolve();
                   if (data.data == 1) {
                     if (_num < _maxNum) {
                       //重试
@@ -1279,10 +1321,15 @@ export default {
           } else if (_step.type === "createClass") {
             //创建课堂
             _stepList[i].status = "2";
+            _stepList[i].startTime =
+              new Date().toLocaleDateString().replaceAll("/", "-") +
+              " " +
+              new Date().toLocaleTimeString();
+
             this.dataList.find(
               i => i.id === _startData.id
             ).jsonData.steps = _stepList;
-
+            this.$forceUpdate()
             //创建课堂   赋值好fileid   替换创建后课堂的基础数据  继续下一个任务
             let newOption = await this.createClassMixin(_startData.jsonData);
 
@@ -1319,6 +1366,16 @@ export default {
               let id = this.dataList.find(i => i.status == "0").id;
               this.startTask(id);
             }
+            break;
+          }
+
+          console.log(this.dataList.find(i => i.id === _startData.id));
+          if (this.dataList.find(i => i.id === _startData.id).status == "1") {
+            this.dataList.find(i => i.id === _startData.id).status = "0";
+            if (this.dataList.find(i => i.status == "0")) {
+              let id = this.dataList.find(i => i.status == "0").id;
+              this.startTask(id);
+            }
           }
         }
       }
@@ -1487,7 +1544,7 @@ export default {
       //     console.log("err", err);
       //   });
     },
-    async regenerateTheReport(){
+    async regenerateTheReport() {
       let _generateList = this.dataList.filter(
         i =>
           this.selectList.includes(i.id) &&
@@ -1498,24 +1555,28 @@ export default {
           i.status == "2"
       );
 
-      if(_generateList.length<=0)return this.$message.info("请先选择已经完成的任务列表");
+      if (_generateList.length <= 0)
+        return this.$message.info("请先选择已经完成的任务列表");
 
       this.$confirm("确认要重新生成课堂观察报告吗?", "提示", {
         confirmButtonText: "确定",
         cancelButtonText: "取消",
         type: "warning"
       }).then(() => {
-        _generateList.forEach(i=>{
-          this.dataList.find(i2=>i2.id==i.id).status = "0";
-          this.dataList.find(i2 => i2.id === i.id).jsonData.steps.find(i2 => i2.type == "generateReport").status ="0";
-        })
+        _generateList.forEach(i => {
+          this.dataList.find(i2 => i2.id == i.id).status = "0";
+          this.dataList
+            .find(i2 => i2.id === i.id)
+            .jsonData.steps.find(i2 => i2.type == "generateReport").status =
+            "0";
+        });
 
         if (!this.dataList.some(i => i.status == "1")) {
           this.startTask(_generateList[0].id);
         }
-      })
-      }
-    },
+      });
+    }
+  },
   mounted() {
     this.getTaskList();
     this.getDialogTagDataList();

+ 12 - 9
src/components/pages/classroomObservation/newComponents/batchClassCard.vue

@@ -70,15 +70,16 @@
                 />
                 <div>{{ item.text }}</div>
                 <span>
-                  <span
+                  <span v-if="item.startTime">{{ item.startTime }}</span>
+                  <!-- <span
                     v-if="
                       item.status == '2' &&
                         item.progress &&
                         item.progress !== '0'
                     "
-                    >{{ item.progress }}%</span
-                  ></span
-                >
+                    >{{ item.progress }}%</span> -->
+
+                  </span>
               </div>
             </div>
           </span>
@@ -113,14 +114,16 @@
                 />
                 <div>{{ item.text }}</div>
                 <span>
-                  <span
+                  <span v-if="item.startTime">{{ item.startTime }}</span>
+                  <!-- <span
                     v-if="
                       item.status == '2' &&
                         item.progress &&
                         item.progress !== '0'
                     "
                     >{{ item.progress }}%</span
-                  ></span
+                  > -->
+                  </span
                 >
               </div>
             </div>
@@ -428,7 +431,7 @@ export default {
 }
 
 .stepBox {
-  width: 200px;
+  width: 315px;
   height: auto;
   background-color: #fff;
   position: absolute;
@@ -457,7 +460,7 @@ export default {
 }
 
 .sb_item > div {
-  max-width: calc(100% - 20px - 35px - 15px);
+  max-width: calc(100% - 20px - 140px - 15px);
   width: calc(100% - 20px - 35px - 15px);
   height: 100%;
   margin: 0 5px 0 10px;
@@ -472,7 +475,7 @@ export default {
   display: flex;
   align-items: center;
   justify-content: center;
-  width: 35px;
+  width: 150px;
   height: 100%;
   color: rgba(54, 129, 252, 1);
 }

+ 17 - 1
src/components/pages/classroomObservation/tools/mixin.js

@@ -1214,12 +1214,25 @@ CH:${_CH}
         let _startTime = 0;
         let _endTime = 0;
 
+        let timer = null;
+
+        timer = setTimeout(()=>{//五分钟无响应就算报错
+          resolve({ data: 1,transcriptionContent:null,editorBarData:null,err: "转录超时" })
+        },180000)
+
         // 转录中
         iframeRef.contentWindow.onRecognizedResult = (e) => {
           let privText = e.privText;
           let privSpeakerId = e.privSpeakerId;
           let privDuration = e.privDuration;
           let privOffset = e.privOffset;
+
+          if(timer){
+            clearTimeout(timer)
+            timer = setTimeout(()=>{//五分钟无响应就算报错
+              resolve({ data: 1,transcriptionContent:null,editorBarData:null,err: "转录超时" })
+            },180000)
+          }
           if (!privText || !privSpeakerId || privSpeakerId == "Unknown") {//不记录
             return;
           }
@@ -1241,6 +1254,9 @@ CH:${_CH}
 
         //转录结束
         iframeRef.contentWindow.onSessionStopped = async (e) => {
+          if(timer){
+            clearTimeout(timer)
+          }
           tableContent = `<table
 	border="0"
 	width="100%"
@@ -2244,4 +2260,4 @@ CH:${_CH}
       })
     }
   }
-};
+};