Commit c4d080d1 by 吴佳

兼容ZK saveData\loadData 调整

parent cf6f5741
......@@ -963,7 +963,7 @@ public class MdaUtils {
//在第一行写入module 名字
os.insertLine(0,module.getName());
try {
os.getOutputStream().write((module.getName()).getBytes(StandardCharsets.UTF_8));
os.getOutputStream().write(("\r"+module.getName()).getBytes(StandardCharsets.UTF_8));
}catch (IOException e){
log.error("流数据写入失败");
}
......@@ -976,7 +976,7 @@ public class MdaUtils {
private static void writeData(String parentDir ,IModule module, IStream os) {
String thisDir = "";
if(parentDir.length() !=0){
thisDir = parentDir +"\\";
thisDir = parentDir +File.separator;
}
String moduleName = module.getClass().getName();
......@@ -1013,7 +1013,7 @@ public class MdaUtils {
String line = thisDir+ fieldName + "=" + newFieldVal;
// os.insertLine(0,line);
try {
os.getOutputStream().write(("\r\n"+line).getBytes(StandardCharsets.UTF_8));
os.getOutputStream().write(("\r"+line).getBytes(StandardCharsets.UTF_8));
}catch (IOException e){
log.error("流数据写入失败");
}
......@@ -1035,24 +1035,41 @@ public class MdaUtils {
return Codetables.getCodetableLabel(key, codetable, locale.getLanguage());
}
public static void loadMdlData(IModule module, IStream stream) {
public static void loadMdlData(IModule module, String moduleName ,IStream stream) {
module.clear();
String[] lines = null;
try {
lines = stream.getOutputStream().toString().split("\r\n");
lines = stream.getOutputStream().toString().split("\r");
}catch (Exception e){
log.error("获取流数据失败");
}
boolean isLoading = false;
if(lines.length > 0){
// Class moduleClass = module.getClass();
for (String line : lines ) {
Class moduleClass = module.getClass();
if(moduleClass.getName().toUpperCase().indexOf(line.toUpperCase()) != -1){
//去除空格
line.trim();
//空行和#开头的注释行 跳过
if(line.length() == 0 || line.indexOf("#") == 0){
continue;
}
//读取到本模型模型名相同数据的行,开始获取模型数据
if(moduleName.toUpperCase().indexOf(line.toUpperCase()) != -1){
//开始获取模型数据标识
isLoading = true;
continue;
}
if(isLoading){
//读取到下一个模型(不包含"="好的列为模型名),跳出循环
if(line.indexOf("=") == -1) {
break;
}
//获取模型数据
String val = line.split("=")[1].trim();
String key = line.split("=")[0].trim();
readData(module,key,val);
}
}
}
}
......@@ -1063,7 +1080,7 @@ public class MdaUtils {
String moduleName = moduleClass.getName();
Method getMethod = null ;
Method setMethod = null ;
if(key.indexOf("\\") == -1){//叶子节点赋值
if(key.indexOf(File.separator) == -1){//叶子节点赋值
//获取setXXX方法名
fieldName = key;
String setMethodName = "set" + fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1);
......@@ -1101,8 +1118,8 @@ public class MdaUtils {
}
}else{//非叶子节点继续迭代
//获取setXXX方法名
fieldName = key.substring(0,key.indexOf("\\"));
String newKey = key.substring(key.indexOf("\\")+1);
fieldName = key.substring(0,key.indexOf(File.separator));
String newKey = key.substring(key.indexOf(File.separator)+1);
String getMethodName = "get" + fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1);
try {
//查询getXXX方法
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment