1
0

3 Commits eaa448dd5b ... c84031d938

Autor SHA1 Nachricht Datum
  twzydn20000928 c84031d938 运行matlab算法功能 vor 2 Jahren
  twzydn20000928 fa5fde0867 运行matlab算法功能 vor 2 Jahren
  twzydn20000928 da1a01ef8d 处理时间和日志 vor 2 Jahren
24 geänderte Dateien mit 480 neuen und 109 gelöschten Zeilen
  1. 3 1
      pdaaphm-admin/src/main/java/com/pdaaphm/PdaaphmApplication.java
  2. 2 1
      pdaaphm-admin/src/main/java/com/pdaaphm/biz/controller/AlgorithmController.java
  3. 16 7
      pdaaphm-admin/src/main/java/com/pdaaphm/biz/domain/Algorithm.java
  4. 7 5
      pdaaphm-admin/src/main/java/com/pdaaphm/biz/domain/AlgorithmIoField.java
  5. 2 0
      pdaaphm-admin/src/main/java/com/pdaaphm/biz/domain/AlgorithmSubType.java
  6. 11 9
      pdaaphm-admin/src/main/java/com/pdaaphm/biz/domain/File.java
  7. 10 6
      pdaaphm-admin/src/main/java/com/pdaaphm/biz/dto/AlgorithmDTO.java
  8. 5 0
      pdaaphm-admin/src/main/java/com/pdaaphm/biz/dto/SubAlgorithmDTO.java
  9. 3 2
      pdaaphm-admin/src/main/java/com/pdaaphm/biz/factory/AlgorithmFactory.java
  10. 8 1
      pdaaphm-admin/src/main/java/com/pdaaphm/biz/mapper/AlgorithmIoFieldMapper.java
  11. 11 4
      pdaaphm-admin/src/main/java/com/pdaaphm/biz/mapper/AlgorithmMapper.java
  12. 2 1
      pdaaphm-admin/src/main/java/com/pdaaphm/biz/service/IAlgorithmService.java
  13. 19 13
      pdaaphm-admin/src/main/java/com/pdaaphm/biz/service/impl/AlgorithmServiceImpl.java
  14. 178 4
      pdaaphm-admin/src/main/java/com/pdaaphm/biz/service/impl/RunMatlabImpl.java
  15. 9 12
      pdaaphm-admin/src/main/java/com/pdaaphm/biz/service/impl/RunPythonImpl.java
  16. 16 6
      pdaaphm-admin/src/main/java/com/pdaaphm/web/controller/common/CommonController.java
  17. 45 1
      pdaaphm-admin/src/main/resources/mapper/algoManager/AlgorithmMapper.xml
  18. 35 2
      pdaaphm-admin/src/main/resources/mapper/conf/AlgorithmIoFieldMapper.xml
  19. 7 2
      pdaaphm-common/src/main/java/com/pdaaphm/common/constant/Constants.java
  20. 15 14
      pdaaphm-common/src/main/java/com/pdaaphm/common/utils/file/FileUtils.java
  21. 1 1
      pdaaphm-ui/src/api/conf/field.js
  22. 51 9
      pdaaphm-ui/src/views/algoManager/algorithm/index.vue
  23. 8 3
      pdaaphm-ui/src/views/conf/field/index.vue
  24. 16 5
      pdaaphm-ui/src/views/conf/subType/index.vue

+ 3 - 1
pdaaphm-admin/src/main/java/com/pdaaphm/PdaaphmApplication.java

@@ -3,13 +3,15 @@ package com.pdaaphm;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+import org.springframework.scheduling.annotation.EnableAsync;
 
 /**
  * 启动程序
- * 
+ *
  * @author Allen
  */
 @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
+@EnableAsync
 public class PdaaphmApplication
 {
     public static void main(String[] args)

+ 2 - 1
pdaaphm-admin/src/main/java/com/pdaaphm/biz/controller/AlgorithmController.java

@@ -134,6 +134,7 @@ public class AlgorithmController extends BaseController
     @Log(title = "算法", businessType = BusinessType.UPDATE)
     @GetMapping(value = "/runAlgorithms/{id}")
     public AjaxResult runAlgorithms(@PathVariable("id") Long id) throws IOException {
-        return success(algorithmService.runAlgorithms(id));
+        algorithmService.runAlgorithms(id);
+        return success();
     }
 }

+ 16 - 7
pdaaphm-admin/src/main/java/com/pdaaphm/biz/domain/Algorithm.java

@@ -3,8 +3,6 @@ package com.pdaaphm.biz.domain;
 import java.util.Date;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
 import com.pdaaphm.common.annotation.Excel;
 import com.pdaaphm.common.core.domain.BaseEntity;
 
@@ -12,12 +10,15 @@ import com.pdaaphm.common.core.domain.BaseEntity;
  * 算法对象 t_algorithm
  *
  * @author xlk
