更新历史数据接口文档

This commit is contained in:
fanghongchao
2018-12-03 15:21:49 +08:00
parent 50ac2dce85
commit 610dbbb8a5
7 changed files with 241 additions and 201 deletions
@@ -1,15 +0,0 @@
package com.gzzn.omms.adminapi.config;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
@Configuration
public class MySpringBootConfig {
@Bean
public RestTemplate restTemplate(RestTemplateBuilder builder) {
// Do any additional configuration here
return builder.build();
}
}
@@ -0,0 +1,23 @@
package com.gzzn.omms.adminapi.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
@Configuration
public class RestTemplateConfig {
@Bean
public RestTemplate restTemplate(ClientHttpRequestFactory factory){
return new RestTemplate(factory);
}
@Bean
public ClientHttpRequestFactory simpleClientHttpRequestFactory(){
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
factory.setReadTimeout(5000);//单位为ms
factory.setConnectTimeout(5000);//单位为ms
return factory;
}
}
@@ -2,14 +2,18 @@ package com.gzzn.omms.adminapi.controller.history;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.gzzn.omms.adminapi.dto.PageInfoDto;
import com.gzzn.omms.adminapi.dto.ResponseDto; import com.gzzn.omms.adminapi.dto.ResponseDto;
import com.gzzn.omms.adminapi.dto.history.HistoryFilghtConditionDto; import com.gzzn.omms.adminapi.dto.history.HistoryFilghtConditionDto;
import com.gzzn.omms.adminapi.dto.history.HistoryFilghtDataDto; import com.gzzn.omms.adminapi.elasticsearch.ElasticsearchUtil;
import com.gzzn.omms.adminapi.elasticsearch.EsPage;
import com.gzzn.omms.adminapi.utils.DateUtils;
/** /**
* 历史航班数据 controller * 历史航班数据 controller
* @author fhc * @author fhc
@@ -19,13 +23,38 @@ import com.gzzn.omms.adminapi.dto.history.HistoryFilghtDataDto;
@RestController @RestController
public class HistoryFlightDataController { public class HistoryFlightDataController {
/**
* 操作日志索引
*/
private final String INDEX_NAME = "airplant_hst";
/**
* 操作日志类型
*/
private final String OPLOG_ES_TYPE = "_doc";
@ApiOperation(value="获取历史航班数据",tags="历史航班数据") @ApiOperation(value="获取历史航班数据",tags="历史航班数据")
@PostMapping(value="/hitFlightData/list") @PostMapping(value="/hitFlightData/list")
public ResponseDto<PageInfoDto<HistoryFilghtDataDto>> findAllByGroupCode(@RequestBody HistoryFilghtConditionDto conditions) { public ResponseDto<EsPage> findAllByGroupCode(@RequestBody HistoryFilghtConditionDto conditions) {
PageInfoDto<HistoryFilghtDataDto> page = new PageInfoDto<HistoryFilghtDataDto>(); //TODO 修改 ElasticsearchUtil 进行分页查询
//TODO 利用 ElasticsearchUtil 进行分页查询 Integer pageIndex = StringUtils.isEmpty(conditions.getPageIndex())?1:conditions.getPageIndex();
Integer pageSize = StringUtils.isEmpty(conditions.getPageSize())?10:conditions.getPageSize();
Long startTimeL = StringUtils.isEmpty(conditions.getStartTime())?DateUtils.getTodayStartTime():DateUtils.dateToStamp(conditions.getStartTime()+" 00:00:00","yyyy-MM-dd HH:mm:ss");
Long endTimeL = StringUtils.isEmpty(conditions.getEndTime())?System.currentTimeMillis():DateUtils.dateToStamp(conditions.getEndTime()+" 23:59:59","yyyy-MM-dd HH:mm:ss");
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
boolQuery.must(QueryBuilders.rangeQuery("log_datetime")
.gt(startTimeL).lt(endTimeL)
.includeLower(true).includeUpper(true));
// if(!StringUtils.isEmpty(keyword)){ //使用模糊搜索 不使用分词
// boolQuery.must(QueryBuilders.boolQuery()
// .should(QueryBuilders.wildcardQuery("summary", "*"+keyword+"*"))
// .should(QueryBuilders.wildcardQuery("real_name", "*"+keyword+"*"))
// .should(QueryBuilders.wildcardQuery("log_content", "*"+keyword+"*")));
// }
EsPage page = ElasticsearchUtil.searchDataPage(INDEX_NAME, OPLOG_ES_TYPE, pageIndex, pageSize, boolQuery, null, null, null);
return ResponseDto.success(page); return ResponseDto.success(page);
} }
} }
@@ -11,155 +11,136 @@ import io.swagger.annotations.ApiModelProperty;
*/ */
@ApiModel(value="历史航班数据条件Dto",description="查询历史航班数据的条件DTO") @ApiModel(value="历史航班数据条件Dto",description="查询历史航班数据的条件DTO")
public class HistoryFilghtConditionDto { public class HistoryFilghtConditionDto {
//TODO 更改字段名
@ApiModelProperty(value="航空公司",example="广东航空") @ApiModelProperty(value="当前页,默认从1开始",example="1")
private String filed_1; private Integer pageIndex;
@ApiModelProperty(value="每页大小,默认10",example="10")
private Integer pageSize;
@ApiModelProperty(value="航空公司_id",example="147576845")
private String airlineId;
@ApiModelProperty(value="航空公司_名",example="长龙航空有限公司")
private String airlineName;
@ApiModelProperty(value="航线类别",example="航线类别类别,I-国际、D-国内、M-混合") @ApiModelProperty(value="航线类别",example="航线类别类别,I-国际、D-国内、M-混合")
private String filed_2; private String routeType;
@ApiModelProperty(value="航班任务",example="航班任务A") @ApiModelProperty(value="航班任务",example="航班任务:S=正班、N=包机、E=急救、B=专机、G=通用、J=加班、M=军用、Q=补班、X=其他、A=计划外(原参考分类:正班、加班、补班、中转、计划外、计划外中转、货运、训练...)")
private String filed_3; private String flightTask;
@ApiModelProperty(value="计划出发时间",example="计划出发时间")
private String filed_4;
@ApiModelProperty(value="计划到达时间",example="计划到达时间")
private String filed_5;
@ApiModelProperty(value="预计出发时间",example="预计出发时间")
private String filed_6;
@ApiModelProperty(value="预计到达时间",example="预计到达时间")
private String filed_7;
@ApiModelProperty(value="实际出发时间",example="实际出发时间")
private String filed_8;
@ApiModelProperty(value="实际到达时间",example="实际到达时间")
private String filed_9;
@ApiModelProperty(value="出发/到达",example="到达/出发(进港/出港)标志,A-到达、D-出发")
private String arriOrDept;
@ApiModelProperty(value="航班代理",example="航班代理") @ApiModelProperty(value="航班代理",example="航班代理")
private String filed_10; private String flightAgentId;
@ApiModelProperty(value="开始时间",example="开始时间") @ApiModelProperty(value="开始时间",example="开始时间(yyyy-mm-dd)")
private String filed_11; private String startTime;
@ApiModelProperty(value="结束时间",example="结束时间") @ApiModelProperty(value="结束时间",example="结束时间(yyyy-mm-dd)")
private String filed_12; private String endTime;
@ApiModelProperty(value="航班异常状态",example="航班异常状态,1-正常、2-检修") @ApiModelProperty(value="航班异常状态",example="是否故障(0-否 1-是)")
private String filed_13; private String isAbnormal;
@ApiModelProperty(value="是否查询航班关联信息",example="是否查询航班关联信息,Y-是、N-否") @ApiModelProperty(value="是否查询航班关联信息",example="是否查询航班关联信息,Y-是、N-否")
private String filed_14; private String ifShowtRelation;
@ApiModelProperty(value="是否查询详细信息",example="是否查询详细信息,Y-是、N-否") @ApiModelProperty(value="是否查询详细信息",example="是否查询详细信息,Y-是、N-否")
private String filed_15; private String ifShowtDetail;
@ApiModelProperty(value="是否查询保障信息",example="是否查询保障信息,Y-是、N-否") @ApiModelProperty(value="是否查询保障信息",example="是否查询保障信息,Y-是、N-否")
private String filed_16; private String ifShowtEnsure ;
@ApiModelProperty(value="是否查询航班VIP信息",example="是否查询航班VIP信息,Y-是、N-否") @ApiModelProperty(value="是否查询航班VIP信息",example="是否查询航班VIP信息,Y-是、N-否")
private String filed_17; private String ifShowtVIP;
@ApiModelProperty(value="是否查询航班特服信息",example="是否查询航班特服信息,Y-是、N-否") @ApiModelProperty(value="是否查询航班特服信息",example="是否查询航班特服信息,Y-是、N-否")
private String filed_18; private String ifShowtSpecialService;
public String getFiled_1() { public Integer getPageIndex() {
return filed_1; return pageIndex;
} }
public void setFiled_1(String filed_1) { public void setPageIndex(Integer pageIndex) {
this.filed_1 = filed_1; this.pageIndex = pageIndex;
} }
public String getFiled_2() { public Integer getPageSize() {
return filed_2; return pageSize;
} }
public void setFiled_2(String filed_2) { public void setPageSize(Integer pageSize) {
this.filed_2 = filed_2; this.pageSize = pageSize;
} }
public String getFiled_3() { public String getAirlineId() {
return filed_3; return airlineId;
} }
public void setFiled_3(String filed_3) { public void setAirlineId(String airlineId) {
this.filed_3 = filed_3; this.airlineId = airlineId;
} }
public String getFiled_4() { public String getAirlineName() {
return filed_4; return airlineName;
} }
public void setFiled_4(String filed_4) { public void setAirlineName(String airlineName) {
this.filed_4 = filed_4; this.airlineName = airlineName;
} }
public String getFiled_5() { public String getRouteType() {
return filed_5; return routeType;
} }
public void setFiled_5(String filed_5) { public void setRouteType(String routeType) {
this.filed_5 = filed_5; this.routeType = routeType;
} }
public String getFiled_6() { public String getFlightTask() {
return filed_6; return flightTask;
} }
public void setFiled_6(String filed_6) { public void setFlightTask(String flightTask) {
this.filed_6 = filed_6; this.flightTask = flightTask;
} }
public String getFiled_7() { public String getArriOrDept() {
return filed_7; return arriOrDept;
} }
public void setFiled_7(String filed_7) { public void setArriOrDept(String arriOrDept) {
this.filed_7 = filed_7; this.arriOrDept = arriOrDept;
} }
public String getFiled_8() { public String getFlightAgentId() {
return filed_8; return flightAgentId;
} }
public void setFiled_8(String filed_8) { public void setFlightAgentId(String flightAgentId) {
this.filed_8 = filed_8; this.flightAgentId = flightAgentId;
} }
public String getFiled_9() { public String getStartTime() {
return filed_9; return startTime;
} }
public void setFiled_9(String filed_9) { public void setStartTime(String startTime) {
this.filed_9 = filed_9; this.startTime = startTime;
} }
public String getFiled_10() { public String getEndTime() {
return filed_10; return endTime;
} }
public void setFiled_10(String filed_10) { public void setEndTime(String endTime) {
this.filed_10 = filed_10; this.endTime = endTime;
} }
public String getFiled_11() { public String getIsAbnormal() {
return filed_11; return isAbnormal;
} }
public void setFiled_11(String filed_11) { public void setIsAbnormal(String isAbnormal) {
this.filed_11 = filed_11; this.isAbnormal = isAbnormal;
} }
public String getFiled_12() { public String getIfShowtRelation() {
return filed_12; return ifShowtRelation;
} }
public void setFiled_12(String filed_12) { public void setIfShowtRelation(String ifShowtRelation) {
this.filed_12 = filed_12; this.ifShowtRelation = ifShowtRelation;
} }
public String getFiled_13() { public String getIfShowtDetail() {
return filed_13; return ifShowtDetail;
} }
public void setFiled_13(String filed_13) { public void setIfShowtDetail(String ifShowtDetail) {
this.filed_13 = filed_13; this.ifShowtDetail = ifShowtDetail;
} }
public String getFiled_14() { public String getIfShowtEnsure() {
return filed_14; return ifShowtEnsure;
} }
public void setFiled_14(String filed_14) { public void setIfShowtEnsure(String ifShowtEnsure) {
this.filed_14 = filed_14; this.ifShowtEnsure = ifShowtEnsure;
} }
public String getFiled_15() { public String getIfShowtVIP() {
return filed_15; return ifShowtVIP;
} }
public void setFiled_15(String filed_15) { public void setIfShowtVIP(String ifShowtVIP) {
this.filed_15 = filed_15; this.ifShowtVIP = ifShowtVIP;
} }
public String getFiled_16() { public String getIfShowtSpecialService() {
return filed_16; return ifShowtSpecialService;
} }
public void setFiled_16(String filed_16) { public void setIfShowtSpecialService(String ifShowtSpecialService) {
this.filed_16 = filed_16; this.ifShowtSpecialService = ifShowtSpecialService;
} }
public String getFiled_17() {
return filed_17;
}
public void setFiled_17(String filed_17) {
this.filed_17 = filed_17;
}
public String getFiled_18() {
return filed_18;
}
public void setFiled_18(String filed_18) {
this.filed_18 = filed_18;
}
} }
@@ -1,40 +0,0 @@
package com.gzzn.omms.adminapi.dto.history;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* 历史航班数据Dto
* @author fhc
* @since 2018-11-30
*
*/
@ApiModel(value="历史航班数据Dto",description="历史航班数据Dto")
public class HistoryFilghtDataDto {
@ApiModelProperty(value="历史数据——1",example="历史数据——1")
private String filed_1;
@ApiModelProperty(value="历史数据——2",example="历史数据——2")
private String filed_2;
@ApiModelProperty(value="历史数据——3",example="历史数据——3")
private String filed_3;
public String getFiled_1() {
return filed_1;
}
public void setFiled_1(String filed_1) {
this.filed_1 = filed_1;
}
public String getFiled_2() {
return filed_2;
}
public void setFiled_2(String filed_2) {
this.filed_2 = filed_2;
}
public String getFiled_3() {
return filed_3;
}
public void setFiled_3(String filed_3) {
this.filed_3 = filed_3;
}
}
@@ -1,31 +1,27 @@
package com.gzzn.omms.adminapi.elasticsearch; package com.gzzn.omms.adminapi.elasticsearch;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ApiModel(value="ES文本分页记录",description="ELK中log的分页记录")
public class EsPage { public class EsPage {
/** @ApiModelProperty(value="当前页,默认从1开始",example="1")
* 当前页
*/
private int currentPage; private int currentPage;
/**
* 每页显示多少条 @ApiModelProperty(value="每页显示多少条,默认10",example="10")
*/
private int pageSize; private int pageSize;
/** @ApiModelProperty(value="总记录数",example="1024")
* 总记录数
*/
private int recordCount; private int recordCount;
/**
* 本页的数据列表 @ApiModelProperty(value="本页的数据结果列表,根据实际业务而定(查询es什么日志则返回对应的数据)",example="")
*/
private List<Map<String, Object>> recordList; private List<Map<String, Object>> recordList;
/** @ApiModelProperty(value="总页数",example="1")
* 总页数
*/
private int pageCount; private int pageCount;
/** /**
* 页码列表的开始索引(包含) * 页码列表的开始索引(包含)
@@ -116,20 +112,4 @@ public class EsPage {
public void setPageCount(int pageCount) { public void setPageCount(int pageCount) {
this.pageCount = pageCount; this.pageCount = pageCount;
} }
public int getBeginPageIndex() {
return beginPageIndex;
}
public void setBeginPageIndex(int beginPageIndex) {
this.beginPageIndex = beginPageIndex;
}
public int getEndPageIndex() {
return endPageIndex;
}
public void setEndPageIndex(int endPageIndex) {
this.endPageIndex = endPageIndex;
}
} }
@@ -0,0 +1,82 @@
package com.gzzn.omms.adminapi.utils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.springframework.util.StringUtils;
public class DateUtils {
/**
* 将时间转换为时间戳(秒单位)
* @param s
* @param format 格式默认 yyyy-MM-dd HH:mm:ss
* @return
* @throws ParseException
*/
public static Long dateToStamp(String s,String format){
format = StringUtils.isEmpty(format)?"yyyy-MM-dd HH:mm:ss":format;
if(s == null)
{
return null;
}
Date date = null;
try {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
date = simpleDateFormat.parse(s);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
long ts = date.getTime();
return ts;
}
/**
* 将时间戳转换为时间字符串
* @param s 秒为单位
* @param format 格式默认 yyyy-MM-dd HH:mm:ss
* @return
*/
public static String stampToDate(Long s,String format){
if(s == null)
{
return null;
}
format = StringUtils.isEmpty(format)?"yyyy-MM-dd HH:mm:ss":format;
String res;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
long lt = new Long(s);
Date date = new Date(lt);
res = simpleDateFormat.format(date);
return res;
}
/**
* 获取今天最小时间 单位秒
* @return
*/
public static Long getTodayStartTime(){
String time = DateUtils.dateToString(new Date(), "yyyy-MM-dd HH:mm:ss");
return DateUtils.dateToStamp(time,"yyyy-MM-dd HH:mm:ss");
}
/**
* 将时间为时间字符串
* @param date
* @param format
* @return
*/
public static String dateToString(Date date,String format){
if(null==date){
return "";
}
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
return simpleDateFormat.format(date);
}
}