63 lines
2.0 KiB
Java
63 lines
2.0 KiB
Java
package com.gzzn.omms.msgexchangeapi.service;
|
|
|
|
import java.util.List;
|
|
import java.util.stream.Collectors;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import com.gzzn.omms.msgexchangeapi.entity.Cminmsg;
|
|
import com.gzzn.omms.msgexchangeapi.entity.msg.schd.dnld.DnldMsg;
|
|
import com.gzzn.omms.msgexchangeapi.msghandler.MsgHandlerDispatcher;
|
|
import com.gzzn.omms.msgexchangeapi.redis.dao.FlightInfoDao;
|
|
import com.gzzn.omms.msgexchangeapi.redis.entity.FlightInfo;
|
|
import com.gzzn.omms.msgexchangeapi.utils.JsonUtil;
|
|
|
|
@Service
|
|
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
|
|
}
|