- * @date 2023-07-26
+ * @date 2023-08-16
  */
 @Data
 public class Algorithm extends BaseEntity
 {
     private static final long serialVersionUID = 1L;
+    public static String createdCode = "0";
+    public static String runningCode = "1";
+    public static String completedCode = "2";
 
     /** 编号 */
     private Long id;
@@ -34,14 +35,22 @@ public class Algorithm extends BaseEntity
     @Excel(name = "名称")
     private String name;
 
+    /** 算法运行状态 */
+    @Excel(name = "算法运行状态")
+    private String status;
+
+    /** 算法错误原因 */
+    @Excel(name = "算法错误原因")
+    private String error;
+
     /** 开始时间 */
-    @JsonFormat(pattern = "yyyy-MM-dd")
-    @Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
     private Date startTime;
 
     /** 完成时间 */
-    @JsonFormat(pattern = "yyyy-MM-dd")
-    @Excel(name = "完成时间", width = 30, dateFormat = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "完成时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
     private Date completedTime;
 
     /** 耗时(s) */

+ 7 - 5
pdaaphm-admin/src/main/java/com/pdaaphm/biz/domain/AlgorithmIoField.java

@@ -1,9 +1,5 @@
 package com.pdaaphm.biz.domain;
-
-import com.pdaaphm.common.annotation.DataSource;
 import lombok.Data;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
 import com.pdaaphm.common.annotation.Excel;
 import com.pdaaphm.common.core.domain.BaseEntity;
 
@@ -11,12 +7,14 @@ import com.pdaaphm.common.core.domain.BaseEntity;
  * 算法输入输出字段对象 t_algorithm_io_field
  *
  * @author xlk
- * @date 2023-07-26
+ * @date 2023-08-17
  */
 @Data
 public class AlgorithmIoField extends BaseEntity
 {
     private static final long serialVersionUID = 1L;
+    public static String inputCode = "1";
+    public static String outputCode = "2";
 
     /** 编号 */
     private Long id;
@@ -40,4 +38,8 @@ public class AlgorithmIoField extends BaseEntity
     /** 算法子类型名称 */
     @Excel(name = "算法子类型名称")
     private String algoSubName;
+
+    /** matlab文件独有的输入输入路径 */
+    @Excel(name = "matlab文件独有的输入输入路径")
+    private String matlabIoPath;
 }

+ 2 - 0
pdaaphm-admin/src/main/java/com/pdaaphm/biz/domain/AlgorithmSubType.java

@@ -14,6 +14,8 @@ import com.pdaaphm.common.core.domain.BaseEntity;
 public class AlgorithmSubType extends BaseEntity
 {
     private static final long serialVersionUID = 1L;
+    public static String pythonCode = "1";
+    public static String matlabCode = "2";
 
     /** 编号 */
     private Long id;

+ 11 - 9
pdaaphm-admin/src/main/java/com/pdaaphm/biz/domain/File.java

@@ -7,13 +7,15 @@ import com.pdaaphm.common.core.domain.BaseEntity;
 
 /**
  * 文件对象 t_file
- * 
+ *
  * @author xlk
  * @date 2023-07-26
  */
 public class File extends BaseEntity
 {
     private static final long serialVersionUID = 1L;
+    public static String inputFlag = "1";
+    public static String ouputFlag = "2";
 
     /** 编号 */
     private Long id;
@@ -30,39 +32,39 @@ public class File extends BaseEntity
     @Excel(name = "类型")
     private String type;
 
-    public void setId(Long id) 
+    public void setId(Long id)
     {
         this.id = id;
     }
 
-    public Long getId() 
+    public Long getId()
     {
         return id;
     }
-    public void setName(String name) 
+    public void setName(String name)
     {
         this.name = name;
     }
 
-    public String getName() 
+    public String getName()
     {
         return name;
     }
-    public void setPath(String path) 
+    public void setPath(String path)
     {
         this.path = path;
     }
 
-    public String getPath() 
+    public String getPath()
     {
         return path;
     }
-    public void setType(String type) 
+    public void setType(String type)
     {
         this.type = type;
     }
 
-    public String getType() 
+    public String getType()
     {
         return type;
     }

+ 10 - 6
pdaaphm-admin/src/main/java/com/pdaaphm/biz/dto/AlgorithmDTO.java

@@ -1,7 +1,6 @@
 package com.pdaaphm.biz.dto;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
-import com.fasterxml.jackson.annotation.JsonIgnore;
 import lombok.Data;
 
 import java.util.Date;
@@ -35,9 +34,16 @@ public class AlgorithmDTO {
     /** 算法子类型名称 */
     private String algoSubName;
 
-    /** 搜索值 */
-    @JsonIgnore
-    private String searchValue;
+    /**
+     * 算法运行状态
+     */
+    private String status;
+
+    /**
+     * 输入输出文件子列表
+     */
+    private List<SubAlgorithmDTO> ioSubList;
+
 
     /** 创建者 */
     private String createBy;
@@ -55,6 +61,4 @@ public class AlgorithmDTO {
 
     /** 备注 */
     private String remark;
-
-    private List<SubAlgorithmDTO> ioSubList;
 }

+ 5 - 0
pdaaphm-admin/src/main/java/com/pdaaphm/biz/dto/SubAlgorithmDTO.java

@@ -29,6 +29,11 @@ public class SubAlgorithmDTO {
      */
     private String type;
 
+    /**
+     * 文件路径
+     */
+    private String path;
+
 
     /** 创建者 */
     private String createBy;

+ 3 - 2
pdaaphm-admin/src/main/java/com/pdaaphm/biz/factory/AlgorithmFactory.java

@@ -1,5 +1,6 @@
 package com.pdaaphm.biz.factory;
 
+import com.pdaaphm.biz.domain.AlgorithmSubType;
 import com.pdaaphm.biz.service.RunAlgorithmService;
 import com.pdaaphm.biz.service.impl.RunMatlabImpl;
 import com.pdaaphm.biz.service.impl.RunPythonImpl;
@@ -14,9 +15,9 @@ public class AlgorithmFactory {
     private RunPythonImpl runPythonImpl;
 
     public RunAlgorithmService createRun(String type) {
-        if ("1".equals(type)) {
+        if (AlgorithmSubType.pythonCode.equals(type)) {
             return runPythonImpl;
-        } else if ("2".equals(type)) {
+        } else if (AlgorithmSubType.matlabCode.equals(type)) {
             return runMatlabImpl;
         } else {
             return null;

+ 8 - 1
pdaaphm-admin/src/main/java/com/pdaaphm/biz/mapper/AlgorithmIoFieldMapper.java

@@ -63,5 +63,12 @@ public interface AlgorithmIoFieldMapper
      */
     public int deleteAlgorithmIoFieldByIds(Long[] ids);
 
-    List<SubAlgorithmDTO> getIoSubList(@Param("subTypeId") Long subTypeId,@Param("algoId") Long algoId);
+    public List<SubAlgorithmDTO> getIoSubList(@Param("subTypeId") Long subTypeId,@Param("algoId") Long algoId);
+
+    /**
+     * 根据算法id查询MatlabIoPath,Type和Index,以构建matlab完整绝对路径
+     * @param id
+     * @return
+     */
+    public List<Map> selectMatlabIoPathTypeIndexByAlgoId(Long id);
 }

+ 11 - 4
pdaaphm-admin/src/main/java/com/pdaaphm/biz/mapper/AlgorithmMapper.java

@@ -1,16 +1,17 @@
 package com.pdaaphm.biz.mapper;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
 import com.pdaaphm.biz.domain.Algorithm;
-import com.pdaaphm.biz.dto.AlgorithmDTO;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * 算法Mapper接口
  *
  * @author xlk
- * @date 2023-07-26
+ * @date 2023-08-16
  */
 public interface AlgorithmMapper
 {
@@ -64,7 +65,13 @@ public interface AlgorithmMapper
 
     public List<Map> getOption();
 
-    public int runAlgorithm(Long id);
-
     public List<Map> selectUrlAndAddressById(Long id);
+
+    public void updateStartTimeById(@Param("id") Long id, @Param("startTime") Date startTime);
+
+    public void updateCompletedTimeById(@Param("id") Long id, @Param("completedTime") Date completedTime);
+
+    public void updateCostSecondById(@Param("id") Long id, @Param("costSecond") Long costSecond);
+
+    public void updateStatusById(@Param("id") Long id, @Param("statusCode") String statusCode);
 }

+ 2 - 1
pdaaphm-admin/src/main/java/com/pdaaphm/biz/service/IAlgorithmService.java

@@ -6,6 +6,7 @@ import java.util.Map;
 
 import com.pdaaphm.biz.domain.Algorithm;
 import com.pdaaphm.biz.dto.AlgorithmDTO;
+import org.springframework.scheduling.annotation.Async;
 
 /**
  * 算法Service接口
@@ -81,5 +82,5 @@ public interface IAlgorithmService
      */
     public AlgorithmDTO getAlgorithmDto(Long id);
 
-    public int runAlgorithms(Long id) throws IOException;
+    public void runAlgorithms(Long id) throws IOException;
 }

+ 19 - 13
pdaaphm-admin/src/main/java/com/pdaaphm/biz/service/impl/AlgorithmServiceImpl.java

@@ -2,9 +2,12 @@ package com.pdaaphm.biz.service.impl;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
 
+import com.pdaaphm.biz.domain.AlgorithmIoField;
 import com.pdaaphm.biz.domain.AlgorithmSubType;
 import com.pdaaphm.biz.domain.SubAlgorithm;
 import com.pdaaphm.biz.dto.AlgorithmDTO;
@@ -20,6 +23,7 @@ import com.pdaaphm.common.utils.DateUtils;
 import com.pdaaphm.common.utils.file.FileUploadUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import com.pdaaphm.biz.mapper.AlgorithmMapper;
 import com.pdaaphm.biz.domain.Algorithm;
@@ -97,13 +101,12 @@ public class AlgorithmServiceImpl implements IAlgorithmService
     public int insertAlgorithm(Algorithm algorithm)
     {
         algorithm.setCreateTime(DateUtils.getNowDate());
+        algorithm.setStatus(Algorithm.createdCode);
         return algorithmMapper.insertAlgorithm(algorithm);
     }
 
     @Override
     public int addOrUpdateDto(AlgorithmDTO algorithmDto) {
-        // todo dto 2 domain, save doman
-        // get ioSubList, save SubAlgorithm
         int res;
         Algorithm algorithm = new Algorithm();
         BeanUtils.copyProperties(algorithmDto,algorithm);
@@ -167,19 +170,18 @@ public class AlgorithmServiceImpl implements IAlgorithmService
     @Override
     public List<Map> getOption() { return algorithmMapper.getOption(); }
 
+//    @Async
     @Override
-    public int runAlgorithms(Long id) throws IOException {
-        int res = 0;
-        //1. update Algorithm.startTime to now
-        //2. run algorithmImpl
+    public void runAlgorithms(Long id) throws IOException {
+        algorithmMapper.updateStatusById(id, Algorithm.runningCode);
+        Date startTime = DateUtils.getNowDate();
+        algorithmMapper.updateStartTimeById(id, startTime);
         List<Map> list = algorithmMapper.selectUrlAndAddressById(id);
         Algorithm algorithm = this.selectAlgorithmById(id);
         AlgorithmSubType algorithmSubType = algorithmSubTypeMapper.selectAlgorithmSubTypeById(algorithm.getSubTypeId());
         RunAlgorithmService runAlgorithmService = algorithmFactory.createRun(algorithmSubType.getRunType());
-        // todo remove this code
-        PadaphmConfig.getProfile();
         if(CollectionUtils.isEmpty(list)){
-            return res;
+            return;
         }
         List<String> docAddress = new ArrayList<>(list.size());
         List<String> resultAddress = new ArrayList<>(list.size());
@@ -187,8 +189,7 @@ public class AlgorithmServiceImpl implements IAlgorithmService
         String prefix2 = PadaphmConfig.getResultPath();
         int j = 1;
         for (int i = 0; i < list.size(); i++) {
-            // todo "1".equals(list.get(i).get("type"))
-            if (list.get(i).get("type").equals("1")) {
+            if (AlgorithmIoField.inputCode.equals(list.get(i).get("type"))) {
                 String s = (String)list.get(i).get("path");
                 if (s.startsWith("/profile")) {
                     s = s.replace("/profile", prefix);
@@ -210,7 +211,12 @@ public class AlgorithmServiceImpl implements IAlgorithmService
         requestDto.setDocList(docAddress);
         requestDto.setResultList(resultAddress);
         runAlgorithmService.runAlgorithm(id, (String)list.get(0).get("url"), requestDto);
-        //3. todo update Algorithm.completedTime and Algorithm.costSecond
-        return res;
+        Date completedTime = DateUtils.getNowDate();
+        algorithmMapper.updateCompletedTimeById(id, completedTime);
+        Long diffInMillies = completedTime.getTime() - startTime.getTime();
+        Long costSecond = TimeUnit.MILLISECONDS.toSeconds(diffInMillies);
+        algorithmMapper.updateCostSecondById(id, costSecond);
+        algorithmMapper.updateStatusById(id, Algorithm.completedCode);
+        return;
     }
 }

+ 178 - 4
pdaaphm-admin/src/main/java/com/pdaaphm/biz/service/impl/RunMatlabImpl.java

@@ -1,30 +1,203 @@
 package com.pdaaphm.biz.service.impl;
 
+import com.pdaaphm.biz.domain.AlgorithmIoField;
 import com.pdaaphm.biz.domain.BaseResponse;
+import com.pdaaphm.biz.domain.File;
+import com.pdaaphm.biz.domain.SubAlgorithm;
 import com.pdaaphm.biz.dto.RequestDTO;
+import com.pdaaphm.biz.mapper.AlgorithmIoFieldMapper;
+import com.pdaaphm.biz.mapper.FileMapper;
+import com.pdaaphm.biz.mapper.SubAlgorithmMapper;
 import com.pdaaphm.biz.service.RunAlgorithmService;
+import com.pdaaphm.common.config.PadaphmConfig;
+import com.pdaaphm.common.utils.DateUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.io.IOException;
-import java.util.List;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import java.util.*;
 import java.io.IOException;
 
 @Service
 public class RunMatlabImpl implements RunAlgorithmService {
+
+    @Autowired
+    private FileMapper fileMapper;
+
+    @Autowired
+    private SubAlgorithmMapper subAlgorithmMapper;
+
+    @Autowired
+    private AlgorithmIoFieldMapper algorithmIoFieldMapper;
+
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
     @Override
     public BaseResponse runAlgorithm(Long id, String url, RequestDTO requestDto) {
-        System.out.println("runMatlab!");
+
+        //初始化res
+        BaseResponse res = new BaseResponse();
+        res.setCode(200);
+
+        //把文件从inputPath文件系统copy到matlab要求的输入位置matlabInputPath,记录matlab的输出文件位置到matlabOutputPathList
+
+        List<String> doctList = requestDto.getDocList();
+        //docList的映射指针
+        int p = 0;
+        List<Map> matlabIoMapList = algorithmIoFieldMapper.selectMatlabIoPathTypeIndexByAlgoId(id);
+        List<String> matlabOutputPathList = new LinkedList<>();
+        for (Map matlabIoMap : matlabIoMapList) {
+            if (AlgorithmIoField.inputCode.equals(matlabIoMap.get("type"))) {
+                String matlabInputPathWithNoFileType = matlabIoMap.get("matlab_io_path") + "\\input" + matlabIoMap.get("index");
+                String inputPath = doctList.get(p);
+                p++;
+                int index = inputPath.lastIndexOf('.');
+                String extension = inputPath.substring(index + 1);
+                String matlabInputPath = matlabInputPathWithNoFileType + '.' + extension;
+                try {
+                    copyFile(inputPath, matlabInputPath);
+                } catch (IOException e) {
+                    throw new RuntimeException(e);
+                }
+            } else {
+                String matlabOutputPathWithNoFileType = matlabIoMap.get("matlab_io_path") + "\\output" + matlabIoMap.get("index");
+                matlabOutputPathList.add(matlabOutputPathWithNoFileType);
+            }
+        }
+
+        //run matlab exe
+//        runMatExe(url);
+
+        //将matlab输出的文件从matlabOutputPathList里copy到文件系统outputPath
+
+        List<String> resultList = requestDto.getResultList();
+        //resultList的映射指针
+        int q = 0;
+        for (String matlabOutputPath : matlabOutputPathList) {
+            int index = matlabOutputPath.lastIndexOf("\\");
+            String dir = matlabOutputPath.substring(0, index);
+            String prefixName = matlabOutputPath.substring(index + 1);
+            Map<String,String> map = getFinalNameAndPath(dir,prefixName);
+            String outputPath = map.get("path");
+            try {
+                copyFile(matlabOutputPath, outputPath);
+            } catch (IOException e) {
+                throw new RuntimeException(e);
+            }
+            q++;
+        }
+
+
+        // save result path to subAlgorithm
+        List<Map> subAlgorithmOutputList = subAlgorithmMapper.selectSubAlgorithmOutputList(id);
+        if (resultList == null) {
+            return res.error("算法未配置输出");
+        }
+        for (int i = 0; i < resultList.size(); i++) {
+            String resultPath = resultList.get(i);
+            Map subAlgorithmOutput = subAlgorithmOutputList.get(i);
+            int lastIndex = resultPath.lastIndexOf("/");
+            String dirs = resultPath.substring(0, lastIndex);
+            String prefixName = resultPath.substring(lastIndex + 1);
+            Map<String, String> map = getFinalNameAndPath(dirs, prefixName);
+            if (map != null) {
+                String prefix = PadaphmConfig.getResultPath();
+                String s = map.get("path");
+                if (s.startsWith(prefix)) {
+                    s = s.replace(prefix, "/resultPath");
+                    map.put("path", s);
+                }
+                File resultFile = new File();
+                resultFile.setName(map.get("name"));
+                resultFile.setPath(map.get("path"));
+                resultFile.setType(File.ouputFlag);
+                resultFile.setCreateTime(DateUtils.getNowDate());
+                Long fileId = fileMapper.selectOutputFile(id);
+                if (fileId == null) {
+                    fileMapper.insertFile(resultFile);
+                } else {
+                    resultFile.setId(fileId);
+                    fileMapper.updateFile(resultFile);
+                }
+                SubAlgorithm subAlgorithm = new SubAlgorithm();
+                subAlgorithm.setId((Long) subAlgorithmOutput.get("id"));
+                subAlgorithm.setAlgorithmId((Long) subAlgorithmOutput.get("algorithm_id"));
+                subAlgorithm.setFieldId((Long) subAlgorithmOutput.get("field_id"));
+                subAlgorithm.setUploadId(resultFile.getId());
+                subAlgorithm.setCreateTime(DateUtils.getNowDate());
+                subAlgorithmMapper.updateSubAlgorithm(subAlgorithm);
+            } else {
+                logger.error("输出文件未生成!");
+                // todo 对程序结果产生负面影响的分子,应反馈给前端
+                // update algorithm
+            }
+        }
         return null;
     }
 
+    // todo return type is Map<String,String>
+    public Map getFinalNameAndPath(String dirs, String prefixName) {
+        // 指定目录路径
+        java.io.File directory = new java.io.File(dirs);
+
+        // 使用FilenameFilter筛选与已知文件名开头的文件
+        String[] matchingFiles = directory.list((dir, name) -> name.startsWith(prefixName));
+
+        Map<String, String> map = new HashMap<>();
+
+        if (matchingFiles != null && matchingFiles.length == 1) {
+            System.out.println("找到匹配的文件:");
+            map.put("name", matchingFiles[0]);
+            map.put("path", dirs + '/' + matchingFiles[0]);
+            return map;
+        } else if (matchingFiles != null && matchingFiles.length > 1) {
+            // todo 工程内禁止使用System.out.print 日志统一使用log
+            logger.error("找到多个匹配的文件,这不应该发生。");
+            return null;
+        } else {
+            // todo 工程内禁止使用System.out.print 日志统一使用log
+            logger.error("没有找到匹配的文件。");
+            return null;
+        }
+    }
+
+    /**
+     * copy file
+     */
+    public void copyFile(String sourcePathStr, String destinationPathStr) throws IOException {
+        Path sourcePath = Paths.get(sourcePathStr);
+        Path destinationPath = Paths.get(destinationPathStr);
+        Files.copy(sourcePath, destinationPath, StandardCopyOption.REPLACE_EXISTING);
+    }
 
     /**
      * this is a demo
      */
-    public static void main(String[] args) {
+    public void runMatExe(String url) {
+        try {
+            // 指定要执行的外部程序和参数
+            ProcessBuilder processBuilder = new ProcessBuilder(url);
+            // 启动外部程序
+            Process process = processBuilder.start();
+            // 等待外部程序执行完成
+            int exitCode = process.waitFor();
+            System.out.println("外部程序执行完成,退出码:" + exitCode);
+        } catch (IOException | InterruptedException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public static void main(String args[]) {
+        String url = "D:\\pdaaphm\\matlabexe\\GWO_SVM_exmp2.exe";
         try {
             // 指定要执行的外部程序和参数
-            ProcessBuilder processBuilder = new ProcessBuilder("C:\\soft\\Program Files (x86)\\Tencent\\WeDoc\\WeChat Files\\Allen_AL\\FileStorage\\File\\2023-08\\fuliye\\for_redistribution_files_only\\fuliye.exe");
+            ProcessBuilder processBuilder = new ProcessBuilder(url);
             // 启动外部程序
             Process process = processBuilder.start();
             // 等待外部程序执行完成
@@ -33,5 +206,6 @@ public class RunMatlabImpl implements RunAlgorithmService {
         } catch (IOException | InterruptedException e) {
             e.printStackTrace();
         }
+        return;
     }
 }

+ 9 - 12
pdaaphm-admin/src/main/java/com/pdaaphm/biz/service/impl/RunPythonImpl.java

@@ -28,6 +28,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.concurrent.TimeoutException;
 
+
 @Service
 public class RunPythonImpl implements RunAlgorithmService {
 
@@ -71,7 +72,9 @@ public class RunPythonImpl implements RunAlgorithmService {
         // save result path to subAlgorithm
         List<String> resultList = requestDto.getResultList();
         List<Map> subAlgorithmOutputList = subAlgorithmMapper.selectSubAlgorithmOutputList(id);
-        // todo subAlgorithmOutputList == null || subAlgorithmOutputList.size == 0?
+        if (resultList == null) {
+            return res.error("算法未配置输出");
+        }
         for (int i = 0; i < resultList.size(); i++) {
             String resultPath = resultList.get(i);
             Map subAlgorithmOutput = subAlgorithmOutputList.get(i);
@@ -89,8 +92,7 @@ public class RunPythonImpl implements RunAlgorithmService {
                 File resultFile = new File();
                 resultFile.setName(map.get("name"));
                 resultFile.setPath(map.get("path"));
-                // todo 魔鬼数字,创建静态变量在File中 xxx=1,yyy=2,这里引用
-                resultFile.setType("2");
+                resultFile.setType(File.ouputFlag);
                 resultFile.setCreateTime(DateUtils.getNowDate());
                 Long fileId = fileMapper.selectOutputFile(id);
                 if (fileId == null) {
@@ -106,11 +108,10 @@ public class RunPythonImpl implements RunAlgorithmService {
                 subAlgorithm.setFieldId((Long) subAlgorithmOutput.get("field_id"));
                 subAlgorithm.setUploadId(resultFile.getId());
                 subAlgorithm.setCreateTime(DateUtils.getNowDate());
-                // todo 只有update?啥时候insert?
                 subAlgorithmMapper.updateSubAlgorithm(subAlgorithm);
             }
             else {
-                logger.error("存在未生成文件!");
+                logger.error("输出文件未生成!");
                 // todo 对程序结果产生负面影响的分子,应反馈给前端
                 // update algorithm
             }
@@ -123,12 +124,8 @@ public class RunPythonImpl implements RunAlgorithmService {
         // 指定目录路径
         java.io.File directory = new java.io.File(dirs);
 
-        // 已知的文件名前缀(不带扩展名)
-        // todo variable is redundant
-        String knownFileName = prefixName;
-
         // 使用FilenameFilter筛选与已知文件名开头的文件
-        String[] matchingFiles = directory.list((dir, name) -> name.startsWith(knownFileName));
+        String[] matchingFiles = directory.list((dir, name) -> name.startsWith(prefixName));
 
         Map<String,String> map = new HashMap<>();
 
@@ -139,11 +136,11 @@ public class RunPythonImpl implements RunAlgorithmService {
             return map;
         } else if (matchingFiles != null && matchingFiles.length > 1) {
             // todo 工程内禁止使用System.out.print 日志统一使用log
-            System.out.println("找到多个匹配的文件,这不应该发生。");
+            logger.error("找到多个匹配的文件,这不应该发生。");
             return null;
         } else {
             // todo 工程内禁止使用System.out.print 日志统一使用log
-            System.out.println("没有找到匹配的文件。");
+            logger.error("没有找到匹配的文件。");
             return null;
         }
     }

+ 16 - 6
pdaaphm-admin/src/main/java/com/pdaaphm/web/controller/common/CommonController.java

@@ -23,7 +23,7 @@ import com.pdaaphm.framework.config.ServerConfig;
 
 /**
  * 通用请求处理
- * 
+ *
  * @author Allen
  */
 @RestController
@@ -39,7 +39,7 @@ public class CommonController
 
     /**
      * 通用下载请求
-     * 
+     *
      * @param fileName 文件名称
      * @param delete 是否删除
      */
@@ -145,10 +145,20 @@ public class CommonController
             {
                 throw new Exception(StringUtils.format("资源文件({})非法,不允许下载。 ", resource));
             }
-            // 本地资源路径
-            String localPath = PadaphmConfig.getProfile();
-            // 数据库资源地址
-            String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX);
+            String localPath;
+            String downloadPath;
+            if (resource.startsWith("/profile")) {
+                // 本地资源路径
+                localPath = PadaphmConfig.getProfile();
+                // 数据库资源地址
+                downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX);
+            }
+            else {
+                // 本地资源路径
+                localPath = PadaphmConfig.getResultPath();
+                // 数据库资源地址
+                downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_RESULTPREFIX);
+            }
             // 下载名称
             String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
             response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);

+ 45 - 1
pdaaphm-admin/src/main/resources/mapper/algoManager/AlgorithmMapper.xml

@@ -9,6 +9,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="type"    column="type"    />
         <result property="subTypeId"    column="sub_type_id"    />
         <result property="name"    column="name"    />
+        <result property="status"    column="status"    />
+        <result property="error"    column="error"    />
         <result property="startTime"    column="start_time"    />
         <result property="completedTime"    column="completed_time"    />
         <result property="costSecond"    column="cost_second"    />
@@ -21,7 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectAlgorithmVo">
-        select algo.`id`, algo.`type`, algo.sub_type_id, algo.`name`, algo.start_time, algo.completed_time, algo.cost_second, algo.create_by, algo.create_time, algo.update_by, algo.update_time, algo.remark, sub.name as sub_name from t_algorithm as algo left join t_algorithm_sub_type as sub on algo.sub_type_id = sub.id
+        select algo.`id`, algo.`type`, algo.sub_type_id, algo.`name`, algo.`status`, algo.error, algo.start_time, algo.completed_time, algo.cost_second, algo.create_by, algo.create_time, algo.update_by, algo.update_time, algo.remark, sub.name as sub_name from t_algorithm as algo left join t_algorithm_sub_type as sub on algo.sub_type_id = sub.id
     </sql>
 
     <select id="selectAlgorithmList" parameterType="Algorithm" resultMap="AlgorithmResult">
@@ -30,6 +32,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="type != null  and type != ''"> and `type` = #{type}</if>
             <if test="subTypeId != null "> and sub_type_id = #{subTypeId}</if>
             <if test="name != null  and name != ''"> and `name` like concat('%', #{name}, '%')</if>
+            <if test="status != null  and status != ''"> and status = #{status}</if>
+            <if test="error != null  and error != ''"> and error = #{error}</if>
             <if test="startTime != null "> and start_time = #{startTime}</if>
             <if test="completedTime != null "> and completed_time = #{completedTime}</if>
             <if test="costSecond != null "> and cost_second = #{costSecond}</if>
@@ -47,6 +51,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="type != null">`type`,</if>
             <if test="subTypeId != null">sub_type_id,</if>
             <if test="name != null">`name`,</if>
+            <if test="status != null and status != ''">status,</if>
+            <if test="error != null">error,</if>
             <if test="startTime != null">start_time,</if>
             <if test="completedTime != null">completed_time,</if>
             <if test="costSecond != null">cost_second,</if>
@@ -60,6 +66,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="type != null">#{type},</if>
             <if test="subTypeId != null">#{subTypeId},</if>
             <if test="name != null">#{name},</if>
+            <if test="status != null and status != ''">#{status},</if>
+            <if test="error != null">#{error},</if>
             <if test="startTime != null">#{startTime},</if>
             <if test="completedTime != null">#{completedTime},</if>
             <if test="costSecond != null">#{costSecond},</if>
@@ -77,6 +85,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="type != null">type = #{type},</if>
             <if test="subTypeId != null">sub_type_id = #{subTypeId},</if>
             <if test="name != null">`name` = #{name},</if>
+            <if test="status != null and status != ''">status = #{status},</if>
+            <if test="error != null">error = #{error},</if>
             <if test="startTime != null">start_time = #{startTime},</if>
             <if test="completedTime != null">completed_time = #{completedTime},</if>
             <if test="costSecond != null">cost_second = #{costSecond},</if>
@@ -117,5 +127,39 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 LEFT JOIN t_file tf ON tf.id = tsa.upload_id
         WHERE
             ta.id = #{id}
+        ORDER BY
+            taf.`index`
     </select>
+
+    <update id="updateStartTimeById" parameterType="map">
+        update t_algorithm
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="startTime != null">start_time = #{startTime},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <update id="updateCompletedTimeById" parameterType="map">
+        update t_algorithm
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="completedTime != null">completed_time = #{completedTime},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <update id="updateCostSecondById" parameterType="map">
+        update t_algorithm
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="costSecond != null">cost_second = #{costSecond},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <update id="updateStatusById" parameterType="map">
+        update t_algorithm
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="statusCode != null">status = #{statusCode},</if>
+        </trim>
+        where id = #{id}
+    </update>
 </mapper>

+ 35 - 2
pdaaphm-admin/src/main/resources/mapper/conf/AlgorithmIoFieldMapper.xml

@@ -10,6 +10,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="type"    column="type"    />
         <result property="name"    column="name"    />
         <result property="index"    column="index"    />
+        <result property="matlabIoPath"    column="matlab_io_path"    />
         <result property="createBy"    column="create_by"    />
         <result property="createTime"    column="create_time"    />
         <result property="updateBy"    column="update_by"    />
@@ -19,7 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectAlgorithmIoFieldVo">
-        select io.id, io.algorithm_sub_id, io.`type`, io.`name`, io.`index`, io.create_by, io.create_time, io.update_by, io.update_time, io.remark, sub.name as sub_name from t_algorithm_io_field as io left join t_algorithm_sub_type as sub on io.algorithm_sub_id = sub.id
+        select io.id, io.algorithm_sub_id, io.`type`, io.`name`, io.`index`,io.matlab_io_path ,io.create_by, io.create_time, io.update_by, io.update_time, io.remark, sub.name as sub_name from t_algorithm_io_field as io left join t_algorithm_sub_type as sub on io.algorithm_sub_id = sub.id
     </sql>
 
     <select id="selectAlgorithmIoFieldList" parameterType="AlgorithmIoField" resultMap="AlgorithmIoFieldResult">
@@ -29,6 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="type != null  and type != ''"> and `type` = #{type}</if>
             <if test="name != null  and name != ''"> and `name` like concat('%', #{name}, '%')</if>
             <if test="index != null "> and `index` = #{index}</if>
+            <if test="matlabIoPath != null  and matlabIoPath != ''"> and matlab_io_path = #{matlabIoPath}</if>
         </where>
     </select>
 
@@ -44,6 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="type != null">`type`,</if>
             <if test="name != null">`name`,</if>
             <if test="index != null">`index`,</if>
+            <if test="matlabIoPath != null">matlab_io_path,</if>
             <if test="createBy != null">create_by,</if>
             <if test="createTime != null">create_time,</if>
             <if test="updateBy != null">update_by,</if>
@@ -55,6 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="type != null">#{type},</if>
             <if test="name != null">#{name},</if>
             <if test="index != null">#{index},</if>
+            <if test="matlabIoPath != null">#{matlabIoPath},</if>
             <if test="createBy != null">#{createBy},</if>
             <if test="createTime != null">#{createTime},</if>
             <if test="updateBy != null">#{updateBy},</if>
@@ -70,6 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="type != null">`type` = #{type},</if>
             <if test="name != null">`name` = #{name},</if>
             <if test="index != null">`index` = #{index},</if>
+            <if test="matlabIoPath != null">matlab_io_path = #{matlabIoPath},</if>
             <if test="createBy != null">create_by = #{createBy},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="updateBy != null">update_by = #{updateBy},</if>
@@ -116,10 +121,38 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                     sa.algorithm_id = a.id
                   AND sa.field_id = io.id
                   AND a.id = #{algoId}
-            ) AS uploadId
+            ) AS uploadId,
+            (
+                SELECT
+                    f.path
+                FROM
+                    t_sub_algorithm sa,
+                    t_file f,
+                    t_algorithm a
+                WHERE
+                    sa.upload_id = f.id
+                  AND sa.algorithm_id = a.id
+                  AND sa.field_id = io.id
+                  AND a.id = #{algoId}
+            ) AS path
         FROM
             t_algorithm_io_field AS io
         WHERE
             io.algorithm_sub_id = #{subTypeId}
     </select>
+
+    <select id="selectMatlabIoPathTypeIndexByAlgoId" resultType="map">
+        SELECT
+            io.matlab_io_path,
+            io.type,
+            io.`index`
+        FROM
+            t_algorithm_io_field io
+                JOIN t_algorithm_sub_type ast ON ast.id = io.algorithm_sub_id
+                JOIN t_algorithm a ON a.sub_type_id = ast.id
+        WHERE
+            a.id = #{id}
+        ORDER BY
+            io.`index`
+    </select>
 </mapper>

+ 7 - 2
pdaaphm-common/src/main/java/com/pdaaphm/common/constant/Constants.java

@@ -4,7 +4,7 @@ import io.jsonwebtoken.Claims;
 
 /**
  * 通用常量信息
- * 
+ *
  * @author Allen
  */
 public class Constants
@@ -63,7 +63,7 @@ public class Constants
      * 登录失败
      */
     public static final String LOGIN_FAIL = "Error";
- 
+
     /**
      * 验证码有效期(分钟)
      */
@@ -114,6 +114,11 @@ public class Constants
      */
     public static final String RESOURCE_PREFIX = "/profile";
 
+    /**
+     * 资源映射路径 前缀
+     */
+    public static final String RESOURCE_RESULTPREFIX = "/resultPath";
+
     /**
      * RMI 远程方法调用
      */

+ 15 - 14
pdaaphm-common/src/main/java/com/pdaaphm/common/utils/file/FileUtils.java

@@ -21,7 +21,7 @@ import org.apache.commons.io.FilenameUtils;
 
 /**
  * 文件处理工具类
- * 
+ *
  * @author Allen
  */
 public class FileUtils
@@ -30,7 +30,7 @@ public class FileUtils
 
     /**
      * 输出指定文件的byte数组
-     * 
+     *
      * @param filePath 文件路径
      * @param os 输出流
      * @return
@@ -105,7 +105,7 @@ public class FileUtils
 
     /**
      * 删除文件
-     * 
+     *
      * @param filePath 文件
      * @return
      */
@@ -123,7 +123,7 @@ public class FileUtils
 
     /**
      * 文件名称验证
-     * 
+     *
      * @param filename 文件名称
      * @return true 正常 false 非法
      */
@@ -134,7 +134,7 @@ public class FileUtils
 
     /**
      * 检查文件是否可下载
-     * 
+     *
      * @param resource 需要下载的文件
      * @return true 正常 false 非法
      */
@@ -147,18 +147,19 @@ public class FileUtils
         }
 
         // 检查允许下载的文件规则
-        if (ArrayUtils.contains(MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION, FileTypeUtils.getFileType(resource)))
-        {
-            return true;
-        }
+//        if (ArrayUtils.contains(MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION, FileTypeUtils.getFileType(resource)))
+//        {
+//            return true;
+//        }
 
         // 不在允许下载的文件规则
-        return false;
+//        return false;
+        return true;
     }
 
     /**
      * 下载文件名重新编码
-     * 
+     *
      * @param request 请求对象
      * @param fileName 文件名
      * @return 编码后的文件名
@@ -228,7 +229,7 @@ public class FileUtils
 
     /**
      * 获取图像后缀
-     * 
+     *
      * @param photoByte 图像数据
      * @return 后缀名
      */
@@ -257,7 +258,7 @@ public class FileUtils
 
     /**
      * 获取文件名称 /profile/upload/2022/04/16/ruoyi.png -- ruoyi.png
-     * 
+     *
      * @param fileName 路径名称
      * @return 没有文件路径的名称
      */
@@ -275,7 +276,7 @@ public class FileUtils
 
     /**
      * 获取不带后缀文件名称 /profile/upload/2022/04/16/ruoyi.png -- ruoyi
-     * 
+     *
      * @param fileName 路径名称
      * @return 没有文件路径和后缀的名称
      */

+ 1 - 1
pdaaphm-ui/src/api/conf/field.js

@@ -44,7 +44,7 @@ export function delField(id) {
 }
 
 // 查询具体算法输入输出字段列表
-export function getIoSubList(subTypeId,algoId) {
+export function getIoSubList(subTypeId, algoId) {
   return request({
     url: '/conf/field/getIoSubList/' + subTypeId + '/'+ algoId,
     method: 'get',

+ 51 - 9
pdaaphm-ui/src/views/algoManager/algorithm/index.vue

@@ -132,27 +132,42 @@
       </el-table-column>
       <el-table-column label="算法子类型" align="center" prop="algoSubName" />
       <el-table-column label="名称" align="center" prop="name" />
+      <el-table-column label="运行状态" align="center" prop="status">
+        <template slot-scope="scope">
+          <dict-tag :options="dict.type.algo_run_status" :value="scope.row.status"/>
+        </template>
+      </el-table-column>
       <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="completedTime" width="180">
         <template slot-scope="scope">
-          <span>{{ parseTime(scope.row.completedTime, '{y}-{m}-{d}') }}</span>
+          <span>{{ parseTime(scope.row.completedTime) }}</span>
         </template>
       </el-table-column>
       <el-table-column label="耗时(s)" align="center" prop="costSecond" />
+      <el-table-column label="错误日志" align="center" prop="error" />
       <el-table-column label="备注" align="center" prop="remark" />
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
         <template slot-scope="scope">
           <el-button
+            v-show="scope.row.status == 0"
             size="mini"
             type="text"
             icon="el-icon-edit"
             @click="handleUpdate(scope.row)"
             v-hasPermi="['algoManager:algorithm:edit']"
           >修改</el-button>
+          <el-button
+            v-show="scope.row.status == 2"
+            size="mini"
+            type="text"
+            icon="el-icon-warning-outline"
+            @click="handleUpdate(scope.row)"
+            v-hasPermi="['algoManager:algorithm:edit']"
+          >查看结果</el-button>
           <el-button
             size="mini"
             type="text"
@@ -176,7 +191,7 @@
     <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
         <el-form-item label="算法类型" prop="type">
-          <el-select v-model="form.type" placeholder="请选择算法类型" clearable filterable @change='changeFormType()'>
+          <el-select v-model="form.type" placeholder="请选择算法类型" clearable filterable :disabled="form.status == 2" @change='changeFormType()'>
             <el-option
               v-for="dict in dict.type.algorithm_type"
               :key="dict.value"
@@ -191,6 +206,7 @@
             placeholder="请选择算法子类型"
             clearable
             filterable
+            :disabled="form.status == 2"
             @change='changeFormSubType()'
           >
             <el-option
@@ -210,6 +226,7 @@
               placeholder="请选择文件"
               clearable
               filterable
+              :disabled="form.status == 2"
             >
               <el-option
                 v-for="file in fileList"
@@ -219,18 +236,26 @@
               >
               </el-option>
             </el-select>
+            <el-button
+              size="mini"
+              type="text"
+              icon="el-icon-download"
+              @click="download(item.path)"
+              v-hasPermi="['data:model:edit']"
+            >{{ "下载文件" }}
+            </el-button>
           </el-form-item>
         </template>
         <el-form-item label="名称" prop="name">
-          <el-input v-model="form.name" placeholder="请输入名称" />
+          <el-input v-model="form.name" placeholder="请输入名称" :disabled="form.status == 2"/>
         </el-form-item>
         <el-form-item label="备注" prop="remark">
-          <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
+          <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" :disabled="form.status == 2"/>
         </el-form-item>
       </el-form>
       <div slot="footer" class="dialog-footer">
-        <el-button type="primary" @click="submitForm">确 定</el-button>
-        <el-button @click="cancel">取 消</el-button>
+        <el-button v-show="form.status != 2" type="primary" @click="submitForm">确 定</el-button>
+        <el-button v-show="form.status != 2" @click="cancel">取 消</el-button>
       </div>
     </el-dialog>
   </div>
@@ -244,7 +269,7 @@ import { getFileList } from "@/api/algoManager/file";
 
 export default {
   name: "Algorithm",
-  dicts: ['algorithm_type'],
+  dicts: ['algorithm_type','algo_run_status'],
   data() {
     return {
       // 遮罩层
@@ -383,6 +408,19 @@ export default {
         this.title = "修改算法";
         this.algoTypeList = this.typeMap.get(this.form.type);
       });
+      console.info(this);
+    },
+    /** 查看结果按钮操作 */
+    viewResult(row) {
+      this.reset();
+      const id = row.id || this.ids
+      getAlgorithmDto(id).then(response => {
+        this.form = response.data;
+        this.open = true;
+        this.title = "查看结果";
+        this.algoTypeList = this.typeMap.get(this.form.type);
+      });
+      console.info(this);
     },
     /** 提交按钮 */
     submitForm() {
@@ -450,11 +488,15 @@ export default {
     },
 
     changeFormSubType() {
-      getIoSubList(this.form.subTypeId,this.form.id).then((resp) => {
+      getIoSubList(this.form.subTypeId, this.form.id).then((resp) => {
         this.form.ioSubList = resp.data;
         console.info(resp);
       });
     },
+
+    download(path) {
+      this.$download.resource(path);
+    },
   }
 };
 </script>

+ 8 - 3
pdaaphm-ui/src/views/conf/field/index.vue

@@ -166,7 +166,10 @@
           <el-input v-model="form.name" placeholder="请输入名称" />
         </el-form-item>
         <el-form-item label="排序" prop="index">
-          <el-input v-model="form.index" placeholder="请输入排序" />
+          <el-input-number v-model="form.index" :min="1" :max="100" />
+        </el-form-item>
+        <el-form-item label="matlab文件路径" prop="matlabIoPath">
+          <el-input v-model="form.matlabIoPath" placeholder="请输入matlab文件路径" />
         </el-form-item>
         <el-form-item label="备注" prop="remark">
           <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
@@ -217,7 +220,8 @@ export default {
         index: null,
       },
       // 表单参数
-      form: {},
+      form: { 
+      },
       // 表单校验
       rules: {
         algorithmSubId: [
@@ -259,7 +263,8 @@ export default {
         createTime: null,
         updateBy: null,
         updateTime: null,
-        remark: null
+        remark: null,
+        matlabIoPath: null,
       };
       this.resetForm("form");
     },

+ 16 - 5
pdaaphm-ui/src/views/conf/subType/index.vue

@@ -123,7 +123,7 @@
     <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
         <el-form-item label="类型" prop="type">
-          <el-select v-model="form.type" placeholder="请选择类型">
+          <el-select v-model="form.type" clearable placeholder="请选择类型">
             <el-option
               v-for="dict in dict.type.algorithm_type"
               :key="dict.value"
@@ -136,11 +136,23 @@
           <el-input v-model="form.name" placeholder="请输入算法子名称" />
         </el-form-item>
         <el-form-item label="算法url" prop="url">
-          <el-input v-model="form.url" placeholder="请输入算法url" />
+          <el-input v-model="form.url" placeholder="请输入算法url/matlab的exe路径" />
         </el-form-item>
         <el-form-item label="算法运行类型" prop="runType">
-          <el-input v-model="form.runType" placeholder="请输入算法运行类型" />
+          <el-select v-model="form.runType" clearable placeholder="请输入算法运行类型">
+            <el-option
+              v-for="dict in dict.type.run_type"
+                :key="dict.value"
+                :label="dict.label"
+                :value="dict.value"
+            ></el-option>
+          </el-select>
         </el-form-item>
+        <!-- <template v-if="form.runType == 2">
+          <el-form-item label="matlab文件路径" prop="matlabIoPath">
+            <el-input v-model="form.matlabIoPath" placeholder="请输入matlab文件路径" />
+          </el-form-item>
+        </template> -->
         <el-form-item label="备注" prop="remark">
           <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
         </el-form-item>
@@ -158,7 +170,7 @@ import { listSubType, getSubType, delSubType, addSubType, updateSubType } from "
 
 export default {
   name: "SubType",
-  dicts: ['algorithm_type'],
+  dicts: ['algorithm_type','run_type'],
   data() {
     return {
       // 遮罩层
@@ -186,7 +198,6 @@ export default {
         type: null,
         name: null,
         url: null,
-        runType: null,
       },
       // 表单参数
       form: {},