完善登机门事件:1. 清空登机门事件处理 2. 添加旧登机门到lgtdt字段
This commit is contained in:
@@ -1,8 +1,13 @@
|
|||||||
package com.gzzn.omms.msgexchangeapi.msghandler.flop;
|
package com.gzzn.omms.msgexchangeapi.msghandler.flop;
|
||||||
|
|
||||||
|
import java.math.BigInteger;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import com.gzzn.omms.msgexchangeapi.entity.msg.FLOP;
|
import com.gzzn.omms.msgexchangeapi.entity.msg.FLOP;
|
||||||
import com.gzzn.omms.msgexchangeapi.entity.msg.GATEDATA;
|
import com.gzzn.omms.msgexchangeapi.entity.msg.GATEDATA;
|
||||||
@@ -22,14 +27,120 @@ public class GTDTHandler extends FlopBaseHandler {
|
|||||||
@Override
|
@Override
|
||||||
protected SCHD.FLTR updateFltr(FLOP flop,SCHD.FLTR fltr)
|
protected SCHD.FLTR updateFltr(FLOP flop,SCHD.FLTR fltr)
|
||||||
{
|
{
|
||||||
|
//相同直接返回
|
||||||
|
if(isTheSameGtdt(fltr.getGTDT(),flop.getGTDT()))
|
||||||
|
{
|
||||||
|
return fltr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//先保存当前航班机位数据
|
||||||
|
if(!CollectionUtils.isEmpty(fltr.getGTDT()))
|
||||||
|
{
|
||||||
|
fltr.setLgtdt(getGtdtAsStr(fltr.getGTDT()));
|
||||||
|
}
|
||||||
|
|
||||||
fltr.getGTDT().clear(); //清空旧数据
|
fltr.getGTDT().clear(); //清空旧数据
|
||||||
|
|
||||||
|
//清空登机门事件,直接返回
|
||||||
|
if (isClearGtdtMsg(flop.getGTDT())) {
|
||||||
|
return fltr;
|
||||||
|
}
|
||||||
|
|
||||||
|
//更新登记门信息
|
||||||
for(OPTGATEDATA optgatedata : flop.getGTDT() )
|
for(OPTGATEDATA optgatedata : flop.getGTDT() )
|
||||||
{
|
{
|
||||||
GATEDATA gatedata = new GATEDATA();
|
GATEDATA gatedata = new GATEDATA();
|
||||||
BeanUtils.copyProperties(optgatedata, gatedata);
|
BeanUtils.copyProperties(optgatedata, gatedata);
|
||||||
|
|
||||||
fltr.getGTDT().add(gatedata);
|
fltr.getGTDT().add(gatedata);
|
||||||
} //添加新数据
|
}
|
||||||
return fltr;
|
return fltr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断当前的登机门信息和要设置的登记门信息是否一致
|
||||||
|
* @param lsGatedata 当前登记门信息
|
||||||
|
* @param lsOptgatedata 要设置成的登记门信息
|
||||||
|
* @return true ,false
|
||||||
|
*/
|
||||||
|
private Boolean isTheSameGtdt(List<GATEDATA> lsGatedata,List<OPTGATEDATA> lsOptgatedata)
|
||||||
|
{
|
||||||
|
//特殊处理清空航班事件
|
||||||
|
if(
|
||||||
|
isClearGtdtMsg(lsOptgatedata)
|
||||||
|
&&
|
||||||
|
CollectionUtils.isEmpty(lsGatedata)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return true;//当前为清除机位信息,同时当前登机门信息为空
|
||||||
|
}
|
||||||
|
|
||||||
|
//不相等,必然不同
|
||||||
|
if (lsGatedata.size() != lsOptgatedata.size()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//生成序列比较是否相等
|
||||||
|
lsGatedata.sort((node1,node2)-> node1.getGATE().compareTo(node2.getGATE()));
|
||||||
|
lsOptgatedata.sort((node1,node2)-> node1.getGATE().compareTo(node2.getGATE()));
|
||||||
|
|
||||||
|
|
||||||
|
StringBuilder strGtdt = new StringBuilder();
|
||||||
|
lsGatedata.forEach(node->{
|
||||||
|
strGtdt.append(node.getGATE());
|
||||||
|
strGtdt.append(",");
|
||||||
|
});
|
||||||
|
|
||||||
|
StringBuilder strOptGtdt = new StringBuilder();
|
||||||
|
lsOptgatedata.forEach(node->{
|
||||||
|
strOptGtdt.append(node.getGATE());
|
||||||
|
strOptGtdt.append(",");
|
||||||
|
});
|
||||||
|
|
||||||
|
return strGtdt.toString().equals(strOptGtdt.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否清空登机门事件,内容为空的情况,<GTDT GTNO = "0"></GTDT>
|
||||||
|
* @param lsOptgatedata 登机门数据列表
|
||||||
|
* @return true 清空登机门事件 ,false 非清空登机门事件
|
||||||
|
*/
|
||||||
|
private Boolean isClearGtdtMsg(List<OPTGATEDATA> lsOptgatedata)
|
||||||
|
{
|
||||||
|
return (
|
||||||
|
lsOptgatedata.size() == 1
|
||||||
|
&& lsOptgatedata.get(0).getGTNO().equals(new BigInteger("0"))
|
||||||
|
&& StringUtils.isEmpty(lsOptgatedata.get(0).getGATE())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将机位信息列表,组织成逗号分隔的字符串
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private String getGtdtAsStr(List<GATEDATA> lsGatedata)
|
||||||
|
{
|
||||||
|
if(CollectionUtils.isEmpty(lsGatedata))
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//先保存当前航班机位数据
|
||||||
|
StringBuilder lgtdt= new StringBuilder();
|
||||||
|
for(GATEDATA node : lsGatedata)
|
||||||
|
{
|
||||||
|
lgtdt.append(node.getGATE());
|
||||||
|
lgtdt.append(",");
|
||||||
|
}
|
||||||
|
if(lgtdt.toString().endsWith(","))
|
||||||
|
{
|
||||||
|
lgtdt.deleteCharAt(lgtdt.length()-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return lgtdt.toString();
|
||||||
|
}//end function
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user