重构提取转历史航班的代码
This commit is contained in:
@@ -2,9 +2,9 @@ package com.gzzn.omms.msgexchangeapi.scheduled;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||||
import org.elasticsearch.index.query.QueryBuilders;
|
import org.elasticsearch.index.query.QueryBuilders;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -14,15 +14,12 @@ import org.springframework.beans.factory.annotation.Value;
|
|||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.StringUtils;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.gzzn.omms.msgexchangeapi.elasticsearch.ElasticsearchUtil;
|
import com.gzzn.omms.msgexchangeapi.elasticsearch.ElasticsearchUtil;
|
||||||
import com.gzzn.omms.msgexchangeapi.entity.msg.DIVERSIONDATA;
|
|
||||||
import com.gzzn.omms.msgexchangeapi.entity.msg.MOVEMENTINDICATOR;
|
|
||||||
import com.gzzn.omms.msgexchangeapi.entity.msg.SCHD.FLTR;
|
import com.gzzn.omms.msgexchangeapi.entity.msg.SCHD.FLTR;
|
||||||
|
import com.gzzn.omms.msgexchangeapi.service.flightInfo.FlightHisServiceImpl;
|
||||||
import com.gzzn.omms.msgexchangeapi.service.flightInfo.IFlightInfoService;
|
import com.gzzn.omms.msgexchangeapi.service.flightInfo.IFlightInfoService;
|
||||||
import com.gzzn.omms.msgexchangeapi.utils.DateTimeUtil;
|
|
||||||
import com.gzzn.omms.msgexchangeapi.utils.JsonUtil;
|
import com.gzzn.omms.msgexchangeapi.utils.JsonUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,28 +34,9 @@ public class FlightHisScheduled {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IFlightInfoService flightInfoService;
|
private IFlightInfoService flightInfoService;
|
||||||
|
|
||||||
/**
|
|
||||||
* 航班到达超过多久则成为历史航班数据(单位:秒)
|
|
||||||
*/
|
|
||||||
@Value("${hstCondition.ARRIVE_HST_TIME}")
|
|
||||||
private Integer ARRIVE_HST_TIME ;
|
|
||||||
/**
|
|
||||||
* 航班取消超过多久则成为历史航班数据(单位:秒)
|
|
||||||
*/
|
|
||||||
@Value("${hstCondition.CANCEL_HST_TIME}")
|
|
||||||
private Integer CANCEL_HST_TIME ;
|
|
||||||
|
|
||||||
/**
|
@Autowired
|
||||||
* 备降超过多久则成为历史航班数据 FROM CTU 本应降落到成都备降到其他地方(单位:秒)
|
private FlightHisServiceImpl flightHisServiceImpl;
|
||||||
*/
|
|
||||||
@Value("${hstCondition.FDIV_HST_TIME}")
|
|
||||||
private Integer FDIV_HST_TIME ;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 计划时间超过多久则成为历史航班数据(单位:秒)
|
|
||||||
*/
|
|
||||||
@Value("${hstCondition.SODT_HST_TIME}")
|
|
||||||
private Integer SODT_HST_TIME ;
|
|
||||||
/**
|
/**
|
||||||
* 历史航班数据索引
|
* 历史航班数据索引
|
||||||
*/
|
*/
|
||||||
@@ -75,107 +53,56 @@ public class FlightHisScheduled {
|
|||||||
@Scheduled(cron = "${scheduled.flightInfoCron}")
|
@Scheduled(cron = "${scheduled.flightInfoCron}")
|
||||||
public void scheduled(){
|
public void scheduled(){
|
||||||
logger.info("开始采集历史数据...");
|
logger.info("开始采集历史数据...");
|
||||||
//1.从redis中获取 当前的动态消息
|
|
||||||
|
|
||||||
List<FLTR> fltrs = flightInfoService.findAll();
|
List<FLTR> fltrs = flightInfoService.findAll();
|
||||||
List<String> fltrIdForHistory = new ArrayList<String>();
|
if( CollectionUtils.isEmpty(fltrs) ){
|
||||||
List<FLTR> fltrsHistory = new ArrayList<FLTR>();
|
return ;
|
||||||
|
|
||||||
//遍历 查找出已经 可以作为历史数据的动态消息
|
|
||||||
//条件为 :完成运营的航班是指已经落地超过2小时或已经起飞的
|
|
||||||
if(null!=fltrs && fltrs.size()>0){
|
|
||||||
for(FLTR fltr : fltrs){
|
|
||||||
String SODT = fltr.getSODT(); //航班计划时间 ddMMMyyHHmm
|
|
||||||
Long SODT_long = DateTimeUtil.toDate(SODT, "ddMMMyyHHmm",Locale.ENGLISH).getTime();
|
|
||||||
/**===================1.计划时间超时的===================**/
|
|
||||||
if((System.currentTimeMillis()-SODT_long)>SODT_HST_TIME){
|
|
||||||
//转为历史数据
|
|
||||||
fltrsHistory.add(fltr);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
/**===================2.航班取消===================**/
|
|
||||||
String CNCL = fltr.getCNCL(); //航班取消时间 ddMMMyyHHmm
|
|
||||||
if(!StringUtils.isEmpty(CNCL)){ //航班被取消
|
|
||||||
Long CNCL_longTime = DateTimeUtil.toDate(CNCL, "ddMMMyyHHmm",Locale.ENGLISH).getTime();
|
|
||||||
if((System.currentTimeMillis()-CNCL_longTime)>CANCEL_HST_TIME){
|
|
||||||
//转为历史数据
|
|
||||||
fltrsHistory.add(fltr);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**===================3.备降===================**/
|
|
||||||
DIVERSIONDATA FDIV = fltr.getFDIV(); //备降信息
|
|
||||||
|
|
||||||
if(null!=FDIV && FDIV.getDDES().equals("CTU") && FDIV.getDDIR().equals("FROM")){ //本应降落到成都机场 备降到其他机场
|
|
||||||
if((System.currentTimeMillis()-SODT_long)>FDIV_HST_TIME){
|
|
||||||
//转为历史数据
|
|
||||||
fltrsHistory.add(fltr);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Long todayMixTime = DateTimeUtil.getTodayStartTime();
|
|
||||||
String ACTT = fltr.getACTT(); //航班实际时间 ddMMMyyHHmm
|
|
||||||
if(!StringUtils.isEmpty(ACTT) && SODT_long<todayMixTime){ //计划时间是今天之前 且 实际时间存在
|
|
||||||
Long ACTT_longTime = DateTimeUtil.toDate(ACTT, "ddMMMyyHHmm",Locale.ENGLISH).getTime();
|
|
||||||
/**===================4.离港航班===================**/
|
|
||||||
if(fltr.getMVIN().equals(MOVEMENTINDICATOR.D)){
|
|
||||||
//实际时间且小于当前时间则为已离港
|
|
||||||
if(ACTT_longTime<=System.currentTimeMillis()){
|
|
||||||
//转为历史数据
|
|
||||||
fltrsHistory.add(fltr);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**===================5.到达航班===================**/
|
|
||||||
if(fltr.getMVIN().equals(MOVEMENTINDICATOR.A)){
|
|
||||||
//到达实际时间超过规定时间的 则视为历史数据
|
|
||||||
if((System.currentTimeMillis()-ACTT_longTime)>ARRIVE_HST_TIME){
|
|
||||||
//转为历史数据
|
|
||||||
fltrsHistory.add(fltr);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//往 elasticsearch中放入历史数据 通过FLID + SODT 判断唯一 (航班ID+计划时间)
|
|
||||||
if(!ElasticsearchUtil.isIndexExist(INDEX_NAME)){
|
|
||||||
ElasticsearchUtil.createIndex(INDEX_NAME);
|
|
||||||
}
|
|
||||||
if(null!=fltrsHistory && fltrsHistory.size()>0){
|
|
||||||
for(FLTR fltr:fltrsHistory){
|
|
||||||
JSONObject jsondata = JSONObject.parseObject(JsonUtil.getString(fltr));
|
|
||||||
//判断是否已经拥有该历史数据 因es类型原因请注意类型转换
|
|
||||||
String SODT = fltr.getSODT();
|
|
||||||
Long FLID = fltr.getFLID().longValue();
|
|
||||||
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery()
|
|
||||||
.must(QueryBuilders.termQuery("SODT",SODT))
|
|
||||||
.must(QueryBuilders.termQuery("FLID",FLID));
|
|
||||||
List<Map<String, Object>> listInEs = ElasticsearchUtil.searchListData(INDEX_NAME, ES_TYPE, boolQuery, null, "FLID", null, null, null);
|
|
||||||
if(null!=listInEs && listInEs.size()>0){
|
|
||||||
//获取es中的id 并更新当前历史数据
|
|
||||||
//唯一 获取第一个
|
|
||||||
Map<String, Object> map = listInEs.get(0);
|
|
||||||
String id = (String) map.get("id");
|
|
||||||
ElasticsearchUtil.updateDataById(jsondata, INDEX_NAME, ES_TYPE, id);
|
|
||||||
fltrIdForHistory.add(fltr.getFLID().toString());
|
|
||||||
}else{
|
|
||||||
//新增历史数据
|
|
||||||
ElasticsearchUtil.addData(jsondata, INDEX_NAME, ES_TYPE);
|
|
||||||
fltrIdForHistory.add(fltr.getFLID().toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//删除redis中已成为历史数据的动态消息
|
|
||||||
if(null!=fltrIdForHistory && fltrIdForHistory.size()>0){
|
|
||||||
flightInfoService.batchDeleteFltr(fltrIdForHistory);
|
|
||||||
logger.info("本次删除转历史动态航班数据:{}条",fltrIdForHistory.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.info("结束采集历史数据。");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<FLTR> fltrsHistory = new ArrayList<FLTR>();
|
||||||
|
fltrsHistory = flightHisServiceImpl.getHisToBeTran(fltrs);
|
||||||
|
if(CollectionUtils.isEmpty(fltrsHistory)){
|
||||||
|
logger.info("没有航班历史需要转换");
|
||||||
|
return ; //没有要转的航班历史
|
||||||
|
}
|
||||||
|
|
||||||
|
//往 elasticsearch中放入历史数据 通过FLID + SODT 判断唯一 (航班ID+计划时间)
|
||||||
|
if(!ElasticsearchUtil.isIndexExist(INDEX_NAME)){
|
||||||
|
ElasticsearchUtil.createIndex(INDEX_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
//航班历史写入ELK
|
||||||
|
List<String> fltrIdForHistory = new ArrayList<String>();
|
||||||
|
for(FLTR fltr:fltrsHistory){
|
||||||
|
JSONObject jsondata = JSONObject.parseObject(JsonUtil.getString(fltr));
|
||||||
|
//判断是否已经拥有该历史数据 因es类型原因请注意类型转换
|
||||||
|
String SODT = fltr.getSODT();
|
||||||
|
Long FLID = fltr.getFLID().longValue();
|
||||||
|
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery()
|
||||||
|
.must(QueryBuilders.termQuery("SODT",SODT))
|
||||||
|
.must(QueryBuilders.termQuery("FLID",FLID));
|
||||||
|
List<Map<String, Object>> listInEs = ElasticsearchUtil.searchListData(INDEX_NAME, ES_TYPE, boolQuery, null, "FLID", null, null, null);
|
||||||
|
if(null!=listInEs && listInEs.size()>0){
|
||||||
|
//获取es中的id 并更新当前历史数据
|
||||||
|
//唯一 获取第一个
|
||||||
|
Map<String, Object> map = listInEs.get(0);
|
||||||
|
String id = (String) map.get("id");
|
||||||
|
ElasticsearchUtil.updateDataById(jsondata, INDEX_NAME, ES_TYPE, id);
|
||||||
|
fltrIdForHistory.add(fltr.getFLID().toString());
|
||||||
|
}else{
|
||||||
|
//新增历史数据
|
||||||
|
ElasticsearchUtil.addData(jsondata, INDEX_NAME, ES_TYPE);
|
||||||
|
fltrIdForHistory.add(fltr.getFLID().toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//删除redis中已成为历史数据的动态消息
|
||||||
|
if(null!=fltrIdForHistory && fltrIdForHistory.size()>0){
|
||||||
|
flightInfoService.batchDeleteFltr(fltrIdForHistory);
|
||||||
|
logger.info("本次删除转历史动态航班数据:{}条",fltrIdForHistory.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.info("结束采集历史数据。");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+215
@@ -0,0 +1,215 @@
|
|||||||
|
package com.gzzn.omms.msgexchangeapi.service.flightInfo;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import com.gzzn.omms.msgexchangeapi.entity.msg.DIVERSIONDATA;
|
||||||
|
import com.gzzn.omms.msgexchangeapi.entity.msg.MOVEMENTINDICATOR;
|
||||||
|
import com.gzzn.omms.msgexchangeapi.entity.msg.SCHD.FLTR;
|
||||||
|
import com.gzzn.omms.msgexchangeapi.utils.DateTimeUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 航班历史服务
|
||||||
|
* @author zhouxiunai
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class FlightHisServiceImpl {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 航班到达超过多久则成为历史航班数据(单位:秒)
|
||||||
|
*/
|
||||||
|
@Value("${hstCondition.ARRIVE_HST_TIME}")
|
||||||
|
private Integer ARRIVE_HST_TIME ;
|
||||||
|
/**
|
||||||
|
* 航班取消超过多久则成为历史航班数据(单位:秒)
|
||||||
|
*/
|
||||||
|
@Value("${hstCondition.CANCEL_HST_TIME}")
|
||||||
|
private Integer CANCEL_HST_TIME ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备降超过多久则成为历史航班数据 FROM CTU 本应降落到成都备降到其他地方(单位:秒)
|
||||||
|
*/
|
||||||
|
@Value("${hstCondition.FDIV_HST_TIME}")
|
||||||
|
private Integer FDIV_HST_TIME ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计划时间超过多久则成为历史航班数据(单位:秒)
|
||||||
|
*/
|
||||||
|
@Value("${hstCondition.SODT_HST_TIME}")
|
||||||
|
private Integer SODT_HST_TIME ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取可以进行转历史操作的航班
|
||||||
|
* 遍历 查找出已经 可以作为历史数据的动态消息
|
||||||
|
* 条件为 :完成运营的航班是指已经落地超过2小时或已经起飞的
|
||||||
|
* @param fltrs
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<FLTR> getHisToBeTran(List<FLTR> fltrs)
|
||||||
|
{
|
||||||
|
List<FLTR> fltrsHistory = new ArrayList<FLTR>();
|
||||||
|
|
||||||
|
if(CollectionUtils.isEmpty(fltrs)){
|
||||||
|
return fltrsHistory;
|
||||||
|
} //end if
|
||||||
|
|
||||||
|
|
||||||
|
for(FLTR fltr : fltrs){
|
||||||
|
if(isSODTMatch(fltr))
|
||||||
|
{
|
||||||
|
fltrsHistory.add(fltr);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isCNCLMatch(fltr))
|
||||||
|
{
|
||||||
|
fltrsHistory.add(fltr);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isFDIVMatch(fltr))
|
||||||
|
{
|
||||||
|
fltrsHistory.add(fltr);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isDMatch(fltr))
|
||||||
|
{
|
||||||
|
fltrsHistory.add(fltr);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isAMatch(fltr))
|
||||||
|
{
|
||||||
|
fltrsHistory.add(fltr);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} //end for
|
||||||
|
|
||||||
|
return fltrsHistory;
|
||||||
|
} //end function
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计划时间是否满足转历史要求
|
||||||
|
* @param fltr 动态航班信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private boolean isSODTMatch(FLTR fltr)
|
||||||
|
{
|
||||||
|
String SODT = fltr.getSODT(); //航班计划时间 ddMMMyyHHmm
|
||||||
|
Long SODT_long = DateTimeUtil.toDate(SODT, "ddMMMyyHHmm",Locale.ENGLISH).getTime();
|
||||||
|
|
||||||
|
/**===================1.计划时间超时的===================**/
|
||||||
|
if((System.currentTimeMillis()-SODT_long)>SODT_HST_TIME){
|
||||||
|
//转为历史数据
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 已取消的航班是否满足转历史要求
|
||||||
|
* @param fltr
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private boolean isCNCLMatch(FLTR fltr)
|
||||||
|
{
|
||||||
|
/**===================2.航班取消===================**/
|
||||||
|
String CNCL = fltr.getCNCL(); //航班取消时间 ddMMMyyHHmm
|
||||||
|
if(!StringUtils.isEmpty(CNCL)){ //航班被取消
|
||||||
|
Long CNCL_longTime = DateTimeUtil.toDate(CNCL, "ddMMMyyHHmm",Locale.ENGLISH).getTime();
|
||||||
|
if((System.currentTimeMillis()-CNCL_longTime)>CANCEL_HST_TIME){
|
||||||
|
//转为历史数据
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备降航班是否满足转历史要求
|
||||||
|
* @param fltr
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private boolean isFDIVMatch(FLTR fltr)
|
||||||
|
{
|
||||||
|
String SODT = fltr.getSODT(); //航班计划时间 ddMMMyyHHmm
|
||||||
|
Long SODT_long = DateTimeUtil.toDate(SODT, "ddMMMyyHHmm",Locale.ENGLISH).getTime();
|
||||||
|
|
||||||
|
/**===================3.备降===================**/
|
||||||
|
DIVERSIONDATA FDIV = fltr.getFDIV(); //备降信息
|
||||||
|
|
||||||
|
if(null!=FDIV && FDIV.getDDES().equals("CTU") && FDIV.getDDIR().equals("FROM")){ //本应降落到成都机场 备降到其他机场
|
||||||
|
if((System.currentTimeMillis() - SODT_long)>FDIV_HST_TIME){
|
||||||
|
//转为历史数据
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 离港航班是否满足转历史要求
|
||||||
|
* @param fltr
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private boolean isDMatch(FLTR fltr)
|
||||||
|
{
|
||||||
|
String SODT = fltr.getSODT(); //航班计划时间 ddMMMyyHHmm
|
||||||
|
Long SODT_long = DateTimeUtil.toDate(SODT, "ddMMMyyHHmm",Locale.ENGLISH).getTime();
|
||||||
|
|
||||||
|
Long todayMixTime = DateTimeUtil.getTodayStartTime();
|
||||||
|
String ACTT = fltr.getACTT(); //航班实际时间 ddMMMyyHHmm
|
||||||
|
if(!StringUtils.isEmpty(ACTT) && SODT_long<todayMixTime){ //计划时间是今天之前 且 实际时间存在
|
||||||
|
Long ACTT_longTime = DateTimeUtil.toDate(ACTT, "ddMMMyyHHmm",Locale.ENGLISH).getTime();
|
||||||
|
/**===================4.离港航班===================**/
|
||||||
|
if(fltr.getMVIN().equals(MOVEMENTINDICATOR.D)){
|
||||||
|
//实际时间且小于当前时间则为已离港
|
||||||
|
if(ACTT_longTime<=System.currentTimeMillis()){
|
||||||
|
//转为历史数据
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 到港航班是否满足转历史要求
|
||||||
|
* @param fltr
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private boolean isAMatch(FLTR fltr)
|
||||||
|
{
|
||||||
|
String SODT = fltr.getSODT(); //航班计划时间 ddMMMyyHHmm
|
||||||
|
Long SODT_long = DateTimeUtil.toDate(SODT, "ddMMMyyHHmm",Locale.ENGLISH).getTime();
|
||||||
|
|
||||||
|
Long todayMixTime = DateTimeUtil.getTodayStartTime();
|
||||||
|
String ACTT = fltr.getACTT(); //航班实际时间 ddMMMyyHHmm
|
||||||
|
if(!StringUtils.isEmpty(ACTT) && SODT_long<todayMixTime){ //计划时间是今天之前 且 实际时间存在
|
||||||
|
Long ACTT_longTime = DateTimeUtil.toDate(ACTT, "ddMMMyyHHmm",Locale.ENGLISH).getTime();
|
||||||
|
|
||||||
|
/**===================5.到达航班===================**/
|
||||||
|
if(fltr.getMVIN().equals(MOVEMENTINDICATOR.A)){
|
||||||
|
//到达实际时间超过规定时间的 则视为历史数据
|
||||||
|
if((System.currentTimeMillis()-ACTT_longTime)>ARRIVE_HST_TIME){
|
||||||
|
//转为历史数据
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} //end class
|
||||||
@@ -18,6 +18,6 @@ public class RedisServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
public void removeFlightInfo()
|
public void removeFlightInfo()
|
||||||
{
|
{
|
||||||
redisService.del(Arrays.asList("flightInfo:"));
|
redisService.del(Arrays.asList("flightInfo"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package com.gzzn.omms.msgexchangeapi.service;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.kafka.core.KafkaTemplate;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest
|
||||||
|
public class KafkaServiceImplTest {
|
||||||
|
@Autowired
|
||||||
|
private KafkaTemplate kafkaTemplate;
|
||||||
|
|
||||||
|
/***
|
||||||
|
* @param n 字符串长度
|
||||||
|
* @return 返回n长度的随机字符串
|
||||||
|
***/
|
||||||
|
private String randomString(Integer n) {
|
||||||
|
String str = "abcdefghijklmnopqrstuvwxyz9876543210";
|
||||||
|
|
||||||
|
StringBuffer tmp = new StringBuffer();
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
int beginIndex = (int) Math.floor(Math.random() * str.length());
|
||||||
|
String randomStr = str.substring(beginIndex, beginIndex + 1);
|
||||||
|
tmp.append(randomStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return tmp.toString();
|
||||||
|
} //end funciont
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void msgSendTest() {
|
||||||
|
String topic = "schd";
|
||||||
|
String msg = randomString(4*1024*1024);
|
||||||
|
|
||||||
|
|
||||||
|
kafkaTemplate.send(topic, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user