Commit c02c2b68 by 雷紫添

Merge remote-tracking branch 'remotes/origin/dev_QuanGuoTongYongJcxx' into dev_QuanGuoTongYongJcxx

parents ef7f4aed 5f368686
......@@ -86,13 +86,25 @@
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>6.4.3</version>
<version>7.11.1</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>6.4.3</version>
<version>7.11.1</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>7.11.1</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId>
<version>7.11.1</version>
</dependency>
<!-- alibaba的druid数据库连接池 -->
<dependency>
<groupId>com.alibaba</groupId>
......
package com.founder.config;
import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class ElasticSearchClientConfig {
@Value("${spring.data.elasticsearch.cluster-nodes}")
private String hostname;
@Bean
public RestHighLevelClient restHighLevelClient(){
RestHighLevelClient client = new RestHighLevelClient(
RestClient.builder(httpHosts())
);
System.out.println("高级客户端创建成功!");
return client;
}
/**
* 解析hostname
* @return
*/
private HttpHost[] httpHosts(){
//解析hostlist配置信息
String[] split = hostname.split(",");
System.out.println(hostname);
//创建HttpHost数组,其中存放es主机和端口的配置信息
HttpHost[] httpHostArray = new HttpHost[split.length];
for(int i=0;i<split.length;i++){
String item = split[i];
httpHostArray[i] = new HttpHost(item.split(":")[0], Integer.parseInt(item.split(":")[1]), "http");
}
return httpHostArray;
}
}
......@@ -971,7 +971,7 @@ public class XxcxController {
return reslt;
}
Map mapResult = new HashMap();
mapResult.put("isExist","flase");
mapResult.put("isExist","false");
List<Map<String,Object>> listResult = new ArrayList<>();
AsjRyRelateVoBzpt asj=new AsjRyRelateVoBzpt();
asj.setAsjbh(asjbl.getAsjbh());
......
package com.founder.controller;
import com.alibaba.fastjson.JSONObject;
import com.founder.common.IpADdress;
import com.founder.model.AsjRyRelateVoBzpt;
import com.founder.model.Result;
import com.founder.model.XyrParam;
import com.founder.model.ZtryParam;
import com.founder.service.ZtryService;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.TermsQueryBuilder;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@RestController
@RequestMapping(value="/ztry",produces = "application/json; charset=utf-8")
public class ZtryController {
@Value("${xxcx.author}")
private String author;
@Autowired
private ZtryService ztryService;
@RequestMapping("/ZtryApiQuery")
public Result ZtryApiQuery(@RequestBody ZtryParam ztry){
Result reslt = new Result();
HttpServletRequest request = IpADdress.getRequest();
String header = request.getHeader("founder.authorization");
if(StringUtils.isEmpty(header) || !author.equals(header)){
reslt.setData(new ArrayList<>());
reslt.setMsg("没有授权码或者授权码验证未通过,不能查询!");
reslt.setStatus("fail");
return reslt;
}
Map mapResult = new HashMap();
mapResult =ztryService.ZtryApiQuery(ztry);
reslt.setData(mapResult);
reslt.setMsg("在逃信息查询成功");
reslt.setStatus("success");
return reslt;
}
@RequestMapping("/ZtryApiByDetail")
public Result ZtryApiByDetail(@RequestBody ZtryParam ztry){
Result reslt = new Result();
Map mapResult = new HashMap();
HttpServletRequest request = IpADdress.getRequest();
String header = request.getHeader("founder.authorization");
if(StringUtils.isEmpty(header) || !author.equals(header)){
reslt.setData(new ArrayList<>());
reslt.setMsg("没有授权码或者授权码验证未通过,不能查询!");
reslt.setStatus("fail");
return reslt;
}
if(StringUtils.isEmpty(ztry.getZtrybh()) ){
mapResult.put("rows", "");
reslt.setData(mapResult);
reslt.setMsg("没有传入人员编号,不能查询!");
reslt.setStatus("fail");
return reslt;
}
ZtryParam ztryParam=new ZtryParam();
ztryParam.setZtrybh(ztry.getZtrybh());
mapResult =ztryService.ZtryApiByDetail(ztryParam);
reslt.setData(mapResult);
reslt.setMsg("在逃信息查询成功");
reslt.setStatus("success");
return reslt;
}
}
package com.founder.service;
import com.founder.model.QgEsZtryEntity;
import com.founder.model.ZtryParam;
import java.util.List;
import java.util.Map;
public interface ZtryService {
Map<String, Object> ZtryApiQuery(ZtryParam ztry);
Map<String, Object> ZtryApiByDetail(ZtryParam ztry);
}
......@@ -10,8 +10,7 @@ import org.elasticsearch.join.query.JoinQueryBuilders;
import org.elasticsearch.script.Script;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders;
import org.elasticsearch.search.aggregations.pipeline.bucketselector.BucketSelectorPipelineAggregationBuilder;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -328,7 +327,7 @@ public class XxcxServiceImpl implements XxcxService {
int limit = xyr.getLimit();
int begin = (page - 1) * limit;
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.query(bqAj).from(begin).size(limit).trackTotalHits(true);
searchSourceBuilder.query(bqAj).from(begin).size(limit);
searchSourceBuilder.sort("v_solr6_tb_st_asj_AS_LARQ", DESC);
return searchSourceBuilder.toString();
......@@ -351,10 +350,10 @@ public class XxcxServiceImpl implements XxcxService {
Script script = new Script("params.orderCount >=2");
//构建bucket选择器
BucketSelectorPipelineAggregationBuilder bs =
PipelineAggregatorBuilders.bucketSelector("having", bucketsPathsMap, script);
// BucketSelectorPipelineAggregationBuilder bs =
// PipelineAggregatorBuilders.bucketSelector("having", bucketsPathsMap, script);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
termsAgg.subAggregation(bs);
// termsAgg.subAggregation(bs);
searchSourceBuilder.aggregation(termsAgg);
return searchSourceBuilder.toString();
}
......@@ -376,11 +375,11 @@ public class XxcxServiceImpl implements XxcxService {
Script script = new Script("params.orderCount >=2");
//构建bucket选择器
BucketSelectorPipelineAggregationBuilder bs =
PipelineAggregatorBuilders.bucketSelector("having", bucketsPathsMap, script);
// BucketSelectorPipelineAggregationBuilder bs =
// PipelineAggregatorBuilders.bucketSelector("having", bucketsPathsMap, script);
//
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
termsAgg.subAggregation(bs);
// termsAgg.subAggregation(bs);
searchSourceBuilder.aggregation(termsAgg);
return searchSourceBuilder.toString();
}
......
package com.founder.util;
import org.apache.commons.lang3.StringUtils;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* 日期工具类
*
* @author chentian
* @date 2022/03/14/
*/
public class DateUtil {
private static SimpleDateFormat sf = null;
/**
*将小时加入时间
*/
public static Date addHour(Date create, int hour){
long time = create.getTime();
return new Date(time+hour*60*60*1000);
}
//计算时间差 传一个时间戳
public static String dateStr(long diff){
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String result="";
try
{
// Date d1 = df.parse(endDate);
//Date d2 = df.parse(beginDate);
/* long diff = d1.getTime() - d2.getTime();//这样得到的差值是微秒级别
long days = diff / (1000 * 60 * 60 * 24);
long hours = (diff-days*(1000 * 60 * 60 * 24))/(1000* 60 * 60);
long minutes = (diff-days*(1000 * 60 * 60 * 24)-hours*(1000* 60 * 60))/(1000* 60);
result=""+days+"天"+hours+"小时"+minutes+"分";
System.out.println(""+days+"天"+hours+"小时"+minutes+"分");*/
//计算时间差
//计算天数
long days = diff / (1000 * 60 * 60 * 24);
//计算小时
long hours = (diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60);
//计算分钟
long minutes = (diff % (1000 * 60 * 60)) / (1000 * 60);
//计算秒
long seconds = (diff % (1000 * 60)) / 1000;
//输出
if(days>0){
result=days+"天";
}
if(hours>0){
result+=hours+"小时";
}
if(minutes>0){
result+=minutes+"分";
}
if(seconds>0){
result+=seconds+"秒";
}
}catch (Exception e) {
}
return result;
}
public static String getTimeStamp(String currentDate) {
sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date();
try {
date = sf.parse(currentDate);
} catch (ParseException e) {
e.printStackTrace();
}
return String.valueOf(date.getTime());
}
public static String dateStr(String time) {
return dateStr(Long.parseLong(time));
}
// 结束时间均加1天
public static String EndDateAdd(String dateStr){
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
String returnDate = null;
try {
Date EndDate = format.parse(dateStr);
Calendar c = Calendar.getInstance();
c.setTime(EndDate);
c.add(Calendar.DAY_OF_MONTH,1);
EndDate = c.getTime();
returnDate = format.format(EndDate);
} catch (ParseException e) {
e.printStackTrace();
}
return returnDate;
}
public static String dateStrFormat(String dateStr,String sourceFormat,String targetFormat){
String resultDate = "";
if(StringUtils.isNotEmpty(dateStr)){
SimpleDateFormat sourceSdf = new SimpleDateFormat(sourceFormat);
SimpleDateFormat targetSdf = new SimpleDateFormat(targetFormat);
try {
Date date = sourceSdf.parse(dateStr);
resultDate=targetSdf.format(date);
} catch (ParseException e) {
e.printStackTrace();
}
}
return resultDate;
}
}
......@@ -20,8 +20,11 @@ spring:
host: 47.92.223.200
port: 7779
password: p!ssw0rd1
data:
elasticsearch:
cluster-name: node-1
# cluster-nodes: 127.0.0.1:9200
cluster-nodes: 10.142.16.176:9205,10.142.16.177:9205,10.142.16.91:9205
ftpserverip: 47.92.129.99
nginxport: 9053
......@@ -73,3 +76,4 @@ codemsg:
- code: "010104"
name: "用户身份证信息有误"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment