Commit ae8911bb authored by KeYong's avatar KeYong

Merge branch 'develop_dl_bugfix' of http://36.40.66.175:5000/moa/amos-boot-biz…

Merge branch 'develop_dl_bugfix' of http://36.40.66.175:5000/moa/amos-boot-biz into develop_dl_bugfix # Conflicts: # amos-boot-module/amos-boot-module-api/amos-boot-module-equip-api/src/main/java/com/yeejoin/equipmanage/common/utils/WordHtml.java # amos-boot-module/amos-boot-module-biz/amos-boot-module-patrol-biz/src/main/java/com/yeejoin/amos/patrol/business/util/WordHtml.java
parents f021d979 3e89820d
package com.yeejoin.amos.boot.biz.common.utils;
import java.security.SecureRandom;
import java.util.Random;
public class SecureRandomUtil {
public static int getIntSecureRandom(Integer bound) {
......@@ -17,14 +16,4 @@ public class SecureRandomUtil {
public static int getIntSecureRandom(Integer bound, SecureRandom secureRandom) {
return secureRandom.nextInt(bound);
}
public static void main(String[] args) {
SecureRandom secureRandom = new SecureRandom();
System.out.println((secureRandom.nextDouble() * 9 + 1) * 100000 + "-----");
Random random = new Random();
System.out.println((Math.random() * 9 + 1) * 100000);
System.out.println((int) (secureRandom.nextDouble() * 900 + 100));
}
}
......@@ -22,7 +22,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
*
*
* @Author lichenglong
*
*/
......@@ -40,7 +40,7 @@ public class oConvertUtils {
}
return (false);
}
public static boolean isNotEmpty(Object object) {
if (object != null && !object.equals("") && !object.equals("null")) {
return (true);
......@@ -164,7 +164,7 @@ public class oConvertUtils {
return (defval);
}
}
public static Integer getInt(Object object) {
if (isEmpty(object)) {
return null;
......@@ -208,7 +208,7 @@ public class oConvertUtils {
/*public static String escapeJava(Object s) {
return StringEscapeUtils.escapeJava(getString(s));
}*/
public static String getString(Object object) {
if (isEmpty(object)) {
return "";
......@@ -247,24 +247,10 @@ public class oConvertUtils {
return test.longValue();
}
/**
* 获取本机IP
*/
public static String getIp() {
String ip = null;
try {
InetAddress address = InetAddress.getLocalHost();
ip = address.getHostAddress();
} catch (UnknownHostException e) {
e.printStackTrace();
}
return ip;
}
/**
* 判断一个类是否为基本数据类型。
*
*
* @param clazz
* 要判断的类。
* @return true 表示为基本数据类型。
......@@ -293,41 +279,8 @@ public class oConvertUtils {
}
/**
* @return 本机IP
* @throws SocketException
*/
public static String getRealIp() throws SocketException {
String localip = null;// 本地IP,如果没有配置外网IP则返回它
String netip = null;// 外网IP
Enumeration<NetworkInterface> netInterfaces = NetworkInterface.getNetworkInterfaces();
InetAddress ip = null;
boolean finded = false;// 是否找到外网IP
while (netInterfaces.hasMoreElements() && !finded) {
NetworkInterface ni = netInterfaces.nextElement();
Enumeration<InetAddress> address = ni.getInetAddresses();
while (address.hasMoreElements()) {
ip = address.nextElement();
if (!ip.isSiteLocalAddress() && !ip.isLoopbackAddress() && ip.getHostAddress().indexOf(":") == -1) {// 外网IP
netip = ip.getHostAddress();
finded = true;
break;
} else if (ip.isSiteLocalAddress() && !ip.isLoopbackAddress() && ip.getHostAddress().indexOf(":") == -1) {// 内网IP
localip = ip.getHostAddress();
}
}
}
if (netip != null && !"".equals(netip)) {
return netip;
} else {
return localip;
}
}
/**
* java去除字符串中的空格、回车、换行符、制表符
*
*
* @param str
* @return
*/
......@@ -344,7 +297,7 @@ public class oConvertUtils {
/**
* 判断元素是否在数组内
*
*
* @param substring
* @param source
* @return
......@@ -371,7 +324,7 @@ public class oConvertUtils {
/**
* SET转换MAP
*
*
* @param str
* @return
*/
......@@ -415,12 +368,12 @@ public class oConvertUtils {
private static boolean isInner(long userIp, long begin, long end) {
return (userIp >= begin) && (userIp <= end);
}
/**
* 将下划线大写方式命名的字符串转换为驼峰式。
* 如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。</br>
* 例如:hello_world->helloWorld
*
*
* @param name
* 转换前的下划线大写方式命名的字符串
* @return 转换后的驼峰式命名的字符串
......@@ -457,12 +410,12 @@ public class oConvertUtils {
}
return result.toString();
}
/**
* 将下划线大写方式命名的字符串转换为驼峰式。
* 如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。</br>
* 例如:hello_world,test_id->helloWorld,testId
*
*
* @param name
* 转换前的下划线大写方式命名的字符串
* @return 转换后的驼峰式命名的字符串
......@@ -480,13 +433,13 @@ public class oConvertUtils {
String result = sf.toString();
return result.substring(0, result.length() - 1);
}
//update-begin--Author:zhoujf Date:20180503 for:TASK #2500 【代码生成器】代码生成器开发一通用模板生成功能
/**
* 将下划线大写方式命名的字符串转换为驼峰式。(首字母写)
* 如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。</br>
* 例如:hello_world->HelloWorld
*
*
* @param name
* 转换前的下划线大写方式命名的字符串
* @return 转换后的驼峰式命名的字符串
......@@ -515,7 +468,7 @@ public class oConvertUtils {
return result.toString();
}
//update-end--Author:zhoujf Date:20180503 for:TASK #2500 【代码生成器】代码生成器开发一通用模板生成功能
/**
* 将驼峰命名转化成下划线
* @param para
......@@ -523,18 +476,18 @@ public class oConvertUtils {
*/
public static String camelToUnderline(String para){
if(para.length()<3){
return para.toLowerCase();
return para.toLowerCase();
}
StringBuilder sb=new StringBuilder(para);
int temp=0;//定位
//从第三个字符开始 避免命名不规范
//从第三个字符开始 避免命名不规范
for(int i=2;i<para.length();i++){
if(Character.isUpperCase(para.charAt(i))){
sb.insert(i+temp, "_");
temp+=1;
}
}
return sb.toString().toLowerCase();
return sb.toString().toLowerCase();
}
/**
......@@ -549,10 +502,10 @@ public class oConvertUtils {
}
return sb.toString();
}
/**
* 获取类的所有属性,包括父类
*
*
* @param object
* @return
*/
......@@ -567,7 +520,7 @@ public class oConvertUtils {
fieldList.toArray(fields);
return fields;
}
/**
* 将map的key全部转成小写
* @param list
......@@ -577,10 +530,10 @@ public class oConvertUtils {
List<Map<String, Object>> select = new ArrayList<>();
for (Map<String, Object> row : list) {
Map<String, Object> resultMap = new HashMap<>();
Set<String> keySet = row.keySet();
for (String key : keySet) {
String newKey = key.toLowerCase();
resultMap.put(newKey, row.get(key));
Set<String> keySet = row.keySet();
for (String key : keySet) {
String newKey = key.toLowerCase();
resultMap.put(newKey, row.get(key));
}
select.add(resultMap);
}
......@@ -676,7 +629,7 @@ public class oConvertUtils {
}
return json;
}
/**
* 字符串转为数组
* @param strs
......
......@@ -24,9 +24,9 @@ import org.typroject.tyboot.core.restful.exception.GlobalExceptionHandler;
import java.net.InetAddress;
/**
*
*
* <pre>
*
*
* </pre>
*
* @author gwb
......@@ -45,27 +45,21 @@ import java.net.InetAddress;
"org.typroject.tyboot.face.*.orm.dao*", "com.yeejoin.amos.boot.biz.common.dao.mapper" })
@ComponentScan({ "org.typroject", "com.yeejoin.amos" })
public class AccessapiApplication {
@Autowired
private TaAccessConfigServiceImpl taAccessConfigServiceImpl;
private static final Logger logger = LogManager.getLogger(AccessapiApplication.class);
public static void main(String[] args) throws Exception {
// //license授权验证
// System.setProperty("root.path",ClassPathUtil.getPath()+"/config");
// log.info("(license.bat)url:" + ClassPathUtil.getPath()+"/config");
// A.v();
// 服务启动
ConfigurableApplicationContext context = SpringApplication.run(AccessapiApplication.class, args);
GlobalExceptionHandler.setAlwaysOk(true);
Environment env = context.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = env.getProperty("server.servlet.context-path");
logger.info("\n----------------------------------------------------------\n\t"
+ "Application Amos-Biz-Boot is running! Access URLs:\n\t" + "Swagger文档: \thttp://" + ip + ":" + port
+ path + "/doc.html\n" + "----------------------------------------------------------");
String appName = env.getProperty("spring.application.name");
logger.info(
"\n----------------------------------------------------------\n\t"
+ "Application {} is running!\n"
+ "----------------------------------------------------------\n"
, appName
);
}
@Bean
......
......@@ -21,9 +21,9 @@ import org.typroject.tyboot.core.restful.exception.GlobalExceptionHandler;
import java.net.InetAddress;
/**
*
*
* <pre>
*
*
* </pre>
*
* @author gwb
......@@ -50,11 +50,12 @@ public class AlarmApplication {
ConfigurableApplicationContext context = SpringApplication.run(AlarmApplication.class, args);
GlobalExceptionHandler.setAlwaysOk(true);
Environment env = context.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = env.getProperty("server.servlet.context-path");
logger.info("\n----------------------------------------------------------\n\t"
+ "Application Amos-Biz-Boot is running! Access URLs:\n\t" + "Swagger文档: \thttp://" + ip + ":" + port
+ path + "/doc.html\n" + "----------------------------------------------------------");
String appName = env.getProperty("spring.application.name");
logger.info(
"\n----------------------------------------------------------\n\t"
+ "Application {} is running!\n"
+ "----------------------------------------------------------\n"
, appName
);
}
}
......@@ -41,18 +41,16 @@ public class EquipDataApplication {
private static final Logger logger = LogManager.getLogger(EquipDataApplication.class);
public static void main(String[] args) throws Exception {
public static void main(String[] args) {
ConfigurableApplicationContext context = SpringApplication.run(EquipDataApplication.class, args);
GlobalExceptionHandler.setAlwaysOk(true);
Environment env = context.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = env.getProperty("server.servlet.context-path");
logger.info("\n----------------------------------------------------------\n\t"
+ "Application Amos-Biz-Boot is running! Access URLs:\n\t" + "Swagger文档: \thttp://" + ip + ":" + port
+ path + "/doc.html\n" + "----------------------------------------------------------");
String appName = env.getProperty("spring.application.name");
logger.info(
"\n----------------------------------------------------------\n\t"
+ "Application {} is running!\n"
+ "----------------------------------------------------------\n"
, appName
);
}
}
......@@ -21,9 +21,9 @@ import org.typroject.tyboot.core.restful.exception.GlobalExceptionHandler;
import java.net.InetAddress;
/**
*
*
* <pre>
*
*
* </pre>
*
* @author gwb
......@@ -54,11 +54,12 @@ public class OpenapiApplication {
ConfigurableApplicationContext context = SpringApplication.run(OpenapiApplication.class, args);
GlobalExceptionHandler.setAlwaysOk(true);
Environment env = context.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = env.getProperty("server.servlet.context-path");
logger.info("\n----------------------------------------------------------\n\t"
+ "Application Amos-Biz-Boot is running! Access URLs:\n\t" + "Swagger文档: \thttp://" + ip + ":" + port
+ path + "/doc.html\n" + "----------------------------------------------------------");
String appName = env.getProperty("spring.application.name");
logger.info(
"\n----------------------------------------------------------\n\t"
+ "Application {} is running!\n"
+ "----------------------------------------------------------\n"
, appName
);
}
}
......@@ -5,6 +5,8 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import reactor.core.publisher.Mono;
import java.util.Objects;
/**
* 路由限流配置
* @author zhuyu
......@@ -15,6 +17,6 @@ public class RateLimiterConfig {
@Bean(value = "remoteAddrKeyResolver")
public KeyResolver remoteAddrKeyResolver() {
return exchange -> Mono.just(exchange.getRequest().getRemoteAddress().getAddress().getHostAddress());
return exchange -> Mono.just(Objects.requireNonNull(exchange.getRequest().getRemoteAddress()).getAddress().getHostAddress());
}
}
\ No newline at end of file
......@@ -292,7 +292,7 @@ select * from (
group by cd.instance_id
) result
<if test="groupByName != null and groupByName!='' ">
group by #{groupByName}
group by ${groupByName}
</if>
</select>
......@@ -335,7 +335,7 @@ select * from (
group by cd.instance_id
) result
<if test="groupByName != null and groupByName!='' ">
group by #{groupByName}
group by ${groupByName}
</if>
</select>
......
......@@ -107,16 +107,16 @@
<foreach collection="params" index="key" item="value" separator="">
<choose>
<when test="fieldCodes[key] == 'like' and value !=null and value !=''">
and d.#{key} like concat('%',#{value},'%')
and d.${key} like concat('%',#{value},'%')
</when>
<when test="fieldCodes[key] == 'eq' and value !=null and value !=''">
and d.#{key} = #{value}
and d.${key} = #{value}
</when>
<when test="fieldCodes[key] == 'ge' and value !=null and value !=''">
and d.#{key} >= #{value}
and d.${key} >= #{value}
</when>
<when test="fieldCodes[key] == 'le' and value !=null and value !=''">
and d.#{key} <![CDATA[<=]]> #{value}
and d.${key} <![CDATA[<=]]> #{value}
</when>
</choose>
</foreach>
......@@ -157,10 +157,10 @@
<foreach collection="params" index="key" item="value" separator="">
<choose>
<when test="fieldCodes[key] == 'like' and value !=null and value !=''">
and d.#{key} like concat('%',#{value},'%')
and d.${key} like concat('%',#{value},'%')
</when>
<when test="fieldCodes[key] == 'eq' and value !=null and value !=''">
and d.#{key} = #{value}
and d.${key} = #{value}
</when>
</choose>
</foreach>
......@@ -211,10 +211,10 @@
<foreach collection="params" index="key" item="value" separator="">
<choose>
<when test="fieldCodes[key] == 'like' and value !=null and value !=''">
and d.#{key} like concat('%',#{value},'%')
and d.${key} like concat('%',#{value},'%')
</when>
<when test="fieldCodes[key] == 'eq' and value !=null and value !=''">
and d.#{key} = #{value}
and d.${key} = #{value}
</when>
</choose>
</foreach>
......@@ -335,7 +335,7 @@
<foreach collection="fieldCodes" item="value" index="key" >
,MAX(CASE WHEN i.FIELD_CODE = #{key} THEN i.FIELD_VALUE END) as #{key},
IF(FIND_IN_SET(i.field_type,'radio,select,treeSelect'), MAX(CASE WHEN i.FIELD_CODE = #{key} THEN
i.FIELD_VALUE_LABEL END), null) as #{key}Label
i.FIELD_VALUE_LABEL END), null) as ${key}Label
</foreach>
from
cb_dynamic_form_instance i
......@@ -361,16 +361,16 @@
<foreach collection="params" index="key" item="value" separator="">
<choose>
<when test="fieldCodes[key] == 'like' and value !=null and value !=''">
and d.#{key} like concat('%',#{value},'%')
and d.${key} like concat('%',#{value},'%')
</when>
<when test="fieldCodes[key] == 'eq' and value !=null and value !=''">
and d.#{key} = #{value}
and d.${key} = #{value}
</when>
<when test="fieldCodes[key] == 'ge' and value !=null and value !=''">
and d.#{key} >= #{value}
and d.${key} >= #{value}
</when>
<when test="fieldCodes[key] == 'le' and value !=null and value !=''">
and d.#{key} <![CDATA[<=]]> #{value}
and d.${key} <![CDATA[<=]]> #{value}
</when>
</choose>
</foreach>
......
......@@ -110,7 +110,7 @@
<foreach collection="map.fieldsValue.keys" item="item">
<if test="item != 'bizOrgName'">
AND a.#{item} = #{map.fieldsValue[#{item}]}
AND a.${item} = #{map.fieldsValue[#{item}]}
</if>
......@@ -218,7 +218,7 @@
<if test="map.fieldsValue != null">
<foreach collection="map.fieldsValue.keys" item="item">
<if test="item != 'bizOrgName'">
AND a.#{item} = #{map.fieldsValue[#{item}]}
AND a.${item} = #{map.fieldsValue[#{item}]}
</if>
</foreach>
</if>
......@@ -251,7 +251,7 @@
u.biz_org_code bizOrgCode,
<if test="fields != null">
<foreach collection="fields" item="item" separator=",">MAX(case f.field_code when #{item} then IFNULL(v.field_value_label, v.field_value)
end) #{item}
end) ${item}
</foreach>
</if>
FROM
......
......@@ -28,11 +28,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.net.ssl.SSLContext;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Iterator;
import java.util.Map;
......@@ -407,31 +405,33 @@ public class HttpContentTypeUtil {
/**
* 发送 delete请求带请求头
*/
public static String sendHttpDeleteJsonWithHeader(String httpUrl, String paramsJson, Map<String, String> headerMap) {
public static String sendHttpDeleteJsonWithHeader(String httpUrl, String paramsJson, Map<String, String> headerMap) throws IOException {
StringBuffer content = new StringBuffer();
try {
URL url = new URL(httpUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("DELETE");
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
for (Map.Entry<String, String> entry : headerMap.entrySet()) {
connection.setRequestProperty(entry.getKey(), entry.getValue());
}
PrintWriter printWriter = new PrintWriter(connection.getOutputStream());
URL url = new URL(httpUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("DELETE");
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
for (Map.Entry<String, String> entry : headerMap.entrySet()) {
connection.setRequestProperty(entry.getKey(), entry.getValue());
}
try (
PrintWriter printWriter = new PrintWriter(connection.getOutputStream());
InputStream inputStream = connection.getInputStream();
InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
BufferedReader br = new BufferedReader(inputStreamReader);
) {
printWriter.write(paramsJson);
printWriter.flush();
BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
content.append(line);
}
br.close();
connection.disconnect();
} catch (Exception e) {
e.printStackTrace();
}
return content.toString();
}
......
......@@ -21,6 +21,7 @@ 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;
......@@ -29,8 +30,6 @@ 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.InputStreamReader;
......@@ -333,7 +332,7 @@ public class HttpUtil {
* @param encoding
* @return
*/
public static String postSSLUrl(String url, Map<String, Object> reqMap, String encoding) throws IOException, KeyManagementException, NoSuchAlgorithmException {
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;
......@@ -385,23 +384,9 @@ public class HttpUtil {
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
public static SSLContext createIgnoreVerifySSL() throws NoSuchAlgorithmException, KeyManagementException {
SSLContext sc = SSLContext.getInstance("SSLv3");
// 实现一个X509TrustManager接口,用于绕过验证,不用修改里面的方法
X509TrustManager trustManager = new X509TrustManager() {
@Override
public void checkClientTrusted(java.security.cert.X509Certificate[] paramArrayOfX509Certificate, String paramString) {}
@Override
public void checkServerTrusted(java.security.cert.X509Certificate[] paramArrayOfX509Certificate, String paramString) {}
@Override
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return new java.security.cert.X509Certificate[]{};
}
};
sc.init(null, new TrustManager[]{trustManager}, new java.security.SecureRandom());
return sc;
public static SSLContext createIgnoreVerifySSL() throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException {
// 信任所有证书
return new SSLContextBuilder().loadTrustMaterial(null, (TrustStrategy) (arg0, arg1) -> true).build();
}
}
......@@ -20,6 +20,7 @@ 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;
......@@ -349,8 +350,7 @@ public class HttpUtils {
* @param encoding
* @return
*/
public static ResponeVo postSSLUrl(String url, Map<String, Object> reqMap, String encoding) throws IOException, KeyManagementException, NoSuchAlgorithmException {
String result;
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;
......@@ -414,25 +414,9 @@ public class HttpUtils {
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
public static SSLContext createIgnoreVerifySSL() throws NoSuchAlgorithmException, KeyManagementException {
SSLContext sc = SSLContext.getInstance("SSLv3");
// 实现一个X509TrustManager接口,用于绕过验证,不用修改里面的方法
X509TrustManager trustManager = new X509TrustManager() {
@Override
public void checkClientTrusted(java.security.cert.X509Certificate[] paramArrayOfX509Certificate, String paramString) {
}
@Override
public void checkServerTrusted(java.security.cert.X509Certificate[] paramArrayOfX509Certificate, String paramString) {
}
@Override
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return new java.security.cert.X509Certificate[]{};
}
};
sc.init(null, new TrustManager[]{trustManager}, new java.security.SecureRandom());
return sc;
public static SSLContext createIgnoreVerifySSL() throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException {
// 信任所有证书
return new SSLContextBuilder().loadTrustMaterial(null, (TrustStrategy) (arg0, arg1) -> true).build();
}
......
......@@ -139,72 +139,6 @@ public class IpUtils {
return start <= end;
}
public static List<String> getLocalIps() throws SocketException {
List<String> ips = new ArrayList<>();
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
while (networkInterfaces.hasMoreElements()) {
NetworkInterface networkInterface = networkInterfaces.nextElement();
Enumeration<InetAddress> inetAddresses = networkInterface.getInetAddresses();
while (inetAddresses.hasMoreElements()) {
InetAddress inetAddress = inetAddresses.nextElement();
if (inetAddress.isLoopbackAddress()) {
//回路地址
} else if (inetAddress.isLinkLocalAddress()) {
//链接地址
} else {
ips.add(inetAddress.getHostAddress());
}
}
}
return ips;
}
/**
* 获取所有网卡,注意或过滤掉回路地址、链接地址\ipv6
* @return 网卡列表
* @throws SocketException 异常
*/
public static List<InetAddress> getLocalHostLANAddress() throws SocketException {
List<InetAddress> addresses = new ArrayList<>();
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
while (networkInterfaces.hasMoreElements()) {
NetworkInterface networkInterface = networkInterfaces.nextElement();
Enumeration<InetAddress> inetAddresses = networkInterface.getInetAddresses();
while (inetAddresses.hasMoreElements()) {
InetAddress inetAddress = inetAddresses.nextElement();
if (inetAddress.isLoopbackAddress()) {
//回路地址
} else if (inetAddress.isLinkLocalAddress()) {
//链接地址
} else {
//非链接和回路真实ip
if(inetAddress.getHostAddress().contains(":")) {
//过滤ipv6
continue;
}
addresses.add(inetAddress);
}
}
}
return addresses;
}
public static InetAddress getInetAddress(String ip) throws SocketException {
validateIp(ip);
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
while (networkInterfaces.hasMoreElements()) {
NetworkInterface networkInterface = networkInterfaces.nextElement();
Enumeration<InetAddress> inetAddresses = networkInterface.getInetAddresses();
while (inetAddresses.hasMoreElements()) {
InetAddress inetAddress = inetAddresses.nextElement();
if(inetAddress.getHostAddress().contains(ip)) {
return inetAddress;
}
}
}
throw new IllegalArgumentException("ip invalid, ip = " + ip);
}
public static String getMACAddress(InetAddress ia) throws SocketException {
// 获得网络接口对象(即网卡),并得到mac地址,mac地址存在于一个byte数组中。
byte[] mac = NetworkInterface.getByInetAddress(ia).getHardwareAddress();
......@@ -229,25 +163,5 @@ public class IpUtils {
}
return macs;
}
public static String getInet4Address() {
Enumeration<NetworkInterface> nis;
String ip = null;
try {
nis = NetworkInterface.getNetworkInterfaces();
for (; nis.hasMoreElements();) {
NetworkInterface ni = nis.nextElement();
Enumeration<InetAddress> ias = ni.getInetAddresses();
for (; ias.hasMoreElements();) {
InetAddress ia = ias.nextElement();
if (ia instanceof Inet4Address && !ia.getHostAddress().equals("127.0.0.1")) {
ip = ia.getHostAddress();
}
}
}
} catch (SocketException e) {
e.printStackTrace();
}
return ip;
}
}
......@@ -41,19 +41,13 @@ public class MyImageExtractor implements IImageExtractor {
imagePath = s1 + pre + s2;
File imageFile = new File(baseDir, imagePath);
imageFile.getParentFile().mkdirs();
InputStream in = null;
OutputStream out = null;
try {
in = new ByteArrayInputStream(imageData);
out = new FileOutputStream(imageFile);
try (
InputStream in = new ByteArrayInputStream(imageData);
OutputStream out = new FileOutputStream(imageFile);
) {
IOUtils.copy(in, out);
} finally {
if (in != null) {
IOUtils.closeQuietly(in);
}
if (out != null) {
IOUtils.closeQuietly(out);
}
} catch (IOException e) {
e.printStackTrace();
}
}
......
......@@ -5,11 +5,8 @@ import com.yeejoin.amos.boot.biz.common.utils.SecureRandomUtil;
import java.security.SecureRandom;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
public class RandomUtil {
private static ThreadLocalRandom threadLocalRandom;
public static String buildOrderNo() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
......@@ -33,14 +30,12 @@ public class RandomUtil {
* @Date 2020/12/18 11:49
*/
public static String buildNo(String resourceType, String companyCode) {
threadLocalRandom = ThreadLocalRandom.current();
int num = threadLocalRandom.nextInt(1000, 9999);
return resourceType + companyCode + num;
int intSecureRandom = SecureRandomUtil.getIntSecureRandom(9999 - 1000) + 1000;
return resourceType + companyCode + intSecureRandom;
}
public static String buildNo() {
threadLocalRandom = ThreadLocalRandom.current();
int num = threadLocalRandom.nextInt(1000, 9999);
int num = SecureRandomUtil.getIntSecureRandom(9999 - 1000) + 1000;
return String.valueOf(num);
}
}
......@@ -67,9 +67,8 @@ public class TikaUtils {
ContentHandler handler = new ToHTMLContentHandler();
AutoDetectParser parser = new AutoDetectParser();
Metadata metadata = new Metadata();
InputStream stream = null;
try {
stream = new FileInputStream(new File(fileName));
try (InputStream stream = new FileInputStream(new File(fileName));) {
parser.parse(stream, handler, metadata);
FileHelper.writeFile(handler.toString(), outPutFile + ".html");
......@@ -78,8 +77,6 @@ public class TikaUtils {
return null;
} catch (Exception e) {
e.printStackTrace();
} finally {
}
return "";
......
......@@ -78,7 +78,10 @@ public class WordConverterUtils {
* @param readUrl html中img标签的图片存储路径
*/
private static void docToHtml(File srcFile, File targetFile, String readUrl) {
try {
try (
FileInputStream inputStream = new FileInputStream(srcFile);
HWPFDocument wordDocument = new HWPFDocument(inputStream);
) {
String imagePathStr = srcFile.getParentFile().getAbsolutePath() + imgPath;
File imagePath = new File(imagePathStr);
if (!imagePath.exists()) {
......@@ -86,13 +89,12 @@ public class WordConverterUtils {
}
String srcName = srcFile.getName();
String suffix = srcName.substring(0, srcName.lastIndexOf(".")) + "_";
HWPFDocument wordDocument = new HWPFDocument(new FileInputStream(srcFile));
org.w3c.dom.Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
WordToHtmlConverter wordToHtmlConverter = new WordToHtmlConverter(document);
String uri = readUrl + imagePathStr.substring(imagePathStr.indexOf("docs"));
wordToHtmlConverter.setPicturesManager((content, pictureType, name, width, height) -> {
try {
FileOutputStream out = new FileOutputStream(imagePathStr + suffix + name);
try (FileOutputStream out = new FileOutputStream(imagePathStr + suffix + name);) {
out.write(content);
return uri + suffix + name;
} catch (Exception e) {
......@@ -124,7 +126,10 @@ public class WordConverterUtils {
* @return
*/
private static String docToHtmlString(File srcFile, String readUrl) {
try {
try (
FileInputStream inputStream = new FileInputStream(srcFile);
HWPFDocument wordDocument = new HWPFDocument(inputStream);
) {
String imagePathStr = srcFile.getParentFile().getAbsolutePath() + imgPath;
File imagePath = new File(imagePathStr);
if (!imagePath.exists()) {
......@@ -132,13 +137,12 @@ public class WordConverterUtils {
}
String srcName = srcFile.getName();
String suffix = srcName.substring(0, srcName.lastIndexOf(".")) + "_";
HWPFDocument wordDocument = new HWPFDocument(new FileInputStream(srcFile));
org.w3c.dom.Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
WordToHtmlConverter wordToHtmlConverter = new WordToHtmlConverter(document);
String uri = readUrl + imagePathStr.substring(imagePathStr.indexOf("docs"));
wordToHtmlConverter.setPicturesManager((content, pictureType, name, width, height) -> {
try {
FileOutputStream out = new FileOutputStream(imagePathStr + suffix + name);
try (FileOutputStream out = new FileOutputStream(imagePathStr + suffix + name);) {
out.write(content);
return uri + suffix + name;
} catch (Exception e) {
......@@ -183,30 +187,22 @@ public class WordConverterUtils {
}
String temp = srcFile.getName();
String suffix = temp.substring(0, temp.lastIndexOf(".")) + "_";
OutputStreamWriter outputStreamWriter = null;
try {
XWPFDocument document = new XWPFDocument(new FileInputStream(srcFile));
try (
FileInputStream inputStream = new FileInputStream(srcFile);
XWPFDocument document = new XWPFDocument(inputStream);
FileOutputStream fileOutputStream = new FileOutputStream(targetFile);
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream, "utf-8");
) {
XHTMLOptions options = XHTMLOptions.create();
options.setExtractor(new MyImageExtractor(imagePath, suffix));
String uri = readUrl + imagePathStr.substring(imagePathStr.indexOf("docs"));
System.out.println("uri :" + uri);
options.URIResolver(new MyURIResolver(uri));
outputStreamWriter = new OutputStreamWriter(new FileOutputStream(targetFile), "utf-8");
XHTMLConverter xhtmlConverter = (XHTMLConverter) XHTMLConverter.getInstance();
xhtmlConverter.convert(document, outputStreamWriter, options);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (outputStreamWriter != null) {
outputStreamWriter.close();
}
} catch (Exception e2) {
e2.printStackTrace();
}
}
}
/**
......@@ -223,9 +219,11 @@ public class WordConverterUtils {
}
String temp = srcFile.getName();
String suffix = temp.substring(0, temp.lastIndexOf(".")) + "_";
OutputStreamWriter outputStreamWriter = null;
try {
XWPFDocument document = new XWPFDocument(new FileInputStream(srcFile));
try (
FileInputStream inputStream = new FileInputStream(srcFile);
XWPFDocument document = new XWPFDocument(inputStream);
) {
XHTMLOptions options = XHTMLOptions.create();
options.setExtractor(new MyImageExtractor(imagePath, suffix));
String uri = readUrl + imagePathStr.substring(imagePathStr.indexOf("docs"));
......@@ -237,15 +235,6 @@ public class WordConverterUtils {
return stringWriter.toString();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (outputStreamWriter != null) {
outputStreamWriter.close();
}
} catch (Exception e2) {
e2.printStackTrace();
}
}
return null;
......
......@@ -89,27 +89,16 @@ public class WordTemplateUtils {
public File getWordFileItem(Map map, String title, String ftlFile) throws IOException {
configuration.setClassForTemplateLoading(this.getClass(), "/ftl");
Template freemarkerTemplate = configuration.getTemplate(ftlFile, "UTF-8");
File file = null;
// 调用工具类的createDoc方法生成Word文档
File file = createDoc(map, freemarkerTemplate);
File filepdf = new File("sellPlan.pdf");
InputStream fin = null;
OutputStream os = null;
try {
// 调用工具类的createDoc方法生成Word文档
file = createDoc(map, freemarkerTemplate);
fin = new FileInputStream(file);
os = new FileOutputStream(filepdf);
try (
InputStream fin =new FileInputStream(file) ;
OutputStream os = new FileOutputStream(filepdf);
)
{
wordTopdfByAspose(fin, os);
return filepdf;
} finally {
if (fin != null) {
fin.close();
}
if (os != null) {
os.close();
}
if (file != null) {
file.delete();
}// 删除临时文件
}
}
......
......@@ -51,17 +51,25 @@ public class IOConfig {
tmp2.put("lower-greek", 1L);
ILV1_MAP = Collections.unmodifiableMap(tmp2);
NumberingDefinitionsPart numberingDefinitionsPart = null;
try {
numberingDefinitionsPart = new NumberingDefinitionsPart();
InputStream is = IOConfig.class.getClassLoader().getResourceAsStream("office/listStyle.xml");
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
StringBuilder builder = new StringBuilder();
String str;
while ((str = reader.readLine()) != null) {
builder.append(str);
try (
InputStream is = IOConfig.class.getClassLoader().getResourceAsStream("office/listStyle.xml");
) {
assert is != null;
try (InputStreamReader inputStreamReader = new InputStreamReader(is, "UTF-8");
BufferedReader reader = new BufferedReader(inputStreamReader);
) {
numberingDefinitionsPart = new NumberingDefinitionsPart();
StringBuilder builder = new StringBuilder();
String str;
while ((str = reader.readLine()) != null) {
builder.append(str);
}
Numbering numbering = (Numbering) XmlUtils.unmarshalString(builder.toString());
numberingDefinitionsPart.setJaxbElement(numbering);
} catch (Exception e) {
e.printStackTrace();
}
Numbering numbering = (Numbering) XmlUtils.unmarshalString(builder.toString());
numberingDefinitionsPart.setJaxbElement(numbering);
} catch (Exception e) {
e.printStackTrace();
}
......
......@@ -495,6 +495,7 @@ public class DocxBuilder {
*/
private static byte[] getRemotePic2Bytes(String picUrl) {
byte[] picBytes = {};
InputStream is = null;
try {
if (picUrl.startsWith(IOConfig.PIC_ROUTER)) {
picUrl = picUrl.replaceFirst(IOConfig.PIC_ROUTER, IOConfig.PIC_URI);
......@@ -504,7 +505,7 @@ public class DocxBuilder {
// 设置请求超时为5s
con.setConnectTimeout(5 * 1000);
// 输入流
InputStream is = con.getInputStream();
is = con.getInputStream();
// 1K的数据缓冲
byte[] current = new byte[1024];
// 读取到的数据长度
......@@ -513,9 +514,16 @@ public class DocxBuilder {
picBytes = Arrays.copyOf(picBytes, picBytes.length + len);
System.arraycopy(current, 0, picBytes, picBytes.length - len, len);
}
is.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != is) {
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return picBytes;
}
......
......@@ -21,6 +21,7 @@ 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;
......@@ -29,8 +30,6 @@ 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.InputStreamReader;
......@@ -337,7 +336,7 @@ public class HttpUtil {
* @return
*/
public static String postSslUrl(String url, Map<String, Object> reqMap, String encoding) throws IOException,
KeyManagementException, NoSuchAlgorithmException {
NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
String result;
CloseableHttpClient httpClient = null;
CloseableHttpResponse response = null;
......@@ -389,24 +388,8 @@ public class HttpUtil {
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
public static SSLContext createIgnoreVerifySsl() throws NoSuchAlgorithmException, KeyManagementException {
SSLContext sc = SSLContext.getInstance("SSLv3");
// 实现一个X509TrustManager接口,用于绕过验证,不用修改里面的方法
X509TrustManager trustManager = new X509TrustManager() {
@Override
public void checkClientTrusted(java.security.cert.X509Certificate[] paramArrayOfX509Certificate, String paramString) {
}
@Override
public void checkServerTrusted(java.security.cert.X509Certificate[] paramArrayOfX509Certificate, String paramString) {
}
@Override
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return new java.security.cert.X509Certificate[]{};
}
};
sc.init(null, new TrustManager[]{trustManager}, new java.security.SecureRandom());
return sc;
public static SSLContext createIgnoreVerifySsl() throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
// 信任所有证书
return new SSLContextBuilder().loadTrustMaterial(null, (TrustStrategy) (arg0, arg1) -> true).build();
}
}
......@@ -20,6 +20,7 @@ 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;
......@@ -286,8 +287,7 @@ public class HttpUtils {
* @return
*/
public static ResponeVo postSslUrl(String url, Map<String, Object> reqMap, String encoding) throws IOException,
KeyManagementException, NoSuchAlgorithmException {
String result;
KeyManagementException, NoSuchAlgorithmException, KeyStoreException {
CloseableHttpClient httpClient = null;
CloseableHttpResponse response = null;
ResponeVo responeVo = null;
......@@ -351,25 +351,9 @@ public class HttpUtils {
* @throws NoSuchAlgorithmException
* @throws KeyManagementException
*/
public static SSLContext createIgnoreVerifySsl() throws NoSuchAlgorithmException, KeyManagementException {
SSLContext sc = SSLContext.getInstance("SSLv3");
// 实现一个X509TrustManager接口,用于绕过验证,不用修改里面的方法
X509TrustManager trustManager = new X509TrustManager() {
@Override
public void checkClientTrusted(java.security.cert.X509Certificate[] paramArrayOfX509Certificate, String paramString) {
}
@Override
public void checkServerTrusted(java.security.cert.X509Certificate[] paramArrayOfX509Certificate, String paramString) {
}
@Override
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return new java.security.cert.X509Certificate[]{};
}
};
sc.init(null, new TrustManager[]{trustManager}, new java.security.SecureRandom());
return sc;
public static SSLContext createIgnoreVerifySsl() throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException {
// 信任所有证书
return new SSLContextBuilder().loadTrustMaterial(null, (TrustStrategy) (arg0, arg1) -> true).build();
}
private static String inputStreamToString(InputStream is) {
......
......@@ -137,73 +137,6 @@ public class IpUtils {
return start <= end;
}
public static List<String> getLocalIps() throws SocketException {
List<String> ips = new ArrayList<>();
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
while (networkInterfaces.hasMoreElements()) {
NetworkInterface networkInterface = networkInterfaces.nextElement();
Enumeration<InetAddress> inetAddresses = networkInterface.getInetAddresses();
while (inetAddresses.hasMoreElements()) {
InetAddress inetAddress = inetAddresses.nextElement();
if (inetAddress.isLoopbackAddress()) {
//回路地址
} else if (inetAddress.isLinkLocalAddress()) {
//链接地址
} else {
ips.add(inetAddress.getHostAddress());
}
}
}
return ips;
}
/**
* 获取所有网卡,注意或过滤掉回路地址、链接地址\ipv6
*
* @return 网卡列表
* @throws SocketException 异常
*/
public static List<InetAddress> getLocalHostLanAddress() throws SocketException {
List<InetAddress> addresses = new ArrayList<>();
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
while (networkInterfaces.hasMoreElements()) {
NetworkInterface networkInterface = networkInterfaces.nextElement();
Enumeration<InetAddress> inetAddresses = networkInterface.getInetAddresses();
while (inetAddresses.hasMoreElements()) {
InetAddress inetAddress = inetAddresses.nextElement();
if (inetAddress.isLoopbackAddress()) {
//回路地址
} else if (inetAddress.isLinkLocalAddress()) {
//链接地址
} else {
//非链接和回路真实ip
if (inetAddress.getHostAddress().contains(":")) {
//过滤ipv6
continue;
}
addresses.add(inetAddress);
}
}
}
return addresses;
}
public static InetAddress getInetAddress(String ip) throws SocketException {
validateIp(ip);
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
while (networkInterfaces.hasMoreElements()) {
NetworkInterface networkInterface = networkInterfaces.nextElement();
Enumeration<InetAddress> inetAddresses = networkInterface.getInetAddresses();
while (inetAddresses.hasMoreElements()) {
InetAddress inetAddress = inetAddresses.nextElement();
if (inetAddress.getHostAddress().contains(ip)) {
return inetAddress;
}
}
}
throw new IllegalArgumentException("ip invalid, ip = " + ip);
}
public static String getMacAddress(InetAddress ia) throws SocketException {
// 获得网络接口对象(即网卡),并得到mac地址,mac地址存在于一个byte数组中。
byte[] mac = NetworkInterface.getByInetAddress(ia).getHardwareAddress();
......
......@@ -651,12 +651,12 @@ public class EquipmentDetailController extends AbstractBaseController {
// List<EquipmentDetailDownloadTemplateVO> equipmentDetailDownloadS = ExcelUtils.importExcel(file, 1, 1, EquipmentDetailDownloadTemplateVO.class);
String key="";
String stringUUid="";
try {
UUID uuid = UUID.randomUUID();
key= uuid.toString();
ExcelEnums excelEnums = null;
if (!enabled){
UUID uuid = UUID.randomUUID();
stringUUid = uuid.toString();
ExcelEnums excelEnums = null;
if (!enabled) {
excelEnums = ExcelEnums.getByKey(ExcelEnums.XFZBSINGLE.getType());
}else {
excelEnums = ExcelEnums.getByKey(ExcelEnums.XFZB.getType());
......@@ -664,14 +664,14 @@ public class EquipmentDetailController extends AbstractBaseController {
ExcelDto excelDto = new ExcelDto(excelEnums.getFileName(), excelEnums.getSheetName(), excelEnums.getClassUrl(), excelEnums.getType());
// date= excelService.commonUpload(file, excelDto, getSelectedOrgInfo(), getUserInfo());
EquipmentDetailController controllerProxy1 = SpringUtils.getBean(EquipmentDetailController.class);
controllerProxy1.commonUpload(file, excelDto,key, getSelectedOrgInfo(), getUserInfo());
controllerProxy1.commonUpload(file, excelDto, stringUUid, getSelectedOrgInfo(), getUserInfo());
EquipmentDetailController controllerProxy = SpringUtils.getBean(EquipmentDetailController.class);
controllerProxy.refreshAllCount();
} catch (Exception e) {
e.printStackTrace();
throw new BadRequest(e.getMessage());
}
return ResponseHelper.buildResponse(key);
return ResponseHelper.buildResponse(stringUUid);
}
......
......@@ -272,17 +272,14 @@ public class EquipmentManageServiceImpl extends ServiceImpl<EquipmentManageMappe
@Override
public void downLoad(FileUploadVo vo, HttpServletResponse response) {
String fileName = vo.getName() ;
ServletOutputStream out;
response.setHeader("Content-Disposition", "attachment;fileName="+fileName);
response.setHeader("Access-Control-Expose-Headers", "access_token");
response.setHeader("Access-Control-Allow-Origin", "*");
response.setContentType("multipart/form-data");
try {
InputStream inputStream = getInputStreamFromURL(vo.getUrl());
//3.通过response获取ServletOutputStream对象(out)
out = response.getOutputStream();
try (InputStream inputStream = getInputStreamFromURL(vo.getUrl());
//3.通过response获取ServletOutputStream对象(out)
ServletOutputStream out = response.getOutputStream();
) {
int b = 0;
byte[] buffer = new byte[512];
while (b != -1){
......@@ -290,10 +287,7 @@ public class EquipmentManageServiceImpl extends ServiceImpl<EquipmentManageMappe
//4.写到输出流(out)中
out.write(buffer,0,b);
}
inputStream.close();
out.close();
out.flush();
} catch (IOException e) {
e.printStackTrace();
}
......
......@@ -618,27 +618,6 @@ public class EquipmentSpecificAlarmServiceImpl extends ServiceImpl<EquipmentSpec
return lists;
}
private static String getInet4Address() {
Enumeration<NetworkInterface> nis;
String ip = null;
try {
nis = NetworkInterface.getNetworkInterfaces();
for (; nis.hasMoreElements(); ) {
NetworkInterface ni = nis.nextElement();
Enumeration<InetAddress> ias = ni.getInetAddresses();
for (; ias.hasMoreElements(); ) {
InetAddress ia = ias.nextElement();
if (ia instanceof Inet4Address && !ia.getHostAddress().equals("127.0.0.1")) {
ip = ia.getHostAddress();
}
}
}
} catch (SocketException e) {
e.printStackTrace();
}
return ip;
}
@Override
public int getCountAlarmEquipment() {
return equipmentSpecificAlarmMapper.getCountAlarmEquipment();
......
......@@ -1120,27 +1120,6 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
return this.baseMapper.getEquipmentAlarmBySystemIdOrSourceIdVO(page, sourceId, systemId, confirmType, createDate, type, equipmentId);
}
private static String getInet4Address() {
Enumeration<NetworkInterface> nis;
String ip = null;
try {
nis = NetworkInterface.getNetworkInterfaces();
for (; nis.hasMoreElements(); ) {
NetworkInterface ni = nis.nextElement();
Enumeration<InetAddress> ias = ni.getInetAddresses();
for (; ias.hasMoreElements(); ) {
InetAddress ia = ias.nextElement();
if (ia instanceof Inet4Address && !ia.getHostAddress().equals("127.0.0.1")) {
ip = ia.getHostAddress();
}
}
}
} catch (SocketException e) {
e.printStackTrace();
}
return ip;
}
@Override
public Map<String, Object> integrationPageSysData(String systemCode, Boolean isUpdate) {
// TODO Auto-generated method stub
......
......@@ -82,10 +82,6 @@ public class RiskSourceSceneServiceImpl extends ServiceImpl<RiskSourceSceneMappe
@Value("${equip.point.equipmentdata.url}")
private String equipmentdataUrl;
//
// @Value("${equip.point.statusApi.url}")
// private String statusApiUrl;
@Value("${mqtt.scene.host}")
private String sceneUrl;
......@@ -243,12 +239,6 @@ public class RiskSourceSceneServiceImpl extends ServiceImpl<RiskSourceSceneMappe
@Override
public List queryPartType() {
InetAddress address = null;
try {
address = InetAddress.getLocalHost();
} catch (UnknownHostException e) {
e.printStackTrace();
}
String categoryUrl = url;
List<EquipmentCategory> list = iEquipmentCategoryService.list();
List<Map> returnList;
......@@ -324,7 +314,7 @@ public class RiskSourceSceneServiceImpl extends ServiceImpl<RiskSourceSceneMappe
public List<PointTreeVo> getSystemmeanLsit() {
return equipmentSpecificMapper.getSystemmeanLsit();
}
@Override
public List<Map> getstatus(String sceneId) {
List<Map> data = new ArrayList<>();
......@@ -334,7 +324,7 @@ public class RiskSourceSceneServiceImpl extends ServiceImpl<RiskSourceSceneMappe
}else{
equipIndexLatestStatus = equipmentSpecificMapper.getEquipLatestStatusBySceneId(sceneId);
}
equipIndexLatestStatus.forEach(action->{
Map<String, String> map = new HashMap<>();
map.put("equipCode", action.getQrCode());
......@@ -351,59 +341,6 @@ public class RiskSourceSceneServiceImpl extends ServiceImpl<RiskSourceSceneMappe
return data;
}
private String getStatusByQrCode(String qrCode) {
List<EquipmentSpecificIndex> equipMentStatus = equipmentSpecificMapper.getEquipMentStatus(qrCode);
if (equipMentStatus == null || equipMentStatus.size() == 0) {
return EquipmentRiskTypeEnum.QT.getStateCode();
}
// 组态图用
LinkedHashMap<String, String> map = equipMentStatus.stream().collect(LinkedHashMap::new, (n, v) -> n.put(v.getType(), v.getValue()), LinkedHashMap::putAll);
List<String> list = new ArrayList<>(map.keySet());
boolean flag = false;
if (0 < list.size()) {
for (String s : list) {
if (EquipmentRiskTypeEnum.HZGJ.getCode().equals(s)) {
flag = true;
if (TrueOrFalseEnum.real.value.equals(map.get(s))) {
return EquipmentRiskTypeEnum.HZGJ.getStateCode();
} else if (TrueOrFalseEnum.fake.value.equals(map.get(s))) {
return EquipmentRiskTypeEnum.YXZT.getStateCode();
}
}
if (EquipmentRiskTypeEnum.GZ.getCode().equals(s)) {
flag = true;
if (TrueOrFalseEnum.real.value.equals(map.get(s))) {
return EquipmentRiskTypeEnum.GZ.getStateCode();
} else if (TrueOrFalseEnum.fake.value.equals(map.get(s))) {
return EquipmentRiskTypeEnum.YXZT.getStateCode();
}
}
if (EquipmentRiskTypeEnum.PB.getCode().equals(s)) {
flag = true;
if (TrueOrFalseEnum.real.value.equals(map.get(s))) {
return EquipmentRiskTypeEnum.PB.getStateCode();
} else if (TrueOrFalseEnum.fake.value.equals(map.get(s))) {
return EquipmentRiskTypeEnum.YXZT.getStateCode();
}
}
// 如果是运行状态且值为false 或 所有指标都不存在返回挂起
if (EquipmentRiskTypeEnum.YXZT.getCode().equals(s)) {
flag = true;
if (TrueOrFalseEnum.fake.value.equals(map.get(s))) {
return EquipmentRiskTypeEnum.QT.getStateCode();
}
}
}
}
if (flag) {
return EquipmentRiskTypeEnum.QT.getStateCode();
}
return EquipmentRiskTypeEnum.YXZT.getStateCode();
}
private Map<String, Object> getSystemEquList(Map<String, Object> res, String orgCode, Long id) {
List<PointTreeVo> list = equipmentSpecificMapper.getSystemEquList(orgCode, id);
String firstCanvas = equipmentSpecificMapper.getFirstCanvas(orgCode);
......@@ -428,70 +365,6 @@ public class RiskSourceSceneServiceImpl extends ServiceImpl<RiskSourceSceneMappe
return res;
}
private List<RiskSourceTreeVO> getImportantEquipTree(List<RiskSourceTreeVO> list) {
List<RiskSourceTreeVO> treeList = new ArrayList<>();
for (RiskSourceTreeVO tree : list) {
if (tree.getParentId() != null && tree.getParentId() == 0) {
treeList.add(tree);
}
for (RiskSourceTreeVO treeNode : list) {
if (treeNode.getParentId().longValue() == tree.getId()) {
if (tree.getChildren() == null) {
tree.setChildren(new ArrayList<>());
}
tree.getChildren().add(treeNode);
}
}
}
riskSourceTreeVOs = null;
for (RiskSourceTreeVO x : treeList) {
if (x.getChildren() != null) {
for (RiskSourceTreeVO y : x.getChildren()) {
if (y.getChildren() != null) {
for (RiskSourceTreeVO z : y.getChildren()) {
if (z.getChildren() != null) {
for (RiskSourceTreeVO m : z.getChildren()) {
List<RiskSourceTreeVO> list1 = this.baseMapper.getImportantEquip(m.getId());
List<RiskSourceTreeVO> mapperImportantEquips = this.baseMapper.getImportantEquip(m.getId());
if (mapperImportantEquips.size() > 0) {
m.getChildren().addAll(mapperImportantEquips);
}
if (riskSourceTreeVOs == null && list1.size() > 0) {
riskSourceTreeVOs = list1;
}
if (list1.size() > 0 && riskSourceTreeVOs.size() < 4) {
riskSourceTreeVOs.addAll(list1);
}
}
List<RiskSourceTreeVO> mapperImportantEquips2 = this.baseMapper.getImportantEquip(z.getId());
if (mapperImportantEquips2.size() > 0) {
z.getChildren().addAll(mapperImportantEquips2);
}
}
}
}
List<RiskSourceTreeVO> mapperImportantEquips3 = this.baseMapper.getImportantEquip(y.getId());
if (mapperImportantEquips3.size() > 0) {
if (CollectionUtils.isEmpty(y.getChildren())) {
y.setChildren(new ArrayList<>());
}
y.getChildren().addAll(mapperImportantEquips3);
}
}
}
List<RiskSourceTreeVO> mapperImportantEquips4 = this.baseMapper.getImportantEquip(x.getId());
if (mapperImportantEquips4.size() > 0) {
x.getChildren().addAll(mapperImportantEquips4);
}
}
return treeList;
}
// @Override
// public String saveMorphic(PointTreeVo PointTreeVo) {
// RiskSourceScene risk = new RiskSourceScene();
// return null;
// }
private List<RiskSourceTreeVO> getRiskSourcesTree(List<RiskSourceTreeVO> list) {
List<RiskSourceTreeVO> treeList = new ArrayList<>();
for (RiskSourceTreeVO tree : list) {
......
......@@ -41,7 +41,9 @@ public class ExcelUtil {
Class<?> model, String token, String appKey, String product, boolean flag) {
HorizontalCellStyleStrategy horizontalCellStyleStrategy = setMyCellStyle();
try {
try (
OutputStream outputStream = getOutputStream(fileName, response, ExcelTypeEnum.XLSX);
) {
//下拉列表集合
Map<Integer, String[]> explicitListConstraintMap = new HashMap<>();
if (flag) {
......@@ -54,7 +56,7 @@ public class ExcelUtil {
resolveExplicitConstraint(explicitListConstraintMap, explicitConstraint,token,appKey,product);
}
}
EasyExcel.write(getOutputStream(fileName, response, ExcelTypeEnum.XLSX), model)
EasyExcel.write(outputStream, model)
.excelType(ExcelTypeEnum.XLSX).sheet(sheetName)
.registerWriteHandler(new TemplateCellWriteHandlerDate(explicitListConstraintMap))
.registerWriteHandler(new TemplateCellWriteHandler())
......
......@@ -434,62 +434,50 @@ public class FileHelper {
}
public static void nioTransferCopy(File source, File target) {
FileChannel in = null;
FileChannel out = null;
FileInputStream inStream = null;
FileOutputStream outStream = null;
try {
inStream = new FileInputStream(source);
outStream = new FileOutputStream(target);
in = inStream.getChannel();
out = outStream.getChannel();
try (
FileInputStream inStream = new FileInputStream(source);
FileOutputStream outStream = new FileOutputStream(target);
FileChannel in = inStream.getChannel();
FileChannel out = outStream.getChannel();
) {
in.transferTo(0, in.size(), out);
} catch (IOException e) {
e.printStackTrace();
} finally {
close(inStream);
close(in);
close(outStream);
close(out);
}
}
private static boolean nioBufferCopy(File source, File target) {
FileChannel in = null;
FileChannel out = null;
FileInputStream inStream = null;
FileOutputStream outStream = null;
try {
inStream = new FileInputStream(source);
outStream = new FileOutputStream(target);
in = inStream.getChannel();
out = outStream.getChannel();
try (
FileInputStream inStream = new FileInputStream(source);
FileOutputStream outStream = new FileOutputStream(target);
FileChannel in = inStream.getChannel();
FileChannel out = outStream.getChannel();
) {
ByteBuffer buffer = ByteBuffer.allocate(4096);
while (in.read(buffer) != -1) {
buffer.flip();
out.write(buffer);
buffer.clear();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
return false;
} catch (IOException e) {
e.printStackTrace();
return false;
} finally {
close(inStream);
close(in);
close(outStream);
close(out);
}
return true;
}
public static void customBufferStreamCopy(File source, File target) {
InputStream fis = null;
OutputStream fos = null;
try {
fis = new FileInputStream(source);
fos = new FileOutputStream(target);
try (
InputStream fis = new FileInputStream(source);
OutputStream fos = new FileOutputStream(target);
) {
byte[] buf = new byte[4096];
int i;
while ((i = fis.read(buf)) != -1) {
......@@ -497,9 +485,6 @@ public class FileHelper {
}
} catch (Exception e) {
e.printStackTrace();
} finally {
close(fis);
close(fos);
}
}
......
......@@ -42,7 +42,7 @@ public class SocketClient {
logger.error(logs);
datagramSocket.send(new DatagramPacket(b, b.length, InetAddress.getLocalHost(), port));
datagramSocket.send(new DatagramPacket(b, b.length, port));
int deltaSleep = getSleepDelta(len, 16000);
Thread.sleep(deltaSleep);
TimeUnit.MILLISECONDS.sleep(100);
......@@ -53,28 +53,5 @@ public class SocketClient {
}
}
@Async
public void processTcp(int port, int type) {
if (type < 0) type = 0;
if (type >= testFilePath.length) type -= 1;
try (Socket socket = new Socket();
FileInputStream fis = new FileInputStream(testFilePath[type]);) {
socket.connect(new InetSocketAddress(InetAddress.getLocalHost().getHostAddress(), port));
OutputStream outputStream = socket.getOutputStream();
byte[] b = new byte[4096];
int len;
while ((len = fis.read(b)) > 0) {
String logs = String.format("send data pack length: %s", len);
logger.error(logs);
outputStream.write(b);
TimeUnit.MILLISECONDS.sleep(200);
}
outputStream.flush();
outputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
......@@ -102,7 +102,6 @@ public class RealTimeStream2Text {
map.add("number", number);
map.add("codec", "PCM");
map.add("uuid", UUID.randomUUID().toString());
//map.add("dstip", InetAddress.getLocalHost().getHostAddress());
map.add("dstip", localIpAddress);
map.add("dstport", String.valueOf(port));
map.add("marker", "amos");
......
......@@ -5,8 +5,6 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import com.alibaba.nls.client.AccessToken;
import com.alibaba.nls.client.protocol.InputFormatEnum;
......@@ -171,7 +169,7 @@ public class SpeechTranscriberDemo {
while ((len = fis.read(b)) > 0) {
// logger.info("send data pack length: " + len);
datagramSocket.send(new DatagramPacket(b, b.length, InetAddress.getLocalHost(), 25000));
datagramSocket.send(new DatagramPacket(b, b.length, 25000));
transcriber.send(b, len);
//本案例用读取本地文件的形式模拟实时获取语音流并发送的,因为读取速度较快,这里需要设置sleep。
......
......@@ -503,13 +503,9 @@ public class CheckServiceImpl implements ICheckService {
@Override
public AppPointCheckRespone queryCheckPointDetail(String toke, String product, String appKey, long checkId) {
// List list = checkMapper.queryCheckPointInputItem(planTaskId, pointId);
List<PointCheckDetailBo> list = checkMapper.findCheckPointInputItem(checkId);
AppPointCheckRespone pointCheckRespone = new AppPointCheckRespone();
if (!list.isEmpty()) {
// InetAddress address = InetAddress.getLocalHost();
// String ip = address.getHostAddress();
// String ipPort = "http://" + fileIp + ":" + filePort + "/";
List<String> pointImgUrls = new ArrayList<>();
PointCheckDetailBo pointCheckDetailBo = list.get(0);
List<CheckShot> pointShot = checkShotDao.findAllByCheckIdAndCheckInputIdAndClassifyId(pointCheckDetailBo.getCheckId(), 0l, 0l);
......@@ -588,13 +584,9 @@ public class CheckServiceImpl implements ICheckService {
@Override
public AppPointCheckRespone queryCheckPointDetailInVersion2(String toke, String product, String appKey,
long checkId) {
// List list = checkMapper.queryCheckPointInputItem(planTaskId, pointId);
List<PointCheckDetailBo> list = checkMapper.findCheckPointInputItem(checkId);
AppPointCheckRespone pointCheckRespone = new AppPointCheckRespone();
if (!list.isEmpty()) {
// InetAddress address = InetAddress.getLocalHost();
// String ip = address.getHostAddress();
// String ipPort = "http://" + fileIp + ":" + filePort + "/";
List<String> pointImgUrls = new ArrayList<>();
PointCheckDetailBo pointCheckDetailBo = list.get(0);
List<CheckShot> pointShot = checkShotDao.findAllByCheckIdAndCheckInputIdAndClassifyId(pointCheckDetailBo.getCheckId(), 0l, 0l);
......
......@@ -851,35 +851,33 @@ public class CheckController extends AbstractBaseController {
}
InputStream inputStream = new ByteArrayInputStream(xml.getBytes());
Source source = new StreamSource(inputStream);
try {
String filePath = Objects.requireNonNull(this.getClass().getResource("/")).getPath() + "temp" + File.separator + "checkTemplate.xsl";
if (Files.notExists(Paths.get(filePath))) {
throw new RuntimeException("模板文件不存在");
}
FileInputStream fis1 = new FileInputStream(FilenameUtils.normalize(filePath));
String filePath = Objects.requireNonNull(this.getClass().getResource("/")).getPath() + "temp" + File.separator + "checkTemplate.xsl";
if (Files.notExists(Paths.get(filePath))) {
throw new RuntimeException("模板文件不存在");
}
Date date = new Date();
String path = request.getSession().getServletContext().getRealPath("/");
String subPath = path.substring(0, path.indexOf(File.separator) + 1);
String dir = subPath + "check";
String html = subPath + "check" + File.separator + "task_"
+ date.getTime() + ".html";
File htmlFile = new File(html);
try (
FileInputStream fis1 = new FileInputStream(FilenameUtils.normalize(filePath));
FileInputStream fis = new FileInputStream(htmlFile);
) {
Source template = new StreamSource(fis1);
Date date = new Date();
String path = request.getSession().getServletContext().getRealPath("/");
String subPath = path.substring(0, path.indexOf(File.separator) + 1);
String dir = subPath + "check";
String html = subPath + "check" + File.separator + "task_"
+ date.getTime() + ".html";
File dirFile = new File(dir);
if (!dirFile.exists()) {
dirFile.mkdirs();
}
Result result = new StreamResult(html);
TransformerFactory transformerFactory = TransformerFactory.newInstance();
transformerFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
Transformer transformer = transformerFactory.newTransformer(template);
transformer.transform(source, result);
File htmlFile = new File(html);
FileInputStream fis = new FileInputStream(htmlFile);
String data = IOUtils.toString(fis, StandardCharsets.UTF_8);
fis.close();
if (htmlFile.exists()) {
htmlFile.delete();
}
......
......@@ -875,18 +875,13 @@ public class CheckServiceImpl implements ICheckService {
@Override
public AppPointCheckRespone queryCheckPointDetail(String toke,String product,String appKey,long checkId) {
// List list = checkMapper.queryCheckPointInputItem(planTaskId, pointId);
List<PointCheckDetailBo> list = checkMapper.findCheckPointInputItem(checkId);
AppPointCheckRespone pointCheckRespone = new AppPointCheckRespone();
if (!list.isEmpty()) {
// InetAddress address = InetAddress.getLocalHost();
// String ip = address.getHostAddress();
// String ipPort = "http://" + fileIp + ":" + filePort + "/";
List<String> pointImgUrls = new ArrayList<>();
PointCheckDetailBo pointCheckDetailBo = list.get(0);
List<CheckShot> pointShot = checkShotDao.findAllByCheckIdAndCheckInputIdAndClassifyId(pointCheckDetailBo.getCheckId(), 0l,0l);
pointShot.forEach(action -> {
// pointImgUrls.add(fileUrl + action.getPhotoData());
pointImgUrls.add(action.getPhotoData());
});
Check check = checkDao.findById(checkId).get();
......@@ -961,18 +956,13 @@ public class CheckServiceImpl implements ICheckService {
@Override
public AppPointCheckRespone queryCheckPointDetailInVersion2(String toke,String product,String appKey,long checkId) {
// List list = checkMapper.queryCheckPointInputItem(planTaskId, pointId);
List<PointCheckDetailBo> list = checkMapper.findCheckPointInputItem(checkId);
AppPointCheckRespone pointCheckRespone = new AppPointCheckRespone();
if (!list.isEmpty()) {
// InetAddress address = InetAddress.getLocalHost();
// String ip = address.getHostAddress();
// String ipPort = "http://" + fileIp + ":" + filePort + "/";
List<String> pointImgUrls = new ArrayList<>();
PointCheckDetailBo pointCheckDetailBo = list.get(0);
List<CheckShot> pointShot = checkShotDao.findAllByCheckIdAndCheckInputIdAndClassifyId(pointCheckDetailBo.getCheckId(), 0l,0l);
pointShot.forEach(action -> {
// pointImgUrls.add(fileUrl + action.getPhotoData());
pointImgUrls.add(action.getPhotoData());
});
Check check = checkDao.findById(checkId).get();
......
......@@ -164,7 +164,7 @@ public class LatentDangerServiceImpl implements ILatentDangerService {
// private String photoUrlPre;
// @Value("${file.url}")
// private String fileUrl;
@Value("${file.url}")
private String fileServerAddress;
......@@ -371,15 +371,6 @@ public class LatentDangerServiceImpl implements ILatentDangerService {
});
}
private String buildLocalHost() {
try {
String ip = InetAddress.getLocalHost().getHostAddress();
return "http://" + ip + ":" + port + "/";
} catch (Exception e) {
return "";
}
}
private void updateMeasuresContentStatus(Long riskFactorId, Long measuresContentId, String evaluateId, RiskFactorsCmStatusEnum riskFactorsCmStatusEnum) {
Map<String, Object> map = Maps.newHashMap();
map.put("riskFactorId", riskFactorId);
......
......@@ -2108,12 +2108,13 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
}
public static byte[] file2byte(File file) {
try {
FileInputStream in = new FileInputStream(file);
try (
FileInputStream in = new FileInputStream(file);
) {
//当文件没有结束时,每次读取一个字节显示
byte[] data = new byte[in.available()];
in.read(data);
in.close();
return data;
} catch (Exception e) {
e.printStackTrace();
......
......@@ -475,37 +475,26 @@ public class FileHelper {
}
public static void nioTransferCopy(File source, File target) {
FileChannel in = null;
FileChannel out = null;
FileInputStream inStream = null;
FileOutputStream outStream = null;
try {
inStream = new FileInputStream(source);
outStream = new FileOutputStream(target);
in = inStream.getChannel();
out = outStream.getChannel();
try (
FileInputStream inStream = new FileInputStream(source);
FileOutputStream outStream = new FileOutputStream(target);
FileChannel in = inStream.getChannel();
FileChannel out = outStream.getChannel();
) {
in.transferTo(0, in.size(), out);
} catch (IOException e) {
e.printStackTrace();
} finally {
close(inStream);
close(in);
close(outStream);
close(out);
}
}
private static boolean nioBufferCopy(File source, File target) {
FileChannel in = null;
FileChannel out = null;
FileInputStream inStream = null;
FileOutputStream outStream = null;
try {
inStream = new FileInputStream(source);
outStream = new FileOutputStream(target);
in = inStream.getChannel();
out = outStream.getChannel();
try (
FileInputStream inStream = new FileInputStream(source);
FileOutputStream outStream = new FileOutputStream(target);
FileChannel in = inStream.getChannel();
FileChannel out = outStream.getChannel();
) {
ByteBuffer buffer = ByteBuffer.allocate(4096);
while (in.read(buffer) != -1) {
buffer.flip();
......@@ -515,22 +504,16 @@ public class FileHelper {
} catch (IOException e) {
e.printStackTrace();
return false;
} finally {
close(inStream);
close(in);
close(outStream);
close(out);
}
return true;
}
public static void customBufferStreamCopy(File source, File target) {
InputStream fis = null;
OutputStream fos = null;
try {
fis = new FileInputStream(source);
fos = new FileOutputStream(target);
try (
InputStream fis = new FileInputStream(source);
OutputStream fos = new FileOutputStream(target);
) {
byte[] buf = new byte[4096];
int i;
while ((i = fis.read(buf)) != -1) {
......@@ -538,9 +521,6 @@ public class FileHelper {
}
} catch (Exception e) {
e.printStackTrace();
} finally {
close(fis);
close(fos);
}
}
......
......@@ -18,11 +18,9 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.util.EntityUtils;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Iterator;
import java.util.Map;
......@@ -395,31 +393,32 @@ public class HttpUtil {
/**
* 发送 delete请求带请求头
*/
public static String sendHttpDeleteJsonWithHeader(String httpUrl, String paramsJson, Map<String, String> headerMap) {
public static String sendHttpDeleteJsonWithHeader(String httpUrl, String paramsJson, Map<String, String> headerMap) throws IOException {
StringBuffer content = new StringBuffer();
try {
URL url = new URL(httpUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("DELETE");
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
for (Map.Entry<String, String> entry : headerMap.entrySet()) {
connection.setRequestProperty(entry.getKey(), entry.getValue());
}
PrintWriter printWriter = new PrintWriter(connection.getOutputStream());
URL url = new URL(httpUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("DELETE");
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
for (Map.Entry<String, String> entry : headerMap.entrySet()) {
connection.setRequestProperty(entry.getKey(), entry.getValue());
}
try (
OutputStream outputStream = connection.getOutputStream();
InputStreamReader inputStreamReader = new InputStreamReader(connection.getInputStream());
BufferedReader br = new BufferedReader(inputStreamReader);
PrintWriter printWriter = new PrintWriter(outputStream);
) {
printWriter.write(paramsJson);
printWriter.flush();
BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
content.append(line);
}
br.close();
connection.disconnect();
} catch (Exception e) {
e.printStackTrace();
}
return content.toString();
}
......
......@@ -83,8 +83,7 @@ public class WordHtml implements AbstractHtml {
private static void convertDoc2Html(InputStream is, String outPutFile)
throws TransformerException, IOException, ParserConfigurationException {
StreamResult streamResult = null;
ByteArrayOutputStream out = null;
try {
try (ByteArrayOutputStream out = new ByteArrayOutputStream();) {
String[] outPutFiles = outPutFile.split("\\\\");
outPutFiles = outPutFiles[outPutFiles.length - 1].split("/");
final String root = outPutFiles[outPutFiles.length - 1];
......@@ -106,19 +105,18 @@ public class WordHtml implements AbstractHtml {
if (pics != null) {
for (int i = 0; i < pics.size(); i++) {
Picture pic = (Picture) pics.get(i);
try {
try (
FileOutputStream fileOutputStream = new FileOutputStream(outPutFile + "/" + pic.suggestFullFileName());
) {
// 指定doc文档中转换后图片保存的路径
pic.writeImageContent(
new FileOutputStream(outPutFile + "/" + pic.suggestFullFileName()));
pic.writeImageContent(fileOutputStream);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
// #end save pictures
out = new ByteArrayOutputStream();
streamResult = new StreamResult(out);
TransformerFactory tf = TransformerFactory.newInstance();
tf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
// 创建执行从 Source 到 Result 的复制的新 Transformer。
......@@ -134,10 +132,8 @@ public class WordHtml implements AbstractHtml {
FileHelper.writeFile(content, outPutFile + ".html");
// FileHelper.parseCharset(outPutFile + ".html");
// System.out.println(new String(out.toByteArray()));
} finally {
if (null != out) {
out.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
......@@ -216,24 +212,9 @@ public class WordHtml implements AbstractHtml {
Transformer transformer= transformerFactory.newTransformer(template);
//处理xml进行交换
transformer.transform(source, result);
} catch (FileNotFoundException e) {
} catch (TransformerException | IOException e) {
e.printStackTrace();
} catch (TransformerException e) {
e.printStackTrace();
} finally {
//关闭文件流
try {
if(null != fis1){
fis1.close();
}
if(null != fis){
fis.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
......
......@@ -109,27 +109,15 @@ public class WordTemplateUtils {
public File getWordFileItem(Map map, String title, String ftlFile,String type) throws IOException {
configuration.setClassForTemplateLoading(this.getClass(), "/ftl");
Template freemarkerTemplate = configuration.getTemplate(ftlFile, "UTF-8");
File file = null;
File file = createDoc(map, freemarkerTemplate);
File filepdf = new File("sellPlan.pdf");
InputStream fin = null;
OutputStream os = null;
try {
try (
InputStream fin = new FileInputStream(file);
OutputStream os = new FileOutputStream(filepdf);
) {
// 调用工具类的createDoc方法生成Word文档
file = createDoc(map, freemarkerTemplate);
fin = new FileInputStream(file);
os = new FileOutputStream(filepdf);
wordTopdfByAspose(fin, os,type);
return filepdf;
} finally {
if (fin != null) {
fin.close();
}
if (os != null) {
os.close();
}
if (file != null) {
file.delete();
}// 删除临时文件
}
}
......@@ -214,24 +202,17 @@ public class WordTemplateUtils {
if (!file.exists()) {
return "";
}
InputStream in = null;
byte[] data = null;
try {
in = new FileInputStream(file);
} catch (FileNotFoundException e1) {
try (InputStream in = new FileInputStream(file);) {
data = new byte[in.available()];
in.read(data);
BASE64Encoder encoder = new BASE64Encoder();
return encoder.encode(data);
} catch (IOException e1) {
e1.printStackTrace();
}
try {
if (null != in) {
data = new byte[in.available()];
in.read(data);
in.close();
}
} catch (IOException e) {
e.printStackTrace();
}
BASE64Encoder encoder = new BASE64Encoder();
return encoder.encode(data);
return null;
}
}
......@@ -272,13 +272,9 @@ public class CheckServiceImpl implements ICheckService {
@Override
public AppPointCheckRespone queryCheckPointDetail(String toke, String product, String appKey, long checkId) {
// List list = checkMapper.queryCheckPointInputItem(planTaskId, pointId);
List<PointCheckDetailBo> list = checkMapper.findCheckPointInputItem(checkId);
AppPointCheckRespone pointCheckRespone = new AppPointCheckRespone();
if (!list.isEmpty()) {
// InetAddress address = InetAddress.getLocalHost();
// String ip = address.getHostAddress();
// String ipPort = "http://" + fileIp + ":" + filePort + "/";
List<String> pointImgUrls = new ArrayList<>();
PointCheckDetailBo pointCheckDetailBo = list.get(0);
List<CheckShot> pointShot = checkShotDao.findAllByCheckIdAndCheckInputIdAndClassifyId(pointCheckDetailBo.getCheckId(), 0l, 0l);
......@@ -356,13 +352,9 @@ public class CheckServiceImpl implements ICheckService {
@Override
public AppPointCheckRespone queryCheckPointDetailInVersion2(String toke, String product, String appKey, long checkId) {
// List list = checkMapper.queryCheckPointInputItem(planTaskId, pointId);
List<PointCheckDetailBo> list = checkMapper.findCheckPointInputItem(checkId);
AppPointCheckRespone pointCheckRespone = new AppPointCheckRespone();
if (!list.isEmpty()) {
// InetAddress address = InetAddress.getLocalHost();
// String ip = address.getHostAddress();
// String ipPort = "http://" + fileIp + ":" + filePort + "/";
List<String> pointImgUrls = new ArrayList<>();
PointCheckDetailBo pointCheckDetailBo = list.get(0);
List<CheckShot> pointShot = checkShotDao.findAllByCheckIdAndCheckInputIdAndClassifyId(pointCheckDetailBo.getCheckId(), 0l, 0l);
......
......@@ -343,15 +343,6 @@ public class LatentDangerServiceImpl implements ILatentDangerService {
latentDangerMapper.updateCheckInputDangerState(id, code);
}
private String buildLocalHost() {
try {
String ip = InetAddress.getLocalHost().getHostAddress();
return "http://" + ip + ":" + port + "/";
} catch (Exception e) {
return "";
}
}
private void updateMeasuresContentStatus(Long riskFactorId, Long measuresContentId, String evaluateId, RiskFactorsCmStatusEnum riskFactorsCmStatusEnum) {
Map<String, Object> map = Maps.newHashMap();
map.put("riskFactorId", riskFactorId);
......
......@@ -42,13 +42,13 @@ public class AmoAVICApplication {
public static void main(String[] args) throws UnknownHostException {
ConfigurableApplicationContext context = SpringApplication.run(AmoAVICApplication.class, args);
Environment env = context.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = oConvertUtils.getString(env.getProperty("server.servlet.context-path"));
GlobalExceptionHandler.setAlwaysOk(true);
logger.info("\n----------------------------------------------------------\n\t"
+ "Application Amos-Biz-Boot is running! Access URLs:\n\t" + "Swagger文档: \thttp://" + ip + ":" + port
+ path + "/doc.html\n" + "----------------------------------------------------------");
String appName = env.getProperty("spring.application.name");
logger.info(
"\n----------------------------------------------------------\n\t"
+ "Application {} is running!\n"
+ "----------------------------------------------------------\n"
, appName
);
}
}
......@@ -50,12 +50,12 @@ public class AmosCasApplication {
public static void main(String[] args) throws Exception {
ConfigurableApplicationContext context = SpringApplication.run(AmosCasApplication.class, args);
Environment env = context.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = oConvertUtils.getString(env.getProperty("server.servlet.context-path"));
logger.info("\n----------------------------------------------------------\n\t"
+ "Application Amos-Biz-Boot is running! Access URLs:\n\t" + "Swagger文档: \thttp://" + ip + ":" + port
+ path + "/doc.html\n" + "----------------------------------------------------------");
String appName = env.getProperty("spring.application.name");
logger.info(
"\n----------------------------------------------------------\n\t"
+ "Application {} is running!\n"
+ "----------------------------------------------------------\n"
, appName
);
}
}
......@@ -40,13 +40,13 @@ public class AmoCCSApplication {
public static void main(String[] args) throws UnknownHostException {
ConfigurableApplicationContext context = SpringApplication.run(AmoCCSApplication.class, args);
Environment env = context.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = oConvertUtils.getString(env.getProperty("server.servlet.context-path"));
GlobalExceptionHandler.setAlwaysOk(true);
logger.info("\n----------------------------------------------------------\n\t"
+ "Application Amos-Biz-Boot is running! Access URLs:\n\t" + "Swagger文档: \thttp://" + ip + ":" + port
+ path + "/doc.html\n" + "----------------------------------------------------------");
String appName = env.getProperty("spring.application.name");
logger.info(
"\n----------------------------------------------------------\n\t"
+ "Application {} is running!\n"
+ "----------------------------------------------------------\n"
, appName
);
}
}
......@@ -58,20 +58,18 @@ public class AmostEquipApplication {
@Autowired
private CarIotNewListener carIotNewListener;
public static void main(String[] args) throws UnknownHostException {
ConfigurableApplicationContext context = SpringApplication.run(AmostEquipApplication.class, args);
Environment env = context.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = oConvertUtils.getString(env.getProperty("server.servlet.context-path"));
ConfigurableApplicationContext context = SpringApplication.run(AmostEquipApplication.class, args);
GlobalExceptionHandler.setAlwaysOk(true);
logger.info("\n----------------------------------------------------------\n\t"
+ "Application Amos-Biz-Boot is running! Access URLs:\n\t" + "Swagger文档: \thttp://" + ip + ":" + port
+ path + "/doc.html\n" + "----------------------------------------------------------");
}
Environment env = context.getEnvironment();
String appName = env.getProperty("spring.application.name");
logger.info(
"\n----------------------------------------------------------\n\t"
+ "Application {} is running!\n"
+ "----------------------------------------------------------\n"
, appName
);
}
@Bean
@LoadBalanced
......
......@@ -28,10 +28,10 @@
<foreach collection="params" index="key" item="value" separator="">
<choose>
<when test="fieldNames[key] == 'like' and value !=null and value !=''">
and d.#{key} like concat('%',#{value},'%')
and d.${key} like concat('%',#{value},'%')
</when>
<when test="fieldNames[key] == 'eq' and value !=null and value !=''">
and d.#{key} = #{value}
and d.${key} = #{value}
</when>
</choose>
</foreach>
......@@ -80,10 +80,10 @@
<foreach collection="params" index="key" item="value" separator="">
<choose>
<when test="fieldNames[key] == 'like' and value !=null and value !=''">
AND d.#{key} like concat('%',#{value},'%')
AND d.${key} like concat('%',#{value},'%')
</when>
<when test="fieldNames[key] == 'eq' and value !=null and value !=''">
AND d.#{key} = #{value}
AND d.${key} = #{value}
</when>
</choose>
......
......@@ -34,7 +34,7 @@ import com.yeejoin.amos.fas.context.IotContext;
/**
*
*
* <pre>
* 服务启动类
* </pre>
......@@ -70,15 +70,14 @@ public class FireAutoSysApplication implements ApplicationContextAware {
logger.info("start Service..........");
ConfigurableApplicationContext context = SpringApplication.run(FireAutoSysApplication.class, args);
GlobalExceptionHandler.setAlwaysOk(true);
Environment env = context.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = env.getProperty("server.servlet.context-path");
GlobalExceptionHandler.setAlwaysOk(true);
logger.info("\n----------------------------------------------------------\n\t" +
"Application Amos-Biz-Boot is running! Access URLs:\n\t" +
"Swagger文档: \thttp://" + ip + ":" + port + path + "/doc.html\n" +
"----------------------------------------------------------");
Environment env = context.getEnvironment();
String appName = env.getProperty("spring.application.name");
logger.info(
"\n----------------------------------------------------------\n\t"
+ "Application {} is running!\n"
+ "----------------------------------------------------------\n"
, appName
);
}
/**
......
......@@ -50,17 +50,18 @@ public class AmosJcsApplication {
ConfigurableApplicationContext context = SpringApplication.run(AmosJcsApplication.class, args);
Environment env = context.getEnvironment();
delKey(env, context);// 添加全部清空redis缓存的方法 2021-09-09
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = oConvertUtils.getString(env.getProperty("server.servlet.context-path"));
GlobalExceptionHandler.setAlwaysOk(true);
String logs=String.format("%n----------------------------------------------------------%n Application Amos-Biz-Boot is running! Access URLs:%n Swagger文档: http://%s:%s%s/doc.html%n----------------------------------------------------------",ip,port,path);
logger.info( logs);
String appName = env.getProperty("spring.application.name");
logger.info(
"\n----------------------------------------------------------\n\t"
+ "Application {} is running!\n"
+ "----------------------------------------------------------\n"
, appName
);
}
/**
* 清空redis缓存数据
*
*
* @author 陈浩
* @param env
* @param context
......
......@@ -42,13 +42,13 @@ public class AmoKGDApplication {
public static void main(String[] args) throws UnknownHostException {
ConfigurableApplicationContext context = SpringApplication.run(AmoKGDApplication.class, args);
Environment env = context.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = oConvertUtils.getString(env.getProperty("server.servlet.context-path"));
GlobalExceptionHandler.setAlwaysOk(true);
logger.info("\n----------------------------------------------------------\n\t"
+ "Application Amos-Biz-Boot is running! Access URLs:\n\t" + "Swagger文档: \thttp://" + ip + ":" + port
+ path + "/doc.html\n" + "----------------------------------------------------------");
String appName = env.getProperty("spring.application.name");
logger.info(
"\n----------------------------------------------------------\n\t"
+ "Application {} is running!\n"
+ "----------------------------------------------------------\n"
, appName
);
}
}
......@@ -39,13 +39,12 @@ public class KnowledgebaseApplication {
ConfigurableApplicationContext context = new SpringApplicationBuilder(KnowledgebaseApplication.class).web(WebApplicationType.SERVLET).run(args);
GlobalExceptionHandler.setAlwaysOk(true);
Environment env = context.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = env.getProperty("server.servlet.context-path");
GlobalExceptionHandler.setAlwaysOk(true);
logger.info("\n----------------------------------------------------------\n\t" +
"Application Amos-Biz-Boot is running! Access URLs:\n\t" +
"Swagger文档: \thttp://" + ip + ":" + port + path + "/doc.html\n" +
"----------------------------------------------------------");
String appName = env.getProperty("spring.application.name");
logger.info(
"\n----------------------------------------------------------\n\t"
+ "Application {} is running!\n"
+ "----------------------------------------------------------\n"
, appName
);
}
}
......@@ -38,7 +38,7 @@
and dc.USER_ID = #{userId}
</if>
<if test="orgCode != null and orgCode !=''">
and dc.ORG_CODE like '%#{orgCode}%'
and dc.ORG_CODE like CONCAT('%',#{orgCode},'%' )
</if>
)
UNION ALL
......@@ -70,7 +70,7 @@
and dc.USER_ID = #{userId}
</if>
<if test="orgCode != null and orgCode !=''">
and dc.ORG_CODE like '%#{orgCode}%'
and dc.ORG_CODE like CONCAT('%',#{orgCode},'%' )
</if>
)
)d LIMIT #{offset},#{length}
......@@ -84,7 +84,7 @@
(SELECT kdc.CATEGORY_NAME FROM knowledge_doc_category kdc WHERE kdc.SEQUENCE_NBR = DIRECTORY_ID) directoryName,
<if test="extraFields != null and extraFields.size > 0">
<foreach collection="extraFields" item="_field" >
#{_field},
${_field},
</foreach>
</if>
IFNULL(collectNum, 0) collectNum, IFNULL(quoteNum, 0) quoteNum, IFNULL(collect, "UNCOLLECT") collect
......@@ -157,7 +157,7 @@
ORG_CODE LIKE CONCAT(#{permissionFilters.orgCode}, "%")
AND AUDIT_STATUS IN
<foreach collection="permissionFilters.auditStatusList" item="auditStatus" open="(" close=")" separator=", ">
#{auditStatus}
${auditStatus}
</foreach>
)
</if>
......@@ -166,7 +166,7 @@
</if>
<if test="extraStrFilters != null and extraStrFilters.size > 0">
<foreach collection="extraStrFilters" item="str">
AND #{str}
AND ${str}
</foreach>
</if>
</where>
......
......@@ -70,14 +70,13 @@ public class LatentDangerApplication {
logger.info("start Service..........");
ConfigurableApplicationContext context = SpringApplication.run(LatentDangerApplication.class, args);
Environment env = context.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = env.getProperty("server.servlet.context-path");
GlobalExceptionHandler.setAlwaysOk(true);
logger.info("\n----------------------------------------------------------\n\t" +
"Application Amos-Biz-Boot is running! Access URLs:\n\t" +
"Swagger文档: \thttp://" + ip + ":" + port + path + "/doc.html\n" +
"----------------------------------------------------------");
String appName = env.getProperty("spring.application.name");
logger.info(
"\n----------------------------------------------------------\n\t"
+ "Application {} is running!\n"
+ "----------------------------------------------------------\n"
, appName
);
}
}
\ No newline at end of file
......@@ -69,14 +69,13 @@ public class MaintenanceApplication {
ConfigurableApplicationContext context = SpringApplication.run(MaintenanceApplication.class, args);
GlobalExceptionHandler.setAlwaysOk(true);
Environment env = context.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = env.getProperty("server.servlet.context-path");
GlobalExceptionHandler.setAlwaysOk(true);
logger.info("\n----------------------------------------------------------\n\t" +
"Application Amos-Biz-Boot is running! Access URLs:\n\t" +
"Swagger文档: \thttp://" + ip + ":" + port + path + "/doc.html\n" +
"----------------------------------------------------------");
String appName = env.getProperty("spring.application.name");
logger.info(
"\n----------------------------------------------------------\n\t"
+ "Application {} is running!\n"
+ "----------------------------------------------------------\n"
, appName
);
}
......
......@@ -85,14 +85,13 @@ public class PatrolApplication {
ConfigurableApplicationContext context = SpringApplication.run(PatrolApplication.class, args);
GlobalExceptionHandler.setAlwaysOk(true);
Environment env = context.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = env.getProperty("server.servlet.context-path");
GlobalExceptionHandler.setAlwaysOk(true);
logger.info("\n----------------------------------------------------------\n\t" +
"Application Amos-Biz-Boot is running! Access URLs:\n\t" +
"Swagger文档: \thttp://" + ip + ":" + port + path + "/doc.html\n" +
"----------------------------------------------------------");
String appName = env.getProperty("spring.application.name");
logger.info(
"\n----------------------------------------------------------\n\t"
+ "Application {} is running!\n"
+ "----------------------------------------------------------\n"
, appName
);
}
/**
......
......@@ -258,8 +258,8 @@
<if test="orgCode != null and orgCode !=''" >
And pp.org_code= #{orgCode}
</if>
AND d.create_date &gt;= '#{startDate}'
AND d.create_date &lt;= '#{endDate}'
AND d.create_date &gt;= #{startDate}
AND d.create_date &lt;= #{endDate}
<if test="planId != null and planId !=''" >
and EXISTS(select 1 from p_plan_task pt where pt.id = d.task_no and pt.plan_id = #{planId})
</if>
......@@ -532,8 +532,8 @@
LEFT JOIN p_plan_task pt on pt.id = d.task_no
LEFT JOIN p_plan pl on pt.plan_id=pl.id
WHERE
d.create_date &gt;= '#{startDate}'
AND d.create_date &lt;= '#{endDate}'
d.create_date &gt;= #{startDate}
AND d.create_date &lt;= #{endDate}
<if test="orgCode != null and orgCode !=''" >
And (pl.org_code LIKE CONCAT( #{orgCode}, '-%' ) or pl.org_code= #{orgCode} )
</if>
......@@ -812,8 +812,8 @@
<if test="orgCode != null and orgCode !=''" >
And (pt.org_code LIKE CONCAT( #{orgCode}, '-%' ) or pt.org_code= #{orgCode} )
</if>
AND d.create_date &gt;= '#{startDate}'
AND d.create_date &lt;= '#{endDate}'
AND d.create_date &gt;= #{startDate}
AND d.create_date &lt;= #{endDate}
<if test="planId != null and planId !=''" >
and EXISTS(select 1 from p_plan_task pt where pt.id = d.task_no and pt.plan_id = #{planId})
</if>
......@@ -1089,8 +1089,8 @@
<if test="orgCode != null and orgCode !=''" >
And (pp.org_code LIKE CONCAT( #{orgCode}, '-%' ) or pp.org_code= #{orgCode} )
</if>
AND d.create_date &gt;= '#{startDate}'
AND d.create_date &lt;= '#{endDate}'
AND d.create_date &gt;= #{startDate}
AND d.create_date &lt;= #{endDate}
<if test="planId != null and planId !=''" >
and EXISTS(select 1 from p_plan_task pt where pt.id = d.task_no and pt.plan_id = #{planId})
</if>
......@@ -1366,8 +1366,8 @@
<if test="orgCode != null and orgCode !=''" >
And pr.org_code= #{orgCode}
</if>
AND d.create_date &gt;= '#{startDate}'
AND d.create_date &lt;= '#{endDate}'
AND d.create_date &gt;= #{startDate}
AND d.create_date &lt;= #{endDate}
<if test="planId != null and planId !=''" >
and EXISTS(select 1 from p_plan_task pt where pt.id = d.task_no and pt.plan_id = #{planId})
</if>
......@@ -1683,8 +1683,8 @@ FROM
p_plan_task pt
WHERE
pt.user_id >0
AND pt.end_time BETWEEN '#{startTime}'
AND '#{endTime}'
AND pt.end_time BETWEEN #{startTime}
AND #{endTime}
<if test="summation == 'false'">
GROUP BY
......
......@@ -96,7 +96,7 @@
<if test="catalogId!=null and catalogId!=''">and b.Catalog_Id = #{catalogId}</if>
<if test="orgCode!=null and orgCode!=''">and (a.org_Code like concat (#{orgCode},"-%")or a.org_Code= #{orgCode})</if>
<if test="pointId!=null and pointId!=''">and a.point_id = #{pointId}</if>
<if test="checkTime!=null and checkTime!=''">and TO_DAYS(a.check_time) = TO_DAYS('#{checkTime}')</if>
<if test="checkTime!=null and checkTime!=''">and TO_DAYS(a.check_time) = TO_DAYS(#{checkTime})</if>
<if test="departmentId!=null and departmentId!='-1'"> and find_in_set(#{departmentId}, a.dep_id) > 0</if>
<if test="checkType == '计划检查'">and a.plan_task_id &gt; 0</if>
<if test="checkType == '无计划检查'">and a.plan_task_id &lt;= 0</if>
......@@ -150,7 +150,7 @@
<if test="catalogId!=null and catalogId!=''">and b.Catalog_Id = #{catalogId}</if>
<if test="orgCode!=null and orgCode!=''">and (a.org_Code like concat (#{orgCode},"-%")or a.org_Code= #{orgCode})</if>
<if test="pointId!=null and pointId!=''">and a.point_id = #{pointId}</if>
<if test="checkTime!=null and checkTime!=''">and TO_DAYS(a.check_time) = TO_DAYS('#{checkTime}')</if>
<if test="checkTime!=null and checkTime!=''">and TO_DAYS(a.check_time) = TO_DAYS(#{checkTime})</if>
<if test="departmentId!=null and departmentId!='-1'"> and find_in_set(#{departmentId}, a.dep_id) > 0</if>
<if test="checkType == '计划检查'">and a.plan_task_id &gt; 0</if>
<if test="checkType == '无计划检查'">and a.plan_task_id &lt;= 0</if>
......@@ -236,7 +236,7 @@
<if test="catalogId!=null">and b.Catalog_Id = #{catalogId}</if>
<if test="orgCode!=null">and (a.org_Code like concat (#{orgCode},"-%")or a.org_Code= #{orgCode})</if>
<if test="pointId!=null">and a.point_id = #{pointId}</if>
<if test="checkTime!=null">and TO_DAYS(a.check_time) = TO_DAYS('#{checkTime}')</if>
<if test="checkTime!=null">and TO_DAYS(a.check_time) = TO_DAYS(#{checkTime})</if>
<if test="departmentId!=null and departmentId!='-1'"> and find_in_set(#{departmentId}, a.dep_id) > 0</if>
<if test="checkType == '计划检查'">and a.plan_task_id &gt; 0</if>
<if test="checkType == '无计划检查'">and a.plan_task_id &lt;= 0</if>
......@@ -254,7 +254,7 @@
and d.biz_org_code LIKE CONCAT(#{bizOrgCode},'%')
</if>
</trim>
order by #{orderBy}
order by ${orderBy}
<choose>
<when test="pageSize==-1"></when>
<when test="pageSize!=-1">limit #{offset},#{pageSize}</when>
......@@ -404,7 +404,7 @@
<if test="catalogId!=null and catalogId!=''">and b.Catalog_Id = #{catalogId}</if>
<if test="orgCode!=null and orgCode!=''">and (a.org_Code like concat (#{orgCode},"-%")or a.org_Code= #{orgCode})</if>
<if test="pointId!=null and pointId!=''">and a.point_id = #{pointId}</if>
<if test="checkTime!=null and checkTime!=''">and TO_DAYS(a.check_time) = TO_DAYS('#{checkTime}')</if>
<if test="checkTime!=null and checkTime!=''">and TO_DAYS(a.check_time) = TO_DAYS(#{checkTime})</if>
<if test="departmentId!=null and departmentId!='-1'"> and find_in_set(#{departmentId}, a.dep_id) > 0</if>
<if test="checkType == '计划检查'">and a.plan_task_id &gt; 0</if>
<if test="checkType == '无计划检查'">and a.plan_task_id &lt;= 0</if>
......@@ -425,7 +425,7 @@
<if test="isExecute!=null and isExecute!='' and isExecute == '3'">and a.is_OK != #{isExecute}</if>
</trim>
order by
#{orderBy}
${orderBy}
<choose>
<when test="pageSize==-1"></when>
<when test="pageSize!=-1">limit #{offset}, #{pageSize}</when>
......@@ -476,7 +476,7 @@
and a.org_code LIKE CONCAT(#{bizOrgCode},'%')
</if>
</trim>
order by #{orderBy}
order by ${orderBy}
<choose>
<when test="pageSize==-1"></when>
<when test="pageSize!=-1">limit #{offset},#{pageSize}</when>
......
......@@ -237,7 +237,7 @@
) a
<include refid="plan-task-app-where"/>
<if test="orderBy != null and orderBy != ''"> order by #{orderBy} </if>
<if test="orderBy != null and orderBy != ''"> order by ${orderBy} </if>
limit #{offset},#{pageSize}
</select>
<select id="getPlanTasksCount" resultType="long">
......
......@@ -75,14 +75,13 @@ public class SupervisionApplication {
ConfigurableApplicationContext context = SpringApplication.run(SupervisionApplication.class, args);
GlobalExceptionHandler.setAlwaysOk(true);
Environment env = context.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = env.getProperty("server.servlet.context-path");
GlobalExceptionHandler.setAlwaysOk(true);
logger.info("\n----------------------------------------------------------\n\t" +
"Application Amos-Biz-Boot is running! Access URLs:\n\t" +
"Swagger文档: \thttp://" + ip + ":" + port + path + "/doc.html\n" +
"----------------------------------------------------------");
String appName = env.getProperty("spring.application.name");
logger.info(
"\n----------------------------------------------------------\n\t"
+ "Application {} is running!\n"
+ "----------------------------------------------------------\n"
, appName
);
}
@Bean
......
......@@ -50,12 +50,12 @@ public class AmosTdcApplication {
public static void main(String[] args) throws Exception {
ConfigurableApplicationContext context = SpringApplication.run(AmosTdcApplication.class, args);
Environment env = context.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = oConvertUtils.getString(env.getProperty("server.servlet.context-path"));
logger.info("\n----------------------------------------------------------\n\t"
+ "Application Amos-Biz-Boot is running! Access URLs:\n\t" + "Swagger文档: \thttp://" + ip + ":" + port
+ path + "/doc.html\n" + "----------------------------------------------------------");
String appName = env.getProperty("spring.application.name");
logger.info(
"\n----------------------------------------------------------\n\t"
+ "Application {} is running!\n"
+ "----------------------------------------------------------\n"
, appName
);
}
}
......@@ -74,18 +74,17 @@ public class AmosTzsApplication {
public static void main(String[] args) throws UnknownHostException {
ConfigurableApplicationContext context = SpringApplication.run(AmosTzsApplication.class, args);
Environment env = context.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = oConvertUtils.getString(env.getProperty("server.servlet.context-path"));
logger.info("\n----------------------------------------------------------\n\t"
+ "Application Amos-Biz-Boot is running! Access URLs:\n\t" + "Swagger文档: \thttp://" + ip + ":" + port
+ path + "/doc.html\n" + "----------------------------------------------------------");
+ "Application Amos-Biz-Boot is running!\n\t"
+ "----------------------------------------------------------");
}
/**
* 初始化MQTT
*
*
* @throws MqttException
*/
@Bean
......
......@@ -50,12 +50,12 @@ public class AmosUgpApplication {
public static void main(String[] args) throws Exception {
ConfigurableApplicationContext context = SpringApplication.run(AmosUgpApplication.class, args);
Environment env = context.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = oConvertUtils.getString(env.getProperty("server.servlet.context-path"));
logger.info("\n----------------------------------------------------------\n\t"
+ "Application Amos-Biz-Boot is running! Access URLs:\n\t" + "Swagger文档: \thttp://" + ip + ":" + port
+ path + "/doc.html\n" + "----------------------------------------------------------");
String appName = env.getProperty("spring.application.name");
logger.info(
"\n----------------------------------------------------------\n\t"
+ "Application {} is running!\n"
+ "----------------------------------------------------------\n"
, appName
);
}
}
......@@ -40,14 +40,9 @@ public class JpushApplication {
public static void main(String[] args) throws UnknownHostException {
ConfigurableApplicationContext context = SpringApplication.run(JpushApplication.class, args);
// GlobalExceptionHandler.setAlwaysOk(true);
Environment env = context.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = env.getProperty("server.servlet.context-path");
logger.info("\n----------------------------------------------------------\n\t" +
"Application Amos-Biz-Boot is running! Access URLs:\n\t" +
"Swagger文档: \thttp://" + ip + ":" + port + path + "/doc.html\n" +
"----------------------------------------------------------");
logger.info("\n----------------------------------------------------------\n\t"
+ "Application Amos-Biz-Boot is running!\n\t"
+ "----------------------------------------------------------");
}
}
\ No newline at end of file
......@@ -41,13 +41,13 @@ public class AmosBootUtilsMessageApplication {
ConfigurableApplicationContext context = SpringApplication.run(AmosBootUtilsMessageApplication.class, args);
Environment env = context.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = env.getProperty("server.servlet.context-path");
logger.info("\n----------------------------------------------------------\n\t" +
"Application Amos-Biz-Boot is running! Access URLs:\n\t" +
"Swagger文档: \thttp://" + ip + ":" + port + path + "/doc.html\n" +
"----------------------------------------------------------");
String appName = env.getProperty("spring.application.name");
logger.info(
"\n----------------------------------------------------------\n\t"
+ "Application {} is running!\n"
+ "----------------------------------------------------------\n"
, appName
);
}
}
......@@ -36,16 +36,15 @@ import java.net.UnknownHostException;
public class VideoApplication {
private static final Logger logger = LoggerFactory.getLogger(VideoApplication.class);
public static void main(String[] args) throws UnknownHostException {
public static void main(String[] args) {
ConfigurableApplicationContext context = SpringApplication.run(VideoApplication.class, args);
// GlobalExceptionHandler.setAlwaysOk(true);
Environment env = context.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = env.getProperty("server.servlet.context-path");
logger.info("\n----------------------------------------------------------\n\t" +
"Application Amos-Biz-Boot is running! Access URLs:\n\t" +
"Swagger文档: \thttp://" + ip + ":" + port + path + "/doc.html\n" +
"----------------------------------------------------------");
Environment env = context.getEnvironment();
String appName = env.getProperty("spring.application.name");
logger.info(
"\n----------------------------------------------------------\n\t"
+ "Application {} is running!\n"
+ "----------------------------------------------------------\n"
, appName
);
}
}
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