作者 王勇

修改字段,订舱代理人,结算代理人

... ... @@ -105,7 +105,12 @@
<artifactId>hutool-all</artifactId>
<version>4.0.12</version>
</dependency>
<!-- excel导出-->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
... ...
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();
... ...
... ... @@ -97,19 +97,29 @@ public class ResultExitData implements Serializable {
private String areaDescChn;
/**
* 代理人服务
* 16.代理人全称
* 16.订仓代理人
*/
private String fullName;
private String orderName;
/**
* 代理人服务
* 17.货主类型
* 111 = 发货代理
* 222 = 订舱代理
* 333 = 操作代理/结算代理
* 17.结算代理人
*/
private String theShipperType;
private String countName;
// /**
// * 代理人服务
// * 16.代理人全称
// */
// private String fullName;
//
// /**
// * 代理人服务
// * 17.货主类型
// * 111 = 发货代理
// * 222 = 订舱代理
// * 333 = 操作代理/结算代理
// */
// private String theShipperType;
/**
* 代理人服务
... ... @@ -179,4 +189,6 @@ public class ResultExitData implements Serializable {
* 28.体积
*/
private BigDecimal volumeMeasure;
}
... ...
package com.sunyo.wlpt.cgonms.provide.domain;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @author 子诚
* Description:
* 时间:2020/5/29 11:11
*/
@Data
public class ResultExitDataList implements Serializable {
private static final long serialVersionUID = -7991080091037744719L;
private List<ResultExitData> exitInfoList;
private int size=exitInfoList.size();
}
... ...
package com.sunyo.wlpt.cgonms.provide.excle;
import com.sunyo.wlpt.cgonms.provide.domain.ResultExitData;
import com.sunyo.wlpt.cgonms.provide.domain.ResultExitDataList;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.hssf.usermodel.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import oracle.sql.DATE;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author 子诚
* Description:
* 时间:2020/5/29 10:04
*/
@Slf4j
@RestController
@RequestMapping("/exit")
public class ExitExcel {
@PostMapping("/excel")
public void getExit(@RequestBody List<ResultExitData> exitInfoList, HttpServletResponse httpServletResponse) {
exportExcel(exitInfoList, httpServletResponse);
}
private void exportExcel(List<ResultExitData> exitInfoList, HttpServletResponse response) {
// 创建工作簿
HSSFWorkbook workbook = new HSSFWorkbook();
// 创建表
HSSFSheet sheet = workbook.createSheet("export");
// 创建行
HSSFRow row = sheet.createRow(0);
// 创建单元格样式
HSSFCellStyle cellStyle = workbook.createCellStyle();
// 表头
String[] head = {
"运单号",
"件数",
"重量",
"计费重量",
"体积",
"品名",
"二级品类",
"一级品类",
"货物目的站",
"货物目的国家/地区",
"所属洲",
"航空公司",
"航班号",
"航班日期",
"航班时间",
"航班计划日期",
"航班计划时间",
"航段",
"机号",
"机型",
"最大业载",
"运单发货人",
"运单收货人",
"订舱代理人",
"结算代理人",
"自定义项"
};
HSSFCell cell;
// 设置表头
for (int i = 0; i < head.length; i++) {
cell = row.createCell(i);
cell.setCellValue(head[i]);
cell.setCellStyle(cellStyle);
// 设置单元格宽度
sheet.setColumnWidth(i, 4000);
}
// 设置表格内容
for (int i = 0; i < exitInfoList.size(); i++) {
row = sheet.createRow(i + 1);
ResultExitData ResultExitData = exitInfoList.get(i);
// 这里是内容设置,替换则自己的数据即可
String[] excelTitle = new String[40];
//取出数据,运单号
excelTitle[0] = ResultExitData.getWaybillNoMaster();
//件数
excelTitle[1] = ResultExitData.getTallyTotalPiece();
//重量
excelTitle[2] = ResultExitData.getTallyTotalWeight();
//计费重量
excelTitle[3] = String.valueOf(ResultExitData.getTotalGrossWeightMeasure());
//体积
excelTitle[4] = String.valueOf(ResultExitData.getVolumeMeasure());
//品名
excelTitle[5] = ResultExitData.getSdCargoName();
//二级品类
excelTitle[6] = ResultExitData.getTwoTypeName();
//一级品类
excelTitle[7] = ResultExitData.getTypeName();
//货物目的站
excelTitle[8] = ResultExitData.getAimStation();
//货物目的国家/地区
excelTitle[9] = ResultExitData.getCountry();
//所属洲
excelTitle[10] = ResultExitData.getAreaDescChn();
//航空公司
excelTitle[11] = ResultExitData.getAirCompany();
//航班号
excelTitle[12] = ResultExitData.getFlightNo();
//航班日期
excelTitle[13] = String.valueOf(ResultExitData.getFlightDate());
//航班时间
excelTitle[14] = String.valueOf(ResultExitData.getFlightTime());
//航班计划日期
excelTitle[15] = String.valueOf(ResultExitData.getFlightPlanDate());
//航班计划时间
excelTitle[16] = String.valueOf(ResultExitData.getFlightPlanTime());
//航段
excelTitle[17] = ResultExitData.getSegment();
//机号
excelTitle[18] = ResultExitData.getCfNo();
//机型
excelTitle[19] = ResultExitData.getCfTp();
//最大业载
excelTitle[20] = "";
//运单发货人
excelTitle[21] = ResultExitData.getShipperName();
//运单收货人
excelTitle[22] = ResultExitData.getConsigneeName();
//订舱代理人(代理人全称)
excelTitle[23] = ResultExitData.getOrderName();
//结算代理人(代理人全程)
excelTitle[24] = ResultExitData.getCountName();
//自定义项
excelTitle[25] = "";
for (int j = 0; j < excelTitle.length; j++) {
row.createCell(j).setCellValue(excelTitle[j]);
}
}
// 设置文件名
String title = "export.xls";
String filePath = "H:" + File.separator + title;
try {
FileOutputStream fos = new FileOutputStream(filePath);
workbook.write(fos);
fos.flush();
fos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
... ...
... ... @@ -63,11 +63,11 @@ eureka:
feign:
hystrix:
enabled: false
# client:
# config:
# default:
# connectTimeout: 1000000 # feign 的超时设置
# readTimeout: 1000000
client:
config:
default:
connectTimeout: 1000000 # feign 的超时设置
readTimeout: 1000000
# boot admin
management:
endpoints:
... ...