添加动态航班整体处理框架

This commit is contained in:
zhouxiunai
2018-12-04 11:37:45 +08:00
parent af4809efca
commit 747232bc89
6 changed files with 100 additions and 21 deletions
@@ -1,27 +1,62 @@
package com.gzzn.omms.msgexchangeapi.msghandler;
import java.util.Collections;
import java.util.List;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.gzzn.omms.msgexchangeapi.entity.msg.Msg;
import com.gzzn.omms.msgexchangeapi.entity.msg.schd.dnld.FLTR;
import com.gzzn.omms.msgexchangeapi.service.IExchangeService;
import com.gzzn.omms.msgexchangeapi.service.flightInfo.UpdateByCminmsgsResult;
@Service
public class MsgHandlerDispatcher {
@Autowired
IExchangeService exchangeService;
public List<FLTR> dispatch(String xmlMsg)
public UpdateByCminmsgsResult dispatch(String xmlMsg)
{
Msg msg = exchangeService.xmlstrToObject(xmlMsg, Msg.class);
String type = msg.getMeta().getType();
String subType = msg.getMeta().getStyp();
return Collections.emptyList();
}
try
{
Class clazzHandler = Class.forName(getHandlerClassName(type,subType));
Object classObject = clazzHandler.newInstance();
Method runMethod = clazzHandler.getMethod("run", String.class);
UpdateByCminmsgsResult result = (UpdateByCminmsgsResult) runMethod.invoke(classObject, xmlMsg);
return result;
} catch (ClassNotFoundException
| InstantiationException
| IllegalAccessException
| NoSuchMethodException
| SecurityException
| IllegalArgumentException
| InvocationTargetException e) {
throw new RuntimeException(e);
}
}//end function
/**
* 获取handler 类的名称
* @param type
* @param subType
* @return
*/
private String getHandlerClassName(String type , String subType)
{
StringBuffer buffer = new StringBuffer();
buffer.append("com.gzzn.omms.msgexchangeapi.msghandler" );
buffer.append(".");
buffer.append(type);
buffer.append(".");
buffer.append(subType);
buffer.append("Handler");
return buffer.toString();
} //end function
}
@@ -1,4 +1,4 @@
package com.gzzn.omms.msgexchangeapi.service;
package com.gzzn.omms.msgexchangeapi.service.flightInfo;
import java.util.List;
import java.util.Set;
@@ -11,6 +11,7 @@ import com.gzzn.omms.msgexchangeapi.entity.msg.schd.dnld.DnldMsg;
import com.gzzn.omms.msgexchangeapi.entity.msg.schd.dnld.FLTR;
import com.gzzn.omms.msgexchangeapi.msghandler.MsgHandlerDispatcher;
import com.gzzn.omms.msgexchangeapi.redis.RedisService;
import com.gzzn.omms.msgexchangeapi.service.IExchangeService;
@Service
public class FlightInfoServiceImpl implements IFlightInfoService {
@@ -38,17 +39,19 @@ public class FlightInfoServiceImpl implements IFlightInfoService {
.getFltr();
for(FLTR fltr : lsFltr)
{
redisSet(fltr);
}
Boolean result = redisSet(fltr);
if(result == false)
{
return false;
}
}//end for
return true;
} //end function
@Override
public List<FLTR> updateByCminmsgs(List<Cminmsg> lsCminmsgs) {
MsgHandlerDispatcher msgHandlerDispatcher = new MsgHandlerDispatcher();
public List<UpdateByCminmsgsResult> updateByCminmsgs(List<Cminmsg> lsCminmsgs) {
for (Cminmsg cminmsg : lsCminmsgs) {
//更新动态航班消息
String strClobMsg = cminmsg.getCminmsgsClobMsg();
@@ -1,9 +1,8 @@
package com.gzzn.omms.msgexchangeapi.service;
package com.gzzn.omms.msgexchangeapi.service.flightInfo;
import java.util.List;
import com.gzzn.omms.msgexchangeapi.entity.Cminmsg;
import com.gzzn.omms.msgexchangeapi.entity.msg.schd.dnld.FLTR;
public interface IFlightInfoService {
/**
@@ -16,5 +15,5 @@ public interface IFlightInfoService {
* @param lsCminmsgs
* @return 返回被更新了的动态航班信息
*/
public List<FLTR> updateByCminmsgs(List<Cminmsg> lsCminmsgs);
public List<UpdateByCminmsgsResult> updateByCminmsgs(List<Cminmsg> lsCminmsgs);
}
@@ -0,0 +1,12 @@
package com.gzzn.omms.msgexchangeapi.service.flightInfo;
import java.util.List;
import com.gzzn.omms.msgexchangeapi.entity.Cminmsg;
import com.gzzn.omms.msgexchangeapi.entity.msg.schd.dnld.FLTR;
public class UpdateByCminmsgsResult {
Boolean isSuccess;//是否更新成功
Cminmsg cminmsg; //消息
List<FLTR> fltrs; //影响的航班动态信息
}
@@ -15,8 +15,9 @@ import com.gzzn.omms.msgexchangeapi.redis.RedisKeyConstant;
import com.gzzn.omms.msgexchangeapi.redis.RedisService;
import com.gzzn.omms.msgexchangeapi.service.ICminmsgService;
import com.gzzn.omms.msgexchangeapi.service.IExchangeService;
import com.gzzn.omms.msgexchangeapi.service.IFlightInfoService;
import com.gzzn.omms.msgexchangeapi.service.IKafkaService;
import com.gzzn.omms.msgexchangeapi.service.flightInfo.IFlightInfoService;
import com.gzzn.omms.msgexchangeapi.service.flightInfo.UpdateByCminmsgsResult;
/**
@@ -91,16 +92,16 @@ public class ExchangeTask {
//获取航班动态消息
List<Cminmsg> lsCminmsgs = cminmsgService.getNewMsgsAfterId(beginId);
List<FLTR> lsUpdatedFlightInfo = flightInfoService.updateByCminmsgs(lsCminmsgs);
List<UpdateByCminmsgsResult> lsUpdatedFlightInfo = flightInfoService.updateByCminmsgs(lsCminmsgs);
//新增或变更 航班动态信息 发送 到kafka的SCHD topic
for (FLTR flightInfo : lsUpdatedFlightInfo) {
//更新动态航班消息
for (UpdateByCminmsgsResult updateResult : lsUpdatedFlightInfo) {
}
//发送动态消息到kafka
for (Cminmsg cminmsg : lsCminmsgs) {
//更新动态航班消息
}