From 784ce3c64aebecd7e30ab9d4c88043e89c37b35d Mon Sep 17 00:00:00 2001 From: dengzedong <dengzedong@email> Date: 星期一, 25 十一月 2024 18:05:40 +0800 Subject: [PATCH] 添加方法的默认参数(pyFile,模型路径)bug --- iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/MpkFileServiceImpl.java | 58 +++++++++++++++++++++++++++++----------------------------- 1 files changed, 29 insertions(+), 29 deletions(-) diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/MpkFileServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/MpkFileServiceImpl.java index e63215f..4de8772 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/MpkFileServiceImpl.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mpk/service/impl/MpkFileServiceImpl.java @@ -166,36 +166,36 @@ @Override @DSTransactional(rollbackFor = Exception.class) public void update(MpkFileDTO dto) { - // 判断py文件是否修改 - MpkFileEntity oldEntity = selectById(dto.getId()); - if (!oldEntity.getFilePath().equals(dto.getFilePath())) { - // 将备份的pyd文件,转移到MDK_PKGS环境变量下,并添加方法的默认参数(pyFile,模型路径) - String mdkPkgs = System.getenv("MDK_PKGS"); - String fileName = dto.getFilePath().substring(dto.getFilePath().lastIndexOf("\\") + 1,dto.getFilePath().lastIndexOf(".pyd")); - String pyFilePath = mdkPkgs + File.separator + dto.getPyModule().replace(".", File.separator) + File.separator + fileName + ".pyd"; + // 添加方法的默认参数(pyFile,模型路径) + String mdkPkgs = System.getenv("MDK_PKGS"); + String fileName = dto.getFilePath().substring(dto.getFilePath().lastIndexOf("\\") + 1,dto.getFilePath().lastIndexOf(".pyd")); + String pyFilePath = mdkPkgs + File.separator + dto.getPyModule().replace(".", File.separator) + File.separator + fileName + ".pyd"; + // 判断文件是否存在,不存在的话将备份的pyd文件,转移到MDK_PKGS环境变量下 + File pyFile = new File(pyFilePath); + if (!pyFile.exists()) { FileUtil.mkParentDirs(pyFilePath); FileUtil.copy(dto.getFilePath(), pyFilePath, true); + } - // 添加/修改参数 - for (ModelMethodDTO method : dto.getModelMethods()) { - List<MethodSettingDTO> methodSettings = method.getMethodSettings(); - if (methodSettings.stream().anyMatch(e -> e.getSettingKey().equals(MdkConstant.PY_FILE_KEY))) { - methodSettings.forEach(e -> { - if (e.getSettingKey().equals(MdkConstant.PY_FILE_KEY)) { - e.setValue(dto.getPyModule() + "." + fileName); - } - }); - }else { - MethodSettingDTO setting = new MethodSettingDTO(); - setting.setId(UUID.randomUUID().toString()); - setting.setMethodId(method.getId()); - setting.setSettingKey(MdkConstant.PY_FILE_KEY); - setting.setValue(dto.getPyModule() + "." + fileName); - setting.setName("模型路径"); - setting.setType("input"); - setting.setValueType("string"); - methodSettings.add(setting); - } + // 添加/修改参数 + for (ModelMethodDTO method : dto.getModelMethods()) { + List<MethodSettingDTO> methodSettings = method.getMethodSettings(); + if (methodSettings.stream().anyMatch(e -> e.getSettingKey().equals(MdkConstant.PY_FILE_KEY))) { + methodSettings.forEach(e -> { + if (e.getSettingKey().equals(MdkConstant.PY_FILE_KEY)) { + e.setValue(dto.getPyModule() + "." + fileName); + } + }); + }else { + MethodSettingDTO setting = new MethodSettingDTO(); + setting.setId(UUID.randomUUID().toString()); + setting.setMethodId(method.getId()); + setting.setSettingKey(MdkConstant.PY_FILE_KEY); + setting.setValue(dto.getPyModule() + "." + fileName); + setting.setName("模型路径"); + setting.setType("input"); + setting.setValueType("string"); + methodSettings.add(setting); } } @@ -300,7 +300,7 @@ GenUtils.drawTemplate("Jni.h.vm", dataContext, jniHFile); // 添加python源文件 - String pyFilePath = dirPath.getAbsolutePath() + File.separator + MdkConstant.ALGS + File.separator + entity.getPyModule().replace(".", File.separator) + File.separator + entity.getPyName() + ".pyd"; + String pyFilePath = dirPath.getAbsolutePath() + File.separator + MdkConstant.ALGS + File.separator + entity.getPyModule().replace(".", File.separator) + File.separator + entity.getFilePath().substring(entity.getFilePath().lastIndexOf("\\")); FileUtil.mkParentDirs(pyFilePath); FileUtil.copy(entity.getFilePath(), pyFilePath, true); @@ -434,7 +434,7 @@ GenUtils.drawTemplate("Jni.h.vm", dataContext, jniHFile); // 添加python源文件 - String pyFilePath = dirPath.getAbsolutePath() + File.separator + MdkConstant.ALGS + File.separator + entity.getPyModule().replace(".", File.separator) + File.separator + entity.getPyName() + ".pyd"; + String pyFilePath = dirPath.getAbsolutePath() + File.separator + MdkConstant.ALGS + File.separator + entity.getPyModule().replace(".", File.separator) + File.separator + entity.getFilePath().substring(entity.getFilePath().lastIndexOf("\\")); FileUtil.mkParentDirs(pyFilePath); FileUtil.copy(entity.getFilePath(), pyFilePath, true); } -- Gitblit v1.9.3