Files
msgexchange-api/src/main/java/com/gzzn/omms/msgexchangeapi/service/FlightInfoServiceImpl.java
T

63 lines
2.0 KiB
Java
Raw Normal View History

2018-12-03 10:44:14 +08:00
package com.gzzn.omms.msgexchangeapi.service;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
2018-12-03 11:43:03 +08:00
import org.springframework.stereotype.Service;
2018-12-03 10:44:14 +08:00
import com.gzzn.omms.msgexchangeapi.entity.Cminmsg;
import com.gzzn.omms.msgexchangeapi.entity.msg.schd.dnld.DnldMsg;
2018-12-03 10:44:14 +08:00
import com.gzzn.omms.msgexchangeapi.msghandler.MsgHandlerDispatcher;
import com.gzzn.omms.msgexchangeapi.redis.dao.FlightInfoDao;
import com.gzzn.omms.msgexchangeapi.redis.entity.FlightInfo;
2018-12-03 10:44:14 +08:00
import com.gzzn.omms.msgexchangeapi.utils.JsonUtil;
2018-12-03 11:43:03 +08:00
@Service
2018-12-03 10:44:14 +08:00
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
}