日航班计划下载事件处理

This commit is contained in:
zhouxiunai
2018-12-11 11:59:07 +08:00
parent edc63516dc
commit cd209ee926
3 changed files with 98 additions and 0 deletions
@@ -22,6 +22,14 @@ public class HandlerResult {
this.fltrs = fltrs;
}
public static HandlerResult success()
{
HandlerResult handlerResult = new HandlerResult();
handlerResult.isSuccess = true;
return handlerResult;
}//end function
public static HandlerResult success(SCHD.FLTR fltr)
{
@@ -0,0 +1,32 @@
package com.gzzn.omms.msgexchangeapi.msghandler.schd;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.gzzn.omms.msgexchangeapi.entity.Cminmsg;
import com.gzzn.omms.msgexchangeapi.msghandler.HandlerResult;
import com.gzzn.omms.msgexchangeapi.msghandler.schd.base.SchdBaseHandler;
/**
* 航班计划下载事件 download
* @author zhouxiunai
*
*/
public class DNLDHandler extends SchdBaseHandler{
private static Logger logger = LoggerFactory.getLogger(DNLDHandler.class);
@Override
public HandlerResult run(Cminmsg cminmsg) {
Boolean updateResult = flightInfoService.updateByDaySchd(cminmsg);
if(false == updateResult)
{
//航班计划更新失败
logger.error("航班计划更新失败");
return HandlerResult.failure();
}
//日航班计划第二天的,不需要通知前端
this.updateCminmsgToProcessed(cminmsg);
return HandlerResult.success();
} //end function
}
@@ -0,0 +1,58 @@
package com.gzzn.omms.msgexchangeapi.msghandler.schd.base;
import java.util.Arrays;
import com.gzzn.omms.msgexchangeapi.entity.Cminmsg;
import com.gzzn.omms.msgexchangeapi.msghandler.HandlerResult;
import com.gzzn.omms.msgexchangeapi.msghandler.IBaseHandler;
import com.gzzn.omms.msgexchangeapi.service.ICminmsgService;
import com.gzzn.omms.msgexchangeapi.service.IKafkaService;
import com.gzzn.omms.msgexchangeapi.service.exchange.IExchangeService;
import com.gzzn.omms.msgexchangeapi.service.flightInfo.IFlightInfoService;
import com.gzzn.omms.msgexchangeapi.utils.SpringUtil;
/**
* Schd 计划消息处理基类
* @author zhouxiunai
*
*/
public class SchdBaseHandler implements IBaseHandler{
protected IExchangeService exchangeService;
protected IFlightInfoService flightInfoService;
protected IKafkaService kafkaservice;
protected ICminmsgService cminmsgService;
public SchdBaseHandler()
{
exchangeService = (IExchangeService) SpringUtil.getBean("exchangeService");
flightInfoService = (IFlightInfoService) SpringUtil.getBean("flightInfoService");
}
@Override
public HandlerResult run(Cminmsg cminmsg) {
return null;
}
/**
* 仅发送动态消息
* @param cminmsg
*/
protected void sendMsg(Cminmsg cminmsg)
{
//send msg
String msg = exchangeService.xmlstrToJson(
cminmsg.getCminmsgsClobMsg()
);
kafkaservice.msgSend("msg", msg);
}
/**
* 更新Cminmsg状态为已处理
* @param cminmsg
*/
protected void updateCminmsgToProcessed(Cminmsg cminmsg)
{
cminmsgService.updateBatchProcessed(Arrays.asList(cminmsg));
}
}