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
c4352c26
Commit
c4352c26
authored
May 28, 2018
by
chenying
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
5.28仓库实时数据
parent
43ef55d1
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
554 additions
and
33 deletions
+554
-33
GatewayOnLineVo.java
src/main/java/com/example/tdl/domain/vo/GatewayOnLineVo.java
+55
-0
TDLDeviceDetailVo.java
...ain/java/com/example/tdl/domain/vo/TDLDeviceDetailVo.java
+53
-0
WarehouseDataVo.java
src/main/java/com/example/tdl/domain/vo/WarehouseDataVo.java
+27
-0
WarehouseDetailVo.java
...ain/java/com/example/tdl/domain/vo/WarehouseDetailVo.java
+85
-0
WarehouseGatewayDateVo.java
...ava/com/example/tdl/domain/vo/WarehouseGatewayDateVo.java
+35
-0
WarehouseTDLDetailVo.java
.../java/com/example/tdl/domain/vo/WarehouseTDLDetailVo.java
+25
-0
WarehouseTimeAndDataVo.java
...ava/com/example/tdl/domain/vo/WarehouseTimeAndDataVo.java
+24
-0
GatewayMapper.java
src/main/java/com/example/tdl/mapper/GatewayMapper.java
+2
-0
TDLDeviceMapper.java
src/main/java/com/example/tdl/mapper/TDLDeviceMapper.java
+1
-0
WarehouseMapper.java
src/main/java/com/example/tdl/mapper/WarehouseMapper.java
+1
-0
GatewayService.java
src/main/java/com/example/tdl/service/GatewayService.java
+4
-0
TDLDeviceService.java
src/main/java/com/example/tdl/service/TDLDeviceService.java
+1
-0
WarehouseService.java
src/main/java/com/example/tdl/service/WarehouseService.java
+4
-0
TDLDeviceController.java
src/main/java/com/example/tdl/web/TDLDeviceController.java
+6
-0
WarehouseController.java
src/main/java/com/example/tdl/web/WarehouseController.java
+198
-15
messages_zh_CN.properties
src/main/resources/i18n/messages_zh_CN.properties
+7
-7
GatewayMapper.xml
src/main/resources/mapper/GatewayMapper.xml
+7
-0
TDLDeviceMapper.xml
src/main/resources/mapper/TDLDeviceMapper.xml
+2
-1
WarehouseMapper.xml
src/main/resources/mapper/WarehouseMapper.xml
+17
-10
No files found.
src/main/java/com/example/tdl/domain/vo/GatewayOnLineVo.java
0 → 100644
View file @
c4352c26
package
com
.
example
.
tdl
.
domain
.
vo
;
import
java.util.List
;
public
class
GatewayOnLineVo
{
private
String
SN
;
private
String
type
;
private
Integer
state
;
private
String
battery
;
private
List
<
TDLDeviceDetailVo
>
tdlDeviceDetailVos
;
public
List
<
TDLDeviceDetailVo
>
getTdlDeviceDetailVos
()
{
return
tdlDeviceDetailVos
;
}
public
void
setTdlDeviceDetailVos
(
List
<
TDLDeviceDetailVo
>
tdlDeviceDetailVos
)
{
this
.
tdlDeviceDetailVos
=
tdlDeviceDetailVos
;
}
public
String
getBattery
()
{
return
battery
;
}
public
void
setBattery
(
String
battery
)
{
this
.
battery
=
battery
;
}
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
getState
()
{
return
state
;
}
public
void
setState
(
Integer
state
)
{
this
.
state
=
state
;
}
}
src/main/java/com/example/tdl/domain/vo/TDLDeviceDetailVo.java
0 → 100644
View file @
c4352c26
package
com
.
example
.
tdl
.
domain
.
vo
;
public
class
TDLDeviceDetailVo
{
private
String
TDLSN
;
private
String
pressure
;
private
String
temperature
;
private
String
humidity
;
private
String
time
;
public
String
getTDLSN
()
{
return
TDLSN
;
}
public
void
setTDLSN
(
String
TDLSN
)
{
this
.
TDLSN
=
TDLSN
;
}
public
String
getPressure
()
{
return
pressure
;
}
public
void
setPressure
(
String
pressure
)
{
this
.
pressure
=
pressure
;
}
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
getTime
()
{
return
time
;
}
public
void
setTime
(
String
time
)
{
this
.
time
=
time
;
}
}
src/main/java/com/example/tdl/domain/vo/WarehouseDataVo.java
0 → 100644
View file @
c4352c26
package
com
.
example
.
tdl
.
domain
.
vo
;
import
java.util.List
;
public
class
WarehouseDataVo
{
private
String
TDLSN
;
private
List
<
WarehouseTDLDetailVo
>
warehouseTDLDetailVos
;
public
String
getTDLSN
()
{
return
TDLSN
;
}
public
void
setTDLSN
(
String
TDLSN
)
{
this
.
TDLSN
=
TDLSN
;
}
public
List
<
WarehouseTDLDetailVo
>
getWarehouseTDLDetailVos
()
{
return
warehouseTDLDetailVos
;
}
public
void
setWarehouseTDLDetailVos
(
List
<
WarehouseTDLDetailVo
>
warehouseTDLDetailVos
)
{
this
.
warehouseTDLDetailVos
=
warehouseTDLDetailVos
;
}
}
src/main/java/com/example/tdl/domain/vo/WarehouseDetailVo.java
0 → 100644
View file @
c4352c26
package
com
.
example
.
tdl
.
domain
.
vo
;
import
java.util.List
;
public
class
WarehouseDetailVo
{
private
String
warehouseNo
;
private
String
warehouseName
;
private
String
country
;
private
String
city
;
private
String
addressDetail
;
private
Integer
gatewayCounts
;
private
Integer
tdlCounts
;
private
List
<
GatewayOnLineVo
>
gatewayOnLineVos
;
public
List
<
GatewayOnLineVo
>
getGatewayOnLineVos
()
{
return
gatewayOnLineVos
;
}
public
void
setGatewayOnLineVos
(
List
<
GatewayOnLineVo
>
gatewayOnLineVos
)
{
this
.
gatewayOnLineVos
=
gatewayOnLineVos
;
}
public
String
getWarehouseNo
()
{
return
warehouseNo
;
}
public
void
setWarehouseNo
(
String
warehouseNo
)
{
this
.
warehouseNo
=
warehouseNo
;
}
public
String
getWarehouseName
()
{
return
warehouseName
;
}
public
void
setWarehouseName
(
String
warehouseName
)
{
this
.
warehouseName
=
warehouseName
;
}
public
String
getCountry
()
{
return
country
;
}
public
void
setCountry
(
String
country
)
{
this
.
country
=
country
;
}
public
String
getCity
()
{
return
city
;
}
public
void
setCity
(
String
city
)
{
this
.
city
=
city
;
}
public
String
getAddressDetail
()
{
return
addressDetail
;
}
public
void
setAddressDetail
(
String
addressDetail
)
{
this
.
addressDetail
=
addressDetail
;
}
public
Integer
getGatewayCounts
()
{
return
gatewayCounts
;
}
public
void
setGatewayCounts
(
Integer
gatewayCounts
)
{
this
.
gatewayCounts
=
gatewayCounts
;
}
public
Integer
getTdlCounts
()
{
return
tdlCounts
;
}
public
void
setTdlCounts
(
Integer
tdlCounts
)
{
this
.
tdlCounts
=
tdlCounts
;
}
}
src/main/java/com/example/tdl/domain/vo/WarehouseGatewayDateVo.java
0 → 100644
View file @
c4352c26
package
com
.
example
.
tdl
.
domain
.
vo
;
import
java.util.List
;
public
class
WarehouseGatewayDateVo
{
private
String
gSN
;
private
String
type
;
private
List
<
WarehouseDataVo
>
warehouseDataVos
;
public
String
getgSN
()
{
return
gSN
;
}
public
void
setgSN
(
String
gSN
)
{
this
.
gSN
=
gSN
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
List
<
WarehouseDataVo
>
getWarehouseDataVos
()
{
return
warehouseDataVos
;
}
public
void
setWarehouseDataVos
(
List
<
WarehouseDataVo
>
warehouseDataVos
)
{
this
.
warehouseDataVos
=
warehouseDataVos
;
}
}
src/main/java/com/example/tdl/domain/vo/WarehouseTDLDetailVo.java
0 → 100644
View file @
c4352c26
package
com
.
example
.
tdl
.
domain
.
vo
;
import
java.util.List
;
public
class
WarehouseTDLDetailVo
{
private
String
description
;
private
List
<
WarehouseTimeAndDataVo
>
timeAndValuesVos
;
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
List
<
WarehouseTimeAndDataVo
>
getTimeAndValuesVos
()
{
return
timeAndValuesVos
;
}
public
void
setTimeAndValuesVos
(
List
<
WarehouseTimeAndDataVo
>
timeAndValuesVos
)
{
this
.
timeAndValuesVos
=
timeAndValuesVos
;
}
}
src/main/java/com/example/tdl/domain/vo/WarehouseTimeAndDataVo.java
0 → 100644
View file @
c4352c26
package
com
.
example
.
tdl
.
domain
.
vo
;
public
class
WarehouseTimeAndDataVo
{
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/mapper/GatewayMapper.java
View file @
c4352c26
...
...
@@ -32,4 +32,6 @@ public interface GatewayMapper {
List
<
GatewaySNVo
>
getUnusedGateway
(
@Param
(
"SN"
)
String
SN
,
@Param
(
"companyNo"
)
String
companyNo
);
int
updateCompany
(
UpdateGatewayCompanyVo
updateGatewayCompanyVo
);
List
<
GatewayOnLineVo
>
getByWarehouseNo
(
@Param
(
"warehouseNo"
)
String
warehouseNo
);
}
src/main/java/com/example/tdl/mapper/TDLDeviceMapper.java
View file @
c4352c26
...
...
@@ -32,4 +32,5 @@ public interface TDLDeviceMapper {
ResultTDLDeviceVo
getByTransportationNo
(
String
transportationNo
);
int
updateCompany
(
@Param
(
"TDLSN"
)
String
TDLSN
,
@Param
(
"companyNo"
)
String
companyNo
);
}
src/main/java/com/example/tdl/mapper/WarehouseMapper.java
View file @
c4352c26
...
...
@@ -45,4 +45,5 @@ public interface WarehouseMapper {
Integer
updateImg
(
@Param
(
"warehouseNo"
)
String
warehouseNo
,
@Param
(
"img"
)
String
img
,
@Param
(
"updateTime"
)
Long
updateTime
);
WarehouseDetailVo
getWarehouseDetailByNo
(
@Param
(
"warehouseNo"
)
String
warehouseNo
);
}
src/main/java/com/example/tdl/service/GatewayService.java
View file @
c4352c26
...
...
@@ -62,4 +62,8 @@ public class GatewayService {
public
int
updateCompany
(
UpdateGatewayCompanyVo
updateGatewayCompanyVo
){
return
gatewayMapper
.
updateCompany
(
updateGatewayCompanyVo
);
}
public
List
<
GatewayOnLineVo
>
getByWarehouseNo
(
String
warehouseNo
){
return
gatewayMapper
.
getByWarehouseNo
(
warehouseNo
);
}
}
src/main/java/com/example/tdl/service/TDLDeviceService.java
View file @
c4352c26
...
...
@@ -60,4 +60,5 @@ public class TDLDeviceService {
public
int
updateCompany
(
String
TDLSN
,
String
companyNo
){
return
tdlDeviceMapper
.
updateCompany
(
TDLSN
,
companyNo
);
}
}
src/main/java/com/example/tdl/service/WarehouseService.java
View file @
c4352c26
...
...
@@ -79,4 +79,8 @@ public class WarehouseService {
public
Integer
updateImg
(
String
warehouseNo
,
String
img
,
Long
updateTime
){
return
warehouseMapper
.
updateImg
(
warehouseNo
,
img
,
updateTime
);
}
public
WarehouseDetailVo
getWarehouseDetailByNo
(
String
warehouseNo
){
return
warehouseMapper
.
getWarehouseDetailByNo
(
warehouseNo
);
}
}
src/main/java/com/example/tdl/web/TDLDeviceController.java
View file @
c4352c26
...
...
@@ -179,6 +179,12 @@ public class TDLDeviceController {
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"TDLSN"
));
return
gson
.
toJson
(
fb
);
}
Object
[]
o
={
TDLSN
};
if
(
tdlDeviceService
.
getByTDLSN
(
TDLSN
).
getUseScene
()!=
0
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
o
,
"tdlUsed"
));
return
gson
.
toJson
(
fb
);
}
int
a
=
tdlDeviceService
.
delTDLDevice
(
TDLSN
);
if
(
a
>
0
){
fb
.
setCode
(
1
);
...
...
src/main/java/com/example/tdl/web/WarehouseController.java
View file @
c4352c26
...
...
@@ -6,21 +6,25 @@ import com.alibaba.fastjson.JSONObject;
import
com.example.tdl.domain.dto.CommFeedback
;
import
com.example.tdl.domain.vo.*
;
import
com.example.tdl.service.*
;
import
com.example.tdl.service.redis.InfoRedisService
;
import
com.example.tdl.service.redis.TokenRedisService
;
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.influxdb.dto.Query
;
import
org.influxdb.dto.QueryResult
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.influxdb.InfluxDBTemplate
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
import
java.
util.HashMap
;
import
java.
util.Lis
t
;
import
java.util.
Map
;
import
java.
text.ParseException
;
import
java.
text.SimpleDateForma
t
;
import
java.util.
*
;
@RestController
@RequestMapping
(
"/warehouse"
)
...
...
@@ -47,9 +51,20 @@ public class WarehouseController {
@Autowired
private
GatewayService
gatewayService
;
@Autowired
private
TDLDeviceService
tdlDeviceService
;
@Autowired
private
InfoRedisService
infoRedisService
;
@Autowired
private
UserService
userService
;
@Autowired
private
InfluxDBTemplate
influxDBTemplate
;
private
final
static
String
database
=
"original"
;
//查询所有仓库信息
@ApiOperation
(
value
=
"查询所有仓库信息"
,
notes
=
"查询所有仓库信息,返回值说明:"
+
" warehouseName:仓库名,"
+
...
...
@@ -176,7 +191,7 @@ public class WarehouseController {
}
//根据仓库编号获取仓库信息
@ApiOperation
(
value
=
"根据
条件查询仓库信息"
,
notes
=
"根据条件查询
仓库信息,传值说明:"
)
@ApiOperation
(
value
=
"根据
仓库编号获取仓库信息"
,
notes
=
"根据仓库编号获取
仓库信息,传值说明:"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
})
...
...
@@ -185,8 +200,54 @@ public class WarehouseController {
String
token
=
request
.
getHeader
(
"Account_token"
);
String
datum
=
tokenRedisService
.
get
(
"TOKEN_"
+
token
);
UserRedisVo
userRedisVo
=
gson
.
fromJson
(
datum
,
UserRedisVo
.
class
);
return
gson
.
toJson
(
fb
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
warehouseNo
);
warehouseNo
=(
String
)
jsonObject
.
get
(
"warehouseNo"
);
WarehouseDetailVo
warehouseDetailVo
=
warehouseService
.
getWarehouseDetailByNo
(
warehouseNo
);
List
<
GatewayOnLineVo
>
gatewayOnLineVos
=
gatewayService
.
getByWarehouseNo
(
warehouseNo
);
for
(
int
a
=
0
;
a
<
gatewayOnLineVos
.
size
();
a
++){
String
device
=
gatewayOnLineVos
.
get
(
a
).
getType
()
+
"_"
+
gatewayOnLineVos
.
get
(
a
).
getSN
();
Object
data
=
infoRedisService
.
getHash
(
"DeviceOnline"
,
device
);
if
(
data
!=
null
){
OnlineVo
onlineVo
=
gson
.
fromJson
(
data
.
toString
(),
OnlineVo
.
class
);
if
(
onlineVo
.
getOnline
()
==
1
){
gatewayOnLineVos
.
get
(
a
).
setState
(
7
);
}
else
{
gatewayOnLineVos
.
get
(
a
).
setState
(
6
);
}
}
else
{
gatewayOnLineVos
.
get
(
a
).
setState
(
6
);
}
String
sql
=
"SELECT \"battery\" FROM \"tdl_policy\".\""
+
device
+
"\" ORDER BY time DESC LIMIT 1"
;
QueryResult
queryResult
=
influxDBTemplate
.
query
(
new
Query
(
sql
,
database
));
if
(
queryResult
.
getResults
().
get
(
0
).
getSeries
()
!=
null
)
{
gatewayOnLineVos
.
get
(
a
).
setBattery
(
queryResult
.
getResults
().
get
(
0
).
getSeries
().
get
(
0
).
getValues
().
get
(
0
).
get
(
1
).
toString
());
}
else
{
gatewayOnLineVos
.
get
(
a
).
setBattery
(
""
);
}
List
<
String
>
tdls
=
tdlDeviceService
.
getByGatewaySN
(
gatewayOnLineVos
.
get
(
a
).
getSN
(),
gatewayOnLineVos
.
get
(
a
).
getType
());
List
<
TDLDeviceDetailVo
>
tdlDeviceDetailVos
=
new
ArrayList
<>();
for
(
int
b
=
0
;
b
<
tdls
.
size
();
b
++){
TDLDeviceDetailVo
tdlDeviceDetailVo
=
new
TDLDeviceDetailVo
();
String
sqls
=
"SELECT \"b\", \"T\", \"h\" FROM \"tdl_policy\".\""
+
device
+
"\" WHERE (\"tdl\" = '"
+
tdls
.
get
(
b
)+
"') ORDER BY time DESC LIMIT 1"
;
QueryResult
queryResults
=
influxDBTemplate
.
query
(
new
Query
(
sqls
,
database
));
if
(
queryResults
.
getResults
().
get
(
0
).
getSeries
()
!=
null
)
{
tdlDeviceDetailVo
.
setTime
(
parseTime
(
queryResults
.
getResults
().
get
(
0
).
getSeries
().
get
(
0
).
getValues
().
get
(
0
).
get
(
0
).
toString
()));
tdlDeviceDetailVo
.
setPressure
(
queryResults
.
getResults
().
get
(
0
).
getSeries
().
get
(
0
).
getValues
().
get
(
0
).
get
(
1
).
toString
());
tdlDeviceDetailVo
.
setTemperature
(
queryResults
.
getResults
().
get
(
0
).
getSeries
().
get
(
0
).
getValues
().
get
(
0
).
get
(
2
).
toString
());
tdlDeviceDetailVo
.
setHumidity
(
queryResults
.
getResults
().
get
(
0
).
getSeries
().
get
(
0
).
getValues
().
get
(
0
).
get
(
3
).
toString
());
}
else
{
tdlDeviceDetailVo
.
setTime
(
""
);
tdlDeviceDetailVo
.
setPressure
(
""
);
tdlDeviceDetailVo
.
setPressure
(
""
);
tdlDeviceDetailVo
.
setHumidity
(
""
);
}
tdlDeviceDetailVo
.
setTDLSN
(
tdls
.
get
(
b
));
tdlDeviceDetailVos
.
add
(
tdlDeviceDetailVo
);
}
gatewayOnLineVos
.
get
(
a
).
setTdlDeviceDetailVos
(
tdlDeviceDetailVos
);
}
warehouseDetailVo
.
setGatewayOnLineVos
(
gatewayOnLineVos
);
return
warehouseDetailVo
;
}
//获取某个仓库的网关
...
...
@@ -413,8 +474,6 @@ public class WarehouseController {
}
//根据仓库编号修改仓库信息
@ApiOperation
(
value
=
"根据仓库编号修改仓库信息"
,
notes
=
"根据仓库编号修改仓库信息,updatTime不用传,传值说明:"
+
" warehouseNo:需要修改的仓库编号,"
+
...
...
@@ -608,8 +667,7 @@ public class WarehouseController {
return
gson
.
toJson
(
fb
);
}
// 删除仓库信息
//删除仓库信息
@ApiOperation
(
value
=
"删除仓库信息"
,
notes
=
"删除仓库信息,只用传仓库编号"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
...
...
@@ -648,8 +706,7 @@ public class WarehouseController {
return
gson
.
toJson
(
fb
);
}
//添加网关
@ApiOperation
(
value
=
"添加网关"
,
notes
=
"添加网关,传值:"
+
"warehouseNo:仓库编号"
+
"SN:网关编号"
)
...
...
@@ -700,8 +757,6 @@ public class WarehouseController {
return
gson
.
toJson
(
fb
);
}
//绑定报警联系人
@ApiOperation
(
value
=
"绑定报警联系人"
,
notes
=
"绑定报警联系人,传值:"
+
"warehouseNo:仓库编号"
+
...
...
@@ -736,7 +791,7 @@ public class WarehouseController {
fb
.
setMessage
(
"用户名不存在"
);
return
gson
.
toJson
(
fb
);
}
userNameVar
=
userNameVar
+
warehouseUserVo
.
getUserNameList
().
get
(
i
)
+
"
"
;
userNameVar
=
userNameVar
+
warehouseUserVo
.
getUserNameList
().
get
(
i
)
+
"
&
"
;
}
Map
<
Object
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"warehouseNo"
,
warehouseUserVo
.
getWarehouseNo
());
...
...
@@ -755,7 +810,110 @@ public class WarehouseController {
return
gson
.
toJson
(
fb
);
}
// String tdl="";
// for (int i=0;i<tdls.size();i++){
// if (i!=tdls.size()-1){
// tdl=tdl+tdls.get(i)+"' or \"tdl\"='";
// }else{
// tdl=tdl+tdls.get(i);
// }
// }
//根据仓库编号获取仓库实时数据
@ApiOperation
(
value
=
"根据仓库编号获取仓库信息"
,
notes
=
"根据仓库编号获取仓库信息,传值说明:"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"Account_token"
,
value
=
"token"
,
required
=
true
,
dataType
=
"String"
),
})
@PostMapping
(
"/getWarehouseData"
)
public
Object
getWarehouseData
(
@RequestBody
String
warehouseNo
,
HttpServletRequest
request
){
JSONObject
jsonObject
=
JSON
.
parseObject
(
warehouseNo
);
warehouseNo
=(
String
)
jsonObject
.
get
(
"warehouseNo"
);
List
<
WarehouseGatewayDateVo
>
warehouseGatewayDateVoList
=
new
ArrayList
<>();
List
<
GatewayOnLineVo
>
gatewayOnLineVos
=
gatewayService
.
getByWarehouseNo
(
warehouseNo
);
for
(
int
a
=
0
;
a
<
gatewayOnLineVos
.
size
();
a
++){
WarehouseGatewayDateVo
warehouseGatewayDateVo
=
new
WarehouseGatewayDateVo
();
warehouseGatewayDateVo
.
setgSN
(
gatewayOnLineVos
.
get
(
a
).
getSN
());
warehouseGatewayDateVo
.
setType
(
gatewayOnLineVos
.
get
(
a
).
getType
());
String
device
=
gatewayOnLineVos
.
get
(
a
).
getType
()
+
"_"
+
gatewayOnLineVos
.
get
(
a
).
getSN
();
List
<
String
>
tdls
=
tdlDeviceService
.
getByGatewaySN
(
gatewayOnLineVos
.
get
(
a
).
getSN
(),
gatewayOnLineVos
.
get
(
a
).
getType
());
List
<
WarehouseTimeAndDataVo
>
warehouseTimeAndDataVos
=
new
ArrayList
<>();
List
<
WarehouseTimeAndDataVo
>
warehouseTimeAndDataVos1
=
new
ArrayList
<>();
List
<
WarehouseTDLDetailVo
>
warehouseTDLDetailVos
=
new
ArrayList
<>();
List
<
WarehouseDataVo
>
warehouseDataVos
=
new
ArrayList
<>();
for
(
int
b
=
0
;
b
<
tdls
.
size
();
b
++){
String
sqls
=
"SELECT \"tdl\",\"T\", \"h\" FROM \"tdl_policy\".\""
+
device
+
"\" WHERE (\"tdl\" = 'TDL-1701110082608') ORDER BY time DESC "
;
QueryResult
queryResults
=
influxDBTemplate
.
query
(
new
Query
(
sqls
,
database
));
WarehouseDataVo
warehouseDataVo
=
new
WarehouseDataVo
();
if
(
queryResults
.
getResults
().
get
(
0
).
getSeries
()
!=
null
){
//解析数据
WarehouseTDLDetailVo
warehouseTDLDetailVo
=
new
WarehouseTDLDetailVo
();
warehouseTimeAndDataVos
=
getData
(
queryResults
);
warehouseTDLDetailVo
.
setDescription
(
"temperature"
);
warehouseTDLDetailVo
.
setTimeAndValuesVos
(
warehouseTimeAndDataVos
);
warehouseTDLDetailVos
.
add
(
warehouseTDLDetailVo
);
WarehouseTDLDetailVo
warehouseTDLDetailVo1
=
new
WarehouseTDLDetailVo
();
warehouseTimeAndDataVos1
=
getDatas
(
queryResults
);
warehouseTDLDetailVo1
.
setDescription
(
"humidity"
);
warehouseTDLDetailVo1
.
setTimeAndValuesVos
(
warehouseTimeAndDataVos1
);
warehouseTDLDetailVos
.
add
(
warehouseTDLDetailVo1
);
}
warehouseDataVo
.
setTDLSN
(
tdls
.
get
(
b
));
warehouseDataVo
.
setWarehouseTDLDetailVos
(
warehouseTDLDetailVos
);
warehouseDataVos
.
add
(
warehouseDataVo
);
}
warehouseGatewayDateVo
.
setWarehouseDataVos
(
warehouseDataVos
);
warehouseGatewayDateVoList
.
add
(
warehouseGatewayDateVo
);
}
return
warehouseGatewayDateVoList
;
}
public
List
<
WarehouseTimeAndDataVo
>
getData
(
QueryResult
queryResult
){
List
<
List
<
Object
>>
values
=
getValues
(
queryResult
);
List
<
WarehouseTimeAndDataVo
>
historyDataList
=
new
ArrayList
<>();
for
(
List
<
Object
>
value:
values
){
WarehouseTimeAndDataVo
warehouseTimeAndDataVo
=
new
WarehouseTimeAndDataVo
();
warehouseTimeAndDataVo
.
setTime
(
parseTime
(
value
.
get
(
0
).
toString
()));
warehouseTimeAndDataVo
.
setValue
(
value
.
get
(
2
)==
null
?
""
:
value
.
get
(
2
).
toString
());
historyDataList
.
add
(
warehouseTimeAndDataVo
);
}
return
historyDataList
;
}
public
List
<
WarehouseTimeAndDataVo
>
getDatas
(
QueryResult
queryResult
){
List
<
List
<
Object
>>
values
=
getValues
(
queryResult
);
List
<
WarehouseTimeAndDataVo
>
historyDataList
=
new
ArrayList
<>();
for
(
List
<
Object
>
value:
values
){
WarehouseTimeAndDataVo
warehouseTimeAndDataVo
=
new
WarehouseTimeAndDataVo
();
warehouseTimeAndDataVo
.
setTime
(
parseTime
(
value
.
get
(
0
).
toString
()));
warehouseTimeAndDataVo
.
setValue
(
value
.
get
(
3
)==
null
?
""
:
value
.
get
(
3
).
toString
());
historyDataList
.
add
(
warehouseTimeAndDataVo
);
}
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
;
}
//生成仓库编号
public
String
getWarehouseNo
(){
...
...
@@ -768,4 +926,29 @@ public class WarehouseController {
}
return
warehouseNo
;
}
//解析时间
public
String
parseTime
(
String
time
){
String
dateResult
=
null
;
try
{
dateResult
=
dateToStamp
(
time
);
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
logger
.
info
(
e
.
toString
());
fb
.
setCode
(
0
);
fb
.
setMessage
(
"解析时间异常"
);
}
return
dateResult
;
}
//将utc时间转换成时间戳
public
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
());
}
}
src/main/resources/i18n/messages_zh_CN.properties
View file @
c4352c26
...
...
@@ -63,16 +63,16 @@ gateway = \u7F51\u5173\u5E8F\u5217\u53F7\u4E0D\u80FD\u4E3A\u7A7A
gatewayExist
=
\u
8BE5
\u
7F51
\u5173\u
5E8F
\u5217\u
53F7
\u
4E0D
\u
5B58
\u5728
gatewayMounted
=
\u
8BE5
\u
7F51
\u5173\u
672A
\u6302\u
8F7D
gatewayConsistent
=
\u
8BE5
\u
7F51
\u5173\u7684\u
4F7F
\u7528\u
573A
\u
666F
\u
4E0E
\u
5F53
\u
524D
\u
4E0D
\u
7B26
tdl
=
TDL
\u
5E8F
\u5217\u
53F7
\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
tdlExist
=
{0}
TDL
\u
4E0D
\u
5B58
\u5728
tdlUsed
=
{0}
\u7684
TDL
\u
5DF2
\u
7ECF
\u
88AB
\u
4F7F
\u7528
tdl
=
\u
4F20
\u
611F
\u5668
\u
5E8F
\u5217\u
53F7
\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
tdlExist
=
{0}
\u
4F20
\u
611F
\u5668
\u
4E0D
\u
5B58
\u5728
tdlUsed
=
{0}
\u7684
\u
4F20
\u
611F
\u5668
\u
5DF2
\u
7ECF
\u
88AB
\u
4F7F
\u7528
cargoNo
=
\u
8D27
\u7269\u
7F16
\u
53F7
\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
plateNo
=
\u
8F66
\u
724C
\u
53F7
\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
cargoName
=
\u
8D27
\u7269\u
522B
\u
540D
\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
circuitSuccess
=
\u
6DFB
\u
52A0
\u
7EBF
\u
8DEF
\u6210\u
529F
circuitFailure
=
\u
6DFB
\u
52A0
\u
7EBF
\u
8DEF
\u5931\u
8D25
notStarted
=
\u
7EBF
\u
8DEF
\u
672A
\u
5F00
\u
59CB
\u
8FD0
\u
8F93
notBound
=
\u
8BE5
\u
7EBF
\u
8DEF
\u
672A
\u
7ED1
\u
5B9A
\u
7F51
\u5173\u6216\u8005
tdl
notBound
=
\u
8BE5
\u
7EBF
\u
8DEF
\u
672A
\u
7ED1
\u
5B9A
\u
7F51
\u5173\u6216\u8005
\u
4F20
\u
611F
\u5668
endCircuitSuccess
=
\u
7EBF
\u
8DEF
\u
7ED3
\u
675F
\u6210\u
529F
endCircuitFailure
=
\u
7EBF
\u
8DEF
\u
7ED3
\u
675F
\u5931\u
8D25
transportation
=
\u
8FD0
\u
8F93
\u
65B9
\u
5F0F
\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
...
...
@@ -84,7 +84,7 @@ evaluateSuccess = \u8BC4\u4EF7\u6210\u529F
evaluateFailure
=
\u
8BC4
\u
4EF7
\u5931\u
8D25
circuitState
=
\u9700\u8981\u
67E5
\u
8BE2
\u7684\u
7EBF
\u
8DEF
\u
72B6
\u6001\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
inTransit
=
\u
8BE5
\u
7EBF
\u
8DEF
\u
6B63
\u5728\u
8FD0
\u
8F93
\u
4E2D
\u
FF0C
\u
4E0D
\u
80FD
\u5220\u9664
bindTDL
=
\u
8BE5
\u
7EBF
\u
8DEF
\u
672A
\u
7ED1
\u
5B9A
tdl
bindTDL
=
\u
8BE5
\u
7EBF
\u
8DEF
\u
672A
\u
7ED1
\u
5B9A
\u
4F20
\u
611F
\u5668
bindGateway
=
\u
8BE5
\u
7EBF
\u
8DEF
\u
672A
\u
7ED1
\u
5B9A
\u
7F51
\u5173
circuitDeleteSuccess
=
\u
7EBF
\u
8DEF
\u5220\u9664\u6210\u
529F
circuitDeleteFailure
=
\u
7EBF
\u
8DEF
\u5220\u9664\u5931\u
8D25
...
...
@@ -209,8 +209,8 @@ isUseing=\u8BBE\u5907\u5728\u6302\u8F7D
updateGatewayCompanySuccess
=
\u
7F51
\u5173\u5206\u
914D
\u
516C
\u
53F8
\u6210\u
529F
updateGatewayCompanyFailure
=
\u
7F51
\u5173\u5206\u
914D
\u
516C
\u
53F8
\u5931\u
8D25
#TDL
TDLSN
=
TDL
\u
7F16
\u
53F7
\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
TDLName
=
TDL
\u
540D
\u
5B57
\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
TDLSN
=
\u
4F20
\u
611F
\u5668
\u
7F16
\u
53F7
\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
TDLName
=
\u
4F20
\u
611F
\u5668
\u
540D
\u
5B57
\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
updateTDLSuccess
=
\u
4FEE
\u6539\u
7F51
\u5173\u6210\u
529F
updateTDLFailure
=
\u
4FEE
\u6539\u
7F51
\u5173\u5931\u
8D25
deleteTDLSuccess
=
\u5220\u9664\u
7F51
\u5173\u6210\u
529F
...
...
src/main/resources/mapper/GatewayMapper.xml
View file @
c4352c26
...
...
@@ -108,6 +108,13 @@
WHERE SN=#{SN,jdbcType=VARCHAR} AND type=#{type,jdbcType=VARCHAR}
</update>
<!--根据仓库编号查询网关信息-->
<select
id=
"getByWarehouseNo"
parameterType=
"String"
resultType=
"com.example.tdl.domain.vo.GatewayOnLineVo"
>
SELECT SN,type from gateway
WHERE id IN (SELECT gateway_id from gateway_warehouse where warehouse_id=(
SELECT id from warehouse WHERE warehouseNo=#{warehouseNo,jdbcType=VARCHAR}))
</select>
<!-- <insert id="addGateway" parameterType="com.example.tdl.domain.vo.AddGatewayVo">
INSERT into gateway VALUES (
...
...
src/main/resources/mapper/TDLDeviceMapper.xml
View file @
c4352c26
...
...
@@ -107,3 +107,4 @@
WHERE TDLSN=#{TDLSN,jdbcType=VARCHAR}
</update>
</mapper>
src/main/resources/mapper/WarehouseMapper.xml
View file @
c4352c26
...
...
@@ -47,7 +47,6 @@
select count(warehouseNo) from warehouse where warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
</select>
<select
id=
"getByWarehouseName"
parameterType=
"String"
resultType=
"com.example.tdl.domain.vo.ResultWarehouseVo"
>
select warehouseNo,w.img,warehouseName,c.country,c.city,CONCAT_WS("-",c.country,c.city) regions ,w.addressDetail,r.regionName,lng,lat,a.alarmType,property,
type,hardwareLevel,areaIndoor,areaRack,areaOutdoor,areaPlanIndoor,office,timeZone,warehouseInfo,companyName,w.remark
...
...
@@ -248,7 +247,15 @@
</select>
<update
id=
"updateImg"
>
UPDATE warehouse set img = #{img,jdbcType=VARCHAR}, updateTime =#{updateTime,mode=IN,jdbcType=BIGINT} where warehouseNo= #{warehouseNo,jdbcType=VARCHAR}
UPDATE warehouse set img = #{img,jdbcType=VARCHAR}, updateTime =#{updateTime,mode=IN,jdbcType=BIGINT}
where warehouseNo= #{warehouseNo,jdbcType=VARCHAR}
</update>
<select
id=
"getWarehouseDetailByNo"
parameterType=
"String"
resultType=
"com.example.tdl.domain.vo.WarehouseDetailVo"
>
SELECT warehouseNo,warehouseName,c.country,c.city,addressDetail,(SELECT COUNT(id) from gateway_warehouse WHERE warehouse_id=w.id) gatewayCounts,
(SELECT COUNT(id) FROM tdldevice WHERE warehouse_id=w.id) tdlCounts
from warehouse w INNER JOIN city c ON w.city_id=c.id
where warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
</select>
</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