Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
T
TDLCloud
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
WitCloud
TDLCloud
Commits
00afa7d3
Commit
00afa7d3
authored
Jun 08, 2018
by
zhuangzhuang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
6.8-优化报警数据的接口
parent
79cf6251
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
120 additions
and
358 deletions
+120
-358
AlarmRule.java
src/main/java/com/example/tdl/util/AlarmRule.java
+53
-0
CookieUtils.java
src/main/java/com/example/tdl/util/CookieUtils.java
+0
-220
HttpRequester.java
src/main/java/com/example/tdl/util/HttpRequester.java
+45
-5
PicUploadUtil.java
src/main/java/com/example/tdl/util/PicUploadUtil.java
+0
-49
AlarmLogController.java
src/main/java/com/example/tdl/web/AlarmLogController.java
+0
-4
CircuitController.java
src/main/java/com/example/tdl/web/CircuitController.java
+3
-40
EquipmentBindingController.java
.../java/com/example/tdl/web/EquipmentBindingController.java
+2
-36
WarehouseController.java
src/main/java/com/example/tdl/web/WarehouseController.java
+2
-4
application-docker.properties
src/main/resources/application-docker.properties
+15
-0
No files found.
src/main/java/com/example/tdl/util/AlarmRule.java
0 → 100644
View file @
00afa7d3
package
com
.
example
.
tdl
.
util
;
import
com.example.tdl.domain.vo.AlarmRuleVo
;
import
com.example.tdl.domain.vo.ResultAlarmVo
;
import
com.example.tdl.service.AlarmService
;
import
com.example.tdl.service.redis.AlarmRedisService
;
import
com.google.gson.Gson
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
AlarmRule
{
private
static
Gson
gson
=
new
Gson
();
private
static
List
<
String
>
list
=
new
ArrayList
<
String
>(){{
add
(
"T"
);
add
(
"h"
);
add
(
"a1"
);
add
(
"ta"
);
}};
public
static
void
saveAlarmRule
(
String
topic
,
String
TDLSN
,
String
alarmType
,
String
companyNo
,
AlarmService
alarmService
,
AlarmRedisService
alarmRedisService
){
ResultAlarmVo
alarmVo
=
alarmService
.
getByType
(
alarmType
,
companyNo
);
for
(
String
alias
:
list
){
List
<
AlarmRuleVo
>
alarmRuleVos
=
new
ArrayList
<>();
AlarmRuleVo
alarmRuleVo
=
new
AlarmRuleVo
();
if
(
alias
.
equals
(
"T"
)){
alarmRuleVo
.
setMinval
(
String
.
valueOf
(
alarmVo
.
getTemMin
()));
alarmRuleVo
.
setMaxval
(
String
.
valueOf
(
alarmVo
.
getTemMax
()));
alarmRuleVo
.
setMode
(
"twoway"
);
alarmRuleVo
.
setPriority
(
"1"
);
}
else
if
(
alias
.
equals
(
"h"
)){
alarmRuleVo
.
setMinval
(
String
.
valueOf
(
alarmVo
.
getHumidityMin
()));
alarmRuleVo
.
setMaxval
(
String
.
valueOf
(
alarmVo
.
getHumidityMax
()));
alarmRuleVo
.
setMode
(
"twoway"
);
alarmRuleVo
.
setPriority
(
"1"
);
}
else
if
(
alias
.
equals
(
"ta"
)){
alarmRuleVo
.
setMaxval
(
String
.
valueOf
(
alarmVo
.
getTilt
()));
alarmRuleVo
.
setMode
(
"greater"
);
alarmRuleVo
.
setPriority
(
"1"
);
}
else
if
(
alias
.
equals
(
"a1"
)){
alarmRuleVo
.
setMaxval
(
String
.
valueOf
(
alarmVo
.
getShock
()));
alarmRuleVo
.
setMode
(
"greater"
);
alarmRuleVo
.
setPriority
(
"1"
);
}
alarmRuleVos
.
add
(
alarmRuleVo
);
//向redis中写入报警信息
alarmRedisService
.
hmSet
(
topic
,
"TDL-"
+
TDLSN
+
"_"
+
alias
,
gson
.
toJson
(
alarmRuleVos
));
}
}
}
src/main/java/com/example/tdl/util/CookieUtils.java
deleted
100644 → 0
View file @
79cf6251
package
com
.
example
.
tdl
.
util
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.servlet.http.Cookie
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLDecoder
;
import
java.net.URLEncoder
;
/**
*
* Cookie 工具类
*
*/
public
final
class
CookieUtils
{
protected
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
CookieUtils
.
class
);
/**
* 得到Cookie的值, 不编码
*
* @param request
* @param cookieName
* @return
*/
public
static
String
getCookieValue
(
HttpServletRequest
request
,
String
cookieName
)
{
return
getCookieValue
(
request
,
cookieName
,
false
);
}
/**
* 得到Cookie的值,
*
* @param request
* @param cookieName
* @return
*/
public
static
String
getCookieValue
(
HttpServletRequest
request
,
String
cookieName
,
boolean
isDecoder
)
{
Cookie
[]
cookieList
=
request
.
getCookies
();
if
(
cookieList
==
null
||
cookieName
==
null
){
return
null
;
}
String
retValue
=
null
;
try
{
for
(
int
i
=
0
;
i
<
cookieList
.
length
;
i
++)
{
if
(
cookieList
[
i
].
getName
().
equals
(
cookieName
))
{
if
(
isDecoder
)
{
retValue
=
URLDecoder
.
decode
(
cookieList
[
i
].
getValue
(),
"UTF-8"
);
}
else
{
retValue
=
cookieList
[
i
].
getValue
();
}
break
;
}
}
}
catch
(
UnsupportedEncodingException
e
)
{
logger
.
error
(
"Cookie Decode Error."
,
e
);
}
return
retValue
;
}
/**
* 得到Cookie的值,
*
* @param request
* @param cookieName
* @return
*/
public
static
String
getCookieValue
(
HttpServletRequest
request
,
String
cookieName
,
String
encodeString
)
{
Cookie
[]
cookieList
=
request
.
getCookies
();
if
(
cookieList
==
null
||
cookieName
==
null
){
return
null
;
}
String
retValue
=
null
;
try
{
for
(
int
i
=
0
;
i
<
cookieList
.
length
;
i
++)
{
if
(
cookieList
[
i
].
getName
().
equals
(
cookieName
))
{
retValue
=
URLDecoder
.
decode
(
cookieList
[
i
].
getValue
(),
encodeString
);
break
;
}
}
}
catch
(
UnsupportedEncodingException
e
)
{
logger
.
error
(
"Cookie Decode Error."
,
e
);
}
return
retValue
;
}
/**
* 设置Cookie的值 不设置生效时间默认浏览器关闭即失效,也不编码
*/
public
static
void
setCookie
(
HttpServletRequest
request
,
HttpServletResponse
response
,
String
cookieName
,
String
cookieValue
)
{
setCookie
(
request
,
response
,
cookieName
,
cookieValue
,
-
1
);
}
/**
* 设置Cookie的值 在指定时间内生效,但不编码
*/
public
static
void
setCookie
(
HttpServletRequest
request
,
HttpServletResponse
response
,
String
cookieName
,
String
cookieValue
,
int
cookieMaxage
)
{
setCookie
(
request
,
response
,
cookieName
,
cookieValue
,
cookieMaxage
,
false
);
}
/**
* 设置Cookie的值 不设置生效时间,但编码
*/
public
static
void
setCookie
(
HttpServletRequest
request
,
HttpServletResponse
response
,
String
cookieName
,
String
cookieValue
,
boolean
isEncode
)
{
setCookie
(
request
,
response
,
cookieName
,
cookieValue
,
-
1
,
isEncode
);
}
/**
* 设置Cookie的值 在指定时间内生效, 编码参数
*/
public
static
void
setCookie
(
HttpServletRequest
request
,
HttpServletResponse
response
,
String
cookieName
,
String
cookieValue
,
int
cookieMaxage
,
boolean
isEncode
)
{
doSetCookie
(
request
,
response
,
cookieName
,
cookieValue
,
cookieMaxage
,
isEncode
);
}
/**
* 设置Cookie的值 在指定时间内生效, 编码参数(指定编码)
*/
public
static
void
setCookie
(
HttpServletRequest
request
,
HttpServletResponse
response
,
String
cookieName
,
String
cookieValue
,
int
cookieMaxage
,
String
encodeString
)
{
doSetCookie
(
request
,
response
,
cookieName
,
cookieValue
,
cookieMaxage
,
encodeString
);
}
/**
* 删除Cookie带cookie域名
*/
public
static
void
deleteCookie
(
HttpServletRequest
request
,
HttpServletResponse
response
,
String
cookieName
)
{
doSetCookie
(
request
,
response
,
cookieName
,
""
,
-
1
,
false
);
}
/**
* 设置Cookie的值,并使其在指定时间内生效
*
* @param cookieMaxage
* cookie生效的最大秒数
*/
private
static
final
void
doSetCookie
(
HttpServletRequest
request
,
HttpServletResponse
response
,
String
cookieName
,
String
cookieValue
,
int
cookieMaxage
,
boolean
isEncode
)
{
try
{
if
(
cookieValue
==
null
)
{
cookieValue
=
""
;
}
else
if
(
isEncode
)
{
cookieValue
=
URLEncoder
.
encode
(
cookieValue
,
"utf-8"
);
}
Cookie
cookie
=
new
Cookie
(
cookieName
,
cookieValue
);
if
(
cookieMaxage
>
0
)
cookie
.
setMaxAge
(
cookieMaxage
);
if
(
null
!=
request
)
{
// 设置域名的cookie
if
(
request
.
getRemoteHost
().
equals
(
"localhost"
)
||
request
.
getRemoteHost
().
equals
(
"127.0.0.1"
)
||
request
.
getRemoteHost
().
equals
(
"192.168.1.52"
))
{
cookie
.
setDomain
(
""
);
}
else
{
cookie
.
setDomain
(
getDomainName
(
request
));
}
}
cookie
.
setPath
(
"/"
);
response
.
addCookie
(
cookie
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"Cookie Encode Error."
,
e
);
}
}
/**
* 设置Cookie的值,并使其在指定时间内生效
*
* @param cookieMaxage
* cookie生效的最大秒数
*/
private
static
final
void
doSetCookie
(
HttpServletRequest
request
,
HttpServletResponse
response
,
String
cookieName
,
String
cookieValue
,
int
cookieMaxage
,
String
encodeString
)
{
try
{
if
(
cookieValue
==
null
)
{
cookieValue
=
""
;
}
else
{
cookieValue
=
URLEncoder
.
encode
(
cookieValue
,
encodeString
);
}
Cookie
cookie
=
new
Cookie
(
cookieName
,
cookieValue
);
if
(
cookieMaxage
>
0
)
cookie
.
setMaxAge
(
cookieMaxage
);
if
(
null
!=
request
)
// 设置域名的cookie
cookie
.
setDomain
(
getDomainName
(
request
));
cookie
.
setPath
(
"/"
);
response
.
addCookie
(
cookie
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"Cookie Encode Error."
,
e
);
}
}
/**
* 得到cookie的域名
*/
private
static
final
String
getDomainName
(
HttpServletRequest
request
)
{
String
domainName
=
null
;
String
serverName
=
request
.
getRequestURL
().
toString
();
if
(
serverName
==
null
||
serverName
.
equals
(
""
))
{
domainName
=
""
;
}
else
{
serverName
=
serverName
.
toLowerCase
();
serverName
=
serverName
.
substring
(
7
);
final
int
end
=
serverName
.
indexOf
(
"/"
);
serverName
=
serverName
.
substring
(
0
,
end
);
final
String
[]
domains
=
serverName
.
split
(
"\\."
);
int
len
=
domains
.
length
;
if
(
len
>
3
)
{
// www.xxx.com.cn
domainName
=
"."
+
domains
[
len
-
3
]
+
"."
+
domains
[
len
-
2
]
+
"."
+
domains
[
len
-
1
];
}
else
if
(
len
<=
3
&&
len
>
1
)
{
// xxx.com or xxx.cn
domainName
=
"."
+
domains
[
len
-
2
]
+
"."
+
domains
[
len
-
1
];
}
else
{
domainName
=
serverName
;
}
}
if
(
domainName
!=
null
&&
domainName
.
indexOf
(
":"
)
>
0
)
{
String
[]
ary
=
domainName
.
split
(
"\\:"
);
domainName
=
ary
[
0
];
}
return
domainName
;
}
}
src/main/java/com/example/tdl/util/HttpRequester.java
View file @
00afa7d3
...
@@ -4,10 +4,7 @@ package com.example.tdl.util;
...
@@ -4,10 +4,7 @@ package com.example.tdl.util;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
java.io.BufferedReader
;
import
java.io.*
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.PrintWriter
;
import
java.net.HttpURLConnection
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
java.net.URLConnection
;
...
@@ -79,9 +76,10 @@ public class HttpRequester {
...
@@ -79,9 +76,10 @@ public class HttpRequester {
// 设置通用的请求属性
// 设置通用的请求属性
connection
.
setRequestProperty
(
"accept"
,
"*/*"
);
connection
.
setRequestProperty
(
"accept"
,
"*/*"
);
connection
.
setRequestProperty
(
"connection"
,
"Keep-Alive"
);
connection
.
setRequestProperty
(
"connection"
,
"Keep-Alive"
);
connection
.
setRequestProperty
(
"Content-Type"
,
"application/json; charset=utf-8"
);
connection
.
setRequestProperty
(
"user-agent"
,
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"
);
connection
.
setRequestProperty
(
"user-agent"
,
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"
);
connection
.
setConnectTimeout
(
5000
);
connection
.
setConnectTimeout
(
5000
);
connection
.
setReadTimeout
(
5
000
);
connection
.
setReadTimeout
(
20
000
);
// 建立实际的连接
// 建立实际的连接
connection
.
connect
();
connection
.
connect
();
// 定义 BufferedReader输入流来读取URL的响应
// 定义 BufferedReader输入流来读取URL的响应
...
@@ -110,5 +108,47 @@ public class HttpRequester {
...
@@ -110,5 +108,47 @@ public class HttpRequester {
return
null
;
return
null
;
}
}
static
String
startGet
(
String
path
){
BufferedReader
in
=
null
;
StringBuilder
result
=
new
StringBuilder
();
try
{
//GET请求直接在链接后面拼上请求参数
URL
url
=
new
URL
(
path
);
HttpURLConnection
conn
=
(
HttpURLConnection
)
url
.
openConnection
();
conn
.
setRequestMethod
(
"GET"
);
//Get请求不需要DoOutPut
conn
.
setDoOutput
(
false
);
conn
.
setDoInput
(
true
);
//设置连接超时时间和读取超时时间
conn
.
setConnectTimeout
(
10000
);
conn
.
setReadTimeout
(
10000
);
conn
.
setRequestProperty
(
"Content-Type"
,
"application/x-www-form-urlencoded"
);
//连接服务器
conn
.
connect
();
// 取得输入流,并使用Reader读取
in
=
new
BufferedReader
(
new
InputStreamReader
(
conn
.
getInputStream
(),
"UTF-8"
));
String
line
;
while
((
line
=
in
.
readLine
())
!=
null
)
{
result
.
append
(
line
);
}
conn
.
disconnect
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
//关闭输入流
finally
{
try
{
if
(
in
!=
null
){
in
.
close
();
}
}
catch
(
IOException
ex
){
ex
.
printStackTrace
();
}
}
return
result
.
toString
();
}
}
}
src/main/java/com/example/tdl/util/PicUploadUtil.java
deleted
100644 → 0
View file @
79cf6251
package
com
.
example
.
tdl
.
util
;
import
com.aliyun.oss.OSSClient
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.web.multipart.MultipartFile
;
public
class
PicUploadUtil
{
private
static
final
String
[]
IMAGE_TYPE
=
new
String
[]{
".bmp"
,
".jpg"
,
".jpeg"
,
".gif"
,
".png"
};
public
static
String
uploadImage
(
MultipartFile
multipartFile
,
String
number
,
String
imageType
){
boolean
isLegal
=
false
;
// 判断文件后缀名是否符合
for
(
String
type
:
IMAGE_TYPE
)
{
if
(
StringUtils
.
endsWithIgnoreCase
(
multipartFile
.
getOriginalFilename
(),
type
))
{
isLegal
=
true
;
break
;
}
}
if
(
isLegal
)
{
try
{
//初始化OSSClient
OSSClient
ossClient
=
AliyunOSSClientUtil
.
getOSSClient
();
String
url
=
AliyunOSSClientUtil
.
uploadImg2Oss
(
ossClient
,
multipartFile
,
number
,
imageType
);
if
(
url
==
null
)
{
return
"上传失败"
;
}
else
{
if
(
"user"
.
equals
(
imageType
)){
return
"https://uploadexcelhltp.oss-cn-shanghai.aliyuncs.com/pic/userImage/"
+
url
;
}
else
if
(
"company"
.
equals
(
imageType
)){
return
"https://uploadexcelhltp.oss-cn-shanghai.aliyuncs.com/pic/companyLog/"
+
url
;
}
else
if
(
"palte"
.
equals
(
imageType
)){
return
"https://uploadexcelhltp.oss-cn-shanghai.aliyuncs.com/pic/palteImage/"
+
url
;
}
else
if
(
"wareHouse"
.
equals
(
imageType
)){
return
"https://uploadexcelhltp.oss-cn-shanghai.aliyuncs.com/pic/wareHouseImage/"
+
url
;
}
else
if
(
"circuit"
.
equals
(
imageType
)){
return
"https://uploadexcelhltp.oss-cn-shanghai.aliyuncs.com/picture/"
+
url
;
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
"上传失败"
;
}
}
else
{
return
"图片格式不正确"
;
}
return
"上传失败"
;
}
}
src/main/java/com/example/tdl/web/AlarmLogController.java
View file @
00afa7d3
...
@@ -205,10 +205,6 @@ public class AlarmLogController {
...
@@ -205,10 +205,6 @@ public class AlarmLogController {
desp
=
"倾角"
+
map
.
get
(
addAlarmLogVo
.
getAlarm
().
get
(
i
).
getAlarmno
());
desp
=
"倾角"
+
map
.
get
(
addAlarmLogVo
.
getAlarm
().
get
(
i
).
getAlarmno
());
classify
=
"4"
;
classify
=
"4"
;
}
}
// else if(addAlarmLogVo.getAlarm().get(i).getAlias().contains("离线")){
// desp = addAlarmLogVo.getAlarm().get(i).getTdlsn()+"离线";
// classify = "6";
// }
AlarmLog
alarmLog
=
new
AlarmLog
(
transportationNo
,
resultCircuitVo
.
getStartCity
(),
resultCircuitVo
.
getEndCity
(),
addAlarmLogVo
.
getAlarm
().
get
(
i
).
getTdlsn
().
replace
(
"TDL-"
,
""
).
trim
(),
desp
,
addAlarmLogVo
.
getAlarm
().
get
(
i
).
getValue
(),
addAlarmLogVo
.
getAlarm
().
get
(
i
).
getTs
()*
1000
,
classify
,
addAlarmLogVo
.
getAlarm
().
get
(
i
).
getDesp
(),
addAlarmLogVo
.
getAlarm
().
get
(
i
).
getAlarmno
());
AlarmLog
alarmLog
=
new
AlarmLog
(
transportationNo
,
resultCircuitVo
.
getStartCity
(),
resultCircuitVo
.
getEndCity
(),
addAlarmLogVo
.
getAlarm
().
get
(
i
).
getTdlsn
().
replace
(
"TDL-"
,
""
).
trim
(),
desp
,
addAlarmLogVo
.
getAlarm
().
get
(
i
).
getValue
(),
addAlarmLogVo
.
getAlarm
().
get
(
i
).
getTs
()*
1000
,
classify
,
addAlarmLogVo
.
getAlarm
().
get
(
i
).
getDesp
(),
addAlarmLogVo
.
getAlarm
().
get
(
i
).
getAlarmno
());
int
a
=
alarmLogServcie
.
addAlarmLog
(
alarmLog
);
int
a
=
alarmLogServcie
.
addAlarmLog
(
alarmLog
);
if
(
a
==
0
){
if
(
a
==
0
){
...
...
src/main/java/com/example/tdl/web/CircuitController.java
View file @
00afa7d3
...
@@ -9,6 +9,7 @@ import com.example.tdl.service.*;
...
@@ -9,6 +9,7 @@ import com.example.tdl.service.*;
import
com.example.tdl.service.redis.AlarmRedisService
;
import
com.example.tdl.service.redis.AlarmRedisService
;
import
com.example.tdl.service.redis.InfoRedisService
;
import
com.example.tdl.service.redis.InfoRedisService
;
import
com.example.tdl.service.redis.TokenRedisService
;
import
com.example.tdl.service.redis.TokenRedisService
;
import
com.example.tdl.util.AlarmRule
;
import
com.google.gson.Gson
;
import
com.google.gson.Gson
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiImplicitParams
;
...
@@ -87,12 +88,7 @@ public class CircuitController {
...
@@ -87,12 +88,7 @@ public class CircuitController {
private
final
static
String
database
=
"original"
;
private
final
static
String
database
=
"original"
;
List
<
String
>
list
=
new
ArrayList
<
String
>(){{
add
(
"T"
);
add
(
"h"
);
add
(
"a0"
);
add
(
"ta"
);
}};
//获取本公司的线路信息
//获取本公司的线路信息
@ApiOperation
(
value
=
"获取本公司的线路信息"
,
notes
=
"获取本公司的线路信息,返回值说明:"
+
@ApiOperation
(
value
=
"获取本公司的线路信息"
,
notes
=
"获取本公司的线路信息,返回值说明:"
+
...
@@ -879,7 +875,7 @@ public class CircuitController {
...
@@ -879,7 +875,7 @@ public class CircuitController {
alarmTypeVar
=
alarmTypeVar
+
addCircuitVo
.
getTdlAlarmList
().
get
(
j
).
getAlarmType
()
+
"&"
;
alarmTypeVar
=
alarmTypeVar
+
addCircuitVo
.
getTdlAlarmList
().
get
(
j
).
getAlarmType
()
+
"&"
;
TDLSNVar
=
TDLSNVar
+
addCircuitVo
.
getTdlAlarmList
().
get
(
j
).
getTDLSN
()
+
"&"
;
TDLSNVar
=
TDLSNVar
+
addCircuitVo
.
getTdlAlarmList
().
get
(
j
).
getTDLSN
()
+
"&"
;
devList
.
add
(
"TDL-"
+
addCircuitVo
.
getTdlAlarmList
().
get
(
j
).
getTDLSN
());
devList
.
add
(
"TDL-"
+
addCircuitVo
.
getTdlAlarmList
().
get
(
j
).
getTDLSN
());
saveAlarmRule
(
"TDL/"
+
type
+
"/"
+
addCircuitVo
.
getSN
()+
"/Data"
,
addCircuitVo
.
getTdlAlarmList
().
get
(
j
).
getTDLSN
(),
addCircuitVo
.
getTdlAlarmList
().
get
(
j
).
getAlarmType
(),
request
);
AlarmRule
.
saveAlarmRule
(
"TDL/"
+
type
+
"/"
+
addCircuitVo
.
getSN
()+
"/Data"
,
addCircuitVo
.
getTdlAlarmList
().
get
(
j
).
getTDLSN
(),
addCircuitVo
.
getTdlAlarmList
().
get
(
j
).
getAlarmType
(),
user
.
getCompanyNo
(),
alarmService
,
alarmRedisService
);
}
}
if
(
StringUtils
.
isEmpty
(
addCircuitVo
.
getCargoNo
())){
if
(
StringUtils
.
isEmpty
(
addCircuitVo
.
getCargoNo
())){
fb
.
setCode
(
0
);
fb
.
setCode
(
0
);
...
@@ -1602,39 +1598,6 @@ public class CircuitController {
...
@@ -1602,39 +1598,6 @@ public class CircuitController {
return
day
+
"天"
+
hour
+
"小时"
+
min
+
"分钟"
+
sec
+
"秒"
;
return
day
+
"天"
+
hour
+
"小时"
+
min
+
"分钟"
+
sec
+
"秒"
;
}
}
//将报警规则存到redis中
public
void
saveAlarmRule
(
String
topic
,
String
TDLSN
,
String
alarmType
,
HttpServletRequest
request
){
String
token
=
request
.
getHeader
(
"Account_token"
);
String
datum
=
tokenRedisService
.
get
(
"TOKEN_"
+
token
);
UserRedisVo
user
=
gson
.
fromJson
(
datum
,
UserRedisVo
.
class
);
ResultAlarmVo
alarmVo
=
alarmService
.
getByType
(
alarmType
,
user
.
getCompanyNo
());
for
(
String
alias
:
list
){
List
<
AlarmRuleVo
>
alarmRuleVos
=
new
ArrayList
<>();
AlarmRuleVo
alarmRuleVo
=
new
AlarmRuleVo
();
if
(
alias
.
equals
(
"T"
)){
alarmRuleVo
.
setMinval
(
String
.
valueOf
(
alarmVo
.
getTemMin
()));
alarmRuleVo
.
setMaxval
(
String
.
valueOf
(
alarmVo
.
getTemMax
()));
alarmRuleVo
.
setMode
(
"twoway"
);
alarmRuleVo
.
setPriority
(
"1"
);
}
else
if
(
alias
.
equals
(
"h"
)){
alarmRuleVo
.
setMinval
(
String
.
valueOf
(
alarmVo
.
getHumidityMin
()));
alarmRuleVo
.
setMaxval
(
String
.
valueOf
(
alarmVo
.
getHumidityMax
()));
alarmRuleVo
.
setMode
(
"twoway"
);
alarmRuleVo
.
setPriority
(
"1"
);
}
else
if
(
alias
.
equals
(
"ta"
)){
alarmRuleVo
.
setMaxval
(
String
.
valueOf
(
alarmVo
.
getTilt
()));
alarmRuleVo
.
setMode
(
"greater"
);
alarmRuleVo
.
setPriority
(
"1"
);
}
else
if
(
alias
.
equals
(
"a0"
)){
alarmRuleVo
.
setMaxval
(
String
.
valueOf
(
alarmVo
.
getShock
()));
alarmRuleVo
.
setMode
(
"greater"
);
alarmRuleVo
.
setPriority
(
"1"
);
}
alarmRuleVos
.
add
(
alarmRuleVo
);
//向redis中写入报警信息
alarmRedisService
.
hmSet
(
topic
,
"TDL-"
+
TDLSN
+
"_"
+
alias
,
gson
.
toJson
(
alarmRuleVos
));
}
}
...
...
src/main/java/com/example/tdl/web/EquipmentBindingController.java
View file @
00afa7d3
...
@@ -8,6 +8,7 @@ import com.example.tdl.domain.vo.*;
...
@@ -8,6 +8,7 @@ import com.example.tdl.domain.vo.*;
import
com.example.tdl.service.*
;
import
com.example.tdl.service.*
;
import
com.example.tdl.service.redis.AlarmRedisService
;
import
com.example.tdl.service.redis.AlarmRedisService
;
import
com.example.tdl.service.redis.TokenRedisService
;
import
com.example.tdl.service.redis.TokenRedisService
;
import
com.example.tdl.util.AlarmRule
;
import
com.google.gson.Gson
;
import
com.google.gson.Gson
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiImplicitParams
;
...
@@ -60,12 +61,6 @@ public class EquipmentBindingController {
...
@@ -60,12 +61,6 @@ public class EquipmentBindingController {
@Autowired
@Autowired
private
I18nController
i18n
;
private
I18nController
i18n
;
List
<
String
>
list
=
new
ArrayList
<
String
>(){{
add
(
"T"
);
add
(
"h"
);
add
(
"a0"
);
add
(
"ta"
);
}};
@ApiOperation
(
value
=
"绑定gateWay和tdl"
,
notes
=
"绑定gateWay和tdl"
+
@ApiOperation
(
value
=
"绑定gateWay和tdl"
,
notes
=
"绑定gateWay和tdl"
+
" SN:gateWay编号,"
+
" SN:gateWay编号,"
+
...
@@ -130,15 +125,12 @@ public class EquipmentBindingController {
...
@@ -130,15 +125,12 @@ public class EquipmentBindingController {
}
else
if
(
StringUtils
.
isEmpty
(
bindingVo
.
getWarehouseNo
())
&&
!
StringUtils
.
isEmpty
(
bindingVo
.
getTransportationNo
())){
}
else
if
(
StringUtils
.
isEmpty
(
bindingVo
.
getWarehouseNo
())
&&
!
StringUtils
.
isEmpty
(
bindingVo
.
getTransportationNo
())){
bindingVo
.
setWarehouseNo
(
""
);
bindingVo
.
setWarehouseNo
(
""
);
}
}
String
alarmScene
=
""
;
Integer
gpsPeriod
=
null
;
Integer
gpsPeriod
=
null
;
Integer
gprsPeriod
=
null
;
Integer
gprsPeriod
=
null
;
if
(
bindingVo
.
getMode
()
==
2
){
if
(
bindingVo
.
getMode
()
==
2
){
alarmScene
=
"仓库"
;
gpsPeriod
=
43200
;
gpsPeriod
=
43200
;
gprsPeriod
=
60
;
gprsPeriod
=
60
;
}
else
{
}
else
{
alarmScene
=
"运输"
;
gpsPeriod
=
5
;
gpsPeriod
=
5
;
if
(
"17110194"
.
equals
(
bindingVo
.
getSN
())){
if
(
"17110194"
.
equals
(
bindingVo
.
getSN
())){
gprsPeriod
=
7
;
gprsPeriod
=
7
;
...
@@ -194,33 +186,7 @@ public class EquipmentBindingController {
...
@@ -194,33 +186,7 @@ public class EquipmentBindingController {
fb
.
setCode
(
1
);
fb
.
setCode
(
1
);
fb
.
setMessage
(
"配置网关成功"
);
fb
.
setMessage
(
"配置网关成功"
);
//根据报警类型货报警信息
//根据报警类型货报警信息
AlarmRule
.
saveAlarmRule
(
"TDL/"
+
bindingVo
.
getType
()+
"/"
+
bindingVo
.
getSN
()+
"/Data"
,
bindingVo
.
getTDLSN
(),
bindingVo
.
getAlarmType
(),
user
.
getCompanyNo
(),
alarmService
,
alarmRedisService
);
for
(
String
alias
:
list
){
List
<
AlarmRuleVo
>
alarmRuleVos
=
new
ArrayList
<>();
AlarmRuleVo
alarmRuleVo
=
new
AlarmRuleVo
();
if
(
alias
.
equals
(
"T"
)){
alarmRuleVo
.
setMinval
(
String
.
valueOf
(
alarmVo
.
getTemMin
()));
alarmRuleVo
.
setMaxval
(
String
.
valueOf
(
alarmVo
.
getTemMax
()));
alarmRuleVo
.
setMode
(
"twoway"
);
alarmRuleVo
.
setPriority
(
"1"
);
}
else
if
(
alias
.
equals
(
"h"
)){
alarmRuleVo
.
setMinval
(
String
.
valueOf
(
alarmVo
.
getHumidityMin
()));
alarmRuleVo
.
setMaxval
(
String
.
valueOf
(
alarmVo
.
getHumidityMax
()));
alarmRuleVo
.
setMode
(
"twoway"
);
alarmRuleVo
.
setPriority
(
"1"
);
}
else
if
(
alias
.
equals
(
"ta"
)){
alarmRuleVo
.
setMaxval
(
String
.
valueOf
(
alarmVo
.
getTilt
()));
alarmRuleVo
.
setMode
(
"greater"
);
alarmRuleVo
.
setPriority
(
"1"
);
}
else
if
(
alias
.
equals
(
"a0"
)){
alarmRuleVo
.
setMaxval
(
String
.
valueOf
(
alarmVo
.
getShock
()));
alarmRuleVo
.
setMode
(
"greater"
);
alarmRuleVo
.
setPriority
(
"1"
);
}
alarmRuleVos
.
add
(
alarmRuleVo
);
//向redis中写入报警信息
alarmRedisService
.
hmSet
(
"TDL/"
+
bindingVo
.
getType
()+
"/"
+
bindingVo
.
getSN
()+
"/Data"
,
"TDL-"
+
bindingVo
.
getTDLSN
()+
"_"
+
alias
,
gson
.
toJson
(
alarmRuleVos
));
}
}
else
{
}
else
{
fb
.
setCode
(
0
);
fb
.
setCode
(
0
);
fb
.
setMessage
(
msg
.
get
(
"msg"
).
toString
());
fb
.
setMessage
(
msg
.
get
(
"msg"
).
toString
());
...
...
src/main/java/com/example/tdl/web/WarehouseController.java
View file @
00afa7d3
...
@@ -1008,8 +1008,6 @@ public class WarehouseController {
...
@@ -1008,8 +1008,6 @@ public class WarehouseController {
warehouseDataVo
.
setTemperature
(
"NA"
);
warehouseDataVo
.
setTemperature
(
"NA"
);
warehouseDataVo
.
setHumidity
(
"NA"
);
warehouseDataVo
.
setHumidity
(
"NA"
);
}
}
if
(
queryResults
.
getResults
().
get
(
0
).
getSeries
()
!=
null
){
if
(
queryResults
.
getResults
().
get
(
0
).
getSeries
()
!=
null
){
//解析数据
//解析数据
WarehouseTDLDetailVo
warehouseTDLDetailVo
=
new
WarehouseTDLDetailVo
();
WarehouseTDLDetailVo
warehouseTDLDetailVo
=
new
WarehouseTDLDetailVo
();
...
@@ -1155,7 +1153,7 @@ public class WarehouseController {
...
@@ -1155,7 +1153,7 @@ public class WarehouseController {
for
(
List
<
Object
>
value:
values
){
for
(
List
<
Object
>
value:
values
){
WarehouseTimeAndDataVo
warehouseTimeAndDataVo
=
new
WarehouseTimeAndDataVo
();
WarehouseTimeAndDataVo
warehouseTimeAndDataVo
=
new
WarehouseTimeAndDataVo
();
warehouseTimeAndDataVo
.
setTime
(
parseTime
(
value
.
get
(
0
).
toString
()));
warehouseTimeAndDataVo
.
setTime
(
parseTime
(
value
.
get
(
0
).
toString
()));
warehouseTimeAndDataVo
.
setValue
(
value
.
get
(
2
)==
null
?
""
:
value
.
get
(
2
).
toString
());
warehouseTimeAndDataVo
.
setValue
(
value
.
get
(
3
)==
null
?
""
:
value
.
get
(
3
).
toString
());
historyDataList
.
add
(
warehouseTimeAndDataVo
);
historyDataList
.
add
(
warehouseTimeAndDataVo
);
}
}
return
historyDataList
;
return
historyDataList
;
...
@@ -1167,7 +1165,7 @@ public class WarehouseController {
...
@@ -1167,7 +1165,7 @@ public class WarehouseController {
for
(
List
<
Object
>
value:
values
){
for
(
List
<
Object
>
value:
values
){
WarehouseTimeAndDataVo
warehouseTimeAndDataVo
=
new
WarehouseTimeAndDataVo
();
WarehouseTimeAndDataVo
warehouseTimeAndDataVo
=
new
WarehouseTimeAndDataVo
();
warehouseTimeAndDataVo
.
setTime
(
parseTime
(
value
.
get
(
0
).
toString
()));
warehouseTimeAndDataVo
.
setTime
(
parseTime
(
value
.
get
(
0
).
toString
()));
warehouseTimeAndDataVo
.
setValue
(
value
.
get
(
3
)==
null
?
""
:
value
.
get
(
3
).
toString
());
warehouseTimeAndDataVo
.
setValue
(
value
.
get
(
4
)==
null
?
""
:
value
.
get
(
4
).
toString
());
historyDataList
.
add
(
warehouseTimeAndDataVo
);
historyDataList
.
add
(
warehouseTimeAndDataVo
);
}
}
return
historyDataList
;
return
historyDataList
;
...
...
src/main/resources/application-docker.properties
View file @
00afa7d3
...
@@ -12,3 +12,18 @@ server.port=8092
...
@@ -12,3 +12,18 @@ server.port=8092
spring.influxdb.url
=
http://housetest-influxdb:8086
spring.influxdb.url
=
http://housetest-influxdb:8086
#spring.datasource.url=jdbc:mysql://witcloud-mysql:3306/tdlCloud?useUnicode=true&characterEncoding=utf-8&useSSL=false
#spring.datasource.username=root
#spring.datasource.password=37774020
#spring.datasource.driver-class-name=com.mysql.jdbc.Driver
#tdl.redis.host=witcloud-redis
# InfluxDB
#spring.influxdb.url=http://witcloud-influxdb:8086
#tdl.mqtt.url = ssl://47.96.128.181
#tdl.mqtt.port = 8883
#tdl.mqtt.username = logistics
#tdl.mqtt.password = logistics37774020
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment