1
|
package com.sunyo.wlpt.cgonms.provide.controller;
|
1
|
package com.sunyo.wlpt.cgonms.provide.controller;
|
2
|
|
2
|
|
3
|
import com.alibaba.fastjson.JSON;
|
3
|
import com.alibaba.fastjson.JSON;
|
|
|
4
|
+import com.alibaba.fastjson.serializer.SerializerFeature;
|
4
|
import com.google.common.collect.Lists;
|
5
|
import com.google.common.collect.Lists;
|
5
|
|
6
|
|
6
|
import com.sunyo.wlpt.cgonms.provide.domain.*;
|
7
|
import com.sunyo.wlpt.cgonms.provide.domain.*;
|
|
@@ -16,6 +17,7 @@ import lombok.extern.slf4j.Slf4j; |
|
@@ -16,6 +17,7 @@ import lombok.extern.slf4j.Slf4j; |
16
|
import org.springframework.beans.propertyeditors.CustomDateEditor;
|
17
|
import org.springframework.beans.propertyeditors.CustomDateEditor;
|
17
|
import org.springframework.web.bind.WebDataBinder;
|
18
|
import org.springframework.web.bind.WebDataBinder;
|
18
|
import org.springframework.web.bind.annotation.*;
|
19
|
import org.springframework.web.bind.annotation.*;
|
|
|
20
|
+
|
19
|
import java.io.IOException;
|
21
|
import java.io.IOException;
|
20
|
|
22
|
|
21
|
import javax.annotation.Resource;
|
23
|
import javax.annotation.Resource;
|
|
@@ -96,10 +98,10 @@ public class NmsController { |
|
@@ -96,10 +98,10 @@ public class NmsController { |
96
|
* 2.每個可以返回給前端的消息通過websocket發送回去
|
98
|
* 2.每個可以返回給前端的消息通過websocket發送回去
|
97
|
*/
|
99
|
*/
|
98
|
String sid = request.getHeader("Authorization");
|
100
|
String sid = request.getHeader("Authorization");
|
99
|
- log.info("token的值:"+sid);
|
101
|
+ log.info("token的值:" + sid);
|
100
|
final String startTime = sdf.format(new Date());
|
102
|
final String startTime = sdf.format(new Date());
|
101
|
System.out.println("开始时间:" + startTime);
|
103
|
System.out.println("开始时间:" + startTime);
|
102
|
- sendMsgByWebsocket("开始时间:" + startTime,sid);
|
104
|
+ sendMsgByWebsocket("开始时间:" + startTime, sid);
|
103
|
System.out.println("出港数据,开始获取");
|
105
|
System.out.println("出港数据,开始获取");
|
104
|
ResultJson resultJson = new ResultJson();
|
106
|
ResultJson resultJson = new ResultJson();
|
105
|
|
107
|
|
|
@@ -123,13 +125,18 @@ public class NmsController { |
|
@@ -123,13 +125,18 @@ public class NmsController { |
123
|
log.trace("获取开始{},剩余数量:{}", startTime, resultList.size());
|
125
|
log.trace("获取开始{},剩余数量:{}", startTime, resultList.size());
|
124
|
int i;
|
126
|
int i;
|
125
|
for (i = 0; i < THREAD_ACCOUNT; i++) {
|
127
|
for (i = 0; i < THREAD_ACCOUNT; i++) {
|
126
|
- ResultExitData result = threadJob(resultList.get(i + index), latch, threadPool);
|
128
|
+ ResultExitData result = new ResultExitData();
|
|
|
129
|
+ result = threadJob(resultList.get(i + index), latch, threadPool);
|
127
|
resultList.set(i, result);
|
130
|
resultList.set(i, result);
|
128
|
- int temp=i+index;
|
|
|
129
|
- String resultJs=JSON.toJSONString(new ResultWs(sid,"获取数据,第"+temp+"条",result));
|
|
|
130
|
- sendMsgByWebsocket(resultJs,sid);
|
131
|
+
|
|
|
132
|
+ int temp = i + index;
|
|
|
133
|
+ ResultWs resultWs = new ResultWs();
|
|
|
134
|
+ resultWs = new ResultWs(sid, "获取数据,第" + temp + "条", result);
|
|
|
135
|
+ String resultJs = JSON.toJSONString(resultWs, SerializerFeature.DisableCircularReferenceDetect);
|
|
|
136
|
+
|
|
|
137
|
+ sendMsgByWebsocket(resultJs, sid);
|
131
|
}
|
138
|
}
|
132
|
- index = index + i;
|
139
|
+ index = index + i + 1;
|
133
|
//完成一次,就等待。每次减1,为0的时候往下执行
|
140
|
//完成一次,就等待。每次减1,为0的时候往下执行
|
134
|
latch.await();
|
141
|
latch.await();
|
135
|
}
|
142
|
}
|
|
@@ -139,10 +146,15 @@ public class NmsController { |
|
@@ -139,10 +146,15 @@ public class NmsController { |
139
|
log.trace("获取开始{},剩余数量:{}", startTime, resultList.size());
|
146
|
log.trace("获取开始{},剩余数量:{}", startTime, resultList.size());
|
140
|
int i;
|
147
|
int i;
|
141
|
for (i = 0; i < resultList.size() - index; i++) {
|
148
|
for (i = 0; i < resultList.size() - index; i++) {
|
142
|
- ResultExitData result = threadJob(resultList.get(i + index), latch, threadPool);
|
|
|
143
|
- int temp=i+index;
|
|
|
144
|
- String resultJs=JSON.toJSONString(new ResultWs(sid,"获取数据,第"+temp+"条",result));
|
|
|
145
|
- sendMsgByWebsocket(resultJs,sid);
|
149
|
+ ResultExitData result = new ResultExitData();
|
|
|
150
|
+ result = threadJob(resultList.get(i + index), latch, threadPool);
|
|
|
151
|
+
|
|
|
152
|
+ int temp = i + index;
|
|
|
153
|
+ ResultWs resultWs = new ResultWs();
|
|
|
154
|
+ resultWs = new ResultWs(sid, "获取数据,第" + temp + "条", result);
|
|
|
155
|
+
|
|
|
156
|
+ String resultJs = JSON.toJSONString(resultWs, SerializerFeature.DisableCircularReferenceDetect);
|
|
|
157
|
+ sendMsgByWebsocket(resultJs, sid);
|
146
|
}
|
158
|
}
|
147
|
index = index + i;
|
159
|
index = index + i;
|
148
|
//完成一次,就等待。每次减1,为0的时候往下执行
|
160
|
//完成一次,就等待。每次减1,为0的时候往下执行
|
|
@@ -155,10 +167,15 @@ public class NmsController { |
|
@@ -155,10 +167,15 @@ public class NmsController { |
155
|
CountDownLatch latch = new CountDownLatch(resultList.size());
|
167
|
CountDownLatch latch = new CountDownLatch(resultList.size());
|
156
|
log.trace("获取开始{},剩余数量:{}", startTime, resultList.size());
|
168
|
log.trace("获取开始{},剩余数量:{}", startTime, resultList.size());
|
157
|
for (int i = 0; i < resultList.size(); i++) {
|
169
|
for (int i = 0; i < resultList.size(); i++) {
|
158
|
- ResultExitData result = threadJob(resultList.get(i), latch, threadPool);
|
170
|
+ ResultExitData result = new ResultExitData();
|
|
|
171
|
+ result = threadJob(resultList.get(i), latch, threadPool);
|
|
|
172
|
+
|
159
|
resultList.set(i, result);
|
173
|
resultList.set(i, result);
|
160
|
- String resultJs=JSON.toJSONString(new ResultWs(sid,"获取数据,第"+i+"条",result));
|
|
|
161
|
- sendMsgByWebsocket(resultJs,sid);
|
174
|
+ ResultWs resultWs = new ResultWs();
|
|
|
175
|
+ resultWs = new ResultWs(sid, "获取数据,第" + i + "条", result);
|
|
|
176
|
+ String resultJs = JSON.toJSONString(resultWs, SerializerFeature.DisableCircularReferenceDetect);
|
|
|
177
|
+
|
|
|
178
|
+ sendMsgByWebsocket(resultJs, sid);
|
162
|
}
|
179
|
}
|
163
|
//完成一次,就等待。等所有的全部完成,再一起返回
|
180
|
//完成一次,就等待。等所有的全部完成,再一起返回
|
164
|
latch.await();
|
181
|
latch.await();
|
|
@@ -174,10 +191,13 @@ public class NmsController { |
|
@@ -174,10 +191,13 @@ public class NmsController { |
174
|
final String endTime = sdf.format(new Date());
|
191
|
final String endTime = sdf.format(new Date());
|
175
|
|
192
|
|
176
|
System.out.println("结束时间:" + endTime);
|
193
|
System.out.println("结束时间:" + endTime);
|
177
|
- sendMsgByWebsocket("出港信息,获取完毕,结束时间:" + endTime,sid);
|
194
|
+ String resultJs = JSON.toJSONString(new ResultWs(sid, "获取数据,完毕", resultList));
|
|
|
195
|
+ sendMsgByWebsocket(resultJs, sid);
|
|
|
196
|
+ sendMsgByWebsocket("出港信息,获取完毕,结束时间:" + endTime, sid);
|
178
|
|
197
|
|
179
|
resultJson.setCode("200");
|
198
|
resultJson.setCode("200");
|
180
|
resultJson.setData(resultList);
|
199
|
resultJson.setData(resultList);
|
|
|
200
|
+
|
181
|
return resultJson;
|
201
|
return resultJson;
|
182
|
}
|
202
|
}
|
183
|
|
203
|
|
|
@@ -193,104 +213,108 @@ public class NmsController { |
|
@@ -193,104 +213,108 @@ public class NmsController { |
193
|
Runnable run = new Runnable() {
|
213
|
Runnable run = new Runnable() {
|
194
|
@Override
|
214
|
@Override
|
195
|
public void run() {
|
215
|
public void run() {
|
196
|
-
|
|
|
197
|
- //设置航班
|
|
|
198
|
- result.setSegment(result.getOriginatingStation() + " — " + result.getDestinationStation());
|
|
|
199
|
-
|
|
|
200
|
- //设置承运人二字码
|
|
|
201
|
- result.setCarrier(result.getFlightNo().substring(0, 2));
|
|
|
202
|
-
|
|
|
203
|
- /**
|
|
|
204
|
- * 3.根据 理货信息 中的目的站代码,获取 新舱单机场代码表 中的相应数据
|
|
|
205
|
- *
|
|
|
206
|
- * 机场所属城市代码
|
|
|
207
|
- */
|
|
|
208
|
- BasAirport ba = basAirportService.getBasAirportInfo(result.getDestinationStation());
|
|
|
209
|
-
|
|
|
210
|
- /**
|
|
|
211
|
- * 4.根据 新舱单机场代码表 中的 机场所属城市代码 ,获取 天博——机场代码表 的相应数据
|
|
|
212
|
- *
|
|
|
213
|
- * 城市代码
|
|
|
214
|
- * 区域id
|
|
|
215
|
- * 国家代码
|
|
|
216
|
- */
|
|
|
217
|
- TbAirportCode ta = tbAirportCodeService.getTbAirportCodeInfo(ba.getCityId());
|
|
|
218
|
- // 所属国家代码
|
|
|
219
|
- result.setCountry(ta.getCountry());
|
|
|
220
|
-
|
|
|
221
|
- /**
|
|
|
222
|
- * 5.根据 天博——机场代码表 中的 区域id,获取 新舱单——区域代码表 的相应数据
|
|
|
223
|
- *
|
|
|
224
|
- * 区域id
|
|
|
225
|
- * 国际国内标识;1,国外;2,国内
|
|
|
226
|
- * 区域描述,中文
|
|
|
227
|
- */
|
|
|
228
|
- BasArea basArea = basAreaService.getBasAreaInfo(ta.getArea());
|
|
|
229
|
- //航班目的区域,中文描述,所属洲
|
|
|
230
|
- result.setAreaDescChn(basArea.getAreaDescChn());
|
|
|
231
|
-
|
|
|
232
|
- /**
|
|
|
233
|
- * 6.根据 理货信息 中的运单号,获取预配表中的相应数据
|
|
|
234
|
- *
|
|
|
235
|
- * 发货人名称
|
|
|
236
|
- * 收货人名称
|
|
|
237
|
- * 航班目的站
|
|
|
238
|
- */
|
|
|
239
|
- List<PrepareMaster> pm = prepareMasterService.getPrepareMasterInfo(result.getWaybillNoMaster());
|
|
|
240
|
- if (pm != null && pm.size() > 0) {
|
|
|
241
|
- //发货人名称
|
|
|
242
|
- result.setShipperName(pm.get(0).getShipperName());
|
|
|
243
|
- //收货人名称
|
|
|
244
|
- result.setConsigneeName(pm.get(0).getConsigneeName());
|
|
|
245
|
- //获取目的货物目的站
|
|
|
246
|
- result.setAimStation(pm.get(0).getDestinationStation());
|
|
|
247
|
- }
|
|
|
248
|
- /**
|
|
|
249
|
- * 获取数据仓库的对应数据
|
|
|
250
|
-
|
|
|
251
|
- // if (result.getWaybillNoMaster() != null && result.getWaybillNoMaster() != "") {}
|
|
|
252
|
- ResultExitData dataWareHouseInfo=new ResultExitData();
|
|
|
253
|
- dataWareHouseInfo = getDataWareHouseFeign.getInfo(result.getWaybillNoMaster());
|
|
|
254
|
- //设置体积
|
|
|
255
|
- result.setVolumeMeasure(dataWareHouseInfo.getVolumeMeasure());
|
|
|
256
|
- //设置计费重量
|
|
|
257
|
- result.setTotalGrossWeightMeasure(dataWareHouseInfo.getTotalGrossWeightMeasure());
|
|
|
258
|
- */
|
|
|
259
|
-
|
|
|
260
|
- /**
|
|
|
261
|
- * 获取运输工具的对应数据
|
|
|
262
|
- */
|
|
|
263
|
- ResultExitData transportInfo = new ResultExitData();
|
|
|
264
|
- transportInfo = getTransportFeign.getInfo(result.getFlightNo(), result.getFlightDate());
|
|
|
265
|
- //设置航班公司
|
|
|
266
|
- result.setAirCompany(transportInfo.getAirCompany());
|
|
|
267
|
- //设置机型
|
|
|
268
|
- result.setCfTp(transportInfo.getCfTp());
|
|
|
269
|
- //设置机号
|
|
|
270
|
- result.setCfNo(transportInfo.getCfNo());
|
|
|
271
|
- //设置航班计划日期
|
|
|
272
|
- result.setFlightPlanDate(transportInfo.getFlightPlanDate());
|
|
|
273
|
- //设置航班(起飞)时间
|
|
|
274
|
- result.setFlightTime(transportInfo.getFlightTime());
|
|
|
275
|
- //设置航班计划时间
|
|
|
276
|
- result.setFlightPlanTime(transportInfo.getFlightPlanTime());
|
|
|
277
|
-
|
|
|
278
|
- /**
|
|
|
279
|
- * 获取代理人的相关数据
|
|
|
280
|
- */
|
216
|
+ try {
|
|
|
217
|
+ //设置航班
|
|
|
218
|
+ result.setSegment(result.getOriginatingStation() + " — " + result.getDestinationStation());
|
|
|
219
|
+
|
|
|
220
|
+ //设置承运人二字码
|
|
|
221
|
+ result.setCarrier(result.getFlightNo().substring(0, 2));
|
|
|
222
|
+
|
|
|
223
|
+ /**
|
|
|
224
|
+ * 3.根据 理货信息 中的目的站代码,获取 新舱单机场代码表 中的相应数据
|
|
|
225
|
+ *
|
|
|
226
|
+ * 机场所属城市代码
|
|
|
227
|
+ */
|
|
|
228
|
+ BasAirport ba = basAirportService.getBasAirportInfo(result.getDestinationStation());
|
|
|
229
|
+
|
|
|
230
|
+ /**
|
|
|
231
|
+ * 4.根据 新舱单机场代码表 中的 机场所属城市代码 ,获取 天博——机场代码表 的相应数据
|
|
|
232
|
+ *
|
|
|
233
|
+ * 城市代码
|
|
|
234
|
+ * 区域id
|
|
|
235
|
+ * 国家代码
|
|
|
236
|
+ */
|
|
|
237
|
+ TbAirportCode ta = tbAirportCodeService.getTbAirportCodeInfo(ba.getCityId());
|
|
|
238
|
+ // 所属国家代码
|
|
|
239
|
+ result.setCountry(ta.getCountry());
|
|
|
240
|
+
|
|
|
241
|
+ /**
|
|
|
242
|
+ * 5.根据 天博——机场代码表 中的 区域id,获取 新舱单——区域代码表 的相应数据
|
|
|
243
|
+ *
|
|
|
244
|
+ * 区域id
|
|
|
245
|
+ * 国际国内标识;1,国外;2,国内
|
|
|
246
|
+ * 区域描述,中文
|
|
|
247
|
+ */
|
|
|
248
|
+ BasArea basArea = basAreaService.getBasAreaInfo(ta.getArea());
|
|
|
249
|
+ //航班目的区域,中文描述,所属洲
|
|
|
250
|
+ result.setAreaDescChn(basArea.getAreaDescChn());
|
|
|
251
|
+
|
|
|
252
|
+ /**
|
|
|
253
|
+ * 6.根据 理货信息 中的运单号,获取预配表中的相应数据
|
|
|
254
|
+ *
|
|
|
255
|
+ * 发货人名称
|
|
|
256
|
+ * 收货人名称
|
|
|
257
|
+ * 航班目的站
|
|
|
258
|
+ */
|
|
|
259
|
+ List<PrepareMaster> pm = prepareMasterService.getPrepareMasterInfo(result.getWaybillNoMaster());
|
|
|
260
|
+ if (pm != null && pm.size() > 0) {
|
|
|
261
|
+ //发货人名称
|
|
|
262
|
+ result.setShipperName(pm.get(0).getShipperName());
|
|
|
263
|
+ //收货人名称
|
|
|
264
|
+ result.setConsigneeName(pm.get(0).getConsigneeName());
|
|
|
265
|
+ //获取目的货物目的站
|
|
|
266
|
+ result.setAimStation(pm.get(0).getDestinationStation());
|
|
|
267
|
+ }
|
|
|
268
|
+ /**
|
|
|
269
|
+ * 获取数据仓库的对应数据
|
|
|
270
|
+
|
|
|
271
|
+ // if (result.getWaybillNoMaster() != null && result.getWaybillNoMaster() != "") {}
|
|
|
272
|
+ ResultExitData dataWareHouseInfo=new ResultExitData();
|
|
|
273
|
+ dataWareHouseInfo = getDataWareHouseFeign.getInfo(result.getWaybillNoMaster());
|
|
|
274
|
+ //设置体积
|
|
|
275
|
+ result.setVolumeMeasure(dataWareHouseInfo.getVolumeMeasure());
|
|
|
276
|
+ //设置计费重量
|
|
|
277
|
+ result.setTotalGrossWeightMeasure(dataWareHouseInfo.getTotalGrossWeightMeasure());
|
|
|
278
|
+ */
|
|
|
279
|
+
|
|
|
280
|
+ /**
|
|
|
281
|
+ * 获取运输工具的对应数据
|
|
|
282
|
+ */
|
|
|
283
|
+ ResultExitData transportInfo = new ResultExitData();
|
|
|
284
|
+ transportInfo = getTransportFeign.getInfo(result.getFlightNo(), result.getFlightDate());
|
|
|
285
|
+ //设置航班公司
|
|
|
286
|
+ result.setAirCompany(transportInfo.getAirCompany());
|
|
|
287
|
+ //设置机型
|
|
|
288
|
+ result.setCfTp(transportInfo.getCfTp());
|
|
|
289
|
+ //设置机号
|
|
|
290
|
+ result.setCfNo(transportInfo.getCfNo());
|
|
|
291
|
+ //设置航班计划日期
|
|
|
292
|
+ result.setFlightPlanDate(transportInfo.getFlightPlanDate());
|
|
|
293
|
+ //设置航班(起飞)时间
|
|
|
294
|
+ result.setFlightTime(transportInfo.getFlightTime());
|
|
|
295
|
+ //设置航班计划时间
|
|
|
296
|
+ result.setFlightPlanTime(transportInfo.getFlightPlanTime());
|
|
|
297
|
+
|
|
|
298
|
+ /**
|
|
|
299
|
+ * 获取代理人的相关数据
|
|
|
300
|
+ */
|
281
|
// if (result.getWaybillNoMaster() != null && result.getWaybillNoMaster() != "") { }
|
301
|
// if (result.getWaybillNoMaster() != null && result.getWaybillNoMaster() != "") { }
|
282
|
- ResultExitData asmInfo = new ResultExitData();
|
|
|
283
|
- asmInfo = getCgoAsmFeign.getInfo(result.getWaybillNoMaster());
|
|
|
284
|
- //设置代理人全称
|
|
|
285
|
- result.setFullName(asmInfo.getFullName());
|
|
|
286
|
- //设置货主类型
|
|
|
287
|
- result.setTheShipperType(asmInfo.getTheShipperType());
|
|
|
288
|
- //设置品名
|
|
|
289
|
- result.setSdCargoName(asmInfo.getSdCargoName());
|
|
|
290
|
- //设置二级类名称
|
|
|
291
|
- result.setTwoTypeName(asmInfo.getTwoTypeName());
|
|
|
292
|
- //设置一级类名称
|
|
|
293
|
- result.setTypeName(asmInfo.getTypeName());
|
302
|
+ ResultExitData asmInfo = new ResultExitData();
|
|
|
303
|
+ asmInfo = getCgoAsmFeign.getInfo(result.getWaybillNoMaster());
|
|
|
304
|
+ //设置结算代理人
|
|
|
305
|
+ result.setCountName(asmInfo.getCountName());
|
|
|
306
|
+ //设置订舱代理人
|
|
|
307
|
+ result.setOrderName(asmInfo.getOrderName());
|
|
|
308
|
+ //设置品名
|
|
|
309
|
+ result.setSdCargoName(asmInfo.getSdCargoName());
|
|
|
310
|
+ //设置二级类名称
|
|
|
311
|
+ result.setTwoTypeName(asmInfo.getTwoTypeName());
|
|
|
312
|
+ //设置一级类名称
|
|
|
313
|
+ result.setTypeName(asmInfo.getTypeName());
|
|
|
314
|
+ } catch (Exception e) {
|
|
|
315
|
+ latch.countDown();
|
|
|
316
|
+ e.printStackTrace();
|
|
|
317
|
+ }
|
294
|
latch.countDown();
|
318
|
latch.countDown();
|
295
|
}
|
319
|
}
|
296
|
};
|
320
|
};
|
|
@@ -305,9 +329,9 @@ public class NmsController { |
|
@@ -305,9 +329,9 @@ public class NmsController { |
305
|
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
|
329
|
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
|
306
|
}
|
330
|
}
|
307
|
|
331
|
|
308
|
- private void sendMsgByWebsocket(String msg,String sid){
|
332
|
+ private void sendMsgByWebsocket(String msg, String sid) {
|
309
|
try {
|
333
|
try {
|
310
|
- WebSocketServer.sendInfo(msg,sid);
|
334
|
+ WebSocketServer.sendInfo(msg, sid);
|
311
|
} catch (IOException e) {
|
335
|
} catch (IOException e) {
|
312
|
e.printStackTrace();
|
336
|
e.printStackTrace();
|
313
|
|
337
|
|