更新历史数据接口文档

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 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.RequestBody;
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.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
* @author fhc
@@ -19,13 +23,38 @@ import com.gzzn.omms.adminapi.dto.history.HistoryFilghtDataDto;
@RestController
public class HistoryFlightDataController {
/**
* 操作日志索引
*/
private final String INDEX_NAME = "airplant_hst";
/**
* 操作日志类型
*/
private final String OPLOG_ES_TYPE = "_doc";
@ApiOperation(value="获取历史航班数据",tags="历史航班数据")
@PostMapping(value="/hitFlightData/list")
public ResponseDto<PageInfoDto<HistoryFilghtDataDto>> findAllByGroupCode(@RequestBody HistoryFilghtConditionDto conditions) {
PageInfoDto<HistoryFilghtDataDto> page = new PageInfoDto<HistoryFilghtDataDto>();
public ResponseDto<EsPage> findAllByGroupCode(@RequestBody HistoryFilghtConditionDto conditions) {
//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);
}
}
@@ -11,155 +11,136 @@ import io.swagger.annotations.ApiModelProperty;
*/
@ApiModel(value="历史航班数据条件Dto",description="查询历史航班数据的条件DTO")
public class HistoryFilghtConditionDto {
//TODO 更改字段名
@ApiModelProperty(value="航空公司",example="广东航空")
private String filed_1;
@ApiModelProperty(value="当前页,默认从1开始",example="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-混合")
private String filed_2;
@ApiModelProperty(value="航班任务",example="航班任务A")
private String filed_3;
@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;
private String routeType;
@ApiModelProperty(value="航班任务",example="航班任务:S=正班、N=包机、E=急救、B=专机、G=通用、J=加班、M=军用、Q=补班、X=其他、A=计划外(原参考分类:正班、加班、补班、中转、计划外、计划外中转、货运、训练...)")
private String flightTask;
@ApiModelProperty(value="出发/到达",example="到达/出发(进港/出港)标志,A-到达、D-出发")
private String arriOrDept;
@ApiModelProperty(value="航班代理",example="航班代理")
private String filed_10;
@ApiModelProperty(value="开始时间",example="开始时间")
private String filed_11;
@ApiModelProperty(value="结束时间",example="结束时间")
private String filed_12;
@ApiModelProperty(value="航班异常状态",example="航班异常状态,1-正常、2-检修")
private String filed_13;
private String flightAgentId;
@ApiModelProperty(value="开始时间",example="开始时间(yyyy-mm-dd)")
private String startTime;
@ApiModelProperty(value="结束时间",example="结束时间(yyyy-mm-dd)")
private String endTime;
@ApiModelProperty(value="航班异常状态",example="是否故障(0-否 1-是)")
private String isAbnormal;
@ApiModelProperty(value="是否查询航班关联信息",example="是否查询航班关联信息,Y-是、N-否")
private String filed_14;
private String ifShowtRelation;
@ApiModelProperty(value="是否查询详细信息",example="是否查询详细信息,Y-是、N-否")
private String filed_15;
private String ifShowtDetail;
@ApiModelProperty(value="是否查询保障信息",example="是否查询保障信息,Y-是、N-否")
private String filed_16;
private String ifShowtEnsure ;
@ApiModelProperty(value="是否查询航班VIP信息",example="是否查询航班VIP信息,Y-是、N-否")
private String filed_17;
private String ifShowtVIP;
@ApiModelProperty(value="是否查询航班特服信息",example="是否查询航班特服信息,Y-是、N-否")
private String filed_18;
public String getFiled_1() {
return filed_1;
private String ifShowtSpecialService;
public Integer getPageIndex() {
return pageIndex;
}
public void setFiled_1(String filed_1) {
this.filed_1 = filed_1;
public void setPageIndex(Integer pageIndex) {
this.pageIndex = pageIndex;
}
public String getFiled_2() {
return filed_2;
public Integer getPageSize() {
return pageSize;
}
public void setFiled_2(String filed_2) {
this.filed_2 = filed_2;
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
public String getFiled_3() {
return filed_3;
public String getAirlineId() {
return airlineId;
}
public void setFiled_3(String filed_3) {
this.filed_3 = filed_3;
public void setAirlineId(String airlineId) {
this.airlineId = airlineId;
}
public String getFiled_4() {
return filed_4;
public String getAirlineName() {
return airlineName;
}
public void setFiled_4(String filed_4) {
this.filed_4 = filed_4;
public void setAirlineName(String airlineName) {
this.airlineName = airlineName;
}
public String getFiled_5() {
return filed_5;
public String getRouteType() {
return routeType;
}
public void setFiled_5(String filed_5) {
this.filed_5 = filed_5;
public void setRouteType(String routeType) {
this.routeType = routeType;
}
public String getFiled_6() {
return filed_6;
public String getFlightTask() {
return flightTask;
}
public void setFiled_6(String filed_6) {
this.filed_6 = filed_6;
public void setFlightTask(String flightTask) {
this.flightTask = flightTask;
}
public String getFiled_7() {
return filed_7;
public String getArriOrDept() {
return arriOrDept;
}
public void setFiled_7(String filed_7) {
this.filed_7 = filed_7;
public void setArriOrDept(String arriOrDept) {
this.arriOrDept = arriOrDept;
}
public String getFiled_8() {
return filed_8;
public String getFlightAgentId() {
return flightAgentId;
}
public void setFiled_8(String filed_8) {
this.filed_8 = filed_8;
public void setFlightAgentId(String flightAgentId) {
this.flightAgentId = flightAgentId;
}
public String getFiled_9() {
return filed_9;
public String getStartTime() {
return startTime;
}
public void setFiled_9(String filed_9) {
this.filed_9 = filed_9;
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getFiled_10() {
return filed_10;
public String getEndTime() {
return endTime;
}
public void setFiled_10(String filed_10) {
this.filed_10 = filed_10;
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public String getFiled_11() {
return filed_11;
public String getIsAbnormal() {
return isAbnormal;
}
public void setFiled_11(String filed_11) {
this.filed_11 = filed_11;
public void setIsAbnormal(String isAbnormal) {
this.isAbnormal = isAbnormal;
}
public String getFiled_12() {
return filed_12;
public String getIfShowtRelation() {
return ifShowtRelation;
}
public void setFiled_12(String filed_12) {
this.filed_12 = filed_12;
public void setIfShowtRelation(String ifShowtRelation) {
this.ifShowtRelation = ifShowtRelation;
}
public String getFiled_13() {
return filed_13;
public String getIfShowtDetail() {
return ifShowtDetail;
}
public void setFiled_13(String filed_13) {
this.filed_13 = filed_13;
public void setIfShowtDetail(String ifShowtDetail) {
this.ifShowtDetail = ifShowtDetail;
}
public String getFiled_14() {
return filed_14;
public String getIfShowtEnsure() {
return ifShowtEnsure;
}
public void setFiled_14(String filed_14) {
this.filed_14 = filed_14;
public void setIfShowtEnsure(String ifShowtEnsure) {
this.ifShowtEnsure = ifShowtEnsure;
}
public String getFiled_15() {
return filed_15;
public String getIfShowtVIP() {
return ifShowtVIP;
}
public void setFiled_15(String filed_15) {
this.filed_15 = filed_15;
public void setIfShowtVIP(String ifShowtVIP) {
this.ifShowtVIP = ifShowtVIP;
}
public String getFiled_16() {
return filed_16;
public String getIfShowtSpecialService() {
return ifShowtSpecialService;
}
public void setFiled_16(String filed_16) {
this.filed_16 = filed_16;
public void setIfShowtSpecialService(String ifShowtSpecialService) {
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;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
import java.util.Map;
@ApiModel(value="ES文本分页记录",description="ELK中log的分页记录")
public class EsPage {
/**
* 当前页
*/
@ApiModelProperty(value="当前页,默认从1开始",example="1")
private int currentPage;
/**
* 每页显示多少条
*/
@ApiModelProperty(value="每页显示多少条,默认10",example="10")
private int pageSize;
/**
* 总记录数
*/
@ApiModelProperty(value="总记录数",example="1024")
private int recordCount;
/**
* 本页的数据列表
*/
@ApiModelProperty(value="本页的数据结果列表,根据实际业务而定(查询es什么日志则返回对应的数据)",example="")
private List<Map<String, Object>> recordList;
/**
* 总页数
*/
@ApiModelProperty(value="总页数",example="1")
private int pageCount;
/**
* 页码列表的开始索引(包含)
@@ -116,20 +112,4 @@ public class EsPage {
public void setPageCount(int 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);
}
}