WangRuiLin 1 рік тому
батько
коміт
832781d9ca

+ 1 - 1
cirs-admin/src/main/resources/application-druid.yml

@@ -58,4 +58,4 @@ spring:
                     merge-sql: true
                 wall:
                     config:
-                        multi-statement-allow: true
+                        multi-statement-allow: trut

+ 1 - 0
cirs-biz/pom.xml

@@ -31,6 +31,7 @@
             <artifactId>reactor-netty-http</artifactId>
         </dependency>
 
+
     </dependencies>
 
 

+ 22 - 7
cirs-biz/src/main/java/com/cirs/biz/controller/FactoryScoreController.java

@@ -6,6 +6,9 @@ import java.util.List;
 import java.util.Map;
 import javax.servlet.http.HttpServletResponse;
 
+import com.alibaba.fastjson2.JSONObject;
+import com.cirs.biz.domain.TMarkingrecord;
+import com.cirs.biz.service.ITMarkingrecordService;
 import com.cirs.common.utils.DictUtils;
 import org.springframework.http.MediaType;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -43,6 +46,9 @@ public class FactoryScoreController extends BaseController
     @Autowired
     private IFactoryScoreService factoryScoreService;
 
+    @Autowired
+    private ITMarkingrecordService tMarkingrecordService;
+
     private WebClient webClient = WebClient.builder()
 //            .baseUrl("http://jsonplaceholder.typicode.com")
             .build();
@@ -176,9 +182,10 @@ public class FactoryScoreController extends BaseController
     }
 
     @PreAuthorize("@ss.hasPermi('biz:score:marking')")
