WangRuiLin 1 an în urmă
părinte
comite
46b4d70367

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

@@ -1,6 +1,7 @@
 package com.cirs.biz.controller;
 
 import com.cirs.biz.domain.VerificationData;
+import com.cirs.common.utils.DictUtils;
 import org.springframework.http.HttpMethod;
 
 
@@ -51,9 +52,12 @@ public class SysTrainController extends BaseController
 
     // 创建 WebClient 对象
     private WebClient webClient = WebClient.builder()
-            .baseUrl("http://jsonplaceholder.typicode.com")
+//            .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");
     /**
      * 查询训练集数据列列表
      */
@@ -171,21 +175,20 @@ public class SysTrainController extends BaseController
 
     @PreAuthorize("@ss.hasPermi('biz:train:train')")
     @GetMapping("/train")
-    public AjaxResult train(String modelPath) {
+    public AjaxResult train() {
         try {
 
 
             Map<String, Object> objectMap=new HashMap<>();
 
-
             objectMap.put("dataSet", sysTrainService.getComponentids());
 
-            objectMap.put("modelPath", modelPath);
+            objectMap.put("modelPath", model_path);
             // 发送请求
             // todo wangruilin uri 应该是一个全地址+端口,这个地址可以通过数据字典配置和获取
             Mono<String> mono = webClient
                     .post() // POST 请求
-                    .uri("/posts")  // 请求路径
+                    .uri(train_uri)  // 请求路径
                     .contentType(MediaType.APPLICATION_JSON_UTF8)
                     .syncBody(objectMap)
                     .retrieve() // 获取响应体
@@ -224,17 +227,17 @@ public class SysTrainController extends BaseController
             // todo wangruilin uri 应该是一个全地址+端口,这个地址可以通过数据字典配置和获取
             Mono<String> mono = webClient
                     .post() // POST 请求
-                    .uri("/posts")  // 请求路径
+                    .uri(recommend_uri)  // 请求路径
                     .contentType(MediaType.APPLICATION_JSON_UTF8)
                     .syncBody(objectMap)
                     .retrieve() // 获取响应体
                     .bodyToMono(String.class); //响应数据类型转换
 
 
-            mono.subscribe(result -> {
+
                 // // todo wangruilin 改成logger
-                System.out.println(result);
-            });
+                logger.info(mono.block());
+
             //暂时赋值
             recommend_args.setResult1Id((long)53);
 
@@ -246,15 +249,12 @@ public class SysTrainController extends BaseController
     }
 
     @GetMapping("/getTraindataset")
-    public AjaxResult getTraindataset(){
-        List<VerificationData> train_dataset = sysTrainService.gettraindataset();
-        for(int i=0;i<train_dataset.size();i++){
-            VerificationData data = train_dataset.get(i);
-            data.setId((long)(i+1));
-            data.setTrained(1);
-            data.setTested(0);
+    public TableDataInfo getTraindataset(){
+        try{
+            startPage();
+            return getDataTable(sysTrainService.alldata());
+        } catch (Exception e){
+            return null;
         }
-        return success(train_dataset);
-
     }
 }

+ 4 - 0
cirs-biz/src/main/java/com/cirs/biz/controller/TElectronComponentController.java

@@ -155,6 +155,10 @@ public class TElectronComponentController extends BaseController
         util.importTemplateExcel(response, "元器件数据");
     }
 
+    @GetMapping("/getDetailById/{id}")
+    public String getDetailById(@PathVariable Long id) {
+        return tElectronComponentService.getDetailById(id);
+    }
 
 
 }

+ 85 - 15
cirs-biz/src/main/java/com/cirs/biz/controller/TVerificationTaskDetailController.java

@@ -5,9 +5,16 @@ import java.util.List;
 import java.util.Map;
 import javax.servlet.http.HttpServletResponse;
 
+import com.alibaba.fastjson2.JSON;
 import com.cirs.biz.domain.SysTrain;
 import com.cirs.biz.domain.TVerificationTask;
 import com.cirs.biz.domain.VerificationData;
+import com.cirs.biz.service.ITElectronComponentService;
+import com.cirs.common.utils.DictUtils;
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.springframework.boot.json.GsonJsonParser;
 import org.springframework.http.MediaType;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -37,8 +44,12 @@ public class TVerificationTaskDetailController extends BaseController
     @Autowired
     private ITVerificationTaskDetailService tVerificationTaskDetailService;
 
+    @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")
+//            .baseUrl("http://jsonplaceholder.typicode.com")
             .build();
     /**
      * 查询验证任务详情列表
@@ -166,44 +177,103 @@ public class TVerificationTaskDetailController extends BaseController
 
     @PreAuthorize("@ss.hasPermi('biz:detail:verification')")
     @GetMapping("/verification")
-    public AjaxResult train(Long taskid,String modelPath) {
+    public AjaxResult train(Long taskid) {
+
+//        try {
+
 
-        try {
             // todo wangruilin 后续测试的日志可以删除
+            logger.info(taskid.toString());
             System.out.println(taskid);
-            System.out.println(modelPath);
+
             getComponentIds(taskid);
             Map<String, Object> objectMap=new HashMap<>();
-            List<VerificationData> dataset = tVerificationTaskDetailService.getComponentids(taskid);
-            for(int i=0;i<dataset.size();i++){
-                dataset.get(i).setId((long)(i+1));
-            }
+            List<VerificationData> dataset = tVerificationTaskDetailService.getComponentids(taskid);//id就是taskdetail的id,由此更新相应的taskdetail
+//            for(int i=0;i<dataset.size();i++){
+//                dataset.get(i).setId((long)(i+1));
+//            }
+
             objectMap.put("dataSet", dataset);
-            objectMap.put("modelPath", modelPath);
+            objectMap.put("modelPath", model_path);
             // todo wangruilin uri应该还有个全地址的链接和端口号,比如192.168.1.2:8080/verification
             // 发送请求
             Mono<String> mono = webClient
                     .post() // POST 请求
-                    .uri("/posts")  // 请求路径
+                    .uri(verification_uri)  // 请求路径
                     .contentType(MediaType.APPLICATION_JSON_UTF8)
                     .syncBody(objectMap)
                     .retrieve() // 获取响应体
                     .bodyToMono(String.class); //响应数据类型转换
 
             AjaxResult res = new AjaxResult();
-            Object result = mono.block();
-            // todo wangruilin result 在这块没必要给用户返回
+            String result = mono.block();//返回值有accuracyRate和recallRate属性
+//
+//            GsonJsonParser jsonParser = new GsonJsonParser();
+//
+//            System.out.println(jsonParser.parseMap(result).get("dataSet").toString());
+
+            // 这里后端GsonJsonParser解析json语句报错Handler dispatch failed;,所以返回到前端解析
             res.put("data",result);
             res.put("msg","任务"+taskid+"验证算法调用成功");
             res.put("code",200);
             // todo System.out.println System.out.println应该使用logger框架替换
-            System.out.println(result);//返回值有accuracyRate和recallRate属性
+            System.out.println(result);
+            logger.info(result);
             return res;
 
 //            return success("任务"+taskid+"验证算法调用成功");
-        } catch (Exception e) {
+//        } catch (Exception e) {
+
+//            return error("任务"+taskid+"验证算法调用失败");
+//        }
+    }
+
+
+    public String getDetailById(Long id) {
+        if(id==null) return null;
+        return tElectronComponentService.getDetailById(id);
+    }
 
-            return error("任务"+taskid+"验证算法调用失败");
+    @PostMapping("/updateDetails")
+    public AjaxResult updateDetails(@RequestBody List<VerificationData> dataset){
+//        try {
+            for (VerificationData verificationData : dataset) {
+
+                TVerificationTaskDetail detail = tVerificationTaskDetailService.selectTVerificationTaskDetailById(verificationData.getId());
+
+                detail.setCalculate1Id(verificationData.getCalculate1Id());
+                detail.setCalculate2Id(verificationData.getCalculate2Id());
+                detail.setCalculate3Id(verificationData.getCalculate3Id());
+                detail.setCalculate4Id(verificationData.getCalculate4Id());
+                detail.setCalculate5Id(verificationData.getCalculate5Id());
+
+                detail.setCalculate1(getDetailById(detail.getCalculate1Id()));
+                detail.setCalculate2(getDetailById(detail.getCalculate2Id()));
+                detail.setCalculate3(getDetailById(detail.getCalculate3Id()));
+                detail.setCalculate4(getDetailById(detail.getCalculate4Id()));
+                detail.setCalculate5(getDetailById(detail.getCalculate5Id()));
+
+                detail.setTested(1);
+
+                tVerificationTaskDetailService.updateTVerificationTaskDetail(detail);
+            }
+
+//            List<TVerificationTaskDetail> detaildataset = tVerificationTaskDetailService.selectTVerificationTaskDetailByTaskIds(taskids);
+
+            return success();
+//        } catch (Exception e){
+//            return error("加载数据出错");
+//        }
+    }
+
+    @PostMapping("/getUpdatedDetails")
+    public TableDataInfo getUpdatedDetails(@RequestBody List<Long> taskids){
+        try{
+            startPage();
+            return getDataTable(tVerificationTaskDetailService.selectTVerificationTaskDetailByTaskIds(taskids));
+        } catch (Exception e){
+            return null;
         }
+
     }
 }

+ 3 - 0
cirs-biz/src/main/java/com/cirs/biz/mapper/TElectronComponentMapper.java

@@ -2,6 +2,7 @@ package com.cirs.biz.mapper;
 
 import java.util.List;
 import com.cirs.biz.domain.TElectronComponent;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * 元器件Mapper接口
@@ -60,4 +61,6 @@ public interface TElectronComponentMapper
     public int deleteTElectronComponentByIds(Long[] ids);
 
     public List<TElectronComponent> getAll();
+
+    public List<String> getDetailById(@Param("id") Long id);
 }

+ 2 - 0
cirs-biz/src/main/java/com/cirs/biz/service/ITElectronComponentService.java

@@ -62,4 +62,6 @@ public interface ITElectronComponentService
     public List<TElectronComponent> getAll();
 
     public String importComponent(List<TElectronComponent> componentList, boolean updateSupport, String operName);
+
+    public String getDetailById(Long id);
 }

+ 6 - 0
cirs-biz/src/main/java/com/cirs/biz/service/impl/TElectronComponentServiceImpl.java

@@ -155,4 +155,10 @@ public class TElectronComponentServiceImpl implements ITElectronComponentService
         }
         return successMsg.toString();
     }
+
+    @Override
+    public String getDetailById(Long id) {
+        List<String> detail = tElectronComponentMapper.getDetailById(id);
+        return detail.get(0)+"-"+detail.get(1)+"-"+detail.get(2);
+    }
 }

+ 3 - 0
cirs-biz/src/main/resources/mapper/biz/TElectronComponentMapper.xml

@@ -89,6 +89,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="getAll" resultType="com.cirs.biz.domain.TElectronComponent" resultMap="TElectronComponentResult">
         <include refid="selectTElectronComponentVo"/>
     </select>
+    <select id="getDetailById" resultType="java.lang.String">
+        select component_name,component_model,quality_grade from from t_electron_component where id = #{id}
+    </select>
 
     <insert id="insertTElectronComponent" parameterType="TElectronComponent" useGeneratedKeys="true" keyProperty="id">
         insert into t_electron_component

+ 3 - 2
cirs-biz/src/main/resources/mapper/biz/TVerificationTaskDetailMapper.xml

@@ -99,9 +99,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             resultType="com.cirs.biz.domain.TVerificationTaskDetail" resultMap="TVerificationTaskDetailResult">
         select task_id, use_scene,search_condition, result1, result2, result3, result4, result5, calculate1, calculate2, calculate3,calculate4,calculate5, create_by, create_time, update_by, update_time, remark from t_verification_task_detail
             where task_id in
-        <foreach item="item" collection="taskids" index="index" open="(" separator="," close=")">
+        <foreach item="item" collection="taskids" open="(" separator="," close=")">
             #{item}
         </foreach>
+
     </select>
     <select id="alldata" resultMap="TVerificationTaskDetailResult">
         select id,task_id, use_scene,search_condition, result1,result1_id, result2,result2_id, result3,result3_id, result4,result4_id, result5,result5_id, calculate1,calculate1_id, calculate2,calculate2_id, calculate3,calculate3_id,calculate4,calculate4_id,calculate5,calculate5_id, create_by, create_time, update_by, update_time, remark,trained,tested from t_verification_task_detail
@@ -113,7 +114,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                                               AND t_electron_component.quality_grade=#{attr2}
     </select>
     <select id="getComponentids" resultMap="VerificationData">
-        select use_scene, search_condition, result1_id, result2_id, result3_id, result4_id, result5_id,calculate1_id,calculate2_id,calculate3_id,calculate4_id,calculate5_id,trained,tested from t_verification_task_detail
+        select id,use_scene, search_condition, result1_id, result2_id, result3_id, result4_id, result5_id,calculate1_id,calculate2_id,calculate3_id,calculate4_id,calculate5_id,trained,tested from t_verification_task_detail
             where task_id = #{taskid}
     </select>
 

+ 8 - 0
cirs-ui/src/App.vue

@@ -25,4 +25,12 @@ export default {
 #app .theme-picker {
   display: none;
 }
+/*#app {*/
+/*  min-height: 100%;*/
+/*  background: radial-gradient(circle at 10% 20%, #3A71A8 0%,  rgb(239, 249, 249)90%);*/
+
+/*}*/
+
+
+
 </style>

+ 21 - 2
cirs-ui/src/api/biz/detail.js

@@ -43,11 +43,11 @@ export function delDetail(id) {
   })
 }
 
