From 9f80b925877e99a4df5e6bea0a410d1bdea7d887 Mon Sep 17 00:00:00 2001 From: zhouxiunai <154707516@qq.com> Date: Mon, 28 Jan 2019 15:46:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E8=AE=A1=E5=88=92=E6=9C=BA?= =?UTF-8?q?=E4=BD=8D=E5=92=8C=E7=99=BB=E6=9C=BA=E6=A1=A5=E8=81=94=E5=8A=A8?= =?UTF-8?q?=E5=8F=98=E6=9B=B4=EF=BC=8C=E5=90=8C=E6=97=B6=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E5=9F=BA=E7=A1=80=E6=95=B0=E6=8D=AE=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basicdata/entity/OrmsStand.java | 281 ++++++++++++++++++ .../basicdata/manager/OrmsStandManager.java | 56 ++++ .../basicdata/service/IOrmsStandService.java | 18 ++ .../service/OrmsStandServiceImpl.java | 39 +++ .../config/RestTemplateConfig.java | 25 ++ .../msghandler/flop/PSDTHandler.java | 21 +- src/main/resources/application-dev.yml | 10 +- src/main/resources/application-pro.yml | 8 +- .../basicdata/OrmsStandServiceImplTest.java | 29 ++ 9 files changed, 478 insertions(+), 9 deletions(-) create mode 100644 src/main/java/com/gzzn/omms/msgexchangeapi/basicdata/entity/OrmsStand.java create mode 100644 src/main/java/com/gzzn/omms/msgexchangeapi/basicdata/manager/OrmsStandManager.java create mode 100644 src/main/java/com/gzzn/omms/msgexchangeapi/basicdata/service/IOrmsStandService.java create mode 100644 src/main/java/com/gzzn/omms/msgexchangeapi/basicdata/service/OrmsStandServiceImpl.java create mode 100644 src/main/java/com/gzzn/omms/msgexchangeapi/config/RestTemplateConfig.java create mode 100644 src/test/java/com/gzzn/omms/msgexchangeapi/basicdata/OrmsStandServiceImplTest.java diff --git a/src/main/java/com/gzzn/omms/msgexchangeapi/basicdata/entity/OrmsStand.java b/src/main/java/com/gzzn/omms/msgexchangeapi/basicdata/entity/OrmsStand.java new file mode 100644 index 00000000..7d81f910 --- /dev/null +++ b/src/main/java/com/gzzn/omms/msgexchangeapi/basicdata/entity/OrmsStand.java @@ -0,0 +1,281 @@ +package com.gzzn.omms.msgexchangeapi.basicdata.entity; + +import java.math.BigDecimal; + +import javax.persistence.Column; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.SequenceGenerator; + + +/** + * 机位 + * @author zhouxiunai + */ +public class OrmsStand { + private String standCode; //停机位号 + + private BigDecimal currentFlightId; //当前航班ID + + private String ddgt; //该机位默认的国内登机门 + + private String digt; //该机位默认的国际登机门 + + private String fstandCode; //父停机位号 + + private BigDecimal iconLength; //资源图标长度(单位:像素) + + private BigDecimal iconWidth; //资源图标宽度(单位:像素) + + private String lstandCode; + + private BigDecimal maxPermit; //该停机位可容纳的最大旅客数/最大翼展 + + private BigDecimal maxflightnum; //最大可停靠航班数 + + private BigDecimal operate; + + private String pierCode; //指廊代码 + + private BigDecimal posX; //坐标位置的X值 + + private BigDecimal posY; //坐标位置的Y值 + + private String rstandCode; + + private String satc; //该停机位可以停放的最大机型种类 + + private String standAreaCode; //停机位区域代码 + + private BigDecimal standLayouted; //资源已布局标志:1-已布局 0-未布局 + + private BigDecimal standLength; //停机位长度(单位:米) + + private String standName; //停机位名称 + + private BigDecimal standOrder; //停机位顺序号 + + private BigDecimal standStatus; //停机位状态(0-可用、1-在用、2-锁定、3-禁用、4-预分...) + + //停机位类别可取值:bridge-靠桥机位、remote-远机位、near-近机位、night-过夜机位、specific-专机位... + private String standType; + + private BigDecimal standWidth; //停机位宽度 + + private String stml; //航站楼代码 + + private String terminalAreaCode; //航站楼区域代码 + + public OrmsStand() { + } + + public String getStandCode() { + return this.standCode; + } + + public void setStandCode(String standCode) { + this.standCode = standCode; + } + + public BigDecimal getCurrentFlightId() { + return this.currentFlightId; + } + + public void setCurrentFlightId(BigDecimal currentFlightId) { + this.currentFlightId = currentFlightId; + } + + public String getDdgt() { + return this.ddgt; + } + + public void setDdgt(String ddgt) { + this.ddgt = ddgt; + } + + public String getDigt() { + return this.digt; + } + + public void setDigt(String digt) { + this.digt = digt; + } + + public String getFstandCode() { + return this.fstandCode; + } + + public void setFstandCode(String fstandCode) { + this.fstandCode = fstandCode; + } + + public BigDecimal getIconLength() { + return this.iconLength; + } + + public void setIconLength(BigDecimal iconLength) { + this.iconLength = iconLength; + } + + public BigDecimal getIconWidth() { + return this.iconWidth; + } + + public void setIconWidth(BigDecimal iconWidth) { + this.iconWidth = iconWidth; + } + + public String getLstandCode() { + return this.lstandCode; + } + + public void setLstandCode(String lstandCode) { + this.lstandCode = lstandCode; + } + + public BigDecimal getMaxPermit() { + return this.maxPermit; + } + + public void setMaxPermit(BigDecimal maxPermit) { + this.maxPermit = maxPermit; + } + + public BigDecimal getMaxflightnum() { + return this.maxflightnum; + } + + public void setMaxflightnum(BigDecimal maxflightnum) { + this.maxflightnum = maxflightnum; + } + + public BigDecimal getOperate() { + return this.operate; + } + + public void setOperate(BigDecimal operate) { + this.operate = operate; + } + + public String getPierCode() { + return this.pierCode; + } + + public void setPierCode(String pierCode) { + this.pierCode = pierCode; + } + + public BigDecimal getPosX() { + return this.posX; + } + + public void setPosX(BigDecimal posX) { + this.posX = posX; + } + + public BigDecimal getPosY() { + return this.posY; + } + + public void setPosY(BigDecimal posY) { + this.posY = posY; + } + + public String getRstandCode() { + return this.rstandCode; + } + + public void setRstandCode(String rstandCode) { + this.rstandCode = rstandCode; + } + + public String getSatc() { + return this.satc; + } + + public void setSatc(String satc) { + this.satc = satc; + } + + public String getStandAreaCode() { + return this.standAreaCode; + } + + public void setStandAreaCode(String standAreaCode) { + this.standAreaCode = standAreaCode; + } + + public BigDecimal getStandLayouted() { + return this.standLayouted; + } + + public void setStandLayouted(BigDecimal standLayouted) { + this.standLayouted = standLayouted; + } + + public BigDecimal getStandLength() { + return this.standLength; + } + + public void setStandLength(BigDecimal standLength) { + this.standLength = standLength; + } + + public String getStandName() { + return this.standName; + } + + public void setStandName(String standName) { + this.standName = standName; + } + + public BigDecimal getStandOrder() { + return this.standOrder; + } + + public void setStandOrder(BigDecimal standOrder) { + this.standOrder = standOrder; + } + + public BigDecimal getStandStatus() { + return this.standStatus; + } + + public void setStandStatus(BigDecimal standStatus) { + this.standStatus = standStatus; + } + + public String getStandType() { + return this.standType; + } + + public void setStandType(String standType) { + this.standType = standType; + } + + public BigDecimal getStandWidth() { + return this.standWidth; + } + + public void setStandWidth(BigDecimal standWidth) { + this.standWidth = standWidth; + } + + public String getStml() { + return this.stml; + } + + public void setStml(String stml) { + this.stml = stml; + } + + public String getTerminalAreaCode() { + return this.terminalAreaCode; + } + + public void setTerminalAreaCode(String terminalAreaCode) { + this.terminalAreaCode = terminalAreaCode; + } + +} \ No newline at end of file diff --git a/src/main/java/com/gzzn/omms/msgexchangeapi/basicdata/manager/OrmsStandManager.java b/src/main/java/com/gzzn/omms/msgexchangeapi/basicdata/manager/OrmsStandManager.java new file mode 100644 index 00000000..b0d49230 --- /dev/null +++ b/src/main/java/com/gzzn/omms/msgexchangeapi/basicdata/manager/OrmsStandManager.java @@ -0,0 +1,56 @@ +package com.gzzn.omms.msgexchangeapi.basicdata.manager; + + +import java.util.Hashtable; +import java.util.List; + +import com.gzzn.omms.msgexchangeapi.basicdata.entity.OrmsStand; +import com.gzzn.omms.msgexchangeapi.basicdata.service.IOrmsStandService; +import com.gzzn.omms.msgexchangeapi.utils.SpringUtil; + +/** + * 登记位基础数据管理 + * @author zhouxiunai + * + */ +public class OrmsStandManager { + private static Hashtable dataCache = null; + + private static OrmsStandManager instance = new OrmsStandManager(); + + private OrmsStandManager() + { + + } + + public static OrmsStandManager getInstance() + { + return instance; + } + + public OrmsStand getOrmsStandByStandCode(String standCode) + { + OrmsStand ormsStand = null; + synchronized (OrmsStandManager.class) { + if(null == dataCache) + { + //远程获取 + IOrmsStandService ormsStandService = (IOrmsStandService) SpringUtil + .getBean("ormsStandService"); + List lsOrmsStand = ormsStandService.findAll(); + + + dataCache = new Hashtable<>(); + for(OrmsStand node: lsOrmsStand) + { + dataCache.put(node.getStandCode(), node); + } + } + + //本地获取 + ormsStand = (OrmsStand) dataCache.get(standCode); + } + + return ormsStand; + } +} diff --git a/src/main/java/com/gzzn/omms/msgexchangeapi/basicdata/service/IOrmsStandService.java b/src/main/java/com/gzzn/omms/msgexchangeapi/basicdata/service/IOrmsStandService.java new file mode 100644 index 00000000..a1730018 --- /dev/null +++ b/src/main/java/com/gzzn/omms/msgexchangeapi/basicdata/service/IOrmsStandService.java @@ -0,0 +1,18 @@ +package com.gzzn.omms.msgexchangeapi.basicdata.service; + +import java.util.List; + +import com.gzzn.omms.msgexchangeapi.basicdata.entity.OrmsStand; + +/** + * 停机位service + * @author zhouxiunai + * + */ +public interface IOrmsStandService { + /** + * 获取所有停机位信息 + * @return + */ + public List findAll(); +} diff --git a/src/main/java/com/gzzn/omms/msgexchangeapi/basicdata/service/OrmsStandServiceImpl.java b/src/main/java/com/gzzn/omms/msgexchangeapi/basicdata/service/OrmsStandServiceImpl.java new file mode 100644 index 00000000..1d95b440 --- /dev/null +++ b/src/main/java/com/gzzn/omms/msgexchangeapi/basicdata/service/OrmsStandServiceImpl.java @@ -0,0 +1,39 @@ +package com.gzzn.omms.msgexchangeapi.basicdata.service; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; + +import com.gzzn.omms.msgexchangeapi.basicdata.entity.OrmsStand; +import com.gzzn.omms.msgexchangeapi.dto.ResponseDto; + +@Service("ormsStandService") +public class OrmsStandServiceImpl implements IOrmsStandService{ + + @Value("${adminApi.ormsStandsUrl}") + private String ormsStandsUrl; + + @Autowired + private RestTemplate restTemplate; + + @Override + public List findAll() { + ResponseEntity responseEntity = restTemplate + .getForEntity( + ormsStandsUrl, + ResponseDto.class); + ResponseDto responseDto = responseEntity.getBody(); + if (responseDto.getIs_success()) { + + List rt = (List)responseDto.getBody(); + return rt; + } + else { + throw new RuntimeException("未知错误"+responseDto.getErr_msg()); + } + }//end function +} diff --git a/src/main/java/com/gzzn/omms/msgexchangeapi/config/RestTemplateConfig.java b/src/main/java/com/gzzn/omms/msgexchangeapi/config/RestTemplateConfig.java new file mode 100644 index 00000000..fae99d4e --- /dev/null +++ b/src/main/java/com/gzzn/omms/msgexchangeapi/config/RestTemplateConfig.java @@ -0,0 +1,25 @@ +package com.gzzn.omms.msgexchangeapi.config; + +import org.springframework.cloud.client.loadbalancer.LoadBalanced; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.client.ClientHttpRequestFactory; +import org.springframework.http.client.SimpleClientHttpRequestFactory; +import org.springframework.web.client.RestTemplate; + +@Configuration +public class RestTemplateConfig { + @Bean + @LoadBalanced + public RestTemplate restTemplate(ClientHttpRequestFactory factory){ + return new RestTemplate(factory); + } + + @Bean + public ClientHttpRequestFactory simpleClientHttpRequestFactory(){ + SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory(); + factory.setReadTimeout(5000);//单位为ms + factory.setConnectTimeout(5000);//单位为ms + return factory; + } +} diff --git a/src/main/java/com/gzzn/omms/msgexchangeapi/msghandler/flop/PSDTHandler.java b/src/main/java/com/gzzn/omms/msgexchangeapi/msghandler/flop/PSDTHandler.java index 3e0baa19..fe5b81e5 100644 --- a/src/main/java/com/gzzn/omms/msgexchangeapi/msghandler/flop/PSDTHandler.java +++ b/src/main/java/com/gzzn/omms/msgexchangeapi/msghandler/flop/PSDTHandler.java @@ -4,6 +4,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; +import com.gzzn.omms.msgexchangeapi.basicdata.entity.OrmsStand; +import com.gzzn.omms.msgexchangeapi.basicdata.manager.OrmsStandManager; import com.gzzn.omms.msgexchangeapi.entity.msg.FLOP; import com.gzzn.omms.msgexchangeapi.entity.msg.OPTSTANDDATA; import com.gzzn.omms.msgexchangeapi.entity.msg.SCHD; @@ -43,11 +45,24 @@ public class PSDTHandler extends FlopBaseHandler { BeanUtils.copyProperties(optStandata, standata); fltr.getPSDT().add(standata); + + //如果是近机位 + OrmsStand ormsStand = OrmsStandManager + .getInstance() + .getOrmsStandByStandCode(standata.getPSST()); + if(null == ormsStand) + { + logger.error("机位:{},基础数据获取失败",standata.getPSST()); + continue; + } + + if("near".equalsIgnoreCase(ormsStand.getStandType())) + { + String abdg = fltr.getAbdg() + "," + standata.getPSST();//登机桥 + fltr.setAbdg(abdg);//登机桥叠加 + } } //添加新数据 - - //联动变更登机桥 - return fltr; } } diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index bc31c038..747c9251 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -71,7 +71,7 @@ scheduled: hstCondition: #航班到达超过多久则成为历史航班数据(单位:毫秒) ARRIVE_HST_TIME: 3600000 - #航班取消超过多久则成为历史航班数据(单位:秒) + #航班取消超过多久则成为历史航班数据(单位:毫秒) CANCEL_HST_TIME: 3600000 #备降超过多久则成为历史航班数据 FROM CTU 本应降落到成都备降到其他地方(单位:毫秒) FDIV_HST_TIME: 59400000 @@ -92,4 +92,10 @@ eureka: service-url: defaultZone: http://130.120.3.231:94/eureka/ instance: - prefer-ip-address: true \ No newline at end of file + prefer-ip-address: true +adminApi: + host: 130.120.3.231 + port: 92 + schema: http + baseUrl: ${adminApi.schema}://ADMINAPI + ormsStandsUrl: ${adminApi.baseUrl}/basicdata/ormsStands \ No newline at end of file diff --git a/src/main/resources/application-pro.yml b/src/main/resources/application-pro.yml index 732fdbd3..f83a28cd 100644 --- a/src/main/resources/application-pro.yml +++ b/src/main/resources/application-pro.yml @@ -69,13 +69,13 @@ scheduled: flightSendCron: "*/3 * * * * ?" #计入历史航班数据的条件 hstCondition: - #航班到达超过多久则成为历史航班数据(单位:秒) + #航班到达超过多久则成为历史航班数据(单位:毫秒) ARRIVE_HST_TIME: 3600000 - #航班取消超过多久则成为历史航班数据(单位:秒) + #航班取消超过多久则成为历史航班数据(单位:毫秒) CANCEL_HST_TIME: 3600000 - #备降超过多久则成为历史航班数据 FROM CTU 本应降落到成都备降到其他地方(单位:秒) + #备降超过多久则成为历史航班数据 FROM CTU 本应降落到成都备降到其他地方(单位:毫秒) FDIV_HST_TIME: 59400000 - #计划时间超过多久则成为历史航班数据(单位:秒) + #计划时间超过多久则成为历史航班数据(单位:毫秒) SODT_HST_TIME: 259200000 # Elasticsearch diff --git a/src/test/java/com/gzzn/omms/msgexchangeapi/basicdata/OrmsStandServiceImplTest.java b/src/test/java/com/gzzn/omms/msgexchangeapi/basicdata/OrmsStandServiceImplTest.java new file mode 100644 index 00000000..3236f584 --- /dev/null +++ b/src/test/java/com/gzzn/omms/msgexchangeapi/basicdata/OrmsStandServiceImplTest.java @@ -0,0 +1,29 @@ +package com.gzzn.omms.msgexchangeapi.basicdata; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.List; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import com.gzzn.omms.msgexchangeapi.basicdata.entity.OrmsStand; +import com.gzzn.omms.msgexchangeapi.basicdata.service.IOrmsStandService; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class OrmsStandServiceImplTest { + + @Autowired + IOrmsStandService ormsStandService; + + @Test + public void testFindAll() + { + List lsOrmsStands = ormsStandService.findAll(); + assertThat(lsOrmsStands).isNotEmpty(); + } +}