|
|
@@ -1,6 +1,9 @@
|
|
1
|
1
|
package com.chinaitop.depot.intelligent.utils;
|
|
2
|
2
|
|
|
3
|
3
|
import com.chinaitop.depot.intelligent.grainsituation.model.TPoints;
|
|
|
4
|
+import com.chinaitop.depot.intelligent.grainsituation.model.TTestdata;
|
|
|
5
|
+import com.chinaitop.depot.intelligent.grainsituation.model.TTestdataLayer;
|
|
|
6
|
+import com.chinaitop.depot.intelligent.grainsituation.model.TWarningThresholdHistory;
|
|
4
|
7
|
import com.fasterxml.jackson.databind.JavaType;
|
|
5
|
8
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
6
|
9
|
import org.slf4j.Logger;
|
|
|
@@ -28,7 +31,6 @@ public class JsonToObjectUtils {
|
|
28
|
31
|
JavaType javaType = mapper.getTypeFactory().constructParametricType(ArrayList.class, Class.forName(packageName));
|
|
29
|
32
|
object = mapper.readValue(str, javaType);
|
|
30
|
33
|
} catch (Exception e) {
|
|
31
|
|
- e.printStackTrace();
|
|
32
|
34
|
logger.info("json转换异常 "+e.getMessage());
|
|
33
|
35
|
}
|
|
34
|
36
|
return object;
|
|
|
@@ -47,7 +49,6 @@ public class JsonToObjectUtils {
|
|
47
|
49
|
JavaType javaType = mapper.getTypeFactory().constructParametricType(ArrayList.class, classs);
|
|
48
|
50
|
object = mapper.readValue(str, javaType);
|
|
49
|
51
|
} catch (Exception e) {
|
|
50
|
|
- e.printStackTrace();
|
|
51
|
52
|
logger.info("json转换异常 "+e.getMessage());
|
|
52
|
53
|
}
|
|
53
|
54
|
return object;
|
|
|
@@ -66,7 +67,6 @@ public class JsonToObjectUtils {
|
|
66
|
67
|
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
|
|
67
|
68
|
object = mapper.readValue(str, Class.forName(packageName));
|
|
68
|
69
|
} catch (Exception e) {
|
|
69
|
|
- e.printStackTrace();
|
|
70
|
70
|
logger.info("json转换异常 "+e.getMessage());
|
|
71
|
71
|
}
|
|
72
|
72
|
return object;
|
|
|
@@ -84,7 +84,6 @@ public class JsonToObjectUtils {
|
|
84
|
84
|
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
|
|
85
|
85
|
object = mapper.readValue(str, classs);
|
|
86
|
86
|
} catch (Exception e) {
|
|
87
|
|
- e.printStackTrace();
|
|
88
|
87
|
logger.info("json转换异常 "+e.getMessage());
|
|
89
|
88
|
}
|
|
90
|
89
|
return object;
|
|
|
@@ -105,7 +104,6 @@ public class JsonToObjectUtils {
|
|
105
|
104
|
JavaType javaType = mapper.getTypeFactory().constructParametricType(ArrayList.class, classs);
|
|
106
|
105
|
object = mapper.readValue(str, javaType);
|
|
107
|
106
|
} catch (Exception e) {
|
|
108
|
|
- e.printStackTrace();
|
|
109
|
107
|
logger.info("json转换异常 "+e.getMessage());
|
|
110
|
108
|
}
|
|
111
|
109
|
return object;
|
|
|
@@ -121,7 +119,52 @@ public class JsonToObjectUtils {
|
|
121
|
119
|
ObjectMapper mapper = new ObjectMapper();
|
|
122
|
120
|
return mapper.writeValueAsString(points);
|
|
123
|
121
|
} catch (Exception e) {
|
|
124
|
|
- e.printStackTrace();
|
|
|
122
|
+ logger.info("json转换异常 "+e.getMessage());
|
|
|
123
|
+ }
|
|
|
124
|
+ return null;
|
|
|
125
|
+ }
|
|
|
126
|
+
|
|
|
127
|
+ /**
|
|
|
128
|
+ * list转换字符串
|
|
|
129
|
+ * @param tTestdatas list参数
|
|
|
130
|
+ * @return
|
|
|
131
|
+ */
|
|
|
132
|
+ public static String listToStrings(List<TTestdata> tTestdatas){
|
|
|
133
|
+ try {
|
|
|
134
|
+ ObjectMapper mapper = new ObjectMapper();
|
|
|
135
|
+ mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
|
|
|
136
|
+ return mapper.writeValueAsString(tTestdatas);
|
|
|
137
|
+ } catch (Exception e) {
|
|
|
138
|
+ logger.info("json转换异常 "+e.getMessage());
|
|
|
139
|
+ }
|
|
|
140
|
+ return null;
|
|
|
141
|
+ }
|
|
|
142
|
+ /**
|
|
|
143
|
+ * list转换字符串
|
|
|
144
|
+ * @param tTestdatas list参数
|
|
|
145
|
+ * @return
|
|
|
146
|
+ */
|
|
|
147
|
+ public static String listToLayerStrings(List<TTestdataLayer> tTestdatas){
|
|
|
148
|
+ try {
|
|
|
149
|
+ ObjectMapper mapper = new ObjectMapper();
|
|
|
150
|
+ mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
|
|
|
151
|
+ return mapper.writeValueAsString(tTestdatas);
|
|
|
152
|
+ } catch (Exception e) {
|
|
|
153
|
+ logger.info("json转换异常 "+e.getMessage());
|
|
|
154
|
+ }
|
|
|
155
|
+ return null;
|
|
|
156
|
+ }
|
|
|
157
|
+ /**
|
|
|
158
|
+ * list转换字符串
|
|
|
159
|
+ * @param tTestdatas list参数
|
|
|
160
|
+ * @return
|
|
|
161
|
+ */
|
|
|
162
|
+ public static String listToWarningThresholdStrings(List<TWarningThresholdHistory> tTestdatas){
|
|
|
163
|
+ try {
|
|
|
164
|
+ ObjectMapper mapper = new ObjectMapper();
|
|
|
165
|
+ mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
|
|
|
166
|
+ return mapper.writeValueAsString(tTestdatas);
|
|
|
167
|
+ } catch (Exception e) {
|
|
125
|
168
|
logger.info("json转换异常 "+e.getMessage());
|
|
126
|
169
|
}
|
|
127
|
170
|
return null;
|