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
22f43585
Commit
22f43585
authored
May 27, 2019
by
zhuangzhuang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
5.27-修改中文乱码问题
parent
eee8b1ae
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
963 additions
and
344 deletions
+963
-344
build.gradle
build.gradle
+2
-2
MqttListener.java
src/main/java/com/example/tdl/mqtt/MqttListener.java
+6
-12
AlarmLogForABBExcelUtil.java
...in/java/com/example/tdl/util/AlarmLogForABBExcelUtil.java
+0
-1
CSVUtils.java
src/main/java/com/example/tdl/util/CSVUtils.java
+95
-0
MapUtils.java
src/main/java/com/example/tdl/util/MapUtils.java
+23
-10
AlarmLogABBController.java
src/main/java/com/example/tdl/web/AlarmLogABBController.java
+77
-35
DataController.java
src/main/java/com/example/tdl/web/DataController.java
+749
-276
application-dev.properties
src/main/resources/application-dev.properties
+3
-3
application.properties
src/main/resources/application.properties
+8
-5
No files found.
build.gradle
View file @
22f43585
...
...
@@ -36,8 +36,8 @@ dependencies {
compile
(
'org.apache.shiro:shiro-ehcache:1.2.4'
)
compile
(
'com.google.code.gson:gson:2.6.2'
)
compile
(
'com.mangofactory:swagger-springmvc:0.9.4'
)
compile
(
'io.springfox:springfox-swagger2:2.
2.2
'
)
compile
(
'io.springfox:springfox-swagger-ui:2.
2.2
'
)
compile
(
'io.springfox:springfox-swagger2:2.
8.0
'
)
compile
(
'io.springfox:springfox-swagger-ui:2.
8.0
'
)
compile
(
'org.apache.commons:commons-lang3:3.3.2'
)
compile
(
'org.apache.commons:commons-io:1.3.2'
)
compile
(
'commons-codec:commons-codec:1.6'
)
...
...
src/main/java/com/example/tdl/mqtt/MqttListener.java
View file @
22f43585
...
...
@@ -191,12 +191,6 @@ public class MqttListener implements MqttCallback {
mqttconfig
.
getUsername
(),
mqttconfig
.
getPassword
(),
mqttconfig
.
getQos
(),
mqttconfig
.
getCacrt
(),
mqttconfig
.
getClientkey
(),
mqttconfig
.
getClientcrt
(),
mqttconfig
.
getClientpwd
());
result
=
configthreadPool
.
submit
(
gcconfig
);
// while (result.isDone())
// {
// String respcmd = result.get();
// }
}
catch
(
JsonSyntaxException
e
)
{
e
.
printStackTrace
();
System
.
out
.
println
(
"mqttAsyncClient: message "
+
Message
+
" received syntax error."
);
...
...
@@ -250,9 +244,9 @@ public class MqttListener implements MqttCallback {
return
3
;
//重发
}
if
(
compare
(
configCMDVo
.
getDevList
(),
checkInVo
.
getDevList
())
&&
checkInVo
.
getGprsPeriod
()
.
equals
(
configCMDVo
.
getGprsPeriod
()
)
&&
checkInVo
.
getGpsPeriod
()
.
equals
(
configCMDVo
.
getGpsPeriod
()
)
&&
checkInVo
.
getMode
()
.
equals
(
configCMDVo
.
getMode
()
)
&&
checkInVo
.
getGprsPeriod
()
==
configCMDVo
.
getGprsPeriod
(
)
&&
checkInVo
.
getGpsPeriod
()
==
configCMDVo
.
getGpsPeriod
(
)
&&
checkInVo
.
getMode
()
==
configCMDVo
.
getMode
(
)
&&
compare
(
configCMDVo
.
getTempL
(),
checkInVo
.
getTempL
())
&&
compare
(
configCMDVo
.
getTempH
(),
checkInVo
.
getTempH
())
&&
compare
(
configCMDVo
.
getHumiL
(),
checkInVo
.
getHumiL
())
...
...
@@ -275,9 +269,9 @@ public class MqttListener implements MqttCallback {
}
//判断两者的devList是否一致
if
(
compare
(
configCMDVo
.
getDevList
(),
checkInVo
.
getDevList
())
&&
checkInVo
.
getGprsPeriod
()
.
equals
(
configCMDVo
.
getGprsPeriod
())
&&
checkInVo
.
getGpsPeriod
()
.
equals
(
configCMDVo
.
getGpsPeriod
())
&&
checkInVo
.
getMode
()
.
equals
(
configCMDVo
.
getMode
()))
{
&&
checkInVo
.
getGprsPeriod
()
==
(
configCMDVo
.
getGprsPeriod
())
&&
checkInVo
.
getGpsPeriod
()
==
(
configCMDVo
.
getGpsPeriod
())
&&
checkInVo
.
getMode
()
==
(
configCMDVo
.
getMode
()))
{
//一致
return
0
;
//休眠
}
else
{
...
...
src/main/java/com/example/tdl/util/AlarmLogForABBExcelUtil.java
View file @
22f43585
...
...
@@ -5,7 +5,6 @@ import org.apache.poi.hssf.usermodel.*;
import
org.apache.poi.hssf.util.HSSFColor
;
import
org.apache.poi.ss.util.CellRangeAddress
;
import
javax.servlet.http.HttpServletResponse
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Date
;
...
...
src/main/java/com/example/tdl/util/CSVUtils.java
0 → 100644
View file @
22f43585
package
com
.
example
.
tdl
.
util
;
import
java.io.BufferedWriter
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.OutputStreamWriter
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
public
class
CSVUtils
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
CSVUtils
.
class
);
public
static
File
createCSVFile
(
List
<
Object
>
head
,
List
<
List
<
Object
>>
dataList
,
String
outPutPath
,
String
filename
)
{
File
csvFile
=
null
;
BufferedWriter
csvWtriter
=
null
;
try
{
csvFile
=
new
File
(
outPutPath
+
File
.
separator
+
filename
+
".csv"
);
File
parent
=
csvFile
.
getParentFile
();
if
(
parent
!=
null
&&
!
parent
.
exists
()){
parent
.
mkdirs
();
}
csvFile
.
createNewFile
();
FileOutputStream
fos
=
new
FileOutputStream
(
csvFile
);
// 写入bom头
byte
[]
uft8bom
={(
byte
)
0xef
,(
byte
)
0xbb
,(
byte
)
0xbf
};
//String bOM = new String(new byte[] { (byte) 0xEF, (byte) 0xBB, (byte) 0xBF });
fos
.
write
(
uft8bom
);
// GB2312使正确读取分隔符","
csvWtriter
=
new
BufferedWriter
(
new
OutputStreamWriter
(
fos
,
"UTF-8"
));
// 写入文件头部
writeRow
(
head
,
csvWtriter
);
// 写入文件内容
for
(
List
<
Object
>
row
:
dataList
)
{
writeRow
(
row
,
csvWtriter
);
}
csvWtriter
.
flush
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
csvWtriter
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
return
csvFile
;
}
/* *
* 写一行数据方法
* @param row
* @param csvWriter
* @throws IOException*/
private
static
void
writeRow
(
List
<
Object
>
row
,
BufferedWriter
csvWriter
)
throws
IOException
{
// 写入文件头部
for
(
Object
data
:
row
)
{
StringBuffer
sb
=
new
StringBuffer
();
String
rowStr
=
sb
.
append
(
"\""
).
append
(
data
).
append
(
"\","
).
toString
();
csvWriter
.
write
(
rowStr
);
}
csvWriter
.
newLine
();
}
/**
* 测试数据
*
* @param args
*/
@SuppressWarnings
({
"rawtypes"
,
"unchecked"
})
public
static
void
main
(
String
[]
args
)
{
List
<
Object
>
head
=
new
ArrayList
<
Object
>(){{
add
(
"时间"
);
add
(
"最大值"
);
add
(
"最小值"
);
add
(
"平均值"
);
}};
List
<
List
<
Object
>>
dataList
=
new
ArrayList
<>();
createCSVFile
(
head
,
dataList
,
"E:/"
,
"小时粗糙度"
);
}
}
src/main/java/com/example/tdl/util/MapUtils.java
View file @
22f43585
...
...
@@ -32,30 +32,43 @@ public class MapUtils {
return
s
;
}
public
static
double
getTransSpeed
(
double
lat1
,
double
lng1
,
double
lat2
,
double
lng2
,
Long
time
){
if
(
time
==
0
){
return
0
d
;
}
double
s
=
getDistance
(
lat1
,
lng1
,
lat2
,
lng2
);
double
speed
=
(
double
)
s
/
time
;
System
.
out
.
println
(
"lng:"
+
lng1
+
" ----lat:"
+
lat1
+
" ----speed:"
+
speed
+
" ---time :"
+
time
+
" -----distance:"
+
s
);
if
(
s
<
10000
){
//计算速度
public
static
double
getSpeed
(
double
lat1
,
double
lng1
,
double
lat2
,
double
lng2
,
Long
time
,
Float
sppeed
){
if
(
speed
>
60
){
return
0
;
}
return
s
/
time
;
}
else
{
return
s
/
time
;
}
}
//计算速度
public
static
double
getSpeed
(
double
lat1
,
double
lng1
,
double
lat2
,
double
lng2
,
Long
time
,
Float
sppeed
){
if
(
time
==
0
){
return
0
d
;
}
double
s
=
getDistance
(
lat1
,
lng1
,
lat2
,
lng2
);
double
speed
=
(
double
)
s
/
time
;
// if((lng1+"") .contains("110.")){
// System.out.println("lng:" + lng1 +" ----lat:" +lat1 +" ----speed:" + speed +" ---time :" +time +" -----distance:"+s);
// }
// System.out.println("lng:" + lng1 +" ----lat:" +lat1 +" ----speed:" + speed +" ---time :" +time +" -----distance:"+s);
System
.
out
.
println
(
"lng:"
+
lng1
+
" ----lat:"
+
lat1
+
" ----speed:"
+
speed
+
" ---time :"
+
time
+
" -----distance:"
+
s
);
if
(
s
<
1000
||
s
>
10000
){
//计算速度
if
(
speed
>
250
||
speed
<
sppeed
){
// if((lng1+"") .contains("110.")){
// System.out.println("lng:" + lng1 +" ----lat:" +lat1 +" ----speed:" + speed +" ---time :" +time +" -----distance:"+s);
// }
if
(
speed
>
60
||
speed
<
sppeed
){
return
0
;
}
return
s
/
time
;
}
else
{
if
(
speed
>
60
||
speed
<
sppeed
){
return
0
;
}
return
s
/
time
;
}
...
...
src/main/java/com/example/tdl/web/AlarmLogABBController.java
View file @
22f43585
...
...
@@ -8,6 +8,7 @@ import com.example.tdl.domain.vo.*;
import
com.example.tdl.service.*
;
import
com.example.tdl.service.redis.TokenRedisService
;
import
com.example.tdl.util.AliyunOSSClientUtil
;
import
com.example.tdl.util.CSVUtils
;
import
com.example.tdl.util.ZipCompressUtil
;
import
com.google.gson.Gson
;
import
io.swagger.annotations.ApiImplicitParam
;
...
...
@@ -25,6 +26,7 @@ import javax.servlet.http.HttpServletResponse;
import
java.io.File
;
import
java.nio.charset.Charset
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -259,30 +261,38 @@ public class AlarmLogABBController {
alarmTermABBVo
.
setCompanyNo
(
user
.
getCompanyNo
());
List
<
ResultAlarmLogABBVo
>
resultAlarmLogVos
=
alarmLogABBService
.
getByTermForDownload
(
alarmTermABBVo
);
if
(
resultAlarmLogVos
.
size
()>
0
){
try
{
String
address
=
"./export/"
;
String
fileName
=
"报警日志数据-"
+
System
.
currentTimeMillis
();
CsvWriter
csvWriter
=
new
CsvWriter
(
address
+
fileName
+
".csv"
,
','
,
Charset
.
forName
(
"GB2312"
));
// 创建CSV写对象 例如:CsvWriter(文件路径,分隔符,编码格式);
String
[]
rowsName
={
"运输编号"
,
"货物编号"
,
"传感器序列号"
,
"描述"
,
"报警数据"
,
"报警时间"
,
"报警参数"
};
csvWriter
.
writeRecord
(
rowsName
);
List
<
Object
>
head
=
new
ArrayList
<
Object
>(){{
add
(
"运输编号"
);
add
(
"货物编号"
);
add
(
"传感器序列号"
);
add
(
"描述"
);
add
(
"报警数据"
);
add
(
"报警时间"
);
add
(
"报警参数"
);
}};
List
<
List
<
Object
>>
dataList
=
new
ArrayList
<>();
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
for
(
int
i
=
0
;
i
<
resultAlarmLogVos
.
size
();
++
i
)
{
String
[]
objs
=
new
String
[
rowsName
.
length
]
;
objs
[
0
]
=
String
.
valueOf
(
resultAlarmLogVos
.
get
(
i
).
getTransportationNo
());
objs
[
1
]
=
String
.
valueOf
(
resultAlarmLogVos
.
get
(
i
).
getCargoNo
());
objs
[
2
]
=
String
.
valueOf
(
resultAlarmLogVos
.
get
(
i
).
getTDLSN
());
objs
[
3
]
=
String
.
valueOf
(
resultAlarmLogVos
.
get
(
i
).
getDescription
());
objs
[
4
]
=
String
.
valueOf
(
resultAlarmLogVos
.
get
(
i
).
getData
());
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
//这个是你要转成后的时间的格式
objs
[
5
]
=
String
.
valueOf
(
sdf
.
format
(
new
Date
(
resultAlarmLogVos
.
get
(
i
).
getAlarmTime
())));
objs
[
6
]
=
String
.
valueOf
(
resultAlarmLogVos
.
get
(
i
).
getClassify
());
csvWriter
.
writeRecord
(
obj
s
);
List
<
Object
>
values
=
new
ArrayList
<>()
;
values
.
add
(
resultAlarmLogVos
.
get
(
i
).
getTransportationNo
());
values
.
add
(
resultAlarmLogVos
.
get
(
i
).
getCargoNo
());
values
.
add
(
resultAlarmLogVos
.
get
(
i
).
getTDLSN
());
values
.
add
(
resultAlarmLogVos
.
get
(
i
).
getDescription
());
values
.
add
(
resultAlarmLogVos
.
get
(
i
).
getData
());
//这个是你要转成后的时间的格式
values
.
add
(
sdf
.
format
(
new
Date
(
resultAlarmLogVos
.
get
(
i
).
getAlarmTime
())));
values
.
add
(
resultAlarmLogVos
.
get
(
i
).
getClassify
());
dataList
.
add
(
value
s
);
}
csvWriter
.
flush
();
csvWriter
.
close
();
String
fileName
=
"报警日志数据-"
+
System
.
currentTimeMillis
();
String
address
=
"./export/"
;
CSVUtils
.
createCSVFile
(
head
,
dataList
,
address
,
fileName
);
ZipCompressUtil
zipCom
=
new
ZipCompressUtil
(
address
+
fileName
+
".zip"
,
address
+
fileName
+
".csv"
);
try
{
zipCom
.
zip
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
OSSClient
ossClient
=
AliyunOSSClientUtil
.
getOSSClient
();
String
md5Key
=
AliyunOSSClientUtil
.
uploadObject2OSS
(
ossClient
,
new
File
(
address
+
fileName
+
".zip"
));
if
(
md5Key
!=
null
)
{
...
...
@@ -294,11 +304,43 @@ public class AlarmLogABBController {
fb
.
setCode
(
0
);
fb
.
setMessage
(
"上传失败"
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
fb
.
setCode
(
0
);
fb
.
setMessage
(
"下载失败"
);
}
// try {
// CsvWriter csvWriter = new CsvWriter(address + fileName+".csv", ',', Charset.forName("GB2312"));
// // 创建CSV写对象 例如:CsvWriter(文件路径,分隔符,编码格式);
// String[] rowsName={"运输编号","货物编号","传感器序列号","描述","报警数据","报警时间","报警参数"};
//
// csvWriter.writeRecord(rowsName);
// for (int i = 0; i < resultAlarmLogVos.size(); ++i) {
// String[] objs = new String[rowsName.length];
// objs[0] = String.valueOf(resultAlarmLogVos.get(i).getTransportationNo());
// objs[1] = String.valueOf(resultAlarmLogVos.get(i).getCargoNo());
// objs[2] = String.valueOf(resultAlarmLogVos.get(i).getTDLSN());
// objs[3] = String.valueOf(resultAlarmLogVos.get(i).getDescription());
// objs[4] = String.valueOf(resultAlarmLogVos.get(i).getData());
// objs[5] = String.valueOf(sdf.format(new Date(resultAlarmLogVos.get(i).getAlarmTime())));
// objs[6] = String.valueOf(resultAlarmLogVos.get(i).getClassify());
// csvWriter.writeRecord(objs);
// }
// csvWriter.flush();
// csvWriter.close();
// ZipCompressUtil zipCom = new ZipCompressUtil(address + fileName+".zip", address + fileName+".csv");
// zipCom.zip();
// OSSClient ossClient = AliyunOSSClientUtil.getOSSClient();
// String md5Key = AliyunOSSClientUtil.uploadObject2OSS(ossClient, new File(address + fileName+ ".zip"));
// if (md5Key != null) {
// fb.setCode(1);
// fb.setMessage("https://tdlcloud.oss-cn-shanghai.aliyuncs.com/abbAlarm/" + fileName+ ".zip");
// new File(address + fileName).delete();
// return gson.toJson(fb);
// } else {
// fb.setCode(0);
// fb.setMessage("上传失败");
// }
// } catch (Exception e) {
// e.printStackTrace();
// fb.setCode(0);
// fb.setMessage("下载失败");
// }
}
else
{
fb
.
setCode
(
0
);
fb
.
setMessage
(
"没有数据可以下载"
);
...
...
src/main/java/com/example/tdl/web/DataController.java
View file @
22f43585
This diff is collapsed.
Click to expand it.
src/main/resources/application-dev.properties
View file @
22f43585
spring.datasource.url
=
jdbc:mysql://1
92.168
.1.200:3306/tdlcloud?useUnicode=true&characterEncoding=utf-8&useSSL=false
spring.datasource.url
=
jdbc:mysql://1
72.16
.1.200:3306/tdlcloud?useUnicode=true&characterEncoding=utf-8&useSSL=false
spring.redis.host
=
1
92.168
.1.200
spring.redis.host
=
1
72.16
.1.200
server.port
=
8092
tdl.influxdb.host
=
http://1
92.168
.1.200:8086
tdl.influxdb.host
=
http://1
72.16
.1.200:8086
src/main/resources/application.properties
View file @
22f43585
#spring.datasource.url=jdbc:mysql://47.97.184.225:3306/tdlcloud?useUnicode=true&characterEncoding=utf-8&useSSL=false
spring.datasource.url
=
jdbc:mysql://47.110.153.44:3306/tdlcloud?useUnicode=true&characterEncoding=utf-8&useSSL=false
#spring.datasource.url=jdbc:mysql://47.110.153.44:3306/tdlcloud?useUnicode=true&characterEncoding=utf-8&useSSL=false
spring.datasource.url
=
jdbc:mysql://172.16.1.13: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
...
...
@@ -24,7 +25,7 @@ spring.messages.cache-seconds= 3600
spring.messages.encoding
=
UTF-8
tdl.redis.host
=
1
27.0.0.1
tdl.redis.host
=
1
72.16.1.24
tdl.redis.index
=
0
tdl.redis.port
=
6379
tdl.redis.password
=
...
...
@@ -50,13 +51,15 @@ tdl.mqtt.timeout = 20
tdl.mqtt.cacrt
=
ca.crt
tdl.mqtt.clientkey
=
witcd.pem
tdl.mqtt.clientcrt
=
witcd.crt
tdl.mqtt.clientpwd
=
# InfluxDB
spring.influxdb.username
=
admin
spring.influxdb.password
=
37774020
#spring.influxdb.url=http://47.97.184.225:8086
spring.influxdb.url
=
http://47.110.153.44:8086
#spring.influxdb.url=http://47.110.153.44:8086
spring.influxdb.url
=
http://172.16.1.24:8086
spring.influxdb.database
=
original
spring.influxdb.retentionPolicy
=
tdl_policy
spring.influxdb.connent-timeout
=
10
...
...
@@ -65,8 +68,8 @@ spring.influxdb.write-timeout=10
spring.influxdb.gzip
=
true
tdl.core.add
=
http://172.16.1.
16
:8079/witium/addMount
tdl.core.delete
=
http://172.16.
1.16
:8079/witium/delMount
tdl.core.add
=
http://172.16.1.
52
:8079/witium/addMount
tdl.core.delete
=
http://172.16.
52
:8079/witium/delMount
mqtt.userName
=
ugen
mqtt.password
=
ugen
...
...
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