提交 5084f748 编写于 作者: zhouweidong's avatar zhouweidong

副本逻辑优化

上级 47dd6b9a
...@@ -70,14 +70,18 @@ public class MetaDynamicModelExService extends MetaDynamicModelServiceImpl { ...@@ -70,14 +70,18 @@ public class MetaDynamicModelExService extends MetaDynamicModelServiceImpl {
@Override @Override
public boolean create(MetaDynamicModel et) { public boolean create(MetaDynamicModel et) {
et.setConfigid((String)et.getDefaultKey(true)); et.setConfigid((String)et.getDefaultKey(true));
super.create(et); JSONObject system = unzip(et);
return unzip(et); boolean result = super.create(et);
createSubDynaInst(et,system);
return result;
} }
@Override @Override
public boolean update(MetaDynamicModel et) { public boolean update(MetaDynamicModel et) {
super.update(et); JSONObject system = unzip(et);
return unzip(et); boolean result = super.update(et);
createSubDynaInst(et,system);
return result;
} }
/** /**
...@@ -85,7 +89,7 @@ public class MetaDynamicModelExService extends MetaDynamicModelServiceImpl { ...@@ -85,7 +89,7 @@ public class MetaDynamicModelExService extends MetaDynamicModelServiceImpl {
* *
* @param et * @param et
*/ */
private boolean unzip(MetaDynamicModel et) { private JSONObject unzip(MetaDynamicModel et) {
try { try {
File modelFile = null; File modelFile = null;
JSONObject system = null; JSONObject system = null;
...@@ -115,8 +119,24 @@ public class MetaDynamicModelExService extends MetaDynamicModelServiceImpl { ...@@ -115,8 +119,24 @@ public class MetaDynamicModelExService extends MetaDynamicModelServiceImpl {
}else{ }else{
throw new BadRequestAlertException("文件后缀名异常,请以zip或tar.gz作为后缀名", "MetaDynamicModel", "unzip"); throw new BadRequestAlertException("文件后缀名异常,请以zip或tar.gz作为后缀名", "MetaDynamicModel", "unzip");
} }
et.setDynainstid(system.getString("getPSDynaInstId")); if(!ObjectUtils.isEmpty(system)) {
et.setSystemId(system.getString("name")); et.setDynainstid(system.getString("getPSDynaInstId"));
et.setSystemId(system.getString("name"));
}
return system;
} catch (IOException e) {
throw new BadRequestAlertException("解析动态模型文件失败," + e, "MetaDynamicModel", "unzip");
}
}
/**
* 创建副本实例
* @param et
* @param system
* @return
*/
private void createSubDynaInst(MetaDynamicModel et,JSONObject system){
if(!ObjectUtils.isEmpty(system)){
JSONArray array = system.getJSONArray("getPSDynaInsts"); JSONArray array = system.getJSONArray("getPSDynaInsts");
List<MetaDynamicModel> metaDynamicModels = new ArrayList<>(); List<MetaDynamicModel> metaDynamicModels = new ArrayList<>();
if(!ObjectUtils.isEmpty(array)){ if(!ObjectUtils.isEmpty(array)){
...@@ -133,9 +153,6 @@ public class MetaDynamicModelExService extends MetaDynamicModelServiceImpl { ...@@ -133,9 +153,6 @@ public class MetaDynamicModelExService extends MetaDynamicModelServiceImpl {
} }
dynamicModelService.saveOrUpdateBatch(metaDynamicModels); dynamicModelService.saveOrUpdateBatch(metaDynamicModels);
} }
return true;
} catch (IOException e) {
throw new BadRequestAlertException("解析动态模型文件失败," + e, "MetaDynamicModel", "unzip");
} }
} }
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册