提交 bf510c0c 编写于 作者: tangyaolong's avatar tangyaolong

优化逻辑

上级 30b2c75f
...@@ -84,8 +84,8 @@ public class DynamicModelConfigExService extends DynamicModelConfigServiceImpl { ...@@ -84,8 +84,8 @@ public class DynamicModelConfigExService extends DynamicModelConfigServiceImpl {
String unzipPath = modelFile.getParent().replace("ibizutil", "dynamicmodel"); String unzipPath = modelFile.getParent().replace("ibizutil", "dynamicmodel");
if(".gz".equals(modelFile.getName().substring(modelFile.getName().lastIndexOf(".")))){ if(".gz".equals(modelFile.getName().substring(modelFile.getName().lastIndexOf(".")))){
String fileName = modelFile.getName().substring(0,modelFile.getName().indexOf(".")); String fileName = modelFile.getName().substring(0,modelFile.getName().indexOf("."));
FileHelper.unTarGz(modelFile, unzipPath); FileHelper.unTarGz(modelFile, unzipPath, true);
system = getSystem(unzipPath,fileName); system = getSystem(unzipPath);
}else if(".zip".equals(modelFile.getName().substring(modelFile.getName().lastIndexOf(".")))){ }else if(".zip".equals(modelFile.getName().substring(modelFile.getName().lastIndexOf(".")))){
FileHelper.unzip(modelFile, unzipPath, true); FileHelper.unzip(modelFile, unzipPath, true);
system = getSystem(unzipPath); system = getSystem(unzipPath);
...@@ -130,14 +130,14 @@ public class DynamicModelConfigExService extends DynamicModelConfigServiceImpl { ...@@ -130,14 +130,14 @@ public class DynamicModelConfigExService extends DynamicModelConfigServiceImpl {
List<Map<String, Object>> workflow = searchWorkFlow(publishFile.getPath()); List<Map<String, Object>> workflow = searchWorkFlow(publishFile.getPath());
//部署流程 //部署流程
if (workflow.size() > 0) { if (workflow.size() > 0) {
wfClient.deployBpmnFile(workflow); // wfClient.deployBpmnFile(workflow);
} }
//发送redis广播 //发送redis广播
Map<String, Object> message = new HashMap<>(); // Map<String, Object> message = new HashMap<>();
message.put("cacheName", "dynamicModel"); // message.put("cacheName", "dynamicModel");
message.put("dynamicModel", et.getConfigname()); // message.put("dynamicModel", et.getConfigname());
RedisPublisher redisPublisher = new RedisPublisher(redisOperations, RedisChannelTopic.REDIS_CACHE_DYNAMICMODEL_TOPIC.getChannelTopic()); // RedisPublisher redisPublisher = new RedisPublisher(redisOperations, RedisChannelTopic.REDIS_CACHE_DYNAMICMODEL_TOPIC.getChannelTopic());
redisPublisher.publisher(message); // redisPublisher.publisher(message);
//激活当前et. //激活当前et.
et.setStatus(StaticDict.DynamicModelStatus.ITEM_1.getValue()); et.setStatus(StaticDict.DynamicModelStatus.ITEM_1.getValue());
update(Wrappers.<DynamicModelConfig>lambdaUpdate().set(DynamicModelConfig::getStatus, StaticDict.DynamicModelStatus.ITEM_0.getValue()).eq(DynamicModelConfig::getSystemId, systemId)); update(Wrappers.<DynamicModelConfig>lambdaUpdate().set(DynamicModelConfig::getStatus, StaticDict.DynamicModelStatus.ITEM_0.getValue()).eq(DynamicModelConfig::getSystemId, systemId));
...@@ -181,7 +181,7 @@ public class DynamicModelConfigExService extends DynamicModelConfigServiceImpl { ...@@ -181,7 +181,7 @@ public class DynamicModelConfigExService extends DynamicModelConfigServiceImpl {
if (!ObjectUtils.isEmpty(subModels)) { if (!ObjectUtils.isEmpty(subModels)) {
models.addAll(subModels); models.addAll(subModels);
} }
} else if (subFile.isFile() && (!subFile.getName().equalsIgnoreCase("PSWFVERSION.json.bpm")) && (subFile.getName().endsWith(".bpmn") || subFile.getName().endsWith(".drl"))) { } else if (subFile.isFile() && (!subFile.getName().equalsIgnoreCase("PSWFVERSION.json.bpmn")) && (subFile.getName().endsWith(".bpmn") || subFile.getName().endsWith(".drl"))) {
InputStream file = null; InputStream file = null;
try { try {
file = new FileInputStream(subFile); file = new FileInputStream(subFile);
...@@ -300,43 +300,4 @@ public class DynamicModelConfigExService extends DynamicModelConfigServiceImpl { ...@@ -300,43 +300,4 @@ public class DynamicModelConfigExService extends DynamicModelConfigServiceImpl {
} }
return system; return system;
} }
/**
* gzip版获取系统标识
*
* @param filePath
* @return
*/
private JSONObject getSystem(String filePath,String fileName) {
JSONObject system = null;
InputStream in = null;
byte[] bytes = null;
try {
File file = new File(filePath + File.separator + fileName + File.separator+ "PSSYSTEM.json");
if (!file.exists()) {
throw new BadRequestAlertException(String.format("无法找到动态系统模型文件[%s]", file.getPath()), "DynamicModelConfig", "getSystemId");
}
in = new FileInputStream(file);
bytes = new byte[in.available()];
in.read(bytes);
} catch (Exception e) {
} finally {
try {
if (in != null) {
in.close();
}
} catch (IOException e) {
}
}
if (bytes != null) {
String strSystem = new String(bytes);
if (!StringUtils.isEmpty(strSystem)) {
system = JSONObject.parseObject(strSystem);
}
}
if (ObjectUtils.isEmpty(system)) {
throw new BadRequestAlertException("无法获取系统标识", "DynamicModelConfig", "getSystem");
}
return system;
}
} }
...@@ -76,25 +76,27 @@ public class FileHelper { ...@@ -76,25 +76,27 @@ public class FileHelper {
* @param zipFile zip文件路径 * @param zipFile zip文件路径
* @param descDir 解压目录 * @param descDir 解压目录
*/ */
public static void unTarGz(File zipFile, String descDir) throws IOException{ public static void unTarGz(File zipFile, String descDir,boolean exp) throws IOException{
TarInputStream tarIn = null; TarInputStream tarIn = null;
try{ try{
tarIn = new TarInputStream(new GZIPInputStream( tarIn = new TarInputStream(new GZIPInputStream(
new BufferedInputStream(new FileInputStream(zipFile))), new BufferedInputStream(new FileInputStream(zipFile))),
1024 * 2); 1024 * 2);
//创建输出目录 //创建输出目录
String root = zipFile.getName().replace(".tar.gz","/");
createDirectory(descDir,null); createDirectory(descDir,null);
TarEntry entry = null; TarEntry entry = null;
String fileName = null;
while((entry = tarIn.getNextEntry()) != null ){ while((entry = tarIn.getNextEntry()) != null ){
fileName = exp ? entry.getName().replace(root,"") : entry.getName();
if(entry.isDirectory()){ if(entry.isDirectory()){
//是目录
entry.getName();
//创建空目录 //创建空目录
createDirectory(descDir,entry.getName()); createDirectory(descDir,fileName);
}else{ }else{
fileName = exp ? entry.getName().replace(root,"") : entry.getName();
//是文件 //是文件
File tmpFile = new File(descDir + "/" + entry.getName()); File tmpFile = new File(descDir + "/" + fileName);
//创建输出目录 //创建输出目录
createDirectory(tmpFile.getParent() + "/",null); createDirectory(tmpFile.getParent() + "/",null);
OutputStream out = null; OutputStream out = null;
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册