-    @PostMapping ("/marking")
-    public AjaxResult marking(@RequestBody FactoryScore args) {
+    @GetMapping  ("/marking/{id}")
+    public AjaxResult marking(@PathVariable("id") Long id) {
         try {
+            TMarkingrecord args = tMarkingrecordService.selectTMarkingrecordById(id);
             String model_path = DictUtils.getDictValue("biz_factoryScore_algorithm_config","model_path");
             String marking_uri = DictUtils.getDictValue("biz_factoryScore_algorithm_config","marking_uri");
 
@@ -200,14 +207,22 @@ public class FactoryScoreController extends BaseController
 
 
             String res = mono.block();
+            JSONObject jsonObject = JSONObject.parseObject(res);
+            JSONObject object = jsonObject.getJSONObject("data").getJSONObject("dataSet");
+            TMarkingrecord markingrecord = JSONObject.parseObject(object.toJSONString(),TMarkingrecord.class);
+            tMarkingrecordService.updateTMarkingrecord(markingrecord);
             // // todo wangruilin 改成logger
             logger.info(res);
 
-            AjaxResult result = new AjaxResult();
-            result.put("msg","成功");
-            result.put("data",res);
-            result.put("code",200);
-            return result;
+//            AjaxResult result = new AjaxResult();
+//            result.put("msg","成功");
+//            result.put("data",res);
+//            result.put("code",200);
+            if(jsonObject.getIntValue("code")!=200){
+
+                throw new Exception();
+            }
+            return success(jsonObject.getString("msg"));
         } catch (Exception e) {
 
             return error("打分失败!");

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

@@ -241,7 +241,7 @@ public class SysTrainController extends BaseController
             objectMap.put("result5Id",recommend_args.getResult5Id());
             //接下来就传入算法
 //            System.out.println(JSON.toJSONString(objectMap));
-            logger.info("request payload: {}",JSON.toJSONString(objectMap));
+            // todo wangruilin uri 应该是一个全地址+端口,这个地址可以通过数据字典配置和获取
             Mono<String> mono = webClient
                     .post() // POST 请求
                     .uri(recommend_uri)  // 请求路径
@@ -251,7 +251,8 @@ public class SysTrainController extends BaseController
                     .bodyToMono(String.class); //响应数据类型转换
 
                 String res = mono.block();
-            logger.info(res);
+                // // todo wangruilin 改成logger
+                logger.info(res);
             AjaxResult result = new AjaxResult();
             result.put("data",res);
             result.put("code",200);

+ 22 - 0
cirs-biz/src/main/java/com/cirs/biz/controller/TMarkingrecordController.java

@@ -2,6 +2,8 @@ package com.cirs.biz.controller;
 
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
+
+import com.cirs.biz.domain.FactoryScore;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -20,6 +22,7 @@ import com.cirs.biz.domain.TMarkingrecord;
 import com.cirs.biz.service.ITMarkingrecordService;
 import com.cirs.common.utils.poi.ExcelUtil;
 import com.cirs.common.core.page.TableDataInfo;
+import org.springframework.web.multipart.MultipartFile;
 
 /**
  * 打分记录Controller
@@ -101,4 +104,23 @@ public class TMarkingrecordController extends BaseController
     {
         return toAjax(tMarkingrecordService.deleteTMarkingrecordByIds(ids));
     }
+
+    @PreAuthorize("@ss.hasPermi('biz:markingrecord:import')")
+    @PostMapping("/importData")
+    public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
+    {
+        ExcelUtil<TMarkingrecord> util = new ExcelUtil<TMarkingrecord>(TMarkingrecord.class);
+        List<TMarkingrecord> markingrecordList = util.importExcel(file.getInputStream());
+
+        String operName = getUsername();
+        String message = tMarkingrecordService.importMarkingrecord(markingrecordList, updateSupport, operName);
+        return success(message);
+    }
+
+    @PostMapping("/importTemplate")
+    public void importTemplate(HttpServletResponse response)
+    {
+        ExcelUtil<TMarkingrecord> util = new ExcelUtil<TMarkingrecord>(TMarkingrecord.class);
+        util.importTemplateExcel(response, "训练集数据");
+    }
 }

+ 27 - 9
cirs-biz/src/main/java/com/cirs/biz/controller/TVerificationScoretaskDetailController.java

@@ -1,15 +1,18 @@
 package com.cirs.biz.controller;
 
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import javax.servlet.http.HttpServletResponse;
-
+import com.cirs.biz.utils.WebClientUtils;
 import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
+import com.cirs.biz.domain.TVerificationScoretask;
 import com.cirs.biz.domain.TVerificationTaskDetail;
 import com.cirs.biz.domain.VerificationData;
-import com.cirs.biz.utils.WebClientUtils;
+import com.cirs.biz.service.ITVerificationScoretaskService;
 import com.cirs.common.utils.DictUtils;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
@@ -42,6 +45,9 @@ public class TVerificationScoretaskDetailController extends BaseController
     @Autowired
     private ITVerificationScoretaskDetailService tVerificationScoretaskDetailService;
 
+    @Autowired
+    private ITVerificationScoretaskService tVerificationScoretaskService;
+
     private WebClient webClient = WebClient.builder()
 //            .baseUrl("http://jsonplaceholder.typicode.com")
             .build();
@@ -144,8 +150,9 @@ public class TVerificationScoretaskDetailController extends BaseController
     @PreAuthorize("@ss.hasPermi('biz:scoretaskdetail:verification')")
     @GetMapping("/verification")
     public AjaxResult verification(Long taskid) {
-
+        TVerificationScoretask task = tVerificationScoretaskService.selectTVerificationScoretaskById(taskid);
         try {
+            task.setStartTime(new Date());
 
             String model_path = DictUtils.getDictValue("biz_factoryScore_algorithm_config","model_path");
             String verification_uri = DictUtils.getDictValue("biz_factoryScore_algorithm_config","verification_uri");
@@ -160,7 +167,6 @@ public class TVerificationScoretaskDetailController extends BaseController
             List<TVerificationScoretaskDetail> dataset = tVerificationScoretaskDetailService.getByscoretaskid(taskid);
             objectMap.put("dataSet", dataset);
             objectMap.put("modelPath", model_path);
-            logger.info("request payload: {}", JSON.toJSONString(objectMap));
             // 发送请求
             Mono<String> mono = WebClientUtils.createWebClient()
                     .post() // POST 请求
@@ -172,19 +178,31 @@ public class TVerificationScoretaskDetailController extends BaseController
 
             AjaxResult res = new AjaxResult();
             String result = mono.block();//返回值有accuracyRate和recallRate属性
+            JSONObject jsonObject = JSONObject.parseObject(result);
+            task.setEndTime(new Date());
+            task.setTaskStatus("运行成功");
 
-            res.put("data",result);
-            res.put("msg","打分任务"+taskid+"验证算法调用成功");
-            res.put("code",200);
 
+            JSONArray jsonArray =  jsonObject.getJSONObject("data").getJSONArray("dataSet");
+            task.setAccuracyRate(jsonObject.getJSONObject("data").getString("accuracyRate")+"%");
+            task.setRecallRate(jsonObject.getJSONObject("data").getString("recallRate")+"%");
+            List<TVerificationScoretaskDetail> dataSet = JSONArray.parseArray(jsonArray.toJSONString(),TVerificationScoretaskDetail.class);
+            tVerificationScoretaskService.updateTVerificationScoretask(task);
+            updateDetails(dataSet);
 //            System.out.println(result);
             logger.info(result);
-            return res;
+
+            if(jsonObject.getIntValue("code")!=200){
+
+                throw new Exception();
+            }
+            return success(jsonObject.getString("msg"));
 //            return success(returndata);
 
 //            return success("任务"+taskid+"验证算法调用成功");
         } catch (Exception e) {
-            logger.info("任务"+taskid+"验证算法调用失败",e);
+            task.setTaskStatus("运行失败");
+            tVerificationScoretaskService.updateTVerificationScoretask(task);
             return error("任务"+taskid+"验证算法调用失败");
         }
     }

+ 54 - 7
cirs-biz/src/main/java/com/cirs/biz/controller/TVerificationTaskDetailController.java

@@ -1,17 +1,24 @@
 package com.cirs.biz.controller;
 
+import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import javax.servlet.http.HttpServletResponse;
 
 
-import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
+import com.alibaba.fastjson2.JSONObject;
 import com.cirs.biz.domain.*;
 import com.cirs.biz.service.ITElectronComponentService;
+import com.cirs.biz.service.ITVerificationTaskService;
 import com.cirs.common.utils.DictUtils;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import jdk.nashorn.internal.parser.JSONParser;
 import org.springframework.http.MediaType;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -43,6 +50,9 @@ public class TVerificationTaskDetailController extends BaseController
     @Autowired
     private ITElectronComponentService tElectronComponentService;//之前写在元器件接口不太方便
 
+    @Autowired
+    private ITVerificationTaskService tVerificationTaskService;
+
     private WebClient webClient = WebClient.builder()
 //            .baseUrl("http://jsonplaceholder.typicode.com")
             .build();
@@ -167,18 +177,34 @@ public class TVerificationTaskDetailController extends BaseController
     @PreAuthorize("@ss.hasPermi('biz:detail:verification')")
     @GetMapping("/verification")
     public AjaxResult verification(Long taskid) {
-
+        TVerificationTask task = tVerificationTaskService.selectTVerificationTaskById(taskid);
         try {
 
+
+            task.setStartTime(new Date());
+
             String model_path = DictUtils.getDictValue("biz_algorithm_config","model_path");
             String verification_uri = DictUtils.getDictValue("biz_algorithm_config","verification_uri");
 
+
+//            logger.info(taskid.toString());
+//            System.out.println(taskid);
+
+//            getComponentIds(taskid);
             Map<String, Object> objectMap=new HashMap<>();
             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", model_path);
-            logger.info("request payload: {}", JSON.toJSONString(objectMap));
+            // 创建一个 ObjectMapper 实例
+//            ObjectMapper objectMapper = new ObjectMapper();
+
+// 将对象转换为 JSON 字符串
+//            String json = objectMapper.writeValueAsString(objectMap);
+//            logger.info("post json: {}", json);
             // 发送请求
             Mono<String> mono = webClient
                     .post() // POST 请求
@@ -190,25 +216,46 @@ public class TVerificationTaskDetailController extends BaseController
 
             AjaxResult res = new AjaxResult();
             String result = mono.block();//返回值有accuracyRate和recallRate属性
+            task.setEndTime(new Date());
+            task.setTaskStatus("运行成功");
+            JSONObject jsonObject = JSONObject.parseObject(result);
+
+            JSONArray jsonArray =  jsonObject.getJSONObject("data").getJSONArray("dataSet");
+            task.setAccuracyRate(jsonObject.getJSONObject("data").getString("accuracyRate")+"%");
+            task.setRecallRate(jsonObject.getJSONObject("data").getString("recallRate")+"%");
+
+            List<VerificationData> dataSet = JSONArray.parseArray(jsonArray.toJSONString(),VerificationData.class);
+
+            tVerificationTaskService.updateTVerificationTask(task);
+            updateDetails(dataSet);
+
 //
 //            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);
+//            res.put("data",result);
+//            res.put("msg","任务"+taskid+"验证算法调用成功");
+//            res.put("code",200);
             // todo System.out.println System.out.println应该使用logger框架替换
 //            System.out.println(result);
             logger.info(result);
-            return res;
+            if(jsonObject.getIntValue("code")!=200){
+
+                throw new Exception();
+            }
+            return success(jsonObject.getString("msg"));
 
 //            return success("任务"+taskid+"验证算法调用成功");
         } catch (Exception e) {
+            task.setTaskStatus("运行失败");
+            tVerificationTaskService.updateTVerificationTask(task);
             logger.error("任务"+taskid+"验证算法调用失败", e);
             return error("任务"+taskid+"验证算法调用失败");
         }
+
+
     }
 
 

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

@@ -58,4 +58,6 @@ public interface ITMarkingrecordService
      * @return 结果
      */
     public int deleteTMarkingrecordById(Long id);
+
+    public String importMarkingrecord(List<TMarkingrecord> markingrecordList, boolean updateSupport, String operName);
 }

+ 56 - 0
cirs-biz/src/main/java/com/cirs/biz/service/impl/TMarkingrecordServiceImpl.java

@@ -1,12 +1,21 @@
 package com.cirs.biz.service.impl;
 
 import java.util.List;
+
+import com.cirs.biz.domain.FactoryScore;
+import com.cirs.common.exception.ServiceException;
+import com.cirs.common.utils.StringUtils;
+import com.cirs.common.utils.bean.BeanValidators;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.cirs.biz.mapper.TMarkingrecordMapper;
 import com.cirs.biz.domain.TMarkingrecord;
 import com.cirs.biz.service.ITMarkingrecordService;
 
+import javax.validation.Validator;
+
 /**
  * 打分记录Service业务层处理
  * 
@@ -18,6 +27,10 @@ public class TMarkingrecordServiceImpl implements ITMarkingrecordService
 {
     @Autowired
     private TMarkingrecordMapper tMarkingrecordMapper;
+    private static final Logger log = LoggerFactory.getLogger(TMarkingrecordServiceImpl.class);
+
+    @Autowired
+    protected Validator validator;
 
     /**
      * 查询打分记录
@@ -90,4 +103,47 @@ public class TMarkingrecordServiceImpl implements ITMarkingrecordService
     {
         return tMarkingrecordMapper.deleteTMarkingrecordById(id);
     }
+
+    @Override
+    public String importMarkingrecord(List<TMarkingrecord> markingrecordList, boolean updateSupport, String operName) {
+        if (StringUtils.isNull(markingrecordList) || markingrecordList.size() == 0)
+        {
+            throw new ServiceException("导入元器件数据不能为空!");
+        }
+        int successNum = 0;
+        int failureNum = 0;
+        StringBuilder successMsg = new StringBuilder();
+        StringBuilder failureMsg = new StringBuilder();
+
+        for (TMarkingrecord markingrecord : markingrecordList)
+        {
+            try
+            {
+
+                BeanValidators.validateWithException(validator, markingrecord);
+                markingrecord.setCreateBy(operName);
+                tMarkingrecordMapper.insertTMarkingrecord(markingrecord);
+                successNum++;
+//                successMsg.append("<br/>" + successNum + "、训练数据 " + score.getId() + " 导入成功");
+
+            }
+            catch (Exception e)
+            {
+                failureNum++;
+                String msg = "<br/>" + failureNum + "、训练数据 " + markingrecord.getId() + " 导入失败:";
+                failureMsg.append(msg + e.getMessage());
+                log.error(msg, e);
+            }
+        }
+        if (failureNum > 0)
+        {
+            failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
+            throw new ServiceException(failureMsg.toString());
+        }
+        else
+        {
+            successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条");
+        }
+        return successMsg.toString();
+    }
 }

+ 2 - 2
cirs-biz/src/main/java/com/cirs/biz/service/impl/TVerificationTaskDetailServiceImpl.java

@@ -212,8 +212,8 @@ public class TVerificationTaskDetailServiceImpl implements ITVerificationTaskDet
 
     @Override
     public Long setComponentId(String result) {
-//        String[] attrs = result.split("-");//切割不同属性
-        return tVerificationTaskDetailMapper.getComponentId(result, null, null);
+        String[] attrs = result.split("-");//切割不同属性
+        return tVerificationTaskDetailMapper.getComponentId(attrs[0], attrs.length >= 2 ? attrs[1] : null, attrs.length >= 3 ? attrs[2] : null);
     }
 
     @Override

+ 4 - 4
cirs-biz/src/main/java/com/cirs/biz/utils/WebClientUtils.java

@@ -24,9 +24,9 @@ public class WebClientUtils {
     public static WebClient createWebClient() {
 
         return WebClient.builder().exchangeStrategies(ExchangeStrategies.builder()
-                        .codecs(configurer -> configurer
-                                .defaultCodecs()
-                                .maxInMemorySize(10 * 1024 * 1024))
-                        .build()).build();
+                .codecs(configurer -> configurer
+                        .defaultCodecs()
+                        .maxInMemorySize(10 * 1024 * 1024))
+                .build()).build();
     }
 }

+ 3 - 4
cirs-ui/src/api/biz/score.js

@@ -53,11 +53,10 @@ export function train() {
 }
 
 //推荐按钮
-export function marking(args) {
+export function marking(id) {
   return request({
-    url: '/biz/score/marking',
-    method: 'post',
-    data: args,
+    url: '/biz/score/marking/' + id,
+    method: 'get',
 
   })
 }

+ 93 - 13
cirs-ui/src/views/biz/marking/index.vue

@@ -34,6 +34,15 @@
           v-hasPermi="['biz:markingrecord:remove']"
         >删除</el-button>
       </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="info"
+          icon="el-icon-upload2"
+          size="mini"
+          @click="handleImport"
+          v-hasPermi="['biz:markingrecord:import']"
+        >导入</el-button>
+      </el-col>
       <el-col :span="1.5">
         <el-button
           type="warning"
@@ -460,7 +469,36 @@
         <el-button @click="cancel">取 消</el-button>
       </div>
     </el-dialog>
-
+    <!-- 数据导入对话框 -->
+    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px">
+      <el-upload
+        ref="upload"
+        :limit="1"
+        accept=".xlsx, .xls"
+        :headers="upload.headers"
+        :action="upload.url + '?updateSupport=' + upload.updateSupport"
+        :disabled="upload.isUploading"
+        :on-progress="handleFileUploadProgress"
+        :on-success="handleFileSuccess"
+        :auto-upload="false"
+        drag
+      >
+        <i class="el-icon-upload"></i>
+        <div class="el-upload__text">
+          将文件拖到此处,或
+          <em>点击上传</em>
+        </div>
+        <div class="el-upload__tip" slot="tip">
+          <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的数据
+          <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
+        </div>
+        <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
+      </el-upload>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitFileForm">确 定</el-button>
+        <el-button @click="upload.open = false">取 消</el-button>
+      </div>
+    </el-dialog>
 
     <el-table v-loading="loading" :data="List" @selection-change="handleSelectionChange">
       <el-table-column type="selection" width="55" align="center" />
@@ -526,6 +564,7 @@
             @click="handleDelete(scope.row)"
             v-hasPermi="['biz:markingrecord:remove']"
           >删除</el-button>
+
         </template>
       </el-table-column>
     </el-table>
@@ -557,6 +596,7 @@
 
 import { marking } from "@/api/biz/score";
 import { listMarkingrecord, getMarkingrecord, delMarkingrecord, addMarkingrecord, updateMarkingrecord } from "@/api/biz/markingrecord";
+import { getToken } from "@/utils/auth";
 export default {
   name: "recommend",
   data() {
@@ -578,7 +618,21 @@ export default {
       // 元器件数据
       List: [
       ],
-
+      // 导入参数
+      upload: {
+        // 是否显示弹出层(导入)
+        open: false,
+        // 弹出层标题(导入)
+        title: "",
+        // 是否禁用上传
+        isUploading: false,
+        // 是否更新已经存在的用户数据
+        updateSupport: 0,
+        // 设置上传的请求头部
+        headers: { Authorization: "Bearer " + getToken() },
+        // 上传的地址
+        url: process.env.VUE_APP_BASE_API + "/biz/markingrecord/importData"
+      },
 
       // 是否显示弹出层
       open: false,
@@ -628,18 +682,18 @@ export default {
         return ;
       }
       let result;
-      getMarkingrecord(this.ids[0]).then(response=>{
-        this.form = response.data
-        console.log(this.form)
-        marking(this.form).then(res=>{
+      // getMarkingrecord(this.ids[0]).then(response=>{
+      //   this.form = response.data
+      //   console.log(this.form)
+        marking(this.ids[0]).then(res=>{
           result = res
-          if(res.code===200&&JSON.parse(res.data).code===200) {
-            this.form = JSON.parse(res.data).data.dataSet
-            updateMarkingrecord(this.form).then(updateres=>{
-              this.$modal.msgSuccess("调用打分算法成功")
+          if(res.code===200) {
+            // this.form = JSON.parse(res.data).data.dataSet
+            // updateMarkingrecord(this.form).then(updateres=>{
+            this.$modal.msgSuccess(res.msg)
 
-              this.getList()
-            })
+            this.getList()
+            // })
             // console.log(this.form)
             // this.List.push(this.form)
             // this.$set(this.List,0,this.form)
@@ -652,7 +706,7 @@ export default {
 
 
         })
-      })
+      // })
 
 
       // 模拟进度变化,每0.0.5秒更新一次,共更新100次
@@ -741,7 +795,33 @@ export default {
         ...this.queryParams
       }, `markingrecord_${new Date().getTime()}.xlsx`)
     },
+    /** 下载模板操作 */
+    importTemplate() {
+      this.download('biz/markingrecord/importTemplate', {
+      }, `markingrecord_template_${new Date().getTime()}.xlsx`)
+    },
 
+    /** 导入按钮操作 */
+    handleImport() {
+      this.upload.title = "训练数据集导入";
+      this.upload.open = true;
+    },
+    // 文件上传中处理
+    handleFileUploadProgress(event, file, fileList) {
+      this.upload.isUploading = true;
+    },
+    // 文件上传成功处理
+    handleFileSuccess(response, file, fileList) {
+      this.upload.open = false;
+      this.upload.isUploading = false;
+      this.$refs.upload.clearFiles();
+      this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
+      this.getList();
+    },
+    // 提交上传文件
+    submitFileForm() {
+      this.$refs.upload.submit();
+    },
 
 
     // 取消按钮

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

@@ -117,43 +117,43 @@
                           readonly>
           </el-date-picker>
         </el-form-item>
-        <el-form-item label="阻值" prop="resistanceValue">
+        <el-form-item label="阻值" prop="resistanceValue" v-if="form.resistanceValue!==null && form.resistanceValue!==''">
           <el-input v-model="form.resistanceValue" readonly />
         </el-form-item>
-        <el-form-item label="精度" prop="resistancePrecision">
+        <el-form-item label="精度" prop="resistancePrecision" v-if="form.resistancePrecision!==null && form.resistancePrecision!==''">
           <el-input v-model="form.resistancePrecision" readonly />
         </el-form-item>
-        <el-form-item label="电阻温度特性" prop="resistanceTemperature">
+        <el-form-item label="电阻温度特性" prop="resistanceTemperature" v-if="form.resistanceTemperature!==null && form.resistanceTemperature!==''">
           <el-input v-model="form.resistanceTemperature" readonly />
         </el-form-item>
-        <el-form-item label="功耗" prop="resistancePower">
+        <el-form-item label="功耗" prop="resistancePower" v-if="form.resistancePower!==null && form.resistancePower!==''">
           <el-input v-model="form.resistancePower" readonly />
         </el-form-item>
-        <el-form-item label="封装形式" prop="encapsulationMode">
+        <el-form-item label="封装形式" prop="encapsulationMode" v-if="form.encapsulationMode!==null && form.encapsulationMode!==''">
           <el-input v-model="form.encapsulationMode" readonly />
         </el-form-item>
-        <el-form-item label="电容量Cp" prop="capacitanceValue">
+        <el-form-item label="电容量Cp" prop="capacitanceValue" v-if="form.capacitanceValue!==null && form.capacitanceValue!==''">
           <el-input v-model="form.capacitanceValue" readonly />
         </el-form-item>
-        <el-form-item label="损耗DF" prop="capacitanceLoss">
+        <el-form-item label="损耗DF" prop="capacitanceLoss" v-if="form.capacitanceLoss!==null && form.capacitanceLoss!==''">
           <el-input v-model="form.capacitanceLoss" readonly />
         </el-form-item>
-        <el-form-item label="温度系数" prop="temperatureCoefficient">
+        <el-form-item label="温度系数" prop="temperatureCoefficient" v-if="form.temperatureCoefficient!==null && form.temperatureCoefficient!==''">
           <el-input v-model="form.temperatureCoefficient" readonly />
         </el-form-item>
-        <el-form-item label="额定电压WVDC" prop="ratedVoltage">
+        <el-form-item label="额定电压WVDC" prop="ratedVoltage" v-if="form.ratedVoltage!==null && form.ratedVoltage!==''">
           <el-input v-model="form.ratedVoltage" readonly />
         </el-form-item>
-        <el-form-item label="电感量" prop="inductance">
+        <el-form-item label="电感量" prop="inductance" v-if="form.inductance!==null && form.inductance!==''">
           <el-input v-model="form.inductance" readonly />
         </el-form-item>
-        <el-form-item label="品质因数Qmin" prop="qualityFactor">
+        <el-form-item label="品质因数Qmin" prop="qualityFactor" v-if="form.qualityFactor!==null && form.qualityFactor!==''">
           <el-input v-model="form.qualityFactor" readonly />
         </el-form-item>
-        <el-form-item label="直流电阻" prop="dcResistance">
+        <el-form-item label="直流电阻" prop="dcResistance" v-if="form.dcResistance!==null && form.dcResistance!==''">
           <el-input v-model="form.dcResistance" readonly />
         </el-form-item>
-        <el-form-item label="额定电流" prop="ratedCurrent">
+        <el-form-item label="额定电流" prop="ratedCurrent" v-if="form.ratedCurrent!==null && form.ratedCurrent!==''">
           <el-input v-model="form.ratedCurrent" readonly />
         </el-form-item>
         <el-form-item label="最大正向电流IFM" prop="paramIfm" v-if="form.paramIfm!==null && form.paramIfm!==''">
@@ -368,7 +368,7 @@ export default {
         // console.log(res.code)
         if(res.code===200&&JSON.parse(res.data).code===200) {
           this.recommmend_args = JSON.parse(res.data).data
-          // console.log(this.recommmend_args)
+          console.log(this.recommmend_args)
           // this.queryParams.result1Id = 53
           this.queryParams.result1Id = this.recommmend_args.result1Id
           this.queryParams.result2Id = this.recommmend_args.result2Id

+ 30 - 30
cirs-ui/src/views/biz/scoretask/index.vue

@@ -91,12 +91,12 @@
       <el-table-column label="任务数" align="center" prop="subtaskNum" />
       <el-table-column label="开始时间" align="center" prop="startTime" width="180">
         <template slot-scope="scope">
-          <span>{{ parseTime(scope.row.startTime, '{y}-{m}-{d}') }}</span>
+          <span>{{ parseTime(scope.row.startTime) }}</span>
         </template>
       </el-table-column>
       <el-table-column label="结束时间" align="center" prop="endTime" width="180">
         <template slot-scope="scope">
-          <span>{{ parseTime(scope.row.endTime, '{y}-{m}-{d}') }}</span>
+          <span>{{ parseTime(scope.row.endTime) }}</span>
         </template>
       </el-table-column>
       <el-table-column label="完成率" align="center" prop="progress" />
@@ -497,35 +497,35 @@ export default {
 
       for (let taskid of taskids) {
         let index = this.taskidToIndexMap.get(taskid)
-        getScoretask(taskid).then(response => {
-
-          let task = response.data;
-          task.startTime = dayjs().format('YYYY-MM-DD HH:mm:ss');
+        // getScoretask(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 = JSON.parse(res.data).code;
-            if (res.code === 200&&code===200) {
-              this.verificationdataset = JSON.parse(res.data).data.dataSet;
-              console.log(this.verificationdataset)
-              //更新任务详情表
-              updateDetails(this.verificationdataset).then(res1=>{
-                console.log(res1.msg)
-              })
-
-              // 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
-              updateScoretask(task).then(res2=>{
-                console.log(res2.msg)
-              })
-            }
+            // console.log(res);
+            code = res.code;
+            // if (res.code === 200&&code===200) {
+            //   this.verificationdataset = JSON.parse(res.data).data.dataSet;
+            //   console.log(this.verificationdataset)
+            //   //更新任务详情表
+            //   updateDetails(this.verificationdataset).then(res1=>{
+            //     console.log(res1.msg)
+            //   })
+            //
+            //   // 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
+            //   updateScoretask(task).then(res2=>{
+            //     console.log(res2.msg)
+            //   })
+            // }
           });
 
           // 使用闭包确保每个循环迭代中创建一个新的 taskid
@@ -535,7 +535,7 @@ export default {
               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){
+              if(code!==200){
                 clearInterval(intervalId);
                 this.$message.error('任务' + taskId + '运行失败!'+' '+'该任务导入的数据很可能不足!');
               }
@@ -557,7 +557,7 @@ export default {
           // 调用闭包函数,传入当前的 taskid
 
           createInterval(taskid);
-        });
+        // });
       }
     },
     /** 查询打分算法验证任务列表 */

+ 25 - 26
cirs-ui/src/views/biz/task/index.vue

@@ -517,40 +517,39 @@ export default {
 
       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');
+        // 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.data)
-            console.log(JSON.parse(res.data))
-            let result = JSON.parse(res.data).data
-            code = JSON.parse(res.data).code;
-            if (res.code === 200&&code===200) {
+            // let result = JSON.parse(res.data).data
+            // code = JSON.parse(res.data).code;
+            code = res.code;
+            // if (res.code === 200) {
 
-              this.verificationdataset = result.dataSet;
-              console.log(this.verificationdataset)
+              // this.verificationdataset = result.dataSet;
+              // console.log(this.verificationdataset)
               //更新任务详情表
-              updateDetails(this.verificationdataset).then(res1=>{
-                console.log('updateDetails:'+res1.msg)
-              })
+              // updateDetails(this.verificationdataset).then(res1=>{
+              //   console.log('updateDetails:'+res1.msg)
+              // })
 
               // console.log(this.verificationdataset)
 
-              task.accuracyRate = result.accuracyRate+'%'
-              task.recallRate = result.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)
-              })
-            }
+              // task.accuracyRate = result.accuracyRate+'%'
+              // task.recallRate = result.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)
+              // })
+            // }
           });
 
           // 使用闭包确保每个循环迭代中创建一个新的 taskid
@@ -560,7 +559,7 @@ export default {
               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){
+              if(code!==200){
                 clearInterval(intervalId);
                 this.$message.error('任务' + taskId + '运行失败!'+' '+'该任务导入的数据很可能不足!');
               }
@@ -582,7 +581,7 @@ export default {
           // 调用闭包函数,传入当前的 taskid
 
           createInterval(taskid);
-        });
+        // });
       }
     },