|
@@ -230,8 +230,9 @@ public class RWDAlarmUtil {
|
|
}
|
|
}
|
|
|
|
|
|
public static void modify_alarm(JSONObject alarm) throws Exception {
|
|
public static void modify_alarm(JSONObject alarm) throws Exception {
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
|
|
|
- SimpleDateFormat sdf_ = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
|
|
|
+ SimpleDateFormat sdf_T = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
|
|
|
+ SimpleDateFormat sdf_blank = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
|
|
|
if (alarm.containsKey("triggerInfo")) {
|
|
if (alarm.containsKey("triggerInfo")) {
|
|
Object object = alarm.get("triggerInfo");
|
|
Object object = alarm.get("triggerInfo");
|
|
@@ -314,9 +315,9 @@ public class RWDAlarmUtil {
|
|
JSONArray comments = JSON.parseArray((String) commentObject);
|
|
JSONArray comments = JSON.parseArray((String) commentObject);
|
|
for (int i = 0; i < comments.size(); i++) {
|
|
for (int i = 0; i < comments.size(); i++) {
|
|
JSONObject one_comment = comments.getJSONObject(i);
|
|
JSONObject one_comment = comments.getJSONObject(i);
|
|
- String commentTime = one_comment.getString("commentTime");
|
|
|
|
- if (commentTime != null) {
|
|
|
|
- one_comment.put("commentTime", sdf.format(sdf_.parse(commentTime)));
|
|
|
|
|
|
+ if (one_comment.get("commentTime") != null) {
|
|
|
|
+ Object commentTime = one_comment.get("commentTime");
|
|
|
|
+ one_comment.put("commentTime", getTime(sdf_T, sdf_blank, sdf, commentTime));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
alarm.put("comments", comments);
|
|
alarm.put("comments", comments);
|
|
@@ -328,57 +329,21 @@ public class RWDAlarmUtil {
|
|
alarm.remove("comment");
|
|
alarm.remove("comment");
|
|
}
|
|
}
|
|
|
|
|
|
- if (alarm.containsKey("triggerTime")) {
|
|
|
|
- Object object = alarm.get("triggerTime");
|
|
|
|
- if (object != null) {
|
|
|
|
- if (object instanceof Long) {
|
|
|
|
- Long timeLong = (Long) object;
|
|
|
|
- alarm.put("triggerTime", sdf.format(new Date(timeLong)));
|
|
|
|
- } else if (object instanceof String) {
|
|
|
|
- String timeString = (String) object;
|
|
|
|
- try {
|
|
|
|
- alarm.put("triggerTime", sdf.format(sdf_.parse(timeString)));
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- // e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ if (alarm.get("triggerTime") != null) {
|
|
|
|
+ Object commentTime = alarm.get("triggerTime");
|
|
|
|
+ alarm.put("triggerTime", getTime(sdf_T, sdf_blank, sdf, commentTime));
|
|
}
|
|
}
|
|
- if (alarm.containsKey("endTime")) {
|
|
|
|
- Object object = alarm.get("endTime");
|
|
|
|
- if (object != null) {
|
|
|
|
- if (object instanceof Long) {
|
|
|
|
- Long timeLong = (Long) object;
|
|
|
|
- alarm.put("endTime", sdf.format(new Date(timeLong)));
|
|
|
|
- } else if (object instanceof String) {
|
|
|
|
- String timeString = (String) object;
|
|
|
|
- alarm.put("endTime", sdf.format(sdf_.parse(timeString)));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ if (alarm.get("endTime") != null) {
|
|
|
|
+ Object commentTime = alarm.get("endTime");
|
|
|
|
+ alarm.put("endTime", getTime(sdf_T, sdf_blank, sdf, commentTime));
|
|
}
|
|
}
|
|
- if (alarm.containsKey("createTime")) {
|
|
|
|
- Object object = alarm.get("createTime");
|
|
|
|
- if (object != null) {
|
|
|
|
- if (object instanceof Long) {
|
|
|
|
- Long timeLong = (Long) object;
|
|
|
|
- alarm.put("createTime", sdf.format(new Date(timeLong)));
|
|
|
|
- } else if (object instanceof String) {
|
|
|
|
- String timeString = (String) object;
|
|
|
|
- alarm.put("createTime", sdf.format(sdf_.parse(timeString)));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ if (alarm.get("createTime") != null) {
|
|
|
|
+ Object commentTime = alarm.get("createTime");
|
|
|
|
+ alarm.put("createTime", getTime(sdf_T, sdf_blank, sdf, commentTime));
|
|
}
|
|
}
|
|
- if (alarm.containsKey("updateTime")) {
|
|
|
|
- Object object = alarm.get("updateTime");
|
|
|
|
- if (object != null) {
|
|
|
|
- if (object instanceof Long) {
|
|
|
|
- Long timeLong = (Long) object;
|
|
|
|
- alarm.put("updateTime", sdf.format(new Date(timeLong)));
|
|
|
|
- } else if (object instanceof String) {
|
|
|
|
- String timeString = (String) object;
|
|
|
|
- alarm.put("updateTime", sdf.format(sdf_.parse(timeString)));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ if (alarm.get("updateTime") != null) {
|
|
|
|
+ Object commentTime = alarm.get("updateTime");
|
|
|
|
+ alarm.put("updateTime", getTime(sdf_T, sdf_blank, sdf, commentTime));
|
|
}
|
|
}
|
|
|
|
|
|
if (alarm.containsKey("createTime")) {
|
|
if (alarm.containsKey("createTime")) {
|
|
@@ -397,6 +362,28 @@ public class RWDAlarmUtil {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public static String getTime(SimpleDateFormat sdf_T, SimpleDateFormat sdf_blank, SimpleDateFormat sdf, Object object) throws Exception {
|
|
|
|
+ String result;
|
|
|
|
+ if (object instanceof Long) {
|
|
|
|
+ Long timeLong = (Long) object;
|
|
|
|
+ result = sdf_T.format(new Date(timeLong));
|
|
|
|
+ } else if (object instanceof String) {
|
|
|
|
+ String timeString = (String) object;
|
|
|
|
+ try {
|
|
|
|
+ result = sdf_T.format(sdf_blank.parse(timeString));
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ try {
|
|
|
|
+ result = sdf_T.format(sdf.parse(timeString));
|
|
|
|
+ } catch (Exception e1) {
|
|
|
|
+ result = object.toString();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ result = object.toString();
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
public static void chixushijian(SimpleDateFormat sdf, Date currentTime, SceneDataObject sdoInner) {
|
|
public static void chixushijian(SimpleDateFormat sdf, Date currentTime, SceneDataObject sdoInner) {
|
|
String triggerTime = (String) sdoInner.get("triggerTime").value_prim.value;
|
|
String triggerTime = (String) sdoInner.get("triggerTime").value_prim.value;
|
|
String duration;
|
|
String duration;
|