-export function verification(taskid,modelPath) {
+export function verification(taskid) {
   return request({
     url: '/biz/detail/verification',
     method: 'get',
-    params: {taskid,modelPath},
+    params: { taskid: taskid }
   })
 }
 export function getTraindataset(){
@@ -56,3 +56,22 @@ export function getTraindataset(){
     method:'get'
   })
 }
+
+// 修改验证任务详情
+export function updateDetails(dataset) {
+  return request({
+    url: '/biz/detail/updateDetails',
+    method: 'post',
+    data: dataset,
+
+  })
+}
+
+//得到运行验证任务详情
+export function getUpdatedDetails(taskids){
+  return request({
+    url:'/biz/detail/getUpdatedDetails',
+    method:'post',
+    data: taskids,
+  })
+}

+ 2 - 2
cirs-ui/src/api/biz/train.js

@@ -51,11 +51,11 @@ export function getComponentIds() {
   })
 }
 //训练按钮
-export function train(modelPath) {
+export function train() {
   return request({
     url:'/biz/train/train',
     method:'get',
-    params: modelPath
+
   })
 }
 

+ 1 - 1
cirs-ui/src/components/Pagination/index.vue

@@ -105,7 +105,7 @@ export default {
 
 <style scoped>
 .pagination-container {
-  background: #fff;
+  background: transparent !important;
   padding: 32px 16px;
 }
 .pagination-container.hidden {

+ 2 - 1
cirs-ui/src/views/biz/recommend/index.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="app-container">
-    <div>
+    <div style="padding-bottom: 8px">
     <el-select v-model="use_scene" placeholder="请选择使用场景" style="padding-right: 14px">
       <el-option
         v-for="item in options"
@@ -53,6 +53,7 @@
       :total="total"
       :page.sync="queryParams.pageNum"
       :limit.sync="queryParams.pageSize"
+
       @pagination="getList"
     />
     <el-dialog title="评分" :visible.sync="showevalatedialog" width="30%">

+ 181 - 53
cirs-ui/src/views/biz/task/index.vue

@@ -1,5 +1,6 @@
 <template>
   <div class="app-container">
+
     <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
       <el-form-item label="任务名称" prop="taskName">
         <el-input
@@ -134,7 +135,7 @@
           plain
           icon="el-icon-document"
           size="mini"
-          @click="traindata"
+          @click="gettraindata"
         >查询训练数据</el-button>
 
       </el-col>
@@ -145,7 +146,7 @@
           plain
           icon="el-icon-document"
           size="mini"
-          @click="verificationdata"
+          @click="getverificationdata"
         >查询验证数据</el-button>
 
       </el-col>
@@ -165,7 +166,7 @@
     </el-row>
 
     <el-table v-loading="loading" :data="taskList" @selection-change="handleSelectionChange">
-      <el-table-column type="selection" width="55" align="center" />
+      <el-table-column type="selection" width="55" align="center" class="custom-selection"/>
       <el-table-column label="任务编号" align="center" prop="id" />
       <el-table-column label="任务名称" align="center" prop="taskName" :show-overflow-tooltip='true'  />
       <el-table-column label="状态" align="center" prop="taskStatus" :show-overflow-tooltip='true' />
@@ -180,7 +181,17 @@
           <span>{{ parseTime(scope.row.endTime) }}</span>
         </template>
       </el-table-column>
-      <el-table-column label="完成率" align="center" prop="progress" />
+      <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' />
@@ -211,6 +222,7 @@
       :total="total"
       :page.sync="queryParams.pageNum"
       :limit.sync="queryParams.pageSize"
+
       @pagination="getList"
     />
     <!-- 任务详情导入对话框 -->
@@ -287,15 +299,54 @@
         <el-button @click="cancel">取 消</el-button>
       </div>
     </el-dialog>
-    <el-dialog title="训练数据" :visible.sync="traindatavisible" width="500px" append-to-body>
-      <div style="white-space: pre-wrap;font-size: 17px">
-        {{traindataset}}
-      </div>
+    <el-dialog title="训练数据" :visible.sync="traindatavisible" width="800px" append-to-body>
+
+      <el-table :data="traindataset" >
+        <el-table-column label="使用场景" align="center" prop="useScene" />
+        <el-table-column label="查询条件" align="center" prop="searchCondition" />
+        <el-table-column label="标准结果1" align="center" prop="result1" />
+        <el-table-column label="标准结果2" align="center" prop="result2" />
+        <el-table-column label="标准结果3" align="center" prop="result3" />
+        <el-table-column label="标准结果4" align="center" prop="result4" />
+        <el-table-column label="标准结果5" align="center" prop="result5" />
+        <el-table-column label="trained" align="center" >{{1}}</el-table-column>
+        <el-table-column label="tested" align="center" >{{0}}</el-table-column>
+      </el-table>
+
+      <pagination
+        v-show="ttotal>0"
+        :total="ttotal"
+        :page.sync="queryParams.pageNum"
+        :limit.sync="queryParams.pageSize"
+        @pagination="gettraindata"
+      />
     </el-dialog>
-    <el-dialog title="验证数据" :visible.sync="verificationdatavisible" width="500px" append-to-body>
-      <div style="white-space: pre-wrap;font-size: 17px">
-        {{verificationdataset}}
-      </div>
+    <el-dialog title="验证数据" :visible.sync="verificationdatavisible" width="800px" append-to-body>
+
+      <el-table :data="verificationtabledata" >
+        <el-table-column label="使用场景" align="center" prop="useScene" />
+        <el-table-column label="查询条件" align="center" prop="searchCondition" />
+        <el-table-column label="标准结果1" align="center" prop="result1" />
+        <el-table-column label="标准结果2" align="center" prop="result2" />
+        <el-table-column label="标准结果3" align="center" prop="result3" />
+        <el-table-column label="标准结果4" align="center" prop="result4" />
+        <el-table-column label="标准结果5" align="center" prop="result5" />
+        <el-table-column label="计算结果1" align="center" prop="calculate1" />
+        <el-table-column label="计算结果2" align="center" prop="calculate2" />
+        <el-table-column label="计算结果3" align="center" prop="calculate3" />
+        <el-table-column label="计算结果4" align="center" prop="calculate4" />
+        <el-table-column label="计算结果5" align="center" prop="calculate5" />
+
+        <el-table-column label="trained" align="center" >{{0}}</el-table-column>
+        <el-table-column label="tested" align="center" >{{1}}</el-table-column>
+      </el-table>
+      <pagination
+        v-show="vtotal>0"
+        :total="vtotal"
+        :page.sync="queryParams.pageNum"
+        :limit.sync="queryParams.pageSize"
+        @pagination="getverificationdata"
+      />
     </el-dialog>
   </div>
 
@@ -306,18 +357,21 @@
 
 <script>
 import { listTask, getTask, delTask, addTask, updateTask } from "@/api/biz/task";
-import { verification,getTraindataset } from "@/api/biz/detail";
+import { verification,getTraindataset,updateDetails,getUpdatedDetails } from "@/api/biz/detail";
 import { getToken } from "@/utils/auth";
 import {Loading, Message} from "element-ui";
 import service from "../../../utils/request";
 import errorCode from "../../../utils/errorCode";
 import dayjs from "dayjs";
+import {updateDetail} from "../../../api/biz/detail";
 export default {
   name: "Task",
   data() {
     return {
       // 遮罩层
       loading: true,
+      vloading:true,
+      tloading:true,
       // 选中数组
       ids: [],
       // 非单个禁用
@@ -328,6 +382,8 @@ export default {
       showSearch: true,
       // 总条数
       total: 0,
+      ttotal:0,
+      vtotal:0,
       // 验证任务表格数据
       taskList: [],
       // 弹出层标题
@@ -347,6 +403,7 @@ export default {
         accuracyRate: null,
         recallRate: null,
       },
+
       // 表单参数
       form: {},
       // 表单校验
@@ -370,69 +427,130 @@ export default {
       traindatavisible:false,
       verificationdatavisible:false,
       traindataset:[],
-      verificationdataset:[]
+      verificationdataset:[],
+      ProgressMap: [],
+      taskidToIndexMap: new Map(),
+      verificationtabledata:[],
     };
 
   },
   created() {
     this.getList();
   },
+  computed: {
+    progressStatus() {
+      return this.Progress === 100 ? 'success' : '';
+    },
+  },
   methods: {
 
-    traindata(){
+
+    gettraindata(){
       getTraindataset().then(res=>{
-        console.log(res)
-        this.traindataset = res.data
-        this.traindataset.id = undefined
+        this.traindatavisible = true
+        // console.log(res)
+
+          this.tloading = false
+          this.ttotal = res.total;
+          this.traindataset = res.rows
+
+
       })
-      this.traindatavisible = true
-    },
-    verificationdata(){
 
-      this.verificationdatavisible = true
     },
-    handleRun(){
-      let taskids = this.ids;
+    getverificationdata(){
 
-      const dayjs = require('dayjs');
-      for(let taskid of taskids){
-        // getTask(taskid).then(response => {
-        //
-        //   let task = response.data;
-        //   task.startTime = dayjs().format('YYYY-MM-DD HH:mm:ss');
-        //   setTimeout(()=>{
-        //     task.taskStatus = "运行成功"
-        //     task.endTime = dayjs().format('YYYY-MM-DD HH:mm:ss');
-        //     updateTask(task).then(res => {
-        //       this.$message.success("任务"+taskid+"运行成功!")
-        //
-        //       this.getList();
-        //     });
-        //   }, 3000);
-        //
-        // });
-        console.log(taskid)
-        verification(taskid,'D:\\checkpoint\\mymodel.pth').then(res=>{
-          console.log(res)
-          if(res.code===200){
-            this.$modal.msgSuccess(res.msg)
-            this.verificationdataset = res.data
-            this.verificationdataset.id = undefined
-          }
+      getUpdatedDetails(this.ids).then(res=>{
+        this.verificationdatavisible = true
 
-          else {
-            this.$modal.msgError(res.msg)
-          }
-        })
+        this.verificationtabledata = res.rows
+        this.vloading = false
+        this.vtotal = res.total;
 
+      })
 
+    },
+
+    handleRun() {
+      let taskids = this.ids;
+      const dayjs = require('dayjs');
+
+      for (let taskid of taskids) {
+        let index = this.taskidToIndexMap.get(taskid)
+        getTask(taskid).then(response => {
+
+          let task = response.data;
+          task.startTime = dayjs().format('YYYY-MM-DD HH:mm:ss');
+          let code = 0;
+          this.ProgressMap[index] = 0;
+          verification(taskid).then(res => {
+            console.log(res);
+            code = res.code;
+            if (res.code === 200) {
+              this.verificationdataset = JSON.parse(res.data).dataSet;
+              //更新任务详情表
+              updateDetails(this.verificationdataset).then(res1=>{
+                console.log(res1.msg)
+              })
+
+              console.log(this.verificationdataset)
+
+              task.accuracyRate = res.data.accuracyRate
+              task.recallRate = res.data.recallRate
+              //这里需要更新数据库task
+              updateTask(task).then(res2=>{
+                console.log(res2.msg)
+              })
+            }
+          });
+
+          // 使用闭包确保每个循环迭代中创建一个新的 taskid
+          const createInterval = (taskId) => {
+            // 模拟进度变化,每0.1秒更新一次,共更新100次
+            const intervalId = setInterval(() => {
+              let idx = this.taskidToIndexMap.get(taskId)
+              // this.ProgressMap[index] = this.ProgressMap[index] + 1
+              this.$set(this.ProgressMap, idx, this.ProgressMap[idx] + 1);
+              if(code!==200&&code!==0){
+                clearInterval(intervalId);
+                this.$message.error('任务' + taskId + '运行失败!');
+              }
+              // 如果进度达到100%,清除定时器并调用后端算法
+              if (this.ProgressMap[idx] >= 100) {
+                clearInterval(intervalId);
+                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);
+          };
+
+          // 调用闭包函数,传入当前的 taskid
+
+          createInterval(taskid);
+        });
       }
     },
+
     /** 查询验证任务列表 */
     getList() {
       this.loading = true;
       listTask(this.queryParams).then(response => {
         this.taskList = response.rows;
+        let task;
+        let idx = 0;
+        for(task of this.taskList){
+          this.taskidToIndexMap.set(task.id, idx)
+          // this.ProgressMap.push(task.progress)
+          this.ProgressMap.push(0)
+          idx++;
+        }
         this.total = response.total;
         this.loading = false;
       });
@@ -593,3 +711,13 @@ export default {
   }
 };
 </script>
+
+<style>
+
+ .el-checkbox__inner {
+  border-color: #8492a6 !important;
+}
+
+
+
+</style>

+ 40 - 8
cirs-ui/src/views/biz/train/index.vue

@@ -86,8 +86,9 @@
           v-hasPermi="['biz:train:export']"
         >导出</el-button>
       </el-col >
-      <el-col :span="1.5" style="padding-left: 500px">
+      <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>
 
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
@@ -128,6 +129,7 @@
       :total="total"
       :page.sync="queryParams.pageNum"
       :limit.sync="queryParams.pageSize"
+
       @pagination="getList"
     />
 
@@ -197,10 +199,12 @@
 <script>
 import { listTrain, getTrain, delTrain, addTrain, updateTrain,getComponentIds,train } from "@/api/biz/train";
 import { getToken } from "@/utils/auth";
+import dayjs from "dayjs";
 export default {
   name: "Train",
   data() {
     return {
+      Progress:0,
       // 导入参数
       upload: {
         // 是否显示弹出层(导入)
@@ -266,28 +270,46 @@ export default {
           label: '供货量最优'
         }
       ],
-      modelPath:'D:\\checkpoint\\mymodel.pth'
+
     };
   },
   created() {
     this.getList();
   },
+  computed: {
+    progressStatus() {
+      return this.Progress === 100 ? 'success' : '';
+    },
+  },
   methods: {
+
     mytrain() {
       getComponentIds().then(response=>{
+        let result;
+        train().then(res=>{
+          result = res
 
-        train({modelPath: this.modelPath}).then(res=>{
-          if(res.code===200)
-            this.$modal.msgSuccess(res.msg);
-          else {
-            this.$modal.msgError(res.msg);
-          }
         })
+        // 模拟进度变化,每0.1秒更新一次,共更新100次
+        const intervalId = setInterval(() => {
+
+          this.Progress++;
+          // 如果进度达到100%,清除定时器并调用后端算法
+          if (this.Progress >= 100) {
+            clearInterval(intervalId);
+            if(result.code===200)
+              this.$modal.msgSuccess(result.msg);
+            else {
+              this.$modal.msgError(result.msg);
+            }
+          }
+        }, 100);
       })
 
     },
     /** 查询训练集数据列列表 */
     getList() {
+      this.Progress = 0;
       this.loading = true;
       listTrain(this.queryParams).then(response => {
         this.trainList = response.rows;
@@ -411,3 +433,13 @@ export default {
   }
 };
 </script>
+<style>
+
+.el-checkbox__inner {
+  border-color: #8492a6 !important;
+}
+.app-container {
+  min-height: 100vh;
+  background: radial-gradient(circle at 10% 20%, #3A71A8 0%, rgb(239, 249, 249) 90%);
+}
+</style>

+ 14 - 10
cirs-ui/src/views/index.vue

@@ -12,7 +12,10 @@
       </el-carousel-item>
 
       <el-carousel-item >
-        <div style="width: 640px;height:400px;" id="piechart"></div>
+        <span v-if="ac===null" style="color:#FFFFFF">该任务还没有运行得到准确率和召回率</span>
+        <div style="width: 640px;height:400px;" id="piechart" >
+
+        </div>
 
       </el-carousel-item>
     </el-carousel>
@@ -164,6 +167,7 @@ import { get_top10} from "@/api/biz/evaluation";
 import { getComponent,getBycomponentId,addTime } from "@/api/biz/recommend";
 import {getLastTask} from '@/api/biz/task'
 import * as echarts from 'echarts'
+
 export default {
   name: "Index",
   data() {
@@ -248,15 +252,15 @@ export default {
         this.callback = res.data.recallRate;
         let chartDom = document.getElementById('piechart');
         let myChart = echarts.init(chartDom);
-        let ac;
-        let callback;
-
-        let endidx = this.ac.indexOf('%')
-
-        ac = endidx!==-1 ? parseFloat(this.ac)/100.0 : parseFloat(this.ac);
+        let ac = 0;
+        let callback = 0;
+        if(this.ac!==null&&this.callback!==null){
+          let endidx = this.ac.indexOf('%')
 
-        endidx = this.callback.indexOf('%')
-        callback = endidx!==-1 ? parseFloat(this.callback)/100.0 : parseFloat(this.callback);
+          ac = endidx!==-1 ? parseFloat(this.ac)/100.0 : parseFloat(this.ac);
+          endidx = this.callback.indexOf('%')
+          callback = endidx!==-1 ? parseFloat(this.callback)/100.0 : parseFloat(this.callback);
+        }
 
         let option;
         option = {
@@ -424,7 +428,7 @@ export default {
   }
 
   .el-carousel__item:nth-child(2n+1) {
-    background-color: #1a2c41;
+    background-color:#004d8c;
   }
 
 }