Commit 49c43cd2 authored by KeYong's avatar KeYong

Merge remote-tracking branch 'origin/develop_dl_bugfix_0723' into develop_dl_bugfix_0723

parents 88e7d2da cc9a951d
...@@ -62,182 +62,7 @@ public class HttpUtils { ...@@ -62,182 +62,7 @@ public class HttpUtils {
requestConfig = configBuilder.build(); requestConfig = configBuilder.build();
} }
/**
* 发送 GET 请求(HTTP),不带输入数据
*
* @param url
* @return
*/
public static String doGet(String url) {
return doGet(url, new HashMap<String, Object>());
}
/**
* 发送 GET 请求(HTTP),K-V形式
*
* @param url
* @param params
* @return
*/
public static String doGet(String url, Map<String, Object> params) {
String apiUrl = url;
StringBuffer param = new StringBuffer();
int i = 0;
for (String key : params.keySet()) {
if (i == 0)
param.append("?");
else
param.append("&");
param.append(key).append("=").append(params.get(key));
i++;
}
apiUrl += param;
String result = null;
HttpClient httpClient = null;
if (apiUrl.startsWith("https")) {
httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory())
.setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build();
} else {
httpClient = HttpClients.createDefault();
}
try {
HttpGet httpGet = new HttpGet(apiUrl);
HttpResponse response = httpClient.execute(httpGet);
HttpEntity entity = response.getEntity();
if (entity != null) {
InputStream instream = entity.getContent();
result = IOUtils.toString(instream, "UTF-8");
}
} catch (IOException e) {
e.printStackTrace();
}
return result;
}
/**
* 发送 POST 请求(HTTP),不带输入数据
*
* @param apiUrl
* @return
*/
public static String doPost(String apiUrl) {
return doPost(apiUrl, new HashMap<String, Object>());
}
/**
* 发送 POST 请求,K-V形式
*
* @param apiUrl
* API接口URL
* @param params
* 参数map
* @return
*/
public static String doPost(String apiUrl, Map<String, Object> params) {
CloseableHttpClient httpClient = null;
if (apiUrl.startsWith("https")) {
httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory())
.setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build();
} else {
httpClient = HttpClients.createDefault();
}
String httpStr = null;
HttpPost httpPost = new HttpPost(apiUrl);
CloseableHttpResponse response = null;
try {
httpPost.setConfig(requestConfig);
List<NameValuePair> pairList = new ArrayList<>(params.size());
for (Map.Entry<String, Object> entry : params.entrySet()) {
NameValuePair pair = new BasicNameValuePair(entry.getKey(), entry.getValue()!=null?entry.getValue().toString():"");
pairList.add(pair);
}
httpPost.setEntity(new UrlEncodedFormEntity(pairList, Charset.forName("UTF-8")));
response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
httpStr = EntityUtils.toString(entity, "UTF-8");
} catch (IOException e) {
e.printStackTrace();
} finally {
if (response != null) {
try {
EntityUtils.consume(response.getEntity());
} catch (IOException e) {
e.printStackTrace();
}
}
}
return httpStr;
}
/**
* 发送 POST 请求,JSON形式,接收端需要支持json形式,否则取不到数据
*
* @param apiUrl
* @param json
* json对象
* @return
*/
public static String doPost(String apiUrl, String json) {
CloseableHttpClient httpClient = null;
if (apiUrl.startsWith("https")) {
httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory()).setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build();
} else {
httpClient = HttpClients.createDefault();
}
String httpStr = null;
HttpPost httpPost = new HttpPost(apiUrl);
CloseableHttpResponse response = null;
try {
httpPost.setConfig(requestConfig);
StringEntity stringEntity = new StringEntity(json, "UTF-8");// 解决中文乱码问题
stringEntity.setContentEncoding("UTF-8");
stringEntity.setContentType("application/json");
httpPost.setEntity(stringEntity);
response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
httpStr = EntityUtils.toString(entity, "UTF-8");
} catch (IOException e) {
e.printStackTrace();
} finally {
if (response != null) {
try {
EntityUtils.consume(response.getEntity());
} catch (IOException e) {
e.printStackTrace();
}
}
}
return httpStr;
}
/**
* 创建SSL安全连接
*
* @return
*/
private static SSLConnectionSocketFactory createSSLConnSocketFactory() {
SSLConnectionSocketFactory sslsf = null;
try {
SSLContext sslContext = new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() {
public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException {
return true;
}
}).build();
sslsf = new SSLConnectionSocketFactory(sslContext, new HostnameVerifier() {
@Override
public boolean verify(String arg0, SSLSession arg1) {
return true;
}
});
} catch (GeneralSecurityException e) {
e.printStackTrace();
}
return sslsf;
}
......
...@@ -1664,6 +1664,7 @@ ...@@ -1664,6 +1664,7 @@
GROUP BY GROUP BY
a.sequenceNbr a.sequenceNbr
ORDER BY a.personStatus DESC ORDER BY a.personStatus DESC
LIMIT #{map.pageNum}, #{map.pageSize} LIMIT #{map.pageNum}, #{map.pageSize}
</select> </select>
...@@ -1718,6 +1719,7 @@ ...@@ -1718,6 +1719,7 @@
a.biz_org_name IS NOT NULL a.biz_org_name IS NOT NULL
AND a.is_delete = 0 AND a.is_delete = 0
AND a.biz_org_type = 'PERSON' AND a.biz_org_type = 'PERSON'
and fp.is_delete = 0
<if test='bizOrgCode!=null and bizOrgCode!=""'>and LEFT(a.biz_org_code,18) like concat (#{bizOrgCode},'%')</if> <if test='bizOrgCode!=null and bizOrgCode!=""'>and LEFT(a.biz_org_code,18) like concat (#{bizOrgCode},'%')</if>
<if test='peopleTypeCode != null and peopleTypeCode != ""'>and a.peopleType like concat ('%', #{peopleTypeCode},'%')</if> <if test='peopleTypeCode != null and peopleTypeCode != ""'>and a.peopleType like concat ('%', #{peopleTypeCode},'%')</if>
</select> </select>
...@@ -1841,7 +1843,7 @@ ...@@ -1841,7 +1843,7 @@
AND a.is_delete = 0 AND a.is_delete = 0
AND a.biz_org_type = 'PERSON' AND a.biz_org_type = 'PERSON'
AND fp.is_delete = 0 AND fp.is_delete = 0
AND LENGTH( a.biz_org_code ) = 18 AND LENGTH( a.biz_org_code ) > 18
<if test='bizOrgCode!=null and bizOrgCode!=""'> <if test='bizOrgCode!=null and bizOrgCode!=""'>
and LEFT(a.biz_org_code,18) like concat (#{bizOrgCode},'%') and LEFT(a.biz_org_code,18) like concat (#{bizOrgCode},'%')
</if> </if>
......
...@@ -82,6 +82,18 @@ public class PluginInterceptor implements Interceptor { ...@@ -82,6 +82,18 @@ public class PluginInterceptor implements Interceptor {
ReflectionUtils.makeAccessible(field); ReflectionUtils.makeAccessible(field);
field.set(boundSql, sql); field.set(boundSql, sql);
return executor.query(mappedStatement, parameter, rowBounds, resultHandler, cacheKey, boundSql); return executor.query(mappedStatement, parameter, rowBounds, resultHandler, cacheKey, boundSql);
} else if ("com.yeejoin.equipmanage.mapper.FireFightingSystemMapper.getSystemInfoPage".equals(id)) {
//执行结果
String sortField = "";
if (parameter instanceof HashMap) {
sortField = ((HashMap<?, ?>) parameter).get("sortField").toString();
}
sql = sql.replace("_sortField", sortField);
//通过反射修改sql语句
Field field = boundSql.getClass().getDeclaredField("sql");
ReflectionUtils.makeAccessible(field);
field.set(boundSql, sql);
return executor.query(mappedStatement, parameter, rowBounds, resultHandler, cacheKey, boundSql);
} else { } else {
return invocation.proceed(); return invocation.proceed();
} }
......
package com.yeejoin.equipmanage.common.utils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustStrategy;
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.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.ssl.SSLContexts;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.Assert;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URISyntaxException;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* @description: http https工具类 原生
* @author: duanwei
* @create: 2019-06-03 11:19
**/
public class HttpUtil {
private static final Logger log = LoggerFactory.getLogger(HttpUtil.class);
// 连接超时时间
public static final int CONNECTION_TIMEOUT = 5000;
// 请求超时时间
public static final int CONNECTION_REQUEST_TIMEOUT = 5000;
// 数据读取等待超时
public static final int SOCKET_TIMEOUT = 10000;
// http
public static final String HTTP = "http";
// https
public static final String HTTPS = "https";
// http端口
public static final int DEFAULT_HTTP_PORT = 80;
// https端口
public static final int DEFAULT_HTTPS_PORT = 443;
// 默认编码
public static final String DEFAULT_ENCODING = "UTF-8";
/**
* get请求(1.处理http请求;2.处理https请求,信任所有证书)[默认编码:UTF-8]
*
* @param url (参数直接拼接到URL后面,即http://test.com?a=1&b=2的形式)
* @return
*/
public static String get(String url) throws IOException, URISyntaxException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
return get(url, null, DEFAULT_ENCODING);
}
/**
* get请求(1.处理http请求;2.处理https请求,信任所有证书)[默认编码:UTF-8]
*
* @param url (url不带参数,例:http://test.com)
* @param reqMap (参数放置到一个map中)
* @return
*/
public static String get(String url, Map<String, Object> reqMap) throws IOException, URISyntaxException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
return get(url, reqMap, DEFAULT_ENCODING);
}
/**
* 根据请求头选择相应的client
* https HttpUtil.createSSLInsecureClient
* http createDefault
* @param url (url不带参数,例:http://test.com)
* @return CloseableHttpClient
*/
public static CloseableHttpClient getHttpClient(String url){
CloseableHttpClient httpClient = null;
try {
if (url.startsWith(HTTPS)) {
// 创建一个SSL信任所有证书的httpClient对象
httpClient = HttpUtil.createSSLInsecureClient();
} else {
httpClient = HttpClients.createDefault();
}
}catch (Exception e){
log.error("请求client 初始化失败 请检查地址是否正确,url={}",url,e);
throw new RuntimeException(e);
}
return httpClient;
}
/**
* 获取post请求头
* @param url (url不带参数,例:http://test.com)
* @return HttpPost
*/
public static HttpPost getHttpPost(String url)
{
HttpPost httpPost = new HttpPost(url);
RequestConfig requestConfig = RequestConfig.custom()
.setConnectTimeout(CONNECTION_TIMEOUT)
.setConnectionRequestTimeout(CONNECTION_REQUEST_TIMEOUT)
.setSocketTimeout(SOCKET_TIMEOUT)
.setRedirectsEnabled(true)
.build();
httpPost.setConfig(requestConfig);
return httpPost;
}
/**
* get请求(1.处理http请求;2.处理https请求,信任所有证书)
*
* @param url (只能是http或https请求)
* @param encoding
* @return
*/
public static String get(String url, Map<String, Object> reqMap, String encoding) throws IOException, URISyntaxException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
Assert.hasText(url, "url invalid");
String result = "";
// 处理参数
List<NameValuePair> params = buildParams(reqMap);
CloseableHttpResponse response = null;
HttpGet httpGet;
CloseableHttpClient httpClient=null;
try {
httpClient=getHttpClient(url);
if (params != null && params.size() > 0) {
URIBuilder builder = new URIBuilder(url);
builder.setParameters(params);
httpGet = new HttpGet(builder.build());
} else {
httpGet = new HttpGet(url);
}
RequestConfig requestConfig = RequestConfig.custom()
.setConnectTimeout(CONNECTION_TIMEOUT)
.setConnectionRequestTimeout(CONNECTION_REQUEST_TIMEOUT)
.setSocketTimeout(SOCKET_TIMEOUT)
//默认允许自动重定向
.setRedirectsEnabled(true)
.build();
httpGet.setConfig(requestConfig);
// 发送请求,并接收响应
response = httpClient.execute(httpGet);
result = handleResponse(url, encoding, response);
} finally {
ExtendedIOUtils.closeQuietly(httpClient);
ExtendedIOUtils.closeQuietly(response);
}
return result;
}
/**
* post请求(1.处理http请求;2.处理https请求,信任所有证书)[默认编码:UTF-8]
*
* @param url
* @param reqMap
* @return
*/
public static String post(String url, Map<String, Object> reqMap) throws IOException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
return post(url, reqMap, DEFAULT_ENCODING);
}
/**
* post请求(1.处理http请求;2.处理https请求,信任所有证书)
*
* @param url
* @param reqMap 入参是个map
* @param encoding
* @return
*/
public static String post(String url, Map<String, Object> reqMap, String encoding) throws IOException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
Assert.hasText(url, "url invalid");
String result="";
// 添加参数
List<NameValuePair> params = buildParams(reqMap);
CloseableHttpClient httpClient=null;
CloseableHttpResponse response = null;
try {
httpClient=getHttpClient(url);
HttpPost httpPost = getHttpPost(url);
httpPost.setHeader("Content-type", "application/x-www-form-urlencoded");
httpPost.setEntity(new UrlEncodedFormEntity(params, encoding));
// 发送请求,并接收响应
response = httpClient.execute(httpPost);
result = handleResponse(url, encoding, response);
log.info("http调用完成,返回数据:{}", result);
}finally {
ExtendedIOUtils.closeQuietly(httpClient);
ExtendedIOUtils.closeQuietly(response);
}
return result;
}
/**
* post请求(1.处理http请求;2.处理https请求,信任所有证书)
*
* @param url
* @param jsonParams 入参是个json字符串
* @return
*/
public static String post(String url, String jsonParams) throws IOException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
log.info("----->调用请求 url:{} ---->json参数:{}",url,jsonParams);
return post(url, jsonParams, DEFAULT_ENCODING);
}
/**
* post请求(1.处理http请求;2.处理https请求,信任所有证书)
*
* @param url
* @param jsonParams 入参是个json字符串
* @param encoding
* @return
*/
public static String post(String url, String jsonParams, String encoding) throws IOException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
Assert.hasText(url, "url invalid");
String result;
CloseableHttpClient httpClient;
if (url.startsWith(HTTPS)) {
// 创建一个SSL信任所有证书的httpClient对象
httpClient = HttpUtil.createSSLInsecureClient();
} else {
httpClient = HttpClients.createDefault();
}
CloseableHttpResponse response = null;
try {
HttpPost httpPost = getHttpPost(url);
httpPost.setHeader("Content-Type", "application/json");
httpPost.setEntity(new StringEntity(jsonParams, ContentType.create("application/json", encoding)));
// 发送请求,并接收响应
response = httpClient.execute(httpPost);
result = handleResponse(url, encoding, response);
// result= JSONObject.parseObject(result).getString("data");
} finally {
ExtendedIOUtils.closeQuietly(httpClient);
ExtendedIOUtils.closeQuietly(response);
}
return result;
}
/**
* 创建一个SSL信任所有证书的httpClient对象
*
* @return
*/
public static CloseableHttpClient createSSLInsecureClient() throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException {
// 默认信任所有证书
HostnameVerifier hostnameVerifier = (hostname, session) -> true;
SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(null, (TrustStrategy) (chain, authType) -> true).build();
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(sslContext, hostnameVerifier);
return HttpClients.custom().setSSLSocketFactory(sslConnectionSocketFactory).build();
}
/**
* 处理响应,获取响应报文
*
* @param url
* @param encoding
* @param response
* @return
* @throws IOException
*/
private static String handleResponse(String url, String encoding, CloseableHttpResponse response) throws IOException {
StringBuilder sb = new StringBuilder();
BufferedReader br = null;
try {
if (response != null) {
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
// 获取响应实体
HttpEntity entity = response.getEntity();
if (entity != null) {
br = new BufferedReader(new InputStreamReader(entity.getContent(), encoding));
String s;
while ((s = br.readLine()) != null) {
sb.append(s);
}
}
// 释放entity
EntityUtils.consume(entity);
} else if (response.getStatusLine().getStatusCode() == HttpStatus.SC_NOT_FOUND) {
log.info("-----> get请求404,未找到资源. url:" + url);
} else if (response.getStatusLine().getStatusCode() == HttpStatus.SC_INTERNAL_SERVER_ERROR) {
log.info("-----> get请求500,服务器端异常. url:" + url);
}
}
} finally {
ExtendedIOUtils.closeQuietly(br);
}
return sb.toString();
}
/**
* 采用绕过验证的方式处理https请求
*
* @param url
* @param reqMap
* @param encoding
* @return
*/
public static String postSSLUrl(String url, Map<String, Object> reqMap, String encoding) throws IOException, KeyManagementException, NoSuchAlgorithmException, KeyStoreException {
String result;
CloseableHttpClient httpClient = null;
CloseableHttpResponse response = null;
// 添加参数
List<NameValuePair> params = buildParams(reqMap);
try {
//采用绕过验证的方式处理https请求
HostnameVerifier hostnameVerifier = (hostname, session) -> true;
SSLContext sslcontext = createIgnoreVerifySSL();
//设置协议http和https对应的处理socket链接工厂的对象
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
.register("http", PlainConnectionSocketFactory.INSTANCE)
.register("https", new SSLConnectionSocketFactory(sslcontext, hostnameVerifier))
.build();
PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
//创建自定义的httpclient对象
httpClient = HttpClients.custom().setConnectionManager(connManager).build();
//创建post方式请求对象
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(params, encoding));
//指定报文头Content-type、User-Agent
httpPost.setHeader("Content-type", "application/x-www-form-urlencoded");
//执行请求操作,并拿到结果(同步阻塞)
response = httpClient.execute(httpPost);
result = handleResponse(url, encoding, response);
} finally {
ExtendedIOUtils.closeQuietly(httpClient);
ExtendedIOUtils.closeQuietly(response);
}
return result;
}
private static List<NameValuePair> buildParams(Map<String, Object> reqMap) {
List<NameValuePair> params = new ArrayList<>();
if (reqMap != null && reqMap.keySet().size() > 0) {
Iterator<Map.Entry<String, Object>> iter = reqMap.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry<String, Object> entity = iter.next();
params.add(new BasicNameValuePair(entity.getKey(), entity.getValue().toString()));
}
}
return params;
}
/**
* 绕过验证
*
* @return
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
public static SSLContext createIgnoreVerifySSL() throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException {
// 信任所有证书
return new SSLContextBuilder().loadTrustMaterial(null, (TrustStrategy) (arg0, arg1) -> true).build();
}
}
package com.yeejoin.equipmanage.common.utils;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.equipmanage.common.config.GlobalCache;
import com.yeejoin.equipmanage.common.vo.ResponeVo;
import org.apache.http.NameValuePair;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.*;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustStrategy;
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.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.ssl.SSLContexts;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.Assert;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* @description: HTTP HTTPS 二次封装
* @author: duanwei
* @create: 2020-05-28 13:57
**/
public class HttpUtils {
private static final Logger log = LoggerFactory.getLogger(HttpUtils.class);
// 连接超时时间
public static final int CONNECTION_TIMEOUT = 5000;
// 请求超时时间
public static final int CONNECTION_REQUEST_TIMEOUT = 5000;
// 数据读取等待超时
public static final int SOCKET_TIMEOUT = 10000;
// http
public static final String HTTP = "http";
// https
public static final String HTTPS = "https";
// http端口
public static final int DEFAULT_HTTP_PORT = 80;
// https端口
public static final int DEFAULT_HTTPS_PORT = 443;
// 默认编码
public static final String DEFAULT_ENCODING = "UTF-8";
/**
* 根据请求头选择相应的client
* https HttpUtil.createSSLInsecureClient
* http createDefault
*
* @param url (url不带参数,例:http://test.com)
* @return CloseableHttpClient
*/
private static CloseableHttpClient getHttpClient(String url) {
CloseableHttpClient httpClient = null;
try {
if (url.startsWith(HTTPS)) {
// 创建一个SSL信任所有证书的httpClient对象
httpClient = HttpUtils.createSSLInsecureClient();
} else {
httpClient = HttpClients.createDefault();
}
} catch (Exception e) {
log.error("请求client 初始化失败 请检查地址是否正确,url=" + url + " error" + e);
throw new RuntimeException(e);
}
return httpClient;
}
/**
* 获取post请求头
*
* @param url (url不带参数,例:http://test.com)
* @return HttpPost
*/
public static HttpPost getHttpPost(String url) {
HttpPost httpPost = new HttpPost(url);
RequestConfig requestConfig = RequestConfig.custom()
.setConnectTimeout(CONNECTION_TIMEOUT)
.setConnectionRequestTimeout(CONNECTION_REQUEST_TIMEOUT)
.setSocketTimeout(SOCKET_TIMEOUT)
.setRedirectsEnabled(true)
.build();
httpPost.setConfig(requestConfig);
return httpPost;
}
/**
* get请求(1.处理http请求;2.处理https请求,信任所有证书)
*
* @param url (只能是http或https请求)
*/
public static ResponeVo get(String url) throws IOException {
log.info("----->调用请求 url:" + url);
String result = "";
// 处理参数
HttpGet httpGet;
CloseableHttpClient httpClient = null;
httpClient = getHttpClient(url);
httpGet = new HttpGet(url);
//加入请求头
if (GlobalCache.header != null) {
for (String key : GlobalCache.header.keySet()) {
String value = GlobalCache.header.get(key);
httpGet.setHeader(key, value);
}
}
//加入全局请求令牌权限
httpGet.setHeader("Http-Authorization", GlobalCache.paramMap.get("token"));
RequestConfig requestConfig = RequestConfig.custom()
.setConnectTimeout(CONNECTION_TIMEOUT)
.setConnectionRequestTimeout(CONNECTION_REQUEST_TIMEOUT)
.setSocketTimeout(SOCKET_TIMEOUT)
//默认允许自动重定向
.setRedirectsEnabled(true)
.build();
httpGet.setConfig(requestConfig);
return baseRequest(httpClient, httpGet);
}
/**
* post请求(1.处理http请求;2.处理https请求,信任所有证书)
*
* @param url
* @param jsonParams 入参是个json字符串
* @return
*/
public static ResponeVo post(String url, String jsonParams) throws IOException,
NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
Assert.hasText(url, "url invalid");
String result;
CloseableHttpClient httpClient;
if (url.startsWith(HTTPS)) {
// 创建一个SSL信任所有证书的httpClient对象
httpClient = HttpUtils.createSSLInsecureClient();
} else {
httpClient = HttpClients.createDefault();
}
CloseableHttpResponse response = null;
HttpPost httpPost = getHttpPost(url);
if (GlobalCache.header != null && !GlobalCache.header.isEmpty()) {
for (String key : GlobalCache.header.keySet()) {
String value = GlobalCache.header.get(key);
httpPost.setHeader(key, value);
}
} else {
GlobalCache.header.put("Content-Type", "application/json;charset=UTF-8");
}
//加入全局请求令牌权限
httpPost.setHeader("Http-Authorization", GlobalCache.paramMap.get("token"));
if (GlobalCache.header.get("Content-Type") != null) {
String contentType = GlobalCache.header.get("Content-Type");
if ("application/x-www-form-urlencoded".equals(contentType)) {
JSONObject jsonObject = JSONObject.parseObject(jsonParams);
List<NameValuePair> params = new ArrayList<>();
//循环json key value 仅能解决正常对象 若Json对象中嵌套数组 则可能需要单独处理
if (jsonObject != null) {
for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
params.add(new BasicNameValuePair(entry.getKey(), entry.getValue().toString()));
}
httpPost.setEntity(new UrlEncodedFormEntity(params, DEFAULT_ENCODING));
}
}
if ("application/json;charset=UTF-8".equals(contentType)) {
httpPost.setEntity(new StringEntity(jsonParams, ContentType.create("application/json", DEFAULT_ENCODING)));
}
} else {
log.error("请求头为空");
}
return baseRequest(httpClient, httpPost);
}
/**
* post请求(1.处理http请求;2.处理https请求,信任所有证书)
*
* @param url
* @param jsonParams 入参是个json字符串
* @return
*/
public static ResponeVo post(String url, String jsonParams, Map<String, String> headerMap) throws IOException,
NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
Assert.hasText(url, "url invalid");
String result;
CloseableHttpClient httpClient;
if (url.startsWith(HTTPS)) {
// 创建一个SSL信任所有证书的httpClient对象
httpClient = HttpUtils.createSSLInsecureClient();
} else {
httpClient = HttpClients.createDefault();
}
CloseableHttpResponse response = null;
HttpPost httpPost = getHttpPost(url);
if (GlobalCache.header != null && !GlobalCache.header.isEmpty()) {
for (String key : GlobalCache.header.keySet()) {
String value = GlobalCache.header.get(key);
httpPost.setHeader(key, value);
}
} else {
GlobalCache.header.put("Content-Type", "application/json;charset=UTF-8");
}
//加入全局请求令牌权限
if (!headerMap.isEmpty()) {
for (Map.Entry<String, String> entry : headerMap.entrySet()) {
httpPost.setHeader(entry.getKey(), entry.getValue());
}
} else {
httpPost.setHeader("Http-Authorization", GlobalCache.paramMap.get("token"));
}
if (GlobalCache.header.get("Content-Type") != null) {
String contentType = GlobalCache.header.get("Content-Type");
if ("application/x-www-form-urlencoded".equals(contentType)) {
JSONObject jsonObject = JSONObject.parseObject(jsonParams);
List<NameValuePair> params = new ArrayList<>();
//循环json key value 仅能解决正常对象 若Json对象中嵌套数组 则可能需要单独处理
if (jsonObject != null) {
for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
params.add(new BasicNameValuePair(entry.getKey(), entry.getValue().toString()));
}
httpPost.setEntity(new UrlEncodedFormEntity(params, DEFAULT_ENCODING));
}
}
if ("application/json;charset=UTF-8".equals(contentType)) {
httpPost.setEntity(new StringEntity(jsonParams, ContentType.create("application/json", DEFAULT_ENCODING)));
}
} else {
log.error("请求头为空");
}
return baseRequest(httpClient, httpPost);
}
/**
* get请求(1.处理http请求;2.处理https请求,信任所有证书)
*
* @param url (只能是http或https请求)
* @return
*/
public static ResponeVo delete(String url) throws IOException, NoSuchAlgorithmException,
KeyStoreException, KeyManagementException {
CloseableHttpClient httpClient = null;
CloseableHttpResponse response = null;
if (url.startsWith(HTTPS)) {
// 创建一个SSL信任所有证书的httpClient对象
httpClient = HttpUtils.createSSLInsecureClient();
} else {
httpClient = HttpClients.createDefault();
}
HttpDelete httpDelete = new HttpDelete(url);
if (GlobalCache.header != null) {
for (String key : GlobalCache.header.keySet()) {
String value = GlobalCache.header.get(key);
httpDelete.setHeader(key, value);
}
}
httpDelete.setHeader("Http-Authorization", GlobalCache.paramMap.get("token"));
return baseRequest(httpClient, httpDelete);
}
/**
* get请求(1.处理http请求;2.处理https请求,信任所有证书)
*
* @param url (只能是http或https请求)
* @return
*/
public static ResponeVo put(String url, String jsonParams) throws IOException, NoSuchAlgorithmException,
KeyStoreException, KeyManagementException {
log.info("----->调用请求 url:" + url + " ---->json参数:" + jsonParams);
CloseableHttpClient httpClient = null;
String content;
if (url.startsWith(HTTPS)) {
// 创建一个SSL信任所有证书的httpClient对象
httpClient = HttpUtils.createSSLInsecureClient();
} else {
httpClient = HttpClients.createDefault();
}
CloseableHttpResponse response = null;
HttpPut httpPut = new HttpPut(url);
if (GlobalCache.header != null) {
for (String key : GlobalCache.header.keySet()) {
String value = GlobalCache.header.get(key);
httpPut.setHeader(key, value);
}
}
//加入全局请求令牌权限
httpPut.setHeader("Http-Authorization", GlobalCache.paramMap.get("token"));
if (GlobalCache.header.get("Content-Type") != null) {
String contentType = GlobalCache.header.get("Content-Type");
if ("application/x-www-form-urlencoded".equals(contentType)) {
JSONObject jsonObject = JSONObject.parseObject(jsonParams);
List<NameValuePair> params = new ArrayList<>();
//循环json key value 仅能解决正常对象 若Json对象中嵌套数组 则可能需要单独处理
if (jsonObject != null) {
for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
params.add(new BasicNameValuePair(entry.getKey(), entry.getValue().toString()));
}
httpPut.setEntity(new UrlEncodedFormEntity(params, DEFAULT_ENCODING));
}
}
if ("application/json;charset=UTF-8".equals(contentType)) {
httpPut.setEntity(new StringEntity(jsonParams, ContentType.create("application/json", DEFAULT_ENCODING)));
}
} else {
log.error("请求头为空");
}
return baseRequest(httpClient, httpPut);
}
/**
* 采用绕过验证的方式处理https请求
*
* @param url
* @param reqMap
* @param encoding
* @return
*/
public static ResponeVo postSSLUrl(String url, Map<String, Object> reqMap, String encoding) throws IOException, KeyManagementException, NoSuchAlgorithmException, KeyStoreException {
CloseableHttpClient httpClient = null;
CloseableHttpResponse response = null;
ResponeVo responeVo = null;
// 添加参数
List<NameValuePair> params = buildParams(reqMap);
try {
//采用绕过验证的方式处理https请求
HostnameVerifier hostnameVerifier = (hostname, session) -> true;
SSLContext sslcontext = createIgnoreVerifySSL();
//设置协议http和https对应的处理socket链接工厂的对象
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
.register("http", PlainConnectionSocketFactory.INSTANCE)
.register("https", new SSLConnectionSocketFactory(sslcontext, hostnameVerifier))
.build();
PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
//创建自定义的httpclient对象
httpClient = HttpClients.custom().setConnectionManager(connManager).build();
//创建post方式请求对象
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(params, encoding));
//指定报文头Content-type、User-Agent
httpPost.setHeader("Content-type", "application/x-www-form-urlencoded");
//执行请求操作,并拿到结果(同步阻塞)
responeVo = baseRequest(httpClient, httpPost);
} finally {
ExtendedIOUtils.closeQuietly(httpClient);
ExtendedIOUtils.closeQuietly(response);
}
return responeVo;
}
private static List<NameValuePair> buildParams(Map<String, Object> reqMap) {
List<NameValuePair> params = new ArrayList<>();
if (reqMap != null && reqMap.keySet().size() > 0) {
Iterator<Map.Entry<String, Object>> iter = reqMap.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry<String, Object> entity = iter.next();
params.add(new BasicNameValuePair(entity.getKey(), entity.getValue().toString()));
}
}
return params;
}
/**
* 创建一个SSL信任所有证书的httpClient对象
*
* @return
*/
public static CloseableHttpClient createSSLInsecureClient() throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException {
// 默认信任所有证书
HostnameVerifier hostnameVerifier = (hostname, session) -> true;
SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(null, (TrustStrategy) (chain, authType) -> true).build();
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(sslContext, hostnameVerifier);
return HttpClients.custom().setSSLSocketFactory(sslConnectionSocketFactory).build();
}
/**
* 绕过验证
*
* @return
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
public static SSLContext createIgnoreVerifySSL() throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException {
// 信任所有证书
return new SSLContextBuilder().loadTrustMaterial(null, (TrustStrategy) (arg0, arg1) -> true).build();
}
private static String inputStreamToString(InputStream is) {
String line = "";
StringBuilder total = new StringBuilder();
// Wrap a BufferedReader around the InputStream
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
try {
// Read response until the end
while ((line = rd.readLine()) != null) {
total.append(line);
}
} catch (IOException e) {
log.error(e.getLocalizedMessage(), e);
}
// Return full string
return total.toString();
}
public static ResponeVo baseRequest(CloseableHttpClient httpClient, HttpUriRequest request) {
ResponeVo responeVo = new ResponeVo();
CloseableHttpResponse response = null;
try {
String content;
response = httpClient.execute(request);
content = inputStreamToString(response.getEntity().getContent());
responeVo.setCode(response.getStatusLine().getStatusCode());
responeVo.setContent(content);
responeVo.setResponse(response);
log.info("http调用完成,返回数据" + content);
} catch (Exception e) {
log.error(" http调用失败:" + e);
}
ExtendedIOUtils.closeQuietly(httpClient);
ExtendedIOUtils.closeQuietly(response);
return responeVo;
}
}
...@@ -119,7 +119,7 @@ public class PoolStatisticController { ...@@ -119,7 +119,7 @@ public class PoolStatisticController {
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@RequestMapping(value = "/panel/station/statistic", method = RequestMethod.GET) @RequestMapping(value = "/panel/station/statistic", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "获取水池统计信息", notes = "获取水池统计信息") @ApiOperation(httpMethod = "GET", value = "获取水池统计信息", notes = "获取水池统计信息")
public ResponseModel getStationWaterPanelInfo( @RequestParam(required = false) String bizOrgCode) { public ResponseModel<List<Map<String, Object>>> getStationWaterPanelInfo( @RequestParam(required = false) String bizOrgCode) {
List<Map<String, Object>> infoList = fireFightingSystemMapper.getWaterInfoBySuper(bizOrgCode); List<Map<String, Object>> infoList = fireFightingSystemMapper.getWaterInfoBySuper(bizOrgCode);
List<Map<String, Object>> normalList = new ArrayList<>(); List<Map<String, Object>> normalList = new ArrayList<>();
List<Map<String, Object>> abNormalList = new ArrayList<>(); List<Map<String, Object>> abNormalList = new ArrayList<>();
...@@ -140,10 +140,14 @@ public class PoolStatisticController { ...@@ -140,10 +140,14 @@ public class PoolStatisticController {
BigDecimal bigDecimal = new BigDecimal(String.valueOf(m.get("volume"))).multiply(new BigDecimal(String.valueOf(transResult.get("abs")))).divide(divide, 0, RoundingMode.HALF_UP); BigDecimal bigDecimal = new BigDecimal(String.valueOf(m.get("volume"))).multiply(new BigDecimal(String.valueOf(transResult.get("abs")))).divide(divide, 0, RoundingMode.HALF_UP);
m.put("volume", bigDecimal + "m³"); m.put("volume", bigDecimal + "m³");
m.put("levelAbs", transResult.get("abs") + "%"); m.put("levelAbs", transResult.get("abs") + "%");
// 预警使用以下字段
m.put("volumeBigDecimal", bigDecimal);
} else if (String.valueOf(transResult.get("abs")).equals("100") && String.valueOf(transResult.get("status")).equals("1")) { } else if (String.valueOf(transResult.get("abs")).equals("100") && String.valueOf(transResult.get("status")).equals("1")) {
BigDecimal bigDecimal = new BigDecimal(String.valueOf(m.get("volume"))); BigDecimal bigDecimal = new BigDecimal(String.valueOf(m.get("volume")));
m.put("volume", bigDecimal + "m³"); m.put("volume", bigDecimal + "m³");
m.put("levelAbs", transResult.get("abs") + "%"); m.put("levelAbs", transResult.get("abs") + "%");
// 预警使用以下字段
m.put("volumeBigDecimal", bigDecimal);
} else { } else {
m.put("levelAbs", transResult.get("abs")); m.put("levelAbs", transResult.get("abs"));
} }
......
...@@ -212,7 +212,7 @@ public class SupervisionConfigureController extends AbstractBaseController { ...@@ -212,7 +212,7 @@ public class SupervisionConfigureController extends AbstractBaseController {
levelAbsLiter = volume.multiply(new BigDecimal(1000)); levelAbsLiter = volume.multiply(new BigDecimal(1000));
}else { }else {
BigDecimal abs = new BigDecimal(String.valueOf(transResult.get("abs"))); BigDecimal abs = new BigDecimal(String.valueOf(transResult.get("abs")));
levelAbsLiter = volume.multiply(abs.divide(new BigDecimal(100),2, RoundingMode.HALF_UP)); levelAbsLiter = volume.multiply(new BigDecimal(1000)).multiply(abs.divide(new BigDecimal(100),2, RoundingMode.HALF_UP));
} }
float outputFlowRate = Float.parseFloat(String.valueOf(m.get("outputFlowRate"))); float outputFlowRate = Float.parseFloat(String.valueOf(m.get("outputFlowRate")));
if (levelAbsLiter.compareTo(new BigDecimal(0)) != 0 && outputFlowRate != 0) { if (levelAbsLiter.compareTo(new BigDecimal(0)) != 0 && outputFlowRate != 0) {
......
...@@ -231,17 +231,7 @@ public class WlCarMileageController { ...@@ -231,17 +231,7 @@ public class WlCarMileageController {
} }
/**
* 获取轨迹
*
* @return
*/
@RequestMapping(value = "/travel", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "获取轨迹", notes = "获取轨迹")
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
public List<Coordinate> travel(long id) {
return iWlCarMileageService.getCoordinateList(id);
}
/** /**
* 获取日历 * 获取日历
......
...@@ -86,4 +86,12 @@ public interface IotFeign { ...@@ -86,4 +86,12 @@ public interface IotFeign {
ResponseModel<Map<String ,Object>> queryIotDataNum(@RequestParam("timeStart") String timeStart, ResponseModel<Map<String ,Object>> queryIotDataNum(@RequestParam("timeStart") String timeStart,
@RequestParam("timeEnd") String timeEnd); @RequestParam("timeEnd") String timeEnd);
@RequestMapping(value = "v1/livedata/queryIotDataNumByIndex", method = RequestMethod.GET, consumes = "application/json")
ResponseModel<Map<String ,Integer>> queryIotDataNumByIndex(@RequestParam(value = "timeStart") String timeStart,
@RequestParam(value = "timeEnd") String timeEnd,
@RequestParam(value = "productKey") String productKey,
@RequestParam(value = "deviceName") String deviceName,
@RequestParam(value = "indexKeys") String indexKeys,
@RequestParam(value = "value") String value);
} }
...@@ -21,7 +21,6 @@ public interface IWlCarMileageService extends IService<WlCarMileage> { ...@@ -21,7 +21,6 @@ public interface IWlCarMileageService extends IService<WlCarMileage> {
Double totalMileage(String iotCode); Double totalMileage(String iotCode);
List<Coordinate> getCoordinateList(long id);
Map<String,Boolean> getCalender(long id,Date date); Map<String,Boolean> getCalender(long id,Date date);
......
...@@ -1971,8 +1971,6 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM ...@@ -1971,8 +1971,6 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
Date now = new Date(); Date now = new Date();
String scrapTime = new SimpleDateFormat(DateUtils.DATE_TIME_PATTERN).format(calendar.getTime()); String scrapTime = new SimpleDateFormat(DateUtils.DATE_TIME_PATTERN).format(calendar.getTime());
int day = DateUtils.dateBetween(now, calendar.getTime()); int day = DateUtils.dateBetween(now, calendar.getTime());
log.info("报废时间:{}" , day);
log.info("报废时间ID:{}" , e.get("id").toString());
if (day < Integer.parseInt(equipmentScrapDay) && day > -1) { if (day < Integer.parseInt(equipmentScrapDay) && day > -1) {
syncSystemctlMsg(e, scrapTime, day); syncSystemctlMsg(e, scrapTime, day);
} else if (day == -1) { } else if (day == -1) {
......
...@@ -2263,9 +2263,7 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste ...@@ -2263,9 +2263,7 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
// 日告警设备数 // 日告警设备数
listItem.put("alarmEquipNum", ObjectUtils.isEmpty(weekItem.get("alarmEquipNum")) ? "" : String.valueOf(weekItem.get("alarmEquipNum"))); listItem.put("alarmEquipNum", ObjectUtils.isEmpty(weekItem.get("alarmEquipNum")) ? "" : String.valueOf(weekItem.get("alarmEquipNum")));
// 日告警条数 // 日告警条数
log.info("==========sbco={}", weekItem.get("type_code").toString()); if (!ObjectUtils.isEmpty(weekItem.get("type_code")) && !ObjectUtils.isEmpty(weekItem.get("code"))) {
log.info("==========sbCC={}", weekItem.get("code").toString());
if (!ObjectUtils.isEmpty(weekItem.get("type_code")) && !ObjectUtils.isEmpty(weekItem.get("code"))) {
Integer integer = fireFightingSystemMapper.selectAlarms(valueOf(system.get("id")), valueOf(weekItem.get("type_code")), valueOf(weekItem.get("code")), startDate, endDate, new ArrayList<>()); Integer integer = fireFightingSystemMapper.selectAlarms(valueOf(system.get("id")), valueOf(weekItem.get("type_code")), valueOf(weekItem.get("code")), startDate, endDate, new ArrayList<>());
listItem.put("trueNum", String.valueOf(integer)); listItem.put("trueNum", String.valueOf(integer));
} else { } else {
......
package com.yeejoin.equipmanage.service.impl; package com.yeejoin.equipmanage.service.impl;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
...@@ -28,6 +29,7 @@ import com.yeejoin.equipmanage.common.utils.UUIDUtils; ...@@ -28,6 +29,7 @@ import com.yeejoin.equipmanage.common.utils.UUIDUtils;
import com.yeejoin.equipmanage.common.vo.*; import com.yeejoin.equipmanage.common.vo.*;
import com.yeejoin.equipmanage.common.vo.BizMessage; import com.yeejoin.equipmanage.common.vo.BizMessage;
import com.yeejoin.equipmanage.common.vo.CustomizeItems; import com.yeejoin.equipmanage.common.vo.CustomizeItems;
import com.yeejoin.equipmanage.controller.PoolStatisticController;
import com.yeejoin.equipmanage.dto.TabContent; import com.yeejoin.equipmanage.dto.TabContent;
import com.yeejoin.equipmanage.fegin.IotFeign; import com.yeejoin.equipmanage.fegin.IotFeign;
import com.yeejoin.equipmanage.fegin.SystemctlFeign; import com.yeejoin.equipmanage.fegin.SystemctlFeign;
...@@ -104,6 +106,11 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -104,6 +106,11 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
* 水箱液位 * 水箱液位
*/ */
private final static String CAFS_WaterTank_WaterTankLevel = "CAFS_WaterTank_WaterTankLevel"; private final static String CAFS_WaterTank_WaterTankLevel = "CAFS_WaterTank_WaterTankLevel";
private final static String FHS_PressurePump_Start = "FHS_PressurePump_Start";
private final static String FHS_PressurePump_Stop = "FHS_PressurePump_Stop";
private static final String PUMP_JOB_GROUP_NAME = "EQUIP_PUMP_JOB_GROUP_NAME"; private static final String PUMP_JOB_GROUP_NAME = "EQUIP_PUMP_JOB_GROUP_NAME";
private static final String PUMP_TRIGGER_NAME = "EQUIP_PUMP_TRIGGER_NAME"; private static final String PUMP_TRIGGER_NAME = "EQUIP_PUMP_TRIGGER_NAME";
private static final String PUMP_TRIGGER_GROUP_NAME = "EQUIP_PUMP_TRIGGER_GROUP_NAME"; private static final String PUMP_TRIGGER_GROUP_NAME = "EQUIP_PUMP_TRIGGER_GROUP_NAME";
...@@ -180,6 +187,9 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -180,6 +187,9 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
@Autowired @Autowired
private ManufacturerInfoMapper manufacturerInfoMapper; private ManufacturerInfoMapper manufacturerInfoMapper;
@Autowired
private PoolStatisticController poolStatisticController;
// @Autowired // @Autowired
// private AmosRequestContext amosAuth; // private AmosRequestContext amosAuth;
@Value("${equipManage.name}") @Value("${equipManage.name}")
...@@ -389,7 +399,13 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -389,7 +399,13 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
} }
//给 iot服务 推送消息 插数据到 influxdb //给 iot服务 推送消息 插数据到 influxdb
if (isSendIot) { if (isSendIot) {
mqttSendGateway.sendToMqtt("influxdb/" + topic.substring(0, endIndex), message); JSONObject messageObj = JSON.parseObject(message);
if (!messageObj.containsKey("traceId")) {
String traceId = System.currentTimeMillis() + "";
messageObj.put("traceId", traceId);
}
String messageTraceId = JSON.toJSONString(messageObj);
mqttSendGateway.sendToMqtt("influxdb/" + topic.substring(0, endIndex), messageTraceId);
} }
EquipmentSpecificVo vo = eqIotCodeList.get(0); EquipmentSpecificVo vo = eqIotCodeList.get(0);
topicEntity.setType(vo.getType()); topicEntity.setType(vo.getType());
...@@ -1119,6 +1135,13 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1119,6 +1135,13 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
iotDataVO.getKey().equalsIgnoreCase(FHS_WirelessliquidDetector_WaterLevel) || iotDataVO.getKey().equalsIgnoreCase(FHS_WirelessliquidDetector_WaterLevel) ||
iotDataVO.getKey().equalsIgnoreCase(FHS_LevelDetector_WaterLevel)) { iotDataVO.getKey().equalsIgnoreCase(FHS_LevelDetector_WaterLevel)) {
alarmFlag = doWaterPoolLevel(iotDataVO, equipmentSpecificIndex, messageBodyMap); alarmFlag = doWaterPoolLevel(iotDataVO, equipmentSpecificIndex, messageBodyMap);
// 处理每站消防储水量不少于4000m³ 预警问题
doWaterStationWarning(equipmentSpecificIndex.getBizOrgCode(), equipmentSpecificIndex.getBizOrgName());
}
//稳压泵启停次数大于15次触发预警
if (iotDataVO.getKey().equalsIgnoreCase(FHS_PressurePump_Start) ||
iotDataVO.getKey().equalsIgnoreCase(FHS_PressurePump_Stop)) {
doPressurePumInfo(topicEntity, equipmentSpecificIndex);
} }
// 遥测数据生成告警事件、日志处理 // 遥测数据生成告警事件、日志处理
if (iotDataVO.getKey().equalsIgnoreCase(CAFS_FoamTank_FoamTankLevel) || if (iotDataVO.getKey().equalsIgnoreCase(CAFS_FoamTank_FoamTankLevel) ||
...@@ -1360,7 +1383,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1360,7 +1383,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
if (iotDataVO.getKey().equalsIgnoreCase(CAFS_FoamTank_FoamTankLevel) || iotDataVO.getKey().equalsIgnoreCase(CAFS_WaterTank_WaterTankLevel)) { if (iotDataVO.getKey().equalsIgnoreCase(CAFS_FoamTank_FoamTankLevel) || iotDataVO.getKey().equalsIgnoreCase(CAFS_WaterTank_WaterTankLevel)) {
map = fireFightingSystemMapper.getFoamTankLevel(equipmentSpecificIndex.getEquipmentSpecificId()); map = fireFightingSystemMapper.getFoamTankLevel(equipmentSpecificIndex.getEquipmentSpecificId());
indexKey = iotDataVO.getKey().equalsIgnoreCase(CAFS_FoamTank_FoamTankLevel) ? "CAFS_FOAM_TANK" : "WATER_TANK_LEVEL"; indexKey = iotDataVO.getKey().equalsIgnoreCase(CAFS_FoamTank_FoamTankLevel) ? "CAFS_FOAM_TANK" : "CAFS_WaterTank_WaterTankLevel";
} else { } else {
map = fireFightingSystemMapper.getPipeNetwork(equipmentSpecificIndex.getEquipmentSpecificId()); map = fireFightingSystemMapper.getPipeNetwork(equipmentSpecificIndex.getEquipmentSpecificId());
indexKey = "PIPE_PRESSURE"; indexKey = "PIPE_PRESSURE";
...@@ -1440,6 +1463,117 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1440,6 +1463,117 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
return alarmFlag; return alarmFlag;
} }
private void doWaterStationWarning(String bizOrgCode, String bizOrgName) {
List<Map<String, Object>> result = poolStatisticController.getStationWaterPanelInfo(bizOrgCode).getResult();
String indexValue = result.stream()
.map(map -> (BigDecimal) map.get("volumeBigDecimal"))
.reduce(BigDecimal.ZERO, BigDecimal::add).toString();
doWaterStationInfo(bizOrgCode, bizOrgName, indexValue);
}
private void doWaterStationInfo(String bizOrgCode, String bizOrgName, String indexValue) {
String indexKey = "WATER_CAPACITY";
String warningObjectCode = bizOrgCode + "@" + indexKey;
HashMap<String, String> extra = new HashMap<>();
extra.put("useSource", "center");
extra.put("codingSystem", "center");
extra.put("codingType", "station");
extra.put("problemReception", "station");
extra.put("bussId", warningObjectCode);
extra.put("clearUniqueCode", "station-WATER_CAPACITY");
TableContentVo tableContentVo = new TableContentVo("分析结果", "text", "消防水池+工业水池储水量<4000m³", "1");
TableContentVo tableContentVo1 = new TableContentVo("管理要求", "text", "每站消防储水量不少于4000m³", "2");
TableContentVo tableContentVo2 = new TableContentVo("管理依据", "text", "换流站消防系统运行规程", "3");
List<TableContentVo> tableContentVos = Arrays.asList(tableContentVo, tableContentVo1, tableContentVo2);
// 触发预警业务
BizMessage bizMessage = new BizMessage();
bizMessage.setIndexKey(indexKey);
bizMessage.setIndexValue(indexValue);
RiskBizInfoVo riskBizInfoVo = new RiskBizInfoVo();
riskBizInfoVo.setWarningObjectName("消防储水量");
riskBizInfoVo.setWarningObjectCode(warningObjectCode);
riskBizInfoVo.setSourceAttribution(bizOrgCode);
riskBizInfoVo.setSourceAttributionDesc(bizOrgName);
List<RiskDynamicDetailsVo> detailsVos = new ArrayList<>();
RiskDynamicDetailsVo dynamicDetailsVo = new RiskDynamicDetailsVo();
dynamicDetailsVo.setTabName("预警详情");
detailsVos.add(dynamicDetailsVo);
riskBizInfoVo.setDynamicDetails(detailsVos);
CustomizeItems customizeItems = new CustomizeItems();
customizeItems.setWarningContent("消防水池+工业水池储水量<4000m³");
riskBizInfoVo.setCustomizeItems(customizeItems);
riskBizInfoVo.setExtra(extra);
riskBizInfoVo.setType("waterCapacity");
riskBizInfoVo.getDynamicDetails().get(0).setTabContent(tableContentVos);
bizMessage.setBizInfo(riskBizInfoVo);
bizMessage.setTraceId(warningObjectCode);
try {
emqKeeper.getMqttClient().publish("fireIot/data/analysis",
JSON.toJSONString(bizMessage).getBytes(StandardCharsets.UTF_8), 2, false);
} catch (MqttException e) {
e.printStackTrace();
}
}
private void doPressurePumInfo(TopicEntityVo topicEntity, EquipmentSpecificIndex equipmentSpecificIndex) {
// 查询iot该稳压泵的启停次数 一个小时内
String startDate = DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN);
String endDate = DateUtil.format(DateUtil.offsetHour(new Date(), -1), DatePattern.NORM_DATETIME_PATTERN);
String prefix = topicEntity.getIotCode().substring(0, 8);
String suffix = topicEntity.getIotCode().substring(8);
ResponseModel<Map<String, Integer>> mapResponseModel = iotFeign.queryIotDataNumByIndex(startDate, endDate, prefix, suffix, FHS_PressurePump_Start + "," + FHS_PressurePump_Stop, "true");
if (200 == mapResponseModel.getStatus()) {
Map<String, Integer> result = mapResponseModel.getResult();
Integer totalNum = result.get("num");
HashMap<String, String> extra = new HashMap<>();
extra.put("useSource", "center");
extra.put("codingSystem", "center");
extra.put("codingType", "equipment");
extra.put("problemReception", "station");
extra.put("bussId", String.valueOf(equipmentSpecificIndex.getEquipmentSpecificId()));
extra.put("clearUniqueCode", "equip-pressure");
TableContentVo tableContentVo = new TableContentVo("报警类型", "text", "稳压泵启停频次过高", "1");
TableContentVo tableContentVo1 = new TableContentVo("报警部位", "text", equipmentSpecificIndex.getLocation(), "2");
TableContentVo tableContentVo2 = new TableContentVo("报警时间", "text", DateUtil.now(), "3");
TableContentVo tableContentVo3 = new TableContentVo("报警对象", "text", equipmentSpecificIndex.getEquipmentSpecificName(), "4");
List<TableContentVo> tableContentVos = Arrays.asList(tableContentVo, tableContentVo1, tableContentVo2, tableContentVo3);
handlePressureWarning(totalNum.toString(),
equipmentSpecificIndex,
String.valueOf(equipmentSpecificIndex.getEquipmentSpecificId()),
"fireIot/data/analysis",
"START_NUM",
extra,
"equip",
tableContentVos);
}
}
private void handlePressureWarning(String indexValue,
EquipmentSpecificIndex equipmentSpecificIndex,
String businessId,
String topic,
String indexKey,
Object extra,
String source,
List<TableContentVo> tableContentVos) {
// 触发预警业务
BizMessage bizMessage = new BizMessage();
bizMessage.setIndexKey(indexKey);
bizMessage.setIndexValue(indexValue);
RiskBizInfoVo riskBizInfoVo = fetchData(equipmentSpecificIndex, extra, source);
riskBizInfoVo.setWarningObjectCode(businessId);
riskBizInfoVo.getDynamicDetails().get(0).setTabContent(tableContentVos);
bizMessage.setBizInfo(riskBizInfoVo);
bizMessage.setTraceId(businessId);
try {
emqKeeper.getMqttClient().publish(topic,
JSON.toJSONString(bizMessage).getBytes(StandardCharsets.UTF_8), 2, false);
} catch (MqttException e) {
e.printStackTrace();
}
}
/** /**
* 消防水池、工业水池和消防水箱 消息发送 * 消防水池、工业水池和消防水箱 消息发送
* *
...@@ -1487,7 +1621,8 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1487,7 +1621,8 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
TableContentVo tableContentVo2 = new TableContentVo("报警时间", "text", DateUtil.now(), "3"); TableContentVo tableContentVo2 = new TableContentVo("报警时间", "text", DateUtil.now(), "3");
TableContentVo tableContentVo3 = new TableContentVo("报警对象", "text", map.getOrDefault("name", "").toString(), "4"); TableContentVo tableContentVo3 = new TableContentVo("报警对象", "text", map.getOrDefault("name", "").toString(), "4");
List<TableContentVo> tableContentVos = Arrays.asList(tableContentVo, tableContentVo1, tableContentVo2, tableContentVo3); List<TableContentVo> tableContentVos = Arrays.asList(tableContentVo, tableContentVo1, tableContentVo2, tableContentVo3);
equipmentSpecificIndex.setEquipmentSpecificName(map.get("name").toString());
equipmentSpecificIndex.setEquipmentSpecificCode(map.get("id").toString());
//预警业务 消防水池和消防水箱 //预警业务 消防水池和消防水箱
handleWarning(minValue, handleWarning(minValue,
maxValue, maxValue,
...@@ -1495,7 +1630,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService { ...@@ -1495,7 +1630,7 @@ public class MqttReceiveServiceImpl implements MqttReceiveService {
equipmentSpecificIndex, equipmentSpecificIndex,
map.get("id").toString(), map.get("id").toString(),
"fireIot/data/analysis", "fireIot/data/analysis",
"WATER_POOL_LEVEL", "pool".equals(map.get("resourceType").toString()) ? "WATER_POOL_LEVEL" : "WATER_TANK_LEVEL",
extra, extra,
"waterLevelOver", "waterLevelOver",
tableContentVos); tableContentVos);
......
...@@ -13,7 +13,6 @@ import com.yeejoin.equipmanage.common.entity.CarSpeedWarningRecord; ...@@ -13,7 +13,6 @@ import com.yeejoin.equipmanage.common.entity.CarSpeedWarningRecord;
import com.yeejoin.equipmanage.common.entity.WlCarMileage; import com.yeejoin.equipmanage.common.entity.WlCarMileage;
import com.yeejoin.equipmanage.common.utils.CoordinateUtil; import com.yeejoin.equipmanage.common.utils.CoordinateUtil;
import com.yeejoin.equipmanage.common.utils.DateUtils; import com.yeejoin.equipmanage.common.utils.DateUtils;
import com.yeejoin.equipmanage.common.utils.HttpUtil;
import com.yeejoin.equipmanage.common.utils.RedisUtil; import com.yeejoin.equipmanage.common.utils.RedisUtil;
import com.yeejoin.equipmanage.controller.Coordinate; import com.yeejoin.equipmanage.controller.Coordinate;
import com.yeejoin.equipmanage.fegin.IotFeign; import com.yeejoin.equipmanage.fegin.IotFeign;
...@@ -69,7 +68,6 @@ import java.util.stream.Collectors; ...@@ -69,7 +68,6 @@ import java.util.stream.Collectors;
@EnableAsync @EnableAsync
public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlCarMileage> public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlCarMileage>
implements IWlCarMileageService { implements IWlCarMileageService {
private static final Logger log = LoggerFactory.getLogger(HttpUtil.class);
private final String GUIDE_KEY = "8d2ab194d72e88d3636e9d721814333a"; private final String GUIDE_KEY = "8d2ab194d72e88d3636e9d721814333a";
private final String GUIDE_URL = "https://restapi.amap.com/v4/grasproad/driving?"; private final String GUIDE_URL = "https://restapi.amap.com/v4/grasproad/driving?";
private final String GUIDE_ADDRESS_URL = "https://restapi.amap.com/v3/geocode/regeo?"; private final String GUIDE_ADDRESS_URL = "https://restapi.amap.com/v3/geocode/regeo?";
...@@ -132,137 +130,6 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC ...@@ -132,137 +130,6 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
return this.baseMapper.totalMileage(iotCode); return this.baseMapper.totalMileage(iotCode);
} }
@Override
public List<Coordinate> getCoordinateList(long id) {
double speed = 0;
WlCarMileage wlCarMileage = this.getById(id);
String iotCode = wlCarMileage.getIotCode();
String measurement = iotCode.substring(0, 8);
String deviceName = iotCode.replace(measurement, "");
// 由于iot存在毫秒故结束时间要+1秒 iot+1秒有bug还是查不到 +2秒
ResponseModel<List<Object>> result = iotFeign.getLiveData(measurement, deviceName, wlCarMileage.getStartTime(),
new Date(wlCarMileage.getEndTime().getTime()));
List<Object> list = result.getResult();
List<Coordinate> coordinateList = new ArrayList<Coordinate>();
if (list != null) {
DateFormat format1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
DateFormat format2 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
for (Object object : list) {
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(object));
if (jsonObject.get("FireCar_Longitude") != null && jsonObject.get("FireCar_Latitude") != null) {
Coordinate coordinate = new Coordinate();
List<Double> lnglat = new ArrayList<Double>();
lnglat.add(jsonObject.getDoubleValue("FireCar_Longitude"));
lnglat.add(jsonObject.getDoubleValue("FireCar_Latitude"));
coordinate.setLnglat(lnglat);
coordinate.setSpeed(jsonObject.getDoubleValue("fireCar_Speed"));
speed = speed + jsonObject.getDoubleValue("fireCar_Speed");
String time = jsonObject.getString("time");
if (time.length() > 20) {
try {
coordinate.setTime(format1.parse(jsonObject.getString("time")).getTime());
} catch (ParseException e) {
e.printStackTrace();
}
} else {
try {
coordinate.setTime(format2.parse(jsonObject.getString("time")).getTime());
} catch (ParseException e) {
e.printStackTrace();
}
}
double direction = jsonObject.getDoubleValue("direction");
if (!ObjectUtils.isEmpty(direction)) {
coordinate.setDirection(jsonObject.getDoubleValue("direction"));
} else {
coordinate.setDirection(0);
}
coordinateList.add(coordinate);
}
}
}
// 倒序坐标变为正序
Collections.reverse(coordinateList);
// 坐标轨迹纠偏
double avgSpeed = speed / coordinateList.size();
double count = Double.valueOf(coordinateList.size()) / 500;
int ceil = (int) Math.ceil(count);
ArrayList<Coordinate> resultList = new ArrayList<>();
for (int i = 1; i <= ceil; i++) {
if (i == ceil) {
List<Coordinate> coordinates = coordinateList.subList(500 * (i - 1), coordinateList.size());
List<Coordinate> check = check(coordinates, avgSpeed);
resultList.addAll(check);
} else {
List<Coordinate> coordinates = coordinateList.subList(500 * (i - 1), 500 + (i - 1) * 500);
List<Coordinate> check = check(coordinates, avgSpeed);
resultList.addAll(check);
}
}
return resultList;
}
private List<Coordinate> check(List<Coordinate> list, double avgSpeed) {
ArrayList<Coordinate> coordinates = new ArrayList<>();
JSONArray objects = new JSONArray();
int count = 0;
for (Coordinate coordinate : list) {
JSONObject jsonObject = new JSONObject();
// 经度
jsonObject.put("x", coordinate.getLnglat().get(0));
// 纬度
jsonObject.put("y", coordinate.getLnglat().get(1));
// 角度
jsonObject.put("ag", coordinate.getDirection());
// 速度
jsonObject.put("sp", coordinate.getSpeed() > 0 ? coordinate.getSpeed() : avgSpeed);
// 时间
if (count == 0) {
jsonObject.put("tm", coordinate.getTime() / 1000);
} else {
jsonObject.put("tm", 3 * count);
}
count += 1;
objects.add(jsonObject);
}
String s = objects.toJSONString();
StringBuilder api = new StringBuilder(GUIDE_URL);
api.append("key=").append(GUIDE_KEY);
String result = null;
try {
result = HttpUtil.post(api.toString(), s);
} catch (IOException | NoSuchAlgorithmException | KeyStoreException | KeyManagementException e) {
e.printStackTrace();
}
if (result != null) {
Map<String, Object> jsonObject = (Map<String, Object>) JSONObject.parseObject(result);
//判断是否坐标不满足高德地图纠偏需求
if (jsonObject.containsKey("errcode") && jsonObject.get("errcode").toString().equals("30001")) {
return list;
}
if (jsonObject.containsKey("data")) {
JSONObject data3 = JSONObject.parseObject(jsonObject.get("data").toString());
JSONArray points1 = JSONArray.parseArray(data3.get("points").toString());
// for (int i = 0; i < points1.size(); i++) {
// JSONObject jsonObject1 = JSONObject.parseObject(points1.get(i).toString());
// List<Double> doubles = new ArrayList<>();
// Coordinate coordinate = new Coordinate();
// doubles.add(Double.valueOf(jsonObject1.get("x").toString()));
// doubles.add(Double.valueOf(jsonObject1.get("y").toString()));
// coordinate.setLnglat(doubles);
// Double speeed = getSpeedByOriginalData(objects, Double.valueOf(jsonObject1.get("x").toString()), Double.valueOf(jsonObject1.get("y").toString()));
// coordinate.setSpeed(speeed);
// coordinates.add(coordinate);
// }
coordinates = giveSpeedToCoordinate(objects, points1);
}
}
return coordinates;
}
@Override @Override
public Map<String, Boolean> getCalender(long id, Date date) { public Map<String, Boolean> getCalender(long id, Date date) {
...@@ -314,16 +181,12 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC ...@@ -314,16 +181,12 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
@Scheduled(cron = "${mileage.segmentation.cron}") @Scheduled(cron = "${mileage.segmentation.cron}")
@Async @Async
public void mileageSegmentation() { public void mileageSegmentation() {
log.info("轨迹切分定时任务开始执行时间.............{}", LocalDateTime.now());
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
cal.setTime(new Date()); cal.setTime(new Date());
cal.add(Calendar.DATE, -1); cal.add(Calendar.DATE, -1);
String nowDate = new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime()); String nowDate = new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime());
log.info("轨迹切分定时任务数据过滤时间.............{}", nowDate);
List<WlCarMileage> list = this.baseMapper.list(nowDate); List<WlCarMileage> list = this.baseMapper.list(nowDate);
log.info("需要切分数据, {}", list);
log.info("销毁所有坐标信息成功");
log.info("------------------跨天轨迹切分任开始切分里程-------------------------------");
list.forEach(item -> { list.forEach(item -> {
redisTemplate.delete(item.getIotCode()); redisTemplate.delete(item.getIotCode());
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
...@@ -393,10 +256,8 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC ...@@ -393,10 +256,8 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
item.setTravel(new BigDecimal(travel / 1000).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue()); item.setTravel(new BigDecimal(travel / 1000).setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue());
item.setTakeTime(takeTime); item.setTakeTime(takeTime);
this.getBaseMapper().updateById(item); this.getBaseMapper().updateById(item);
log.info("-----------跨天轨迹切分任更新车辆坐标成功:::" + JSONObject.toJSONString(item) + "-----------------"); }
}
}); });
log.info("-------------------跨天轨迹切分任务执行完成..............");
//删除过期的告警数据 //删除过期的告警数据
Date endTime = DateUtil.offsetDay(new Date(),-15); Date endTime = DateUtil.offsetDay(new Date(),-15);
String endTimeStr = DateUtil.format(endTime, "yyyy-MM-dd HH:mm:00"); String endTimeStr = DateUtil.format(endTime, "yyyy-MM-dd HH:mm:00");
...@@ -474,12 +335,10 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC ...@@ -474,12 +335,10 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
} else { } else {
this.getBaseMapper().deleteById(item.getId()); this.getBaseMapper().deleteById(item.getId());
} }
log.info("-----------正常结束轨迹更新车辆坐标成功:::" + JSONObject.toJSONString(item) + "-----------------"); }
}
} }
}); });
log.info("轨迹切分任务执行完成..............");
//删除无效的告警数据 //删除无效的告警数据
Date endTime = DateUtil.offsetMinute(new Date(),-10); Date endTime = DateUtil.offsetMinute(new Date(),-10);
String endTimeStr = DateUtil.format(endTime, "yyyy-MM-dd HH:mm:00"); String endTimeStr = DateUtil.format(endTime, "yyyy-MM-dd HH:mm:00");
...@@ -588,12 +447,9 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC ...@@ -588,12 +447,9 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
Double travel1 = CoordinateUtil.distance(startLatitude, startLongitude, jsonObject1.getDoubleValue("x"), jsonObject1.getDoubleValue("y")); Double travel1 = CoordinateUtil.distance(startLatitude, startLongitude, jsonObject1.getDoubleValue("x"), jsonObject1.getDoubleValue("y"));
Double travel2 = CoordinateUtil.distance(startLatitude, startLongitude, jsonObject2.getDoubleValue("x"), jsonObject2.getDoubleValue("y")); Double travel2 = CoordinateUtil.distance(startLatitude, startLongitude, jsonObject2.getDoubleValue("x"), jsonObject2.getDoubleValue("y"));
log.info("travel1:" + travel1 + "travel2:" + travel2);
if (travel2 > travel1) { if (travel2 > travel1) {
log.info("travel1:" + travel1 + "travel2:" + travel2); speed = jsonObject1.getDoubleValue("sp");
log.info("lat:" + startLatitude + "long:" + startLongitude);
log.info("lat:" + jsonObject1.getDoubleValue("x") + "long:" + jsonObject1.getDoubleValue("y"));
speed = jsonObject1.getDoubleValue("sp");
break; break;
} else { } else {
speed = jsonObject2.getDoubleValue("sp"); speed = jsonObject2.getDoubleValue("sp");
......
...@@ -197,30 +197,4 @@ public class SpeechTranscriberDemo { ...@@ -197,30 +197,4 @@ public class SpeechTranscriberDemo {
public void shutdown() { public void shutdown() {
client.shutdown(); client.shutdown();
} }
public static void main(String[] args) throws Exception {
String appKey = "89KKwpGXXN37Pn1G";
String id = "LTAI5t8F2oYwmfoYXjCx5vbf";
String secret = "du6jOpdxlKNCkCo5QN6EVFiI5zSaAv";
String url = "wss://nls-gateway.cn-shanghai.aliyuncs.com/ws/v1"; // 默认值:wss://nls-gateway.cn-shanghai.aliyuncs.com/ws/v1。
/* if (args.length == 3) {
appKey = args[0];
id = args[1];
secret = args[2];
} else if (args.length == 4) {
appKey = args[0];
id = args[1];
secret = args[2];
url = args[3];
} else {
System.err.println("run error, need params(url is optional): " + "<app-key> <AccessKeyId> <AccessKeySecret> [url]");
System.exit(-1);
}*/
//本案例使用本地文件模拟发送实时流数据。您在实际使用时,可以实时采集或接收语音流并发送到ASR服务端。
String filepath = ""; // * 此处写的文件路径地址不要提交到git, 国网电科院SCA扫描会报告为漏洞: 存在“便携性缺陷”
SpeechTranscriberDemo demo = new SpeechTranscriberDemo(appKey, id, secret, url);
demo.process(filepath);
demo.shutdown();
}
} }
\ No newline at end of file
...@@ -1537,10 +1537,10 @@ ...@@ -1537,10 +1537,10 @@
AND wlesal.create_date LIKE CONCAT( DATE_FORMAT( NOW( ), '%Y-%m-%d' ), '%' ) AND wlesal.create_date LIKE CONCAT( DATE_FORMAT( NOW( ), '%Y-%m-%d' ), '%' )
</if> </if>
<if test="startDate != null and startDate != ''"> <if test="startDate != null and startDate != ''">
AND wlesal.create_date >= DATE_FORMAT( ${startDate}, '%Y-%m-%d %H:%i:%s' ) AND wlesal.create_date >= DATE_FORMAT( #{startDate}, '%Y-%m-%d %H:%i:%s' )
</if> </if>
<if test="endDate != null and endDate != ''"> <if test="endDate != null and endDate != ''">
AND DATE_FORMAT( ${endDate}, '%Y-%m-%d %H:%i:%s' ) >= wlesal.create_date AND DATE_FORMAT( #{endDate}, '%Y-%m-%d %H:%i:%s' ) >= wlesal.create_date
</if> </if>
<if test="systemCode != null and systemCode != ''"> <if test="systemCode != null and systemCode != ''">
and fs.code = #{systemCode} and fs.code = #{systemCode}
......
...@@ -7005,10 +7005,10 @@ ...@@ -7005,10 +7005,10 @@
<if test="sortField != null and sortField != ''"> <if test="sortField != null and sortField != ''">
<choose> <choose>
<when test="sortOrder == 'ascend'"> <when test="sortOrder == 'ascend'">
${sortField} ASC _sortField ASC
</when> </when>
<otherwise> <otherwise>
${sortField} DESC _sortField DESC
</otherwise> </otherwise>
</choose> </choose>
</if> </if>
......
...@@ -135,9 +135,9 @@ fire-rescue=1432549862557130753 ...@@ -135,9 +135,9 @@ fire-rescue=1432549862557130753
management.endpoints.enabled-by-default=false management.endpoints.enabled-by-default=false
#阿里云实时语音识别参数 #阿里云实时语音识别参数
speech-config.access-key-id=LTAI5t62oH95jgbjRiNXPsho speech-config.access-key-id=ENC(bgO92hxidPL5U5gKK94aEHvWAQ9db9wjb/7XgkCsw6J+t9gTD20xsWrxF2tPY90Kw2fM/25m4ER7K5SQLsdi9g==)
speech-config.access-key-secret=shy9SpogYgcdDoyTB3bvP21VSRmz8n speech-config.access-key-secret=ENC(GZthiafYoLwmNWRgT97aiVEBM6NkBnAx9tPyLKlUo/Qoh1r6A3R1u0x4WxSMcuGPqb1OlA/4DsZWpJ5kpONuQA==)
speech-config.app-key=FC84bGUpbNFrexoL speech-config.app-key=ENC(AR74B7pRjlZVPInZ9RsZroQRHjuU/6rkGamtcp2O5XMLbEgk8NMEEAksnLrNaKFmrUlkfMnNkC5bIiwjVisx3w==)
mqtt.topic.command.car.jw=carCoordinates mqtt.topic.command.car.jw=carCoordinates
......
...@@ -1523,13 +1523,13 @@ ...@@ -1523,13 +1523,13 @@
UNION ALL UNION ALL
SELECT SELECT
ifnull( count( DISTINCT LEFT(p_plan_task.point_num, 18) ), 0 ) AS value, COUNT(DISTINCT LEFT(p_plan_task.org_code, 18)) AS value,
'今日已巡查站' AS name, '今日已巡查站' AS name,
'JRYXCZ' AS code 'JRYXCZ' AS code
FROM FROM
p_plan_task p_plan_task
<where> <where>
finish_status = 2 (finish_status = 2 OR finish_status = 3)
AND DATE_FORMAT( check_date, '%Y-%m-%d' ) = CURRENT_DATE () AND DATE_FORMAT( check_date, '%Y-%m-%d' ) = CURRENT_DATE ()
<if test="bizOrgCode != null and bizOrgCode != ''"> <if test="bizOrgCode != null and bizOrgCode != ''">
AND org_code LIKE CONCAT(#{bizOrgCode}, '%') AND org_code LIKE CONCAT(#{bizOrgCode}, '%')
......
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