package nicetime.com.baseutil;

import java.util.Random;

/**
* @author nicetime
* @create 2018-10-14 16:06
*/
public class FlightUtil
{
public static void main(String[] args)
{

//获取航班记录数
// String count="${flightSn_matchNr}";

String count="3";
int flightCount=Integer.valueOf(count);

String unsubscribeUrl=null;

// log.info("aaa");

//确定要循环的次数
int line=0;

//随机删除的航班序号数
int index=0;

//航班序号
String flightSnstr=null;

//航班号信息
String flightKeystr=null;

//航班信息是否存在
boolean hasFlightinfo=false;

if(flightCount!=0)
{
// log.info("bbbb");

line=flightCount;

Random rand =new Random();

//生成0-5之间的整数
index=rand.nextInt(line);

StringBuffer strb=new StringBuffer();

for(int i=0;i<=line;i++)
{
// log.info("ddd");
if(i!=0)
{

String key=null;
String sn=null;

key="flightKey_".concat(String.valueOf(i));
sn="flightKey_".concat(String.valueOf(i));

flightKeystr="${key}";
flightSnstr="${sn}";

strb.append("flightID=").append(flightKeystr).append("&");
strb.append(".cgifields=").append(flightSnstr).append("&");
}
}

strb.append(index).append("=on&removeFlights.x=27&removeFlights.y=5");
unsubscribeUrl=strb.toString();

// log.info("fff");

hasFlightinfo=true;

System.out.println("unsubscribeUrl=\n\r"+unsubscribeUrl);
}

// log.info("gggg");
// vars.put("index",String.valueOf(index));
// vars.put("unsubscribeUrl",unsubscribeUrl);
// log.info("hhh");

}
}