|
|
package com.sunyo.wlpt.cgonms.provide.controller;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
|
import com.sunyo.wlpt.cgonms.provide.domain.*;
|
...
|
...
|
@@ -16,6 +17,7 @@ import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.beans.propertyeditors.CustomDateEditor;
|
|
|
import org.springframework.web.bind.WebDataBinder;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
import javax.annotation.Resource;
|
...
|
...
|
@@ -96,10 +98,10 @@ public class NmsController { |
|
|
* 2.每個可以返回給前端的消息通過websocket發送回去
|
|
|
*/
|
|
|
String sid = request.getHeader("Authorization");
|
|
|
log.info("token的值:"+sid);
|
|
|
log.info("token的值:" + sid);
|
|
|
final String startTime = sdf.format(new Date());
|
|
|
System.out.println("开始时间:" + startTime);
|
|
|
sendMsgByWebsocket("开始时间:" + startTime,sid);
|
|
|
sendMsgByWebsocket("开始时间:" + startTime, sid);
|
|
|
System.out.println("出港数据,开始获取");
|
|
|
ResultJson resultJson = new ResultJson();
|
|
|
|
...
|
...
|
@@ -123,13 +125,18 @@ public class NmsController { |
|
|
log.trace("获取开始{},剩余数量:{}", startTime, resultList.size());
|
|
|
int i;
|
|
|
for (i = 0; i < THREAD_ACCOUNT; i++) {
|
|
|
ResultExitData result = threadJob(resultList.get(i + index), latch, threadPool);
|
|
|
ResultExitData result = new ResultExitData();
|
|
|
result = threadJob(resultList.get(i + index), latch, threadPool);
|
|
|
resultList.set(i, result);
|
|
|
int temp=i+index;
|
|
|
String resultJs=JSON.toJSONString(new ResultWs(sid,"获取数据,第"+temp+"条",result));
|
|
|
sendMsgByWebsocket(resultJs,sid);
|
|
|
|
|
|
int temp = i + index;
|
|
|
ResultWs resultWs = new ResultWs();
|
|
|
resultWs = new ResultWs(sid, "获取数据,第" + temp + "条", result);
|
|
|
String resultJs = JSON.toJSONString(resultWs, SerializerFeature.DisableCircularReferenceDetect);
|
|
|
|
|
|
sendMsgByWebsocket(resultJs, sid);
|
|
|
}
|
|
|
index = index + i;
|
|
|
index = index + i + 1;
|
|
|
//完成一次,就等待。每次减1,为0的时候往下执行
|
|
|
latch.await();
|
|
|
}
|
...
|
...
|
@@ -139,10 +146,15 @@ public class NmsController { |
|
|
log.trace("获取开始{},剩余数量:{}", startTime, resultList.size());
|
|
|
int i;
|
|
|
for (i = 0; i < resultList.size() - index; i++) {
|
|
|
ResultExitData result = threadJob(resultList.get(i + index), latch, threadPool);
|
|
|
int temp=i+index;
|
|
|
String resultJs=JSON.toJSONString(new ResultWs(sid,"获取数据,第"+temp+"条",result));
|
|
|
sendMsgByWebsocket(resultJs,sid);
|
|
|
ResultExitData result = new ResultExitData();
|
|
|
result = threadJob(resultList.get(i + index), latch, threadPool);
|
|
|
|
|
|
int temp = i + index;
|
|
|
ResultWs resultWs = new ResultWs();
|
|
|
resultWs = new ResultWs(sid, "获取数据,第" + temp + "条", result);
|
|
|
|
|
|
String resultJs = JSON.toJSONString(resultWs, SerializerFeature.DisableCircularReferenceDetect);
|
|
|
sendMsgByWebsocket(resultJs, sid);
|
|
|
}
|
|
|
index = index + i;
|
|
|
//完成一次,就等待。每次减1,为0的时候往下执行
|
...
|
...
|
@@ -155,10 +167,15 @@ public class NmsController { |
|
|
CountDownLatch latch = new CountDownLatch(resultList.size());
|
|
|
log.trace("获取开始{},剩余数量:{}", startTime, resultList.size());
|
|
|
for (int i = 0; i < resultList.size(); i++) {
|
|
|
ResultExitData result = threadJob(resultList.get(i), latch, threadPool);
|
|
|
ResultExitData result = new ResultExitData();
|
|
|
result = threadJob(resultList.get(i), latch, threadPool);
|
|
|
|
|
|
resultList.set(i, result);
|
|
|
String resultJs=JSON.toJSONString(new ResultWs(sid,"获取数据,第"+i+"条",result));
|
|
|
sendMsgByWebsocket(resultJs,sid);
|
|
|
ResultWs resultWs = new ResultWs();
|
|
|
resultWs = new ResultWs(sid, "获取数据,第" + i + "条", result);
|
|
|
String resultJs = JSON.toJSONString(resultWs, SerializerFeature.DisableCircularReferenceDetect);
|
|
|
|
|
|
sendMsgByWebsocket(resultJs, sid);
|
|
|
}
|
|
|
//完成一次,就等待。等所有的全部完成,再一起返回
|
|
|
latch.await();
|
...
|
...
|
@@ -174,10 +191,13 @@ public class NmsController { |
|
|
final String endTime = sdf.format(new Date());
|
|
|
|
|
|
System.out.println("结束时间:" + endTime);
|
|
|
sendMsgByWebsocket("出港信息,获取完毕,结束时间:" + endTime,sid);
|
|
|
String resultJs = JSON.toJSONString(new ResultWs(sid, "获取数据,完毕", resultList));
|
|
|
sendMsgByWebsocket(resultJs, sid);
|
|
|
sendMsgByWebsocket("出港信息,获取完毕,结束时间:" + endTime, sid);
|
|
|
|
|
|
resultJson.setCode("200");
|
|
|
resultJson.setData(resultList);
|
|
|
|
|
|
return resultJson;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -193,104 +213,108 @@ public class NmsController { |
|
|
Runnable run = new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
|
|
|
//设置航班
|
|
|
result.setSegment(result.getOriginatingStation() + " — " + result.getDestinationStation());
|
|
|
|
|
|
//设置承运人二字码
|
|
|
result.setCarrier(result.getFlightNo().substring(0, 2));
|
|
|
|
|
|
/**
|
|
|
* 3.根据 理货信息 中的目的站代码,获取 新舱单机场代码表 中的相应数据
|
|
|
*
|
|
|
* 机场所属城市代码
|
|
|
*/
|
|
|
BasAirport ba = basAirportService.getBasAirportInfo(result.getDestinationStation());
|
|
|
|
|
|
/**
|
|
|
* 4.根据 新舱单机场代码表 中的 机场所属城市代码 ,获取 天博——机场代码表 的相应数据
|
|
|
*
|
|
|
* 城市代码
|
|
|
* 区域id
|
|
|
* 国家代码
|
|
|
*/
|
|
|
TbAirportCode ta = tbAirportCodeService.getTbAirportCodeInfo(ba.getCityId());
|
|
|
// 所属国家代码
|
|
|
result.setCountry(ta.getCountry());
|
|
|
|
|
|
/**
|
|
|
* 5.根据 天博——机场代码表 中的 区域id,获取 新舱单——区域代码表 的相应数据
|
|
|
*
|
|
|
* 区域id
|
|
|
* 国际国内标识;1,国外;2,国内
|
|
|
* 区域描述,中文
|
|
|
*/
|
|
|
BasArea basArea = basAreaService.getBasAreaInfo(ta.getArea());
|
|
|
//航班目的区域,中文描述,所属洲
|
|
|
result.setAreaDescChn(basArea.getAreaDescChn());
|
|
|
|
|
|
/**
|
|
|
* 6.根据 理货信息 中的运单号,获取预配表中的相应数据
|
|
|
*
|
|
|
* 发货人名称
|
|
|
* 收货人名称
|
|
|
* 航班目的站
|
|
|
*/
|
|
|
List<PrepareMaster> pm = prepareMasterService.getPrepareMasterInfo(result.getWaybillNoMaster());
|
|
|
if (pm != null && pm.size() > 0) {
|
|
|
//发货人名称
|
|
|
result.setShipperName(pm.get(0).getShipperName());
|
|
|
//收货人名称
|
|
|
result.setConsigneeName(pm.get(0).getConsigneeName());
|
|
|
//获取目的货物目的站
|
|
|
result.setAimStation(pm.get(0).getDestinationStation());
|
|
|
}
|
|
|
/**
|
|
|
* 获取数据仓库的对应数据
|
|
|
|
|
|
// if (result.getWaybillNoMaster() != null && result.getWaybillNoMaster() != "") {}
|
|
|
ResultExitData dataWareHouseInfo=new ResultExitData();
|
|
|
dataWareHouseInfo = getDataWareHouseFeign.getInfo(result.getWaybillNoMaster());
|
|
|
//设置体积
|
|
|
result.setVolumeMeasure(dataWareHouseInfo.getVolumeMeasure());
|
|
|
//设置计费重量
|
|
|
result.setTotalGrossWeightMeasure(dataWareHouseInfo.getTotalGrossWeightMeasure());
|
|
|
*/
|
|
|
|
|
|
/**
|
|
|
* 获取运输工具的对应数据
|
|
|
*/
|
|
|
ResultExitData transportInfo = new ResultExitData();
|
|
|
transportInfo = getTransportFeign.getInfo(result.getFlightNo(), result.getFlightDate());
|
|
|
//设置航班公司
|
|
|
result.setAirCompany(transportInfo.getAirCompany());
|
|
|
//设置机型
|
|
|
result.setCfTp(transportInfo.getCfTp());
|
|
|
//设置机号
|
|
|
result.setCfNo(transportInfo.getCfNo());
|
|
|
//设置航班计划日期
|
|
|
result.setFlightPlanDate(transportInfo.getFlightPlanDate());
|
|
|
//设置航班(起飞)时间
|
|
|
result.setFlightTime(transportInfo.getFlightTime());
|
|
|
//设置航班计划时间
|
|
|
result.setFlightPlanTime(transportInfo.getFlightPlanTime());
|
|
|
|
|
|
/**
|
|
|
* 获取代理人的相关数据
|
|
|
*/
|
|
|
try {
|
|
|
//设置航班
|
|
|
result.setSegment(result.getOriginatingStation() + " — " + result.getDestinationStation());
|
|
|
|
|
|
//设置承运人二字码
|
|
|
result.setCarrier(result.getFlightNo().substring(0, 2));
|
|
|
|
|
|
/**
|
|
|
* 3.根据 理货信息 中的目的站代码,获取 新舱单机场代码表 中的相应数据
|
|
|
*
|
|
|
* 机场所属城市代码
|
|
|
*/
|
|
|
BasAirport ba = basAirportService.getBasAirportInfo(result.getDestinationStation());
|
|
|
|
|
|
/**
|
|
|
* 4.根据 新舱单机场代码表 中的 机场所属城市代码 ,获取 天博——机场代码表 的相应数据
|
|
|
*
|
|
|
* 城市代码
|
|
|
* 区域id
|
|
|
* 国家代码
|
|
|
*/
|
|
|
TbAirportCode ta = tbAirportCodeService.getTbAirportCodeInfo(ba.getCityId());
|
|
|
// 所属国家代码
|
|
|
result.setCountry(ta.getCountry());
|
|
|
|
|
|
/**
|
|
|
* 5.根据 天博——机场代码表 中的 区域id,获取 新舱单——区域代码表 的相应数据
|
|
|
*
|
|
|
* 区域id
|
|
|
* 国际国内标识;1,国外;2,国内
|
|
|
* 区域描述,中文
|
|
|
*/
|
|
|
BasArea basArea = basAreaService.getBasAreaInfo(ta.getArea());
|
|
|
//航班目的区域,中文描述,所属洲
|
|
|
result.setAreaDescChn(basArea.getAreaDescChn());
|
|
|
|
|
|
/**
|
|
|
* 6.根据 理货信息 中的运单号,获取预配表中的相应数据
|
|
|
*
|
|
|
* 发货人名称
|
|
|
* 收货人名称
|
|
|
* 航班目的站
|
|
|
*/
|
|
|
List<PrepareMaster> pm = prepareMasterService.getPrepareMasterInfo(result.getWaybillNoMaster());
|
|
|
if (pm != null && pm.size() > 0) {
|
|
|
//发货人名称
|
|
|
result.setShipperName(pm.get(0).getShipperName());
|
|
|
//收货人名称
|
|
|
result.setConsigneeName(pm.get(0).getConsigneeName());
|
|
|
//获取目的货物目的站
|
|
|
result.setAimStation(pm.get(0).getDestinationStation());
|
|
|
}
|
|
|
/**
|
|
|
* 获取数据仓库的对应数据
|
|
|
|
|
|
// if (result.getWaybillNoMaster() != null && result.getWaybillNoMaster() != "") {}
|
|
|
ResultExitData dataWareHouseInfo=new ResultExitData();
|
|
|
dataWareHouseInfo = getDataWareHouseFeign.getInfo(result.getWaybillNoMaster());
|
|
|
//设置体积
|
|
|
result.setVolumeMeasure(dataWareHouseInfo.getVolumeMeasure());
|
|
|
//设置计费重量
|
|
|
result.setTotalGrossWeightMeasure(dataWareHouseInfo.getTotalGrossWeightMeasure());
|
|
|
*/
|
|
|
|
|
|
/**
|
|
|
* 获取运输工具的对应数据
|
|
|
*/
|
|
|
ResultExitData transportInfo = new ResultExitData();
|
|
|
transportInfo = getTransportFeign.getInfo(result.getFlightNo(), result.getFlightDate());
|
|
|
//设置航班公司
|
|
|
result.setAirCompany(transportInfo.getAirCompany());
|
|
|
//设置机型
|
|
|
result.setCfTp(transportInfo.getCfTp());
|
|
|
//设置机号
|
|
|
result.setCfNo(transportInfo.getCfNo());
|
|
|
//设置航班计划日期
|
|
|
result.setFlightPlanDate(transportInfo.getFlightPlanDate());
|
|
|
//设置航班(起飞)时间
|
|
|
result.setFlightTime(transportInfo.getFlightTime());
|
|
|
//设置航班计划时间
|
|
|
result.setFlightPlanTime(transportInfo.getFlightPlanTime());
|
|
|
|
|
|
/**
|
|
|
* 获取代理人的相关数据
|
|
|
*/
|
|
|
// if (result.getWaybillNoMaster() != null && result.getWaybillNoMaster() != "") { }
|
|
|
ResultExitData asmInfo = new ResultExitData();
|
|
|
asmInfo = getCgoAsmFeign.getInfo(result.getWaybillNoMaster());
|
|
|
//设置代理人全称
|
|
|
result.setFullName(asmInfo.getFullName());
|
|
|
//设置货主类型
|
|
|
result.setTheShipperType(asmInfo.getTheShipperType());
|
|
|
//设置品名
|
|
|
result.setSdCargoName(asmInfo.getSdCargoName());
|
|
|
//设置二级类名称
|
|
|
result.setTwoTypeName(asmInfo.getTwoTypeName());
|
|
|
//设置一级类名称
|
|
|
result.setTypeName(asmInfo.getTypeName());
|
|
|
ResultExitData asmInfo = new ResultExitData();
|
|
|
asmInfo = getCgoAsmFeign.getInfo(result.getWaybillNoMaster());
|
|
|
//设置结算代理人
|
|
|
result.setCountName(asmInfo.getCountName());
|
|
|
//设置订舱代理人
|
|
|
result.setOrderName(asmInfo.getOrderName());
|
|
|
//设置品名
|
|
|
result.setSdCargoName(asmInfo.getSdCargoName());
|
|
|
//设置二级类名称
|
|
|
result.setTwoTypeName(asmInfo.getTwoTypeName());
|
|
|
//设置一级类名称
|
|
|
result.setTypeName(asmInfo.getTypeName());
|
|
|
} catch (Exception e) {
|
|
|
latch.countDown();
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
latch.countDown();
|
|
|
}
|
|
|
};
|
...
|
...
|
@@ -305,9 +329,9 @@ public class NmsController { |
|
|
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
|
|
|
}
|
|
|
|
|
|
private void sendMsgByWebsocket(String msg,String sid){
|
|
|
private void sendMsgByWebsocket(String msg, String sid) {
|
|
|
try {
|
|
|
WebSocketServer.sendInfo(msg,sid);
|
|
|
WebSocketServer.sendInfo(msg, sid);
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
|
...
|
...
|
|