1.增加FltrEsDto在存入es的时候,对ABN字段的body格式化成字符串存储。2.修复转航班历史失败依然删除了redis上的航班记录导致航班丢失的问题。
This commit is contained in:
+19
-4
@@ -9,12 +9,15 @@ import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.gzzn.omms.msgexchangeapi.dto.msg.FltrEsDto;
|
||||
import com.gzzn.omms.msgexchangeapi.dto.msg.convert.FltrConvert;
|
||||
import com.gzzn.omms.msgexchangeapi.elasticsearch.ElasticsearchUtil;
|
||||
import com.gzzn.omms.msgexchangeapi.entity.msg.DIVERSIONDATA;
|
||||
import com.gzzn.omms.msgexchangeapi.entity.msg.MOVEMENTINDICATOR;
|
||||
@@ -22,6 +25,7 @@ import com.gzzn.omms.msgexchangeapi.entity.msg.SCHD.FLTR;
|
||||
import com.gzzn.omms.msgexchangeapi.utils.DateTimeUtil;
|
||||
import com.gzzn.omms.msgexchangeapi.utils.JsonUtil;
|
||||
|
||||
|
||||
/**
|
||||
* 航班历史服务
|
||||
* @author zhouxiunai
|
||||
@@ -54,6 +58,9 @@ public class FlightHisServiceImpl {
|
||||
@Value("${hstCondition.SODT_HST_TIME}")
|
||||
private Integer SODT_HST_TIME ;
|
||||
|
||||
@Autowired
|
||||
FltrConvert fltrConvert;
|
||||
|
||||
|
||||
/**
|
||||
* 历史航班数据索引
|
||||
@@ -119,13 +126,19 @@ public class FlightHisServiceImpl {
|
||||
/**
|
||||
* 保存航班历史到ELK
|
||||
* @param fltrs
|
||||
* @return
|
||||
* @return 成功保存的航班动态
|
||||
*/
|
||||
public boolean save(List<FLTR> fltrs)
|
||||
public List<FLTR> save(List<FLTR> fltrs)
|
||||
{
|
||||
List<FLTR> fltrSaveSuccess = new ArrayList<FLTR>(); //成功转历史的航班列表信息
|
||||
|
||||
for(FLTR fltr : fltrs){
|
||||
try {
|
||||
JSONObject jsondata = JSONObject.parseObject(JsonUtil.getString(fltr));
|
||||
//先转换航班信息为可存储到es 中的fltr dto 对象
|
||||
FltrEsDto fltrEsDto = fltrConvert.FltrToFltrEsDto(fltr);
|
||||
|
||||
|
||||
JSONObject jsondata = JSONObject.parseObject(JsonUtil.getString(fltrEsDto));
|
||||
//判断是否已经拥有该历史数据 因es类型原因请注意类型转换
|
||||
String SODT = fltr.getSODT();
|
||||
Long FLID = fltr.getFLID().longValue();
|
||||
@@ -143,11 +156,13 @@ public class FlightHisServiceImpl {
|
||||
//新增
|
||||
ElasticsearchUtil.addData(jsondata, INDEX_NAME, ES_TYPE);
|
||||
}
|
||||
|
||||
fltrSaveSuccess.add(fltr);
|
||||
} catch (Exception e) {
|
||||
logger.error("插入或更新动态航班历史错误:{}",e.getMessage());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return fltrSaveSuccess;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user