|
@@ -466,6 +466,10 @@ public class RWDDownloadUtil {
|
|
|
|
|
|
public static void LoadZKTAlarmConfig(String path) throws Exception {
|
|
|
FileUtil.deleteRecursive(new File(path));
|
|
|
+ File root = new File(path);
|
|
|
+ if (!root.exists()) {
|
|
|
+ root.mkdir();
|
|
|
+ }
|
|
|
JSONArray alarmConfigArray = null;
|
|
|
List<String> groupCodeList = new ArrayList<String>();
|
|
|
groupCodeList.add(RepositoryContainer.RepositoryBase.groupCode);
|
|
@@ -491,27 +495,56 @@ public class RWDDownloadUtil {
|
|
|
}
|
|
|
}
|
|
|
if (alarmConfigArray != null) {
|
|
|
- FileUtil.Save(path, FastJsonUtil.toFormatString(alarmConfigArray));
|
|
|
+ FileUtil.Save(path + Constant.getSeperator() + "zkt_alarm_config.json", FastJsonUtil.toFormatString(alarmConfigArray));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public static boolean Process_zkt_alarm_config() throws Exception {
|
|
|
- String validPath = Constant.zkt_alarm_config;
|
|
|
- File valid = new File(validPath);
|
|
|
-
|
|
|
- String tmpPath = Constant.zkt_alarm_config + Constant.getSeperator() + "tmp" + ".json";
|
|
|
- LoadZKTAlarmConfig(tmpPath);
|
|
|
- File tmp = new File(tmpPath);
|
|
|
-
|
|
|
- boolean compare_valid = FileUtil.compareRecursive(valid, tmp);
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
+ String validPath = Constant.getLatestPath(Constant.zkt_alarm_config, true);
|
|
|
+ // 存储临时文件
|
|
|
+ File dir1;
|
|
|
+ {
|
|
|
+ String tmpPath = Constant.zkt_alarm_config + Constant.getSeperator() + "tmp1";
|
|
|
+ dir1 = new File(tmpPath);
|
|
|
+ RWDDownloadUtil.LoadZKTAlarmConfig(tmpPath);
|
|
|
+ }
|
|
|
+ File dir2;
|
|
|
+ {
|
|
|
+ String tmpPath = Constant.zkt_alarm_config + Constant.getSeperator() + "tmp2";
|
|
|
+ dir2 = new File(tmpPath);
|
|
|
+ RWDDownloadUtil.LoadZKTAlarmConfig(tmpPath);
|
|
|
+ }
|
|
|
+ // 检查一致性
|
|
|
+ boolean compare = FileUtil.compareRecursive(dir1, dir2);
|
|
|
+ log.debug("Compare tmp1" + (compare ? "==" : "!=") + "tmp2");
|
|
|
boolean result;
|
|
|
- if (!compare_valid) {
|
|
|
- tmp.renameTo(new File(Constant.zkt_alarm_config + Constant.getSeperator() + "zkt_alarm_config.json"));
|
|
|
- result = true;
|
|
|
+ if (compare) {
|
|
|
+ File valid = null;
|
|
|
+ if (validPath != null) {
|
|
|
+ valid = new File(validPath);
|
|
|
+ }
|
|
|
+ if (valid != null && valid.exists()) {
|
|
|
+ boolean compare_valid = FileUtil.compareRecursive(valid, dir2);
|
|
|
+ log.debug("Compare valid" + (compare_valid ? "==" : "!=") + "tmp2");
|
|
|
+ if (compare_valid) {
|
|
|
+ result = false;
|
|
|
+ } else {
|
|
|
+ // 移动tmp2
|
|
|
+ Date currTime = new Date();
|
|
|
+ dir2.renameTo(new File(Constant.zkt_alarm_config + Constant.getSeperator() + sdf.format(currTime)));
|
|
|
+ result = true;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 移动tmp2
|
|
|
+ Date currTime = new Date();
|
|
|
+ dir2.renameTo(new File(Constant.zkt_alarm_config + Constant.getSeperator() + sdf.format(currTime)));
|
|
|
+ result = true;
|
|
|
+ }
|
|
|
} else {
|
|
|
result = false;
|
|
|
}
|
|
|
- Clear(Constant.zkt_alarm_config, false);
|
|
|
+ Clear(Constant.zkt_alarm_config, true);
|
|
|
return result;
|
|
|
}
|
|
|
}
|