Commit c0b4c534 by yangyang

美亚厨房ip调整(内蒙)

parent 7e7eeb52
package com.founder.commonutils.model.nmDataEntity.ParamsEntity; //package com.founder.commonutils.model.nmDataEntity.ParamsEntity;
//
//
import com.alibaba.fastjson.JSONObject; //import com.alibaba.fastjson.JSONObject;
import com.founder.commonutils.util.PropertieUtil; //import com.founder.commonutils.util.PropertieUtil;
import org.apache.commons.logging.Log; //import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; //import org.apache.commons.logging.LogFactory;
import org.apache.cxf.helpers.IOUtils; //import org.apache.cxf.helpers.IOUtils;
import org.apache.http.HttpStatus; //import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient; //import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig; //import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse; //import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost; //import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ssl.NoopHostnameVerifier; //import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.entity.ContentType; //import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity; //import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient; //import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients; //import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContexts; //import org.apache.http.ssl.SSLContexts;
import org.apache.http.util.EntityUtils; //import org.apache.http.util.EntityUtils;
import org.apache.tomcat.util.http.fileupload.ByteArrayOutputStream; //import org.apache.tomcat.util.http.fileupload.ByteArrayOutputStream;
import org.springframework.stereotype.Component; //import org.springframework.stereotype.Component;
import org.springframework.util.ClassUtils; //import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils; //import org.springframework.util.StringUtils;
//
import javax.net.ssl.SSLContext; //import javax.net.ssl.SSLContext;
import javax.servlet.ServletContext; //import javax.servlet.ServletContext;
import java.io.FileInputStream; //import java.io.FileInputStream;
import java.io.IOException; //import java.io.IOException;
import java.io.InputStream; //import java.io.InputStream;
import java.security.cert.X509Certificate; //import java.security.cert.X509Certificate;
import java.util.*; //import java.util.*;
//
/** ///**
* @Auther: yy // * @Auther: yy
* @CreateDate: 2022-03-14 // * @CreateDate: 2022-03-14
*/ // */
@Component //@Component
public class NmTokenUtils { //public class NmTokenUtils {
private static Log logger = LogFactory.getLog(HttpClient.class); // private static Log logger = LogFactory.getLog(HttpClient.class);
private static RequestConfig requestConfig = null; // private static RequestConfig requestConfig = null;
private static String tokenPath="/data/nmsk/token2.properties"; // private static String tokenPath="/data/nmsk/token2.properties";
//
static{ // static{
// 设置请求和传输超时时间 // // 设置请求和传输超时时间
//setConnectTimeout:设置连接超时时间,单位毫秒。 // //setConnectTimeout:设置连接超时时间,单位毫秒。
//setSocketTimeout:请求获取数据的超时时间,单位毫秒。 如果访问一个接口,多少时间内无法返回数据,就直接放弃此次调用。 // //setSocketTimeout:请求获取数据的超时时间,单位毫秒。 如果访问一个接口,多少时间内无法返回数据,就直接放弃此次调用。
//setConnectionRequestTimeout:设置从connect Manager获取Connection 超时时间,单位毫秒 // //setConnectionRequestTimeout:设置从connect Manager获取Connection 超时时间,单位毫秒
requestConfig = RequestConfig.custom().setSocketTimeout(120000).setConnectTimeout(120000).build(); // requestConfig = RequestConfig.custom().setSocketTimeout(120000).setConnectTimeout(120000).build();
try{ // try{
// tokenPath=ResourceUtils.getURL("classpath:").getPath()+"token.properties"; //// tokenPath=ResourceUtils.getURL("classpath:").getPath()+"token.properties";
}catch (Exception e){ // }catch (Exception e){
e.printStackTrace(); // e.printStackTrace();
} // }
} // }
//
// 内蒙大数据token // // 内蒙大数据token
public static String getToken(){ // public static String getTokendsadad(){
String result_token = ""; // String result_token = "";
try{ // try{
//1 先比较已有token是否过期 // //1 先比较已有token是否过期
long nowtime = new Date().getTime(); // long nowtime = new Date().getTime();
//获取绝对路径下的token属性文件 // //获取绝对路径下的token属性文件
String token= PropertieUtil.readTokenValue("token",tokenPath); // String token= PropertieUtil.readTokenValue("token",tokenPath);
String expiration =PropertieUtil.readTokenValue("expiration",tokenPath); // String expiration =PropertieUtil.readTokenValue("expiration",tokenPath);
if(StringUtils.isEmpty(token) || StringUtils.isEmpty(expiration)){ // if(StringUtils.isEmpty(token) || StringUtils.isEmpty(expiration)){
result_token=readeWriteToken(nowtime); // result_token=readeWriteToken(nowtime);
}else{ // }else{
//token值已过期 // //token值已过期
if(nowtime > Long.valueOf(expiration)){ // if(nowtime > Long.valueOf(expiration)){
result_token=readeWriteToken(nowtime); // result_token=readeWriteToken(nowtime);
}else{ // }else{
result_token = token; // result_token = token;
} // }
} // }
}catch (Exception e){ // }catch (Exception e){
e.printStackTrace(); // e.printStackTrace();
logger.info(e.getMessage()); // logger.info(e.getMessage());
} // }
return result_token; // return result_token;
//
} // }
//读和写内蒙大数据的token值 // //读和写内蒙大数据的token值
public static String readeWriteToken(long nowtime){ // public static String readeWriteToken(long nowtime){
String result_token=""; // String result_token="";
//2 如果过期先获取新的token值 // //2 如果过期先获取新的token值
String ContentType =PropertieUtil.readTokenValue("Content-Type",tokenPath); // String ContentType =PropertieUtil.readTokenValue("Content-Type",tokenPath);
Map headerMap=new HashMap(); // Map headerMap=new HashMap();
headerMap.put("Content-Type","application/json"); // headerMap.put("Content-Type","application/json");
JSONObject jsonObject = new JSONObject(); // JSONObject jsonObject = new JSONObject();
jsonObject.put("client_id", "xzpt");//客户端编码 // jsonObject.put("client_id", "xzpt");//客户端编码
jsonObject.put("client_secret", "522f2d3673684d7b916bf68a06db18ea");//客户端密钥 // jsonObject.put("client_secret", "522f2d3673684d7b916bf68a06db18ea");//客户端密钥
jsonObject.put("grant_type", "client_credentials"); // jsonObject.put("grant_type", "client_credentials");
jsonObject.put("scop", "email"); // jsonObject.put("scop", "email");
String token_url ="https://26.13.101.72:8443/xsp-auth/oauth2/token"; // String token_url ="https://26.3.111.234:8443/xsp-auth/oauth2/token";
try { // try {
String resultString = doPostJson(token_url,headerMap,JSONObject.toJSONString(jsonObject)); // String resultString = doPostJson(token_url,headerMap,JSONObject.toJSONString(jsonObject));
// 返回解析 // // 返回解析
if (!StringUtils.isEmpty(resultString)) { // if (!StringUtils.isEmpty(resultString)) {
System.out.println("aaaaaaaa"); // System.out.println("aaaaaaaa");
JSONObject result=JSONObject.parseObject(resultString); // JSONObject result=JSONObject.parseObject(resultString);
result_token = result.getString("access_token"); // result_token = result.getString("access_token");
String expires_in = result.getString("expires_in");//有效时间段 单位为秒 // String expires_in = result.getString("expires_in");//有效时间段 单位为秒
String result_expiration = nowtime+Integer.parseInt(expires_in)*1000+""; // String result_expiration = nowtime+Integer.parseInt(expires_in)*1000+"";
//写入新的token值和本次token的过期时间 // //写入新的token值和本次token的过期时间
PropertieUtil.writeTokenProperties(tokenPath, "token", result_token); // PropertieUtil.writeTokenProperties(tokenPath, "token", result_token);
PropertieUtil.writeTokenProperties(tokenPath, "expiration", result_expiration); // PropertieUtil.writeTokenProperties(tokenPath, "expiration", result_expiration);
} // }
}catch (Exception e){ // }catch (Exception e){
e.printStackTrace(); // e.printStackTrace();
logger.info(e.getMessage()); // logger.info(e.getMessage());
} // }
return result_token; // return result_token;
} // }
//
/** // /**
* 请求的参数类型为json // * 请求的参数类型为json
* @param url // * @param url
* @param json // * @param json
*/ // */
public static String doPostJson(String url,Map<String, String> headers,String json) throws Exception { // public static String doPostJson(String url,Map<String, String> headers,String json) throws Exception {
// post请求返回结果 // // post请求返回结果
String jsonResult = null; // String jsonResult = null;
SSLContext sslContext = null; // SSLContext sslContext = null;
try { // try {
sslContext = SSLContexts.custom().loadTrustMaterial(null, // sslContext = SSLContexts.custom().loadTrustMaterial(null,
(X509Certificate[] x509Certificates, String s) -> { // (X509Certificate[] x509Certificates, String s) -> {
return true; // return true;
}).build(); // }).build();
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
} // }
//
//以上为忽略ssl证书代码 // //以上为忽略ssl证书代码
//创建httpClient // //创建httpClient
CloseableHttpClient httpClient = HttpClients.custom().setSSLContext(sslContext). // CloseableHttpClient httpClient = HttpClients.custom().setSSLContext(sslContext).
setSSLHostnameVerifier(new NoopHostnameVerifier()).build(); // setSSLHostnameVerifier(new NoopHostnameVerifier()).build();
HttpPost httpPost = new HttpPost(url); // HttpPost httpPost = new HttpPost(url);
CloseableHttpResponse result = null; // CloseableHttpResponse result = null;
//
// 设置请求和传输超时时间 // // 设置请求和传输超时时间
httpPost.setConfig(requestConfig); // httpPost.setConfig(requestConfig);
if(headers != null) { // if(headers != null) {
for (String key : headers.keySet()) { // for (String key : headers.keySet()) {
httpPost.setHeader(key, headers.get(key)); // httpPost.setHeader(key, headers.get(key));
} // }
} // }
try{ // try{
//设置参数解决中文乱码 // //设置参数解决中文乱码
StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON); // StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON);
httpPost.setEntity(entity); // httpPost.setEntity(entity);
//
//发送请求 // //发送请求
result = httpClient.execute(httpPost); // result = httpClient.execute(httpPost);
String resultString = EntityUtils.toString(result.getEntity(), "utf-8"); // String resultString = EntityUtils.toString(result.getEntity(), "utf-8");
System.out.println("调用获取token::StatusCode===="+result.getStatusLine().getStatusCode()+JSONObject.parse(resultString)); // System.out.println("调用获取token::StatusCode===="+result.getStatusLine().getStatusCode()+JSONObject.parse(resultString));
if (result.getStatusLine().getStatusCode() == HttpStatus.SC_OK){ // if (result.getStatusLine().getStatusCode() == HttpStatus.SC_OK){
// 读取服务器返回的json数据(然后解析) // // 读取服务器返回的json数据(然后解析)
jsonResult = resultString; // jsonResult = resultString;
} // }
}catch (Exception e){ // }catch (Exception e){
e.printStackTrace(); // e.printStackTrace();
throw new Exception(); // throw new Exception();
}finally{ // }finally{
result.close(); // result.close();
} // }
return jsonResult; // return jsonResult;
} // }
} //}
package com.founder.commonutils.util; package com.founder.commonutils.util;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.UnknownHostException; import java.net.UnknownHostException;
...@@ -51,4 +54,35 @@ public class NetworkUtil { ...@@ -51,4 +54,35 @@ public class NetworkUtil {
} }
return ipAddress; return ipAddress;
} }
public static String getRealIp(HttpServletRequest request) throws Exception {
String ip = request.getHeader("X-Forwarded-For");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("X-Real-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
//有些网络通过多层代理,那么获取到的ip就会有多个,一般都是通过逗号(,)分割开来,并且第一个ip为客户端的真实IP
if (ip != null && ip.length() != 0) {
ip = ip.split(",")[0];
}
if ("127.0.0.1".equals(ip) || ip == "127.0.0.1" || "0:0:0:0:0:0:0:1".equals(ip)
|| ip == "0:0:0:0:0:0:0:1") {
ip = InetAddress.getLocalHost().getHostAddress();
}
return ip;
}
} }
package com.founder.commonutils.util;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.java.Log;
import org.apache.http.HttpStatus;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContexts;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import javax.net.ssl.SSLContext;
import java.security.cert.X509Certificate;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* @ClassName: ZgTokenUtils
* @Auther: yangyang
* @Description: java类作用描述
* @CreateDate: 2024-03-28
* @Version: 1.0
*/
@Component
@Log
public class RedisTokenUtils {
private static StringRedisTemplate redisTemplate;
private static RequestConfig requestConfig = null;
@Autowired
public void setRestTemplate(StringRedisTemplate redisTemplate) {
RedisTokenUtils.redisTemplate = redisTemplate;
}
static{
// 设置请求和传输超时时间
//setConnectTimeout:设置连接超时时间,单位毫秒。
//setSocketTimeout:请求获取数据的超时时间,单位毫秒。 如果访问一个接口,多少时间内无法返回数据,就直接放弃此次调用。
//setConnectionRequestTimeout:设置从connect Manager获取Connection 超时时间,单位毫秒
requestConfig = RequestConfig.custom().setSocketTimeout(120000).setConnectTimeout(120000).build();
}
/**
* 判断并获取新的token(紫光)
* @return
*/
public static String getZgToken (){
String result_token = null;
try{
// 1 先比较已有token是否过期或空
long nowtime = new Date().getTime();
// 获取redis tokenZg
Map<Object,Object> redisMap = redisTemplate.opsForHash().entries("tokenZg");
String token = String.valueOf(redisMap.get("token"));
String expiration = String.valueOf(redisMap.get("expiration"));
System.out.println("得到的token: "+token);
System.out.println("得到的时间是: "+expiration);
if("null" == token || "null" == expiration){
// 2 如果为空获取新的token值
result_token = readeWriteZgToken(nowtime);
}else{
// 3 如果过期获取新的token值
if(nowtime > Long.valueOf(expiration)){
result_token= readeWriteZgToken(nowtime);
}else{
result_token = token;
}
}
}catch (Exception e){
e.printStackTrace();
log.info(e.getMessage());
}
return result_token;
}
//读和写云天的token值
public static String readeWriteZgToken(long nowtime){
String result_token="";
//2 如果过期先获取新的token值
String ContentType = "application/json";
Map headerMap=new HashMap();
headerMap.put("Content-Type",ContentType);
String client_id = "GATXZFZ";
String client_secret = "GATXZFZ123";
String grant_type = "client_credentials";
String token_url = "http://26.7.9.56:11125/sso/oauth2.0/accessToken";
try {
System.out.println("紫光tokenurl"+token_url+"?grant_type="+grant_type+"&client_id="+client_id+"&client_secret="+client_secret+"&format=json");
String resultString = HttpUtil.doGet(token_url+"?grant_type="+grant_type+"&client_id="+client_id+"&client_secret="+client_secret+"&format=json");
if (!StringUtils.isEmpty(resultString)) {
JSONObject result=JSONObject.parseObject(resultString);
result_token = result.getString("access_token");
String expires_in = result.getString("expires_in");//有效时间段 单位为秒
String result_expiration = nowtime+Integer.parseInt(expires_in)*1000+"";
// 写入新的token值和本次token的过期时间
Map<String, Object> map = new HashMap<>();
map.put("token", result_token);
map.put("expiration", result_expiration);
redisTemplate.opsForHash().putAll("tokenZg", map);
}
}catch (Exception e){
e.printStackTrace();
log.info(e.getMessage());
}
return result_token;
}
/**
* 判断并获取新的token(大数据)
* @return
*/
public static String getDsjToken (){
String result_token = null;
try{
// 1 先比较已有token是否过期或空
long nowtime = new Date().getTime();
// 获取redis tokenZg
Map<Object,Object> redisMap = redisTemplate.opsForHash().entries("tokenDsj");
String token = String.valueOf(redisMap.get("token"));
String expiration = String.valueOf(redisMap.get("expiration"));
System.out.println("得到的token: "+token);
System.out.println("得到的时间是: "+expiration);
if("null" == token || "null" == expiration){
// 2 如果为空获取新的token值
result_token = readeWriteDsjToken(nowtime);
}else{
// 3 如果过期获取新的token值
if(nowtime > Long.valueOf(expiration)){
result_token= readeWriteDsjToken(nowtime);
}else{
result_token = token;
}
}
}catch (Exception e){
e.printStackTrace();
log.info(e.getMessage());
}
return result_token;
}
//读和写内蒙大数据的token值
public static String readeWriteDsjToken(long nowtime){
String result_token="";
//2 如果过期先获取新的token值
Map headerMap=new HashMap();
headerMap.put("Content-Type","application/json");
JSONObject jsonObject = new JSONObject();
jsonObject.put("client_id", "xzpt");//客户端编码
jsonObject.put("client_secret", "522f2d3673684d7b916bf68a06db18ea");//客户端密钥
jsonObject.put("grant_type", "client_credentials");
jsonObject.put("scop", "email");
String token_url ="https://26.3.111.234:8443/xsp-auth/oauth2/token";
try {
String resultString = doPostJson(token_url,headerMap,JSONObject.toJSONString(jsonObject));
// 返回解析
if (!StringUtils.isEmpty(resultString)) {
JSONObject result=JSONObject.parseObject(resultString);
result_token = result.getString("access_token");
String expires_in = result.getString("expires_in");//有效时间段 单位为秒
String result_expiration = nowtime+Integer.parseInt(expires_in)*1000+"";
// 写入新的token值和本次token的过期时间
Map<String, Object> map = new HashMap<>();
map.put("token", result_token);
map.put("expiration", result_expiration);
redisTemplate.opsForHash().putAll("tokenDsj", map);
}
}catch (Exception e){
e.printStackTrace();
log.info(e.getMessage());
}
return result_token;
}
/**
* 请求的参数类型为json
* @param url
* @param json
*/
public static String doPostJson(String url,Map<String, String> headers,String json) throws Exception {
// post请求返回结果
String jsonResult = null;
SSLContext sslContext = null;
try {
sslContext = SSLContexts.custom().loadTrustMaterial(null,
(X509Certificate[] x509Certificates, String s) -> {
return true;
}).build();
} catch (Exception e) {
e.printStackTrace();
}
//以上为忽略ssl证书代码
//创建httpClient
CloseableHttpClient httpClient = HttpClients.custom().setSSLContext(sslContext).
setSSLHostnameVerifier(new NoopHostnameVerifier()).build();
HttpPost httpPost = new HttpPost(url);
CloseableHttpResponse result = null;
// 设置请求和传输超时时间
httpPost.setConfig(requestConfig);
if(headers != null) {
for (String key : headers.keySet()) {
httpPost.setHeader(key, headers.get(key));
}
}
try{
//设置参数解决中文乱码
StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON);
httpPost.setEntity(entity);
//发送请求
result = httpClient.execute(httpPost);
String resultString = EntityUtils.toString(result.getEntity(), "utf-8");
System.out.println("调用获取token::StatusCode===="+result.getStatusLine().getStatusCode()+JSONObject.parse(resultString));
if (result.getStatusLine().getStatusCode() == HttpStatus.SC_OK){
// 读取服务器返回的json数据(然后解析)
jsonResult = resultString;
}
}catch (Exception e){
e.printStackTrace();
throw new Exception();
}finally{
result.close();
}
return jsonResult;
}
}
token_url = https://26.13.101.72:8443/xsp-auth/oauth2/token token_url = https://26.3.111.234:8443/xsp-auth/oauth2/token
#header #header
Content-Type=application/json Content-Type=application/json
#body #body
......
...@@ -10,7 +10,7 @@ import com.founder.commonutils.model.nmDataEntity.ResultEntity.MySjGjxx; ...@@ -10,7 +10,7 @@ import com.founder.commonutils.model.nmDataEntity.ResultEntity.MySjGjxx;
import com.founder.commonutils.model.vo.response.SkTrailVO; import com.founder.commonutils.model.vo.response.SkTrailVO;
import com.founder.commonutils.util.DateUtil; import com.founder.commonutils.util.DateUtil;
import com.founder.commonutils.util.HttpClient; import com.founder.commonutils.util.HttpClient;
import com.founder.commonutils.util.TokenUtils; import com.founder.commonutils.util.RedisTokenUtils;
import com.founder.publicapi.mapper.oracleXzxtMapper.SysDictitemMapper; import com.founder.publicapi.mapper.oracleXzxtMapper.SysDictitemMapper;
import com.founder.publicapi.service.SkPointlocationService; import com.founder.publicapi.service.SkPointlocationService;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
...@@ -412,7 +412,7 @@ public class InterfaceAPI { ...@@ -412,7 +412,7 @@ public class InterfaceAPI {
while (flag) { while (flag) {
try { try {
// 接口调用 // 接口调用
String token = TokenUtils.getYtgsToken(); String token = RedisTokenUtils.getZgToken();
Map herders = new HashMap(); Map herders = new HashMap();
JSONObject jsonObjectParams = new JSONObject(); JSONObject jsonObjectParams = new JSONObject();
String[] device_type = {"6","20"}; String[] device_type = {"6","20"};
......
...@@ -7,10 +7,10 @@ import com.alibaba.fastjson.JSONObject; ...@@ -7,10 +7,10 @@ import com.alibaba.fastjson.JSONObject;
import com.founder.commonutils.model.newPublicEntity.SysUser; import com.founder.commonutils.model.newPublicEntity.SysUser;
import com.founder.commonutils.model.nmDataEntity.ParamsEntity.DataCodeConstant; import com.founder.commonutils.model.nmDataEntity.ParamsEntity.DataCodeConstant;
import com.founder.commonutils.model.nmDataEntity.ParamsEntity.NmDataEnum; import com.founder.commonutils.model.nmDataEntity.ParamsEntity.NmDataEnum;
import com.founder.commonutils.model.nmDataEntity.ParamsEntity.NmTokenUtils;
import com.founder.commonutils.model.nmDataEntity.ResultEntity.MyXsGxxx; import com.founder.commonutils.model.nmDataEntity.ResultEntity.MyXsGxxx;
import com.founder.commonutils.util.JsonUtils; import com.founder.commonutils.util.JsonUtils;
import com.founder.commonutils.util.NetworkUtil; import com.founder.commonutils.util.NetworkUtil;
import com.founder.commonutils.util.RedisTokenUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair; import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.entity.UrlEncodedFormEntity;
...@@ -35,7 +35,7 @@ import java.util.*; ...@@ -35,7 +35,7 @@ import java.util.*;
*/ */
@Component @Component
public class NmDataUtil { public class NmDataUtil {
private String dataUrl="http://26.13.101.72:8999/center_new";// 统一url private String dataUrl="http://26.3.111.234:8999/center_new";// 统一url
/** /**
* httpclient连接池对象 * httpclient连接池对象
...@@ -50,7 +50,7 @@ public class NmDataUtil { ...@@ -50,7 +50,7 @@ public class NmDataUtil {
Map paramsMap) { Map paramsMap) {
String url = dataUrl + nmDataEnum.getUrl(); String url = dataUrl + nmDataEnum.getUrl();
// 请求接口 // 请求接口
String resultString = getData(request, url,paramsMap); String resultString = getData(request, url,paramsMap,1);
JSONObject map = JSON.parseObject(resultString); JSONObject map = JSON.parseObject(resultString);
Object object = map.get(DataCodeConstant.MY_RETURN_DATA_CODE); Object object = map.get(DataCodeConstant.MY_RETURN_DATA_CODE);
// 返回处理 // 返回处理
...@@ -69,7 +69,7 @@ public class NmDataUtil { ...@@ -69,7 +69,7 @@ public class NmDataUtil {
} }
// 三方接口调用 // 三方接口调用
public String getData(HttpServletRequest request, String url,Map<String,String> paramsMap) { public String getData(HttpServletRequest request, String url,Map<String,String> paramsMap,int flag) {
System.out.println("中央厨房参数传入:" + url + JSON.toJSONString(paramsMap)); System.out.println("中央厨房参数传入:" + url + JSON.toJSONString(paramsMap));
// 入参处理 // 入参处理
List<NameValuePair> pairsData = new ArrayList<NameValuePair>(); List<NameValuePair> pairsData = new ArrayList<NameValuePair>();
...@@ -86,7 +86,7 @@ public class NmDataUtil { ...@@ -86,7 +86,7 @@ public class NmDataUtil {
CloseableHttpResponse response = null; CloseableHttpResponse response = null;
String resultString = ""; String resultString = "";
// token获取 // token获取
String token = NmTokenUtils.getToken(); String token = RedisTokenUtils.getDsjToken();
CloseableHttpClient httpClient = HttpClients.custom() CloseableHttpClient httpClient = HttpClients.custom()
.setConnectionManager(cm).build(); .setConnectionManager(cm).build();
try { try {
...@@ -107,11 +107,8 @@ public class NmDataUtil { ...@@ -107,11 +107,8 @@ public class NmDataUtil {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
System.out.println(e.getMessage()); System.out.println(e.getMessage());
} finally { if(flag<30){
try { return getData(request, url,paramsMap,flag+1);
response.close();
} catch (IOException e) {
e.printStackTrace();
} }
} }
return resultString; return resultString;
......
...@@ -10,7 +10,6 @@ import com.founder.commonutils.model.newPublicEntity.SysUser; ...@@ -10,7 +10,6 @@ import com.founder.commonutils.model.newPublicEntity.SysUser;
import com.founder.commonutils.model.newPublicEntity.hnkshEntity.*; import com.founder.commonutils.model.newPublicEntity.hnkshEntity.*;
import com.founder.commonutils.model.newPublicEntity.MapRestResult; import com.founder.commonutils.model.newPublicEntity.MapRestResult;
import com.founder.commonutils.model.nmDataEntity.NeiMengEntity.*; import com.founder.commonutils.model.nmDataEntity.NeiMengEntity.*;
import com.founder.commonutils.model.nmDataEntity.ParamsEntity.NmTokenUtils;
import com.founder.commonutils.util.*; import com.founder.commonutils.util.*;
import com.founder.publicapi.SkNmInterface.NmDataUtil; import com.founder.publicapi.SkNmInterface.NmDataUtil;
import com.founder.publicapi.mapper.oracleXzxtMapper.ZbFzxyrDataMapper; import com.founder.publicapi.mapper.oracleXzxtMapper.ZbFzxyrDataMapper;
...@@ -750,34 +749,34 @@ public class KshSlServiceController { ...@@ -750,34 +749,34 @@ public class KshSlServiceController {
String identitycard = sysUser.getIdentitycard();// 请求人证件 String identitycard = sysUser.getIdentitycard();// 请求人证件
String ipAddr = NetworkUtil.getIpAddr(request);// 请求人ip String ipAddr = NetworkUtil.getIpAddr(request);// 请求人ip
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
System.out.println("token=========" + NmTokenUtils.getToken()); System.out.println("token=========" + RedisTokenUtils.getDsjToken());
System.out.println("请求人姓名=========" + trueName); System.out.println("请求人姓名=========" + trueName);
System.out.println("请求人证件=========" + identitycard); System.out.println("请求人证件=========" + identitycard);
System.out.println("请求人ip=========" + ipAddr); System.out.println("请求人ip=========" + ipAddr);
System.out.println("当前登录用户的证件号=========" + sysUser.getIdentitycard()); System.out.println("当前登录用户的证件号=========" + sysUser.getIdentitycard());
System.out.println("当前用户的用户名=========" + sysUser.getTrueName()); System.out.println("当前用户的用户名=========" + sysUser.getTrueName());
map.put("Authorization", NmTokenUtils.getToken()); map.put("Authorization", RedisTokenUtils.getDsjToken());
map.put("user-cert", sysUser.getIdentitycard());//当前登录用户的证件号(比如身份证) map.put("user-cert", sysUser.getIdentitycard());//当前登录用户的证件号(比如身份证)
map.put("user-username", sysUser.getTrueName());//当前用户的用户名 map.put("user-username", sysUser.getTrueName());//当前用户的用户名
return map; return map;
} }
public String JPGX = "http://26.13.101.72:8999/center_new/004/001"; public String JPGX = "http://26.3.111.234:8999/center_new/004/001";
public String TZGX = "http://26.13.101.72:8999/center_new/004/002"; public String TZGX = "http://26.3.111.234:8999/center_new/004/002";
public String TAGX = "http://26.13.101.72:8999/center_new/004/004"; public String TAGX = "http://26.3.111.234:8999/center_new/004/004";
public String SHGX = "http://26.13.101.72:8999/center_new/004/005"; public String SHGX = "http://26.3.111.234:8999/center_new/004/005";
public String TLGX = "http://26.13.101.72:8999/center_new/004/003"; public String TLGX = "http://26.3.111.234:8999/center_new/004/003";
public String XSGX = "http://26.13.101.72:8999/center_new/005/001"; public String XSGX = "http://26.3.111.234:8999/center_new/005/001";
public String SMGL = "http://26.13.101.72:8999/center_new/005/002"; public String SMGL = "http://26.3.111.234:8999/center_new/005/002";
public String TLFX = "http://26.13.101.72:8999/center_new/006/008"; public String TLFX = "http://26.3.111.234:8999/center_new/006/008";
public String JDFX = "http://26.13.101.72:8999/center_new/006/002"; public String JDFX = "http://26.3.111.234:8999/center_new/006/002";
public String RZFX = "http://26.13.101.72:8999/center_new/006/003"; public String RZFX = "http://26.3.111.234:8999/center_new/006/003";
public String CRJFX = "http://26.13.101.72:8999/center_new/006/004"; public String CRJFX = "http://26.3.111.234:8999/center_new/006/004";
public String CXFX = "http://26.13.101.72:8999/center_new/006/005"; public String CXFX = "http://26.3.111.234:8999/center_new/006/005";
public String TXFX = "http://26.13.101.72:8999/center_new/006/007"; public String TXFX = "http://26.3.111.234:8999/center_new/006/007";
public String AJDA = "http://26.13.101.72:8999/center_new/001/006";//案件档案 public String AJDA = "http://26.3.111.234:8999/center_new/001/006";//案件档案
public String WPDA = "http://26.13.101.72:8999/center_new/001/003";//物品档案 public String WPDA = "http://26.3.111.234:8999/center_new/001/003";//物品档案
//通过身份证号查询人员亲属关系信息 //通过身份证号查询人员亲属关系信息
...@@ -2554,7 +2553,7 @@ public class KshSlServiceController { ...@@ -2554,7 +2553,7 @@ public class KshSlServiceController {
} }
public String RYDA = "http://26.13.101.72:8999/center_new/001/001"; public String RYDA = "http://26.3.111.234:8999/center_new/001/001";
//根据身份证获取照片 //根据身份证获取照片
public Map<String, String> getPhoto(String zjhm, HttpServletRequest request) { public Map<String, String> getPhoto(String zjhm, HttpServletRequest request) {
......
...@@ -55,7 +55,7 @@ public class SkRxController extends ApiController { ...@@ -55,7 +55,7 @@ public class SkRxController extends ApiController {
faceRxbdSearchParam.setImage(dataImage); faceRxbdSearchParam.setImage(dataImage);
faceRxbdSearchParam.setThreshold(Integer.valueOf(sktrailParam.getXsd())); faceRxbdSearchParam.setThreshold(Integer.valueOf(sktrailParam.getXsd()));
// 接口调用 // 接口调用
String token = TokenUtils.getYtgsToken(); String token = RedisTokenUtils.getZgToken();
Map herders = new HashMap(); Map herders = new HashMap();
List<Map<String, Object>> list = new ArrayList<>(); List<Map<String, Object>> list = new ArrayList<>();
...@@ -100,7 +100,7 @@ public class SkRxController extends ApiController { ...@@ -100,7 +100,7 @@ public class SkRxController extends ApiController {
// 身份稽查名单库查询 // 身份稽查名单库查询
public List<FaceRxbdSearchParam.mdkList> getSfyck()throws Exception{ public List<FaceRxbdSearchParam.mdkList> getSfyck()throws Exception{
// 接口调用 // 接口调用
String token = TokenUtils.getYtgsToken(); String token = RedisTokenUtils.getZgToken();
Map herders = new HashMap(); Map herders = new HashMap();
List<FaceRxbdSearchParam.mdkList> list = new ArrayList<>(); List<FaceRxbdSearchParam.mdkList> list = new ArrayList<>();
JSONObject jsonObjectParams = new JSONObject(); JSONObject jsonObjectParams = new JSONObject();
......
...@@ -497,7 +497,7 @@ public class SkTrailController extends ApiController implements ExcelControllerI ...@@ -497,7 +497,7 @@ public class SkTrailController extends ApiController implements ExcelControllerI
faceSearchParam.setEnd_time(Long.valueOf(DateUtil.getTimeStamp(sktrailParam.getJssj()))); faceSearchParam.setEnd_time(Long.valueOf(DateUtil.getTimeStamp(sktrailParam.getJssj())));
faceSearchParam.setThreshold(Integer.valueOf(sktrailParam.getXsd())); faceSearchParam.setThreshold(Integer.valueOf(sktrailParam.getXsd()));
// 接口调用 // 接口调用
String token = TokenUtils.getYtgsToken(); String token = RedisTokenUtils.getZgToken();
Map herders = new HashMap(); Map herders = new HashMap();
// 设置请求的header参数 // 设置请求的header参数
herders.put("Authorization", token); herders.put("Authorization", token);
......
...@@ -10,10 +10,7 @@ import com.founder.commonutils.model.newPublicEntity.SkRegionalsResultAll; ...@@ -10,10 +10,7 @@ import com.founder.commonutils.model.newPublicEntity.SkRegionalsResultAll;
import com.founder.commonutils.model.newPublicEntity.SkRegionalsResultFl; import com.founder.commonutils.model.newPublicEntity.SkRegionalsResultFl;
import com.founder.commonutils.model.nmDataEntity.ParamsEntity.FaceJghSearchParam; import com.founder.commonutils.model.nmDataEntity.ParamsEntity.FaceJghSearchParam;
import com.founder.commonutils.model.vo.param.*; import com.founder.commonutils.model.vo.param.*;
import com.founder.commonutils.util.DateUtil; import com.founder.commonutils.util.*;
import com.founder.commonutils.util.HttpClient;
import com.founder.commonutils.util.JsonUtils;
import com.founder.commonutils.util.TokenUtils;
import com.founder.publicapi.mapper.mysqlMapper.SkPointlocationMapper; import com.founder.publicapi.mapper.mysqlMapper.SkPointlocationMapper;
import com.founder.publicapi.mapper.mysqlMapper.SkRegionalsResultMapper; import com.founder.publicapi.mapper.mysqlMapper.SkRegionalsResultMapper;
import com.founder.publicapi.mapper.mysqlMapper.SkRegionalsTaskMapper; import com.founder.publicapi.mapper.mysqlMapper.SkRegionalsTaskMapper;
...@@ -747,7 +744,7 @@ public class SkRegionalsResultServiceImpl extends ServiceImpl<SkRegionalsResultM ...@@ -747,7 +744,7 @@ public class SkRegionalsResultServiceImpl extends ServiceImpl<SkRegionalsResultM
// 分页处理 // 分页处理
faceJghSearchParam.setPage(faceJghSearchParamPage); faceJghSearchParam.setPage(faceJghSearchParamPage);
// 接口调用 // 接口调用
String token = TokenUtils.getYtgsToken(); String token = RedisTokenUtils.getZgToken();
Map herders = new HashMap(); Map herders = new HashMap();
// 设置请求的header参数 // 设置请求的header参数
......
...@@ -35,6 +35,12 @@ spring.datasource.mysql.username=skyp ...@@ -35,6 +35,12 @@ spring.datasource.mysql.username=skyp
spring.datasource.mysql.password=skyp spring.datasource.mysql.password=skyp
spring.datasource.mysql.type=com.alibaba.druid.pool.DruidDataSource spring.datasource.mysql.type=com.alibaba.druid.pool.DruidDataSource
#redis
spring.redis.host=localhost
spring.redis.port=6378
spring.redis.password=123
spring.redis.database=6
#\u5377\u5B97\u4E0A\u4F20\u7684\u8DEF\u5F84 #\u5377\u5B97\u4E0A\u4F20\u7684\u8DEF\u5F84
approvalFilePath = /data/excel/approvalWord/ approvalFilePath = /data/excel/approvalWord/
#\u65B0\u589E\u5377\u5B97\u5927\u6570\u636E\u6A21\u578B\u4E0B\u8F7D\u8DEF\u5F84 #\u65B0\u589E\u5377\u5B97\u5927\u6570\u636E\u6A21\u578B\u4E0B\u8F7D\u8DEF\u5F84
......
...@@ -35,6 +35,12 @@ spring.datasource.mysql.username=skyp ...@@ -35,6 +35,12 @@ spring.datasource.mysql.username=skyp
spring.datasource.mysql.password=skyp spring.datasource.mysql.password=skyp
spring.datasource.mysql.type=com.alibaba.druid.pool.DruidDataSource spring.datasource.mysql.type=com.alibaba.druid.pool.DruidDataSource
#redis
spring.redis.host=10.100.17.124
spring.redis.port=9379
spring.redis.password=bjhlxt@2020
spring.redis.database=6
#\u5377\u5B97\u4E0A\u4F20\u7684\u8DEF\u5F84 #\u5377\u5B97\u4E0A\u4F20\u7684\u8DEF\u5F84
approvalFilePath = /data/excel/approvalWord/ approvalFilePath = /data/excel/approvalWord/
#\u65B0\u589E\u5377\u5B97\u5927\u6570\u636E\u6A21\u578B\u4E0B\u8F7D\u8DEF\u5F84 #\u65B0\u589E\u5377\u5B97\u5927\u6570\u636E\u6A21\u578B\u4E0B\u8F7D\u8DEF\u5F84
......
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