提交整体消息转换分发处理框架

This commit is contained in:
zhouxiunai
2018-12-03 10:44:14 +08:00
parent 48d37b2bf7
commit 021de12235
9 changed files with 267 additions and 51 deletions
@@ -3,19 +3,23 @@ package com.gzzn.omms.msgexchangeapi.service;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.gzzn.omms.msgexchangeapi.domain.primary.dao.CminmsgDao;
import com.gzzn.omms.msgexchangeapi.domain.primary.entity.Cminmsg;
import com.gzzn.omms.msgexchangeapi.domain.primary.entity.msg.Msg;
@Service
public class CminmsgServiceImpl implements ICminmsgService {
@Autowired
private CminmsgDao cminmsgDao;
@Autowired
IExchangeService exchangeService;
@Override
public Cminmsg sendXmlMsg(String xmlMsg) {
Cminmsg cminmsg = new Cminmsg();
@@ -49,4 +53,21 @@ public class CminmsgServiceImpl implements ICminmsgService {
return lsCminmsgs;
}
@Override
public Optional<Cminmsg> getRespSchdCminmsg(Date date) {
List<Cminmsg> lsCminmsgs = getNewMsgsAfterDate(date);
Optional<Cminmsg> opCminmsg = lsCminmsgs
.stream()
.filter(x->{
String msgBlob = x.getCminmsgsClobMsg();
Msg msg = exchangeService.xmlstrToObject(msgBlob, Msg.class);
String type = msg.getMeta().getType();
String subType = msg.getMeta().getStyp();
return type.equals("SCHD") && subType.equals("RESP");
})
.findFirst();
return opCminmsg;
}//end function
}
@@ -0,0 +1,61 @@
package com.gzzn.omms.msgexchangeapi.service;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import com.gzzn.omms.msgexchangeapi.domain.primary.entity.Cminmsg;
import com.gzzn.omms.msgexchangeapi.domain.primary.entity.msg.Msg;
import com.gzzn.omms.msgexchangeapi.domain.primary.entity.msg.schd.dnld.DnldMsg;
import com.gzzn.omms.msgexchangeapi.domain.secondary.dao.FlightInfoDao;
import com.gzzn.omms.msgexchangeapi.domain.secondary.entity.FlightInfo;
import com.gzzn.omms.msgexchangeapi.msghandler.MsgHandlerDispatcher;
import com.gzzn.omms.msgexchangeapi.utils.JsonUtil;
public class FlightInfoServiceImpl implements IFlightInfoService {
@Autowired
private FlightInfoDao flightInfoDao;
@Autowired
IExchangeService exchangeService;
@Autowired
MsgHandlerDispatcher msgHandlerDispatcher;
@Override
public Boolean updateByDaySchd(Cminmsg cminmsg) {
String clobMsg = cminmsg.getCminmsgsClobMsg();
DnldMsg dnldMsg = exchangeService.xmlstrToObject(clobMsg, DnldMsg.class);
List<FlightInfo> flightSchdInfo = dnldMsg
.getSchd()
.getFltr()
.stream()
.map(x->{
FlightInfo node = new FlightInfo();
node.setFlightId(x.getFlid());
node.setContext(JsonUtil.getString(x));
return node;
}).collect(Collectors.toList());
List<FlightInfo> flightInfos = (List<FlightInfo>) flightInfoDao.save(flightSchdInfo);
return flightInfos != null;
} //end function
@Override
public List<FlightInfo> updateByCminmsgs(List<Cminmsg> lsCminmsgs) {
MsgHandlerDispatcher msgHandlerDispatcher = new MsgHandlerDispatcher();
for (Cminmsg cminmsg : lsCminmsgs) {
//更新动态航班消息
String strClobMsg = cminmsg.getCminmsgsClobMsg();
msgHandlerDispatcher.dispatch(strClobMsg);
}
return null;
}//end function
}
@@ -2,6 +2,7 @@ package com.gzzn.omms.msgexchangeapi.service;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import com.gzzn.omms.msgexchangeapi.domain.primary.entity.Cminmsg;
@@ -14,6 +15,14 @@ public interface ICminmsgService {
*/
public Cminmsg sendXmlMsg(String xmlMsg);
/**
* 获取回复的航班计划信息
* @param date
* @return
*/
public Optional<Cminmsg> getRespSchdCminmsg(Date date);
/**
* 获取指定时间后的新消息
* @return
@@ -0,0 +1,20 @@
package com.gzzn.omms.msgexchangeapi.service;
import java.util.List;
import com.gzzn.omms.msgexchangeapi.domain.primary.entity.Cminmsg;
import com.gzzn.omms.msgexchangeapi.domain.secondary.entity.FlightInfo;
public interface IFlightInfoService {
/**
* 同步日计划更新航班信息
*/
public Boolean updateByDaySchd(Cminmsg cminmsg);
/**
* 根据消息更新航班信息
* @param lsCminmsgs
* @return 返回被更新了的动态航班信息
*/
public List<FlightInfo> updateByCminmsgs(List<Cminmsg> lsCminmsgs);
}