Parcourir la source

2023/12/7 弹框显示进度条

WangRuiLin il y a 1 an
Parent
commit
e78f56334b

+ 8 - 5
cirs-biz/src/main/java/com/cirs/biz/controller/SysTrainController.java

@@ -55,9 +55,8 @@ public class SysTrainController extends BaseController
 //            .baseUrl("http://jsonplaceholder.typicode.com")
             .build();
 
-    String model_path = DictUtils.getDictValue("biz_algorithm_config","model_path");
-    String train_uri = DictUtils.getDictValue("biz_algorithm_config","train_uri");
-    String recommend_uri = DictUtils.getDictValue("biz_algorithm_config","recommend_uri");
+
+
     /**
      * 查询训练集数据列列表
      */
@@ -178,6 +177,8 @@ public class SysTrainController extends BaseController
     public AjaxResult train() {
         try {
 
+            String model_path = DictUtils.getDictValue("biz_algorithm_config","model_path");
+            String train_uri = DictUtils.getDictValue("biz_algorithm_config","train_uri");
 
             Map<String, Object> objectMap=new HashMap<>();
 
@@ -201,10 +202,10 @@ public class SysTrainController extends BaseController
             //接下来就传入算法即可
 //            System.out.println(JSON.toJSONString(objectMap));
 
-            return success("数据处理成功");
+            return success("训练成功");
         } catch (Exception e) {
 
-            return error("数据处理失败");
+            return error("训练失败");
         }
     }
 
