Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
znks
Project
Project
Details
Activity
Releases
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
王夏晖
znks
Commits
04d68aef
Commit
04d68aef
authored
Sep 17, 2018
by
王夏晖
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.ZnksServer完成,接受客户端解码未完成
parent
207cf28d
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
130 additions
and
66 deletions
+130
-66
DeviceController.java
...ain/java/com/adc/da/znks/controller/DeviceController.java
+1
-0
GatewayController.java
...in/java/com/adc/da/znks/controller/GatewayController.java
+2
-2
InstructionsController.java
...va/com/adc/da/znks/controller/InstructionsController.java
+14
-8
DeviceDao.java
adc-da-main/src/main/java/com/adc/da/znks/dao/DeviceDao.java
+11
-1
LockRecordDao.java
...main/src/main/java/com/adc/da/znks/dao/LockRecordDao.java
+1
-1
Device.java
adc-da-main/src/main/java/com/adc/da/znks/entity/Device.java
+10
-0
DeviceService.java
.../src/main/java/com/adc/da/znks/service/DeviceService.java
+6
-4
LockRecordService.java
.../main/java/com/adc/da/znks/service/LockRecordService.java
+5
-1
AppPushUtils.java
...main/src/main/java/com/adc/da/znks/util/AppPushUtils.java
+1
-1
Test.java
adc-da-main/src/main/java/com/adc/da/znks/util/Test.java
+7
-2
ServerHandler.java
...c/main/java/com/adc/da/znks/util/netty/ServerHandler.java
+52
-34
DeviceMapper.xml
...n/src/main/resources/mybatis/mapper/znks/DeviceMapper.xml
+17
-3
LockRecordMapper.xml
...c/main/resources/mybatis/mapper/znks/LockRecordMapper.xml
+3
-9
No files found.
adc-da-main/src/main/java/com/adc/da/znks/controller/DeviceController.java
View file @
04d68aef
...
...
@@ -38,6 +38,7 @@ public class DeviceController extends BaseController<Device> {
try
{
deviceVO
.
setId
(
UUID
.
randomUUID
());
deviceVO
.
setUserId
(
user
.
getId
());
deviceVO
.
setMacAddress
(
deviceService
.
getMacByPhone
(
deviceVO
.
getPhoneNumber
()));
deviceService
.
insertSelective
(
deviceVO
);
return
GenResponse
.
success
();
}
catch
(
Exception
e
)
{
...
...
adc-da-main/src/main/java/com/adc/da/znks/controller/GatewayController.java
View file @
04d68aef
...
...
@@ -61,8 +61,8 @@ public class GatewayController extends BaseController<Gateway> {
}
@PostMapping
(
"/u
dp
ate"
)
public
ResponseEntity
u
dp
ate
(
String
phoneNumber
,
String
macAddress
)
{
@PostMapping
(
"/u
pd
ate"
)
public
ResponseEntity
u
pd
ate
(
String
phoneNumber
,
String
macAddress
)
{
User
user
=
userService
.
getByPhoneNumber
(
phoneNumber
);
if
(
user
!=
null
){
if
(
gatewayService
.
updateMac
(
user
.
getId
(),
macAddress
.
toUpperCase
())){
...
...
adc-da-main/src/main/java/com/adc/da/znks/controller/InstructionsController.java
View file @
04d68aef
...
...
@@ -6,8 +6,11 @@ import com.adc.da.znks.service.UserService;
import
com.adc.da.znks.util.GenResponse
;
import
com.adc.da.znks.util.SocketUtils
;
import
com.adc.da.znks.util.SystemValue
;
import
com.adc.da.znks.util.netty.ServerHandler
;
import
io.netty.channel.Channel
;
import
io.swagger.annotations.Api
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
@@ -28,6 +31,8 @@ public class InstructionsController {
@Autowired
private
UserService
userService
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
InstructionsController
.
class
);
@GetMapping
(
"/loginGateway"
)
public
ResponseEntity
<
Boolean
>
loginGateway
(
String
phoneNumber
)
{
User
user
=
userService
.
getByPhoneNumber
(
phoneNumber
);
...
...
@@ -76,6 +81,7 @@ public class InstructionsController {
open
[
5
]
=
0x00
;
open
[
6
]
=
(
byte
)
number
;
open
[
7
]
=
0x2d
;
logger
.
info
(
"设备吗学习指令发送:++++++++++++++++++++++++++++++++"
+
SocketUtils
.
bytesToHex
(
open
,
0
,
open
.
length
));
String
mac
=
getMacByPhone
(
phoneNumber
);
if
(
mac
==
null
){
return
GenResponse
.
fail
(
"网关mac获取失败"
);
...
...
@@ -84,7 +90,7 @@ public class InstructionsController {
System
.
out
.
println
(
"open status : "
+
ch
.
isOpen
());
System
.
out
.
println
(
"active status : "
+
ch
.
isActive
());
ch
.
writeAndFlush
(
open
);
return
GenResponse
.
fail
(
"开锁成功"
);
return
GenResponse
.
success
(
);
}
else
{
return
GenResponse
.
fail
(
"开锁异常"
);
}
...
...
@@ -112,7 +118,7 @@ public class InstructionsController {
System
.
out
.
println
(
"open status : "
+
ch
.
isOpen
());
System
.
out
.
println
(
"active status : "
+
ch
.
isActive
());
ch
.
writeAndFlush
(
open
);
return
GenResponse
.
fail
(
"安防码学习成功"
);
return
GenResponse
.
success
(
);
}
else
{
return
GenResponse
.
fail
(
"安防码学习异常"
);
}
...
...
@@ -145,7 +151,7 @@ public class InstructionsController {
System
.
out
.
println
(
"open status : "
+
ch
.
isOpen
());
System
.
out
.
println
(
"active status : "
+
ch
.
isActive
());
ch
.
writeAndFlush
(
open
);
return
GenResponse
.
fail
(
"布防成功"
);
return
GenResponse
.
success
(
);
}
else
{
return
GenResponse
.
fail
(
"布防失败"
);
}
...
...
@@ -178,7 +184,7 @@ public class InstructionsController {
System
.
out
.
println
(
"open status : "
+
ch
.
isOpen
());
System
.
out
.
println
(
"active status : "
+
ch
.
isActive
());
ch
.
writeAndFlush
(
open
);
return
GenResponse
.
fail
(
"撤防成功"
);
return
GenResponse
.
success
(
);
}
else
{
return
GenResponse
.
fail
(
"撤防失败"
);
}
...
...
@@ -209,7 +215,7 @@ public class InstructionsController {
System
.
out
.
println
(
"open status : "
+
ch
.
isOpen
());
System
.
out
.
println
(
"active status : "
+
ch
.
isActive
());
ch
.
writeAndFlush
(
open
);
return
GenResponse
.
fail
(
"进入组网成功"
);
return
GenResponse
.
success
(
);
}
else
{
return
GenResponse
.
fail
(
"进入组网失败"
);
}
...
...
@@ -240,7 +246,7 @@ public class InstructionsController {
System
.
out
.
println
(
"open status : "
+
ch
.
isOpen
());
System
.
out
.
println
(
"active status : "
+
ch
.
isActive
());
ch
.
writeAndFlush
(
open
);
return
GenResponse
.
fail
(
"退出组网成功"
);
return
GenResponse
.
success
(
);
}
else
{
return
GenResponse
.
fail
(
"退出组网失败"
);
}
...
...
@@ -271,7 +277,7 @@ public class InstructionsController {
System
.
out
.
println
(
"open status : "
+
ch
.
isOpen
());
System
.
out
.
println
(
"active status : "
+
ch
.
isActive
());
ch
.
writeAndFlush
(
open
);
return
GenResponse
.
fail
(
"ZigBee恢复出厂成功"
);
return
GenResponse
.
success
(
);
}
else
{
return
GenResponse
.
fail
(
"zigBee恢复出厂失败"
);
}
...
...
@@ -302,7 +308,7 @@ public class InstructionsController {
System
.
out
.
println
(
"open status : "
+
ch
.
isOpen
());
System
.
out
.
println
(
"active status : "
+
ch
.
isActive
());
ch
.
writeAndFlush
(
open
);
return
GenResponse
.
fail
(
"Wifi恢复出厂成功"
);
return
GenResponse
.
success
(
);
}
else
{
return
GenResponse
.
fail
(
"wifi恢复出厂失败"
);
}
...
...
adc-da-main/src/main/java/com/adc/da/znks/dao/DeviceDao.java
View file @
04d68aef
...
...
@@ -24,7 +24,17 @@ public interface DeviceDao extends BaseDao<Device> {
void
deleteDeviceById
(
@Param
(
"id"
)
String
id
);
@Select
(
"select t.* from tb_device t
,tb_gateway g where t.user_id = g.user_id and g
.mac_address = #{macAddress} and t.code = #{deviceCode} "
)
@Select
(
"select t.* from tb_device t
where t
.mac_address = #{macAddress} and t.code = #{deviceCode} "
)
List
<
Map
<
String
,
Object
>>
getDeviceId
(
@Param
(
"macAddress"
)
String
macAddress
,
@Param
(
"deviceCode"
)
String
deviceCode
);
@Select
(
"SELECT\n"
+
" g.mac_address\n"
+
" FROM\n"
+
" tb_user t,\n"
+
" tb_gateway g\n"
+
" WHERE\n"
+
" t.id = g.user_id\n"
+
" AND t.temphone = #{phone}"
)
List
<
Map
<
String
,
Object
>>
getMacByPhone
(
@Param
(
"phone"
)
String
phone
);
}
adc-da-main/src/main/java/com/adc/da/znks/dao/LockRecordDao.java
View file @
04d68aef
...
...
@@ -17,6 +17,6 @@ public interface LockRecordDao extends BaseDao<LockRecord> {
void
insertLockRecord
(
LockRecord
lockRecord
);
List
<
Map
<
String
,
Object
>>
selectLockRecord
(
@Param
(
"
phone"
)
String
phone
,
@Param
(
"deviceCode"
)
String
deviceCode
);
List
<
Map
<
String
,
Object
>>
selectLockRecord
(
@Param
(
"
mac"
)
String
mac
,
@Param
(
"deviceCode"
)
String
deviceCode
);
}
adc-da-main/src/main/java/com/adc/da/znks/entity/Device.java
View file @
04d68aef
...
...
@@ -23,6 +23,8 @@ public class Device extends BaseEntity {
private
String
uid
;
private
String
macAddress
;
public
String
getId
()
{
return
id
;
}
...
...
@@ -86,4 +88,12 @@ public class Device extends BaseEntity {
public
void
setUid
(
String
uid
)
{
this
.
uid
=
uid
;
}
public
String
getMacAddress
()
{
return
macAddress
;
}
public
void
setMacAddress
(
String
macAddress
)
{
this
.
macAddress
=
macAddress
;
}
}
adc-da-main/src/main/java/com/adc/da/znks/service/DeviceService.java
View file @
04d68aef
...
...
@@ -37,10 +37,12 @@ public class DeviceService extends BaseService<Device, String> {
}
public
String
getDeviceId
(
String
macAddress
,
String
deviceCode
){
List
<
Map
<
String
,
Object
>>
list
=
dao
.
getDeviceId
(
macAddress
,
deviceCode
);
if
(
list
!=
null
&&
list
.
size
()>
0
){
return
list
.
get
(
0
).
get
(
"id"
)!=
null
?
list
.
get
(
0
).
get
(
"id"
).
toString
():
""
;
}
return
""
;
return
list
.
get
(
0
)!=
null
?
list
.
get
(
0
).
get
(
"id"
).
toString
():
""
;
}
public
String
getMacByPhone
(
String
phone
){
return
dao
.
getMacByPhone
(
phone
)!=
null
?
dao
.
getMacByPhone
(
phone
).
get
(
0
).
get
(
"mac_address"
).
toString
():
""
;
}
}
adc-da-main/src/main/java/com/adc/da/znks/service/LockRecordService.java
View file @
04d68aef
...
...
@@ -27,6 +27,9 @@ public class LockRecordService extends BaseService<LockRecord, String> {
@Autowired
(
required
=
false
)
private
LockRecordDao
dao
;
@Autowired
private
DeviceDao
deviceDao
;
@Override
public
BaseDao
<
LockRecord
>
getDao
()
{
return
dao
;
...
...
@@ -38,7 +41,8 @@ public class LockRecordService extends BaseService<LockRecord, String> {
public
List
<
Map
<
String
,
Object
>>
selectLockRecord
(
String
phone
,
String
deviceCode
){
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<>();
List
<
Map
<
String
,
Object
>>
list
=
dao
.
selectLockRecord
(
phone
,
deviceCode
);
String
mac
=
deviceDao
.
getMacByPhone
(
phone
)!=
null
?
deviceDao
.
getMacByPhone
(
phone
).
get
(
0
).
get
(
"mac_address"
).
toString
():
""
;
List
<
Map
<
String
,
Object
>>
list
=
dao
.
selectLockRecord
(
mac
,
deviceCode
);
List
<
String
>
dayList
=
new
ArrayList
<>();
for
(
Map
<
String
,
Object
>
tmap
:
list
){
if
(!
dayList
.
contains
(
tmap
.
get
(
"day"
))){
...
...
adc-da-main/src/main/java/com/adc/da/znks/util/AppPushUtils.java
View file @
04d68aef
...
...
@@ -116,7 +116,7 @@ public class AppPushUtils {
public
static
void
main
(
String
[]
args
)
{
try
{
push
Tc
(
"提示"
,
"测试推送"
,
"c3d2cb373109db849b7ecfb22a4fd93d"
);
push
(
"提示"
,
"测试推送"
,
"c3d2cb373109db849b7ecfb22a4fd93d"
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
...
...
adc-da-main/src/main/java/com/adc/da/znks/util/Test.java
View file @
04d68aef
...
...
@@ -10,6 +10,11 @@ import java.math.BigInteger;
**/
public
class
Test
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
byte
a
=
0x32
;
System
.
out
.
println
(
String
.
valueOf
(
a
));
/* List<Map<String,Object>> list = new ArrayList<>();
Map<String,Object> map1 = new HashMap<>();
map1.put("component","盖子");
...
...
@@ -55,8 +60,8 @@ public class Test {
System.out.println(list);*/
/*byte[] b = {0x54,0x59};
System.out.println(SocketUtils.bytesToHex(b,0,b.length).split(" ").length);*/
System
.
out
.
println
(
"54 59 54 01 01 00"
.
replace
(
" "
,
""
));
AppPushUtils
.
pushTc
(
"主题"
,
"消息"
,
"c3d2cb373109db849b7ecfb22a4fd93d"
);
//
System.out.println("54 59 54 01 01 00".replace(" ",""));
//
AppPushUtils.pushTc("主题","消息","c3d2cb373109db849b7ecfb22a4fd93d");
//AppPushUtils.push("主题","消息","c3d2cb373109db849b7ecfb22a4fd93d");
}
...
...
adc-da-main/src/main/java/com/adc/da/znks/util/netty/ServerHandler.java
View file @
04d68aef
...
...
@@ -52,6 +52,7 @@ public class ServerHandler extends ChannelInboundHandlerAdapter {
serverHandler
.
gatewayService
=
this
.
gatewayService
;
serverHandler
.
lockRecordService
=
this
.
lockRecordService
;
serverHandler
.
userService
=
this
.
userService
;
serverHandler
.
deviceService
=
this
.
deviceService
;
}
@Override
...
...
@@ -60,14 +61,18 @@ public class ServerHandler extends ChannelInboundHandlerAdapter {
String
remoteAddress
=
ctx
.
channel
().
remoteAddress
().
toString
();
String
host
=
remoteAddress
.
substring
(
1
,
remoteAddress
.
lastIndexOf
(
":"
));
System
.
out
.
println
(
"网关IP地址:"
+
host
);
logger
.
info
(
"server channelRead...; received:"
+
msg
);
byte
[]
result
=
(
byte
[])
msg
;
System
.
out
.
println
(
SocketUtils
.
bytesToHex
(
result
,
0
,
result
.
length
));
String
resultStr
=
SocketUtils
.
bytesToHex
(
result
,
0
,
result
.
length
);
logger
.
info
(
SocketUtils
.
bytesToHex
(
result
,
0
,
result
.
length
));
String
mac
=
SocketUtils
.
bytesToHex
(
result
,
0
,
6
);
String
macR
=
mac
.
trim
().
replace
(
" "
,
""
);
// 在此处需要分别解析
// 1.上报MAC地址信息 6位mac地址+10位的(MAC-UPLOAD)
try
{
String
[]
resultArr
=
resultStr
.
split
(
" "
);
int
len
=
SocketUtils
.
bytesToHex
(
result
,
0
,
result
.
length
).
split
(
" "
).
length
;
System
.
out
.
println
(
"字符串"
+
SocketUtils
.
bytesToHex
(
result
,
0
,
result
.
length
));
if
(
String
.
valueOf
(
len
).
equals
(
"16"
)){
SystemValue
.
channelMap
.
put
(
macR
,
ctx
.
channel
());
...
...
@@ -80,16 +85,16 @@ public class ServerHandler extends ChannelInboundHandlerAdapter {
// 前6位不用管,第七位是设备编号,第八位是功能码0x05代表开锁,0x06代表关锁,最后两位代表用户ID,1-300
// 3.安防信息,需要根据安防信息做不同的处理,安防信息有 0x60(非法开门警报),0x61(非法尝试开锁警报),0x80(远程开锁触发),0x28(电池低电量警报)
byte
device
=
result
[
1
3
];
byte
device
=
result
[
1
2
];
byte
user
=
0
;
String
device_code
=
String
.
valueOf
(
device
);
String
deviceId
=
deviceService
.
getDeviceId
(
macR
,
device_code
);
byte
instruct
=
0
;
String
deviceId
=
serverHandler
.
deviceService
.
getDeviceId
(
macR
,
device_code
);
String
instruct
=
""
;
if
(
result
.
length
==
17
){
//开关门信息,6位mac + 11位指令
instruct
=
result
[
14
];
instruct
=
result
Arr
[
14
];
user
=
result
[
16
];
}
else
{
//安防信息,6位mac + 8位指令
instruct
=
result
[
9
];
instruct
=
result
Arr
[
9
];
}
int
user_id
=
Integer
.
parseInt
(
String
.
valueOf
(
user
));
String
lockType
=
getLockType
(
instruct
);
...
...
@@ -103,13 +108,26 @@ public class ServerHandler extends ChannelInboundHandlerAdapter {
System
.
out
.
println
(
lockType
);
serverHandler
.
lockRecordService
.
insertLockRecord
(
lockRecord
);
if
(
list
!=
null
){
clientId
=
list
.
get
(
0
).
get
(
"client_id"
)!=
null
?
list
.
get
(
0
).
get
(
"client_id"
).
toString
():
""
;
if
(!
""
.
equals
(
clientId
)){
if
(
instruct
==
0x80
){
// 远程开锁触发请求,发送透传
AppPushUtils
.
pushTc
(
title
,
message
,
clientId
);
AppPushUtils
.
push
(
title
,
message
,
clientId
);
}
else
{
AppPushUtils
.
push
(
title
,
message
,
clientId
);
if
(
"80"
.
equals
(
instruct
)){
// 远程开锁触发请求,发送透传
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++){
clientId
=
list
.
get
(
i
).
get
(
"client_id"
)!=
null
?
list
.
get
(
i
).
get
(
"client_id"
).
toString
():
""
;
if
(!
""
.
equals
(
clientId
)){
AppPushUtils
.
pushTc
(
title
,
message
,
clientId
);
AppPushUtils
.
push
(
title
,
message
,
clientId
);
}
else
{
logger
.
info
(
"clientId为空"
);
}
}
}
else
{
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++){
clientId
=
list
.
get
(
i
).
get
(
"client_id"
)!=
null
?
list
.
get
(
i
).
get
(
"client_id"
).
toString
():
""
;
if
(!
""
.
equals
(
clientId
)){
AppPushUtils
.
push
(
title
,
message
,
clientId
);
}
else
{
logger
.
info
(
"clientId为空"
);
}
}
}
...
...
@@ -182,35 +200,35 @@ public class ServerHandler extends ChannelInboundHandlerAdapter {
return
true
;
}
public
String
getLockType
(
byte
b
){
if
(
b
==
0x05
){
return
"开锁"
;}
else
if
(
b
==
0x06
){
return
"关锁"
;}
else
if
(
b
==
0x60
){
return
"非法开门警报"
;}
else
if
(
b
==
0x61
){
return
"非法尝试开锁警报"
;}
else
if
(
b
==
0x80
){
return
"远程开锁触发"
;}
else
if
(
b
==
0x28
){
return
"电池低电量警报"
;}
public
String
getLockType
(
String
b
){
if
(
"05"
.
equals
(
b
)
){
return
"开锁"
;}
else
if
(
"06"
.
equals
(
b
)
){
return
"关锁"
;}
else
if
(
"60"
.
equals
(
b
)
){
return
"非法开门警报"
;}
else
if
(
"61"
.
equals
(
b
)
){
return
"非法尝试开锁警报"
;}
else
if
(
"80"
.
equals
(
b
)
){
return
"远程开锁触发"
;}
else
if
(
"28"
.
equals
(
b
)
){
return
"电池低电量警报"
;}
return
""
;
}
public
String
getTitle
(
byte
b
){
public
String
getTitle
(
String
b
){
String
title
=
""
;
if
(
b
==
0x05
){
title
=
"开锁"
;}
else
if
(
b
==
0x06
){
title
=
"关锁"
;}
else
if
(
b
==
0x60
){
title
=
"非法开门警报"
;}
else
if
(
b
==
0x61
){
title
=
"非法尝试开锁警报"
;}
else
if
(
b
==
0x80
){
title
=
"远程开锁触发"
;}
else
if
(
b
==
0x28
){
title
=
"电池低电量警报"
;}
if
(
"05"
.
equals
(
b
)
){
title
=
"开锁"
;}
else
if
(
"06"
.
equals
(
b
)
){
title
=
"关锁"
;}
else
if
(
"60"
.
equals
(
b
)
){
title
=
"非法开门警报"
;}
else
if
(
"61"
.
equals
(
b
)
){
title
=
"非法尝试开锁警报"
;}
else
if
(
"80"
.
equals
(
b
)
){
title
=
"远程开锁触发"
;}
else
if
(
"28"
.
equals
(
b
)
){
title
=
"电池低电量警报"
;}
return
title
;
}
public
String
getMessage
(
byte
b
){
public
String
getMessage
(
String
b
){
String
msg
=
""
;
if
(
b
==
0x05
){
msg
=
"开锁"
;}
else
if
(
b
==
0x06
){
msg
=
"关锁"
;}
else
if
(
b
==
0x60
){
msg
=
"非法开门警报"
;}
else
if
(
b
==
0x61
){
msg
=
"非法尝试开锁警报"
;}
else
if
(
b
==
0x80
){
msg
=
"远程开锁触发"
;}
else
if
(
b
==
0x28
){
msg
=
"电池低电量警报"
;}
if
(
"05"
.
equals
(
b
)
){
msg
=
"开锁"
;}
else
if
(
"06"
.
equals
(
b
)
){
msg
=
"关锁"
;}
else
if
(
"60"
.
equals
(
b
)
){
msg
=
"非法开门警报"
;}
else
if
(
"61"
.
equals
(
b
)
){
msg
=
"非法尝试开锁警报"
;}
else
if
(
"80"
.
equals
(
b
)
){
msg
=
"远程开锁触发"
;}
else
if
(
"28"
.
equals
(
b
)
){
msg
=
"电池低电量警报"
;}
SimpleDateFormat
simple
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
return
simple
.
format
(
new
Date
())
+
" 触发 "
+
msg
;
}
...
...
adc-da-main/src/main/resources/mybatis/mapper/znks/DeviceMapper.xml
View file @
04d68aef
...
...
@@ -12,9 +12,21 @@
<result
column=
"uid"
property=
"uid"
/>
</resultMap>
<select
id=
"listByPhoneNumber"
resultMap=
"BaseResultMap"
>
select * from tb_device,tb_user
where tb_device.user_id = tb_user.id
and tb_user.temphone = #{phoneNumber}
SELECT
t.*
FROM
tb_device t
WHERE
t.mac_Address = (
SELECT
g.mac_address
FROM
tb_user t,
tb_gateway g
WHERE
t.id = g.user_id
AND t.temphone = #{phone})
order by t.code
</select>
<!-- 动态插入记录 主键是序列 -->
...
...
@@ -29,6 +41,7 @@
<if
test=
"userPassword != null"
>
user_password,
</if>
<if
test=
"uid != null"
>
uid,
</if>
<if
test=
"userId != null"
>
user_id,
</if>
<if
test=
"macAddress != null"
>
mac_address,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"id != null"
>
#{id, jdbcType=VARCHAR},
</if>
...
...
@@ -39,6 +52,7 @@
<if
test=
"userPassword != null"
>
#{userPassword, jdbcType=VARCHAR},
</if>
<if
test=
"uid != null"
>
#{uid, jdbcType=VARCHAR},
</if>
<if
test=
"userId != null"
>
#{userId, jdbcType=VARCHAR},
</if>
<if
test=
"macAddress != null"
>
#{macAddress, jdbcType=VARCHAR},
</if>
</trim>
</insert>
...
...
adc-da-main/src/main/resources/mybatis/mapper/znks/LockRecordMapper.xml
View file @
04d68aef
...
...
@@ -15,17 +15,11 @@
<select
id=
"selectLockRecord"
resultType=
"java.util.Map"
parameterType=
"java.util.Map"
>
SELECT
loc.*, DATE_FORMAT(loc.time, '%Y-%m-%d') day,
DATE_FORMAT(loc.time,'%Y-%m-%d %
h:%i:%s
') htime
DATE_FORMAT(loc.time,'%Y-%m-%d %
T
') htime
FROM
tb_lock_record loc,
tb_device dev,
tb_user u
tb_lock_record loc
WHERE
u.id = dev.user_id
AND dev.code = loc.device_id
AND u.temphone = #{phone}
AND dev. CODE = #{deviceCode}
AND dev.type = 1
loc.device_id = (select dev.id from tb_device dev where dev.mac_address = #{mac} and dev.code = #{deviceCode} limit 1)
AND DATE_SUB(now(), INTERVAL 10 DAY)
<
= loc.time
order by loc.time desc
</select>
...
...
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