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

优化初始化模型逻辑

上级 a8b1399d
......@@ -52,8 +52,8 @@ public class DynamicModelConfigExService extends DynamicModelConfigServiceImpl {
@Lazy
private IBZWFFeignClient wfClient;
@Value("${ibiz.dynamic.publicpath:/app/file/dynamicModel/publicpath}")
private String publicPath;
@Value("${ibiz.dynamic.publishpath:/app/file/dynamicModel/publicpath}")
private String publishPath;
@Autowired
RedisTemplate<String, Object> redisOperations;
......@@ -103,7 +103,7 @@ public class DynamicModelConfigExService extends DynamicModelConfigServiceImpl {
List<FileItem> items = JSONArray.parseArray(strModelFile, FileItem.class);
if (!ObjectUtils.isEmpty(items) && items.size() > 1)
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()) {
FileHelper.deleteDir(publishFile.getPath());
......@@ -143,10 +143,10 @@ public class DynamicModelConfigExService extends DynamicModelConfigServiceImpl {
*/
@SneakyThrows
public List<Map<String, Object>> getDynamicModel(String systemId) {
String publishPath = publicPath + systemId;
List<Map<String, Object>> delogics = searchLogic(publishPath);
String pubPath = getPublishPath() + systemId;
List<Map<String, Object>> delogics = searchLogic(pubPath);
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;
}
......@@ -154,12 +154,12 @@ public class DynamicModelConfigExService extends DynamicModelConfigServiceImpl {
/**
* 从发布目录中查询 bpmn及drl
*
* @param publishPath
* @param path
* @return
*/
public List<Map<String, Object>> searchLogic(String publishPath) {
public List<Map<String, Object>> searchLogic(String path) {
List<Map<String, Object>> models = new ArrayList<>();
File publish = new File(publishPath);
File publish = new File(path);
if (!publish.exists()) {
throw new BadRequestAlertException(String.format("发布目录[%s]不存在", publish.getPath()), "DynamicModelConfig", "search");
}
......@@ -177,7 +177,7 @@ public class DynamicModelConfigExService extends DynamicModelConfigServiceImpl {
file = new FileInputStream(subFile);
Map fileMap = new HashMap();
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"));
models.add(fileMap);
} catch (IOException e) {
......@@ -198,12 +198,12 @@ public class DynamicModelConfigExService extends DynamicModelConfigServiceImpl {
/**
* 从查询工作流 bpmn
*
* @param publishPath
* @param pubPath
* @return
*/
public List<Map<String, Object>> searchWorkFlow(String publishPath) {
public List<Map<String, Object>> searchWorkFlow(String pubPath) {
List<Map<String, Object>> models = new ArrayList<>();
File publish = new File(publishPath);
File publish = new File(pubPath);
if (!publish.exists()) {
throw new BadRequestAlertException(String.format("发布目录[%s]不存在", publish.getPath()), "DynamicModelConfig", "search");
}
......@@ -237,6 +237,21 @@ public class DynamicModelConfigExService extends DynamicModelConfigServiceImpl {
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 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册