Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
device-new-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
device-new-platform
Commits
7e9a64b4
Commit
7e9a64b4
authored
3 years ago
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改平台编码
parent
f96f6a97
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
230 additions
and
240 deletions
+230
-240
device-manager-ui/admin/src/views/device/dialogshow.vue
device-manager-ui/admin/src/views/device/dialogshow.vue
+1
-4
device-manager-ui/admin/src/views/device/list.vue
device-manager-ui/admin/src/views/device/list.vue
+1
-1
device-manager-ui/admin/src/views/platform/dialogshow.vue
device-manager-ui/admin/src/views/platform/dialogshow.vue
+1
-1
device-manager/src/main/java/com/mortals/xhx/base/system/message/impl/MessageServiceImpl.java
...tals/xhx/base/system/message/impl/MessageServiceImpl.java
+1
-1
device-manager/src/main/java/com/mortals/xhx/busiz/req/DeviceReq.java
...er/src/main/java/com/mortals/xhx/busiz/req/DeviceReq.java
+6
-2
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceApiController.java
...n/java/com/mortals/xhx/busiz/web/DeviceApiController.java
+138
-114
device-manager/src/main/java/com/mortals/xhx/common/code/DeviceStatusEnum.java
...in/java/com/mortals/xhx/common/code/DeviceStatusEnum.java
+3
-3
device-manager/src/main/java/com/mortals/xhx/common/utils/SendTask.java
.../src/main/java/com/mortals/xhx/common/utils/SendTask.java
+20
-5
device-manager/src/main/java/com/mortals/xhx/daemon/DemoApiController.java
...c/main/java/com/mortals/xhx/daemon/DemoApiController.java
+1
-1
device-manager/src/main/java/com/mortals/xhx/daemon/applicationservice/DeviceMsgComsumerStartedService.java
...n/applicationservice/DeviceMsgComsumerStartedService.java
+8
-5
device-manager/src/main/java/com/mortals/xhx/module/device/service/DeviceService.java
.../com/mortals/xhx/module/device/service/DeviceService.java
+7
-0
device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
...als/xhx/module/device/service/impl/DeviceServiceImpl.java
+16
-9
device-manager/src/main/java/com/mortals/xhx/module/device/web/DeviceController.java
...a/com/mortals/xhx/module/device/web/DeviceController.java
+22
-0
doc/api.md
doc/api.md
+5
-94
No files found.
device-manager-ui/admin/src/views/device/dialogshow.vue
View file @
7e9a64b4
...
@@ -8,10 +8,7 @@
...
@@ -8,10 +8,7 @@
<Field
:span=
"20"
label=
"平台类型"
prop=
"platformId"
v-model=
"form.platformId"
type=
"select"
:enumData=
"dict.platformId"
placeholder=
"请选择平台类型"
/>
<Field
:span=
"20"
label=
"平台类型"
prop=
"platformId"
v-model=
"form.platformId"
type=
"select"
:enumData=
"dict.platformId"
placeholder=
"请选择平台类型"
/>
<Field
:span=
"20"
label=
"产品类型"
prop=
"productId"
v-model=
"form.productId"
type=
"select"
:enumData=
"dict.productId"
placeholder=
"请选择产品类型"
/>
<Field
:span=
"20"
label=
"产品类型"
prop=
"productId"
v-model=
"form.productId"
type=
"select"
:enumData=
"dict.productId"
placeholder=
"请选择产品类型"
/>
<Field
:span=
"20"
label=
"设备的MAC地址"
prop=
"deviceMac"
v-model=
"form.deviceMac"
placeholder=
"请输入设备的MAC地址"
/>
<Field
:span=
"20"
label=
"设备的MAC地址"
prop=
"deviceMac"
v-model=
"form.deviceMac"
placeholder=
"请输入设备的MAC地址"
/>
<Field
:span=
"20"
label=
"中心设备编码"
v-model=
"form.centernum"
placeholder=
"请输入中心设备编码"
/>
<Field
:span=
"20"
disabled
label=
"设备访问ip"
v-model=
"form.ip"
/>
<Field
:span=
"20"
disabled
label=
"端口"
v-model=
"form.port"
/>
<Field
:span=
"20"
disabled
label=
"站点编号"
v-model=
"form.siteNum"
/>
<Field
:span=
"20"
disabled
label=
"站点编号"
v-model=
"form.siteNum"
/>
<Field
<Field
:span=
"20"
:span=
"20"
...
...
This diff is collapsed.
Click to expand it.
device-manager-ui/admin/src/views/device/list.vue
View file @
7e9a64b4
...
@@ -76,7 +76,7 @@ export default {
...
@@ -76,7 +76,7 @@ export default {
},
},
activeDevice
(
row
)
{
activeDevice
(
row
)
{
this
.
$post
(
"
/device/
sa
ve
"
,
{
this
.
$post
(
"
/device/
acti
ve
"
,
{
"
entity.id
"
:
row
.
id
,
"
entity.id
"
:
row
.
id
,
"
entity.active
"
:
1
,
"
entity.active
"
:
1
,
})
})
...
...
This diff is collapsed.
Click to expand it.
device-manager-ui/admin/src/views/platform/dialogshow.vue
View file @
7e9a64b4
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<el-row>
<el-row>
<Field
:span=
"20"
label=
"平台名称"
prop=
"platformName"
v-model=
"form.platformName"
placeholder=
"请输入平台名称,名称唯一"
/>
<Field
:span=
"20"
label=
"平台名称"
prop=
"platformName"
v-model=
"form.platformName"
placeholder=
"请输入平台名称,名称唯一"
/>
<Field
:span=
"20"
label=
"平台编码"
prop=
"platformSn"
v-model=
"form.platformSn"
placeholder=
"请输入平台编码,编码唯一"
/>
<Field
:span=
"20"
label=
"平台编码"
prop=
"platformSn"
v-model=
"form.platformSn"
placeholder=
"请输入平台编码,编码唯一"
/>
<Field
:span=
"20"
label=
"发送
参数配置"
prop=
"sendConfig"
v-model=
"form.sendConfig"
type=
"textarea"
placeholder=
"请输入发送参数配置,如发送消息地址等,xml结构,根据消息类型变化
"
/>
<Field
:span=
"20"
label=
"发送
地址"
prop=
"sendUrl"
v-model=
"form.sendUrl"
type=
"textarea"
placeholder=
"请输入发送httpurl地址
"
/>
<Field
:span=
"20"
label=
"发送消息类型"
prop=
"sendMsgType"
v-model=
"form.sendMsgType"
type=
"radio"
:enumData=
"dict.sendMsgType"
placeholder=
"请选择发送第三方平台消息类型"
/>
<Field
:span=
"20"
label=
"发送消息类型"
prop=
"sendMsgType"
v-model=
"form.sendMsgType"
type=
"radio"
:enumData=
"dict.sendMsgType"
placeholder=
"请选择发送第三方平台消息类型"
/>
<Field
:span=
"20"
label=
"是否发送消息"
prop=
"sendSwitch"
v-model=
"form.sendSwitch"
type=
"radio"
:enumData=
"dict.sendSwitch"
placeholder=
"请选择是否启用发送消息"
/>
<Field
:span=
"20"
label=
"是否发送消息"
prop=
"sendSwitch"
v-model=
"form.sendSwitch"
type=
"radio"
:enumData=
"dict.sendSwitch"
placeholder=
"请选择是否启用发送消息"
/>
<Field
:span=
"20"
label=
"备注"
prop=
"platformRemark"
v-model=
"form.platformRemark"
type=
"textarea"
placeholder=
"请输入备注"
/>
<Field
:span=
"20"
label=
"备注"
prop=
"platformRemark"
v-model=
"form.platformRemark"
type=
"textarea"
placeholder=
"请输入备注"
/>
...
...
This diff is collapsed.
Click to expand it.
device-manager/src/main/java/com/mortals/xhx/base/system/message/impl/MessageServiceImpl.java
View file @
7e9a64b4
...
@@ -103,7 +103,7 @@ public class MessageServiceImpl implements MessageService {
...
@@ -103,7 +103,7 @@ public class MessageServiceImpl implements MessageService {
if
(
code
==
YesNoEnum
.
YES
.
getValue
())
{
if
(
code
==
YesNoEnum
.
YES
.
getValue
())
{
JSONObject
dataObj
=
jsonObject
.
getJSONObject
(
"data"
);
JSONObject
dataObj
=
jsonObject
.
getJSONObject
(
"data"
);
String
authtoken
=
dataObj
.
getString
(
"token"
);
String
authtoken
=
dataObj
.
getString
(
"token"
);
cacheService
.
setnx
(
Constant
.
BASEPLATFORM_AUTHTOKEN
,
authtoken
,
7
*
24
*
60
*
60
*
1000
);
cacheService
.
setnx
(
Constant
.
BASEPLATFORM_AUTHTOKEN
,
authtoken
,
7
*
24
*
60
);
return
authtoken
;
return
authtoken
;
}
else
{
}
else
{
throw
new
AppException
(
"异常"
);
throw
new
AppException
(
"异常"
);
...
...
This diff is collapsed.
Click to expand it.
device-manager/src/main/java/com/mortals/xhx/busiz/req/DeviceReq.java
View file @
7e9a64b4
...
@@ -11,9 +11,9 @@ import java.io.Serializable;
...
@@ -11,9 +11,9 @@ import java.io.Serializable;
public
class
DeviceReq
implements
Serializable
{
public
class
DeviceReq
implements
Serializable
{
/**
/**
*
状态,0:新增,1:修改,2:删除,3:激活,4:上线,5:下线
*
1:新增,2:修改,3:删除,4:激活,5:启用,6:停用
*/
*/
private
Integer
deviceStatus
;
private
Integer
receiveMethod
;
/**
/**
* 平台系统编码
* 平台系统编码
*/
*/
...
@@ -42,6 +42,10 @@ public class DeviceReq implements Serializable {
...
@@ -42,6 +42,10 @@ public class DeviceReq implements Serializable {
* 设备备注信息
* 设备备注信息
*/
*/
private
String
deviceRemark
;
private
String
deviceRemark
;
/**
* 设备
*/
private
String
homeUrl
;
}
}
This diff is collapsed.
Click to expand it.
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceApiController.java
View file @
7e9a64b4
...
@@ -14,10 +14,7 @@ import com.mortals.xhx.base.system.user.service.UserService;
...
@@ -14,10 +14,7 @@ import com.mortals.xhx.base.system.user.service.UserService;
import
com.mortals.xhx.busiz.req.DeviceReq
;
import
com.mortals.xhx.busiz.req.DeviceReq
;
import
com.mortals.xhx.busiz.req.UploadDeviceReq
;
import
com.mortals.xhx.busiz.req.UploadDeviceReq
;
import
com.mortals.xhx.busiz.rsp.*
;
import
com.mortals.xhx.busiz.rsp.*
;
import
com.mortals.xhx.common.code.ActiveEnum
;
import
com.mortals.xhx.common.code.*
;
import
com.mortals.xhx.common.code.ApiRespCodeEnum
;
import
com.mortals.xhx.common.code.DeviceOnlineStatusEnum
;
import
com.mortals.xhx.common.code.StatusEnum
;
import
com.mortals.xhx.common.key.Constant
;
import
com.mortals.xhx.common.key.Constant
;
import
com.mortals.xhx.common.model.DefaultTbQueueMsgHeaders
;
import
com.mortals.xhx.common.model.DefaultTbQueueMsgHeaders
;
import
com.mortals.xhx.common.model.MessageHeader
;
import
com.mortals.xhx.common.model.MessageHeader
;
...
@@ -90,10 +87,7 @@ public class DeviceApiController {
...
@@ -90,10 +87,7 @@ public class DeviceApiController {
rsp
.
setCode
(
ApiRespCodeEnum
.
SUCCESS
.
getValue
());
rsp
.
setCode
(
ApiRespCodeEnum
.
SUCCESS
.
getValue
());
DeviceResp
deviceResp
=
new
DeviceResp
();
DeviceResp
deviceResp
=
new
DeviceResp
();
try
{
try
{
DeviceEntity
deviceEntity
=
deviceService
.
getExtCache
(
req
.
getDeviceCode
());
DeviceEntity
deviceEntity
=
checkDeviceExist
(
req
);
if
(
ObjectUtils
.
isEmpty
(
deviceEntity
))
{
throw
new
AppException
(
"当前设备不存在!"
);
}
if
(
deviceEntity
.
getActive
()
!=
ActiveEnum
.
已激活
.
getValue
())
{
if
(
deviceEntity
.
getActive
()
!=
ActiveEnum
.
已激活
.
getValue
())
{
throw
new
AppException
(
"当前设备未激活,请在后台配置后再激活!"
);
throw
new
AppException
(
"当前设备未激活,请在后台配置后再激活!"
);
}
}
...
@@ -250,56 +244,34 @@ public class DeviceApiController {
...
@@ -250,56 +244,34 @@ public class DeviceApiController {
return
JSON
.
toJSONString
(
rsp
);
return
JSON
.
toJSONString
(
rsp
);
}
}
/**
/**
*
保存或更新设备
*
设备对外接收接口
*
*
* @param req
* @param req
* @return
* @return
*/
*/
@PostMapping
(
"
saveOrUpdat
e"
)
@PostMapping
(
"
receiv
e"
)
@ApiUserAuth
@ApiUserAuth
public
String
saveOrUpdat
e
(
@RequestBody
DeviceReq
req
)
{
public
String
receiv
e
(
@RequestBody
DeviceReq
req
)
{
log
.
info
(
"【
保存或更新设备
】【请求体】--> "
+
JSONObject
.
toJSONString
(
req
));
log
.
info
(
"【
设备接收
】【请求体】--> "
+
JSONObject
.
toJSONString
(
req
));
ApiResp
<
String
>
rsp
=
new
ApiResp
<>();
ApiResp
<
String
>
rsp
=
new
ApiResp
<>();
rsp
.
setMsg
(
ApiRespCodeEnum
.
SUCCESS
.
getLabel
());
rsp
.
setMsg
(
ApiRespCodeEnum
.
SUCCESS
.
getLabel
());
rsp
.
setCode
(
ApiRespCodeEnum
.
SUCCESS
.
getValue
());
rsp
.
setCode
(
ApiRespCodeEnum
.
SUCCESS
.
getValue
());
try
{
try
{
//根据设备编码查询设备
switch
(
DeviceStatusEnum
.
getByValue
(
req
.
getReceiveMethod
()))
{
DeviceEntity
deviceEntity
=
deviceService
.
getExtCache
(
req
.
getDeviceCode
());
case
ADD:
if
(!
ObjectUtils
.
isEmpty
(
deviceEntity
))
{
deviceAdd
(
req
);
// TODO: 2022/5/13 设备更新
case
UPDATE:
deviceUpdate
(
req
);
//log.info(String.format("sendMsgResp:%s", JSON.toJSONString(sendDeviceMessageResp)));
case
DEL:
}
else
{
deviceDel
(
req
);
if
(
ObjectUtils
.
isEmpty
(
req
.
getPlatformCode
()))
{
case
ACTIVE:
throw
new
AppException
(
"当前平台编码为空!"
);
deviceActive
(
req
);
}
case
ENABLED:
PlatformEntity
platformEntity
=
platformService
.
selectOne
(
new
PlatformQuery
().
platformSn
(
req
.
getPlatformCode
()));
deviceEnabled
(
req
);
if
(
ObjectUtils
.
isEmpty
(
platformEntity
))
{
case
STOP:
throw
new
AppException
(
"所属系统平台不存在!"
);
deviceStop
(
req
);
}
if
(
ObjectUtils
.
isEmpty
(
req
.
getPlatformCode
()))
{
throw
new
AppException
(
"当前产品Code为空!"
);
}
ProductEntity
productEntity
=
productService
.
selectOne
(
new
ProductQuery
().
productCode
(
req
.
getProductCode
()));
if
(
ObjectUtils
.
isEmpty
(
productEntity
))
{
throw
new
AppException
(
"所属产品编码不存在"
);
}
deviceEntity
=
new
DeviceEntity
();
deviceEntity
.
initAttrValue
();
deviceEntity
.
setDeviceName
(
req
.
getDeviceName
());
deviceEntity
.
setDeviceCode
(
req
.
getDeviceCode
());
deviceEntity
.
setDeviceMac
(
req
.
getDeviceCode
());
deviceEntity
.
setSiteCode
(
req
.
getSiteCode
());
deviceEntity
.
setSiteName
(
req
.
getSiteName
());
deviceEntity
.
setPlatformId
(
platformEntity
.
getId
());
deviceEntity
.
setPlatformName
(
platformEntity
.
getPlatformName
());
deviceEntity
.
setProductId
(
productEntity
.
getId
());
deviceEntity
.
setProductName
(
productEntity
.
getProductName
());
deviceEntity
.
setDeviceRemark
(
req
.
getDeviceRemark
());
deviceEntity
.
setCreateUserId
(
1L
);
deviceEntity
.
setCreateTime
(
new
Date
());
deviceService
.
save
(
deviceEntity
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"接收数据失败"
,
e
);
log
.
error
(
"接收数据失败"
,
e
);
...
@@ -307,85 +279,137 @@ public class DeviceApiController {
...
@@ -307,85 +279,137 @@ public class DeviceApiController {
rsp
.
setMsg
(
e
.
getMessage
());
rsp
.
setMsg
(
e
.
getMessage
());
return
JSON
.
toJSONString
(
rsp
);
return
JSON
.
toJSONString
(
rsp
);
}
}
log
.
info
(
"响应【设备接收】【响应体】--> "
+
JSONObject
.
toJSONString
(
rsp
));
log
.
info
(
"响应【保存或更新设备】【响应体】--> "
+
JSONObject
.
toJSONString
(
rsp
));
return
JSON
.
toJSONString
(
rsp
);
return
JSON
.
toJSONString
(
rsp
);
}
}
/**
private
void
deviceAdd
(
DeviceReq
req
)
throws
AppException
{
* 激活设备
log
.
info
(
"【设备新增】【请求体】--> "
+
JSONObject
.
toJSONString
(
req
));
*
//根据设备编码查询设备
* @param req
DeviceEntity
deviceEntity
=
deviceService
.
getExtCache
(
req
.
getDeviceCode
());
* @return
if
(!
ObjectUtils
.
isEmpty
(
deviceEntity
))
{
*/
throw
new
AppException
(
"当前设备编码已存在!"
);
@PostMapping
(
"active"
)
@ApiUserAuth
public
String
active
(
@RequestBody
DeviceReq
req
)
{
log
.
info
(
"【激活设备】【请求体】--> "
+
JSONObject
.
toJSONString
(
req
));
ApiResp
<
String
>
rsp
=
new
ApiResp
<>();
rsp
.
setMsg
(
ApiRespCodeEnum
.
SUCCESS
.
getLabel
());
rsp
.
setCode
(
ApiRespCodeEnum
.
SUCCESS
.
getValue
());
try
{
//根据设备编码查询设备
DeviceEntity
deviceEntity
=
deviceService
.
getExtCache
(
req
.
getDeviceCode
());
if
(
ObjectUtils
.
isEmpty
(
deviceEntity
))
{
throw
new
AppException
(
"当前设备不存在!"
);
}
if
(
deviceEntity
.
getActive
()
==
ActiveEnum
.
已激活
.
getValue
())
{
throw
new
AppException
(
"当前设备已激活!"
);
}
deviceEntity
.
setActive
(
ActiveEnum
.
已激活
.
getValue
());
deviceEntity
.
setUpdateTime
(
new
Date
());
deviceEntity
.
setUpdateUserId
(
1L
);
deviceService
.
update
(
deviceEntity
);
}
catch
(
Exception
e
)
{
log
.
error
(
"接收数据失败"
,
e
);
rsp
.
setCode
(
ApiRespCodeEnum
.
FAILED
.
getValue
());
rsp
.
setMsg
(
e
.
getMessage
());
return
JSON
.
toJSONString
(
rsp
);
}
}
log
.
info
(
"响应【激活设备】【响应体】--> "
+
JSONObject
.
toJSONString
(
rsp
));
if
(
ObjectUtils
.
isEmpty
(
req
.
getPlatformCode
()))
{
return
JSON
.
toJSONString
(
rsp
);
throw
new
AppException
(
"当前平台编码为空!"
);
}
PlatformEntity
platformEntity
=
platformService
.
selectOne
(
new
PlatformQuery
().
platformSn
(
req
.
getPlatformCode
()));
if
(
ObjectUtils
.
isEmpty
(
platformEntity
))
{
throw
new
AppException
(
"所属系统平台不存在!"
);
}
if
(
ObjectUtils
.
isEmpty
(
req
.
getPlatformCode
()))
{
throw
new
AppException
(
"当前产品Code为空!"
);
}
ProductEntity
productEntity
=
productService
.
selectOne
(
new
ProductQuery
().
productCode
(
req
.
getProductCode
()));
if
(
ObjectUtils
.
isEmpty
(
productEntity
))
{
throw
new
AppException
(
"所属产品编码不存在"
);
}
deviceEntity
=
new
DeviceEntity
();
deviceEntity
.
initAttrValue
();
deviceEntity
.
setDeviceName
(
req
.
getDeviceName
());
deviceEntity
.
setDeviceCode
(
req
.
getDeviceCode
());
deviceEntity
.
setDeviceMac
(
req
.
getDeviceCode
());
deviceEntity
.
setSiteCode
(
req
.
getSiteCode
());
deviceEntity
.
setSiteName
(
req
.
getSiteName
());
deviceEntity
.
setPlatformId
(
platformEntity
.
getId
());
deviceEntity
.
setPlatformName
(
platformEntity
.
getPlatformName
());
deviceEntity
.
setProductId
(
productEntity
.
getId
());
deviceEntity
.
setProductName
(
productEntity
.
getProductName
());
deviceEntity
.
setDeviceRemark
(
req
.
getDeviceRemark
());
deviceEntity
.
setCreateUserId
(
1L
);
deviceEntity
.
setCreateTime
(
new
Date
());
deviceService
.
save
(
deviceEntity
);
}
}
private
void
deviceUpdate
(
DeviceReq
req
)
throws
AppException
{
log
.
info
(
"【设备更新】【请求体】--> "
+
JSONObject
.
toJSONString
(
req
));
//根据设备编码查询设备
DeviceEntity
deviceEntity
=
deviceService
.
getExtCache
(
req
.
getDeviceCode
());
/**
if
(
ObjectUtils
.
isEmpty
(
deviceEntity
))
{
* 删除设备
throw
new
AppException
(
"当前设备编码不存在!"
);
*
* @param req
* @return
*/
@PostMapping
(
"deviceDel"
)
@ApiUserAuth
public
String
deviceDel
(
@RequestBody
DeviceReq
req
)
{
log
.
info
(
"【删除设备】【请求体】--> "
+
JSONObject
.
toJSONString
(
req
));
ApiResp
<
String
>
rsp
=
new
ApiResp
<>();
rsp
.
setMsg
(
ApiRespCodeEnum
.
SUCCESS
.
getLabel
());
rsp
.
setCode
(
ApiRespCodeEnum
.
SUCCESS
.
getValue
());
try
{
//根据设备编码查询设备
DeviceEntity
deviceEntity
=
deviceService
.
getExtCache
(
req
.
getDeviceCode
());
if
(
ObjectUtils
.
isEmpty
(
deviceEntity
))
{
throw
new
AppException
(
"当前设备不存在!"
);
}
deviceService
.
remove
(
deviceEntity
.
getId
(),
null
);
}
catch
(
Exception
e
)
{
log
.
error
(
"接收数据失败"
,
e
);
rsp
.
setCode
(
ApiRespCodeEnum
.
FAILED
.
getValue
());
rsp
.
setMsg
(
e
.
getMessage
());
return
JSON
.
toJSONString
(
rsp
);
}
}
log
.
info
(
"响应【删除设备】【响应体】--> "
+
JSONObject
.
toJSONString
(
rsp
));
if
(
ObjectUtils
.
isEmpty
(
req
.
getPlatformCode
()))
{
return
JSON
.
toJSONString
(
rsp
);
throw
new
AppException
(
"当前平台编码为空!"
);
}
PlatformEntity
platformEntity
=
platformService
.
selectOne
(
new
PlatformQuery
().
platformSn
(
req
.
getPlatformCode
()));
if
(
ObjectUtils
.
isEmpty
(
platformEntity
))
{
throw
new
AppException
(
"所属系统平台不存在!"
);
}
if
(
ObjectUtils
.
isEmpty
(
req
.
getPlatformCode
()))
{
throw
new
AppException
(
"当前产品Code为空!"
);
}
ProductEntity
productEntity
=
productService
.
selectOne
(
new
ProductQuery
().
productCode
(
req
.
getProductCode
()));
if
(
ObjectUtils
.
isEmpty
(
productEntity
))
{
throw
new
AppException
(
"所属产品编码不存在"
);
}
deviceEntity
.
setDeviceName
(
req
.
getDeviceName
());
deviceEntity
.
setDeviceCode
(
req
.
getDeviceCode
());
deviceEntity
.
setDeviceMac
(
req
.
getDeviceCode
());
deviceEntity
.
setSiteCode
(
req
.
getSiteCode
());
deviceEntity
.
setSiteName
(
req
.
getSiteName
());
deviceEntity
.
setPlatformId
(
platformEntity
.
getId
());
deviceEntity
.
setPlatformName
(
platformEntity
.
getPlatformName
());
deviceEntity
.
setProductId
(
productEntity
.
getId
());
deviceEntity
.
setProductName
(
productEntity
.
getProductName
());
deviceEntity
.
setDeviceRemark
(
req
.
getDeviceRemark
());
deviceEntity
.
setUpdateUserId
(
1L
);
deviceEntity
.
setUpdateTime
(
new
Date
());
deviceService
.
save
(
deviceEntity
);
}
}
private
void
deviceDel
(
DeviceReq
req
)
throws
AppException
{
log
.
info
(
"【设备删除】【请求体】--> "
+
JSONObject
.
toJSONString
(
req
));
//根据设备编码查询设备
DeviceEntity
deviceEntity
=
checkDeviceExist
(
req
);
deviceService
.
remove
(
deviceEntity
.
getId
(),
null
);
public
static
void
main
(
String
[]
args
)
{
UserEntity
userEntity
=
new
UserEntity
();
userEntity
.
setToken
(
"1231231"
);
System
.
out
.
println
(
userEntity
.
getToken
());
}
}
private
void
deviceActive
(
DeviceReq
req
)
throws
AppException
{
log
.
info
(
"【设备激活】【请求体】--> "
+
JSONObject
.
toJSONString
(
req
));
//根据设备编码查询设备
DeviceEntity
deviceEntity
=
checkDeviceExist
(
req
);
if
(
deviceEntity
.
getActive
()
==
ActiveEnum
.
已激活
.
getValue
())
{
throw
new
AppException
(
"当前设备已激活!"
);
}
deviceEntity
.
setActive
(
ActiveEnum
.
已激活
.
getValue
());
deviceEntity
.
setUpdateTime
(
new
Date
());
deviceEntity
.
setUpdateUserId
(
1L
);
deviceService
.
update
(
deviceEntity
);
}
private
void
deviceEnabled
(
DeviceReq
req
)
throws
AppException
{
log
.
info
(
"【设备启用】【请求体】--> "
+
JSONObject
.
toJSONString
(
req
));
//根据设备编码查询设备
DeviceEntity
deviceEntity
=
checkDeviceExist
(
req
);
deviceEntity
.
setActive
(
YesNoEnum
.
YES
.
getValue
());
deviceEntity
.
setUpdateTime
(
new
Date
());
deviceEntity
.
setUpdateUserId
(
1L
);
deviceService
.
update
(
deviceEntity
);
}
private
void
deviceStop
(
DeviceReq
req
)
throws
AppException
{
log
.
info
(
"【设备停用】【请求体】--> "
+
JSONObject
.
toJSONString
(
req
));
DeviceEntity
deviceEntity
=
checkDeviceExist
(
req
);
deviceEntity
.
setActive
(
YesNoEnum
.
YES
.
getValue
());
deviceEntity
.
setUpdateTime
(
new
Date
());
deviceEntity
.
setUpdateUserId
(
1L
);
deviceService
.
update
(
deviceEntity
);
}
private
DeviceEntity
checkDeviceExist
(
DeviceReq
req
)
{
DeviceEntity
deviceEntity
=
deviceService
.
getExtCache
(
req
.
getDeviceCode
());
if
(
ObjectUtils
.
isEmpty
(
deviceEntity
))
{
throw
new
AppException
(
"当前设备不存在!"
);
}
return
deviceEntity
;
}
}
}
This diff is collapsed.
Click to expand it.
device-manager/src/main/java/com/mortals/xhx/common/code/DeviceStatusEnum.java
View file @
7e9a64b4
...
@@ -4,7 +4,7 @@ import java.util.LinkedHashMap;
...
@@ -4,7 +4,7 @@ import java.util.LinkedHashMap;
import
java.util.Map
;
import
java.util.Map
;
/**
/**
* 设备状态,1:新增,2:修改,3:删除,4:激活,5:
上线,6:下线
* 设备状态,1:新增,2:修改,3:删除,4:激活,5:
启用,6:停用
*
*
* @author zxfei
* @author zxfei
*/
*/
...
@@ -13,8 +13,8 @@ public enum DeviceStatusEnum {
...
@@ -13,8 +13,8 @@ public enum DeviceStatusEnum {
UPDATE
(
2
,
"修改"
),
UPDATE
(
2
,
"修改"
),
DEL
(
3
,
"删除"
),
DEL
(
3
,
"删除"
),
ACTIVE
(
4
,
"激活"
),
ACTIVE
(
4
,
"激活"
),
ONLINE
(
5
,
"上线
"
),
ENABLED
(
5
,
"启用
"
),
OFFLINE
(
6
,
"下线
"
);
STOP
(
6
,
"停用
"
);
private
Integer
value
;
private
Integer
value
;
private
String
desc
;
private
String
desc
;
...
...
This diff is collapsed.
Click to expand it.
device-manager/src/main/java/com/mortals/xhx/common/utils/SendTask.java
View file @
7e9a64b4
package
com.mortals.xhx.common.utils
;
package
com.mortals.xhx.common.utils
;
import
com.alibaba.fastjson.JSON
;
import
com.mortals.framework.util.HttpUtil
;
import
com.mortals.framework.util.HttpUtil
;
import
com.mortals.xhx.busiz.req.ApiThirdPartyReq
;
import
com.mortals.xhx.busiz.req.DeviceReq
;
import
com.mortals.xhx.busiz.rsp.ApiResp
;
import
com.mortals.xhx.common.code.MessageTypeEnum
;
import
com.mortals.xhx.common.code.YesNoEnum
;
import
lombok.AllArgsConstructor
;
import
lombok.AllArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
java.util.HashMap
;
import
java.util.Map
;
import
static
com
.
mortals
.
framework
.
util
.
HttpUtil
.
HEADER_CONTENT_TYPE
;
/**
/**
* 发送任务
* 发送任务
*
*
...
@@ -20,13 +31,17 @@ public class SendTask implements Runnable {
...
@@ -20,13 +31,17 @@ public class SendTask implements Runnable {
private
String
content
;
private
String
content
;
@Override
@Override
public
void
run
()
{
public
void
run
()
{
// TODO: 2022/4/28
ApiThirdPartyReq
<
String
>
deviceReqApiReq
=
new
ApiThirdPartyReq
<>();
deviceReqApiReq
.
setCode
(
YesNoEnum
.
YES
.
getValue
());
deviceReqApiReq
.
setType
(
MessageTypeEnum
.
TRANSACTION
.
getValue
());
deviceReqApiReq
.
setData
(
content
);
String
resp
=
null
;
try
{
try
{
// log.debug("启动发送"+smsGateQueueEntity
);
Map
<
String
,
String
>
header
=
new
HashMap
<>(
);
String
resp
=
HttpUtil
.
doPost
(
sendUrl
,
content
);
header
.
put
(
HEADER_CONTENT_TYPE
,
"application/json"
);
log
.
debug
(
"http resp:{}"
,
resp
);
resp
=
HttpUtil
.
doPost
(
sendUrl
,
header
,
JSON
.
toJSONString
(
deviceReqApiReq
)
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"
发送异常:"
+
e
);
log
.
error
(
"
异常:"
,
e
);
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
device-manager/src/main/java/com/mortals/xhx/daemon/DemoApiController.java
View file @
7e9a64b4
...
@@ -166,7 +166,7 @@ public class DemoApiController {
...
@@ -166,7 +166,7 @@ public class DemoApiController {
TbQueueMsgHeaders
header
=
new
DefaultTbQueueMsgHeaders
();
TbQueueMsgHeaders
header
=
new
DefaultTbQueueMsgHeaders
();
header
.
put
(
MessageHeader
.
MESSAGETYPE
,
Constant
.
MESSAGETYPE_HEARTBEAT
);
header
.
put
(
MessageHeader
.
MESSAGETYPE
,
Constant
.
MESSAGETYPE_HEARTBEAT
);
UploadDeviceReq
uploadDeviceReq
=
new
UploadDeviceReq
();
UploadDeviceReq
uploadDeviceReq
=
new
UploadDeviceReq
();
uploadDeviceReq
.
setDeviceMac
(
deviceEntity
.
getDeviceMac
());
//
uploadDeviceReq.setDeviceMac(deviceEntity.getDeviceMac());
uploadDeviceReq
.
setDeviceCode
(
deviceEntity
.
getDeviceCode
());
uploadDeviceReq
.
setDeviceCode
(
deviceEntity
.
getDeviceCode
());
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
for
(
int
i
=
0
;
i
<
100
;
i
++)
{
...
...
This diff is collapsed.
Click to expand it.
device-manager/src/main/java/com/mortals/xhx/daemon/applicationservice/DeviceMsgComsumerStartedService.java
View file @
7e9a64b4
...
@@ -69,6 +69,8 @@ public class DeviceMsgComsumerStartedService implements IApplicationStartedServi
...
@@ -69,6 +69,8 @@ public class DeviceMsgComsumerStartedService implements IApplicationStartedServi
if
(!
ObjectUtils
.
isEmpty
(
mainConsumer
))
{
if
(!
ObjectUtils
.
isEmpty
(
mainConsumer
))
{
//订阅所有已几快活设备
//订阅所有已几快活设备
Set
<
TopicPartitionInfo
>
topicPartitionInfoSet
=
deviceService
.
find
(
new
DeviceQuery
().
active
(
ActiveEnum
.
已激活
.
getValue
()).
status
(
StatusEnum
.
启用
.
getValue
())).
stream
()
Set
<
TopicPartitionInfo
>
topicPartitionInfoSet
=
deviceService
.
find
(
new
DeviceQuery
().
active
(
ActiveEnum
.
已激活
.
getValue
()).
status
(
StatusEnum
.
启用
.
getValue
())).
stream
()
.
filter
(
f
->!
ObjectUtils
.
isEmpty
(
platformService
.
get
(
f
.
getPlatformId
())))
.
filter
(
f
->!
ObjectUtils
.
isEmpty
(
productService
.
get
(
f
.
getProductId
())))
.
map
(
item
->
{
.
map
(
item
->
{
PlatformEntity
platformEntity
=
platformService
.
get
(
item
.
getPlatformId
());
PlatformEntity
platformEntity
=
platformService
.
get
(
item
.
getPlatformId
());
ProductEntity
productEntity
=
productService
.
get
(
item
.
getProductId
());
ProductEntity
productEntity
=
productService
.
get
(
item
.
getProductId
());
...
@@ -161,8 +163,6 @@ public class DeviceMsgComsumerStartedService implements IApplicationStartedServi
...
@@ -161,8 +163,6 @@ public class DeviceMsgComsumerStartedService implements IApplicationStartedServi
}
}
deviceEntity
.
setOnlineTime
(
new
Date
());
deviceEntity
.
setOnlineTime
(
new
Date
());
deviceEntity
.
setDeviceOnlineStatus
(
DeviceOnlineStatusEnum
.
在线
.
getValue
());
deviceEntity
.
setDeviceOnlineStatus
(
DeviceOnlineStatusEnum
.
在线
.
getValue
());
deviceEntity
.
setIp
(
deviceReq
.
getIp
());
deviceEntity
.
setPort
(
deviceReq
.
getPort
());
deviceService
.
update
(
deviceEntity
);
deviceService
.
update
(
deviceEntity
);
DeviceLogEntity
deviceLogEntity
=
new
DeviceLogEntity
();
DeviceLogEntity
deviceLogEntity
=
new
DeviceLogEntity
();
...
@@ -179,11 +179,14 @@ public class DeviceMsgComsumerStartedService implements IApplicationStartedServi
...
@@ -179,11 +179,14 @@ public class DeviceMsgComsumerStartedService implements IApplicationStartedServi
//获取exchange,
//获取exchange,
PlatformEntity
platformEntity
=
platformService
.
get
(
deviceEntity
.
getPlatformId
());
PlatformEntity
platformEntity
=
platformService
.
get
(
deviceEntity
.
getPlatformId
());
if
(!
ObjectUtils
.
isEmpty
(
platformEntity
)
&&
platformEntity
.
getSendSwitch
()
==
YesNoEnum
.
YES
.
getValue
())
{
if
(!
ObjectUtils
.
isEmpty
(
platformEntity
)
&&
platformEntity
.
getSendSwitch
()
==
YesNoEnum
.
YES
.
getValue
())
{
if
(
platformEntity
.
getSendMsgType
()
==
SendMsgTypeEnum
.
http
.
getValue
()
&&
!
ObjectUtils
.
isEmpty
(
platformEntity
.
getSend
Config
()))
{
if
(
platformEntity
.
getSendMsgType
()
==
SendMsgTypeEnum
.
http
.
getValue
()
&&
!
ObjectUtils
.
isEmpty
(
platformEntity
.
getSend
Url
()))
{
//http方式
//http方式
//通过线程池进行发送消息
//通过线程池进行发送消息
SendTask
sendTask
=
new
SendTask
(
platformEntity
.
getSendConfig
(),
new
String
(
queueMsg
.
getData
()));
sendTaskThreadPool
.
execute
(
sendTask
);
SendTask
sendTask
=
new
SendTask
(
platformEntity
.
getSendUrl
(),
new
String
(
queueMsg
.
getData
()));
sendTaskThreadPool
.
execute
(
sendTask
);
}
}
}
}
// if (bool) {
// if (bool) {
...
...
This diff is collapsed.
Click to expand it.
device-manager/src/main/java/com/mortals/xhx/module/device/service/DeviceService.java
View file @
7e9a64b4
...
@@ -31,5 +31,12 @@ public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{
...
@@ -31,5 +31,12 @@ public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{
*/
*/
void
active
(
String
deviceCode
,
Context
context
);
void
active
(
String
deviceCode
,
Context
context
);
/**
* 设备启用停用
* @param deviceCode
* @param context
*/
void
deviceEnabled
(
String
deviceCode
,
Integer
status
,
Context
context
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
View file @
7e9a64b4
package
com.mortals.xhx.module.device.service.impl
;
package
com.mortals.xhx.module.device.service.impl
;
import
cn.hutool.core.lang.PatternPool
;
import
cn.hutool.core.lang.PatternPool
;
import
cn.hutool.http.HttpUtil
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl
;
import
com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl
;
...
@@ -26,10 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -26,10 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.ObjectUtils
;
import
java.util.Arrays
;
import
java.util.*
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
/**
/**
* DeviceService
* DeviceService
...
@@ -80,6 +76,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
...
@@ -80,6 +76,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
public
void
onSuccess
(
TbQueueMsgMetadata
metadata
)
{
public
void
onSuccess
(
TbQueueMsgMetadata
metadata
)
{
log
.
info
(
"消息投递成功,设备通道编码:"
+
deviceEntity
.
getDeviceMac
());
log
.
info
(
"消息投递成功,设备通道编码:"
+
deviceEntity
.
getDeviceMac
());
}
}
@Override
@Override
public
void
onFailure
(
Throwable
t
)
{
public
void
onFailure
(
Throwable
t
)
{
log
.
error
(
"消息投递成功,设备通道编码:"
+
deviceEntity
.
getDeviceMac
(),
t
);
log
.
error
(
"消息投递成功,设备通道编码:"
+
deviceEntity
.
getDeviceMac
(),
t
);
...
@@ -114,7 +111,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
...
@@ -114,7 +111,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
//新增设备通知第三方平台
//新增设备通知第三方平台
DeviceReq
deviceReq
=
new
DeviceReq
();
DeviceReq
deviceReq
=
new
DeviceReq
();
BeanUtils
.
copyProperties
(
deviceEntity
,
deviceReq
,
BeanUtil
.
getNullPropertyNames
(
deviceEntity
));
BeanUtils
.
copyProperties
(
deviceEntity
,
deviceReq
,
BeanUtil
.
getNullPropertyNames
(
deviceEntity
));
deviceReq
.
set
DeviceStatus
(
DeviceStatusEnum
.
ACTIVE
.
getValue
());
deviceReq
.
set
ReceiveMethod
(
DeviceStatusEnum
.
ACTIVE
.
getValue
());
deviceReq
.
setProductCode
(
productEntity
.
getProductCode
());
deviceReq
.
setProductCode
(
productEntity
.
getProductCode
());
deviceReq
.
setPlatformCode
(
platformEntity
.
getPlatformSn
());
deviceReq
.
setPlatformCode
(
platformEntity
.
getPlatformSn
());
if
(!
ObjectUtils
.
isEmpty
(
platformEntity
.
getSendUrl
())
&&
platformEntity
.
getSendSwitch
()
==
SendSwitchEnum
.
启用
.
getValue
())
{
if
(!
ObjectUtils
.
isEmpty
(
platformEntity
.
getSendUrl
())
&&
platformEntity
.
getSendSwitch
()
==
SendSwitchEnum
.
启用
.
getValue
())
{
...
@@ -128,6 +125,16 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
...
@@ -128,6 +125,16 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
}
}
@Override
public
void
deviceEnabled
(
String
deviceCode
,
Integer
status
,
Context
context
)
{
DeviceEntity
deviceEntity
=
this
.
selectOne
(
new
DeviceQuery
().
deviceCode
(
deviceCode
));
if
(!
ObjectUtils
.
isEmpty
(
deviceEntity
))
throw
new
AppException
(
"当前设备不存在!"
);
deviceEntity
.
setStatus
(
status
);
deviceEntity
.
setUpdateTime
(
new
Date
());
deviceEntity
.
setUpdateUserId
(
getContextUserId
(
context
));
this
.
update
(
deviceEntity
,
context
);
}
@Override
@Override
protected
void
saveAfter
(
DeviceEntity
entity
,
Context
context
)
throws
AppException
{
protected
void
saveAfter
(
DeviceEntity
entity
,
Context
context
)
throws
AppException
{
...
@@ -162,7 +169,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
...
@@ -162,7 +169,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
//新增设备通知第三方平台
//新增设备通知第三方平台
DeviceReq
deviceReq
=
new
DeviceReq
();
DeviceReq
deviceReq
=
new
DeviceReq
();
BeanUtils
.
copyProperties
(
entity
,
deviceReq
,
BeanUtil
.
getNullPropertyNames
(
entity
));
BeanUtils
.
copyProperties
(
entity
,
deviceReq
,
BeanUtil
.
getNullPropertyNames
(
entity
));
deviceReq
.
set
DeviceStatus
(
DeviceStatusEnum
.
ADD
.
getValue
());
deviceReq
.
set
ReceiveMethod
(
DeviceStatusEnum
.
ADD
.
getValue
());
deviceReq
.
setProductCode
(
productEntity
.
getProductCode
());
deviceReq
.
setProductCode
(
productEntity
.
getProductCode
());
deviceReq
.
setPlatformCode
(
platformEntity
.
getPlatformSn
());
deviceReq
.
setPlatformCode
(
platformEntity
.
getPlatformSn
());
if
(!
ObjectUtils
.
isEmpty
(
platformEntity
.
getSendUrl
())
&&
platformEntity
.
getSendSwitch
()
==
SendSwitchEnum
.
启用
.
getValue
())
{
if
(!
ObjectUtils
.
isEmpty
(
platformEntity
.
getSendUrl
())
&&
platformEntity
.
getSendSwitch
()
==
SendSwitchEnum
.
启用
.
getValue
())
{
...
@@ -187,7 +194,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
...
@@ -187,7 +194,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
//新增设备通知第三方平台
//新增设备通知第三方平台
DeviceReq
deviceReq
=
new
DeviceReq
();
DeviceReq
deviceReq
=
new
DeviceReq
();
BeanUtils
.
copyProperties
(
entity
,
deviceReq
,
BeanUtil
.
getNullPropertyNames
(
entity
));
BeanUtils
.
copyProperties
(
entity
,
deviceReq
,
BeanUtil
.
getNullPropertyNames
(
entity
));
deviceReq
.
set
DeviceStatus
(
DeviceStatusEnum
.
UPDATE
.
getValue
());
deviceReq
.
set
ReceiveMethod
(
DeviceStatusEnum
.
UPDATE
.
getValue
());
deviceReq
.
setProductCode
(
productEntity
.
getProductCode
());
deviceReq
.
setProductCode
(
productEntity
.
getProductCode
());
deviceReq
.
setPlatformCode
(
platformEntity
.
getPlatformSn
());
deviceReq
.
setPlatformCode
(
platformEntity
.
getPlatformSn
());
if
(!
ObjectUtils
.
isEmpty
(
platformEntity
.
getSendUrl
())
&&
platformEntity
.
getSendSwitch
()
==
SendSwitchEnum
.
启用
.
getValue
())
{
if
(!
ObjectUtils
.
isEmpty
(
platformEntity
.
getSendUrl
())
&&
platformEntity
.
getSendSwitch
()
==
SendSwitchEnum
.
启用
.
getValue
())
{
...
@@ -228,7 +235,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
...
@@ -228,7 +235,7 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
//新增设备通知第三方平台
//新增设备通知第三方平台
DeviceReq
deviceReq
=
new
DeviceReq
();
DeviceReq
deviceReq
=
new
DeviceReq
();
BeanUtils
.
copyProperties
(
deviceEntity
,
deviceReq
,
BeanUtil
.
getNullPropertyNames
(
deviceEntity
));
BeanUtils
.
copyProperties
(
deviceEntity
,
deviceReq
,
BeanUtil
.
getNullPropertyNames
(
deviceEntity
));
deviceReq
.
set
DeviceStatus
(
DeviceStatusEnum
.
DEL
.
getValue
());
deviceReq
.
set
ReceiveMethod
(
DeviceStatusEnum
.
DEL
.
getValue
());
deviceReq
.
setProductCode
(
productEntity
.
getProductCode
());
deviceReq
.
setProductCode
(
productEntity
.
getProductCode
());
deviceReq
.
setPlatformCode
(
platformEntity
.
getPlatformSn
());
deviceReq
.
setPlatformCode
(
platformEntity
.
getPlatformSn
());
if
(!
ObjectUtils
.
isEmpty
(
platformEntity
.
getSendUrl
())
&&
platformEntity
.
getSendSwitch
()
==
SendSwitchEnum
.
启用
.
getValue
())
{
if
(!
ObjectUtils
.
isEmpty
(
platformEntity
.
getSendUrl
())
&&
platformEntity
.
getSendSwitch
()
==
SendSwitchEnum
.
启用
.
getValue
())
{
...
...
This diff is collapsed.
Click to expand it.
device-manager/src/main/java/com/mortals/xhx/module/device/web/DeviceController.java
View file @
7e9a64b4
...
@@ -188,4 +188,26 @@ public class DeviceController extends BaseCRUDJsonMappingController<DeviceServic
...
@@ -188,4 +188,26 @@ public class DeviceController extends BaseCRUDJsonMappingController<DeviceServic
return
jsonObject
.
toJSONString
();
return
jsonObject
.
toJSONString
();
}
}
/**
* 设备启用停用
*/
@PostMapping
(
value
=
"enable"
)
public
String
deviceEnable
(
@RequestParam
(
value
=
"deviceCode"
)
String
deviceCode
,
@RequestParam
(
value
=
"status"
)
Integer
status
)
{
JSONObject
jsonObject
=
new
JSONObject
();
Map
<
String
,
Object
>
model
=
new
HashMap
<>();
String
busiDesc
=
this
.
getModuleDesc
()
+
"设备启用停用"
;
try
{
this
.
service
.
active
(
deviceCode
,
getContext
());
this
.
init
(
request
,
response
,
null
,
model
,
getContext
());
recordSysLog
(
request
,
busiDesc
+
" 【成功】"
);
jsonObject
.
put
(
KEY_RESULT_DATA
,
model
);
jsonObject
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_SUCCESS
);
}
catch
(
Exception
e
)
{
log
.
error
(
"设备激活消息"
,
e
);
jsonObject
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_FAILURE
);
jsonObject
.
put
(
KEY_RESULT_MSG
,
super
.
convertException
(
e
));
}
return
jsonObject
.
toJSONString
();
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
doc/api.md
View file @
7e9a64b4
...
@@ -150,14 +150,6 @@ password|String|平台用户密码|是|-
...
@@ -150,14 +150,6 @@ password|String|平台用户密码|是|-
code|Integer|结果码(-1.失败,1.成功)|-
code|Integer|结果码(-1.失败,1.成功)|-
msg|String|消息|-
msg|String|消息|-
data|object|数据对象|-
data|object|数据对象|-
 
platformList|array|平台列表|数组
  
id|Long|ID|-
  
platformName|String|平台名称,名称唯一|-
  
platformSn|String|平台编码,编码唯一|-
 
productList|array|产品列表|数组
  
id|Long|ID|-
  
productName|String|产品名称,名称唯一|-
  
productCode|String|产品编码,编码唯一|-
**响应消息样例:**
**响应消息样例:**
...
@@ -167,9 +159,9 @@ data|object|数据对象|-
...
@@ -167,9 +159,9 @@ data|object|数据对象|-
###
新增或更新设备
###
接收第三方平台设备消息
**请求URL:**
m/api/
saveOrUpdat
e
**请求URL:**
m/api/
receiv
e
**请求方式:**
POST
**请求方式:**
POST
...
@@ -177,13 +169,13 @@ data|object|数据对象|-
...
@@ -177,13 +169,13 @@ data|object|数据对象|-
**内容类型:**
application/json;charset=utf-8
**内容类型:**
application/json;charset=utf-8
**简要描述:**
保存或更新设备,设备deviceCode存在更新,不存在新增,
**简要描述:**
请求需添加接口鉴权token信息,来源getToken接口
**请求参数:**
**请求参数:**
参数名称|类型|备注|必填|其它
参数名称|类型|备注|必填|其它
---|---|---|---|---
---|---|---|---|---
receiveMethod|Integer|1:新增,2:修改,3:删除,4:激活,5:启用,6:停用|是|-
deviceName|String|设备名称|否|-
deviceName|String|设备名称|否|-
deviceCode|String|设备编码,如MAC地址|是|-
deviceCode|String|设备编码,如MAC地址|是|-
platformCode|String|平台系统编码|是|见平台编码附录
platformCode|String|平台系统编码|是|见平台编码附录
...
@@ -213,87 +205,6 @@ data|object|数据对象|-
...
@@ -213,87 +205,6 @@ data|object|数据对象|-
```
```
### 激活设备
**请求URL:**
m/api/active
**请求方式:**
POST
**鉴权头信息:**
Authorization: {{token}}
**内容类型:**
application/json;charset=utf-8
**简要描述:**
激活设备
请求需添加接口鉴权token信息,来源getToken接口
**请求参数:**
参数名称|类型|备注|必填|其它
---|---|---|---|---
deviceCode|String|设备编码|是|-
**请求样例:**
```
{
"deviceCode":"yte9s3",
}
```
**响应参数:**
参数名称 |参数类型|备注|其它
---|---|---|---
code|Integer|结果码(-1.失败,1.成功)|-
msg|String|消息|-
data|object|数据对象|-
**响应消息样例:**
```
```
### 删除设备
**请求URL:**
m/api/deviceDel
**请求方式:**
POST
**鉴权头信息:**
Authorization: {{token}}
**内容类型:**
application/json;charset=utf-8
**简要描述:**
删除设备
请求需添加接口鉴权token信息,来源getToken接口
**请求参数:**
参数名称|类型|备注|必填|其它
---|---|---|---|---
deviceCode|String|设备编码|是|-
**请求样例:**
```
{
"deviceCode":"yte9s3",
}
```
**响应参数:**
参数名称 |参数类型|备注|其它
---|---|---|---
code|Integer|结果码(-1.失败,1.成功)|-
msg|String|消息|-
data|object|数据对象|-
**响应消息样例:**
```
```
### 回调各个平台通知消息
### 回调各个平台通知消息
...
@@ -313,7 +224,7 @@ code|Integer|结果码(-1.失败,1.成功)|是|-
...
@@ -313,7 +224,7 @@ code|Integer|结果码(-1.失败,1.成功)|是|-
msg|String|消息|否|-
msg|String|消息|否|-
type|Integer|消息类型|是|0:设备增删改查,data数据域封装具体设备消息,1:设备消息类,数据域透传设备上行消息体。|-
type|Integer|消息类型|是|0:设备增删改查,data数据域封装具体设备消息,1:设备消息类,数据域透传设备上行消息体。|-
data|object|数据对象|是|-
data|object|数据对象|是|-
 
deviceStatus|Integer|状态,1:新增,2:修改,3:删除,4:激活,5:
上线,6
:下线|是|-
 
deviceStatus|Integer|状态,1:新增,2:修改,3:删除,4:激活,5:
启用,6:停用,7:上线,8
:下线|是|-
 
deviceName|String|设备名称|否|-
 
deviceName|String|设备名称|否|-
 
deviceCode|String|设备编码,如MAC地址|是|-
 
deviceCode|String|设备编码,如MAC地址|是|-
 
platformCode|String|平台系统编码|是|见平台编码附录
 
platformCode|String|平台系统编码|是|见平台编码附录
...
...
This diff is collapsed.
Click to expand it.
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