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
ce7d2c94
Commit
ce7d2c94
authored
Jun 06, 2018
by
zhuangzhuang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
6.6--修改获取仓库详情
parent
a39f3b50
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
210 additions
and
28 deletions
+210
-28
TDLDeviceDetailVo.java
...ain/java/com/example/tdl/domain/vo/TDLDeviceDetailVo.java
+10
-0
WarehouseLogVo.java
src/main/java/com/example/tdl/domain/vo/WarehouseLogVo.java
+64
-0
TDLLogMapper.java
src/main/java/com/example/tdl/mapper/TDLLogMapper.java
+3
-4
TDLLogService.java
src/main/java/com/example/tdl/service/TDLLogService.java
+6
-4
PicUploadController.java
src/main/java/com/example/tdl/web/PicUploadController.java
+68
-0
WarehouseController.java
src/main/java/com/example/tdl/web/WarehouseController.java
+50
-20
TDLLogMapper.xml
src/main/resources/mapper/TDLLogMapper.xml
+9
-0
No files found.
src/main/java/com/example/tdl/domain/vo/TDLDeviceDetailVo.java
View file @
ce7d2c94
...
...
@@ -11,6 +11,8 @@ public class TDLDeviceDetailVo {
private
String
time
;
private
String
gatewaySN
;
public
String
getTDLSN
()
{
return
TDLSN
;
}
...
...
@@ -50,4 +52,12 @@ public class TDLDeviceDetailVo {
public
void
setTime
(
String
time
)
{
this
.
time
=
time
;
}
public
String
getGatewaySN
()
{
return
gatewaySN
;
}
public
void
setGatewaySN
(
String
gatewaySN
)
{
this
.
gatewaySN
=
gatewaySN
;
}
}
src/main/java/com/example/tdl/domain/vo/WarehouseLogVo.java
0 → 100644
View file @
ce7d2c94
package
com
.
example
.
tdl
.
domain
.
vo
;
public
class
WarehouseLogVo
{
private
String
warehouseNo
;
private
String
SN
;
private
String
type
;
private
String
device
;
private
Long
createTime
;
private
Long
endTime
;
public
String
getWarehouseNo
()
{
return
warehouseNo
;
}
public
void
setWarehouseNo
(
String
warehouseNo
)
{
this
.
warehouseNo
=
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
String
getDevice
()
{
return
device
;
}
public
void
setDevice
(
String
device
)
{
this
.
device
=
device
;
}
public
Long
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
Long
createTime
)
{
this
.
createTime
=
createTime
;
}
public
Long
getEndTime
()
{
return
endTime
;
}
public
void
setEndTime
(
Long
endTime
)
{
this
.
endTime
=
endTime
;
}
}
src/main/java/com/example/tdl/mapper/TDLLogMapper.java
View file @
ce7d2c94
package
com
.
example
.
tdl
.
mapper
;
import
com.example.tdl.domain.vo.DelAlarmVo
;
import
com.example.tdl.domain.vo.ResultAlarmVo
;
import
com.example.tdl.domain.vo.ResultGatewayVo
;
import
com.example.tdl.domain.vo.TDLLogVo
;
import
com.example.tdl.domain.vo.*
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
...
...
@@ -24,4 +21,6 @@ public interface TDLLogMapper {
ResultAlarmVo
getByTdl
(
@Param
(
"transportationNo"
)
String
transportationNo
,
@Param
(
"TDLSN"
)
String
TDLSN
);
List
<
WarehouseLogVo
>
getByWarehouse
(
String
warehouseNo
);
}
src/main/java/com/example/tdl/service/TDLLogService.java
View file @
ce7d2c94
package
com
.
example
.
tdl
.
service
;
import
com.example.tdl.domain.vo.DelAlarmVo
;
import
com.example.tdl.domain.vo.ResultAlarmVo
;
import
com.example.tdl.domain.vo.ResultGatewayVo
;
import
com.example.tdl.domain.vo.TDLLogVo
;
import
com.example.tdl.domain.vo.*
;
import
com.example.tdl.mapper.TDLLogMapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -41,4 +38,9 @@ public class TDLLogService {
public
ResultAlarmVo
getByTdl
(
String
transportationNo
,
String
TdlSN
){
return
tdlLogMapper
.
getByTdl
(
transportationNo
,
TdlSN
);
}
public
List
<
WarehouseLogVo
>
getByWarehouse
(
String
warehouseNo
){
return
tdlLogMapper
.
getByWarehouse
(
warehouseNo
);
}
}
src/main/java/com/example/tdl/web/PicUploadController.java
View file @
ce7d2c94
...
...
@@ -17,6 +17,10 @@ import org.springframework.web.bind.annotation.RequestParam;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.imageio.ImageIO
;
import
java.awt.image.BufferedImage
;
import
java.io.IOException
;
@RestController
(
"/picUpload"
)
public
class
PicUploadController
{
...
...
@@ -60,6 +64,38 @@ public class PicUploadController {
fb
.
setMessage
(
"上传图片大小不能超过5M!"
);
return
gson
.
toJson
(
fb
);
}
try
{
BufferedImage
sourceImg
=
ImageIO
.
read
(
multipartFile
.
getInputStream
());
// 仓库 150*120 //货车 90*60
if
(
sourceImg
==
null
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
"上传图片格式不正确"
);
}
else
{
if
(
"truck"
.
equals
(
imageType
)){
if
(
sourceImg
.
getHeight
()>
90
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
"上传图片尺寸不正确"
);
}
if
(
sourceImg
.
getWidth
()>
60
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
"上传图片尺寸不正确"
);
}
}
else
if
(
"warehouse"
.
equals
(
imageType
)){
if
(
sourceImg
.
getHeight
()>
150
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
"上传图片尺寸不正确"
);
}
if
(
sourceImg
.
getWidth
()>
120
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
"上传图片尺寸不正确"
);
}
}
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
fb
.
setCode
(
0
);
fb
.
setMessage
(
"上传图片格式不正确"
);
}
// 校验图片格式
boolean
isLegal
=
false
;
// 判断文件后缀名是否符合
...
...
@@ -123,6 +159,38 @@ public class PicUploadController {
fb
.
setMessage
(
"上传图片大小不能超过5M!"
);
return
gson
.
toJson
(
fb
);
}
try
{
BufferedImage
sourceImg
=
ImageIO
.
read
(
multipartFile
.
getInputStream
());
// 仓库 150*120 //货车 90*60
if
(
sourceImg
==
null
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
"上传图片格式不正确"
);
}
else
{
if
(
"truck"
.
equals
(
imageType
)){
if
(
sourceImg
.
getHeight
()>
90
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
"上传图片尺寸不正确"
);
}
if
(
sourceImg
.
getWidth
()>
60
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
"上传图片尺寸不正确"
);
}
}
else
if
(
"warehouse"
.
equals
(
imageType
)){
if
(
sourceImg
.
getHeight
()>
150
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
"上传图片尺寸不正确"
);
}
if
(
sourceImg
.
getWidth
()>
120
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
"上传图片尺寸不正确"
);
}
}
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
fb
.
setCode
(
0
);
fb
.
setMessage
(
"上传图片格式不正确"
);
}
boolean
isLegal
=
false
;
// 判断文件后缀名是否符合
for
(
String
type
:
IMAGE_TYPE
)
{
...
...
src/main/java/com/example/tdl/web/WarehouseController.java
View file @
ce7d2c94
...
...
@@ -67,6 +67,8 @@ public class WarehouseController {
@Autowired
private
InfluxDBTemplate
influxDBTemplate
;
private
TDLLogService
tdlLogService
;
private
final
static
String
database
=
"original"
;
//查询所有仓库信息
...
...
@@ -274,6 +276,7 @@ public class WarehouseController {
" humidity: 湿度,"
+
" time: 时间,"
+
" tdlsn: TDL编号"
+
" gatewaySN:网关编号"
+
" }"
+
" ],"
+
" sn: 设备编号"
+
...
...
@@ -288,35 +291,61 @@ public class WarehouseController {
String
token
=
request
.
getHeader
(
"Account_token"
);
String
datum
=
tokenRedisService
.
get
(
"TOKEN_"
+
token
);
UserRedisVo
userRedisVo
=
gson
.
fromJson
(
datum
,
UserRedisVo
.
class
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
warehouseNo
);
warehouseNo
=(
String
)
jsonObject
.
get
(
"warehouseNo"
);
if
(
StringUtils
.
isEmpty
(
warehouseNo
)){
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"warehouseNo"
));
return
gson
.
toJson
(
fb
);
}
JSONObject
jsonObject
=
JSON
.
parseObject
(
warehouseNo
);
warehouseNo
=(
String
)
jsonObject
.
get
(
"warehouseNo"
);
if
(
warehouseService
.
getWarehouseNo
(
warehouseNo
)
==
0
){
fb
.
setCode
(
0
);
fb
.
setMessage
(
i18n
.
getMessage
(
request
,
"Nonexistent"
));
return
gson
.
toJson
(
fb
);
}
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
);
//获取
List
<
WarehouseLogVo
>
list
=
tdlLogService
.
getByWarehouse
(
warehouseNo
);
List
<
GatewayOnLineVo
>
gatewayOnLineVos
=
new
ArrayList
<>();
for
(
int
a
=
0
;
a
<
list
.
size
();
a
++){
if
(
list
.
get
(
a
)
==
null
){
continue
;
}
if
(
list
.
get
(
a
).
getEndTime
()!=
null
){
continue
;
}
GatewayOnLineVo
gatewayOnLineVo
=
new
GatewayOnLineVo
();
gatewayOnLineVo
.
setSN
(
list
.
get
(
a
).
getSN
());
gatewayOnLineVo
.
setType
(
list
.
get
(
a
).
getType
());
Object
data
=
infoRedisService
.
getHash
(
"DeviceOnline"
,
list
.
get
(
a
).
getDevice
()
);
if
(
data
!=
null
){
OnlineVo
onlineVo
=
gson
.
fromJson
(
data
.
toString
(),
OnlineVo
.
class
);
if
(
onlineVo
.
getOnline
()
==
1
){
gatewayOnLineVos
.
get
(
a
).
setState
(
7
);
gatewayOnLineVo
.
setState
(
7
);
}
else
{
gatewayOnLineVo
s
.
get
(
a
)
.
setState
(
6
);
gatewayOnLineVo
.
setState
(
6
);
}
}
else
{
gatewayOnLineVo
s
.
get
(
a
)
.
setState
(
6
);
gatewayOnLineVo
.
setState
(
6
);
}
String
sql
=
"SELECT \"battery\" FROM \"tdl_policy\".\""
+
device
+
"\" ORDER BY time DESC LIMIT 1"
;
String
sql
=
"SELECT \"battery\" FROM \"tdl_policy\".\""
+
list
.
get
(
a
).
getDevice
()
+
"\" 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
());
if
(
Double
.
valueOf
(
queryResult
.
getResults
().
get
(
0
).
getSeries
().
get
(
0
).
getValues
().
get
(
0
).
get
(
1
).
toString
())>
0
){
gatewayOnLineVo
.
setBattery
(
queryResult
.
getResults
().
get
(
0
).
getSeries
().
get
(
0
).
getValues
().
get
(
0
).
get
(
1
)==
null
?
"NA"
:
queryResult
.
getResults
().
get
(
0
).
getSeries
().
get
(
0
).
getValues
().
get
(
0
).
get
(
1
).
toString
());
}
else
{
gatewayOnLineVo
.
setBattery
(
"NA"
);
}
}
else
{
gatewayOnLineVo
s
.
get
(
a
).
setBattery
(
"
"
);
gatewayOnLineVo
.
setBattery
(
"NA
"
);
}
List
<
String
>
tdls
=
tdlDeviceService
.
getByGatewaySN
(
gatewayOnLineVos
.
get
(
a
).
getSN
(),
gatewayOnLineVos
.
get
(
a
).
getType
());
List
<
String
>
tdls
=
tdlDeviceService
.
getByGatewaySN
(
list
.
get
(
a
).
getSN
(),
list
.
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"
;
tdlDeviceDetailVo
.
setGatewaySN
(
list
.
get
(
a
).
getSN
());
String
sqls
=
"SELECT \"b\", \"T\", \"h\" FROM \"tdl_policy\".\""
+
list
.
get
(
a
).
getDevice
()
+
"\" 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
()));
...
...
@@ -324,15 +353,16 @@ public class WarehouseController {
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
.
set
Pressure
(
"
"
);
tdlDeviceDetailVo
.
setHumidity
(
""
);
tdlDeviceDetailVo
.
setTime
(
"
NA
"
);
tdlDeviceDetailVo
.
setPressure
(
"
NA
"
);
tdlDeviceDetailVo
.
set
Temperature
(
"NA
"
);
tdlDeviceDetailVo
.
setHumidity
(
"
NA
"
);
}
tdlDeviceDetailVo
.
setTDLSN
(
tdls
.
get
(
b
));
tdlDeviceDetailVo
.
setTDLSN
(
tdls
.
get
(
b
)
.
replace
(
"TDL-"
,
""
).
trim
()
);
tdlDeviceDetailVos
.
add
(
tdlDeviceDetailVo
);
}
gatewayOnLineVos
.
get
(
a
).
setTdlDeviceDetailVos
(
tdlDeviceDetailVos
);
gatewayOnLineVo
.
setTdlDeviceDetailVos
(
tdlDeviceDetailVos
);
gatewayOnLineVos
.
add
(
gatewayOnLineVo
);
}
warehouseDetailVo
.
setGatewayOnLineVos
(
gatewayOnLineVos
);
return
warehouseDetailVo
;
...
...
src/main/resources/mapper/TDLLogMapper.xml
View file @
ce7d2c94
...
...
@@ -41,4 +41,13 @@
and transportationNo = #{transportationNo,jdbcType=VARCHAR}
and TDLSN = #{TDLSN,jdbcType=VARCHAR}
</select>
<select
id=
"getByWarehouse"
parameterType=
"String"
resultType=
"com.example.tdl.domain.vo.WarehouseLogVo"
>
select DISTINCT CONCAT( gatewaytype,"_",gatewaySN) device, tgl.gatewaySN SN,gatewaytype type, w.warehouseNo
from tdl_gateway_log tgl,warehouse w
where tgl.warehouseNo = w.warehouseNo
and w.warehouseNo=#{warehouseNo,jdbcType=VARCHAR}
and ISNULL(endTime)
</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