@@ -213,6 +214,8 @@ public class SysTrainController extends BaseController
     public AjaxResult recommend(@RequestBody TrainReturn recommend_args, String modelPath) {
         try {
 
+            String recommend_uri = DictUtils.getDictValue("biz_algorithm_config","recommend_uri");
+
             Map<String, Object> objectMap=new HashMap<>();
             objectMap.put("useScene", recommend_args.getUseScene());
             objectMap.put("SearchCondition",recommend_args.getSearchCondition());

+ 13 - 12
cirs-biz/src/main/java/com/cirs/biz/controller/TVerificationTaskDetailController.java

@@ -46,8 +46,7 @@ public class TVerificationTaskDetailController extends BaseController
 
     @Autowired
     private ITElectronComponentService tElectronComponentService;//之前写在元器件接口不太方便
-    String model_path = DictUtils.getDictValue("biz_algorithm_config","model_path");
-    String verification_uri = DictUtils.getDictValue("biz_algorithm_config","verification_uri");
+
     private WebClient webClient = WebClient.builder()
 //            .baseUrl("http://jsonplaceholder.typicode.com")
             .build();
@@ -179,10 +178,12 @@ public class TVerificationTaskDetailController extends BaseController
     @GetMapping("/verification")
     public AjaxResult train(Long taskid) {
 
-//        try {
+        try {
+
+            String model_path = DictUtils.getDictValue("biz_algorithm_config","model_path");
+            String verification_uri = DictUtils.getDictValue("biz_algorithm_config","verification_uri");
 
 
-            // todo wangruilin 后续测试的日志可以删除
             logger.info(taskid.toString());
 //            System.out.println(taskid);
 
@@ -195,7 +196,7 @@ public class TVerificationTaskDetailController extends BaseController
 
             objectMap.put("dataSet", dataset);
             objectMap.put("modelPath", model_path);
-            // todo wangruilin uri应该还有个全地址的链接和端口号,比如192.168.1.2:8080/verification
+
             // 发送请求
             Mono<String> mono = webClient
                     .post() // POST 请求
@@ -222,10 +223,10 @@ public class TVerificationTaskDetailController extends BaseController
             return res;
 
 //            return success("任务"+taskid+"验证算法调用成功");
-//        } catch (Exception e) {
+        } catch (Exception e) {
 
-//            return error("任务"+taskid+"验证算法调用失败");
-//        }
+            return error("任务"+taskid+"验证算法调用失败");
+        }
     }
 
 
@@ -236,7 +237,7 @@ public class TVerificationTaskDetailController extends BaseController
 
     @PostMapping("/updateDetails")
     public AjaxResult updateDetails(@RequestBody List<VerificationData> dataset){
-//        try {
+        try {
             for (VerificationData verificationData : dataset) {
 
                 TVerificationTaskDetail detail = tVerificationTaskDetailService.selectTVerificationTaskDetailById(verificationData.getId());
@@ -261,9 +262,9 @@ public class TVerificationTaskDetailController extends BaseController
 //            List<TVerificationTaskDetail> detaildataset = tVerificationTaskDetailService.selectTVerificationTaskDetailByTaskIds(taskids);
 
             return success();
-//        } catch (Exception e){
-//            return error("加载数据出错");
-//        }
+        } catch (Exception e){
+            return error("加载数据出错");
+        }
     }
 
     @PostMapping("/getUpdatedDetails")

+ 45 - 21
cirs-ui/src/views/biz/task/index.vue

@@ -181,17 +181,7 @@
           <span>{{ parseTime(scope.row.endTime) }}</span>
         </template>
       </el-table-column>
-      <el-table-column label="运行进度" align="center" >
-        <template slot-scope="scope">
-          <el-progress
-            type="circle"
-            :percentage="ProgressMap[scope.$index]"
-            width="48"
-            :status="progressStatus"
-            ></el-progress>
-        </template>
 
-      </el-table-column>
       <el-table-column label="准确率" align="center" prop="accuracyRate" />
       <el-table-column label="召回率" align="center" prop="recallRate" />
       <el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip='true' />
@@ -348,6 +338,24 @@
         @pagination="getverificationdata"
       />
     </el-dialog>
+
+    <el-dialog
+      :title=progresstitle
+      :visible.sync="dialogVisible"
+      width="20%"
+      style="top:225px"
+      >
+      <div  align="center">
+        <el-progress
+          type="circle"
+          :percentage="ProgressMap[taskidToIndexMap.get(ids[0])]"
+          width="80"
+          :status="progressStatus"
+        ></el-progress>
+      </div>
+
+
+    </el-dialog>
   </div>
 
 
@@ -368,6 +376,8 @@ export default {
   name: "Task",
   data() {
     return {
+      progresstitle:'',
+      dialogVisible:false,
       // 遮罩层
       loading: true,
       vloading:true,
@@ -431,17 +441,18 @@ export default {
       ProgressMap: [],
       taskidToIndexMap: new Map(),
       verificationtabledata:[],
+      progressStatus:'',
     };
 
   },
   created() {
     this.getList();
   },
-  computed: {
-    progressStatus() {
-      return this.Progress === 100 ? 'success' : '';
-    },
-  },
+  // computed: {
+  //   progressStatus() {
+  //     return this.Progress === 100 ? 'success' : '';
+  //   },
+  // },
   methods: {
 
 
@@ -472,6 +483,17 @@ export default {
     },
 
     handleRun() {
+      if(this.ids.length>1) {
+        this.$modal.msg("不能选择多个任务!")
+        return ;
+      }
+      if(this.ids.length===0){
+        this.$modal.msg("请先选中验证任务!")
+        return ;
+      }
+      this.progresstitle = "验证任务"+this.ids[0]+"运行"
+      this.progressStatus = ''
+      this.dialogVisible = true
       let taskids = this.ids;
       const dayjs = require('dayjs');
 
@@ -493,10 +515,13 @@ export default {
                 console.log(res1.msg)
               })
 
-              console.log(this.verificationdataset)
+              // console.log(this.verificationdataset)
 
               task.accuracyRate = res.data.accuracyRate
               task.recallRate = res.data.recallRate
+              task.endTime = dayjs().format('YYYY-MM-DD HH:mm:ss');
+              task.taskStatus = '运行成功';
+              task.progress = 100;
               //这里需要更新数据库task
               updateTask(task).then(res2=>{
                 console.log(res2.msg)
@@ -517,15 +542,14 @@ export default {
               }
               // 如果进度达到100%,清除定时器并调用后端算法
               if (this.ProgressMap[idx] >= 100) {
+                this.$set(this.ProgressMap, idx, 0);
                 clearInterval(intervalId);
+                this.progressStatus = 'success'
+                this.dialogVisible = false
+
                 if(code===200){
-                  task.endTime = dayjs().format('YYYY-MM-DD HH:mm:ss');
-                  task.taskStatus = '运行成功';
-                  task.progress = 100;
-                  updateTask(task).then(res => {
                     this.$message.success('任务' + taskId + '运行成功!');
                     this.getList();
-                  });
                 }
               }
             }, 100);

+ 27 - 4
cirs-ui/src/views/biz/train/index.vue

@@ -86,9 +86,9 @@
           v-hasPermi="['biz:train:export']"
         >导出</el-button>
       </el-col >
-      <el-col :span="1.5" style="display: flex; flex-direction: row; align-items: center; padding-left:1000px ">
-        <el-button type="primary" @click="mytrain">训练</el-button>
-        <el-progress type="circle" :status="progressStatus" :percentage="Progress" :stroke-width="10" width="60" style="padding-bottom: 0; margin-left: 10px;"></el-progress>
+      <el-col :span="1.5" >
+        <el-button type="primary" size="mini" @click="mytrain">训练</el-button>
+
       </el-col>
 
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
@@ -193,6 +193,23 @@
         <el-button @click="upload.open = false">取 消</el-button>
       </div>
     </el-dialog>
+
+    <el-dialog
+      title="训练"
+      :visible.sync="dialogVisible"
+      width="20%"
+      style="top:225px"
+
+    >
+      <div  align="center">
+      <el-progress
+        type="circle"
+        :percentage="Progress"
+        width="80"
+        :status="progressStatus"
+      ></el-progress>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
@@ -204,6 +221,7 @@ export default {
   name: "Train",
   data() {
     return {
+      dialogVisible:false,
       Progress:0,
       // 导入参数
       upload: {
@@ -284,6 +302,7 @@ export default {
   methods: {
 
     mytrain() {
+
       getComponentIds().then(response=>{
         let result;
         train().then(res=>{
@@ -291,12 +310,16 @@ export default {
 
         })
         // 模拟进度变化,每0.1秒更新一次,共更新100次
+        this.dialogVisible = true
         const intervalId = setInterval(() => {
 
           this.Progress++;
-          // 如果进度达到100%,清除定时器并调用后端算法
+          // 如果进度达到100%,清除定时器
           if (this.Progress >= 100) {
+            this.Progress = 0
             clearInterval(intervalId);
+            this.dialogVisible = false
+
             if(result.code===200)
               this.$modal.msgSuccess(result.msg);
             else {