作者 王勇

逻辑修改,减少for循环。关闭熔断器与超时

... ... @@ -60,6 +60,8 @@ public class CgoNmsController {
ResultExitData resultExitData = new ResultExitData();
resultExitData.setFlightDate(flightDate);
resultExitData.setFlightNo(flightNo);
System.out.println("开始时间:" + new Date());
System.out.println("出港数据,开始获取");
/**
* 1.先获取出 新舱单——理货信息 中的相应数据
*
... ... @@ -67,8 +69,8 @@ public class CgoNmsController {
* 航段(在数据库里面为null,所以只能 起始站 > 目的站 )
* 理货件数; 理货重量
*/
List<ResultExitData> resultList = resultExitDataService.getResultExitDataInfo(resultExitData);
System.out.println("长度为:" + resultList.size());
for (int i = 0, resultSize = resultList.size(); i < resultSize; i++) {
ResultExitData result = resultList.get(i);
//设置航班
... ... @@ -121,14 +123,54 @@ public class CgoNmsController {
//获取目的货物目的站
result.setAimStation(pm.get(0).getDestinationStation());
}
/**
* 获取数据仓库的对应数据
*/
// if (result.getWaybillNoMaster() != null && result.getWaybillNoMaster() != "") {}
ResultExitData dataWareHouseInfo = getDataWareHouseFeign.getInfo(result.getWaybillNoMaster());
//设置体积
result.setVolumeMeasure(dataWareHouseInfo.getVolumeMeasure());
//设置计费重量
result.setTotalGrossWeightMeasure(dataWareHouseInfo.getTotalGrossWeightMeasure());
/**
* 获取运输工具的对应数据
*/
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 = getCgoAsmFeign.getInfo(result.getWaybillNoMaster());
//设置代理人全称
result.setFullName(asmInfo.getFullName());
//设置货主类型
result.setTheShipperType(asmInfo.getTheShipperType());
//设置品名
result.setSdCargoName(asmInfo.getSdCargoName());
//设置二级类名称
result.setTwoTypeName(asmInfo.getTwoTypeName());
//设置一级类名称
result.setTypeName(asmInfo.getTypeName());
System.out.println("第" + i + "条,获取完毕");
}
System.out.println("代理人服务,开始获取");
List<ResultExitData> asmInfo = getCgoAsmFeign.getInfo(resultList);
System.out.println("运输工具服务,开始获取");
List<ResultExitData> transportInfo = getTransportFeign.getInfo(asmInfo);
System.out.println("数据仓库服务,开始获取");
List<ResultExitData> info = getDataWareHouseFeign.getInfo(transportInfo);
System.out.println("出港基本数据,获取完毕");
return info;
System.out.println("结束时间:" + new Date());
System.out.println("出港信息,获取完毕");
return resultList;
}
}
... ...
... ... @@ -23,6 +23,7 @@ public class BasAirport implements Serializable {
* 机场站代码
*/
private String airportId;
/**
* 机场所属城市代码
*/
... ...
... ... @@ -97,11 +97,13 @@ public class ResultExitData implements Serializable {
private String areaDescChn;
/**
* 代理人服务
* 16.代理人全称
*/
private String fullName;
/**
* 代理人服务
* 17.货主类型
* 111 = 发货代理
* 222 = 订舱代理
... ... @@ -110,59 +112,70 @@ public class ResultExitData implements Serializable {
private String theShipperType;
/**
* 代理人服务
* 18.品名
*/
private String sdCargoName;
/**
* 代理人服务
* 19.二级类名称
*/
private String twoTypeName;
/**
* 代理人服务
* 20.一级类名称
*/
private String typeName;
/**
* 运输工具服务
* 21.航空公司
*/
private String airCompany;
/**
* 运输工具服务
* 22.机型
*/
private String cfTp;
/**
* 运输工具服务
* 23.机号
*/
private String cfNo;
/**
* 运输工具服务
* 24.航班(起飞)时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date flightTime;
/**
* 运输工具服务
* 25.航班计划日期
*/
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date flightPlanDate;
/**
* 运输工具服务
* 26.航班计划时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date flightPlanTime;
/**
* 数据仓库服务
* 27.计费重量
*/
private BigDecimal totalGrossWeightMeasure;
/**
* 数据仓库服务
* 28.体积
*/
private BigDecimal volumeMeasure;
... ...
... ... @@ -15,7 +15,7 @@ import java.util.List;
public class GetCgoAsmFeginHystrix implements GetCgoAsmFeign{
@Override
public List<ResultExitData> getInfo(List<ResultExitData> resultList) {
public ResultExitData getInfo(String waybillNoMaster) {
System.out.println("与代理人服务断开连接,获取代理人服务信息失败");
return null;
}
... ...
... ... @@ -3,19 +3,27 @@ package com.sunyo.wlpt.cgonms.provide.feign;
import com.sunyo.wlpt.cgonms.provide.domain.ResultExitData;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* @author 子诚
* Description:
* Description:根据运单号查询代理人服务的相关数据
* 时间:2020/5/21 17:43
*/
@Component
@FeignClient(value = "cgoasm-provide", fallback = GetCgoAsmFeginHystrix.class)
public interface GetCgoAsmFeign {
@PutMapping("/cgoasm/getInfo")
List<ResultExitData> getInfo(@RequestBody List<ResultExitData> resultList);
/**
* 根据运单号查询代理人服务的相关数据
*
* @param waybillNoMaster 运单号
* @return
*/
@GetMapping("/cgoasm/getInfo")
ResultExitData getInfo(@RequestParam(value = "waybillNoMaster", required = false) String waybillNoMaster);
}
... ...
... ... @@ -3,8 +3,10 @@ package com.sunyo.wlpt.cgonms.provide.feign;
import com.sunyo.wlpt.cgonms.provide.domain.ResultExitData;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
... ... @@ -16,6 +18,12 @@ import java.util.List;
@Component
@FeignClient(value = "data-warehouse", fallback = GetDataWareHouseFeignHystrix.class)
public interface GetDataWareHouseFeign {
@PutMapping("/data/getInfo")
List<ResultExitData> getInfo(@RequestBody List<ResultExitData> resultList);
/**
* 根据运单号,查询数据仓库服务的体积和计费重量
*
* @param waybillNoMaster 运单号
* @return
*/
@GetMapping("/data/getInfo")
ResultExitData getInfo(@RequestParam(value = "waybillNoMaster", required = false) String waybillNoMaster);
}
... ...
... ... @@ -13,7 +13,7 @@ import java.util.List;
@Service
public class GetDataWareHouseFeignHystrix implements GetDataWareHouseFeign {
@Override
public List<ResultExitData> getInfo(List<ResultExitData> resultList) {
public ResultExitData getInfo(String waybillNoMaster) {
System.out.println("与 数据仓库 服务 断开连接,获取 数据仓库 服务信息失败");
return null;
}
... ...
... ... @@ -9,14 +9,26 @@ package com.sunyo.wlpt.cgonms.provide.feign;
import com.sunyo.wlpt.cgonms.provide.domain.ResultExitData;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.Date;
import java.util.List;
@Component
@FeignClient(value = "transport-provide", fallback = GetTransportFeignHystrix.class)
public interface GetTransportFeign {
@PutMapping("transport/getInfo")
public List<ResultExitData> getInfo(@RequestBody List<ResultExitData> resultList);
/**
* 根据承运人二字码、航班号、航班日期,获取,运输工具服务中的相关数据
* 航空公司、机型、机号、实际起飞时间、计划起飞时间
*
* @param flightNo 航班号
* @param flightDate 航班日期
* @return
*/
@GetMapping("/transport/getInfo")
public ResultExitData getInfo(@RequestParam(value = "flightNo", required = false) String flightNo,
@RequestParam(value = "flightDate", required = false) Date flightDate);
}
... ...
... ... @@ -3,6 +3,7 @@ package com.sunyo.wlpt.cgonms.provide.feign;
import com.sunyo.wlpt.cgonms.provide.domain.ResultExitData;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
... ... @@ -12,8 +13,9 @@ import java.util.List;
*/
@Service
public class GetTransportFeignHystrix implements GetTransportFeign {
@Override
public List<ResultExitData> getInfo(List<ResultExitData> resultList) {
public ResultExitData getInfo(String flightNo, Date flightDate) {
System.out.println("与“运输工具”服务断开连接,获取“运输工具”服务信息失败");
return null;
}
... ...
... ... @@ -63,11 +63,11 @@ eureka:
feign:
hystrix:
enabled: false
client:
config:
default:
connectTimeout: 60000000 # feign 的超时设置
readTimeout: 60000000
# client:
# config:
# default:
# connectTimeout: 1000000 # feign 的超时设置
# readTimeout: 1000000
# boot admin
management:
endpoints:
... ...