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
b1cbc7d8
Commit
b1cbc7d8
authored
Sep 28, 2018
by
zhuangzhuang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
9.28-增加预警阈值判断,增加数据下载国际化,对异常坐标点进行剔除
parent
8ce43ef4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
567 additions
and
220 deletions
+567
-220
WarehouseExcel.java
src/main/java/com/example/tdl/common/WarehouseExcel.java
+36
-25
DownloadForWarehouseVo.java
...ava/com/example/tdl/domain/vo/DownloadForWarehouseVo.java
+9
-0
TransportationNoVo.java
...in/java/com/example/tdl/domain/vo/TransportationNoVo.java
+24
-0
DataUtil.java
src/main/java/com/example/tdl/util/DataUtil.java
+28
-15
MapUtils.java
src/main/java/com/example/tdl/util/MapUtils.java
+49
-0
ZipCompressUtil.java
src/main/java/com/example/tdl/util/ZipCompressUtil.java
+5
-0
AlarmController.java
src/main/java/com/example/tdl/web/AlarmController.java
+60
-0
DataController.java
src/main/java/com/example/tdl/web/DataController.java
+283
-131
DownloadController.java
src/main/java/com/example/tdl/web/DownloadController.java
+17
-49
messages_en.properties
src/main/resources/i18n/messages_en.properties
+23
-0
messages_ja.properties
src/main/resources/i18n/messages_ja.properties
+8
-0
messages_zh_CN.properties
src/main/resources/i18n/messages_zh_CN.properties
+25
-0
No files found.
src/main/java/com/example/tdl/common/WarehouseExcel.java
View file @
b1cbc7d8
package
com
.
example
.
tdl
.
common
;
import
com.example.tdl.domain.vo.*
;
import
com.example.tdl.web.I18nController
;
import
org.apache.poi.hssf.usermodel.*
;
import
org.apache.poi.hssf.util.HSSFColor
;
import
org.apache.poi.ss.usermodel.CellStyle
;
...
...
@@ -10,8 +11,10 @@ import org.apache.poi.ss.util.RegionUtil;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.text.SimpleDateFormat
;
import
java.time.chrono.IsoChronology
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -24,16 +27,21 @@ public class WarehouseExcel {
private
String
userName
;
private
ResultWarehouseNoAndTDLSNAndTimeVo
resultWarehouseNoAndTDLSNAndTimeVo
;
private
HttpServletRequest
request
;
private
I18nController
i18n
;
// private List<DownloadWarehouseVo> downloadWarehouseVos;
public
WarehouseExcel
(
String
fileName
,
String
userName
,
ResultWarehouseNoAndTDLSNAndTimeVo
resultWarehouseNoAndTDLSNAndTimeVo
)
{
public
WarehouseExcel
(
String
fileName
,
String
userName
,
ResultWarehouseNoAndTDLSNAndTimeVo
resultWarehouseNoAndTDLSNAndTimeVo
,
HttpServletRequest
request
,
I18nController
i18n
)
{
this
.
fileName
=
fileName
;
this
.
userName
=
userName
;
this
.
resultWarehouseNoAndTDLSNAndTimeVo
=
resultWarehouseNoAndTDLSNAndTimeVo
;
this
.
request
=
request
;
this
.
i18n
=
i18n
;
}
/*
...
...
@@ -79,7 +87,7 @@ public class WarehouseExcel {
//设置列的格式
cell2
.
setCellStyle
(
rowStyle2
);
//将标题添加到列中
cell2
.
setCellValue
(
"年度:2018年
"
);
cell2
.
setCellValue
(
i18n
.
getMessage
(
request
,
"year"
)+
":2018
"
);
}
sheet
.
addMergedRegion
(
new
CellRangeAddress
(
1
,
1
,
0
,
2
));
for
(
int
n
=
3
;
n
<
6
;
n
++)
{
...
...
@@ -87,11 +95,13 @@ public class WarehouseExcel {
//设置列的格式
cell2
.
setCellStyle
(
rowStyle2
);
//将标题添加到列中
cell2
.
setCellValue
(
"库房适宜温度为"
+
resultWarehouseNoAndTDLSNAndTimeVo
.
getTemMin
()+
"℃-"
+
resultWarehouseNoAndTDLSNAndTimeVo
.
getTemMax
()+
"℃,湿度保持"
+
resultWarehouseNoAndTDLSNAndTimeVo
.
getHumidityMin
()+
"%-"
+
resultWarehouseNoAndTDLSNAndTimeVo
.
getHumidityMax
()+
"%,超标要做必要调节。"
);
Object
[]
args
={
resultWarehouseNoAndTDLSNAndTimeVo
.
getTemMin
(),
resultWarehouseNoAndTDLSNAndTimeVo
.
getTemMax
(),
resultWarehouseNoAndTDLSNAndTimeVo
.
getHumidityMin
(),
resultWarehouseNoAndTDLSNAndTimeVo
.
getHumidityMax
()};
cell2
.
setCellValue
(
i18n
.
getMessage
(
request
,
args
,
"suitable"
));
}
sheet
.
addMergedRegion
(
new
CellRangeAddress
(
1
,
1
,
3
,
5
));
cell2
=
row2
.
createCell
(
6
);
cell2
.
setCellValue
(
"记录人:"
+
userName
);
cell2
.
setCellValue
(
i18n
.
getMessage
(
request
,
"recorder"
)+
":"
+
userName
);
cell2
.
setCellStyle
(
rowStyle2
);
row2
.
setHeight
((
short
)
(
26
*
20
));
...
...
@@ -106,20 +116,20 @@ public class WarehouseExcel {
cell3
=
row3
.
createCell
(
n
);
cell3
.
setCellStyle
(
rowStyle3
);
//将标题添加到列中
cell3
.
setCellValue
(
"采样时间"
);
cell3
.
setCellValue
(
i18n
.
getMessage
(
request
,
"SamplingTime"
)
);
}
sheet
.
addMergedRegion
(
new
CellRangeAddress
(
2
,
2
,
0
,
2
));
cell3
=
row3
.
createCell
(
3
);
cell3
.
setCellValue
(
"天气"
);
cell3
.
setCellValue
(
i18n
.
getMessage
(
request
,
"Weather"
)
);
cell3
.
setCellStyle
(
rowStyle3
);
cell3
=
row3
.
createCell
(
4
);
cell3
.
setCellValue
(
"温度"
);
cell3
.
setCellValue
(
i18n
.
getMessage
(
request
,
"Temperature"
)
);
cell3
.
setCellStyle
(
rowStyle3
);
cell3
=
row3
.
createCell
(
5
);
cell3
.
setCellValue
(
"湿度"
);
cell3
.
setCellValue
(
i18n
.
getMessage
(
request
,
"Humidity"
)
);
cell3
.
setCellStyle
(
rowStyle3
);
cell3
=
row3
.
createCell
(
6
);
cell3
.
setCellValue
(
"是否预警"
);
cell3
.
setCellValue
(
i18n
.
getMessage
(
request
,
"EnableAllert"
)
);
cell3
.
setCellStyle
(
rowStyle3
);
row3
.
setHeight
((
short
)
(
26
*
20
));
...
...
@@ -131,25 +141,25 @@ public class WarehouseExcel {
HSSFCell
cell4
=
null
;
HSSFCellStyle
rowStyle4
=
getStyle
(
workbook
);
cell4
=
row4
.
createCell
(
0
);
cell4
.
setCellValue
(
"月"
);
cell4
.
setCellValue
(
i18n
.
getMessage
(
request
,
"Month"
)
);
cell4
.
setCellStyle
(
rowStyle4
);
cell4
=
row4
.
createCell
(
1
);
cell4
.
setCellValue
(
"日"
);
cell4
.
setCellValue
(
i18n
.
getMessage
(
request
,
"Day"
)
);
cell4
.
setCellStyle
(
rowStyle4
);
cell4
=
row4
.
createCell
(
2
);
cell4
.
setCellValue
(
"时分"
);
cell4
.
setCellValue
(
i18n
.
getMessage
(
request
,
"Time"
)
);
cell4
.
setCellStyle
(
rowStyle4
);
cell4
=
row4
.
createCell
(
3
);
cell4
.
setCellValue
(
"天气"
);
cell4
.
setCellValue
(
i18n
.
getMessage
(
request
,
"Weather"
)
);
cell4
.
setCellStyle
(
rowStyle4
);
cell4
=
row4
.
createCell
(
4
);
cell4
.
setCellValue
(
"温度(℃)"
);
cell4
.
setCellValue
(
i18n
.
getMessage
(
request
,
"Temperature"
)
);
cell4
.
setCellStyle
(
rowStyle4
);
cell4
=
row4
.
createCell
(
5
);
cell4
.
setCellValue
(
"湿度(%RH)"
);
cell4
.
setCellValue
(
i18n
.
getMessage
(
request
,
"Humidity"
)
);
cell4
.
setCellStyle
(
rowStyle4
);
cell4
=
row4
.
createCell
(
6
);
cell4
.
setCellValue
(
"是否预警"
);
cell4
.
setCellValue
(
i18n
.
getMessage
(
request
,
"EnableAllert"
)
);
cell4
.
setCellStyle
(
rowStyle4
);
sheet
.
addMergedRegion
(
new
CellRangeAddress
(
2
,
3
,
3
,
3
));
sheet
.
addMergedRegion
(
new
CellRangeAddress
(
2
,
3
,
4
,
4
));
...
...
@@ -169,7 +179,7 @@ public class WarehouseExcel {
//设置列的格式
cell
.
setCellStyle
(
rowStyle
);
//将标题添加到列中
cell
.
setCellValue
(
new
HSSFRichTextString
(
resultWarehouseNoAndTDLSNAndTimeVo
.
getGatewaySN
()+
"该时间段没有数据"
));
cell
.
setCellValue
(
new
HSSFRichTextString
(
resultWarehouseNoAndTDLSNAndTimeVo
.
getGatewaySN
()+
i18n
.
getMessage
(
request
,
"NoData"
)
));
}
//设置行高
row
.
setHeight
((
short
)
(
26
*
20
));
...
...
@@ -180,22 +190,23 @@ public class WarehouseExcel {
for
(
int
i
=
0
;
i
<
resultWarehouseNoAndTDLSNAndTimeVo
.
getDownloadWarehouseVos
().
size
();
i
++)
{
HSSFRow
row
=
sheet
.
createRow
((
short
)
rowCount
+
i
);
HSSFCell
cell
=
null
;
Long
time
=
Long
.
valueOf
(
resultWarehouseNoAndTDLSNAndTimeVo
.
getDownloadWarehouseVos
().
get
(
i
).
getTime
());
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd
HH:mm:
ss"
);
Date
date
=
new
Date
(
time
);
Long
seconds
=
Long
.
valueOf
(
resultWarehouseNoAndTDLSNAndTimeVo
.
getDownloadWarehouseVos
().
get
(
i
).
getTime
());
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd
-HH-mm-
ss"
);
String
time
=
sdf
.
format
(
new
Date
(
seconds
)
);
String
[]
t
=
sdf
.
format
(
new
Date
(
seconds
)).
split
(
"-"
);
cell2
=
row2
.
createCell
(
1
);
cell2
.
setCellValue
(
date
.
getYear
()
);
cell2
.
setCellValue
(
t
[
0
]
);
cell2
.
setCellStyle
(
rowStyle
);
cell
=
row
.
createCell
(
0
);
cell
.
setCellValue
(
date
.
getMonth
()+
1
);
cell
.
setCellValue
(
t
[
1
]
);
cell
.
setCellStyle
(
rowStyle
);
cell
=
row
.
createCell
(
1
);
cell
.
setCellValue
(
date
.
getDay
()
);
cell
.
setCellValue
(
t
[
2
]
);
cell
.
setCellStyle
(
rowStyle
);
cell
=
row
.
createCell
(
2
);
cell
.
setCellValue
(
date
.
getHours
()+
":"
+
date
.
getMinutes
()
);
cell
.
setCellValue
(
t
[
3
]+
":"
+
t
[
4
]
);
cell
.
setCellStyle
(
rowStyle
);
cell
=
row
.
createCell
(
3
);
cell
.
setCellValue
(
"-"
);
...
...
src/main/java/com/example/tdl/domain/vo/DownloadForWarehouseVo.java
View file @
b1cbc7d8
...
...
@@ -7,6 +7,8 @@ public class DownloadForWarehouseVo {
private
String
warehouseNo
;
private
String
offset
;
public
Long
getStartTime
()
{
return
startTime
;
}
...
...
@@ -31,4 +33,11 @@ public class DownloadForWarehouseVo {
this
.
warehouseNo
=
warehouseNo
;
}
public
String
getOffset
()
{
return
offset
;
}
public
void
setOffset
(
String
offset
)
{
this
.
offset
=
offset
;
}
}
src/main/java/com/example/tdl/domain/vo/TransportationNoVo.java
0 → 100644
View file @
b1cbc7d8
package
com
.
example
.
tdl
.
domain
.
vo
;
public
class
TransportationNoVo
{
private
String
transportationNo
;
private
String
offset
;
public
String
getTransportationNo
()
{
return
transportationNo
;
}
public
void
setTransportationNo
(
String
transportationNo
)
{
this
.
transportationNo
=
transportationNo
;
}
public
String
getOffset
()
{
return
offset
;
}
public
void
setOffset
(
String
offset
)
{
this
.
offset
=
offset
;
}
}
src/main/java/com/example/tdl/util/DataUtil.java
View file @
b1cbc7d8
...
...
@@ -19,6 +19,7 @@ import javax.servlet.http.HttpServletRequest;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -169,7 +170,11 @@ public class DataUtil {
if
(
result
.
getSeries
()
!=
null
)
{
for
(
QueryResult
.
Series
series
:
result
.
getSeries
())
{
if
(
series
!=
null
)
{
values
=
series
.
getValues
();
if
(
queryResult
.
getResults
().
size
()>
1
){
values
.
add
(
series
.
getValues
().
get
(
0
));
}
else
{
values
=
series
.
getValues
();
}
}
}
}
...
...
@@ -177,6 +182,8 @@ public class DataUtil {
return
values
;
}
public
static
String
parseTime
(
String
time
)
{
String
dateResult
=
null
;
try
{
...
...
@@ -201,20 +208,7 @@ public class DataUtil {
public
static
List
<
HistoryData
>
getHistoryDatas
(
QueryResult
queryResult
,
String
alias
)
{
String
dateResult
=
null
;
List
<
List
<
Object
>>
value
=
new
ArrayList
<>();
for
(
QueryResult
.
Result
result
:
queryResult
.
getResults
())
{
if
(
result
.
getSeries
()
!=
null
)
{
for
(
QueryResult
.
Series
series
:
result
.
getSeries
())
{
if
(
series
!=
null
)
{
value
.
add
(
series
.
getValues
().
get
(
0
));
}
else
{
continue
;
}
}
}
else
{
continue
;
}
}
List
<
List
<
Object
>>
value
=
getValues
(
queryResult
);
List
<
HistoryData
>
historyDataList
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
value
.
size
();
i
++)
{
HistoryData
historyData
=
new
HistoryData
();
...
...
@@ -226,6 +220,25 @@ public class DataUtil {
}
public
static
String
UTCToCST
(
String
UTCStr
,
String
offset
)
{
Date
date
=
null
;
try
{
if
(
UTCStr
.
length
()
!=
20
)
{
date
=
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
).
parse
(
UTCStr
);
}
else
{
date
=
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ss'Z'"
).
parse
(
UTCStr
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
logger
.
info
(
e
.
toString
());
}
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
date
);
calendar
.
set
(
Calendar
.
HOUR
,
calendar
.
get
(
Calendar
.
HOUR
)
+
Integer
.
valueOf
(
offset
));
//calendar.getTime() 返回的是Date类型,也可以使用calendar.getTimeInMillis()获取时间戳
//format的格式可以任意
return
String
.
valueOf
(
calendar
.
getTimeInMillis
());
}
}
src/main/java/com/example/tdl/util/MapUtils.java
0 → 100644
View file @
b1cbc7d8
package
com
.
example
.
tdl
.
util
;
public
class
MapUtils
{
//private static double EARTH_RADIUS = 6378.137;
private
static
double
EARTH_RADIUS
=
6371.393
;
private
static
double
rad
(
double
d
)
{
return
d
*
Math
.
PI
/
180.0
;
}
/**
* 计算两个经纬度之间的距离
* @param lat1
* @param lng1
* @param lat2
* @param lng2
* @return
*/
public
static
double
getDistance
(
double
lat1
,
double
lng1
,
double
lat2
,
double
lng2
)
{
double
radLat1
=
rad
(
lat1
);
double
radLat2
=
rad
(
lat2
);
double
a
=
radLat1
-
radLat2
;
double
b
=
rad
(
lng1
)
-
rad
(
lng2
);
double
s
=
2
*
Math
.
asin
(
Math
.
sqrt
(
Math
.
pow
(
Math
.
sin
(
a
/
2
),
2
)
+
Math
.
cos
(
radLat1
)*
Math
.
cos
(
radLat2
)*
Math
.
pow
(
Math
.
sin
(
b
/
2
),
2
)));
s
=
s
*
EARTH_RADIUS
;
s
=
Math
.
round
(
s
*
1000
);
// System.out.println(s+"----------------");
return
s
;
}
//计算速度
public
static
double
getSpeed
(
double
lat1
,
double
lng1
,
double
lat2
,
double
lng2
,
Long
time
){
double
s
=
getDistance
(
lat1
,
lng1
,
lat2
,
lng2
);
if
(
s
<
1000
||
s
>
10000
){
return
0
;
}
return
s
/
time
;
}
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
MapUtils
.
getDistance
(
29.490295
,
106.486654
,
29.615467
,
106.581515
));
}
}
src/main/java/com/example/tdl/util/ZipCompressUtil.java
View file @
b1cbc7d8
package
com
.
example
.
tdl
.
util
;
import
org.apache.commons.lang3.StringUtils
;
import
java.io.*
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipOutputStream
;
...
...
@@ -85,6 +87,9 @@ public class ZipCompressUtil {
ZipEntry
zipEntry
=
null
;
// 遍历源文件数组
for
(
int
i
=
0
;
i
<
srcFiles
.
length
;
i
++)
{
if
(
srcFiles
[
i
]==
null
){
continue
;
}
// 将源文件数组中的当前文件读入 FileInputStream 流中
fileInputStream
=
new
FileInputStream
(
srcFiles
[
i
]);
// 实例化 ZipEntry 对象,源文件数组中的当前文件
...
...
src/main/java/com/example/tdl/web/AlarmController.java
View file @
b1cbc7d8
...
...
@@ -122,11 +122,21 @@ public class AlarmController {
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"temMax"
));
return
gson
.
toJson
(
fb
);
}
if
(
addAlarmVo
.
getTemMax
()>
85
f
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"temMaxLimit"
));
return
gson
.
toJson
(
fb
);
}
if
(
addAlarmVo
.
getTemMin
()==
null
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"temMin"
));
return
gson
.
toJson
(
fb
);
}
if
(
addAlarmVo
.
getTemMin
()<-
25
f
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"temMinLimit"
));
return
gson
.
toJson
(
fb
);
}
if
(
addAlarmVo
.
getTemMin
()
>
addAlarmVo
.
getTemMax
()){
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"wrongTemp"
));
...
...
@@ -142,6 +152,16 @@ public class AlarmController {
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"humidityMin"
));
return
gson
.
toJson
(
fb
);
}
if
(
addAlarmVo
.
getHumidityMax
()>
100
F
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"humidityMaxLimit"
));
return
gson
.
toJson
(
fb
);
}
if
(
addAlarmVo
.
getHumidityMin
()<
0
F
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"humidityMinLimit"
));
return
gson
.
toJson
(
fb
);
}
if
(
addAlarmVo
.
getHumidityMin
()
>
addAlarmVo
.
getHumidityMax
()){
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"wrongHumidity"
));
...
...
@@ -152,11 +172,21 @@ public class AlarmController {
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"tilt"
));
return
gson
.
toJson
(
fb
);
}
if
(
addAlarmVo
.
getTilt
()<
0
||
addAlarmVo
.
getTilt
()>
180
||
addAlarmVo
.
getTilt
()%
30
!=
0
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"tiltLimit"
));
return
gson
.
toJson
(
fb
);
}
if
(
addAlarmVo
.
getShock
()==
null
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"shock"
));
return
gson
.
toJson
(
fb
);
}
if
(
Float
.
valueOf
(
addAlarmVo
.
getShock
())<
1.5
||
Float
.
valueOf
(
addAlarmVo
.
getShock
())>
13.8
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"shockLimit"
));
return
gson
.
toJson
(
fb
);
}
if
(
alarmService
.
getByType
(
addAlarmVo
.
getAlarmType
(),
user
.
getCompanyNo
())!=
null
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"alarmExist"
));
...
...
@@ -210,11 +240,21 @@ public class AlarmController {
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"temMax"
));
return
gson
.
toJson
(
fb
);
}
if
(
updateAlarmVo
.
getTemMax
()>
85
f
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"temMaxLimit"
));
return
gson
.
toJson
(
fb
);
}
if
(
updateAlarmVo
.
getTemMin
()==
null
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"temMin"
));
return
gson
.
toJson
(
fb
);
}
if
(
updateAlarmVo
.
getTemMin
()<-
25
f
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"temMinLimit"
));
return
gson
.
toJson
(
fb
);
}
if
(
updateAlarmVo
.
getTemMin
()
>
updateAlarmVo
.
getTemMax
()){
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"wrongTemp"
));
...
...
@@ -230,11 +270,26 @@ public class AlarmController {
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"humidityMin"
));
return
gson
.
toJson
(
fb
);
}
if
(
updateAlarmVo
.
getHumidityMax
()>
100
F
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"humidityMaxLimit"
));
return
gson
.
toJson
(
fb
);
}
if
(
updateAlarmVo
.
getHumidityMin
()<
0
F
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"humidityMinLimit"
));
return
gson
.
toJson
(
fb
);
}
if
(
updateAlarmVo
.
getHumidityMin
()>
updateAlarmVo
.
getHumidityMax
()){
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"wrongHumidity"
));
return
gson
.
toJson
(
fb
);
}
if
(
updateAlarmVo
.
getTilt
()<
0
||
updateAlarmVo
.
getTilt
()>
180
||
updateAlarmVo
.
getTilt
()%
30
!=
0
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"tiltLimit"
));
return
gson
.
toJson
(
fb
);
}
if
(
updateAlarmVo
.
getTilt
()==
null
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"tilt"
));
...
...
@@ -245,6 +300,11 @@ public class AlarmController {
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"shock"
));
return
gson
.
toJson
(
fb
);
}
if
(
Float
.
valueOf
(
updateAlarmVo
.
getShock
())<
1.5
||
Float
.
valueOf
(
updateAlarmVo
.
getShock
())>
13.8
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"shockLimit"
));
return
gson
.
toJson
(
fb
);
}
if
(
alarmService
.
getByType
(
updateAlarmVo
.
getAlarmType
(),
user
.
getCompanyNo
())!=
null
&&!
updateAlarmVo
.
getAlarmType
().
equals
(
updateAlarmVo
.
getAlarmType
())){
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"modifiedAlarmExist"
));
...
...
src/main/java/com/example/tdl/web/DataController.java
View file @
b1cbc7d8
This diff is collapsed.
Click to expand it.
src/main/java/com/example/tdl/web/DownloadController.java
View file @
b1cbc7d8
...
...
@@ -4,10 +4,12 @@ import com.aliyun.oss.OSSClient;
import
com.example.tdl.common.WarehouseExcel
;
import
com.example.tdl.domain.dto.CommFeedback
;
import
com.example.tdl.domain.vo.*
;
import
com.example.tdl.entity.Config
;
import
com.example.tdl.service.*
;
import
com.example.tdl.service.redis.InfoRedisService
;
import
com.example.tdl.service.redis.TokenRedisService
;
import
com.example.tdl.util.AliyunOSSClientUtil
;
import
com.example.tdl.util.DataUtil
;
import
com.example.tdl.util.ZipCompressUtil
;
import
com.google.gson.Gson
;
import
io.swagger.annotations.ApiImplicitParam
;
...
...
@@ -64,6 +66,7 @@ public class DownloadController {
@ApiOperation
(
value
=
"仓库数据下载"
,
notes
=
"仓库数据下载"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"AccountLanguage"
,
value
=
"language"
,
required
=
true
,
dataType
=
"String"
),
})
@RequestMapping
(
value
=
"/download"
,
method
=
RequestMethod
.
POST
)
public
String
downLoad
(
HttpServletResponse
response
,
HttpServletRequest
request
,
@RequestBody
DownloadForWarehouseVo
downloadForWarehouseVo
)
throws
ParseException
{
...
...
@@ -101,7 +104,7 @@ public class DownloadController {
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"noData"
));
return
gson
.
toJson
(
fb
);
}
File
zipFile
=
new
File
(
"./export/"
+
downloadForWarehouseVo
.
getWarehouseNo
()+
"仓库温湿度观测记录
.zip"
);
File
zipFile
=
new
File
(
"./export/"
+
downloadForWarehouseVo
.
getWarehouseNo
()+
i18n
.
getMessage
(
request
,
"warehousedata"
)+
"
.zip"
);
File
[]
srcFiles
=
new
File
[
resultWarehouseNoAndTDLSNAndTimeVos
.
size
()];
for
(
int
a
=
0
;
a
<
resultWarehouseNoAndTDLSNAndTimeVos
.
size
();
a
++)
{
ResultWarehouseNoAndTDLSNAndTimeVo
resultWarehouseNoAndTDLSNAndTimeVo
=
resultWarehouseNoAndTDLSNAndTimeVos
.
get
(
a
);
...
...
@@ -118,22 +121,22 @@ public class DownloadController {
if
(
queryResults
.
getResults
().
get
(
0
).
getSeries
()==
null
){
continue
;
}
String
fileName
=
downloadForWarehouseVo
.
getWarehouseNo
()
+
"仓库温湿度观测记录表
-"
+
resultWarehouseNoAndTDLSNAndTimeVo
.
getTDLSN
();
String
fileName
=
downloadForWarehouseVo
.
getWarehouseNo
()
+
i18n
.
getMessage
(
request
,
"warehousedata"
)+
"
-"
+
resultWarehouseNoAndTDLSNAndTimeVo
.
getTDLSN
();
srcFiles
[
a
]
=
new
File
(
"./export/"
+
fileName
+
".xls"
)
;
List
<
DownloadWarehouseVo
>
downloadWarehouseVos
=
getWarehouseData
(
queryResults
);
List
<
DownloadWarehouseVo
>
downloadWarehouseVos
=
getWarehouseData
(
queryResults
,
downloadForWarehouseVo
.
getOffset
()
);
for
(
int
i
=
0
;
i
<
downloadWarehouseVos
.
size
();
i
++)
{
if
(
downloadWarehouseVos
.
get
(
i
).
getTemperature
()
>
resultWarehouseNoAndTDLSNAndTimeVos
.
get
(
a
).
getTemMax
()
||
downloadWarehouseVos
.
get
(
i
).
getTemperature
()
<
resultWarehouseNoAndTDLSNAndTimeVos
.
get
(
a
).
getTemMin
()
||
downloadWarehouseVos
.
get
(
i
).
getHumidity
()
>
resultWarehouseNoAndTDLSNAndTimeVos
.
get
(
a
).
getHumidityMax
()
||
downloadWarehouseVos
.
get
(
i
).
getHumidity
()
<
resultWarehouseNoAndTDLSNAndTimeVos
.
get
(
a
).
getHumidityMin
())
{
downloadWarehouseVos
.
get
(
i
).
setAlarm
(
"报警"
);
downloadWarehouseVos
.
get
(
i
).
setAlarm
(
i18n
.
getMessage
(
request
,
"Alarm"
)
);
}
else
{
downloadWarehouseVos
.
get
(
i
).
setAlarm
(
"正常"
);
downloadWarehouseVos
.
get
(
i
).
setAlarm
(
i18n
.
getMessage
(
request
,
"Nomal"
)
);
}
}
resultWarehouseNoAndTDLSNAndTimeVo
.
setDownloadWarehouseVos
(
downloadWarehouseVos
);
try
{
WarehouseExcel
warehouseExcel
=
new
WarehouseExcel
(
fileName
,
user
.
getUserName
(),
resultWarehouseNoAndTDLSNAndTimeVo
);
WarehouseExcel
warehouseExcel
=
new
WarehouseExcel
(
fileName
,
user
.
getUserName
(),
resultWarehouseNoAndTDLSNAndTimeVo
,
request
,
i18n
);
HSSFWorkbook
wb
=
warehouseExcel
.
downloadExcel
();
request
.
setCharacterEncoding
(
"utf-8"
);
response
.
setCharacterEncoding
(
"utf-8"
);
...
...
@@ -162,7 +165,11 @@ public class DownloadController {
String
md5Key
=
AliyunOSSClientUtil
.
uploadObject2OSS
(
ossClient
,
zipFile
);
if
(
md5Key
!=
null
)
{
for
(
int
a
=
0
;
a
<
srcFiles
.
length
;
a
++){
srcFiles
[
a
].
delete
();
if
(
srcFiles
[
a
]
==
null
){
continue
;
}
else
{
srcFiles
[
a
].
delete
();
}
}
zipFile
.
delete
();
fb
.
setCode
(
1
);
...
...
@@ -205,12 +212,12 @@ public class DownloadController {
return
dirFile
.
delete
();
}
public
List
<
DownloadWarehouseVo
>
getWarehouseData
(
QueryResult
queryResult
){
List
<
List
<
Object
>>
values
=
getValues
(
queryResult
);
public
List
<
DownloadWarehouseVo
>
getWarehouseData
(
QueryResult
queryResult
,
String
offset
){
List
<
List
<
Object
>>
values
=
DataUtil
.
getValues
(
queryResult
);
List
<
DownloadWarehouseVo
>
downloadWarehouseVos
=
new
ArrayList
<>();
for
(
List
<
Object
>
value:
values
){
DownloadWarehouseVo
downloadWarehouseVo
=
new
DownloadWarehouseVo
();
downloadWarehouseVo
.
setTime
(
parseTime
(
value
.
get
(
0
).
toString
()
));
downloadWarehouseVo
.
setTime
(
DataUtil
.
UTCToCST
(
String
.
valueOf
(
value
.
get
(
0
)),
offset
));
downloadWarehouseVo
.
setPressure
(
Float
.
parseFloat
(
value
.
get
(
1
).
toString
()));
downloadWarehouseVo
.
setTemperature
(
Float
.
parseFloat
(
value
.
get
(
2
).
toString
()));
downloadWarehouseVo
.
setHumidity
(
Float
.
parseFloat
(
value
.
get
(
3
).
toString
()));
...
...
@@ -219,43 +226,4 @@ public class DownloadController {
return
downloadWarehouseVos
;
}
//解析数据格式
public
List
<
List
<
Object
>>
getValues
(
QueryResult
queryResult
){
List
<
List
<
Object
>>
values
=
new
ArrayList
<>();
for
(
QueryResult
.
Result
result
:
queryResult
.
getResults
()){
if
(
result
.
getSeries
()
!=
null
){
for
(
QueryResult
.
Series
series
:
result
.
getSeries
())
{
if
(
series
!=
null
){
values
=
series
.
getValues
();
}
}
}
}
return
values
;
}
public
String
parseTime
(
String
time
){
String
dateResult
=
null
;
try
{
dateResult
=
dateToStamp
(
time
);
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
logger
.
info
(
e
.
toString
());
fb
.
setCode
(
0
);
fb
.
setMessage
(
"解析时间异常"
);
}
return
dateResult
;
}
//将utc时间转换成时间戳
public
String
dateToStamp
(
String
s
)
throws
ParseException
{
Date
date
=
null
;
if
(
s
.
length
()
!=
20
)
{
date
=
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
).
parse
(
s
);
}
else
{
date
=
new
SimpleDateFormat
(
"yyyy-MM-dd'T'HH:mm:ss'Z'"
).
parse
(
s
);
}
return
String
.
valueOf
(
date
.
getTime
());
}
}
src/main/resources/i18n/messages_en.properties
View file @
b1cbc7d8
...
...
@@ -295,4 +295,27 @@ wrongThemeColors=The format of the theme color is incorrect
comPictureDimension
=
Width*Height150*200
warePictureDimension
=
Width*Height150*120
truckPictureDimension
=
Width*Height90*60
data
=
Transport data
warehousedata
=
Warehouse temperature and humidity historic data
temMaxLimit
=
The upper temperature limit is 85
\u2103
temMinLimit
=
The lower temperature limit is -25
\u2103
humidityMaxLimit
=
The upper humidity limit is 100%
humidityMinLimit
=
The lower humidity limit is 0%
tiltLimit
=
The tilt therehold must be from 0
\u
00B0 to 180
\u
00B0 and must be a multiple of 30
\u
00B0
shockLimit
=
The shock therehold range is from 1.5g to 13.8g
downLoad
=
suitable
=
The suitable temperature range for the warehouse is {0}
\u2103
-{1}
\u2103
, and the humidity is {2}%-{3}%, otherwise need to regulate.
Alarm
=
Alarm
Nomal
=
Nomal
year
=
Year
recorder
=
Recorder
SamplingTime
=
Sampling time
Month
=
Month
Day
=
Day
Time
=
Time
Weather
=
Weather
Humidity
=
Humidity(%rH)
Temperature
=
Temperature(
\u2103
)
EnableAllert
=
Enable allert
NoData
=
No data for this time period
src/main/resources/i18n/messages_ja.properties
View file @
b1cbc7d8
...
...
@@ -190,3 +190,11 @@ min=\u5206
sec
=
\u
4E8C
\u
756A
\u
76EE
repeateAlias
=
\u
4F1A
\u
793E
\u
306E
\u7565\u
8A9E
\u
306F
\u
7E70
\u
308A
\u
8FD4
\u
305B
\u
307E
\u
305B
\u3093
alias
=
\u
4F1A
\u
793E
\u
306E
\u7565\u
8A9E
\u
306F
\u
7A7A
\u3067\u
306F
\u3042\u
308A
\u
307E
\u
305B
\u3093
data
=
\u
8F38
\u9001\u
30C7
\u
30FC
\u
30BF
warehousedata
=
\u5009\u
5EAB
\u
306E
\u
6E29
\u
5EA6
\u
304A
\u3088\u3073\u
6E7F
\u
5EA6
\u
306E
\u
89B3
\u
6E2C
\u
8A18
\u9332
shockLimit
=
\u
632F
\u
52D5
\u
306F1.5g
\u
304B
\u3089
13.8g
\u
306E
\u9593\u3067\u
306A
\u3051\u
308C
\u3070\u
306A
\u
308A
\u
307E
\u
305B
\u3093
tiltLimit
=
\u
52FE
\u
914D
\u
306F0
\u
00B0
\u
304B
\u3089
180
\u
00B0
\u
306E
\u9593\u3067\u
306A
\u3051\u
308C
\u3070\u
306A
\u3089\u
305A
\u3001
30
\u
306E
\u
500D
\u6570\u3067\u
306A
\u3051\u
308C
\u3070\u
306A
\u
308A
\u
307E
\u
305B
\u3093
humidityMinLimit
=
\u
6E7F
\u
5EA6
\u
306E
\u
4E0B
\u9650\u
306F0
\u
FF05
\u3092\u
4E0B
\u
56DE
\u
308B
\u3053\u3068\u
306F
\u3067\u
304D
\u
307E
\u
305B
\u3093\u3002
humidityMaxLimit
=
\u
6E7F
\u
5EA6
\u
306E
\u
4E0A
\u9650\u
306F100
\u
FF05
\u3092\u
8D85
\u3048\u
308B
\u3053\u3068\u
306F
\u3067\u
304D
\u
307E
\u
305B
\u3093\u3002
temMinLimit
=
\u
4E0B
\u9650\u
6E29
\u
5EA6
\u
306F-25
\u2103\u
4EE5
\u
4E0B
\u
306B
\u3067\u
304D
\u
307E
\u
305B
\u3093
temMaxLimit
=
\u
4E0A
\u9650\u
6E29
\u
5EA6
\u
306F85
\u2103\u3092\u
8D85
\u3048\u
308B
\u3053\u3068\u
306F
\u3067\u
304D
\u
307E
\u
305B
\u3093
src/main/resources/i18n/messages_zh_CN.properties
View file @
b1cbc7d8
...
...
@@ -3,13 +3,19 @@ alarmType = \u9884\u8B66\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A
alarmScene
=
\u9884\u
8B66
\u
573A
\u
666F
\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
wrongAlarmScene
=
\u
8BF7
\u9009\u
62E9
\u
6B63
\u
786E
\u7684\u9884\u
8B66
\u
573A
\u
666F
temMax
=
\u
6E29
\u
5EA6
\u
4E0A
\u9650\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
temMaxLimit
=
\u
6E29
\u
5EA6
\u
4E0A
\u9650\u
4E0D
\u
80FD
\u
8D85
\u
8FC785
\u2103
temMin
=
\u
6E29
\u
5EA6
\u
4E0B
\u9650\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
temMinLimit
=
\u
6E29
\u
5EA6
\u
4E0B
\u9650\u
4E0D
\u
80FD
\u
4F4E
\u
4E8E-25
\u2103
wrongTemp
=
\u
6E29
\u
5EA6
\u
4E0A
\u9650\u
4E0D
\u
80FD
\u
5C0F
\u
4E8E
\u
6E29
\u
5EA6
\u
4E0B
\u9650
humidityMax
=
\u
6E7F
\u
5EA6
\u
4E0A
\u9650\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
humidityMin
=
\u
6E7F
\u
5EA6
\u
4E0B
\u9650\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
humidityMaxLimit
=
\u
6E7F
\u
5EA6
\u
4E0A
\u9650\u
4E0D
\u
80FD
\u
8D85
\u
8FC7100%
humidityMinLimit
=
\u
6E7F
\u
5EA6
\u
4E0B
\u9650\u
4E0D
\u
80FD
\u
4F4E
\u
4E8E0%
wrongHumidity
=
\u
6E7F
\u
5EA6
\u
4E0A
\u9650\u
4E0D
\u
80FD
\u
5C0F
\u
4E8E
\u
6E7F
\u
5EA6
\u
4E0B
\u9650
tilt
=
\u
503E
\u
659C
\u
5EA6
\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
tiltLimit
=
\u
503E
\u
659C
\u
5EA6
\u
5FC5
\u
987B
\u5728
0
\u
00B0-180
\u
00B0
\u
4E4B
\u
95F4
\u
FF0C
\u
4E14
\u
5FC5
\u
987B
\u
662F30
\u7684\u
500D
\u6570
shock
=
\u9707\u
5EA6
\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
shockLimit
=
\u9707\u
52A8
\u
5FC5
\u
987B
\u5728
1.5g-13.8g
\u
4E4B
\u
95F4
alarmExist
=
\u
6DFB
\u
52A0
\u7684\u9884\u
8B66
\u
7C7B
\u
578B
\u5728\u
8BE5
\u
573A
\u
666F
\u
4E2D
\u
5DF2
\u
5B58
\u5728
addSuccess
=
\u
6DFB
\u
52A0
\u9884\u
8B66
\u
4FE1
\u
606F
\u6210\u
529F
addFailure
=
\u
6DFB
\u
52A0
\u9884\u
8B66
\u
4FE1
\u
606F
\u5931\u
8D25
...
...
@@ -297,6 +303,25 @@ hour =\u5C0F\u65F6
min
=
\u5206\u
949F
sec
=
\u
79D2
data
=
\u
8FD0
\u
8F93
\u6570\u
636E
timeparse
=
\u
65F6
\u
95F4
\u
89E3
\u6790\u
5F02
\u
5E38
warehousedata
=
\u
4ED3
\u
5E93
\u
6E29
\u
6E7F
\u
5EA6
\u
89C2
\u
6D4B
\u
8BB0
\u
5F55
Alarm
=
\u
62A5
\u
8B66
Nomal
=
\u
6B63
\u
5E38
year
=
\u
5E74
\u
5EA6
recorder
=
\u
8BB0
\u
5F55
\u
4EBA
SamplingTime
=
\u
91C7
\u6837\u
65F6
\u
95F4
Month
=
\u6708
Day
=
\u
65E5
Time
=
\u
65F6
\u5206
Weather
=
\u5929\u
6C14
Humidity
=
\u
6E7F
\u
5EA6(%rH)
Temperature
=
\u
6E29
\u
5EA6(
\u2103
)
EnableAllert
=
\u
662F
\u5426\u9884\u
8B66
suitable
=
\u
5E93
\u
623F
\u9002\u
5B9C
\u
6E29
\u
5EA6
\u
4E3A{0}
\u2103
-{1}
\u2103\u
FF0C
\u
6E7F
\u
5EA6
\u
4FDD
\u6301
{2}%-{3}%,
\u
8D85
\u6807\u8981\u
505A
\u
5FC5
\u8981\u
8C03
\u8282\u3002
NoData
=
\u
8BE5
\u
65F6
\u
95F4
\u
6BB5
\u
6CA1
\u6709\u6570\u
636E
DataOverview
=
\u6570\u
636E
\u6982\u
89C8
TransportationState
=
\u
8FD0
\u
8F93
\u
72B6
\u6001
SystemSetup
=
\u
7CFB
\u
7EDF
\u
8BBE
\u
7F6E
...
...
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