Эх сурвалжийг харах

运行matlab算法功能bug修复

twzydn20000928 1 жил өмнө
parent
commit
37a3384016

+ 2 - 0
pdaaphm-admin/src/main/java/com/pdaaphm/biz/mapper/AlgorithmIoFieldMapper.java

@@ -71,4 +71,6 @@ public interface AlgorithmIoFieldMapper
      * @return
      */
     public List<Map> selectMatlabIoPathTypeIndexByAlgoId(Long id);
+
+    public int deleteAlgorithmIoFieldBySubTypeId(Long id);
 }

+ 2 - 0
pdaaphm-admin/src/main/java/com/pdaaphm/biz/mapper/AlgorithmMapper.java

@@ -74,4 +74,6 @@ public interface AlgorithmMapper
     public void updateCostSecondById(@Param("id") Long id, @Param("costSecond") Long costSecond);
 
     public void updateStatusById(@Param("id") Long id, @Param("statusCode") String statusCode);
+
+    public int  deleteAlgorithmBySubTypeId(Long id);
 }

+ 8 - 0
pdaaphm-admin/src/main/java/com/pdaaphm/biz/mapper/SubAlgorithmMapper.java

@@ -53,6 +53,14 @@ public interface SubAlgorithmMapper
      */
     public int deleteSubAlgorithmById(Long id);
 
+    /**
+     * 删除子算法
+     *
+     * @param id 文件id
+     * @return 结果
+     */
+    public int deleteSubAlgorithmByUploadId(Long id);
+
     /**
      * 批量删除子算法
      *

+ 11 - 15
pdaaphm-admin/src/main/java/com/pdaaphm/biz/service/impl/AlgorithmIoFieldServiceImpl.java

@@ -4,6 +4,7 @@ import java.util.List;
 import java.util.Map;
 
 import com.pdaaphm.biz.dto.SubAlgorithmDTO;
+import com.pdaaphm.biz.mapper.AlgorithmMapper;
 import com.pdaaphm.common.utils.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -18,8 +19,7 @@ import com.pdaaphm.biz.service.IAlgorithmIoFieldService;
  * @date 2023-07-26
  */
 @Service
-public class AlgorithmIoFieldServiceImpl implements IAlgorithmIoFieldService
-{
+public class AlgorithmIoFieldServiceImpl implements IAlgorithmIoFieldService {
     @Autowired
     private AlgorithmIoFieldMapper algorithmIoFieldMapper;
 
@@ -30,8 +30,7 @@ public class AlgorithmIoFieldServiceImpl implements IAlgorithmIoFieldService
      * @return 算法输入输出字段
      */
     @Override
-    public AlgorithmIoField selectAlgorithmIoFieldById(Long id)
-    {
+    public AlgorithmIoField selectAlgorithmIoFieldById(Long id) {
         return algorithmIoFieldMapper.selectAlgorithmIoFieldById(id);
     }
 
@@ -42,8 +41,7 @@ public class AlgorithmIoFieldServiceImpl implements IAlgorithmIoFieldService
      * @return 算法输入输出字段
      */
     @Override
-    public List<AlgorithmIoField> selectAlgorithmIoFieldList(AlgorithmIoField algorithmIoField)
-    {
+    public List<AlgorithmIoField> selectAlgorithmIoFieldList(AlgorithmIoField algorithmIoField) {
         return algorithmIoFieldMapper.selectAlgorithmIoFieldList(algorithmIoField);
     }
 
@@ -54,8 +52,7 @@ public class AlgorithmIoFieldServiceImpl implements IAlgorithmIoFieldService
      * @return 结果
      */
     @Override
-    public int insertAlgorithmIoField(AlgorithmIoField algorithmIoField)
-    {
+    public int insertAlgorithmIoField(AlgorithmIoField algorithmIoField) {
         algorithmIoField.setCreateTime(DateUtils.getNowDate());
         return algorithmIoFieldMapper.insertAlgorithmIoField(algorithmIoField);
     }
@@ -67,8 +64,7 @@ public class AlgorithmIoFieldServiceImpl implements IAlgorithmIoFieldService
      * @return 结果
      */
     @Override
-    public int updateAlgorithmIoField(AlgorithmIoField algorithmIoField)
-    {
+    public int updateAlgorithmIoField(AlgorithmIoField algorithmIoField) {
         algorithmIoField.setUpdateTime(DateUtils.getNowDate());
         return algorithmIoFieldMapper.updateAlgorithmIoField(algorithmIoField);
     }
@@ -80,8 +76,7 @@ public class AlgorithmIoFieldServiceImpl implements IAlgorithmIoFieldService
      * @return 结果
      */
     @Override
-    public int deleteAlgorithmIoFieldByIds(Long[] ids)
-    {
+    public int deleteAlgorithmIoFieldByIds(Long[] ids) {
         return algorithmIoFieldMapper.deleteAlgorithmIoFieldByIds(ids);
     }
 
@@ -92,11 +87,12 @@ public class AlgorithmIoFieldServiceImpl implements IAlgorithmIoFieldService
      * @return 结果
      */
     @Override
-    public int deleteAlgorithmIoFieldById(Long id)
-    {
+    public int deleteAlgorithmIoFieldById(Long id) {
         return algorithmIoFieldMapper.deleteAlgorithmIoFieldById(id);
     }
 
     @Override
-    public List<SubAlgorithmDTO> getIoSubList(Long subTypeId, Long algoId) { return algorithmIoFieldMapper.getIoSubList(subTypeId, algoId); }
+    public List<SubAlgorithmDTO> getIoSubList(Long subTypeId, Long algoId) {
+        return algorithmIoFieldMapper.getIoSubList(subTypeId, algoId);
+    }
 }

+ 29 - 21
pdaaphm-admin/src/main/java/com/pdaaphm/biz/service/impl/AlgorithmSubTypeServiceImpl.java

@@ -1,6 +1,9 @@
 package com.pdaaphm.biz.service.impl;
 
 import java.util.List;
+
+import com.pdaaphm.biz.mapper.AlgorithmIoFieldMapper;
+import com.pdaaphm.biz.mapper.AlgorithmMapper;
 import com.pdaaphm.common.utils.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -10,87 +13,92 @@ import com.pdaaphm.biz.service.IAlgorithmSubTypeService;
 
 /**
  * 算法子类型Service业务层处理
- * 
+ *
  * @author allen
  * @date 2023-07-26
  */
 @Service
-public class AlgorithmSubTypeServiceImpl implements IAlgorithmSubTypeService 
-{
+public class AlgorithmSubTypeServiceImpl implements IAlgorithmSubTypeService {
     @Autowired
     private AlgorithmSubTypeMapper algorithmSubTypeMapper;
 
+    @Autowired
+    private AlgorithmIoFieldMapper algorithmIoFieldMapper;
+
+    @Autowired
+    private AlgorithmMapper algorithmMapper;
+
     /**
      * 查询算法子类型
-     * 
+     *
      * @param id 算法子类型主键
      * @return 算法子类型
      */
     @Override
-    public AlgorithmSubType selectAlgorithmSubTypeById(Long id)
-    {
+    public AlgorithmSubType selectAlgorithmSubTypeById(Long id) {
         return algorithmSubTypeMapper.selectAlgorithmSubTypeById(id);
     }
 
     /**
      * 查询算法子类型列表
-     * 
+     *
      * @param algorithmSubType 算法子类型
      * @return 算法子类型
      */
     @Override
-    public List<AlgorithmSubType> selectAlgorithmSubTypeList(AlgorithmSubType algorithmSubType)
-    {
+    public List<AlgorithmSubType> selectAlgorithmSubTypeList(AlgorithmSubType algorithmSubType) {
         return algorithmSubTypeMapper.selectAlgorithmSubTypeList(algorithmSubType);
     }
 
     /**
      * 新增算法子类型
-     * 
+     *
      * @param algorithmSubType 算法子类型
      * @return 结果
      */
     @Override
-    public int insertAlgorithmSubType(AlgorithmSubType algorithmSubType)
-    {
+    public int insertAlgorithmSubType(AlgorithmSubType algorithmSubType) {
         algorithmSubType.setCreateTime(DateUtils.getNowDate());
         return algorithmSubTypeMapper.insertAlgorithmSubType(algorithmSubType);
     }
 
     /**
      * 修改算法子类型
-     * 
+     *
      * @param algorithmSubType 算法子类型
      * @return 结果
      */
     @Override
-    public int updateAlgorithmSubType(AlgorithmSubType algorithmSubType)
-    {
+    public int updateAlgorithmSubType(AlgorithmSubType algorithmSubType) {
         algorithmSubType.setUpdateTime(DateUtils.getNowDate());
         return algorithmSubTypeMapper.updateAlgorithmSubType(algorithmSubType);
     }
 
     /**
      * 批量删除算法子类型
-     * 
+     *
      * @param ids 需要删除的算法子类型主键
      * @return 结果
      */
     @Override
-    public int deleteAlgorithmSubTypeByIds(Long[] ids)
-    {
+    public int deleteAlgorithmSubTypeByIds(Long[] ids) {
+        for (Long id : ids) {
+            algorithmIoFieldMapper.deleteAlgorithmIoFieldBySubTypeId(id);
+            algorithmMapper.deleteAlgorithmBySubTypeId(id);
+        }
         return algorithmSubTypeMapper.deleteAlgorithmSubTypeByIds(ids);
     }
 
     /**
      * 删除算法子类型信息
-     * 
+     *
      * @param id 算法子类型主键
      * @return 结果
      */
     @Override
-    public int deleteAlgorithmSubTypeById(Long id)
-    {
+    public int deleteAlgorithmSubTypeById(Long id) {
+        algorithmIoFieldMapper.deleteAlgorithmIoFieldBySubTypeId(id);
+        algorithmMapper.deleteAlgorithmBySubTypeId(id);
         return algorithmSubTypeMapper.deleteAlgorithmSubTypeById(id);
     }
 }

+ 19 - 15
pdaaphm-admin/src/main/java/com/pdaaphm/biz/service/impl/FileServiceImpl.java

@@ -3,6 +3,8 @@ package com.pdaaphm.biz.service.impl;
 import java.util.List;
 import java.util.Map;
 
+import com.pdaaphm.biz.mapper.AlgorithmSubTypeMapper;
+import com.pdaaphm.biz.mapper.SubAlgorithmMapper;
 import com.pdaaphm.common.utils.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -17,11 +19,13 @@ import com.pdaaphm.biz.service.IFileService;
  * @date 2023-07-26
  */
 @Service
-public class FileServiceImpl implements IFileService
-{
+public class FileServiceImpl implements IFileService {
     @Autowired
     private FileMapper fileMapper;
 
+    @Autowired
+    private SubAlgorithmMapper subAlgorithmMapper;
+
     /**
      * 查询文件
      *
@@ -29,8 +33,7 @@ public class FileServiceImpl implements IFileService
      * @return 文件
      */
     @Override
-    public File selectFileById(Long id)
-    {
+    public File selectFileById(Long id) {
         return fileMapper.selectFileById(id);
     }
 
@@ -41,8 +44,7 @@ public class FileServiceImpl implements IFileService
      * @return 文件
      */
     @Override
-    public List<File> selectFileList(File file)
-    {
+    public List<File> selectFileList(File file) {
         return fileMapper.selectFileList(file);
     }
 
@@ -53,8 +55,7 @@ public class FileServiceImpl implements IFileService
      * @return 结果
      */
     @Override
-    public int insertFile(File file)
-    {
+    public int insertFile(File file) {
         file.setCreateTime(DateUtils.getNowDate());
         return fileMapper.insertFile(file);
     }
@@ -66,8 +67,7 @@ public class FileServiceImpl implements IFileService
      * @return 结果
      */
     @Override
-    public int updateFile(File file)
-    {
+    public int updateFile(File file) {
         file.setUpdateTime(DateUtils.getNowDate());
         return fileMapper.updateFile(file);
     }
@@ -79,8 +79,10 @@ public class FileServiceImpl implements IFileService
      * @return 结果
      */
     @Override
-    public int deleteFileByIds(Long[] ids)
-    {
+    public int deleteFileByIds(Long[] ids) {
+        for (Long id : ids) {
+            subAlgorithmMapper.deleteSubAlgorithmByUploadId(id);
+        }
         return fileMapper.deleteFileByIds(ids);
     }
 
@@ -91,11 +93,13 @@ public class FileServiceImpl implements IFileService
      * @return 结果
      */
     @Override
-    public int deleteFileById(Long id)
-    {
+    public int deleteFileById(Long id) {
+        subAlgorithmMapper.deleteSubAlgorithmByUploadId(id);
         return fileMapper.deleteFileById(id);
     }
 
     @Override
-    public List<Map> getOption() { return fileMapper.getOption(); }
+    public List<Map> getOption() {
+        return fileMapper.getOption();
+    }
 }

+ 1 - 7
pdaaphm-admin/src/main/java/com/pdaaphm/biz/service/impl/RunMatlabImpl.java

@@ -122,13 +122,7 @@ public class RunMatlabImpl implements RunAlgorithmService {
                 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);
-                }
+                fileMapper.insertFile(resultFile);
                 SubAlgorithm subAlgorithm = new SubAlgorithm();
                 subAlgorithm.setId((Long) subAlgorithmOutput.get("id"));
                 subAlgorithm.setAlgorithmId((Long) subAlgorithmOutput.get("algorithm_id"));

+ 1 - 8
pdaaphm-admin/src/main/java/com/pdaaphm/biz/service/impl/RunPythonImpl.java

@@ -94,14 +94,7 @@ public class RunPythonImpl implements RunAlgorithmService {
                 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);
-                }
+                fileMapper.insertFile(resultFile);
                 SubAlgorithm subAlgorithm = new SubAlgorithm();
                 subAlgorithm.setId((Long) subAlgorithmOutput.get("id"));
                 subAlgorithm.setAlgorithmId((Long) subAlgorithmOutput.get("algorithm_id"));

+ 4 - 0
pdaaphm-admin/src/main/resources/mapper/algoManager/AlgorithmMapper.xml

@@ -103,6 +103,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         delete from t_algorithm where id = #{id}
     </delete>
 
+    <delete id="deleteAlgorithmBySubTypeId" parameterType="Long">
+        delete from t_algorithm where sub_type_id = #{id}
+    </delete>
+
     <delete id="deleteAlgorithmByIds" parameterType="String">
         delete from t_algorithm where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">

+ 4 - 0
pdaaphm-admin/src/main/resources/mapper/algoManager/SubAlgorithmMapper.xml

@@ -77,6 +77,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         delete from t_sub_algorithm where id = #{id}
     </delete>
 
+    <delete id="deleteSubAlgorithmByUploadId" parameterType="Long">
+        delete from t_sub_algorithm where upload_id = #{id}
+    </delete>
+
     <delete id="deleteSubAlgorithmByIds" parameterType="String">
         delete from t_sub_algorithm where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">

+ 4 - 0
pdaaphm-admin/src/main/resources/mapper/conf/AlgorithmIoFieldMapper.xml

@@ -88,6 +88,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         delete from t_algorithm_io_field where id = #{id}
     </delete>
 
+    <delete id="deleteAlgorithmIoFieldBySubTypeId" parameterType="Long">
+        delete from t_algorithm_io_field where algorithm_sub_id = #{id}
+    </delete>
+
     <delete id="deleteAlgorithmIoFieldByIds" parameterType="String">
         delete from t_algorithm_io_field where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">

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

@@ -165,7 +165,7 @@
             size="mini"
             type="text"
             icon="el-icon-warning-outline"
-            @click="handleUpdate(scope.row)"
+            @click="viewResult(scope.row)"
             v-hasPermi="['algoManager:algorithm:edit']"
           >查看结果</el-button>
           <el-button
@@ -226,7 +226,7 @@
               placeholder="请选择文件"
               clearable
               filterable
-              :disabled="form.status == 2"
+              :disabled="form.status == 2 || item.type == 2"
             >
               <el-option
                 v-for="file in fileList"
@@ -324,6 +324,11 @@ export default {
     this.getAlgoSubOption();
     this.getFileList();
   },
+  activated() {
+    this.getList();
+    this.getAlgoSubOption();
+    this.getFileList();
+  },
   methods: {
     /** 查询算法列表 */
     getList() {
@@ -430,6 +435,7 @@ export default {
             this.$modal.msgSuccess("成功");
             this.open = false;
             this.getList();
+            this.getFileList();
           });
         }
       });
@@ -461,6 +467,7 @@ export default {
     },
     
     createTypeMap() {
+      this.typeMap = new Map();
       for (const algorithmSub of this.algorithmSubList) {
         if(this.typeMap.has(algorithmSub.type)) {
           this.typeMap.get(algorithmSub.type).push({

+ 6 - 2
pdaaphm-ui/src/views/algoManager/file/index.vue

@@ -109,7 +109,7 @@
         <el-form-item label="文档路径" prop="path">
           <file-upload v-model="form.path"/>
         </el-form-item>
-        <el-form-item label="输入/输出" prop="type">
+        <!-- <el-form-item label="输入/输出" prop="type">
           <el-select v-model="form.type" placeholder="请选择输入输出类型" clearable filterable>
             <el-option
               v-for="dict in dict.type.algorithm_io_type"
@@ -118,7 +118,7 @@
               :value="dict.value"
             ></el-option>
           </el-select>
-        </el-form-item>
+        </el-form-item> -->
         <el-form-item label="备注" prop="remark">
           <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
         </el-form-item>
@@ -175,6 +175,9 @@ export default {
   created() {
     this.getList();
   },
+  activated() {
+    this.getList();
+  },
   methods: {
     /** 查询文件列表 */
     getList() {
@@ -242,6 +245,7 @@ export default {
       this.$refs["form"].validate(valid => {
         if (valid) {
           if(this.form.name == null) {
+            this.form.type = "1";
             this.form.name = this.getFileName(this.form.path);
           }
           if (this.form.id != null) {

+ 4 - 0
pdaaphm-ui/src/views/conf/field/index.vue

@@ -236,6 +236,10 @@ export default {
     this.getAlgoSubOption();
     this.getList();
   },
+  activated() {
+    this.getAlgoSubOption();
+    this.getList();
+  },
   methods: {
     /** 查询算法输入输出字段列表 */
     getList() {

+ 8 - 1
pdaaphm-ui/src/views/conf/subType/index.vue

@@ -89,7 +89,11 @@
       </el-table-column>
       <el-table-column label="算法子名称" align="center" prop="name" />
       <el-table-column label="算法url" align="center" prop="url" />
-      <el-table-column label="运行类型" align="center" prop="runType" />
+      <el-table-column label="运行类型" align="center" prop="runType">
+        <template slot-scope="scope">
+          <dict-tag :options="dict.type.run_type" :value="scope.row.runType"/>
+        </template>
+      </el-table-column>
       <el-table-column label="备注" align="center" prop="remark" />
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
         <template slot-scope="scope">
@@ -209,6 +213,9 @@ export default {
   created() {
     this.getList();
   },
+  activated() {
+    this.getList();
+  },
   methods: {
     /** 查询算法子类型列表 */
     getList() {