1
|
package com.sunyo.wlpt.cgonms.provide.controller;
|
1
|
package com.sunyo.wlpt.cgonms.provide.controller;
|
2
|
|
2
|
|
3
|
-import com.alibaba.fastjson.JSON;
|
|
|
4
|
-import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
5
|
|
3
|
|
|
|
4
|
+
|
|
|
5
|
+import com.google.gson.Gson;
|
|
|
6
|
+import com.google.gson.GsonBuilder;
|
6
|
import com.sunyo.wlpt.cgonms.provide.domain.*;
|
7
|
import com.sunyo.wlpt.cgonms.provide.domain.*;
|
7
|
import com.sunyo.wlpt.cgonms.provide.feign.GetCgoAsmFeign;
|
8
|
import com.sunyo.wlpt.cgonms.provide.feign.GetCgoAsmFeign;
|
8
|
import com.sunyo.wlpt.cgonms.provide.feign.GetDataWareHouseFeign;
|
9
|
import com.sunyo.wlpt.cgonms.provide.feign.GetDataWareHouseFeign;
|
|
@@ -11,6 +12,7 @@ import com.sunyo.wlpt.cgonms.provide.response.ResultJson; |
|
@@ -11,6 +12,7 @@ import com.sunyo.wlpt.cgonms.provide.response.ResultJson; |
11
|
import com.sunyo.wlpt.cgonms.provide.response.ResultWs;
|
12
|
import com.sunyo.wlpt.cgonms.provide.response.ResultWs;
|
12
|
import com.sunyo.wlpt.cgonms.provide.service.*;
|
13
|
import com.sunyo.wlpt.cgonms.provide.service.*;
|
13
|
import com.sunyo.wlpt.cgonms.provide.thread.ExitThreadPoolFactory;
|
14
|
import com.sunyo.wlpt.cgonms.provide.thread.ExitThreadPoolFactory;
|
|
|
15
|
+import com.sunyo.wlpt.cgonms.provide.utils.GsonUtils;
|
14
|
import com.sunyo.wlpt.cgonms.provide.websocket.WebSocketServer;
|
16
|
import com.sunyo.wlpt.cgonms.provide.websocket.WebSocketServer;
|
15
|
import lombok.extern.slf4j.Slf4j;
|
17
|
import lombok.extern.slf4j.Slf4j;
|
16
|
import org.springframework.beans.propertyeditors.CustomDateEditor;
|
18
|
import org.springframework.beans.propertyeditors.CustomDateEditor;
|
|
@@ -95,7 +97,8 @@ public class NmsController { |
|
@@ -95,7 +97,8 @@ public class NmsController { |
95
|
String sid = request.getHeader("Authorization");
|
97
|
String sid = request.getHeader("Authorization");
|
96
|
log.info("token的值:" + sid);
|
98
|
log.info("token的值:" + sid);
|
97
|
final String startTime = sdf.format(new Date());
|
99
|
final String startTime = sdf.format(new Date());
|
98
|
- String resultStart = JSON.toJSONString(new ResultWs("数据开始获取"));
|
100
|
+
|
|
|
101
|
+ String resultStart = GsonUtils.toJsonStr(new ResultWs("数据开始获取"));
|
99
|
sendMsgByWebsocket(resultStart, sid);
|
102
|
sendMsgByWebsocket(resultStart, sid);
|
100
|
ResultJson resultJson = new ResultJson();
|
103
|
ResultJson resultJson = new ResultJson();
|
101
|
|
104
|
|
|
@@ -106,9 +109,9 @@ public class NmsController { |
|
@@ -106,9 +109,9 @@ public class NmsController { |
106
|
resultExitData.setFlightDate(flightDate);
|
109
|
resultExitData.setFlightDate(flightDate);
|
107
|
resultExitData.setFlightNo(flightNo);
|
110
|
resultExitData.setFlightNo(flightNo);
|
108
|
List<ResultExitData> resultList = resultExitDataService.getResultExitDataInfo(resultExitData);
|
111
|
List<ResultExitData> resultList = resultExitDataService.getResultExitDataInfo(resultExitData);
|
109
|
- System.out.println("长度为:" + resultList.size());
|
112
|
+ log.info("长度为:" + resultList.size());
|
110
|
ResultWs resultTotal = new ResultWs("一共" + resultList.size() + "条数据", resultList.size());
|
113
|
ResultWs resultTotal = new ResultWs("一共" + resultList.size() + "条数据", resultList.size());
|
111
|
- String resultTotalJs = JSON.toJSONString(resultTotal, SerializerFeature.DisableCircularReferenceDetect);
|
114
|
+ String resultTotalJs = GsonUtils.toJsonStr(resultTotal);
|
112
|
sendMsgByWebsocket(resultTotalJs, sid);
|
115
|
sendMsgByWebsocket(resultTotalJs, sid);
|
113
|
|
116
|
|
114
|
//控制index,查询数据的时候,保证索引的位置不出错
|
117
|
//控制index,查询数据的时候,保证索引的位置不出错
|
|
@@ -129,7 +132,7 @@ public class NmsController { |
|
@@ -129,7 +132,7 @@ public class NmsController { |
129
|
|
132
|
|
130
|
int temp = i + index;
|
133
|
int temp = i + index;
|
131
|
ResultWs resultWs = new ResultWs("获取数据,第" + temp + "条", "201", temp, resultList.size());
|
134
|
ResultWs resultWs = new ResultWs("获取数据,第" + temp + "条", "201", temp, resultList.size());
|
132
|
- String resultJs = JSON.toJSONString(resultWs, SerializerFeature.DisableCircularReferenceDetect);
|
135
|
+ String resultJs = GsonUtils.toJsonStr(resultWs);
|
133
|
|
136
|
|
134
|
sendMsgByWebsocket(resultJs, sid);
|
137
|
sendMsgByWebsocket(resultJs, sid);
|
135
|
}
|
138
|
}
|
|
@@ -149,7 +152,7 @@ public class NmsController { |
|
@@ -149,7 +152,7 @@ public class NmsController { |
149
|
int temp = i + index;
|
152
|
int temp = i + index;
|
150
|
ResultWs resultWs = new ResultWs("获取数据,第" + temp + "条", "201", temp, resultList.size());
|
153
|
ResultWs resultWs = new ResultWs("获取数据,第" + temp + "条", "201", temp, resultList.size());
|
151
|
|
154
|
|
152
|
- String resultJs = JSON.toJSONString(resultWs, SerializerFeature.DisableCircularReferenceDetect);
|
155
|
+ String resultJs = GsonUtils.toJsonStr(resultWs);
|
153
|
sendMsgByWebsocket(resultJs, sid);
|
156
|
sendMsgByWebsocket(resultJs, sid);
|
154
|
}
|
157
|
}
|
155
|
index = index + i;
|
158
|
index = index + i;
|
|
@@ -168,7 +171,7 @@ public class NmsController { |
|
@@ -168,7 +171,7 @@ public class NmsController { |
168
|
|
171
|
|
169
|
resultList.set(i, result);
|
172
|
resultList.set(i, result);
|
170
|
ResultWs resultWs = new ResultWs("获取数据,第" + i + "条", "201", i, resultList.size());
|
173
|
ResultWs resultWs = new ResultWs("获取数据,第" + i + "条", "201", i, resultList.size());
|
171
|
- String resultJs = JSON.toJSONString(resultWs, SerializerFeature.DisableCircularReferenceDetect);
|
174
|
+ String resultJs = GsonUtils.toJsonStr(resultWs);
|
172
|
|
175
|
|
173
|
sendMsgByWebsocket(resultJs, sid);
|
176
|
sendMsgByWebsocket(resultJs, sid);
|
174
|
}
|
177
|
}
|
|
@@ -180,9 +183,9 @@ public class NmsController { |
|
@@ -180,9 +183,9 @@ public class NmsController { |
180
|
log.error("获取数据出错", e);
|
183
|
log.error("获取数据出错", e);
|
181
|
}
|
184
|
}
|
182
|
final String endTime = sdf.format(new Date());
|
185
|
final String endTime = sdf.format(new Date());
|
183
|
- System.out.println("出港信息,获取完毕,index的值为:" + index);
|
|
|
184
|
- System.out.println("结束时间:" + endTime);
|
|
|
185
|
- String resultJs = JSON.toJSONString(new ResultWs("获取数据,完成", resultList, "200", resultList.size(), resultList.size()));
|
186
|
+ log.info("出港信息,获取完毕,index的值为:" + index);
|
|
|
187
|
+ log.info("结束时间:" + endTime);
|
|
|
188
|
+ String resultJs = GsonUtils.toJsonStr(new ResultWs("获取数据,完成", resultList, "200", resultList.size(), resultList.size()));
|
186
|
sendMsgByWebsocket(resultJs, sid);
|
189
|
sendMsgByWebsocket(resultJs, sid);
|
187
|
resultJson.setCode("200");
|
190
|
resultJson.setCode("200");
|
188
|
resultJson.setData(resultList);
|
191
|
resultJson.setData(resultList);
|
|
@@ -323,4 +326,6 @@ public class NmsController { |
|
@@ -323,4 +326,6 @@ public class NmsController { |
323
|
e.printStackTrace();
|
326
|
e.printStackTrace();
|
324
|
}
|
327
|
}
|
325
|
}
|
328
|
}
|
|
|
329
|
+
|
|
|
330
|
+
|
326
|
} |
331
|
} |