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
f4a76c00
Commit
f4a76c00
authored
Mar 19, 2018
by
zhuangzhuang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
3.19--tdl与gateway的绑定、解绑接口;获取历史数据以及实时数据的接口,修改角色的返回值
parent
5a4afdd8
Hide whitespace changes
Inline
Side-by-side
Showing
52 changed files
with
1594 additions
and
436 deletions
+1594
-436
InfluxDBConfiguration.java
...in/java/com/example/tdl/config/InfluxDBConfiguration.java
+45
-0
Influxdbconfig.java
src/main/java/com/example/tdl/config/Influxdbconfig.java
+0
-55
RedisConfig.java
src/main/java/com/example/tdl/config/RedisConfig.java
+12
-5
AddAlarmLogVo.java
src/main/java/com/example/tdl/domain/vo/AddAlarmLogVo.java
+7
-7
BindingVo.java
src/main/java/com/example/tdl/domain/vo/BindingVo.java
+64
-0
ConfigCMDVo.java
src/main/java/com/example/tdl/domain/vo/ConfigCMDVo.java
+20
-0
DeviceDataVo.java
src/main/java/com/example/tdl/domain/vo/DeviceDataVo.java
+64
-0
Humidity.java
src/main/java/com/example/tdl/domain/vo/Humidity.java
+26
-0
HumidityDataVo.java
src/main/java/com/example/tdl/domain/vo/HumidityDataVo.java
+24
-0
LiveDataVo.java
src/main/java/com/example/tdl/domain/vo/LiveDataVo.java
+26
-0
LocationDataVo.java
src/main/java/com/example/tdl/domain/vo/LocationDataVo.java
+44
-0
LocationMessageVo.java
...ain/java/com/example/tdl/domain/vo/LocationMessageVo.java
+126
-0
LocationVo.java
src/main/java/com/example/tdl/domain/vo/LocationVo.java
+45
-0
NumberVo.java
src/main/java/com/example/tdl/domain/vo/NumberVo.java
+24
-0
ProbesVo.java
src/main/java/com/example/tdl/domain/vo/ProbesVo.java
+84
-0
RoleNameVo.java
src/main/java/com/example/tdl/domain/vo/RoleNameVo.java
+14
-0
ShockEnergy.java
src/main/java/com/example/tdl/domain/vo/ShockEnergy.java
+26
-0
ShockEnergyVo.java
src/main/java/com/example/tdl/domain/vo/ShockEnergyVo.java
+24
-0
Temperature.java
src/main/java/com/example/tdl/domain/vo/Temperature.java
+26
-0
TemperatureDataVo.java
...ain/java/com/example/tdl/domain/vo/TemperatureDataVo.java
+24
-0
TiltAngle.java
src/main/java/com/example/tdl/domain/vo/TiltAngle.java
+26
-0
TiltAngleVo.java
src/main/java/com/example/tdl/domain/vo/TiltAngleVo.java
+23
-0
AlarmLog.java
src/main/java/com/example/tdl/entity/AlarmLog.java
+5
-5
PermissionInterceptor.java
...va/com/example/tdl/interceptor/PermissionInterceptor.java
+0
-2
AlarmLogMapper.java
src/main/java/com/example/tdl/mapper/AlarmLogMapper.java
+1
-0
CircuitMapper.java
src/main/java/com/example/tdl/mapper/CircuitMapper.java
+3
-4
ConfigMapper.java
src/main/java/com/example/tdl/mapper/ConfigMapper.java
+7
-2
ProbesMapper.java
src/main/java/com/example/tdl/mapper/ProbesMapper.java
+3
-0
RoleMapper.java
src/main/java/com/example/tdl/mapper/RoleMapper.java
+2
-1
TDLDeviceMapper.java
src/main/java/com/example/tdl/mapper/TDLDeviceMapper.java
+3
-0
AlarmLogService.java
src/main/java/com/example/tdl/service/AlarmLogService.java
+5
-1
CircuitService.java
src/main/java/com/example/tdl/service/CircuitService.java
+5
-4
ConfigService.java
src/main/java/com/example/tdl/service/ConfigService.java
+13
-3
InfluxDBService.java
src/main/java/com/example/tdl/service/InfluxDBService.java
+0
-244
ProbesService.java
src/main/java/com/example/tdl/service/ProbesService.java
+5
-0
RoleService.java
src/main/java/com/example/tdl/service/RoleService.java
+2
-1
TDLDeviceService.java
src/main/java/com/example/tdl/service/TDLDeviceService.java
+4
-0
RealRedisService.java
.../java/com/example/tdl/service/redis/RealRedisService.java
+16
-0
RedisService.java
...main/java/com/example/tdl/service/redis/RedisService.java
+3
-55
AlarmLogController.java
src/main/java/com/example/tdl/web/AlarmLogController.java
+4
-4
DataController.java
src/main/java/com/example/tdl/web/DataController.java
+489
-6
EquipmentBindingController.java
.../java/com/example/tdl/web/EquipmentBindingController.java
+152
-0
GatewayController.java
src/main/java/com/example/tdl/web/GatewayController.java
+3
-0
HomePageController.java
src/main/java/com/example/tdl/web/HomePageController.java
+5
-5
TDLDeviceController.java
src/main/java/com/example/tdl/web/TDLDeviceController.java
+0
-7
application.properties
src/main/resources/application.properties
+10
-5
AlarmLogMapper.xml
src/main/resources/mapper/AlarmLogMapper.xml
+1
-1
CircuitMapper.xml
src/main/resources/mapper/CircuitMapper.xml
+7
-0
ConfigMapper.xml
src/main/resources/mapper/ConfigMapper.xml
+54
-18
ProbesMapper.xml
src/main/resources/mapper/ProbesMapper.xml
+13
-0
RoleMapper.xml
src/main/resources/mapper/RoleMapper.xml
+1
-1
TDLDeviceMapper.xml
src/main/resources/mapper/TDLDeviceMapper.xml
+4
-0
No files found.
src/main/java/com/example/tdl/config/InfluxDBConfiguration.java
0 → 100644
View file @
f4a76c00
package
com
.
example
.
tdl
.
config
;
import
org.influxdb.dto.Point
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.influxdb.DefaultInfluxDBTemplate
;
import
org.springframework.data.influxdb.InfluxDBConnectionFactory
;
import
org.springframework.data.influxdb.InfluxDBProperties
;
import
org.springframework.data.influxdb.InfluxDBTemplate
;
import
org.springframework.data.influxdb.converter.PointConverter
;
@Configuration
@EnableConfigurationProperties
(
value
=
InfluxDBProperties
.
class
)
public
class
InfluxDBConfiguration
{
@Bean
public
InfluxDBConnectionFactory
connectionFactory
(
final
InfluxDBProperties
properties
)
{
return
new
InfluxDBConnectionFactory
(
properties
);
}
@Bean
public
InfluxDBTemplate
<
Point
>
influxDBTemplate
(
final
InfluxDBConnectionFactory
connectionFactory
)
{
/*
* You can use your own 'PointCollectionConverter' implementation, e.g. in case
* you want to use your own custom measurement object.
*/
return
new
InfluxDBTemplate
<>(
connectionFactory
,
new
PointConverter
());
}
@Bean
public
DefaultInfluxDBTemplate
defaultTemplate
(
final
InfluxDBConnectionFactory
connectionFactory
)
{
/* * If you are just dealing with Point objects from 'influxdb-java' you could
* also use an instance of class DefaultInfluxDBTemplate.*/
return
new
DefaultInfluxDBTemplate
(
connectionFactory
);
}
}
src/main/java/com/example/tdl/config/Influxdbconfig.java
deleted
100644 → 0
View file @
5a4afdd8
package
com
.
example
.
tdl
.
config
;
import
org.influxdb.InfluxDB
;
import
org.influxdb.InfluxDBFactory
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
@Configuration
@ConfigurationProperties
(
prefix
=
"tdl.influxdb"
)
public
class
Influxdbconfig
{
private
String
user
;
private
String
password
;
private
String
host
;
private
String
database
;
public
String
getUser
()
{
return
user
;
}
public
void
setUser
(
String
user
)
{
this
.
user
=
user
;
}
public
String
getPassword
()
{
return
password
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
public
String
getHost
()
{
return
host
;
}
public
void
setHost
(
String
host
)
{
this
.
host
=
host
;
}
public
String
getDatabase
()
{
return
database
;
}
public
void
setDatabase
(
String
database
)
{
this
.
database
=
database
;
}
@Bean
public
InfluxDB
influxDB
()
{
return
InfluxDBFactory
.
connect
(
host
,
user
,
password
);
}
}
src/main/java/com/example/tdl/config/RedisConfig.java
View file @
f4a76c00
...
@@ -202,19 +202,26 @@ public class RedisConfig extends CachingConfigurerSupport{
...
@@ -202,19 +202,26 @@ public class RedisConfig extends CachingConfigurerSupport{
* @param
* @param
* @return
* @return
*/
*/
//@SuppressWarnings({"rawtypes", "unchecked"})
@Bean
@Bean
public
RedisTemplate
<
String
,
String
>
tokenR
edisTemplate
()
{
public
RedisTemplate
<
String
,
String
>
r
edisTemplate
()
{
StringRedisTemplate
template
=
new
StringRedisTemplate
(
redisConnectionFactory
(
15
));
StringRedisTemplate
template
=
new
StringRedisTemplate
(
redisConnectionFactory
(
0
));
JsonRedisSerializer
(
template
,
fals
e
);
JsonRedisSerializer
(
template
,
tru
e
);
return
template
;
return
template
;
}
}
@Bean
@Bean
public
RedisTemplate
<
String
,
String
>
redisTemplate
()
{
public
RedisTemplate
<
String
,
String
>
re
alRe
disTemplate
()
{
StringRedisTemplate
template
=
new
StringRedisTemplate
(
redisConnectionFactory
(
1
));
StringRedisTemplate
template
=
new
StringRedisTemplate
(
redisConnectionFactory
(
1
));
JsonRedisSerializer
(
template
,
true
);
JsonRedisSerializer
(
template
,
true
);
return
template
;
return
template
;
}
}
@Bean
public
RedisTemplate
<
String
,
String
>
tokenRedisTemplate
()
{
StringRedisTemplate
template
=
new
StringRedisTemplate
(
redisConnectionFactory
(
15
));
JsonRedisSerializer
(
template
,
false
);
return
template
;
}
}
}
src/main/java/com/example/tdl/domain/vo/AddAlarmLogVo.java
View file @
f4a76c00
...
@@ -2,7 +2,7 @@ package com.example.tdl.domain.vo;
...
@@ -2,7 +2,7 @@ package com.example.tdl.domain.vo;
public
class
AddAlarmLogVo
{
public
class
AddAlarmLogVo
{
private
String
routeNumber
;
private
String
transportationNo
;
private
String
routeName
;
private
String
routeName
;
...
@@ -15,20 +15,20 @@ public class AddAlarmLogVo {
...
@@ -15,20 +15,20 @@ public class AddAlarmLogVo {
public
AddAlarmLogVo
()
{
public
AddAlarmLogVo
()
{
}
}
public
AddAlarmLogVo
(
String
routeNumber
,
String
routeName
,
String
description
,
Float
data
,
Long
alarmTime
)
{
public
AddAlarmLogVo
(
String
transportationNo
,
String
routeName
,
String
description
,
Float
data
,
Long
alarmTime
)
{
this
.
routeNumber
=
routeNumber
;
this
.
transportationNo
=
transportationNo
;
this
.
routeName
=
routeName
;
this
.
routeName
=
routeName
;
this
.
description
=
description
;
this
.
description
=
description
;
this
.
data
=
data
;
this
.
data
=
data
;
this
.
alarmTime
=
alarmTime
;
this
.
alarmTime
=
alarmTime
;
}
}
public
String
get
RouteNumber
()
{
public
String
get
TransportationNo
()
{
return
routeNumber
;
return
transportationNo
;
}
}
public
void
set
RouteNumber
(
String
routeNumber
)
{
public
void
set
TransportationNo
(
String
transportationNo
)
{
this
.
routeNumber
=
routeNumber
;
this
.
transportationNo
=
transportationNo
;
}
}
public
String
getRouteName
()
{
public
String
getRouteName
()
{
...
...
src/main/java/com/example/tdl/domain/vo/BindingVo.java
0 → 100644
View file @
f4a76c00
package
com
.
example
.
tdl
.
domain
.
vo
;
public
class
BindingVo
{
private
String
SN
;
private
String
type
;
private
Integer
mode
;
private
String
TDLSN
;
private
String
transportationNo
;
private
String
warehouseNo
;
public
String
getSN
()
{
return
SN
;
}
public
void
setSN
(
String
SN
)
{
this
.
SN
=
SN
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
Integer
getMode
()
{
return
mode
;
}
public
void
setMode
(
Integer
mode
)
{
this
.
mode
=
mode
;
}
public
String
getTDLSN
()
{
return
TDLSN
;
}
public
void
setTDLSN
(
String
TDLSN
)
{
this
.
TDLSN
=
TDLSN
;
}
public
String
getTransportationNo
()
{
return
transportationNo
;
}
public
void
setTransportationNo
(
String
transportationNo
)
{
this
.
transportationNo
=
transportationNo
;
}
public
String
getWarehouseNo
()
{
return
warehouseNo
;
}
public
void
setWarehouseNo
(
String
warehouseNo
)
{
this
.
warehouseNo
=
warehouseNo
;
}
}
src/main/java/com/example/tdl/domain/vo/ConfigCMDVo.java
View file @
f4a76c00
...
@@ -16,6 +16,26 @@ public class ConfigCMDVo {
...
@@ -16,6 +16,26 @@ public class ConfigCMDVo {
private
Long
t
;
//配置时的时间戳
private
Long
t
;
//配置时的时间戳
public
ConfigCMDVo
()
{
}
public
ConfigCMDVo
(
String
action
,
Integer
gpsPeriod
,
Integer
gprsPeriod
,
List
<
String
>
devList
,
Integer
mode
)
{
this
.
action
=
action
;
this
.
gpsPeriod
=
gpsPeriod
;
this
.
gprsPeriod
=
gprsPeriod
;
this
.
devList
=
devList
;
this
.
mode
=
mode
;
}
public
ConfigCMDVo
(
String
action
,
Integer
gpsPeriod
,
Integer
gprsPeriod
,
List
<
String
>
devList
,
Integer
mode
,
Long
t
)
{
this
.
action
=
action
;
this
.
gpsPeriod
=
gpsPeriod
;
this
.
gprsPeriod
=
gprsPeriod
;
this
.
devList
=
devList
;
this
.
mode
=
mode
;
this
.
t
=
t
;
}
public
String
getAction
()
{
public
String
getAction
()
{
return
action
;
return
action
;
}
}
...
...
src/main/java/com/example/tdl/domain/vo/DeviceDataVo.java
0 → 100644
View file @
f4a76c00
package
com
.
example
.
tdl
.
domain
.
vo
;
public
class
DeviceDataVo
{
private
String
time
;
private
String
temperature
;
private
String
humidity
;
private
String
pressure
;
private
String
shockEnergy
;
private
String
tiltAngle
;
public
String
getTime
()
{
return
time
;
}
public
void
setTime
(
String
time
)
{
this
.
time
=
time
;
}
public
String
getTemperature
()
{
return
temperature
;
}
public
void
setTemperature
(
String
temperature
)
{
this
.
temperature
=
temperature
;
}
public
String
getHumidity
()
{
return
humidity
;
}
public
void
setHumidity
(
String
humidity
)
{
this
.
humidity
=
humidity
;
}
public
String
getPressure
()
{
return
pressure
;
}
public
void
setPressure
(
String
pressure
)
{
this
.
pressure
=
pressure
;
}
public
String
getShockEnergy
()
{
return
shockEnergy
;
}
public
void
setShockEnergy
(
String
shockEnergy
)
{
this
.
shockEnergy
=
shockEnergy
;
}
public
String
getTiltAngle
()
{
return
tiltAngle
;
}
public
void
setTiltAngle
(
String
tiltAngle
)
{
this
.
tiltAngle
=
tiltAngle
;
}
}
src/main/java/com/example/tdl/domain/vo/Humidity.java
0 → 100644
View file @
f4a76c00
package
com
.
example
.
tdl
.
domain
.
vo
;
import
java.util.List
;
public
class
Humidity
{
private
String
TDLSN
;
private
List
<
HumidityDataVo
>
humidityDataVoList
;
public
String
getTDLSN
()
{
return
TDLSN
;
}
public
void
setTDLSN
(
String
TDLSN
)
{
this
.
TDLSN
=
TDLSN
;
}
public
List
<
HumidityDataVo
>
getHumidityDataVoList
()
{
return
humidityDataVoList
;
}
public
void
setHumidityDataVoList
(
List
<
HumidityDataVo
>
humidityDataVoList
)
{
this
.
humidityDataVoList
=
humidityDataVoList
;
}
}
src/main/java/com/example/tdl/domain/vo/HumidityDataVo.java
0 → 100644
View file @
f4a76c00
package
com
.
example
.
tdl
.
domain
.
vo
;
public
class
HumidityDataVo
{
private
String
time
;
private
String
value
;
public
String
getTime
()
{
return
time
;
}
public
void
setTime
(
String
time
)
{
this
.
time
=
time
;
}
public
String
getValue
()
{
return
value
;
}
public
void
setValue
(
String
value
)
{
this
.
value
=
value
;
}
}
src/main/java/com/example/tdl/domain/vo/LiveDataVo.java
0 → 100644
View file @
f4a76c00
package
com
.
example
.
tdl
.
domain
.
vo
;
import
java.util.List
;
public
class
LiveDataVo
{
private
String
key
;
private
List
<
ProbesVo
>
probesVoList
;
public
String
getKey
()
{
return
key
;
}
public
void
setKey
(
String
key
)
{
this
.
key
=
key
;
}
public
List
<
ProbesVo
>
getProbesVoList
()
{
return
probesVoList
;
}
public
void
setProbesVoList
(
List
<
ProbesVo
>
probesVoList
)
{
this
.
probesVoList
=
probesVoList
;
}
}
src/main/java/com/example/tdl/domain/vo/LocationDataVo.java
0 → 100644
View file @
f4a76c00
package
com
.
example
.
tdl
.
domain
.
vo
;
public
class
LocationDataVo
{
private
String
time
;
private
Double
lng
;
private
Double
lat
;
private
Integer
error
;
//0 没有预警//1 发生预警
public
String
getTime
()
{
return
time
;
}
public
void
setTime
(
String
time
)
{
this
.
time
=
time
;
}
public
Double
getLng
()
{
return
lng
;
}
public
void
setLng
(
Double
lng
)
{
this
.
lng
=
lng
;
}
public
Double
getLat
()
{
return
lat
;
}
public
void
setLat
(
Double
lat
)
{
this
.
lat
=
lat
;
}
public
Integer
getError
()
{
return
error
;
}
public
void
setError
(
Integer
error
)
{
this
.
error
=
error
;
}
}
src/main/java/com/example/tdl/domain/vo/LocationMessageVo.java
0 → 100644
View file @
f4a76c00
package
com
.
example
.
tdl
.
domain
.
vo
;
import
java.util.List
;
public
class
LocationMessageVo
{
private
String
transportationNo
;
//运输编号
private
List
<
String
>
TDLSN
;
private
String
gatewaySN
;
private
String
startCity
;
private
String
endCity
;
private
String
startTime
;
private
String
endTime
;
private
Long
alarmTime
;
private
String
alarmType
;
private
String
alarmValue
;
private
String
lng
;
private
String
lat
;
public
String
getTransportationNo
()
{
return
transportationNo
;
}
public
void
setTransportationNo
(
String
transportationNo
)
{
this
.
transportationNo
=
transportationNo
;
}
public
List
<
String
>
getTDLSN
()
{
return
TDLSN
;
}
public
void
setTDLSN
(
List
<
String
>
TDLSN
)
{
this
.
TDLSN
=
TDLSN
;
}
public
String
getGatewaySN
()
{
return
gatewaySN
;
}
public
void
setGatewaySN
(
String
gatewaySN
)
{
this
.
gatewaySN
=
gatewaySN
;
}
public
String
getStartCity
()
{
return
startCity
;
}
public
void
setStartCity
(
String
startCity
)
{
this
.
startCity
=
startCity
;
}
public
String
getEndCity
()
{
return
endCity
;
}
public
void
setEndCity
(
String
endCity
)
{
this
.
endCity
=
endCity
;
}
public
String
getStartTime
()
{
return
startTime
;
}
public
void
setStartTime
(
String
startTime
)
{
this
.
startTime
=
startTime
;
}
public
String
getEndTime
()
{
return
endTime
;
}
public
void
setEndTime
(
String
endTime
)
{
this
.
endTime
=
endTime
;
}
public
Long
getAlarmTime
()
{
return
alarmTime
;
}
public
void
setAlarmTime
(
Long
alarmTime
)
{
this
.
alarmTime
=
alarmTime
;
}
public
String
getAlarmType
()
{
return
alarmType
;
}
public
void
setAlarmType
(
String
alarmType
)
{
this
.
alarmType
=
alarmType
;
}
public
String
getAlarmValue
()
{
return
alarmValue
;
}
public
void
setAlarmValue
(
String
alarmValue
)
{
this
.
alarmValue
=
alarmValue
;
}
public
String
getLng
()
{
return
lng
;
}
public
void
setLng
(
String
lng
)
{
this
.
lng
=
lng
;
}
public
String
getLat
()
{
return
lat
;
}
public
void
setLat
(
String
lat
)
{
this
.
lat
=
lat
;
}
}
src/main/java/com/example/tdl/domain/vo/LocationVo.java
0 → 100644
View file @
f4a76c00
package
com
.
example
.
tdl
.
domain
.
vo
;
public
class
LocationVo
{
private
Long
time
;
private
String
transportationNo
;
private
String
alarmType
;
private
String
vlaue
;
public
Long
getTime
()
{
return
time
;
}
public
void
setTime
(
Long
time
)
{
this
.
time
=
time
;
}
public
String
getTransportationNo
()
{
return
transportationNo
;
}
public
void
setTransportationNo
(
String
transportationNo
)
{
this
.
transportationNo
=
transportationNo
;
}
public
String
getAlarmType
()
{
return
alarmType
;
}
public
void
setAlarmType
(
String
alarmType
)
{
this
.
alarmType
=
alarmType
;
}
public
String
getVlaue
()
{
return
vlaue
;
}
public
void
setVlaue
(
String
vlaue
)
{
this
.
vlaue
=
vlaue
;
}
}
src/main/java/com/example/tdl/domain/vo/NumberVo.java
0 → 100644
View file @
f4a76c00
package
com
.
example
.
tdl
.
domain
.
vo
;
public
class
NumberVo
{
private
String
transportationNo
;
private
String
warehouseNo
;
public
String
getTransportationNo
()
{
return
transportationNo
;
}
public
void
setTransportationNo
(
String
transportationNo
)
{
this
.
transportationNo
=
transportationNo
;
}
public
String
getWarehouseNo
()
{
return
warehouseNo
;
}
public
void
setWarehouseNo
(
String
warehouseNo
)
{
this
.
warehouseNo
=
warehouseNo
;
}
}
src/main/java/com/example/tdl/domain/vo/ProbesVo.java
0 → 100644
View file @
f4a76c00
package
com
.
example
.
tdl
.
domain
.
vo
;
public
class
ProbesVo
{
private
Integer
port
;
private
String
unit
;
private
String
description
;
private
String
alias
;
private
String
type
;
private
Integer
alarmUp
;
private
Integer
alarmDown
;
private
String
value
;
public
Integer
getPort
()
{
return
port
;
}
public
void
setPort
(
Integer
port
)
{
this
.
port
=
port
;
}
public
String
getUnit
()
{
return
unit
;
}
public
void
setUnit
(
String
unit
)
{
this
.
unit
=
unit
;
}
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
String
getAlias
()
{
return
alias
;
}
public
void
setAlias
(
String
alias
)
{
this
.
alias
=
alias
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
Integer
getAlarmUp
()
{
return
alarmUp
;
}
public
void
setAlarmUp
(
Integer
alarmUp
)
{
this
.
alarmUp
=
alarmUp
;
}
public
Integer
getAlarmDown
()
{
return
alarmDown
;
}
public
void
setAlarmDown
(
Integer
alarmDown
)
{
this
.
alarmDown
=
alarmDown
;
}
public
String
getValue
()
{
return
value
;
}
public
void
setValue
(
String
value
)
{
this
.
value
=
value
;
}
}
src/main/java/com/example/tdl/domain/vo/RoleNameVo.java
0 → 100644
View file @
f4a76c00
package
com
.
example
.
tdl
.
domain
.
vo
;
public
class
RoleNameVo
{
private
String
roleName
;
public
String
getRoleName
()
{
return
roleName
;
}
public
void
setRoleName
(
String
roleName
)
{
this
.
roleName
=
roleName
;
}
}
src/main/java/com/example/tdl/domain/vo/ShockEnergy.java
0 → 100644
View file @
f4a76c00
package
com
.
example
.
tdl
.
domain
.
vo
;
import
java.util.List
;
public
class
ShockEnergy
{
private
String
TDLSN
;
private
List
<
ShockEnergyVo
>
shockEnergyVoList
;
public
String
getTDLSN
()
{
return
TDLSN
;
}
public
void
setTDLSN
(
String
TDLSN
)
{
this
.
TDLSN
=
TDLSN
;
}
public
List
<
ShockEnergyVo
>
getShockEnergyVoList
()
{
return
shockEnergyVoList
;
}
public
void
setShockEnergyVoList
(
List
<
ShockEnergyVo
>
shockEnergyVoList
)
{
this
.
shockEnergyVoList
=
shockEnergyVoList
;
}
}
src/main/java/com/example/tdl/domain/vo/ShockEnergyVo.java
0 → 100644
View file @
f4a76c00
package
com
.
example
.
tdl
.
domain
.
vo
;
public
class
ShockEnergyVo
{
private
String
time
;
private
String
value
;
public
String
getTime
()
{
return
time
;
}
public
void
setTime
(
String
time
)
{
this
.
time
=
time
;
}
public
String
getValue
()
{
return
value
;
}
public
void
setValue
(
String
value
)
{
this
.
value
=
value
;
}
}
src/main/java/com/example/tdl/domain/vo/Temperature.java
0 → 100644
View file @
f4a76c00
package
com
.
example
.
tdl
.
domain
.
vo
;
import
java.util.List
;
public
class
Temperature
{
private
String
TDLSN
;
private
List
<
TemperatureDataVo
>
temperatureDataVos
;
public
String
getTDLSN
()
{
return
TDLSN
;
}
public
void
setTDLSN
(
String
TDLSN
)
{
this
.
TDLSN
=
TDLSN
;
}
public
List
<
TemperatureDataVo
>
getTemperatureDataVos
()
{
return
temperatureDataVos
;
}
public
void
setTemperatureDataVos
(
List
<
TemperatureDataVo
>
temperatureDataVos
)
{
this
.
temperatureDataVos
=
temperatureDataVos
;
}
}
src/main/java/com/example/tdl/domain/vo/TemperatureDataVo.java
0 → 100644
View file @
f4a76c00
package
com
.
example
.
tdl
.
domain
.
vo
;
public
class
TemperatureDataVo
{
private
String
time
;
private
String
value
;
public
String
getTime
()
{
return
time
;
}
public
void
setTime
(
String
time
)
{
this
.
time
=
time
;
}
public
String
getValue
()
{
return
value
;
}
public
void
setValue
(
String
value
)
{
this
.
value
=
value
;
}
}
src/main/java/com/example/tdl/domain/vo/TiltAngle.java
0 → 100644
View file @
f4a76c00
package
com
.
example
.
tdl
.
domain
.
vo
;
import
java.util.List
;
public
class
TiltAngle
{
private
String
TDLSN
;
private
List
<
TiltAngleVo
>
shockEnergyVoList
;
public
String
getTDLSN
()
{
return
TDLSN
;
}
public
void
setTDLSN
(
String
TDLSN
)
{
this
.
TDLSN
=
TDLSN
;
}
public
List
<
TiltAngleVo
>
getShockEnergyVoList
()
{
return
shockEnergyVoList
;
}
public
void
setShockEnergyVoList
(
List
<
TiltAngleVo
>
shockEnergyVoList
)
{
this
.
shockEnergyVoList
=
shockEnergyVoList
;
}
}
src/main/java/com/example/tdl/domain/vo/TiltAngleVo.java
0 → 100644
View file @
f4a76c00
package
com
.
example
.
tdl
.
domain
.
vo
;
public
class
TiltAngleVo
{
private
String
time
;
private
String
value
;
public
String
getTime
()
{
return
time
;
}
public
void
setTime
(
String
time
)
{
this
.
time
=
time
;
}
public
String
getValue
()
{
return
value
;
}
public
void
setValue
(
String
value
)
{
this
.
value
=
value
;
}
}
src/main/java/com/example/tdl/entity/AlarmLog.java
View file @
f4a76c00
...
@@ -4,7 +4,7 @@ public class AlarmLog {
...
@@ -4,7 +4,7 @@ public class AlarmLog {
private
Integer
id
;
private
Integer
id
;
private
String
routeNumber
;
private
String
transportationNo
;
private
String
routeName
;
private
String
routeName
;
...
@@ -23,12 +23,12 @@ public class AlarmLog {
...
@@ -23,12 +23,12 @@ public class AlarmLog {
this
.
id
=
id
;
this
.
id
=
id
;
}
}
public
String
get
RouteNumber
()
{
public
String
get
TransportationNo
()
{
return
routeNumber
;
return
transportationNo
;
}
}
public
void
set
RouteNumber
(
String
routeNumber
)
{
public
void
set
TransportationNo
(
String
transportationNo
)
{
this
.
routeNumber
=
routeNumber
;
this
.
transportationNo
=
transportationNo
;
}
}
public
String
getRouteName
()
{
public
String
getRouteName
()
{
...
...
src/main/java/com/example/tdl/interceptor/PermissionInterceptor.java
View file @
f4a76c00
...
@@ -32,8 +32,6 @@ public class PermissionInterceptor implements HandlerInterceptor {
...
@@ -32,8 +32,6 @@ public class PermissionInterceptor implements HandlerInterceptor {
String
contextPath
=
request
.
getContextPath
();
String
contextPath
=
request
.
getContextPath
();
String
url
=
requestUri
.
substring
(
contextPath
.
length
());
String
url
=
requestUri
.
substring
(
contextPath
.
length
());
logger
.
info
(
"requestUri:"
+
requestUri
);
logger
.
info
(
"contextPath:"
+
contextPath
);
logger
.
info
(
"url:"
+
url
);
logger
.
info
(
"url:"
+
url
);
//获取用户信息以及对应的权限信息
//获取用户信息以及对应的权限信息
UserVo
user
=
gson
.
fromJson
(
redisService
.
get
(
"TOKEN_"
+
request
.
getHeader
(
"Account_token"
)),
UserVo
.
class
);
UserVo
user
=
gson
.
fromJson
(
redisService
.
get
(
"TOKEN_"
+
request
.
getHeader
(
"Account_token"
)),
UserVo
.
class
);
...
...
src/main/java/com/example/tdl/mapper/AlarmLogMapper.java
View file @
f4a76c00
...
@@ -17,4 +17,5 @@ public interface AlarmLogMapper {
...
@@ -17,4 +17,5 @@ public interface AlarmLogMapper {
//新增报警数据
//新增报警数据
int
addAlarmLog
(
AddAlarmLogVo
addAlarmLogVo
);
int
addAlarmLog
(
AddAlarmLogVo
addAlarmLogVo
);
List
<
AlarmLogVo
>
getByTransportationNo
(
String
transportationNo
);
}
}
src/main/java/com/example/tdl/mapper/CircuitMapper.java
View file @
f4a76c00
package
com
.
example
.
tdl
.
mapper
;
package
com
.
example
.
tdl
.
mapper
;
import
com.example.tdl.domain.vo.CircuitTermVo
;
import
com.example.tdl.domain.vo.*
;
import
com.example.tdl.domain.vo.ResultCircuitVo
;
import
com.example.tdl.domain.vo.ResultRouteVo
;
import
com.example.tdl.domain.vo.UpdateCircuitVo
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
java.util.List
;
import
java.util.List
;
...
@@ -24,4 +21,6 @@ public interface CircuitMapper {
...
@@ -24,4 +21,6 @@ public interface CircuitMapper {
int
delCircuit
(
String
transportationNo
);
int
delCircuit
(
String
transportationNo
);
ResultCircuitVo
getByTransportationNo
(
String
transportation
);
ResultCircuitVo
getByTransportationNo
(
String
transportation
);
ResultGatewayVo
getByNo
(
String
transportationNo
);
}
}
src/main/java/com/example/tdl/mapper/ConfigMapper.java
View file @
f4a76c00
...
@@ -4,10 +4,14 @@ import com.example.tdl.domain.vo.ConfigVo;
...
@@ -4,10 +4,14 @@ import com.example.tdl.domain.vo.ConfigVo;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.Map
;
@Mapper
@Mapper
public
interface
ConfigMapper
{
public
interface
ConfigMapper
{
int
addConfig
(
ConfigVo
configVo
);
// int addConfig(ConfigVo configVo);
int
addConfig
(
Map
<
Object
,
Object
>
map
);
ConfigVo
getConfig
(
@Param
(
"gSN"
)
String
gSN
,
@Param
(
"gType"
)
String
gType
);
ConfigVo
getConfig
(
@Param
(
"gSN"
)
String
gSN
,
@Param
(
"gType"
)
String
gType
);
...
@@ -15,5 +19,6 @@ public interface ConfigMapper {
...
@@ -15,5 +19,6 @@ public interface ConfigMapper {
int
bindiSuccess
(
@Param
(
"gSN"
)
String
gSN
,
@Param
(
"gType"
)
String
gType
,
@Param
(
"resp"
)
Integer
resp
);
int
bindiSuccess
(
@Param
(
"gSN"
)
String
gSN
,
@Param
(
"gType"
)
String
gType
,
@Param
(
"resp"
)
Integer
resp
);
int
updateConfig
(
@Param
(
"gSN"
)
String
gSN
,
@Param
(
"gType"
)
String
gType
,
@Param
(
"untie"
)
Boolean
untie
);
//int updateConfig(@Param("gSN") String gSN,@Param("gType") String gType,@Param("untie") Boolean untie);
int
updateConfig
(
Map
<
Object
,
Object
>
map
);
}
}
src/main/java/com/example/tdl/mapper/ProbesMapper.java
View file @
f4a76c00
package
com
.
example
.
tdl
.
mapper
;
package
com
.
example
.
tdl
.
mapper
;
import
com.example.tdl.domain.vo.ProbesVo
;
import
com.example.tdl.domain.vo.ResultProbesVo
;
import
com.example.tdl.domain.vo.ResultProbesVo
;
import
com.example.tdl.domain.vo.UpdateProbesVo
;
import
com.example.tdl.domain.vo.UpdateProbesVo
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
...
@@ -26,6 +27,8 @@ public interface ProbesMapper {
...
@@ -26,6 +27,8 @@ public interface ProbesMapper {
List
<
String
>
getNameByAliasList
(
@Param
(
"SN"
)
String
SN
,
@Param
(
"type"
)
String
type
,
@Param
(
"aliasList"
)
List
<
String
>
aliasList
);
List
<
String
>
getNameByAliasList
(
@Param
(
"SN"
)
String
SN
,
@Param
(
"type"
)
String
type
,
@Param
(
"aliasList"
)
List
<
String
>
aliasList
);
List
<
ProbesVo
>
getByAliasList
(
@Param
(
"SN"
)
String
SN
,
@Param
(
"type"
)
String
type
,
@Param
(
"aliasList"
)
List
<
String
>
aliasList
);
Integer
getCountByGateway
(
@Param
(
"SN"
)
String
SN
,
@Param
(
"type"
)
String
type
);
Integer
getCountByGateway
(
@Param
(
"SN"
)
String
SN
,
@Param
(
"type"
)
String
type
);
int
addProbes
(
Map
<
String
,
Object
>
map
);
int
addProbes
(
Map
<
String
,
Object
>
map
);
...
...
src/main/java/com/example/tdl/mapper/RoleMapper.java
View file @
f4a76c00
package
com
.
example
.
tdl
.
mapper
;
package
com
.
example
.
tdl
.
mapper
;
import
com.example.tdl.domain.vo.RoleNameVo
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
java.util.List
;
import
java.util.List
;
@Mapper
@Mapper
public
interface
RoleMapper
{
public
interface
RoleMapper
{
List
<
String
>
getAllRoleName
();
List
<
RoleNameVo
>
getAllRoleName
();
Integer
getByRoleName
(
String
roleName
);
Integer
getByRoleName
(
String
roleName
);
}
}
src/main/java/com/example/tdl/mapper/TDLDeviceMapper.java
View file @
f4a76c00
...
@@ -6,6 +6,7 @@ import com.example.tdl.domain.vo.ResultTDLDeviceVo;
...
@@ -6,6 +6,7 @@ import com.example.tdl.domain.vo.ResultTDLDeviceVo;
import
com.example.tdl.domain.vo.TDLDeviceTermVo
;
import
com.example.tdl.domain.vo.TDLDeviceTermVo
;
import
com.example.tdl.domain.vo.UpdateTDLDeviceVo
;
import
com.example.tdl.domain.vo.UpdateTDLDeviceVo
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
import
java.util.List
;
...
@@ -22,4 +23,6 @@ public interface TDLDeviceMapper {
...
@@ -22,4 +23,6 @@ public interface TDLDeviceMapper {
int
delTDLDevice
(
String
TDLSN
);
int
delTDLDevice
(
String
TDLSN
);
ResultTDLDeviceVo
getByTDLSN
(
String
TDLSN
);
ResultTDLDeviceVo
getByTDLSN
(
String
TDLSN
);
List
<
String
>
getByGatewaySN
(
@Param
(
"SN"
)
String
SN
,
@Param
(
"type"
)
String
type
);
}
}
src/main/java/com/example/tdl/service/AlarmLogServ
ci
e.java
→
src/main/java/com/example/tdl/service/AlarmLogServ
ic
e.java
View file @
f4a76c00
...
@@ -9,7 +9,7 @@ import org.springframework.stereotype.Service;
...
@@ -9,7 +9,7 @@ import org.springframework.stereotype.Service;
import
java.util.List
;
import
java.util.List
;
@Service
@Service
public
class
AlarmLogServ
ci
e
{
public
class
AlarmLogServ
ic
e
{
@Autowired
@Autowired
private
AlarmLogMapper
alarmLogMapper
;
private
AlarmLogMapper
alarmLogMapper
;
...
@@ -26,5 +26,9 @@ public class AlarmLogServcie {
...
@@ -26,5 +26,9 @@ public class AlarmLogServcie {
return
alarmLogMapper
.
addAlarmLog
(
addAlarmLogVo
);
return
alarmLogMapper
.
addAlarmLog
(
addAlarmLogVo
);
}
}
public
List
<
AlarmLogVo
>
getByTransportationNo
(
String
transportationNo
){
return
alarmLogMapper
.
getByTransportationNo
(
transportationNo
);
}
}
}
src/main/java/com/example/tdl/service/CircuitService.java
View file @
f4a76c00
package
com
.
example
.
tdl
.
service
;
package
com
.
example
.
tdl
.
service
;
import
com.example.tdl.domain.vo.AddCircuitVo
;
import
com.example.tdl.domain.vo.*
;
import
com.example.tdl.domain.vo.CircuitTermVo
;
import
com.example.tdl.domain.vo.ResultCircuitVo
;
import
com.example.tdl.domain.vo.UpdateCircuitVo
;
import
com.example.tdl.mapper.CircuitMapper
;
import
com.example.tdl.mapper.CircuitMapper
;
import
com.example.tdl.mapper.RoleMapper
;
import
com.example.tdl.mapper.RoleMapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -46,4 +43,8 @@ public class CircuitService {
...
@@ -46,4 +43,8 @@ public class CircuitService {
return
circuitMapper
.
getByTransportationNo
(
transportationNo
);
return
circuitMapper
.
getByTransportationNo
(
transportationNo
);
}
}
public
ResultGatewayVo
getByNo
(
String
transportationNo
){
return
circuitMapper
.
getByNo
(
transportationNo
);
}
}
}
src/main/java/com/example/tdl/service/ConfigService.java
View file @
f4a76c00
...
@@ -5,6 +5,8 @@ import com.example.tdl.mapper.ConfigMapper;
...
@@ -5,6 +5,8 @@ import com.example.tdl.mapper.ConfigMapper;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.Map
;
@Service
@Service
public
class
ConfigService
{
public
class
ConfigService
{
...
@@ -12,8 +14,12 @@ public class ConfigService {
...
@@ -12,8 +14,12 @@ public class ConfigService {
private
ConfigMapper
configMapper
;
private
ConfigMapper
configMapper
;
//绑定getway和tdl
//绑定getway和tdl
public
int
addConfig
(
ConfigVo
configVo
){
/*
public int addConfig(ConfigVo configVo){
return configMapper.addConfig(configVo);
return configMapper.addConfig(configVo);
}*/
public
int
addConfig
(
Map
<
Object
,
Object
>
map
){
return
configMapper
.
addConfig
(
map
);
}
}
...
@@ -28,8 +34,12 @@ public class ConfigService {
...
@@ -28,8 +34,12 @@ public class ConfigService {
}
}
//解绑getWay和tdl
//解绑getWay和tdl
public
int
updateConfig
(
String
gSN
,
String
gType
,
Boolean
untie
){
// public int updateConfig(String gSN,String gType,Boolean untie ){
return
configMapper
.
updateConfig
(
gSN
,
gType
,
untie
);
// return configMapper.updateConfig(gSN,gType,untie);
// }
public
int
updateConfig
(
Map
<
Object
,
Object
>
map
){
return
configMapper
.
updateConfig
(
map
);
}
}
//解绑成功
//解绑成功
...
...
src/main/java/com/example/tdl/service/InfluxDBService.java
deleted
100644 → 0
View file @
5a4afdd8
package
com
.
example
.
tdl
.
service
;
import
com.example.tdl.config.Influxdbconfig
;
import
org.influxdb.InfluxDB
;
import
org.influxdb.dto.BatchPoints
;
import
org.influxdb.dto.Point
;
import
org.influxdb.dto.Query
;
import
org.influxdb.dto.QueryResult
;
import
org.influxdb.dto.QueryResult.Result
;
import
org.influxdb.dto.QueryResult.Series
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
@Service
(
"influxdbService"
)
public
class
InfluxDBService
{
@Autowired
Influxdbconfig
influxdbconfig
;
@Autowired
private
InfluxDB
influxDB
;
public
final
static
String
DEFAULT_DATABASE
=
"original"
;
public
final
static
String
DEFAULT_POLICY
=
"witium_policy"
;
private
final
static
String
DEFAULT_DURATION
=
"0d"
;
private
final
static
String
DEFAULT_SHARD_DURATION
=
"90d"
;
private
String
mPolicyName
=
DEFAULT_POLICY
;
private
String
mDBName
=
DEFAULT_DATABASE
;
public
void
connectDatabase
(
String
dbname
)
{
if
(!
dbname
.
isEmpty
()
&&
dbname
!=
null
)
{
useDatabase
(
dbname
);
useRetentionPolicy
(
mPolicyName
);
}
}
/* Create the database if it is not exist. */
private
void
createDatabase
(
String
database
)
{
if
(
database
!=
null
&&
!
database
.
isEmpty
())
{
if
(!
influxDB
.
databaseExists
(
database
))
{
influxDB
.
createDatabase
(
database
);
}
}
}
public
void
useDatabase
(
String
database
)
{
if
(!
influxDB
.
databaseExists
(
database
))
{
createDatabase
(
database
);
}
influxdbconfig
.
setDatabase
(
database
);
mDBName
=
database
;
}
public
List
<
String
>
showRetentionPolicys
()
{
String
command
=
String
.
format
(
"SHOW RETENTION POLICIES ON \"%s\""
,
mDBName
);
QueryResult
results
=
this
.
query
(
command
);
List
<
String
>
policys
=
new
ArrayList
<
String
>();
for
(
Result
result
:
results
.
getResults
())
{
List
<
Series
>
series
=
result
.
getSeries
();
for
(
Series
serie
:
series
)
{
List
<
List
<
Object
>>
values
=
serie
.
getValues
();
for
(
List
<
Object
>
value
:
values
)
{
policys
.
add
(
0
,
(
String
)
value
.
get
(
0
));
}
}
}
return
policys
;
}
/* Judge whether policy is exist. */
public
boolean
isRetentionPolicyExist
(
String
policyname
)
{
boolean
isExist
=
false
;
List
<
String
>
policys
;
policys
=
showRetentionPolicys
();
for
(
String
policy
:
policys
)
{
if
(
policy
.
equals
(
policyname
))
{
isExist
=
true
;
break
;
}
}
return
isExist
;
}
public
void
useRetentionPolicy
(
String
policy
)
{
mPolicyName
=
policy
;
if
(!
isRetentionPolicyExist
(
policy
))
{
createRetentionPolicy
(
DEFAULT_DURATION
,
DEFAULT_SHARD_DURATION
,
1
,
true
);
}
}
/**
* 创建保存策略 <br/>
* CREATE RETENTION POLICY "default" ON "database" DURATION 30d REPLICATION 1 DEFAULT
*
* @param duration 存放时间
* @param replicationNum 备份数量
*/
public
void
createRetentionPolicy
(
String
duration
,
Integer
replicationNum
,
Boolean
isDefault
)
{
if
(
mPolicyName
!=
null
&&
!
mPolicyName
.
isEmpty
()
&&
mDBName
!=
null
&&
!
mDBName
.
isEmpty
())
{
String
command
=
String
.
format
(
"CREATE RETENTION POLICY \"%s\" ON \"%s\" DURATION %s REPLICATION %s %s"
,
mPolicyName
,
mDBName
,
duration
,
replicationNum
,
isDefault
?
"DEFAULT"
:
""
);
this
.
query
(
command
);
}
}
/**
* 创建保存策略 <br/>
* CREATE RETENTION POLICY "default" ON "database" DURATION 30d SHARD DURATION %s REPLICATION 1 DEFAULT
*
* @param duration 存放时间
* @param shardGroupDuration 存放快速读取组时间
* @param replicationNum 备份数量
*/
public
void
createRetentionPolicy
(
String
duration
,
String
shardGroupDuration
,
Integer
replicationNum
,
Boolean
isDefault
)
{
if
(
mPolicyName
!=
null
&&
!
mPolicyName
.
isEmpty
()
&&
mDBName
!=
null
&&
!
mDBName
.
isEmpty
())
{
String
command
=
String
.
format
(
"CREATE RETENTION POLICY \"%s\" ON \"%s\" DURATION %s SHARD DURATION %s REPLICATION %s %s"
,
mPolicyName
,
mDBName
,
duration
,
shardGroupDuration
,
replicationNum
,
isDefault
?
"DEFAULT"
:
""
);
this
.
query
(
command
);
}
}
/**
* 插入数据
*
* @param measurement a Point in a fluent manner
* @param tagsToAdd the Map of tags to add
* @param fields the fields to add
*/
public
void
insert
(
String
measurement
,
Long
timestamp
,
Map
<
String
,
String
>
tagsToAdd
,
Map
<
String
,
Object
>
fields
)
{
if
(
measurement
!=
null
&&
!
measurement
.
isEmpty
()
&&
tagsToAdd
!=
null
&&
!
tagsToAdd
.
isEmpty
()
&&
fields
!=
null
&&
!
fields
.
isEmpty
())
{
Point
.
Builder
builder
=
Point
.
measurement
(
measurement
)
.
time
(
timestamp
,
TimeUnit
.
MILLISECONDS
)
.
tag
(
tagsToAdd
)
.
fields
(
fields
);
try
{
influxDB
.
write
(
mDBName
,
mPolicyName
,
builder
.
build
());
}
catch
(
RuntimeException
e
)
{
// TODO: handle exception
e
.
printStackTrace
();
}
catch
(
Exception
e
)
{
// TODO: handle exception
e
.
printStackTrace
();
}
}
}
public
void
insertBatchWithMultiTags
(
String
dbname
,
String
measurement
,
Long
[]
timestamp
,
List
<
Map
<
String
,
String
>>
tagsToAdd
,
List
<
Map
<
String
,
Object
>>
fields
)
{
if
(
measurement
!=
null
&&
!
measurement
.
isEmpty
()
&&
tagsToAdd
!=
null
&&
!
tagsToAdd
.
isEmpty
()
&&
fields
!=
null
&&
!
fields
.
isEmpty
())
{
BatchPoints
batchPoints
=
BatchPoints
.
database
(
dbname
)
.
retentionPolicy
(
mPolicyName
)
.
consistency
(
InfluxDB
.
ConsistencyLevel
.
ALL
)
.
build
();
for
(
int
i
=
0
;
i
<
tagsToAdd
.
size
();
i
++)
{
Point
pointdata
=
Point
.
measurement
(
measurement
)
.
time
(
timestamp
[
i
],
TimeUnit
.
MILLISECONDS
)
.
tag
(
tagsToAdd
.
get
(
i
))
.
fields
(
fields
.
get
(
i
))
.
build
();
batchPoints
.
point
(
pointdata
);
}
try
{
influxDB
.
write
(
batchPoints
);
}
catch
(
RuntimeException
e
)
{
// TODO: handle exception
e
.
printStackTrace
();
}
catch
(
Exception
e
)
{
// TODO: handle exception
e
.
printStackTrace
();
}
}
}
public
void
insertBatchWithSameTags
(
String
dbname
,
String
measurement
,
Long
[]
timestamp
,
Map
<
String
,
String
>
tagsToAdd
,
List
<
Map
<
String
,
Object
>>
fields
)
{
if
(
measurement
!=
null
&&
!
measurement
.
isEmpty
()
&&
tagsToAdd
!=
null
&&
!
tagsToAdd
.
isEmpty
()
&&
fields
!=
null
&&
!
fields
.
isEmpty
())
{
BatchPoints
batchPoints
=
BatchPoints
.
database
(
dbname
)
.
retentionPolicy
(
mPolicyName
)
.
consistency
(
InfluxDB
.
ConsistencyLevel
.
ALL
)
.
build
();
for
(
int
i
=
0
;
i
<
fields
.
size
();
i
++)
{
Point
pointdata
=
Point
.
measurement
(
measurement
)
.
time
(
timestamp
[
i
],
TimeUnit
.
MILLISECONDS
)
.
tag
(
tagsToAdd
)
.
fields
(
fields
.
get
(
i
))
.
build
();
if
(
pointdata
!=
null
)
{
batchPoints
.
point
(
pointdata
);
}
}
try
{
influxDB
.
write
(
batchPoints
);
}
catch
(
RuntimeException
e
)
{
// TODO: handle exception
e
.
printStackTrace
();
}
catch
(
Exception
e
)
{
// TODO: handle exception
e
.
printStackTrace
();
}
}
}
/**
* 查询数据
*
* @param command
* @return QueryResult
*/
public
QueryResult
query
(
String
command
)
{
return
influxDB
.
query
(
new
Query
(
command
,
mDBName
));
}
}
src/main/java/com/example/tdl/service/ProbesService.java
View file @
f4a76c00
package
com
.
example
.
tdl
.
service
;
package
com
.
example
.
tdl
.
service
;
import
com.example.tdl.domain.vo.ProbesVo
;
import
com.example.tdl.domain.vo.ResultProbesVo
;
import
com.example.tdl.domain.vo.ResultProbesVo
;
import
com.example.tdl.domain.vo.UpdateProbesVo
;
import
com.example.tdl.domain.vo.UpdateProbesVo
;
import
com.example.tdl.mapper.ProbesMapper
;
import
com.example.tdl.mapper.ProbesMapper
;
...
@@ -47,6 +48,10 @@ public class ProbesService {
...
@@ -47,6 +48,10 @@ public class ProbesService {
return
probesMapper
.
getNameByAliasList
(
SN
,
type
,
aliasList
);
return
probesMapper
.
getNameByAliasList
(
SN
,
type
,
aliasList
);
}
}
public
List
<
ProbesVo
>
getByAliasList
(
String
SN
,
String
type
,
List
<
String
>
aliasList
){
return
probesMapper
.
getByAliasList
(
SN
,
type
,
aliasList
);
}
public
Integer
getCountByGateway
(
String
SN
,
String
type
){
public
Integer
getCountByGateway
(
String
SN
,
String
type
){
return
probesMapper
.
getCountByGateway
(
SN
,
type
);
return
probesMapper
.
getCountByGateway
(
SN
,
type
);
}
}
...
...
src/main/java/com/example/tdl/service/RoleService.java
View file @
f4a76c00
package
com
.
example
.
tdl
.
service
;
package
com
.
example
.
tdl
.
service
;
import
com.example.tdl.domain.vo.RoleNameVo
;
import
com.example.tdl.mapper.RoleMapper
;
import
com.example.tdl.mapper.RoleMapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -12,7 +13,7 @@ public class RoleService {
...
@@ -12,7 +13,7 @@ public class RoleService {
@Autowired
@Autowired
private
RoleMapper
roleMapper
;
private
RoleMapper
roleMapper
;
public
List
<
String
>
getAllRoleName
(){
public
List
<
RoleNameVo
>
getAllRoleName
(){
return
roleMapper
.
getAllRoleName
();
return
roleMapper
.
getAllRoleName
();
}
}
...
...
src/main/java/com/example/tdl/service/TDLDeviceService.java
View file @
f4a76c00
...
@@ -38,4 +38,8 @@ public class TDLDeviceService {
...
@@ -38,4 +38,8 @@ public class TDLDeviceService {
public
ResultTDLDeviceVo
getByTDLSN
(
String
TDLSN
){
public
ResultTDLDeviceVo
getByTDLSN
(
String
TDLSN
){
return
tdlDeviceMapper
.
getByTDLSN
(
TDLSN
);
return
tdlDeviceMapper
.
getByTDLSN
(
TDLSN
);
}
}
public
List
<
String
>
getByGatewaySN
(
String
SN
,
String
type
){
return
tdlDeviceMapper
.
getByGatewaySN
(
SN
,
type
);
}
}
}
src/main/java/com/example/tdl/service/redis/RealRedisService.java
0 → 100644
View file @
f4a76c00
package
com
.
example
.
tdl
.
service
.
redis
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
@Service
public
class
RealRedisService
extends
RedisService
{
@SuppressWarnings
({
"unchecked"
,
"rawtypes"
})
@Autowired
public
RealRedisService
(
RedisTemplate
realRedisTemplate
)
{
super
(
realRedisTemplate
);
}
}
src/main/java/com/example/tdl/service/redis/RedisService.java
View file @
f4a76c00
...
@@ -122,11 +122,7 @@ public class RedisService {
...
@@ -122,11 +122,7 @@ public class RedisService {
}
}
return
result
;
return
result
;
}
}
/**
* 获取此数据库所有的Keys表
* @return
*/
public
Object
getAllKeys
()
{
public
Object
getAllKeys
()
{
Object
ret
=
null
;
Object
ret
=
null
;
try
{
try
{
...
@@ -136,56 +132,29 @@ public class RedisService {
...
@@ -136,56 +132,29 @@ public class RedisService {
}
}
return
ret
;
return
ret
;
}
}
/**
* 批量删除对应的value
*
* @param keys
*/
public
void
remove
(
final
String
...
keys
)
{
public
void
remove
(
final
String
...
keys
)
{
for
(
String
key
:
keys
)
{
for
(
String
key
:
keys
)
{
remove
(
key
);
remove
(
key
);
}
}
}
}
/**
* 批量删除key
*
* @param pattern
*/
public
void
removePattern
(
final
String
pattern
)
{
public
void
removePattern
(
final
String
pattern
)
{
Set
<
Serializable
>
keys
=
redisTemplate
.
keys
(
pattern
);
Set
<
Serializable
>
keys
=
redisTemplate
.
keys
(
pattern
);
if
(
keys
.
size
()
>
0
)
if
(
keys
.
size
()
>
0
)
redisTemplate
.
delete
(
keys
);
redisTemplate
.
delete
(
keys
);
}
}
/**
* 删除对应的value
*
* @param key
*/
public
void
remove
(
final
String
key
)
{
public
void
remove
(
final
String
key
)
{
if
(
exists
(
key
))
{
if
(
exists
(
key
))
{
redisTemplate
.
delete
(
key
);
redisTemplate
.
delete
(
key
);
}
}
}
}
/**
* 判断缓存中是否有对应的value
*
* @param key
* @return
*/
public
boolean
exists
(
final
String
key
)
{
public
boolean
exists
(
final
String
key
)
{
return
redisTemplate
.
hasKey
(
key
);
return
redisTemplate
.
hasKey
(
key
);
}
}
/**
* 读取缓存
*
* @param key
* @return
*/
public
String
get
(
final
String
key
)
{
public
String
get
(
final
String
key
)
{
String
result
=
null
;
String
result
=
null
;
try
{
try
{
...
@@ -198,13 +167,6 @@ public class RedisService {
...
@@ -198,13 +167,6 @@ public class RedisService {
return
result
;
return
result
;
}
}
/**
* 写入缓存
*
* @param key
* @param value
* @return
*/
public
boolean
set
(
final
String
key
,
Object
value
)
{
public
boolean
set
(
final
String
key
,
Object
value
)
{
boolean
result
=
false
;
boolean
result
=
false
;
try
{
try
{
...
@@ -218,19 +180,11 @@ public class RedisService {
...
@@ -218,19 +180,11 @@ public class RedisService {
return
result
;
return
result
;
}
}
/**
* 写入缓存
*
* @param key
* @param value
* @return
*/
public
boolean
set
(
final
String
key
,
Object
value
,
long
expireTime
)
{
public
boolean
set
(
final
String
key
,
Object
value
,
long
expireTime
)
{
boolean
result
=
false
;
boolean
result
=
false
;
try
{
try
{
ValueOperations
<
Serializable
,
Object
>
operations
=
redisTemplate
.
opsForValue
();
ValueOperations
<
Serializable
,
Object
>
operations
=
redisTemplate
.
opsForValue
();
operations
.
set
(
key
,
value
);
operations
.
set
(
key
,
value
);
//logger.info("[key:" + key + "],[value:" + value + "]");
redisTemplate
.
expire
(
key
,
expireTime
,
TimeUnit
.
SECONDS
);
redisTemplate
.
expire
(
key
,
expireTime
,
TimeUnit
.
SECONDS
);
result
=
true
;
result
=
true
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -240,12 +194,6 @@ public class RedisService {
...
@@ -240,12 +194,6 @@ public class RedisService {
return
result
;
return
result
;
}
}
/**
* 更新过期时间
*
* @param key
* @return
*/
public
boolean
refeshTimeOut
(
String
key
,
long
expireTime
)
{
public
boolean
refeshTimeOut
(
String
key
,
long
expireTime
)
{
boolean
f
=
false
;
boolean
f
=
false
;
try
{
try
{
...
@@ -258,7 +206,6 @@ public class RedisService {
...
@@ -258,7 +206,6 @@ public class RedisService {
return
f
;
return
f
;
}
}
//删除key
public
void
delKey
(
final
String
...
key
){
public
void
delKey
(
final
String
...
key
){
if
(
key
!=
null
&&
key
.
length
>
0
){
if
(
key
!=
null
&&
key
.
length
>
0
){
if
(
key
.
length
==
1
){
if
(
key
.
length
==
1
){
...
@@ -268,4 +215,5 @@ public class RedisService {
...
@@ -268,4 +215,5 @@ public class RedisService {
}
}
}
}
}
}
}
}
src/main/java/com/example/tdl/web/AlarmLogController.java
View file @
f4a76c00
...
@@ -2,7 +2,7 @@ package com.example.tdl.web;
...
@@ -2,7 +2,7 @@ package com.example.tdl.web;
import
com.example.tdl.domain.dto.CommFeedback
;
import
com.example.tdl.domain.dto.CommFeedback
;
import
com.example.tdl.domain.vo.AddAlarmLogVo
;
import
com.example.tdl.domain.vo.AddAlarmLogVo
;
import
com.example.tdl.service.AlarmLogServ
ci
e
;
import
com.example.tdl.service.AlarmLogServ
ic
e
;
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
;
...
@@ -23,7 +23,7 @@ public class AlarmLogController {
...
@@ -23,7 +23,7 @@ public class AlarmLogController {
CommFeedback
fb
=
new
CommFeedback
();
CommFeedback
fb
=
new
CommFeedback
();
@Autowired
@Autowired
private
AlarmLogServ
ci
e
alarmLogServcie
;
private
AlarmLogServ
ic
e
alarmLogServcie
;
//获取所有的报警数据
//获取所有的报警数据
@GetMapping
(
"/getAll"
)
@GetMapping
(
"/getAll"
)
...
@@ -40,9 +40,9 @@ public class AlarmLogController {
...
@@ -40,9 +40,9 @@ public class AlarmLogController {
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
})
})
public
Object
addAlarmLog
(
@RequestBody
AddAlarmLogVo
addAlarmLogVo
){
public
Object
addAlarmLog
(
@RequestBody
AddAlarmLogVo
addAlarmLogVo
){
if
(
StringUtils
.
isEmpty
(
addAlarmLogVo
.
get
RouteNumber
())){
if
(
StringUtils
.
isEmpty
(
addAlarmLogVo
.
get
TransportationNo
())){
fb
.
setCode
(
0
);
fb
.
setCode
(
0
);
fb
.
setMessage
(
"
路由
编号不能为空"
);
fb
.
setMessage
(
"
运输
编号不能为空"
);
return
gson
.
toJson
(
fb
);
return
gson
.
toJson
(
fb
);
}
}
if
(
StringUtils
.
isEmpty
(
addAlarmLogVo
.
getRouteName
())){
if
(
StringUtils
.
isEmpty
(
addAlarmLogVo
.
getRouteName
())){
...
...
src/main/java/com/example/tdl/web/DataController.java
View file @
f4a76c00
...
@@ -2,15 +2,28 @@ package com.example.tdl.web;
...
@@ -2,15 +2,28 @@ package com.example.tdl.web;
import
com.example.tdl.domain.dto.CommFeedback
;
import
com.example.tdl.domain.dto.CommFeedback
;
import
com.example.tdl.
service.GatewayService
;
import
com.example.tdl.
domain.vo.*
;
import
com.example.tdl.service.
InfluxDBService
;
import
com.example.tdl.service.
*
;
import
com.example.tdl.service.redis.RedisService
;
import
com.example.tdl.service.redis.Re
alRe
disService
;
import
com.google.gson.Gson
;
import
com.google.gson.Gson
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
org.influxdb.dto.Query
;
import
org.influxdb.dto.QueryResult
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.data.influxdb.InfluxDBTemplate
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
@RestController
@RestController
public
class
DataController
{
public
class
DataController
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
DataController
.
class
);
private
Logger
logger
=
LoggerFactory
.
getLogger
(
DataController
.
class
);
...
@@ -23,12 +36,482 @@ public class DataController {
...
@@ -23,12 +36,482 @@ public class DataController {
private
GatewayService
gatewayService
;
private
GatewayService
gatewayService
;
@Autowired
@Autowired
private
RedisService
redisService
;
private
TDLDeviceService
tdlDeviceService
;
@Autowired
private
ProbesService
probesService
;
@Autowired
private
RealRedisService
realRedisService
;
@Autowired
private
InfluxDBTemplate
influxDBTemplate
;
@Autowired
private
AlarmLogService
alarmLogService
;
@Autowired
@Autowired
private
InfluxDBService
influxDBService
;
private
CircuitService
circuitService
;
private
String
database
=
"original"
;
//获取实时数据
@ApiOperation
(
value
=
"获取实时数据"
,
notes
=
"获取实时数据"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
})
@PostMapping
(
"/getRealTimeData"
)
public
Object
getRealTimeData
(
@RequestBody
String
transportationNo
){
//获取gateway的信息
ResultGatewayVo
gatewayVo
=
circuitService
.
getByNo
(
transportationNo
);
//获取tdl信息
List
<
String
>
devList
=
tdlDeviceService
.
getByGatewaySN
(
gatewayVo
.
getSN
(),
gatewayVo
.
getType
());
// String gSN = "20180314";
// String gType = "WTD93LG";
//根据gateWay获取tdl信息
List
<
String
>
key
=
new
ArrayList
<>();
key
.
add
(
gatewayVo
.
getSN
()+
"_"
+
gatewayVo
.
getType
()
+
":"
+
gatewayVo
.
getSN
()+
"_"
+
gatewayVo
.
getType
());
for
(
int
i
=
0
;
i
<
devList
.
size
();
i
++){
key
.
add
(
gatewayVo
.
getSN
()+
"_"
+
gatewayVo
.
getType
()+
":"
+
devList
.
get
(
i
));
}
List
<
LiveDataVo
>
liveDataVos
=
new
ArrayList
<>();
for
(
int
j
=
0
;
j
<
key
.
size
();
j
++){
Map
<
Object
,
Object
>
ret
=
realRedisService
.
getHashAll
(
key
.
get
(
j
));
if
(
ret
==
null
){
continue
;
}
else
{
Iterator
entries
=
ret
.
entrySet
().
iterator
();
List
<
String
>
aliasList
=
new
ArrayList
<>();
List
<
String
>
valueList
=
new
ArrayList
<>();
while
(
entries
.
hasNext
()){
Map
.
Entry
entry
=
(
Map
.
Entry
)
entries
.
next
();
aliasList
.
add
((
String
)
entry
.
getKey
());
valueList
.
add
((
String
)
entry
.
getValue
());
}
//根据通道别名获取通道信息
List
<
ProbesVo
>
probesVoList
=
probesService
.
getByAliasList
(
gatewayVo
.
getSN
(),
gatewayVo
.
getType
(),
aliasList
);
for
(
int
m
=
0
;
m
<
probesVoList
.
size
();
m
++){
probesVoList
.
get
(
m
).
setValue
(
valueList
.
get
(
m
));
}
LiveDataVo
liveDataVo
=
new
LiveDataVo
();
liveDataVo
.
setKey
(
key
.
get
(
j
).
substring
(
key
.
get
(
j
).
indexOf
(
":"
),
key
.
get
(
j
).
length
()));
liveDataVo
.
setProbesVoList
(
probesVoList
);
liveDataVos
.
add
(
liveDataVo
);
}
}
return
gson
.
toJson
(
liveDataVos
);
}
//获取坐标数据数据
@ApiOperation
(
value
=
"获取坐标数据数据"
,
notes
=
"获取坐标数据数据"
+
"time:时间"
+
"lng:经度"
+
"lat: 纬度"
)
@PostMapping
(
"/getLocation"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
})
public
Object
getLocation
(
@RequestBody
String
transportationNo
){
//获取gateway的信息
ResultGatewayVo
gatewayVo
=
circuitService
.
getByNo
(
transportationNo
);
String
device
=
gatewayVo
.
getType
()
+
"_"
+
gatewayVo
.
getSN
();
//获取tdl信息
// List<String> devList = tdlDeviceService.getByGatewaySN(gatewayVo.getSN(),gatewayVo.getType());
String
sql
=
"SELECT \"lng\",\"lat\" FROM \"tdl_policy\".\""
+
device
+
"\"ORDER BY time "
;
QueryResult
queryResult
=
influxDBTemplate
.
query
(
new
Query
(
sql
,
database
));
//解析经纬度数据
List
<
LocationDataVo
>
locationDataVos
=
new
ArrayList
<>();
if
(
queryResult
.
getResults
().
get
(
0
).
getSeries
()
!=
null
){
locationDataVos
=
getLocation
(
queryResult
);
}
return
gson
.
toJson
(
locationDataVos
);
}
//根据运输编号获取路线以及设备信息
@PostMapping
(
"/getCircuit"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
})
public
Object
getCircuit
(
@RequestBody
String
transportationNo
){
//根据运输编号获取线路信息,设备信息
//获取gateway的信息
ResultGatewayVo
gatewayVo
=
circuitService
.
getByNo
(
transportationNo
);
String
device
=
gatewayVo
.
getType
()
+
"_"
+
gatewayVo
.
getSN
();
//获取tdl信息
// List<String> devList = tdlDeviceService.getByGatewaySN(gatewayVo.getSN(),gatewayVo.getType());
String
key
=
gatewayVo
.
getSN
()+
"_"
+
gatewayVo
.
getType
()
+
":"
+
gatewayVo
.
getSN
()+
"_"
+
gatewayVo
.
getType
()
;
//获取网关以及TDL的电量
return
gson
.
toJson
(
fb
);
}
//获取温度数据
@ApiOperation
(
value
=
"获取温度数据"
,
notes
=
"获取温度数据"
)
@PostMapping
(
"/getTemperature"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
})
public
Object
getTemperature
(
@RequestBody
String
transportationNo
){
ResultGatewayVo
gatewayVo
=
circuitService
.
getByNo
(
transportationNo
);
String
device
=
gatewayVo
.
getType
()
+
"_"
+
gatewayVo
.
getSN
();
//获取tdl信息
List
<
String
>
devList
=
tdlDeviceService
.
getByGatewaySN
(
gatewayVo
.
getSN
(),
gatewayVo
.
getType
());
String
devcie
=
gatewayVo
.
getType
()+
"_"
+
gatewayVo
.
getSN
()
;
//SELECT "h" FROM "tdl_policy"."WTD93LG_20180314" WHERE "tdl" = 'tdl-0A0B0C0D0F' ORDER BY time DESC
if
(
devList
.
size
()
==
0
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
"没有数据"
);
return
gson
.
toJson
(
fb
);
}
List
<
Temperature
>
temperatures
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
devList
.
size
();
i
++){
Temperature
temperature
=
new
Temperature
();
temperature
.
setTDLSN
(
devList
.
get
(
i
));
String
sql
=
"SELECT \"t\" FROM \"tdl_policy\".\""
+
devcie
+
"\" where \"tdl\"=\'"
+
devList
.
get
(
i
)+
"\' ORDER BY time "
;
QueryResult
queryResult
=
influxDBTemplate
.
query
(
new
Query
(
sql
,
database
));
List
<
TemperatureDataVo
>
temperatureDataVos
=
new
ArrayList
<>();
if
(
queryResult
.
getResults
().
get
(
0
).
getSeries
()
!=
null
){
//解析数据
temperatureDataVos
=
getTemperature
(
queryResult
);
}
temperature
.
setTemperatureDataVos
(
temperatureDataVos
);
temperatures
.
add
(
temperature
);
}
/*String sql = "SELECT \"t\" FROM \"tdl_policy\".\""+devcie+"\" ORDER BY time ";
QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
List<TemperatureDataVo> temperatureDataVos = new ArrayList<>();
if(queryResult.getResults().get(0).getSeries() != null){
//解析数据
temperatureDataVos = getTemperature(queryResult);
}*/
return
gson
.
toJson
(
temperatures
);
}
//获取湿度数据
@ApiOperation
(
value
=
"获取湿度数据"
,
notes
=
"获取湿度数据"
)
@PostMapping
(
"/getHumidity"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
})
public
Object
getHumidity
(
@RequestBody
String
transportationNo
){
ResultGatewayVo
gatewayVo
=
circuitService
.
getByNo
(
transportationNo
);
String
device
=
gatewayVo
.
getType
()
+
"_"
+
gatewayVo
.
getSN
();
//获取tdl信息
List
<
String
>
devList
=
tdlDeviceService
.
getByGatewaySN
(
gatewayVo
.
getSN
(),
gatewayVo
.
getType
());
String
devcie
=
gatewayVo
.
getType
()+
"_"
+
gatewayVo
.
getSN
()
;
if
(
devList
.
size
()
==
0
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
"没有数据"
);
return
gson
.
toJson
(
fb
);
}
List
<
Humidity
>
humidities
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
devList
.
size
();
i
++){
Humidity
humidity
=
new
Humidity
();
humidity
.
setTDLSN
(
devList
.
get
(
i
));
String
sql
=
"SELECT \"h\" FROM \"tdl_policy\".\""
+
devcie
+
"\" where \"tdl\"=\'"
+
devList
.
get
(
i
)+
"\' ORDER BY time "
;
QueryResult
queryResult
=
influxDBTemplate
.
query
(
new
Query
(
sql
,
database
));
List
<
HumidityDataVo
>
humidityDataVos
=
new
ArrayList
<>();
if
(
queryResult
.
getResults
().
get
(
0
).
getSeries
()
!=
null
){
//解析数据
humidityDataVos
=
getHumidity
(
queryResult
);
}
humidity
.
setHumidityDataVoList
(
humidityDataVos
);
humidities
.
add
(
humidity
);
}
// //SELECT "h" FROM "tdl_policy"."WTD93LG_20180314" WHERE "tdl" = 'tdl-0A0B0C0D0F' ORDER BY time DESC
// String sql = "SELECT \"h\" FROM \"tdl_policy\".\""+devcie+"\" ORDER BY time ";
// QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
// List<HumidityDataVo> humidityDataVos = new ArrayList<>();
// if(queryResult.getResults().get(0).getSeries() != null){
// //解析数据
// humidityDataVos = getHumidity(queryResult);
// }
return
gson
.
toJson
(
humidities
);
}
//获取倾斜度数据
@ApiOperation
(
value
=
"获取倾斜度数据"
,
notes
=
"获取倾斜度数据"
)
@PostMapping
(
"/getTiltAngle"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
})
public
Object
getTiltAngle
(
@RequestBody
String
transportationNo
){
ResultGatewayVo
gatewayVo
=
circuitService
.
getByNo
(
transportationNo
);
String
device
=
gatewayVo
.
getType
()
+
"_"
+
gatewayVo
.
getSN
();
//获取tdl信息
List
<
String
>
devList
=
tdlDeviceService
.
getByGatewaySN
(
gatewayVo
.
getSN
(),
gatewayVo
.
getType
());
String
devcie
=
gatewayVo
.
getType
()+
"_"
+
gatewayVo
.
getSN
()
;
if
(
devList
.
size
()
==
0
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
"没有数据"
);
return
gson
.
toJson
(
fb
);
}
List
<
TiltAngle
>
tiltAngles
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
devList
.
size
();
i
++){
TiltAngle
tiltAngle
=
new
TiltAngle
();
tiltAngle
.
setTDLSN
(
devList
.
get
(
i
));
String
sql
=
"SELECT \"ta\" FROM \"tdl_policy\".\""
+
devcie
+
"\" where \"tdl\"=\'"
+
devList
.
get
(
i
)+
"\' ORDER BY time "
;
QueryResult
queryResult
=
influxDBTemplate
.
query
(
new
Query
(
sql
,
database
));
List
<
TiltAngleVo
>
tiltAngleVos
=
new
ArrayList
<>();
if
(
queryResult
.
getResults
().
get
(
0
).
getSeries
()
!=
null
){
//解析数据
tiltAngleVos
=
getTiltAngle
(
queryResult
);
}
tiltAngle
.
setShockEnergyVoList
(
tiltAngleVos
);
tiltAngles
.
add
(
tiltAngle
);
}
// String sql = "SELECT \"ta\" FROM \"tdl_policy\".\""+devcie+"\" ORDER BY time ";
// QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
// List<TiltAngleVo> tiltAngleVos = new ArrayList<>();
// if(queryResult.getResults().get(0).getSeries() != null){
// //解析数据
// tiltAngleVos = getTiltAngle(queryResult);
// }
return
gson
.
toJson
(
tiltAngles
);
}
//获取震动能量
@ApiOperation
(
value
=
"获取震动能量"
,
notes
=
"获取震动能量"
)
@PostMapping
(
"/getShockEnergy"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
})
public
Object
getShockEnergy
(
@RequestBody
String
transportationNo
){
ResultGatewayVo
gatewayVo
=
circuitService
.
getByNo
(
transportationNo
);
String
device
=
gatewayVo
.
getType
()
+
"_"
+
gatewayVo
.
getSN
();
//获取tdl信息
List
<
String
>
devList
=
tdlDeviceService
.
getByGatewaySN
(
gatewayVo
.
getSN
(),
gatewayVo
.
getType
());
String
devcie
=
gatewayVo
.
getType
()+
"_"
+
gatewayVo
.
getSN
()
;
if
(
devList
.
size
()
==
0
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
"没有数据"
);
return
gson
.
toJson
(
fb
);
}
List
<
ShockEnergy
>
shockEnergies
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
devList
.
size
();
i
++){
ShockEnergy
shockEnergy
=
new
ShockEnergy
();
shockEnergy
.
setTDLSN
(
devList
.
get
(
i
));
String
sql
=
"SELECT \"a0\" FROM \"tdl_policy\".\""
+
devcie
+
"\" where \"tdl\"=\'"
+
devList
.
get
(
i
)+
"\' ORDER BY time "
;
QueryResult
queryResult
=
influxDBTemplate
.
query
(
new
Query
(
sql
,
database
));
List
<
ShockEnergyVo
>
shockEnergyVos
=
new
ArrayList
<>();
if
(
queryResult
.
getResults
().
get
(
0
).
getSeries
()
!=
null
){
//解析数据
shockEnergyVos
=
getShockEnergy
(
queryResult
);
}
shockEnergy
.
setShockEnergyVoList
(
shockEnergyVos
);
shockEnergies
.
add
(
shockEnergy
);
}
// String sql = "SELECT \"a0\" FROM \"tdl_policy\".\""+devcie+"\" ORDER BY time ";
// QueryResult queryResult = influxDBTemplate.query(new Query(sql,database));
// List<ShockEnergyVo> shockEnergyVos = new ArrayList<>();
// if(queryResult.getResults().get(0).getSeries() != null){
// //解析数据
// shockEnergyVos = getShockEnergy(queryResult);
// }
return
gson
.
toJson
(
shockEnergies
);
}
//根据运输编号获取所有的报警数据
@ApiOperation
(
value
=
"根据运输编号获取所有的报警数据????"
,
notes
=
"根据运输编号获取所有的报警数据"
)
@PostMapping
(
"/getAlarmData"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
})
public
Object
getAlarmData
(
@RequestBody
String
transportationNo
){
//根据运输编号获取报警信息
List
<
AlarmLogVo
>
alarmLogVoList
=
alarmLogService
.
getByTransportationNo
(
transportationNo
);
return
gson
.
toJson
(
alarmLogVoList
);
}
//根据时间获取经纬度信息
@ApiOperation
(
value
=
"获取震动能量"
,
notes
=
"获取震动能量"
)
@PostMapping
(
"/getLocationByTime"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
})
public
Object
getLocationByTime
(
@RequestBody
LocationVo
locationVo
){
//获取线路信息
//获取网关以及tdl信息
ResultGatewayVo
gatewayVo
=
circuitService
.
getByNo
(
locationVo
.
getTransportationNo
());
ResultCircuitVo
resultCircuitVo
=
circuitService
.
getByTransportationNo
(
locationVo
.
getTransportationNo
());
String
device
=
gatewayVo
.
getType
()
+
"_"
+
gatewayVo
.
getSN
();
//获取tdl信息
List
<
String
>
devList
=
tdlDeviceService
.
getByGatewaySN
(
gatewayVo
.
getSN
(),
gatewayVo
.
getType
());
String
devcie
=
gatewayVo
.
getType
()+
"_"
+
gatewayVo
.
getSN
()
;
//根据时间获取坐标信息
String
sql
=
"SELECT \"lng\",\"lat\" FROM \"tdl_policy\".\""
+
devcie
+
"\" where time = "
+
locationVo
.
getTime
()
*
1000000
l
;
QueryResult
queryResult
=
influxDBTemplate
.
query
(
new
Query
(
sql
,
database
));
List
<
LocationMessageVo
>
locationDataVos
=
new
ArrayList
<>();
if
(
queryResult
.
getResults
().
get
(
0
).
getSeries
()
!=
null
){
List
<
List
<
Object
>>
values
=
getValues
(
queryResult
);
for
(
List
<
Object
>
value:
values
){
LocationMessageVo
messageVo
=
new
LocationMessageVo
();
messageVo
.
setTransportationNo
(
locationVo
.
getTransportationNo
());
messageVo
.
setGatewaySN
(
gatewayVo
.
getSN
());
messageVo
.
setTDLSN
(
devList
);
messageVo
.
setStartCity
(
resultCircuitVo
.
getStartCity
());
messageVo
.
setEndCity
(
resultCircuitVo
.
getEndCity
());
messageVo
.
setStartTime
(
resultCircuitVo
.
getStartTime
());
messageVo
.
setEndTime
(
resultCircuitVo
.
getEndTime
());
messageVo
.
setAlarmTime
(
Long
.
valueOf
(
parseTime
(
value
.
get
(
0
).
toString
())));
messageVo
.
setAlarmType
(
locationVo
.
getAlarmType
());
messageVo
.
setAlarmValue
(
locationVo
.
getVlaue
());
messageVo
.
setLng
(
value
.
get
(
1
)==
null
?
value
.
get
(
1
).
toString
()
:
""
);
messageVo
.
setLat
(
value
.
get
(
2
)==
null
?
value
.
get
(
2
).
toString
()
:
""
);
locationDataVos
.
add
(
messageVo
);
}
}
return
gson
.
toJson
(
locationDataVos
);
}
//获取温度、湿度、震动强度、震动能量、倾斜度
@PostMapping
(
"/getDeviceData"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
})
public
Object
getDeviceData
(
@RequestBody
String
transportationNo
){
//获取网关以及tdl信息
ResultGatewayVo
gatewayVo
=
circuitService
.
getByNo
(
transportationNo
);
String
device
=
gatewayVo
.
getType
()
+
"_"
+
gatewayVo
.
getSN
();
//获取tdl信息
List
<
String
>
devList
=
tdlDeviceService
.
getByGatewaySN
(
gatewayVo
.
getSN
(),
gatewayVo
.
getType
());
String
devcie
=
gatewayVo
.
getType
()+
"_"
+
gatewayVo
.
getSN
()
;
//SELECT "h" FROM "tdl_policy"."WTD93LG_20180314" WHERE "tdl" = 'tdl-0A0B0C0D0F' ORDER BY time DESC
String
sql
=
"SELECT \"t\",\"h\",\"p\",\"a0\",\"ta\" FROM \"tdl_policy\".\""
+
devcie
+
"\" where \"tdl\" = \'"
+
devList
.
get
(
0
)+
"\' ORDER BY time "
;
QueryResult
queryResult
=
influxDBTemplate
.
query
(
new
Query
(
sql
,
database
));
//解析经纬度数据
List
<
DeviceDataVo
>
deviceDataVos
=
new
ArrayList
<>();
if
(
queryResult
.
getResults
().
get
(
0
).
getSeries
()
!=
null
){
deviceDataVos
=
getDeviceData
(
queryResult
);
}
return
gson
.
toJson
(
deviceDataVos
);
}
//解析数据
public
List
<
LocationDataVo
>
getLocation
(
QueryResult
queryResult
){
List
<
List
<
Object
>>
values
=
getValues
(
queryResult
);
List
<
LocationDataVo
>
historyDataList
=
new
ArrayList
<>();
for
(
List
<
Object
>
value:
values
){
LocationDataVo
historyData
=
new
LocationDataVo
();
historyData
.
setTime
(
parseTime
(
value
.
get
(
0
).
toString
()));
historyData
.
setLng
(
Double
.
parseDouble
(
value
.
get
(
1
).
toString
()));
historyData
.
setLat
(
Double
.
parseDouble
(
value
.
get
(
2
).
toString
()));
historyData
.
setError
(
0
);
//没有预警
historyDataList
.
add
(
historyData
);
}
return
historyDataList
;
}
public
List
<
DeviceDataVo
>
getDeviceData
(
QueryResult
queryResult
){
List
<
List
<
Object
>>
values
=
getValues
(
queryResult
);
List
<
DeviceDataVo
>
historyDataList
=
new
ArrayList
<>();
for
(
List
<
Object
>
value:
values
){
DeviceDataVo
historyData
=
new
DeviceDataVo
();
historyData
.
setTime
(
parseTime
(
value
.
get
(
0
).
toString
()));
historyData
.
setTemperature
(
value
.
get
(
1
)==
null
?
""
:
value
.
get
(
1
).
toString
());
historyData
.
setHumidity
(
value
.
get
(
2
)==
null
?
""
:
value
.
get
(
2
).
toString
());
historyData
.
setPressure
(
value
.
get
(
3
)==
null
?
""
:
value
.
get
(
3
).
toString
());
historyData
.
setShockEnergy
(
value
.
get
(
4
)==
null
?
""
:
value
.
get
(
4
).
toString
());
historyData
.
setTiltAngle
(
value
.
get
(
5
)==
null
?
""
:
value
.
get
(
5
).
toString
());
historyDataList
.
add
(
historyData
);
}
return
historyDataList
;
}
public
List
<
TemperatureDataVo
>
getTemperature
(
QueryResult
queryResult
){
List
<
List
<
Object
>>
values
=
getValues
(
queryResult
);
List
<
TemperatureDataVo
>
historyDataList
=
new
ArrayList
<>();
for
(
List
<
Object
>
value:
values
){
TemperatureDataVo
historyData
=
new
TemperatureDataVo
();
historyData
.
setTime
(
parseTime
(
value
.
get
(
0
).
toString
()));
historyData
.
setValue
(
value
.
get
(
1
)==
null
?
""
:
value
.
get
(
1
).
toString
());
historyDataList
.
add
(
historyData
);
}
return
historyDataList
;
}
public
List
<
TiltAngleVo
>
getTiltAngle
(
QueryResult
queryResult
){
List
<
List
<
Object
>>
values
=
getValues
(
queryResult
);
List
<
TiltAngleVo
>
historyDataList
=
new
ArrayList
<>();
for
(
List
<
Object
>
value:
values
){
TiltAngleVo
historyData
=
new
TiltAngleVo
();
historyData
.
setTime
(
parseTime
(
value
.
get
(
0
).
toString
()));
historyData
.
setValue
(
value
.
get
(
1
)==
null
?
""
:
value
.
get
(
1
).
toString
());
historyDataList
.
add
(
historyData
);
}
return
historyDataList
;
}
public
List
<
ShockEnergyVo
>
getShockEnergy
(
QueryResult
queryResult
){
List
<
List
<
Object
>>
values
=
getValues
(
queryResult
);
List
<
ShockEnergyVo
>
historyDataList
=
new
ArrayList
<>();
for
(
List
<
Object
>
value:
values
){
ShockEnergyVo
historyData
=
new
ShockEnergyVo
();
historyData
.
setTime
(
parseTime
(
value
.
get
(
0
).
toString
()));
historyData
.
setValue
(
value
.
get
(
1
)==
null
?
""
:
value
.
get
(
1
).
toString
());
historyDataList
.
add
(
historyData
);
}
return
historyDataList
;
}
public
List
<
HumidityDataVo
>
getHumidity
(
QueryResult
queryResult
){
List
<
List
<
Object
>>
values
=
getValues
(
queryResult
);
List
<
HumidityDataVo
>
historyDataList
=
new
ArrayList
<>();
for
(
List
<
Object
>
value:
values
){
HumidityDataVo
historyData
=
new
HumidityDataVo
();
historyData
.
setTime
(
parseTime
(
value
.
get
(
0
).
toString
()));
historyData
.
setValue
(
value
.
get
(
1
)==
null
?
""
:
value
.
get
(
1
).
toString
());
historyDataList
.
add
(
historyData
);
}
return
historyDataList
;
}
//解析数据格式
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
;
}
//将utc时间转换成时间戳
public
static
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
());
}
}
//解析时间
public
String
parseTime
(
String
time
){
String
dateResult
=
null
;
try
{
dateResult
=
dateToStamp
(
time
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
logger
.
info
(
e
.
toString
());
fb
.
setCode
(
0
);
fb
.
setMessage
(
"解析时间异常"
);
}
return
dateResult
;
}
}
\ No newline at end of file
src/main/java/com/example/tdl/web/EquipmentBindingController.java
0 → 100644
View file @
f4a76c00
package
com
.
example
.
tdl
.
web
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.serializer.FloatArraySerializer
;
import
com.example.tdl.domain.dto.CommFeedback
;
import
com.example.tdl.domain.vo.*
;
import
com.example.tdl.service.ConfigService
;
import
com.example.tdl.service.GatewayService
;
import
com.example.tdl.service.TDLDeviceService
;
import
com.google.gson.Gson
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@RestController
@RequestMapping
(
"/equipmentBinding"
)
public
class
EquipmentBindingController
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
this
.
getClass
());
CommFeedback
fb
=
new
CommFeedback
();
Gson
gson
=
new
Gson
();
@Autowired
private
ConfigService
configService
;
@Autowired
private
GatewayService
gatewayService
;
@Autowired
private
TDLDeviceService
tdlDeviceService
;
@ApiOperation
(
value
=
"绑定gateWay和tdl"
,
notes
=
"绑定gateWay和tdl"
+
" SN:gateWay编号,"
+
" type:gateWay类型,"
+
" mode:1--运输/2--仓库,"
+
" TDLSN:tdl编号,"
+
" transportationNo:运输编号,"
+
" warehouseNo:仓库编号"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
})
@PostMapping
(
"/binding"
)
public
Object
binding
(
@RequestBody
BindingVo
bindingVo
){
//获取gateWay的信息
ResultGatewayVo
resultGatewayVo
=
gatewayService
.
getBySNAndType
(
bindingVo
.
getSN
(),
bindingVo
.
getType
());
if
(
resultGatewayVo
.
getUseScene
()
!=
0
&&
resultGatewayVo
.
getUseScene
()
!=
bindingVo
.
getMode
()){
fb
.
setCode
(
0
);
fb
.
setMessage
(
"该网关所属环境与当前不符"
);
return
gson
.
toJson
(
fb
);
}
//判断当前tdl是否有网关在使用
ResultTDLDeviceVo
resultTDLDeviceVo
=
tdlDeviceService
.
getByTDLSN
(
bindingVo
.
getTDLSN
());
if
(!
StringUtils
.
isEmpty
(
resultTDLDeviceVo
.
getGatewaySN
())){
fb
.
setCode
(
0
);
fb
.
setMessage
(
"该TDL已经被使用"
);
return
gson
.
toJson
(
fb
);
}
if
(
StringUtils
.
isEmpty
(
bindingVo
.
getTransportationNo
())
&&
!
StringUtils
.
isEmpty
(
bindingVo
.
getWarehouseNo
())){
bindingVo
.
setTransportationNo
(
""
);
}
else
if
(
StringUtils
.
isEmpty
(
bindingVo
.
getWarehouseNo
())
&&
!
StringUtils
.
isEmpty
(
bindingVo
.
getTransportationNo
())){
bindingVo
.
setWarehouseNo
(
""
);
}
//开始绑定
//获取gateway下的所有tdl的编号
List
<
String
>
devList
=
tdlDeviceService
.
getByGatewaySN
(
bindingVo
.
getSN
(),
bindingVo
.
getType
());
devList
.
add
(
bindingVo
.
getTDLSN
());
ConfigCMDVo
configCMDVo
=
new
ConfigCMDVo
(
"config"
,
5
,
15
,
devList
,
bindingVo
.
getMode
(),
System
.
currentTimeMillis
()/
1000
l
);
Map
<
Object
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"transportationNo"
,
bindingVo
.
getTransportationNo
());
map
.
put
(
"warehouseNo"
,
bindingVo
.
getWarehouseNo
());
map
.
put
(
"useScene"
,
bindingVo
.
getMode
());
map
.
put
(
"gSN"
,
bindingVo
.
getSN
());
map
.
put
(
"gType"
,
bindingVo
.
getType
());
map
.
put
(
"message"
,
gson
.
toJson
(
configCMDVo
));
map
.
put
(
"flag"
,
false
);
map
.
put
(
"resp"
,
null
);
map
.
put
(
"state"
,
1
);
map
.
put
(
"untie"
,
false
);
map
.
put
(
"TDLSN"
,
bindingVo
.
getTDLSN
());
map
.
put
(
"createTime"
,
System
.
currentTimeMillis
());
configService
.
addConfig
(
map
);
Map
<
Object
,
Object
>
msg
=
new
HashMap
<>();
msg
.
put
(
"msg"
,
map
.
get
(
"msg"
));
if
(
msg
.
get
(
"msg"
).
equals
(
"配置网关成功"
)){
fb
.
setCode
(
1
);
fb
.
setMessage
(
msg
.
get
(
"msg"
).
toString
());
}
else
{
fb
.
setCode
(
0
);
fb
.
setMessage
(
msg
.
get
(
"msg"
).
toString
());
}
return
gson
.
toJson
(
fb
);
}
@ApiOperation
(
value
=
"重置tdl"
,
notes
=
"重置tdl"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
})
@PostMapping
(
"/untie"
)
public
Object
untie
(
@RequestBody
String
TDLSN
){
JSONObject
jsonObject
=
JSON
.
parseObject
(
TDLSN
);
TDLSN
=(
String
)
jsonObject
.
get
(
"TDLSN"
);
//判断当前tdl是否有网关在使用
ResultTDLDeviceVo
resultTDLDeviceVo
=
tdlDeviceService
.
getByTDLSN
(
TDLSN
);
List
<
String
>
devList
=
tdlDeviceService
.
getByGatewaySN
(
resultTDLDeviceVo
.
getGatewaySN
(),
resultTDLDeviceVo
.
getGatewayType
());
ConfigVo
configVo
=
configService
.
getConfig
(
resultTDLDeviceVo
.
getGatewaySN
(),
resultTDLDeviceVo
.
getGatewayType
());
ConfigCMDVo
config
=
gson
.
fromJson
(
configVo
.
getMessage
(),
ConfigCMDVo
.
class
);
ConfigCMDVo
configCMDVo
;
Boolean
untie
=
false
;
if
(
devList
.
size
()>
1
){
devList
.
remove
(
TDLSN
);
configCMDVo
=
new
ConfigCMDVo
(
"config"
,
config
.
getGpsPeriod
(),
config
.
getGprsPeriod
(),
devList
,
config
.
getMode
(),
System
.
currentTimeMillis
()/
1000
l
);
}
else
{
configCMDVo
=
config
;
untie
=
true
;
}
Map
<
Object
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"gSN"
,
resultTDLDeviceVo
.
getGatewaySN
());
map
.
put
(
"gType"
,
resultTDLDeviceVo
.
getGatewayType
());
map
.
put
(
"message"
,
gson
.
toJson
(
configCMDVo
));
map
.
put
(
"untie"
,
untie
);
map
.
put
(
"TDLSN"
,
TDLSN
);
configService
.
updateConfig
(
map
);
Map
<
Object
,
Object
>
msg
=
new
HashMap
<>();
msg
.
put
(
"msg"
,
map
.
get
(
"msg"
));
if
(
msg
.
get
(
"msg"
).
equals
(
"解除网关成功"
)){
fb
.
setCode
(
1
);
fb
.
setMessage
(
msg
.
get
(
"msg"
).
toString
());
}
else
{
fb
.
setCode
(
0
);
fb
.
setMessage
(
msg
.
get
(
"msg"
).
toString
());
}
return
gson
.
toJson
(
fb
);
}
}
src/main/java/com/example/tdl/web/GatewayController.java
View file @
f4a76c00
...
@@ -18,7 +18,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
...
@@ -18,7 +18,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
@RestController
@RestController
...
...
src/main/java/com/example/tdl/web/HomePageController.java
View file @
f4a76c00
...
@@ -5,7 +5,7 @@ import com.example.tdl.domain.vo.AlarmLogVo;
...
@@ -5,7 +5,7 @@ import com.example.tdl.domain.vo.AlarmLogVo;
import
com.example.tdl.domain.vo.HomePageDataVo
;
import
com.example.tdl.domain.vo.HomePageDataVo
;
import
com.example.tdl.domain.vo.ResultRouteVo
;
import
com.example.tdl.domain.vo.ResultRouteVo
;
import
com.example.tdl.domain.vo.TermVo
;
import
com.example.tdl.domain.vo.TermVo
;
import
com.example.tdl.service.AlarmLogServ
ci
e
;
import
com.example.tdl.service.AlarmLogServ
ic
e
;
import
com.example.tdl.service.RouteService
;
import
com.example.tdl.service.RouteService
;
import
com.google.gson.Gson
;
import
com.google.gson.Gson
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParam
;
...
@@ -31,7 +31,7 @@ public class HomePageController {
...
@@ -31,7 +31,7 @@ public class HomePageController {
private
RouteService
routeService
;
private
RouteService
routeService
;
@Autowired
@Autowired
private
AlarmLogServ
ci
e
alarmLogServcie
;
private
AlarmLogServ
ic
e
alarmLogServcie
;
//获取当天所有的设备数据
//获取当天所有的设备数据
@ApiOperation
(
value
=
"获取所有的运输数据"
,
notes
=
"获取运输设备数据:"
+
@ApiOperation
(
value
=
"获取所有的运输数据"
,
notes
=
"获取运输设备数据:"
+
...
@@ -70,14 +70,14 @@ public class HomePageController {
...
@@ -70,14 +70,14 @@ public class HomePageController {
public
Object
getAll
(){
public
Object
getAll
(){
HomePageDataVo
dataVo
=
new
HomePageDataVo
();
HomePageDataVo
dataVo
=
new
HomePageDataVo
();
//获取所有的路线
//获取所有的路线
List
<
ResultRouteVo
>
routeVos
=
routeService
.
getAll
();
//所有的路线
//
List<ResultRouteVo> routeVos = routeService.getAll();//所有的路线
//List<ResultRouteVo> routeVoList = routeService.getAllRoute();//当天的数量
//List<ResultRouteVo> routeVoList = routeService.getAllRoute();//当天的数量
//获取所有的报警
//获取所有的报警
List
<
AlarmLogVo
>
alarmLogVos
=
alarmLogServcie
.
getAll
();
List
<
AlarmLogVo
>
alarmLogVos
=
alarmLogServcie
.
getAll
();
// 获取所有的路线数量
// 获取所有的路线数量
dataVo
.
setRouteVoList
(
routeVos
);
//路线列表
//
dataVo.setRouteVoList(routeVos);//路线列表
dataVo
.
setAlarmLogVoList
(
alarmLogVos
);
//报警列表
dataVo
.
setAlarmLogVoList
(
alarmLogVos
);
//报警列表
dataVo
.
setSum
(
routeVos
.
size
());
//总数量
//
dataVo.setSum(routeVos.size());//总数量
dataVo
.
setOnRoute
(
0
);
//在途数量
dataVo
.
setOnRoute
(
0
);
//在途数量
dataVo
.
setComplted
(
0
);
//已完成数量
dataVo
.
setComplted
(
0
);
//已完成数量
dataVo
.
setAlarmed
(
0
);
//报警数量
dataVo
.
setAlarmed
(
0
);
//报警数量
...
...
src/main/java/com/example/tdl/web/TDLDeviceController.java
View file @
f4a76c00
...
@@ -5,8 +5,6 @@ import com.alibaba.fastjson.JSON;
...
@@ -5,8 +5,6 @@ import com.alibaba.fastjson.JSON;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.example.tdl.domain.dto.CommFeedback
;
import
com.example.tdl.domain.dto.CommFeedback
;
import
com.example.tdl.domain.vo.*
;
import
com.example.tdl.domain.vo.*
;
import
com.example.tdl.entity.Route
;
import
com.example.tdl.service.RouteService
;
import
com.example.tdl.service.TDLDeviceService
;
import
com.example.tdl.service.TDLDeviceService
;
import
com.example.tdl.service.redis.TokenRedisService
;
import
com.example.tdl.service.redis.TokenRedisService
;
import
com.google.gson.Gson
;
import
com.google.gson.Gson
;
...
@@ -14,7 +12,6 @@ import io.swagger.annotations.ApiImplicitParam;
...
@@ -14,7 +12,6 @@ import io.swagger.annotations.ApiImplicitParam;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.shiro.SecurityUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -23,9 +20,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
...
@@ -23,9 +20,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletRequest
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
@RestController
@RestController
@RequestMapping
(
"/tdlDevice"
)
@RequestMapping
(
"/tdlDevice"
)
...
@@ -43,7 +37,6 @@ public class TDLDeviceController {
...
@@ -43,7 +37,6 @@ public class TDLDeviceController {
@Autowired
@Autowired
private
TokenRedisService
tokenRedisService
;
private
TokenRedisService
tokenRedisService
;
//查询TDL信息
//查询TDL信息
@ApiOperation
(
value
=
"查询TDL信息"
,
notes
=
"查询TDL信息,返回值说明:"
+
@ApiOperation
(
value
=
"查询TDL信息"
,
notes
=
"查询TDL信息,返回值说明:"
+
" TDLName:TDL名字,"
+
" TDLName:TDL名字,"
+
...
...
src/main/resources/application.properties
View file @
f4a76c00
...
@@ -15,7 +15,7 @@ mybatis.config-location=classpath:mybatis-config.xml
...
@@ -15,7 +15,7 @@ mybatis.config-location=classpath:mybatis-config.xml
# Redis服务器地址
# Redis服务器地址
tdl.redis.host
=
1
27.0.0.1
tdl.redis.host
=
1
92.168.1.16
# Redis数据库索引(默认为0)
# Redis数据库索引(默认为0)
tdl.redis.index
=
0
tdl.redis.index
=
0
# Redis服务器连接端口
# Redis服务器连接端口
...
@@ -51,9 +51,14 @@ tdl.mqtt.clientcrt = witcd.crt
...
@@ -51,9 +51,14 @@ tdl.mqtt.clientcrt = witcd.crt
# InfluxDB
# InfluxDB
tdl.influxdb.user
=
admin
spring.influxdb.username
=
admin
tdl.influxdb.password
=
Witium37774020
spring.influxdb.password
=
37774020
tdl.influxdb.host
=
http://192.168.1.11:8086
spring.influxdb.url
=
http://192.168.1.16:8086
tdl.influxdb.database
=
original
spring.influxdb.database
=
original
spring.influxdb.retentionPolicy
=
tdl_policy
spring.influxdb.connent-timeout
=
10
spring.influxdb.read-timeout
=
30
spring.influxdb.write-timeout
=
10
spring.influxdb.gzip
=
true
src/main/resources/mapper/AlarmLogMapper.xml
View file @
f4a76c00
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
insert into alarm_log
insert into alarm_log
values(
values(
null,
null,
#{
routeNumber
,jdbcType=VARCHAR},
#{
transportationNo
,jdbcType=VARCHAR},
#{routeName,jdbcType=VARCHAR},
#{routeName,jdbcType=VARCHAR},
#{description,jdbcType=VARCHAR},
#{description,jdbcType=VARCHAR},
#{data,jdbcType=FLOAT},
#{data,jdbcType=FLOAT},
...
...
src/main/resources/mapper/CircuitMapper.xml
View file @
f4a76c00
...
@@ -133,4 +133,11 @@
...
@@ -133,4 +133,11 @@
boxNo,containerNo,deliveryAddress,transportationType,circuitState,c.remark
boxNo,containerNo,deliveryAddress,transportationType,circuitState,c.remark
from circuit c,route r WHERE c.route_id=r.id AND r.state=1 AND c.state=1 AND transportationNo=#{transportationNo,jdbcType=VARCHAR}
from circuit c,route r WHERE c.route_id=r.id AND r.state=1 AND c.state=1 AND transportationNo=#{transportationNo,jdbcType=VARCHAR}
</select>
</select>
<select
id=
"getByNo"
parameterType=
"String"
resultType=
"com.example.tdl.domain.vo.ResultGatewayVo"
>
SELECT SN,`name`,type,state,bConfig,useScene,from_unixtime((createTime/1000),'%Y-%m-%d %T') createTime,from_unixtime((updateTime/1000),'%Y-%m-%d %T') updateTime
from gateway
WHERE id=(SELECT gateway_id from tdldevice where circuit_id =(SELECT id from circuit WHERE transportationNo=#{transportationNo,jdbcType=VARCHAR}))
</select>
</mapper>
</mapper>
\ No newline at end of file
src/main/resources/mapper/ConfigMapper.xml
View file @
f4a76c00
...
@@ -2,18 +2,26 @@
...
@@ -2,18 +2,26 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.example.tdl.mapper.ConfigMapper"
>
<mapper
namespace=
"com.example.tdl.mapper.ConfigMapper"
>
<!--绑定getway和tdl-->
<!--绑定getway和tdl-->
<insert
id=
"addConfig"
parameterType=
"com.example.tdl.domain.vo.ConfigVo"
>
<insert
id=
"addConfig"
parameterType=
"java.util.Map"
statementType=
"CALLABLE"
>
insert into config
<![CDATA[
values(
{
null,
call pro_addTDLGatewayLog(
#{gSN,jdbcType=VARCHAR},
#{transportationNo,mode=IN,jdbcType=VARCHAR},
#{gType,jdbcType=VARCHAR},
#{warehouseNo,mode=IN,jdbcType=VARCHAR},
#{message,jdbcType=VARCHAR},
#{useScene,mode=IN,jdbcType=INTEGER},
#{flag,jdbcType=INTEGER},
#{gSN,mode=IN,jdbcType=VARCHAR},
#{resp,jdbcType=INTEGER},
#{gType,mode=IN,jdbcType=VARCHAR},
#{state,jdbcType=INTEGER},
#{message,mode=IN,jdbcType=VARCHAR},
#{untie,jdbcType=INTEGER}
#{flag,mode=IN,jdbcType=INTEGER},
)
#{resp,mode=IN,jdbcType=INTEGER},
#{state,mode=IN,jdbcType=INTEGER},
#{untie,mode=IN,jdbcType=INTEGER},
#{TDLSN,mode=IN,jdbcType=VARCHAR},
#{createTime,mode=IN,jdbcType=BIGINT},
#{msg,mode=OUT,jdbcType=VARCHAR}
)
}
]]>
</insert>
</insert>
<!--获取绑定消息-->
<!--获取绑定消息-->
...
@@ -29,16 +37,44 @@
...
@@ -29,16 +37,44 @@
and state = 1;
and state = 1;
</update>
</update>
<update
id=
"updateConfig"
>
<!--重置tdl-->
update config set untie=#{untie,jdbcType=INTEGER}
<update
id=
"updateConfig"
parameterType=
"java.util.Map"
statementType=
"CALLABLE"
>
where gSN= #{gSN,jdbcType=VARCHAR}
<![CDATA[
and gType=#{gType,jdbcType=VARCHAR}
{
and state = 1;
call pro_updateTDLGatewayLog(
#{gSN,mode=IN,jdbcType=VARCHAR},
#{gType,mode=IN,jdbcType=VARCHAR},
#{message,mode=IN,jdbcType=VARCHAR},
#{untie,mode=IN,jdbcType=INTEGER},
#{TDLSN,mode=IN,jdbcType=VARCHAR},
#{msg,mode=OUT,jdbcType=VARCHAR}
)
}
]]>
</update>
</update>
<!--解绑成功-->
<update
id=
"delConfig"
parameterType=
"String"
>
<update
id=
"delConfig"
parameterType=
"String"
>
update config set state = 0 where gSN= #{gSN,jdbcType=VARCHAR} and gType=#{gType,jdbcType=VARCHAR} and state = 1;
update config set state = 0 where gSN= #{gSN,jdbcType=VARCHAR} and gType=#{gType,jdbcType=VARCHAR} and state = 1;
</update>
</update>
<!-- <insert id="addConfig" parameterType="com.example.tdl.domain.vo.ConfigVo">
insert into config
values(
null,
#{gSN,jdbcType=VARCHAR},
#{gType,jdbcType=VARCHAR},
#{message,jdbcType=VARCHAR},
#{flag,jdbcType=INTEGER},
#{resp,jdbcType=INTEGER},
#{state,jdbcType=INTEGER},
#{untie,jdbcType=INTEGER}
)
</insert>-->
<!--<update id="updateConfig">
update config set untie=#{untie,jdbcType=INTEGER}
where gSN= #{gSN,jdbcType=VARCHAR}
and gType=#{gType,jdbcType=VARCHAR}
and state = 1;
</update>-->
</mapper>
</mapper>
\ No newline at end of file
src/main/resources/mapper/ProbesMapper.xml
View file @
f4a76c00
...
@@ -61,6 +61,19 @@
...
@@ -61,6 +61,19 @@
</foreach>
)
</foreach>
)
</select>
</select>
<select
id=
"getByAliasList"
resultType=
"com.example.tdl.domain.vo.ProbesVo"
parameterType=
"String"
>
select port,unit,description,alias,type alarmUp alarmDown from probes where gateway_id =(
select id from gateway where SN=#{SN,jdbcType=VARCHAR} and type= #{type,jdbcType=VARCHAR})
and alias in
<foreach
collection=
"aliasList"
item=
"alias"
open=
"("
close=
")"
separator=
","
>
#{alias,jdbcType=VARCHAR}
</foreach>
ORDER BY FIELD(alias,
<foreach
collection=
"aliasList"
item=
"alias"
separator=
","
>
#{alias,jdbcType=VARCHAR}
</foreach>
)
</select>
<select
id=
"getCountByGateway"
parameterType=
"String"
resultType=
"java.lang.Integer"
>
<select
id=
"getCountByGateway"
parameterType=
"String"
resultType=
"java.lang.Integer"
>
select COUNT(*) from probes where gateway_id =(
select COUNT(*) from probes where gateway_id =(
SELECT id FROM gateway WHERE SN = #{SN,jdbcType=VARCHAR} AND type = #{type,jdbcType=VARCHAR})
SELECT id FROM gateway WHERE SN = #{SN,jdbcType=VARCHAR} AND type = #{type,jdbcType=VARCHAR})
...
...
src/main/resources/mapper/RoleMapper.xml
View file @
f4a76c00
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.example.tdl.mapper.RoleMapper"
>
<mapper
namespace=
"com.example.tdl.mapper.RoleMapper"
>
<!--查询所有角色名-->
<!--查询所有角色名-->
<select
id=
"getAllRoleName"
resultType=
"
String
"
>
<select
id=
"getAllRoleName"
resultType=
"
com.example.tdl.domain.vo.RoleNameVo
"
>
SELECT roleName from role;
SELECT roleName from role;
</select>
</select>
...
...
src/main/resources/mapper/TDLDeviceMapper.xml
View file @
f4a76c00
...
@@ -55,4 +55,8 @@
...
@@ -55,4 +55,8 @@
from tdldevice t
from tdldevice t
WHERE TDLSN=#{TDLSN,jdbcType=VARCHAR}
WHERE TDLSN=#{TDLSN,jdbcType=VARCHAR}
</select>
</select>
<select
id=
"getByGatewaySN"
parameterType=
"String"
resultType=
"String"
>
select TDLSN from tdldevice t,gateway g where t.gateway_id = g.id and g.SN =#{SN,jdbcType=VARCHAR} and g.type=#{type,jdbcType=VARCHAR}
</select>
</mapper>
</mapper>
\ No newline at end of file
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