提交 6d497d93 编写于 作者: zhouweidong's avatar zhouweidong

优化初始化模型逻辑

上级 a8b1399d
...@@ -52,8 +52,8 @@ public class DynamicModelConfigExService extends DynamicModelConfigServiceImpl { ...@@ -52,8 +52,8 @@ public class DynamicModelConfigExService extends DynamicModelConfigServiceImpl {
@Lazy @Lazy
private IBZWFFeignClient wfClient; private IBZWFFeignClient wfClient;
@Value("${ibiz.dynamic.publicpath:/app/file/dynamicModel/publicpath}") @Value("${ibiz.dynamic.publishpath:/app/file/dynamicModel/publicpath}")
private String publicPath; private String publishPath;
@Autowired @Autowired
RedisTemplate<String, Object> redisOperations; RedisTemplate<String, Object> redisOperations;
...@@ -103,7 +103,7 @@ public class DynamicModelConfigExService extends DynamicModelConfigServiceImpl { ...@@ -103,7 +103,7 @@ public class DynamicModelConfigExService extends DynamicModelConfigServiceImpl {
List<FileItem> items = JSONArray.parseArray(strModelFile, FileItem.class); List<FileItem> items = JSONArray.parseArray(strModelFile, FileItem.class);
if (!ObjectUtils.isEmpty(items) && items.size() > 1) if (!ObjectUtils.isEmpty(items) && items.size() > 1)
throw new BadRequestAlertException(String.format("模型解析失败,[%s]模型文件过多", et.getConfigid()), "DynamicModelConfig", "unzip"); throw new BadRequestAlertException(String.format("模型解析失败,[%s]模型文件过多", et.getConfigid()), "DynamicModelConfig", "unzip");
File publishFile = new File(publicPath + systemId); File publishFile = new File(getPublishPath() + systemId);
//删除发布目录中的历史文件 //删除发布目录中的历史文件
if (publishFile.exists()) { if (publishFile.exists()) {
FileHelper.deleteDir(publishFile.getPath()); FileHelper.deleteDir(publishFile.getPath());
...@@ -143,10 +143,10 @@ public class DynamicModelConfigExService extends DynamicModelConfigServiceImpl { ...@@ -143,10 +143,10 @@ public class DynamicModelConfigExService extends DynamicModelConfigServiceImpl {
*/ */
@SneakyThrows @SneakyThrows
public List<Map<String, Object>> getDynamicModel(String systemId) { public List<Map<String, Object>> getDynamicModel(String systemId) {
String publishPath = publicPath + systemId; String pubPath = getPublishPath() + systemId;
List<Map<String, Object>> delogics = searchLogic(publishPath); List<Map<String, Object>> delogics = searchLogic(pubPath);
if (ObjectUtils.isEmpty(delogics)) { if (ObjectUtils.isEmpty(delogics)) {
throw new BadRequestAlertException(String.format("在发布目录[%s]中没有找到系统[%s]动态模型文件", publishPath, systemId), "DynamicModelConfig", "getDynamicModel"); throw new BadRequestAlertException(String.format("在发布目录[%s]中没有找到系统[%s]动态模型文件", pubPath, systemId), "DynamicModelConfig", "getDynamicModel");
} }
return delogics; return delogics;
} }
...@@ -154,12 +154,12 @@ public class DynamicModelConfigExService extends DynamicModelConfigServiceImpl { ...@@ -154,12 +154,12 @@ public class DynamicModelConfigExService extends DynamicModelConfigServiceImpl {
/** /**
* 从发布目录中查询 bpmn及drl * 从发布目录中查询 bpmn及drl
* *
* @param publishPath * @param path
* @return * @return
*/ */
public List<Map<String, Object>> searchLogic(String publishPath) { public List<Map<String, Object>> searchLogic(String path) {
List<Map<String, Object>> models = new ArrayList<>(); List<Map<String, Object>> models = new ArrayList<>();
File publish = new File(publishPath); File publish = new File(path);
if (!publish.exists()) { if (!publish.exists()) {
throw new BadRequestAlertException(String.format("发布目录[%s]不存在", publish.getPath()), "DynamicModelConfig", "search"); throw new BadRequestAlertException(String.format("发布目录[%s]不存在", publish.getPath()), "DynamicModelConfig", "search");
} }
...@@ -177,7 +177,7 @@ public class DynamicModelConfigExService extends DynamicModelConfigServiceImpl { ...@@ -177,7 +177,7 @@ public class DynamicModelConfigExService extends DynamicModelConfigServiceImpl {
file = new FileInputStream(subFile); file = new FileInputStream(subFile);
Map fileMap = new HashMap(); Map fileMap = new HashMap();
fileMap.put("filename", subFile.getName().toLowerCase()); fileMap.put("filename", subFile.getName().toLowerCase());
fileMap.put("filepath", subFile.getPath().replace(publicPath, "").toLowerCase()); fileMap.put("filepath", subFile.getPath().replace(getPublishPath(), "").toLowerCase());
fileMap.put("filecontent", IOUtils.toString(file, "UTF-8")); fileMap.put("filecontent", IOUtils.toString(file, "UTF-8"));
models.add(fileMap); models.add(fileMap);
} catch (IOException e) { } catch (IOException e) {
...@@ -198,12 +198,12 @@ public class DynamicModelConfigExService extends DynamicModelConfigServiceImpl { ...@@ -198,12 +198,12 @@ public class DynamicModelConfigExService extends DynamicModelConfigServiceImpl {
/** /**
* 从查询工作流 bpmn * 从查询工作流 bpmn
* *
* @param publishPath * @param pubPath
* @return * @return
*/ */
public List<Map<String, Object>> searchWorkFlow(String publishPath) { public List<Map<String, Object>> searchWorkFlow(String pubPath) {
List<Map<String, Object>> models = new ArrayList<>(); List<Map<String, Object>> models = new ArrayList<>();
File publish = new File(publishPath); File publish = new File(pubPath);
if (!publish.exists()) { if (!publish.exists()) {
throw new BadRequestAlertException(String.format("发布目录[%s]不存在", publish.getPath()), "DynamicModelConfig", "search"); throw new BadRequestAlertException(String.format("发布目录[%s]不存在", publish.getPath()), "DynamicModelConfig", "search");
} }
...@@ -237,6 +237,21 @@ public class DynamicModelConfigExService extends DynamicModelConfigServiceImpl { ...@@ -237,6 +237,21 @@ public class DynamicModelConfigExService extends DynamicModelConfigServiceImpl {
return models; return models;
} }
/**
* 获取发布目录
*
* @return
*/
public String getPublishPath() {
if (!StringUtils.isEmpty(publishPath)) {
publishPath = publishPath.replace("\\\\", File.separator).replace("\\", File.separator).replace("/", File.separator);
if (!publishPath.endsWith(File.separator)) {
publishPath = publishPath + File.separator;
}
}
return publishPath;
}
/** /**
* 获取系统标识 * 获取系统标识
* *
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册