Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
BYOD
Project
Overview
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
tutingyin
BYOD
Commits
23967958
Commit
23967958
authored
Sep 11, 2024
by
tutingyin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 增加设备保活 客户端回调
parent
f9718668
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
102 additions
and
60 deletions
+102
-60
DeviceInstructCmdController.java
...a/com/skr/mdm/controller/DeviceInstructCmdController.java
+37
-0
KeepAliveServiceImpl.java
...va/com/skr/mdm/service/impl/cmd/KeepAliveServiceImpl.java
+53
-0
CmdTypeConstants.java
.../src/main/java/com/skr/mdm/constant/CmdTypeConstants.java
+2
-2
DeviceInstructKeepAliveDao.java
...main/java/com/skr/mdm/dao/DeviceInstructKeepAliveDao.java
+2
-1
DeviceInstructKeepAliveDO.java
...in/java/com/skr/mdm/entity/DeviceInstructKeepAliveDO.java
+3
-18
DeviceInstructKeepAliveDao.xml
.../src/main/resources/mapper/DeviceInstructKeepAliveDao.xml
+5
-39
No files found.
mdm_client/src/main/java/com/skr/mdm/controller/DeviceInstructCmdController.java
0 → 100644
View file @
23967958
package
com
.
skr
.
mdm
.
controller
;
import
com.skr.mdm.constant.CmdTypeConstants
;
import
com.skr.mdm.dto.LoginUserDTO
;
import
com.skr.mdm.result.ResponseResult
;
import
com.skr.mdm.service.CmdHandlerService
;
import
com.skr.mdm.service.StrategyFactory
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
springfox.documentation.annotations.ApiIgnore
;
/**
* @Author tty
* @Date 2024/9/9 16:37
* @Description 指令回调
*/
@RestController
@RequestMapping
(
"status"
)
@Api
(
tags
=
"指令回调"
)
public
class
DeviceInstructCmdController
{
@PostMapping
(
"callback"
)
@ApiOperation
(
"指令回调"
)
public
ResponseResult
equipmentStatusCallback
(
@RequestParam
@ApiParam
(
value
=
"回调内容"
,
required
=
true
)
String
data
,
@ApiIgnore
Authentication
authentication
)
{
LoginUserDTO
loginUserDTO
=
(
LoginUserDTO
)
authentication
.
getPrincipal
();
CmdHandlerService
strategy
=
StrategyFactory
.
getStrategy
(
CmdTypeConstants
.
KEEP_ALIVE
);
return
strategy
.
cmdHandler
(
loginUserDTO
.
getId
(),
data
);
}
}
\ No newline at end of file
mdm_client_websocket/src/main/java/com/skr/mdm/service/impl/cmd/KeepAliveServiceImpl.java
0 → 100644
View file @
23967958
package
com
.
skr
.
mdm
.
service
.
impl
.
cmd
;
import
cn.hutool.json.JSONArray
;
import
cn.hutool.json.JSONUtil
;
import
com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper
;
import
com.skr.mdm.annotation.CmdHandler
;
import
com.skr.mdm.constant.CmdTypeConstants
;
import
com.skr.mdm.dao.DeviceInstructKeepAliveDao
;
import
com.skr.mdm.dto.CmdCallBackDTO
;
import
com.skr.mdm.entity.DeviceInstructKeepAliveDO
;
import
com.skr.mdm.result.ResponseResult
;
import
com.skr.mdm.service.CmdHandlerService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @author nfq
* @date 2020/8/3 18:38
*/
@Slf4j
@CmdHandler
(
cmdType
=
{
CmdTypeConstants
.
KEEP_ALIVE
})
public
class
KeepAliveServiceImpl
implements
CmdHandlerService
{
@Autowired
private
DeviceInstructKeepAliveDao
deviceInstructKeepAliveDao
;
@Override
public
ResponseResult
cmdHandler
(
Integer
equipmentId
,
String
data
)
{
try
{
// 锁屏解锁回调
JSONArray
jsonArray
=
JSONUtil
.
parseArray
(
data
);
List
<
CmdCallBackDTO
>
cmdCallBackDTOList
=
JSONUtil
.
toList
(
jsonArray
,
CmdCallBackDTO
.
class
);
List
<
Integer
>
cidList
=
new
ArrayList
<>(
cmdCallBackDTOList
.
size
());
cmdCallBackDTOList
.
forEach
(
cmdCallBackDTO
->
{
LambdaUpdateChainWrapper
<
DeviceInstructKeepAliveDO
>
updateChainWrapper
=
new
LambdaUpdateChainWrapper
<>(
deviceInstructKeepAliveDao
);
updateChainWrapper
.
set
(
DeviceInstructKeepAliveDO:
:
getState
,
cmdCallBackDTO
.
getState
())
.
eq
(
DeviceInstructKeepAliveDO:
:
getMessageId
,
cmdCallBackDTO
.
getId
())
.
eq
(
DeviceInstructKeepAliveDO:
:
getEquipmentId
,
equipmentId
)
.
update
();
cidList
.
add
(
cmdCallBackDTO
.
getCid
());
});
return
ResponseResult
.
success
(
JSONUtil
.
toJsonStr
(
cidList
));
}
catch
(
Exception
e
)
{
log
.
error
(
"指令保活回调异常: "
+
equipmentId
+
data
,
e
);
return
ResponseResult
.
failure
();
}
}
}
\ No newline at end of file
mdm_common/src/main/java/com/skr/mdm/constant/CmdTypeConstants.java
View file @
23967958
...
@@ -84,9 +84,9 @@ public class CmdTypeConstants {
...
@@ -84,9 +84,9 @@ public class CmdTypeConstants {
*/
*/
public
static
final
short
ELIMINATED
=
0x3A7
;
public
static
final
short
ELIMINATED
=
0x3A7
;
/**
/**
*
点名回调
*
保活
*/
*/
public
static
final
short
ROLL_CALL
=
0x3A8
;
public
static
final
short
KEEP_ALIVE
=
0x3A8
;
/**
/**
* 上传拍照
* 上传拍照
*/
*/
...
...
mdm_dao/src/main/java/com/skr/mdm/dao/DeviceInstructKeepAliveDao.java
View file @
23967958
package
com
.
skr
.
mdm
.
dao
;
package
com
.
skr
.
mdm
.
dao
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.skr.mdm.bean.bo.InstructMessageBO
;
import
com.skr.mdm.bean.bo.InstructMessageBO
;
import
com.skr.mdm.bean.qo.cmd.CmdQO
;
import
com.skr.mdm.bean.qo.cmd.CmdQO
;
import
com.skr.mdm.bean.vo.equipment.SendCmdMessageInfoVO
;
import
com.skr.mdm.bean.vo.equipment.SendCmdMessageInfoVO
;
...
@@ -9,7 +10,7 @@ import org.springframework.stereotype.Repository;
...
@@ -9,7 +10,7 @@ import org.springframework.stereotype.Repository;
import
java.util.List
;
import
java.util.List
;
@Repository
@Repository
public
interface
DeviceInstructKeepAliveDao
{
public
interface
DeviceInstructKeepAliveDao
extends
BaseMapper
<
DeviceInstructKeepAliveDO
>
{
int
deleteByPrimaryKey
(
Integer
id
);
int
deleteByPrimaryKey
(
Integer
id
);
int
insert
(
DeviceInstructKeepAliveDO
record
);
int
insert
(
DeviceInstructKeepAliveDO
record
);
...
...
mdm_dao/src/main/java/com/skr/mdm/entity/DeviceInstructKeepAliveDO.java
View file @
23967958
...
@@ -29,27 +29,17 @@ public class DeviceInstructKeepAliveDO implements Serializable {
...
@@ -29,27 +29,17 @@ public class DeviceInstructKeepAliveDO implements Serializable {
/**
/**
* 状态(1:下发中 2:下发成功)
* 状态(1:下发中 2:下发成功)
*/
*/
private
Byte
state
;
private
Integer
state
;
/**
/**
* 1:保活 2:取消保活
* 1:保活 2:取消保活
*/
*/
private
Byte
cmdType
;
private
Integer
cmdType
;
/**
* 锁屏密码
*/
private
String
lockScreePassword
;
/**
* 离线解锁码
*/
private
String
offlineUnlockCode
;
/**
/**
* 全局标识 0:非全局 1:全局
* 全局标识 0:非全局 1:全局
*/
*/
private
Byte
isGlobal
;
private
Integer
isGlobal
;
/**
/**
* 公司id
* 公司id
...
@@ -57,11 +47,6 @@ public class DeviceInstructKeepAliveDO implements Serializable {
...
@@ -57,11 +47,6 @@ public class DeviceInstructKeepAliveDO implements Serializable {
private
Integer
companyId
;
private
Integer
companyId
;
/**
/**
* 1:web端 2:手机端
*/
private
Byte
clientType
;
/**
* 创建时间
* 创建时间
*/
*/
private
Date
createTime
;
private
Date
createTime
;
...
...
mdm_dao/src/main/resources/mapper/DeviceInstructKeepAliveDao.xml
View file @
23967958
...
@@ -7,17 +7,14 @@
...
@@ -7,17 +7,14 @@
<result
column=
"message_id"
jdbcType=
"VARCHAR"
property=
"messageId"
/>
<result
column=
"message_id"
jdbcType=
"VARCHAR"
property=
"messageId"
/>
<result
column=
"state"
jdbcType=
"TINYINT"
property=
"state"
/>
<result
column=
"state"
jdbcType=
"TINYINT"
property=
"state"
/>
<result
column=
"cmd_type"
jdbcType=
"TINYINT"
property=
"cmdType"
/>
<result
column=
"cmd_type"
jdbcType=
"TINYINT"
property=
"cmdType"
/>
<result
column=
"lock_scree_password"
jdbcType=
"VARCHAR"
property=
"lockScreePassword"
/>
<result
column=
"offline_unlock_code"
jdbcType=
"VARCHAR"
property=
"offlineUnlockCode"
/>
<result
column=
"is_global"
jdbcType=
"TINYINT"
property=
"isGlobal"
/>
<result
column=
"is_global"
jdbcType=
"TINYINT"
property=
"isGlobal"
/>
<result
column=
"company_id"
jdbcType=
"INTEGER"
property=
"companyId"
/>
<result
column=
"company_id"
jdbcType=
"INTEGER"
property=
"companyId"
/>
<result
column=
"client_type"
jdbcType=
"TINYINT"
property=
"clientType"
/>
<result
column=
"create_time"
jdbcType=
"TIMESTAMP"
property=
"createTime"
/>
<result
column=
"create_time"
jdbcType=
"TIMESTAMP"
property=
"createTime"
/>
<result
column=
"update_time"
jdbcType=
"TIMESTAMP"
property=
"updateTime"
/>
<result
column=
"update_time"
jdbcType=
"TIMESTAMP"
property=
"updateTime"
/>
</resultMap>
</resultMap>
<sql
id=
"Base_Column_List"
>
<sql
id=
"Base_Column_List"
>
id, equipment_id, message_id, `state`, cmd_type,
lock_scree_password, offline_unlock_code,
id, equipment_id, message_id, `state`, cmd_type,
is_global, company_id, c
lient_type, c
reate_time, update_time
is_global, company_id, create_time, update_time
</sql>
</sql>
<select
id=
"selectByPrimaryKey"
parameterType=
"java.lang.Integer"
resultMap=
"BaseResultMap"
>
<select
id=
"selectByPrimaryKey"
parameterType=
"java.lang.Integer"
resultMap=
"BaseResultMap"
>
select
select
...
@@ -55,12 +52,11 @@
...
@@ -55,12 +52,11 @@
</delete>
</delete>
<insert
id=
"insert"
keyColumn=
"id"
keyProperty=
"id"
parameterType=
"com.skr.mdm.entity.DeviceInstructKeepAliveDO"
useGeneratedKeys=
"true"
>
<insert
id=
"insert"
keyColumn=
"id"
keyProperty=
"id"
parameterType=
"com.skr.mdm.entity.DeviceInstructKeepAliveDO"
useGeneratedKeys=
"true"
>
insert into device_instruct_keep_alive (equipment_id, message_id, `state`,
insert into device_instruct_keep_alive (equipment_id, message_id, `state`,
cmd_type,
lock_scree_password, offline_unlock_code,
cmd_type,
is_global, company_id,
client_type,
is_global, company_id,
create_time, update_time)
create_time, update_time)
values (#{equipmentId,jdbcType=INTEGER}, #{messageId,jdbcType=VARCHAR}, #{state,jdbcType=TINYINT},
values (#{equipmentId,jdbcType=INTEGER}, #{messageId,jdbcType=VARCHAR}, #{state,jdbcType=TINYINT},
#{cmdType,jdbcType=TINYINT}, #{lockScreePassword,jdbcType=VARCHAR}, #{offlineUnlockCode,jdbcType=VARCHAR},
#{cmdType,jdbcType=TINYINT}, #{isGlobal,jdbcType=TINYINT}, #{companyId,jdbcType=INTEGER},
#{isGlobal,jdbcType=TINYINT}, #{companyId,jdbcType=INTEGER}, #{clientType,jdbcType=TINYINT},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
</insert>
</insert>
<insert
id=
"insertSelective"
keyColumn=
"id"
keyProperty=
"id"
parameterType=
"com.skr.mdm.entity.DeviceInstructKeepAliveDO"
useGeneratedKeys=
"true"
>
<insert
id=
"insertSelective"
keyColumn=
"id"
keyProperty=
"id"
parameterType=
"com.skr.mdm.entity.DeviceInstructKeepAliveDO"
useGeneratedKeys=
"true"
>
...
@@ -78,21 +74,12 @@
...
@@ -78,21 +74,12 @@
<if
test=
"cmdType != null"
>
<if
test=
"cmdType != null"
>
cmd_type,
cmd_type,
</if>
</if>
<if
test=
"lockScreePassword != null"
>
lock_scree_password,
</if>
<if
test=
"offlineUnlockCode != null"
>
offline_unlock_code,
</if>
<if
test=
"isGlobal != null"
>
<if
test=
"isGlobal != null"
>
is_global,
is_global,
</if>
</if>
<if
test=
"companyId != null"
>
<if
test=
"companyId != null"
>
company_id,
company_id,
</if>
</if>
<if
test=
"clientType != null"
>
client_type,
</if>
<if
test=
"createTime != null"
>
<if
test=
"createTime != null"
>
create_time,
create_time,
</if>
</if>
...
@@ -113,21 +100,12 @@
...
@@ -113,21 +100,12 @@
<if
test=
"cmdType != null"
>
<if
test=
"cmdType != null"
>
#{cmdType,jdbcType=TINYINT},
#{cmdType,jdbcType=TINYINT},
</if>
</if>
<if
test=
"lockScreePassword != null"
>
#{lockScreePassword,jdbcType=VARCHAR},
</if>
<if
test=
"offlineUnlockCode != null"
>
#{offlineUnlockCode,jdbcType=VARCHAR},
</if>
<if
test=
"isGlobal != null"
>
<if
test=
"isGlobal != null"
>
#{isGlobal,jdbcType=TINYINT},
#{isGlobal,jdbcType=TINYINT},
</if>
</if>
<if
test=
"companyId != null"
>
<if
test=
"companyId != null"
>
#{companyId,jdbcType=INTEGER},
#{companyId,jdbcType=INTEGER},
</if>
</if>
<if
test=
"clientType != null"
>
#{clientType,jdbcType=TINYINT},
</if>
<if
test=
"createTime != null"
>
<if
test=
"createTime != null"
>
#{createTime,jdbcType=TIMESTAMP},
#{createTime,jdbcType=TIMESTAMP},
</if>
</if>
...
@@ -159,21 +137,12 @@
...
@@ -159,21 +137,12 @@
<if
test=
"cmdType != null"
>
<if
test=
"cmdType != null"
>
cmd_type = #{cmdType,jdbcType=TINYINT},
cmd_type = #{cmdType,jdbcType=TINYINT},
</if>
</if>
<if
test=
"lockScreePassword != null"
>
lock_scree_password = #{lockScreePassword,jdbcType=VARCHAR},
</if>
<if
test=
"offlineUnlockCode != null"
>
offline_unlock_code = #{offlineUnlockCode,jdbcType=VARCHAR},
</if>
<if
test=
"isGlobal != null"
>
<if
test=
"isGlobal != null"
>
is_global = #{isGlobal,jdbcType=TINYINT},
is_global = #{isGlobal,jdbcType=TINYINT},
</if>
</if>
<if
test=
"companyId != null"
>
<if
test=
"companyId != null"
>
company_id = #{companyId,jdbcType=INTEGER},
company_id = #{companyId,jdbcType=INTEGER},
</if>
</if>
<if
test=
"clientType != null"
>
client_type = #{clientType,jdbcType=TINYINT},
</if>
<if
test=
"createTime != null"
>
<if
test=
"createTime != null"
>
create_time = #{createTime,jdbcType=TIMESTAMP},
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
</if>
...
@@ -189,11 +158,8 @@
...
@@ -189,11 +158,8 @@
message_id = #{messageId,jdbcType=VARCHAR},
message_id = #{messageId,jdbcType=VARCHAR},
`state` = #{state,jdbcType=TINYINT},
`state` = #{state,jdbcType=TINYINT},
cmd_type = #{cmdType,jdbcType=TINYINT},
cmd_type = #{cmdType,jdbcType=TINYINT},
lock_scree_password = #{lockScreePassword,jdbcType=VARCHAR},
offline_unlock_code = #{offlineUnlockCode,jdbcType=VARCHAR},
is_global = #{isGlobal,jdbcType=TINYINT},
is_global = #{isGlobal,jdbcType=TINYINT},
company_id = #{companyId,jdbcType=INTEGER},
company_id = #{companyId,jdbcType=INTEGER},
client_type = #{clientType,jdbcType=TINYINT},
create_time = #{createTime,jdbcType=TIMESTAMP},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
...
...
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