|
@@ -20,7 +20,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
@Slf4j
|
|
|
public class RWDDownloadUtil {
|
|
|
|
|
|
- public static void LoadConfig(String path) throws Exception {
|
|
|
+ public static void LoadConfig(String path, LogOfDownload LogOfDownload) throws Exception {
|
|
|
FileUtil.deleteRecursive(new File(path));
|
|
|
JSONArray classArray = null;
|
|
|
List<String> groupCodeList = new CopyOnWriteArrayList<String>();
|
|
@@ -51,11 +51,11 @@ public class RWDDownloadUtil {
|
|
|
}
|
|
|
if (classArray != null && classArray.size() == 1) {
|
|
|
JSONObject item = (JSONObject) classArray.get(0);
|
|
|
- FileUtil.Save(path, FastJsonUtil.toFormatString(item.get("itemData")));
|
|
|
+ FileUtil.Save(path, FastJsonUtil.toFormatString(item.get("itemData")), LogOfDownload.downloadList);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static boolean Process_physical_world() throws Exception {
|
|
|
+ public static boolean Process_physical_world(LogOfDownload LogOfDownload) throws Exception {
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
String validPath = Constant.getLatestPath(Constant.physical_world, true);
|
|
|
// 存储临时文件
|
|
@@ -63,39 +63,34 @@ public class RWDDownloadUtil {
|
|
|
{
|
|
|
String tmpPath = Constant.physical_world + Constant.getSeperator() + "tmp1";
|
|
|
dir1 = new File(tmpPath);
|
|
|
- RWDDownloadUtil.LoadPhysicalWorld(tmpPath);
|
|
|
+ RWDDownloadUtil.LoadPhysicalWorld(tmpPath, LogOfDownload);
|
|
|
}
|
|
|
File dir2;
|
|
|
{
|
|
|
String tmpPath = Constant.physical_world + Constant.getSeperator() + "tmp2";
|
|
|
dir2 = new File(tmpPath);
|
|
|
- RWDDownloadUtil.LoadPhysicalWorld(tmpPath);
|
|
|
+ RWDDownloadUtil.LoadPhysicalWorld(tmpPath, LogOfDownload);
|
|
|
}
|
|
|
// 检查一致性
|
|
|
- boolean compare = FileUtil.compareRecursive(dir1, dir2);
|
|
|
+ boolean compare = FileUtil.compareRecursive(dir1, dir2, null);
|
|
|
log.debug("Compare tmp1" + (compare ? "==" : "!=") + "tmp2");
|
|
|
boolean result;
|
|
|
if (compare) {
|
|
|
- File valid = null;
|
|
|
+ boolean compare_valid = false;
|
|
|
if (validPath != null) {
|
|
|
- valid = new File(validPath);
|
|
|
+ File valid = new File(validPath);
|
|
|
+ compare_valid = FileUtil.compareRecursive(valid, dir2, LogOfDownload);
|
|
|
+ LogOfDownload.pathOld = 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.physical_world + Constant.getSeperator() + sdf.format(currTime)));
|
|
|
- result = true;
|
|
|
- }
|
|
|
- } else {
|
|
|
+ if (!compare_valid) {
|
|
|
// 移动tmp2
|
|
|
Date currTime = new Date();
|
|
|
- dir2.renameTo(new File(Constant.physical_world + Constant.getSeperator() + sdf.format(currTime)));
|
|
|
+ String pathNew = Constant.physical_world + Constant.getSeperator() + sdf.format(currTime);
|
|
|
+ dir2.renameTo(new File(pathNew));
|
|
|
+ LogOfDownload.pathNew = pathNew;
|
|
|
result = true;
|
|
|
+ } else {
|
|
|
+ result = false;
|
|
|
}
|
|
|
} else {
|
|
|
result = false;
|
|
@@ -106,7 +101,7 @@ public class RWDDownloadUtil {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- public static void LoadPhysicalWorld(String path) throws Exception {
|
|
|
+ public static void LoadPhysicalWorld(String path, LogOfDownload LogOfDownload) throws Exception {
|
|
|
log.debug("Download physical world refresh dir");
|
|
|
FileUtil.deleteRecursive(new File(path));
|
|
|
{
|
|
@@ -140,7 +135,7 @@ public class RWDDownloadUtil {
|
|
|
JSONObject resultJSON = JSON.parseObject(post_result);
|
|
|
classArray = resultJSON.getJSONArray("data");
|
|
|
classArray = classArray == null ? new JSONArray() : classArray;
|
|
|
- FileUtil.Save(path + Constant.getSeperator() + "classArray.json", FastJsonUtil.toFormatString(classArray));
|
|
|
+ FileUtil.Save(path + Constant.getSeperator() + "classArray.json", FastJsonUtil.toFormatString(classArray), LogOfDownload.downloadList);
|
|
|
}
|
|
|
for (int i = 0; i < classArray.size(); i++) {
|
|
|
JSONObject item = (JSONObject) classArray.get(i);
|
|
@@ -159,7 +154,8 @@ public class RWDDownloadUtil {
|
|
|
infoArray = resultJSON.getJSONArray("data");
|
|
|
}
|
|
|
infoArray = infoArray == null ? new JSONArray() : infoArray;
|
|
|
- FileUtil.Save(path + Constant.getSeperator() + "info" + Constant.getSeperator() + code + ".json", FastJsonUtil.toFormatString(infoArray));
|
|
|
+ FileUtil.Save(path + Constant.getSeperator() + "info" + Constant.getSeperator() + code + ".json", FastJsonUtil.toFormatString(infoArray),
|
|
|
+ LogOfDownload.downloadList);
|
|
|
}
|
|
|
Map<String, Boolean> objTypeMap = new ConcurrentHashMap<String, Boolean>();
|
|
|
for (int i = 0; i < classArray.size(); i++) {
|
|
@@ -196,7 +192,7 @@ public class RWDDownloadUtil {
|
|
|
}
|
|
|
infoArray = infoArray == null ? new JSONArray() : infoArray;
|
|
|
FileUtil.Save(path + Constant.getSeperator() + "object" + Constant.getSeperator() + code + ".json",
|
|
|
- FastJsonUtil.toFormatString(infoArray));
|
|
|
+ FastJsonUtil.toFormatString(infoArray), LogOfDownload.downloadList);
|
|
|
}
|
|
|
Map<String, Map<String, Integer>> relDic = new ConcurrentHashMap<String, Map<String, Integer>>();
|
|
|
try (InputStream stream = Constant.getStream("relation.xlsx")) {
|
|
@@ -228,13 +224,13 @@ public class RWDDownloadUtil {
|
|
|
}
|
|
|
infoArray = infoArray == null ? new JSONArray() : infoArray;
|
|
|
FileUtil.Save(path + Constant.getSeperator() + "relation" + Constant.getSeperator() + graphCode + Constant.getSeperator() + relCode
|
|
|
- + ".json", FastJsonUtil.toFormatString(infoArray));
|
|
|
+ + ".json", FastJsonUtil.toFormatString(infoArray), LogOfDownload.downloadList);
|
|
|
}
|
|
|
}
|
|
|
log.debug("Download physical world finish " + path);
|
|
|
}
|
|
|
|
|
|
- public static boolean Process_zkt_physical_world() throws Exception {
|
|
|
+ public static boolean Process_zkt_physical_world(LogOfDownload LogOfDownload) throws Exception {
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
String validPath = Constant.getLatestPath(Constant.zkt_physical_world, true);
|
|
|
// 存储临时文件
|
|
@@ -242,39 +238,34 @@ public class RWDDownloadUtil {
|
|
|
{
|
|
|
String tmpPath = Constant.zkt_physical_world + Constant.getSeperator() + "tmp1";
|
|
|
dir1 = new File(tmpPath);
|
|
|
- RWDDownloadUtil.LoadZKTPhysicalWorld(tmpPath);
|
|
|
+ RWDDownloadUtil.LoadZKTPhysicalWorld(tmpPath, LogOfDownload);
|
|
|
}
|
|
|
File dir2;
|
|
|
{
|
|
|
String tmpPath = Constant.zkt_physical_world + Constant.getSeperator() + "tmp2";
|
|
|
dir2 = new File(tmpPath);
|
|
|
- RWDDownloadUtil.LoadZKTPhysicalWorld(tmpPath);
|
|
|
+ RWDDownloadUtil.LoadZKTPhysicalWorld(tmpPath, LogOfDownload);
|
|
|
}
|
|
|
// 检查一致性
|
|
|
- boolean compare = FileUtil.compareRecursive(dir1, dir2);
|
|
|
+ boolean compare = FileUtil.compareRecursive(dir1, dir2, null);
|
|
|
log.debug("Compare tmp1" + (compare ? "==" : "!=") + "tmp2");
|
|
|
boolean result;
|
|
|
if (compare) {
|
|
|
- File valid = null;
|
|
|
+ boolean compare_valid = false;
|
|
|
if (validPath != null) {
|
|
|
- valid = new File(validPath);
|
|
|
+ File valid = new File(validPath);
|
|
|
+ compare_valid = FileUtil.compareRecursive(valid, dir2, LogOfDownload);
|
|
|
+ LogOfDownload.pathOld = 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_physical_world + Constant.getSeperator() + sdf.format(currTime)));
|
|
|
- result = true;
|
|
|
- }
|
|
|
- } else {
|
|
|
+ if (!compare_valid) {
|
|
|
// 移动tmp2
|
|
|
Date currTime = new Date();
|
|
|
- dir2.renameTo(new File(Constant.zkt_physical_world + Constant.getSeperator() + sdf.format(currTime)));
|
|
|
+ String pathNew = Constant.zkt_physical_world + Constant.getSeperator() + sdf.format(currTime);
|
|
|
+ dir2.renameTo(new File(pathNew));
|
|
|
+ LogOfDownload.pathNew = pathNew;
|
|
|
result = true;
|
|
|
+ } else {
|
|
|
+ result = false;
|
|
|
}
|
|
|
} else {
|
|
|
result = false;
|
|
@@ -285,7 +276,7 @@ public class RWDDownloadUtil {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- public static void LoadZKTPhysicalWorld(String path) throws Exception {
|
|
|
+ public static void LoadZKTPhysicalWorld(String path, LogOfDownload LogOfDownload) throws Exception {
|
|
|
log.debug("Download zkt physical world refresh dir");
|
|
|
FileUtil.deleteRecursive(new File(path));
|
|
|
{
|
|
@@ -312,7 +303,7 @@ public class RWDDownloadUtil {
|
|
|
param.toJSONString());
|
|
|
sceneArray = JSON.parseArray(post_result);
|
|
|
sceneArray = sceneArray == null ? new JSONArray() : sceneArray;
|
|
|
- FileUtil.Save(path + Constant.getSeperator() + "sceneArray.json", FastJsonUtil.toFormatString(sceneArray));
|
|
|
+ FileUtil.Save(path + Constant.getSeperator() + "sceneArray.json", FastJsonUtil.toFormatString(sceneArray), LogOfDownload.downloadList);
|
|
|
}
|
|
|
JSONArray classArray;
|
|
|
{
|
|
@@ -326,7 +317,7 @@ public class RWDDownloadUtil {
|
|
|
JSONObject resultJSON = JSON.parseObject(post_result);
|
|
|
classArray = resultJSON.getJSONArray("data");
|
|
|
classArray = classArray == null ? new JSONArray() : classArray;
|
|
|
- FileUtil.Save(path + Constant.getSeperator() + "classArray.json", FastJsonUtil.toFormatString(classArray));
|
|
|
+ FileUtil.Save(path + Constant.getSeperator() + "classArray.json", FastJsonUtil.toFormatString(classArray), LogOfDownload.downloadList);
|
|
|
}
|
|
|
for (int i = 0; i < classArray.size(); i++) {
|
|
|
JSONObject item = (JSONObject) classArray.get(i);
|
|
@@ -352,7 +343,7 @@ public class RWDDownloadUtil {
|
|
|
sceneDir.mkdir();
|
|
|
}
|
|
|
FileUtil.Save(path + Constant.getSeperator() + "object" + Constant.getSeperator() + ibmsSceneCode + Constant.getSeperator()
|
|
|
- + ibmsClassCode + ".json", FastJsonUtil.toFormatString(infoArray));
|
|
|
+ + ibmsClassCode + ".json", FastJsonUtil.toFormatString(infoArray), LogOfDownload.downloadList);
|
|
|
}
|
|
|
log.debug("Download zkt physical world finish " + path);
|
|
|
|
|
@@ -417,7 +408,8 @@ public class RWDDownloadUtil {
|
|
|
item.put("name", alarmTypeMap.get(key));
|
|
|
alarmTypeArray.add(item);
|
|
|
}
|
|
|
- FileUtil.Save(path + Constant.getSeperator() + "alarmTypeArray.json", FastJsonUtil.toFormatString(alarmTypeArray));
|
|
|
+ FileUtil.Save(path + Constant.getSeperator() + "alarmTypeArray.json", FastJsonUtil.toFormatString(alarmTypeArray),
|
|
|
+ LogOfDownload.downloadList);
|
|
|
}
|
|
|
|
|
|
{
|
|
@@ -466,11 +458,12 @@ public class RWDDownloadUtil {
|
|
|
JSONObject resultJSON = JSON.parseObject(post_result);
|
|
|
alarmConfigArray = resultJSON.getJSONArray("Content");
|
|
|
}
|
|
|
- FileUtil.Save(path + Constant.getSeperator() + "zkt_alarm_config.json", FastJsonUtil.toFormatString(alarmConfigArray));
|
|
|
+ FileUtil.Save(path + Constant.getSeperator() + "zkt_alarm_config.json", FastJsonUtil.toFormatString(alarmConfigArray),
|
|
|
+ LogOfDownload.downloadList);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static boolean Process_ibms_physical_world() throws Exception {
|
|
|
+ public static boolean Process_ibms_physical_world(LogOfDownload LogOfDownload) throws Exception {
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
String validPath = Constant.getLatestPath(Constant.ibms_physical_world, true);
|
|
|
// 存储临时文件
|
|
@@ -478,39 +471,34 @@ public class RWDDownloadUtil {
|
|
|
{
|
|
|
String tmpPath = Constant.ibms_physical_world + Constant.getSeperator() + "tmp1";
|
|
|
dir1 = new File(tmpPath);
|
|
|
- RWDDownloadUtil.LoadIBMSPhysicalWorld(tmpPath);
|
|
|
+ RWDDownloadUtil.LoadIBMSPhysicalWorld(tmpPath, LogOfDownload);
|
|
|
}
|
|
|
File dir2;
|
|
|
{
|
|
|
String tmpPath = Constant.ibms_physical_world + Constant.getSeperator() + "tmp2";
|
|
|
dir2 = new File(tmpPath);
|
|
|
- RWDDownloadUtil.LoadIBMSPhysicalWorld(tmpPath);
|
|
|
+ RWDDownloadUtil.LoadIBMSPhysicalWorld(tmpPath, LogOfDownload);
|
|
|
}
|
|
|
// 检查一致性
|
|
|
- boolean compare = FileUtil.compareRecursive(dir1, dir2);
|
|
|
+ boolean compare = FileUtil.compareRecursive(dir1, dir2, null);
|
|
|
log.debug("Compare tmp1" + (compare ? "==" : "!=") + "tmp2");
|
|
|
boolean result;
|
|
|
if (compare) {
|
|
|
- File valid = null;
|
|
|
+ boolean compare_valid = false;
|
|
|
if (validPath != null) {
|
|
|
- valid = new File(validPath);
|
|
|
+ File valid = new File(validPath);
|
|
|
+ compare_valid = FileUtil.compareRecursive(valid, dir2, LogOfDownload);
|
|
|
+ LogOfDownload.pathOld = 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.ibms_physical_world + Constant.getSeperator() + sdf.format(currTime)));
|
|
|
- result = true;
|
|
|
- }
|
|
|
- } else {
|
|
|
+ if (!compare_valid) {
|
|
|
// 移动tmp2
|
|
|
Date currTime = new Date();
|
|
|
- dir2.renameTo(new File(Constant.ibms_physical_world + Constant.getSeperator() + sdf.format(currTime)));
|
|
|
+ String pathNew = Constant.ibms_physical_world + Constant.getSeperator() + sdf.format(currTime);
|
|
|
+ dir2.renameTo(new File(pathNew));
|
|
|
+ LogOfDownload.pathNew = pathNew;
|
|
|
result = true;
|
|
|
+ } else {
|
|
|
+ result = false;
|
|
|
}
|
|
|
} else {
|
|
|
result = false;
|
|
@@ -566,7 +554,7 @@ public class RWDDownloadUtil {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- public static void LoadIBMSPhysicalWorld(String path) throws Exception {
|
|
|
+ public static void LoadIBMSPhysicalWorld(String path, LogOfDownload LogOfDownload) throws Exception {
|
|
|
log.debug("Download ibms physical world refresh dir");
|
|
|
FileUtil.deleteRecursive(new File(path));
|
|
|
{
|
|
@@ -585,7 +573,7 @@ public class RWDDownloadUtil {
|
|
|
criteria.put("projectId", RepositoryContainer.RepositoryProject.projectId);
|
|
|
criteria.put("groupCode", RepositoryContainer.RepositoryProject.groupCode);
|
|
|
classArray = post_by_page("zkt_monitor", Constant.zkt_monitor_url + "/logicalGrouping/list", criteria, page_size);
|
|
|
- FileUtil.Save(path + Constant.getSeperator() + "groupArray.json", FastJsonUtil.toFormatString(classArray));
|
|
|
+ FileUtil.Save(path + Constant.getSeperator() + "groupArray.json", FastJsonUtil.toFormatString(classArray), LogOfDownload.downloadList);
|
|
|
}
|
|
|
Map<String, Map<String, List<String>>> idListMapMap = new ConcurrentHashMap<String, Map<String, List<String>>>();
|
|
|
for (int i = 0; i < classArray.size(); i++) {
|
|
@@ -627,7 +615,7 @@ public class RWDDownloadUtil {
|
|
|
}
|
|
|
infoArray = infoArray == null ? new JSONArray() : infoArray;
|
|
|
FileUtil.Save(path + Constant.getSeperator() + ibmsSceneCode + Constant.getSeperator() + ibmsClassCode + ".json",
|
|
|
- FastJsonUtil.toFormatString(infoArray));
|
|
|
+ FastJsonUtil.toFormatString(infoArray), LogOfDownload.downloadList);
|
|
|
}
|
|
|
}
|
|
|
log.debug("Download ibms physical world finish " + path);
|