ISMPDictionary.java
2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package com.sitech.util;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
public class ISMPDictionary {
static public String getParent(String ALARM_TYPE) {
if ((ALARM_TYPE == null) || ALARM_TYPE.equals(""))
return "";
String al[] = Formater.split2Array(ALARM_TYPE, "-");
String KBP_CLASS = "";
for (int i = 0; i < al.length - 1; i++) {
if (!al[i + 1].equals("00"))
KBP_CLASS = KBP_CLASS + "-" + al[i];
else
KBP_CLASS = KBP_CLASS + "-" + "00";
}
KBP_CLASS = KBP_CLASS + "-" + "00";
return KBP_CLASS.substring(1);
}
static public String getUpParent(String kbpClass) {
if ((kbpClass == null) || kbpClass.equals("")){
return "";
}
int pos = kbpClass.lastIndexOf("-");
if(pos < 0){
return "";
}else{
return kbpClass.substring(0, pos);
}
}
public static void main(String[] args) {
System.out.println(ISMPDictionary.getUpParent("10"));
}
static public ArrayList getGrandsire(String ALARM_TYPE) {
ArrayList al = new ArrayList();
if ((ALARM_TYPE == null) || ALARM_TYPE.equals(""))
return al;
String pKBP = ALARM_TYPE;
while (!pKBP.substring(0, 2).equals("00")) {
al.add(pKBP);
pKBP = getParent(pKBP);
}
al.add(pKBP);
return al;
}
public static List<String> getAllParent(String kbpClass) {
List<String> result = new ArrayList<String>();
if ((kbpClass == null) || kbpClass.equals(""))
return result;
String parentKbpClass = kbpClass;
while (!parentKbpClass.equals("")) {
result.add(parentKbpClass);
parentKbpClass = getUpParent(parentKbpClass);
}
return result;
}
static public String getKBP_CLASS(String KPI_ID) {
if ((KPI_ID == null) || KPI_ID.equals(""))
return "";
String al[] = Formater.split2Array(KPI_ID, "-");
String KBP_CLASS = "";
for (int i = 0; i < 4; i++) {
if (i < al.length - 2)
KBP_CLASS = KBP_CLASS + "-" + al[i + 1];
else
KBP_CLASS = KBP_CLASS + "-" + "00";
}
return KBP_CLASS.substring(1);
}
public static boolean compareDate(Date STARTTIME, Date ENDTIME) {
boolean bool = false;
if (STARTTIME == null || ENDTIME == null) {
return true;
}
Date TimeCurrent = new Date();
Calendar cal = Calendar.getInstance();
cal.setTime(TimeCurrent);
Calendar cal_STARTTIME = Calendar.getInstance();
cal_STARTTIME.setTime(STARTTIME);
Calendar cal_ENDTIME = Calendar.getInstance();
cal_ENDTIME.setTime(ENDTIME);
int Time_year = cal.get(Calendar.YEAR);
int Time_month = cal.get(Calendar.MONTH);
int Time_day = cal.get(Calendar.DAY_OF_MONTH);
cal_STARTTIME.set(Calendar.YEAR, Time_year);
cal_STARTTIME.set(Calendar.MONTH, Time_month);
cal_STARTTIME.set(Calendar.DAY_OF_MONTH, Time_day);
cal_ENDTIME.set(Calendar.YEAR, Time_year);
cal_ENDTIME.set(Calendar.MONTH, Time_month);
cal_ENDTIME.set(Calendar.DAY_OF_MONTH, Time_day);
STARTTIME = cal_STARTTIME.getTime();
ENDTIME = cal_ENDTIME.getTime();
if (TimeCurrent.after(STARTTIME) && TimeCurrent.before(ENDTIME))
bool = true;
return bool;
}
}