完成登机桥逻辑处理
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
package com.gzzn.omms.msgexchangeapi.basicdata.entity;
|
||||
|
||||
public class OrmsStandAirbridge {
|
||||
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.gzzn.omms.msgexchangeapi.basicdata.manager;
|
||||
|
||||
/**
|
||||
* 机位登机桥,关系管理
|
||||
* @author zhouxiunai
|
||||
*
|
||||
*/
|
||||
public class OrmsStandAirbridge {
|
||||
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
package com.gzzn.omms.msgexchangeapi.basicdata.manager;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParseException;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.gzzn.omms.msgexchangeapi.basicdata.entity.OrmsStand;
|
||||
import com.gzzn.omms.msgexchangeapi.basicdata.service.IOrmsStandService;
|
||||
import com.gzzn.omms.msgexchangeapi.redis.RedisService;
|
||||
import com.gzzn.omms.msgexchangeapi.utils.JsonUtil;
|
||||
import com.gzzn.omms.msgexchangeapi.utils.SpringUtil;
|
||||
|
||||
/**
|
||||
* 机位登机桥,关系管理
|
||||
* @author zhouxiunai
|
||||
*
|
||||
*/
|
||||
public class OrmsStandAirbridgeManager {
|
||||
private static final String KEY_ORMSSTANDAIRBRIDGE = "orms_stand_airbridge";
|
||||
private static OrmsStandAirbridgeManager instance = new OrmsStandAirbridgeManager();
|
||||
|
||||
private OrmsStandAirbridgeManager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static OrmsStandAirbridgeManager getInstance()
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
|
||||
public List<String> getAirbridgeCodeByStandCodeCode(String standCode) throws JsonParseException, JsonMappingException, IOException
|
||||
{
|
||||
|
||||
List<String> rtList = new ArrayList<String>();
|
||||
|
||||
synchronized(OrmsStandAirbridgeManager.class)
|
||||
{
|
||||
//缓存获取
|
||||
RedisService redisService = (RedisService) SpringUtil
|
||||
.getBean("redisService");
|
||||
Boolean keyExists = redisService.hasKey(KEY_ORMSSTANDAIRBRIDGE);
|
||||
|
||||
|
||||
if(!keyExists)
|
||||
{
|
||||
//远程获取
|
||||
IOrmsStandService ormsStandService = (IOrmsStandService) SpringUtil
|
||||
.getBean("ormsStandService");
|
||||
List<String> lsAirbridgeCodes = ormsStandService.getAirbridgeCodeByStandCode(standCode);
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put(standCode, JsonUtil.getString(lsAirbridgeCodes));
|
||||
|
||||
redisService.hmset(KEY_ORMSSTANDAIRBRIDGE, map, 3600L);
|
||||
}
|
||||
|
||||
//本地获取
|
||||
String jsonListStr = (String) redisService.hget(KEY_ORMSSTANDAIRBRIDGE, standCode);
|
||||
rtList = JsonUtil.getObject(jsonListStr , List.class);
|
||||
}
|
||||
|
||||
return rtList;
|
||||
} // en
|
||||
}
|
||||
@@ -15,4 +15,6 @@ public interface IOrmsStandService {
|
||||
* @return
|
||||
*/
|
||||
public List<OrmsStand> findAll();
|
||||
|
||||
public List<String> getAirbridgeCodeByStandCode(String StandCode);
|
||||
}
|
||||
|
||||
+22
-2
@@ -1,6 +1,5 @@
|
||||
package com.gzzn.omms.msgexchangeapi.basicdata.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
@@ -21,6 +20,9 @@ public class OrmsStandServiceImpl implements IOrmsStandService{
|
||||
@Value("${adminApi.ormsStandsUrl}")
|
||||
private String ormsStandsUrl;
|
||||
|
||||
@Value("${adminApi.getAirbridgeCodeByStandCodeUrl}")
|
||||
private String getAirbridgeCodeByStandCodeUrl;
|
||||
|
||||
@Autowired
|
||||
private RestTemplate restTemplate;
|
||||
|
||||
@@ -32,7 +34,6 @@ public class OrmsStandServiceImpl implements IOrmsStandService{
|
||||
ResponseDto.class);
|
||||
ResponseDto responseDto = responseEntity.getBody();
|
||||
if (responseDto.getIs_success()) {
|
||||
|
||||
List<LinkedHashMap> lsLinked = (List<LinkedHashMap>)responseDto.getBody();
|
||||
|
||||
//
|
||||
@@ -45,4 +46,23 @@ public class OrmsStandServiceImpl implements IOrmsStandService{
|
||||
throw new RuntimeException("未知错误"+responseDto.getErr_msg());
|
||||
}
|
||||
}//end function
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> getAirbridgeCodeByStandCode(String StandCode) {
|
||||
ResponseEntity<ResponseDto> responseEntity = restTemplate
|
||||
.getForEntity(
|
||||
getAirbridgeCodeByStandCodeUrl,
|
||||
ResponseDto.class,StandCode);
|
||||
|
||||
ResponseDto responseDto = responseEntity.getBody();
|
||||
if (!responseDto.getIs_success()) {
|
||||
throw new RuntimeException("未知错误"+responseDto.getErr_msg());
|
||||
}
|
||||
|
||||
//正常逻辑
|
||||
List<String> rt = (List<String>)responseDto.getBody();
|
||||
|
||||
return rt;
|
||||
} //end function
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.gzzn.omms.msgexchangeapi.msghandler.flop;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
@@ -7,6 +9,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import com.gzzn.omms.msgexchangeapi.basicdata.entity.OrmsStand;
|
||||
import com.gzzn.omms.msgexchangeapi.basicdata.manager.OrmsStandAirbridgeManager;
|
||||
import com.gzzn.omms.msgexchangeapi.basicdata.manager.OrmsStandManager;
|
||||
import com.gzzn.omms.msgexchangeapi.entity.msg.FLOP;
|
||||
import com.gzzn.omms.msgexchangeapi.entity.msg.OPTSTANDDATA;
|
||||
@@ -67,8 +70,28 @@ public class PSDTHandler extends FlopBaseHandler {
|
||||
//获取机位对应的登机桥
|
||||
if("near".equalsIgnoreCase(ormsStand.getStandType()))
|
||||
{
|
||||
String abdg = standata.getPSST();//登机桥
|
||||
fltr.setAbdg(abdg);//登机桥叠加
|
||||
String standCode = standata.getPSST();//登机桥
|
||||
|
||||
List<String> lsBridge = new ArrayList<String>();
|
||||
try {
|
||||
lsBridge = OrmsStandAirbridgeManager
|
||||
.getInstance()
|
||||
.getAirbridgeCodeByStandCodeCode(standCode);
|
||||
} catch (IOException e) {
|
||||
logger.error("获取登机桥信息失败:{}",e.getMessage());
|
||||
}
|
||||
|
||||
StringBuffer abdgBuffer = new StringBuffer();
|
||||
lsBridge.forEach(node->{
|
||||
abdgBuffer.append(node);
|
||||
abdgBuffer.append(",");
|
||||
});
|
||||
if(abdgBuffer.toString().endsWith(","))
|
||||
{
|
||||
abdgBuffer.deleteCharAt(abdgBuffer.length() - 1);
|
||||
}
|
||||
|
||||
fltr.setAbdg(abdgBuffer.toString());//登机桥叠加
|
||||
}
|
||||
} //添加新数据
|
||||
|
||||
|
||||
@@ -99,3 +99,4 @@ adminApi:
|
||||
schema: http
|
||||
baseUrl: ${adminApi.schema}://ADMINAPI
|
||||
ormsStandsUrl: ${adminApi.baseUrl}/basicdata/ormsStands
|
||||
getAirbridgeCodeByStandCodeUrl: ${adminApi.baseUrl}/basicdata/ormsStands/{standCode}/airbridgeCode
|
||||
@@ -100,3 +100,4 @@ adminApi:
|
||||
schema: http
|
||||
baseUrl: ${adminApi.schema}://ADMINAPI
|
||||
ormsStandsUrl: ${adminApi.baseUrl}/basicdata/ormsStands
|
||||
getAirbridgeCodeByStandCodeUrl: ${adminApi.baseUrl}/basicdata/ormsStands/{standCode}/airbridgeCode
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package com.gzzn.omms.msgexchangeapi.basicdata;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParseException;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.gzzn.omms.msgexchangeapi.basicdata.manager.OrmsStandAirbridgeManager;
|
||||
import com.gzzn.omms.msgexchangeapi.config.TestRestTemplateConfig;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes=TestRestTemplateConfig.class)
|
||||
public class OrmsStandAirbridgeManagerTest {
|
||||
|
||||
@Test
|
||||
public void testFindAll() throws JsonParseException, JsonMappingException, IOException
|
||||
{
|
||||
List<String> ls = OrmsStandAirbridgeManager.getInstance().getAirbridgeCodeByStandCodeCode("147");
|
||||
assertThat(ls).isNotNull();
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,12 @@ public class OrmsStandServiceImplTest {
|
||||
assertThat(lsOrmsStands).isNotEmpty();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetAirbridgeCodeByStandCode()
|
||||
{
|
||||
List<String> ls = ormsStandService.getAirbridgeCodeByStandCode("147");
|
||||
assertThat(ls).isNotEmpty()
|
||||
.hasSize(2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user