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
229f8acb
Commit
229f8acb
authored
May 30, 2022
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改平台编码
parent
12e00717
Changes
19
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
1525 additions
and
1011 deletions
+1525
-1011
db/module.sql
db/module.sql
+4
-1
device-manager/src/main/java/com/mortals/xhx/base/system/message/MessageService.java
...a/com/mortals/xhx/base/system/message/MessageService.java
+6
-0
device-manager/src/main/java/com/mortals/xhx/base/system/message/impl/MessageServiceImpl.java
...tals/xhx/base/system/message/impl/MessageServiceImpl.java
+20
-0
device-manager/src/main/java/com/mortals/xhx/base/system/user/model/UserEntity.java
...va/com/mortals/xhx/base/system/user/model/UserEntity.java
+6
-0
device-manager/src/main/java/com/mortals/xhx/busiz/req/ApiThirdPartyReq.java
...main/java/com/mortals/xhx/busiz/req/ApiThirdPartyReq.java
+24
-0
device-manager/src/main/java/com/mortals/xhx/busiz/req/DeviceReq.java
...er/src/main/java/com/mortals/xhx/busiz/req/DeviceReq.java
+13
-28
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceApiController.java
...n/java/com/mortals/xhx/busiz/web/DeviceApiController.java
+0
-2
device-manager/src/main/java/com/mortals/xhx/common/code/DeviceStatusEnum.java
...in/java/com/mortals/xhx/common/code/DeviceStatusEnum.java
+69
-0
device-manager/src/main/java/com/mortals/xhx/common/code/MessageTypeEnum.java
...ain/java/com/mortals/xhx/common/code/MessageTypeEnum.java
+61
-0
device-manager/src/main/java/com/mortals/xhx/common/key/ErrorCode.java
...r/src/main/java/com/mortals/xhx/common/key/ErrorCode.java
+78
-0
device-manager/src/main/java/com/mortals/xhx/common/key/HttpStatus.java
.../src/main/java/com/mortals/xhx/common/key/HttpStatus.java
+89
-0
device-manager/src/main/java/com/mortals/xhx/module/device/service/DeviceService.java
.../com/mortals/xhx/module/device/service/DeviceService.java
+6
-1
device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
...als/xhx/module/device/service/impl/DeviceServiceImpl.java
+97
-11
device-manager/src/main/java/com/mortals/xhx/module/platform/model/PlatformEntity.java
...com/mortals/xhx/module/platform/model/PlatformEntity.java
+109
-67
device-manager/src/main/java/com/mortals/xhx/module/platform/model/PlatformQuery.java
.../com/mortals/xhx/module/platform/model/PlatformQuery.java
+446
-372
device-manager/src/main/java/com/mortals/xhx/module/platform/web/PlatformController.java
...m/mortals/xhx/module/platform/web/PlatformController.java
+0
-133
device-manager/src/main/resources/sqlmap/module/platform/PlatformMapper.xml
.../main/resources/sqlmap/module/platform/PlatformMapper.xml
+424
-356
doc/api.md
doc/api.md
+73
-40
doc/设备管理系统.docx
doc/设备管理系统.docx
+0
-0
No files found.
db/module.sql
View file @
229f8acb
...
...
@@ -55,8 +55,10 @@ CREATE TABLE mortals_xhx_platform(
`platformName`
varchar
(
20
)
NOT
NULL
COMMENT
'平台名称,名称唯一'
,
`platformSn`
varchar
(
256
)
NOT
NULL
COMMENT
'平台编码,编码唯一(编码加上站点编码,如phxt-51010251-1做Vhost虚拟机编码)'
,
`sendMsgType`
tinyint
(
2
)
NOT
NULL
COMMENT
'发送第三方平台消息类型(0.http,1.jms)'
,
`sendConfig`
varchar
(
2048
)
COMMENT
'发送参数配置,如发送消息地址等,xml结构,根据消息类型变化'
,
`sendUrl`
varchar
(
512
)
COMMENT
'发送参数请求地址'
,
`callbackUrl`
varchar
(
512
)
COMMENT
'回调参数地址'
,
`sendSwitch`
tinyint
(
2
)
NOT
NULL
COMMENT
'是否启用发送消息(0.停用,1.启用)'
,
`homeUrl`
varchar
(
512
)
COMMENT
'首页地址'
,
`platformRemark`
varchar
(
256
)
COMMENT
'备注'
,
`createUserId`
bigint
(
20
)
NOT
NULL
COMMENT
'创建用户'
,
`createTime`
datetime
NOT
NULL
COMMENT
'创建时间'
,
...
...
@@ -64,6 +66,7 @@ CREATE TABLE mortals_xhx_platform(
`updateTime`
datetime
COMMENT
'更新时间'
,
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8
COMMENT
=
'平台系统'
;
-- ----------------------------
-- 产品表
-- ----------------------------
...
...
device-manager/src/main/java/com/mortals/xhx/base/system/message/MessageService.java
View file @
229f8acb
package
com.mortals.xhx.base.system.message
;
import
com.mortals.xhx.busiz.req.DeviceReq
;
import
com.mortals.xhx.busiz.rsp.ApiResp
;
import
com.mortals.xhx.queue.TbQueueCallback
;
import
com.mortals.xhx.queue.TbQueueMsgHeaders
;
import
com.mortals.xhx.queue.TopicPartitionInfo
;
...
...
@@ -45,4 +47,8 @@ public interface MessageService {
String
siteTree
();
ApiResp
<
String
>
sendThirdParty
(
String
sendUrl
,
Integer
messageType
,
DeviceReq
deviceReq
);
}
\ No newline at end of file
device-manager/src/main/java/com/mortals/xhx/base/system/message/impl/MessageServiceImpl.java
View file @
229f8acb
...
...
@@ -10,6 +10,9 @@ import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import
com.mortals.framework.util.DateUtils
;
import
com.mortals.framework.util.HttpUtil
;
import
com.mortals.xhx.base.system.message.MessageService
;
import
com.mortals.xhx.busiz.req.ApiReq
;
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.ApiRespCodeEnum
;
import
com.mortals.xhx.common.code.YesNoEnum
;
...
...
@@ -143,4 +146,21 @@ public class MessageServiceImpl implements MessageService {
return
resp
;
}
@Override
public
ApiResp
<
String
>
sendThirdParty
(
String
sendUrl
,
Integer
messageType
,
DeviceReq
deviceReq
)
{
ApiThirdPartyReq
<
DeviceReq
>
deviceReqApiReq
=
new
ApiThirdPartyReq
<>();
deviceReqApiReq
.
setCode
(
YesNoEnum
.
YES
.
getValue
());
deviceReqApiReq
.
setType
(
messageType
);
String
resp
=
null
;
try
{
Map
<
String
,
String
>
header
=
new
HashMap
<>();
header
.
put
(
HEADER_CONTENT_TYPE
,
"application/json"
);
resp
=
HttpUtil
.
doPost
(
sendUrl
,
header
,
JSON
.
toJSONString
(
deviceReqApiReq
));
return
JSON
.
parseObject
(
resp
,
ApiResp
.
class
);
}
catch
(
Exception
e
)
{
log
.
error
(
"异常:"
,
e
);
}
return
null
;
}
}
\ No newline at end of file
device-manager/src/main/java/com/mortals/xhx/base/system/user/model/UserEntity.java
View file @
229f8acb
...
...
@@ -342,6 +342,12 @@ public class UserEntity extends UserEntityExt implements IUser {
public
Long
getSiteId
()
{
return
this
.
siteId
;
}
@Override
public
String
getSiteIds
()
{
return
null
;
}
/**
* 设置 站点id
* @param siteId
...
...
device-manager/src/main/java/com/mortals/xhx/busiz/req/ApiThirdPartyReq.java
0 → 100644
View file @
229f8acb
package
com.mortals.xhx.busiz.req
;
import
lombok.Data
;
@Data
public
class
ApiThirdPartyReq
<
T
>
{
/**
* 结果编码
*/
private
int
code
;
/**
* 结果描述
*/
private
String
msg
;
/**
* 0:设备增删改查,data数据域封装具体设备消息,1:设备消息类,数据域透传设备上行消息体。
*/
private
Integer
type
;
/**
* 响应数据
*/
private
T
data
;
}
device-manager/src/main/java/com/mortals/xhx/busiz/req/DeviceReq.java
View file @
229f8acb
...
...
@@ -9,19 +9,27 @@ import java.io.Serializable;
@Data
public
class
DeviceReq
implements
Serializable
{
/**
* 状态,0:新增,1:修改,2:删除,3:激活,4:上线,5:下线
*/
private
Integer
deviceStatus
;
/**
* 平台系统编码
*/
private
String
platformCode
;
/**
* 产品编码
*/
private
String
productCode
;
/**
* 设备名称
*/
private
String
deviceName
;
/**
* 设备编码(暂定mac地址)
*/
private
String
deviceCode
;
/**
* mac地址
*/
private
String
deviceMac
;
/**
* 所属站点编码
*/
...
...
@@ -30,33 +38,10 @@ public class DeviceReq implements Serializable {
* 所属站点名称
*/
private
String
siteName
;
/**
* 设备ip
*/
private
String
ip
;
/**
* 设备端口
*/
private
String
port
;
/**
* 平台id
*/
private
Long
platformId
;
/**
* 产品Id
*/
private
Long
productId
;
/**
* 设备备注信息
*/
private
String
deviceRemark
;
public
static
void
main
(
String
[]
args
)
{
// DeviceReq deviceReq = new DeviceReq();
// deviceReq.setIsAdmin();
// deviceReq.seti
}
}
device-manager/src/main/java/com/mortals/xhx/busiz/web/DeviceApiController.java
View file @
229f8acb
...
...
@@ -53,7 +53,6 @@ import java.util.stream.Collectors;
@Slf4j
@RequestMapping
(
"/api"
)
public
class
DeviceApiController
{
@Autowired
private
DeviceService
deviceService
;
@Autowired
...
...
@@ -64,7 +63,6 @@ public class DeviceApiController {
private
IAuthTokenService
authTokenService
;
@Autowired
private
PlatformService
platformService
;
@Value
(
"${queue.rabbitmq.virtual_host:}"
)
private
String
virtualHost
;
@Value
(
"${queue.rabbitmq.password:}"
)
...
...
device-manager/src/main/java/com/mortals/xhx/common/code/DeviceStatusEnum.java
0 → 100644
View file @
229f8acb
package
com.mortals.xhx.common.code
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
/**
* 设备状态,1:新增,2:修改,3:删除,4:激活,5:上线,6:下线
*
* @author zxfei
*/
public
enum
DeviceStatusEnum
{
ADD
(
1
,
"新增"
),
UPDATE
(
2
,
"修改"
),
DEL
(
3
,
"删除"
),
ACTIVE
(
4
,
"激活"
),
ONLINE
(
5
,
"上线"
),
OFFLINE
(
6
,
"下线"
);
private
Integer
value
;
private
String
desc
;
DeviceStatusEnum
(
Integer
value
,
String
desc
)
{
this
.
value
=
value
;
this
.
desc
=
desc
;
}
public
Integer
getValue
()
{
return
this
.
value
;
}
public
String
getDesc
()
{
return
this
.
desc
;
}
public
static
DeviceStatusEnum
getByValue
(
Integer
value
)
{
for
(
DeviceStatusEnum
deviceTypeEnum
:
DeviceStatusEnum
.
values
())
{
if
(
deviceTypeEnum
.
getValue
()
==
value
)
{
return
deviceTypeEnum
;
}
}
return
null
;
}
/**
* 获取Map集合
*
* @param eItem 不包含项
* @return
*/
public
static
Map
<
String
,
String
>
getEnumMap
(
Integer
...
eItem
)
{
Map
<
String
,
String
>
resultMap
=
new
LinkedHashMap
<>();
for
(
DeviceStatusEnum
item
:
DeviceStatusEnum
.
values
())
{
try
{
boolean
hasE
=
false
;
for
(
Integer
e
:
eItem
)
{
if
(
item
.
getValue
()
==
e
)
{
hasE
=
true
;
break
;
}
}
if
(!
hasE
)
{
resultMap
.
put
(
item
.
getValue
()
+
""
,
item
.
getDesc
());
}
}
catch
(
Exception
ex
)
{
}
}
return
resultMap
;
}
}
\ No newline at end of file
device-manager/src/main/java/com/mortals/xhx/common/code/MessageTypeEnum.java
0 → 100644
View file @
229f8acb
package
com.mortals.xhx.common.code
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
public
enum
MessageTypeEnum
{
CRUD
(
0
,
"设备增删改查"
),
TRANSACTION
(
1
,
"设备消息类,数据域透传设备上行消息体"
);
private
Integer
value
;
private
String
desc
;
MessageTypeEnum
(
Integer
value
,
String
desc
)
{
this
.
value
=
value
;
this
.
desc
=
desc
;
}
public
Integer
getValue
()
{
return
this
.
value
;
}
public
String
getDesc
()
{
return
this
.
desc
;
}
public
static
MessageTypeEnum
getByValue
(
Integer
value
)
{
for
(
MessageTypeEnum
sendMsgTypeEnum
:
MessageTypeEnum
.
values
())
{
if
(
sendMsgTypeEnum
.
getValue
()
==
value
)
{
return
sendMsgTypeEnum
;
}
}
return
null
;
}
/**
* 获取Map集合
*
* @param eItem 不包含项
* @return
*/
public
static
Map
<
String
,
String
>
getEnumMap
(
Integer
...
eItem
)
{
Map
<
String
,
String
>
resultMap
=
new
LinkedHashMap
<>();
for
(
MessageTypeEnum
item
:
MessageTypeEnum
.
values
())
{
try
{
boolean
hasE
=
false
;
for
(
Integer
e
:
eItem
)
{
if
(
item
.
getValue
()
==
e
)
{
hasE
=
true
;
break
;
}
}
if
(!
hasE
)
{
resultMap
.
put
(
item
.
getValue
()
+
""
,
item
.
getDesc
());
}
}
catch
(
Exception
ex
)
{
}
}
return
resultMap
;
}
}
\ No newline at end of file
device-manager/src/main/java/com/mortals/xhx/common/key/ErrorCode.java
0 → 100644
View file @
229f8acb
package
com.mortals.xhx.common.key
;
/**
* 错误码
*
* @author: zxfei
* @date: 2022/5/12 14:56
*/
public
interface
ErrorCode
{
public
static
final
int
STATUS_MS_EXCEPTION
=
500
;
public
static
final
int
STATUS_VALIDATE_EXCEPTION
=
420
;
public
static
final
int
STATUS_UNCHECKED_EXCEPTION
=
605
;
public
static
final
int
STATUS_TOKEN_NULL_EXCEPTION
=
604
;
public
static
final
int
STATUS_CODE_SUCCESS
=
0
;
public
static
final
int
STATUS_CODE_WARN
=
1
;
public
static
final
int
STATUS_CODE_ERROR
=
2
;
public
static
final
int
STATUS_CODE_INFO
=
3
;
public
static
final
int
STATUS_CODE_TOKEN_EXPIRED
=
4
;
public
static
final
int
STATUS_CODE_FATAL
=
5
;
public
static
final
int
STATUS_CODE_TRADE_PWD_NOT_SET
=
6
;
public
static
final
int
STATUS_ACCOUNT_LOCKED
=
7
;
public
static
final
int
STATUS_TRADE_PWD_OVER_THREE_TIME
=
8
;
public
static
final
int
STATUS_TRADE_PWD_ERROR
=
9
;
public
static
final
int
STATUS_EMPTY_PWD_ERROR
=
10
;
public
static
final
int
STATUS_TEL_NOT_RGI_ERROR
=
11
;
public
static
final
int
STATUS_TEL_ALREADY_REGI
=
12
;
public
static
final
int
STATUS_SAFETY_RISK
=
13
;
public
static
final
int
STATUS_LOGIN_CODE
=
15
;
public
static
final
int
BOOK_FAKUAN_CODE
=
16
;
//还有未付款的订单code
public
static
final
String
ERROR_TOKEN_EXPIRED
=
"登陆过期,请重新登录"
;
public
static
final
String
ERROR_TRADE_PWD_OVER_THREE_TIME
=
"支付密码错误,请15分钟后再试"
;
public
static
final
String
ERROR_TRADE_PWD_ERROR
=
"支付密码错误,请重试"
;
public
static
final
String
ERROR_EMPTY_PWD_ERROR
=
"请设置登录密码"
;
public
static
final
String
ERROR_TEL_NOT_RGI
=
"该号码未注册"
;
public
static
final
String
ERROR_USERNAME_OR_PASSWORD
=
"用户名或者密码错误"
;
public
static
final
String
ERROR_TRADE_PWD
=
"交易密码错误"
;
public
static
final
String
ERROR_FORBIDDEN_OPER
=
"非法操作"
;
public
static
final
String
ERROR_TRADE_PWD_NOT_SET
=
"非法操作"
;
public
static
final
String
ERROR_NOT_REAL_NAME_AUTH
=
"您未实名认证,禁止该操作"
;
public
static
final
String
ERROR_INTERNAL_SERVER_ERROR
=
"服务器内部错误"
;
public
static
final
String
ERROR_UNAUTHORIZED
=
"token不正确或已过期"
;
public
static
final
String
ERROR_TOKEN_IS_NULL
=
"token不能为空"
;
public
static
final
String
ERROR_MISS_SERVLET
=
"服务不存在"
;
public
static
final
String
ERROR_CAPTCHA_OFTEN
=
"验证码已发送"
;
public
static
final
String
ERROR_CAPTCHA_WRONG
=
"验证码错误"
;
public
static
final
String
ERROR_TEL_ALREADY_REGI
=
"该手机号已被注册"
;
public
static
final
String
ERROR_CODE_DUPLICATE_KEY
=
"重复添加信息(含部分)"
;
public
static
final
String
ERROR_NOT_EXITS
=
"对应记录不存在"
;
public
static
final
String
ERROR_STATUS_CATEGORY
=
"状态错误"
;
public
static
final
String
ERROR_FRIEND_SHIP_ALREADY
=
"已经是你好友"
;
public
static
final
String
ERROR_FRIEND_SHIP_WAIT
=
"已向改好友发出邀请,等待接受"
;
public
static
final
String
ERROR_CODE_ACCOUNT_LOCKED
=
"账号被锁定,请联系客服"
;
public
static
final
String
WARN_ARGUMENT
=
"参数错误"
;
public
static
final
String
ERROR_USERNAME_EXIST
=
"该号码已被注册"
;
public
static
final
String
ERROR_SAFETY_RISK
=
"不在常用设备上登录"
;
public
static
final
String
INFO_TEL_BIND
=
"手机号码已经被绑定"
;
public
static
final
String
INFO_TEL_FORMAT_WRONG
=
"手机号码格式不正确"
;
public
static
final
String
ERROR_NOT_FOUND
=
"404 not found"
;
public
static
final
String
DISABLED
=
"该账号已被封禁,如有疑问请联系平台"
;
public
static
final
String
DATENULL
=
"缺少参数"
;
public
static
final
String
ERRDATE
=
"无效参数"
;
public
static
final
String
ERRSTAE
=
"状态异常"
;
public
static
final
String
EXTDATE
=
"参数异常"
;
public
static
final
String
NUMEXE
=
"账号异常"
;
public
static
final
String
CAPDON
=
"资产已被冻结,如有疑问请联系平台"
;
public
static
final
String
CONOTS
=
"操作失败"
;
public
static
final
String
OK
=
"成功!"
;
public
static
final
String
TOKENX
=
"身份验证失败,请重新登录"
;
public
static
final
String
CAPNOT
=
"充值余额不足请充值"
;
public
static
final
String
SYSNOT
=
"系统繁忙,请稍后再试..."
;
public
static
final
String
NOWER
=
"没有权限"
;
public
static
final
String
PAGEDATA
=
"分页参数不能为空"
;
public
static
final
String
CARADD_MEMBERS
=
"该司机已有绑定车辆,不能绑定多个"
;
}
device-manager/src/main/java/com/mortals/xhx/common/key/HttpStatus.java
0 → 100644
View file @
229f8acb
package
com.mortals.xhx.common.key
;
/**
*
*
* @author: zxfei
* @date: 2022/5/12 14:57
*/
public
class
HttpStatus
{
/**
* 操作成功
*/
public
static
final
int
SUCCESS
=
200
;
/**
* 对象创建成功
*/
public
static
final
int
CREATED
=
201
;
/**
* 请求已经被接受
*/
public
static
final
int
ACCEPTED
=
202
;
/**
* 操作已经执行成功,但是没有返回数据
*/
public
static
final
int
NO_CONTENT
=
204
;
/**
* 资源已被移除
*/
public
static
final
int
MOVED_PERM
=
301
;
/**
* 重定向
*/
public
static
final
int
SEE_OTHER
=
303
;
/**
* 资源没有被修改
*/
public
static
final
int
NOT_MODIFIED
=
304
;
/**
* 参数列表错误(缺少,格式不匹配)
*/
public
static
final
int
BAD_REQUEST
=
400
;
/**
* 未授权
*/
public
static
final
int
UNAUTHORIZED
=
401
;
/**
* 访问受限,授权过期
*/
public
static
final
int
FORBIDDEN
=
403
;
/**
* 资源,服务未找到
*/
public
static
final
int
NOT_FOUND
=
404
;
/**
* 不允许的http方法
*/
public
static
final
int
BAD_METHOD
=
405
;
/**
* 资源冲突,或者资源被锁
*/
public
static
final
int
CONFLICT
=
409
;
/**
* 不支持的数据,媒体类型
*/
public
static
final
int
UNSUPPORTED_TYPE
=
415
;
/**
* 系统内部错误
*/
public
static
final
int
ERROR
=
500
;
/**
* 接口未实现
*/
public
static
final
int
NOT_IMPLEMENTED
=
501
;
}
device-manager/src/main/java/com/mortals/xhx/module/device/service/DeviceService.java
View file @
229f8acb
...
...
@@ -24,7 +24,12 @@ public interface DeviceService extends ICRUDCacheService<DeviceEntity,Long>{
ApiResp
<
String
>
sendDeviceMessage
(
List
<
Long
>
deviceIds
,
TopicPartitionInfo
info
,
TbQueueMsgHeaders
header
,
String
message
,
Context
context
);
/**
* 设备激活
* @param deviceCode
* @param context
*/
void
active
(
String
deviceCode
,
Context
context
);
}
\ No newline at end of file
device-manager/src/main/java/com/mortals/xhx/module/device/service/impl/DeviceServiceImpl.java
View file @
229f8acb
package
com.mortals.xhx.module.device.service.impl
;
import
cn.hutool.core.lang.PatternPool
;
import
cn.hutool.http.HttpUtil
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl
;
import
com.mortals.xhx.base.system.message.MessageService
;
import
com.mortals.xhx.busiz.req.DeviceReq
;
import
com.mortals.xhx.busiz.rsp.ApiResp
;
import
com.mortals.xhx.common.code.
ApiRespCodeEnum
;
import
com.mortals.xhx.common.code.
*
;
import
com.mortals.xhx.common.key.Constant
;
import
com.mortals.xhx.common.utils.BeanUtil
;
import
com.mortals.xhx.module.device.dao.DeviceDao
;
import
com.mortals.xhx.module.device.model.DeviceEntity
;
import
com.mortals.xhx.module.device.model.DeviceQuery
;
...
...
@@ -17,6 +21,7 @@ import com.mortals.xhx.module.product.model.ProductEntity;
import
com.mortals.xhx.module.product.service.ProductService
;
import
com.mortals.xhx.queue.*
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
...
...
@@ -55,10 +60,10 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
@Override
protected
void
validData
(
DeviceEntity
entity
,
Context
context
)
throws
AppException
{
if
(!
ObjectUtils
.
isEmpty
(
entity
.
getPlatformId
()))
{
throw
new
AppException
(
"所属平台不能为空!"
);
}
if
(!
ObjectUtils
.
isEmpty
(
entity
.
getProductId
()))
{
if
(!
ObjectUtils
.
isEmpty
(
entity
.
getPlatformId
()))
{
throw
new
AppException
(
"所属平台不能为空!"
);
}
if
(!
ObjectUtils
.
isEmpty
(
entity
.
getProductId
()))
{
throw
new
AppException
(
"所属产品不能为空!"
);
}
...
...
@@ -75,11 +80,9 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
public
void
onSuccess
(
TbQueueMsgMetadata
metadata
)
{
log
.
info
(
"消息投递成功,设备通道编码:"
+
deviceEntity
.
getDeviceMac
());
}
@Override
public
void
onFailure
(
Throwable
t
)
{
log
.
error
(
"消息投递成功,设备通道编码:"
+
deviceEntity
.
getDeviceMac
(),
t
);
}
};
messageService
.
send
(
info
,
header
,
message
,
callback
);
...
...
@@ -98,6 +101,33 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
return
resp
;
}
@Override
public
void
active
(
String
deviceCode
,
Context
context
)
{
DeviceEntity
deviceEntity
=
this
.
selectOne
(
new
DeviceQuery
().
deviceCode
(
deviceCode
));
if
(!
ObjectUtils
.
isEmpty
(
deviceEntity
))
throw
new
AppException
(
"当前设备不存在!"
);
if
(
deviceEntity
.
getActive
()
==
ActiveEnum
.
已激活
.
getValue
())
throw
new
AppException
(
"当前设备已激活!"
);
deviceEntity
.
setActive
(
ActiveEnum
.
已激活
.
getValue
());
this
.
update
(
deviceEntity
,
context
);
PlatformEntity
platformEntity
=
platformService
.
get
(
deviceEntity
.
getPlatformId
());
ProductEntity
productEntity
=
productService
.
get
(
deviceEntity
.
getProductId
());
if
(!
ObjectUtils
.
isEmpty
(
platformEntity
)
&&
!
ObjectUtils
.
isEmpty
(
productEntity
))
{
//新增设备通知第三方平台
DeviceReq
deviceReq
=
new
DeviceReq
();
BeanUtils
.
copyProperties
(
deviceEntity
,
deviceReq
,
BeanUtil
.
getNullPropertyNames
(
deviceEntity
));
deviceReq
.
setDeviceStatus
(
DeviceStatusEnum
.
ACTIVE
.
getValue
());
deviceReq
.
setProductCode
(
productEntity
.
getProductCode
());
deviceReq
.
setPlatformCode
(
platformEntity
.
getPlatformSn
());
if
(!
ObjectUtils
.
isEmpty
(
platformEntity
.
getSendUrl
())
&&
platformEntity
.
getSendSwitch
()
==
SendSwitchEnum
.
启用
.
getValue
())
{
if
(
PatternPool
.
URL_HTTP
.
matcher
(
platformEntity
.
getSendUrl
()).
find
())
{
ApiResp
<
String
>
resp
=
messageService
.
sendThirdParty
(
platformEntity
.
getSendUrl
(),
MessageTypeEnum
.
CRUD
.
getValue
(),
deviceReq
);
}
else
{
throw
new
AppException
(
"http send url 不合法!"
+
platformEntity
.
getSendUrl
());
}
}
}
}
@Override
protected
void
saveAfter
(
DeviceEntity
entity
,
Context
context
)
throws
AppException
{
...
...
@@ -128,15 +158,50 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
//创建下行队列
info
=
TopicPartitionInfo
.
builder
().
exchangeName
(
exchangeName
).
topic
(
Constant
.
DOWN_TOPIC
+
entity
.
getDeviceCode
()).
build
();
messageService
.
queueDeclare
(
info
,
callback
);
//新增设备通知第三方平台
DeviceReq
deviceReq
=
new
DeviceReq
();
BeanUtils
.
copyProperties
(
entity
,
deviceReq
,
BeanUtil
.
getNullPropertyNames
(
entity
));
deviceReq
.
setDeviceStatus
(
DeviceStatusEnum
.
ADD
.
getValue
());
deviceReq
.
setProductCode
(
productEntity
.
getProductCode
());
deviceReq
.
setPlatformCode
(
platformEntity
.
getPlatformSn
());
if
(!
ObjectUtils
.
isEmpty
(
platformEntity
.
getSendUrl
())
&&
platformEntity
.
getSendSwitch
()
==
SendSwitchEnum
.
启用
.
getValue
())
{
if
(
PatternPool
.
URL_HTTP
.
matcher
(
platformEntity
.
getSendUrl
()).
find
())
{
ApiResp
<
String
>
resp
=
messageService
.
sendThirdParty
(
platformEntity
.
getSendUrl
(),
MessageTypeEnum
.
CRUD
.
getValue
(),
deviceReq
);
}
else
{
throw
new
AppException
(
"http send url 不合法!"
+
platformEntity
.
getSendUrl
());
}
}
}
else
{
throw
new
AppException
(
"产品或平台不存在!"
);
}
super
.
saveAfter
(
entity
,
context
);
}
@Override
protected
void
updateAfter
(
DeviceEntity
entity
,
Context
context
)
throws
AppException
{
PlatformEntity
platformEntity
=
platformService
.
get
(
entity
.
getPlatformId
());
ProductEntity
productEntity
=
productService
.
get
(
entity
.
getProductId
());
if
(!
ObjectUtils
.
isEmpty
(
platformEntity
)
&&
!
ObjectUtils
.
isEmpty
(
productEntity
))
{
//新增设备通知第三方平台
DeviceReq
deviceReq
=
new
DeviceReq
();
BeanUtils
.
copyProperties
(
entity
,
deviceReq
,
BeanUtil
.
getNullPropertyNames
(
entity
));
deviceReq
.
setDeviceStatus
(
DeviceStatusEnum
.
UPDATE
.
getValue
());
deviceReq
.
setProductCode
(
productEntity
.
getProductCode
());
deviceReq
.
setPlatformCode
(
platformEntity
.
getPlatformSn
());
if
(!
ObjectUtils
.
isEmpty
(
platformEntity
.
getSendUrl
())
&&
platformEntity
.
getSendSwitch
()
==
SendSwitchEnum
.
启用
.
getValue
())
{
if
(
PatternPool
.
URL_HTTP
.
matcher
(
platformEntity
.
getSendUrl
()).
find
())
{
ApiResp
<
String
>
resp
=
messageService
.
sendThirdParty
(
platformEntity
.
getSendUrl
(),
MessageTypeEnum
.
CRUD
.
getValue
(),
deviceReq
);
}
else
{
throw
new
AppException
(
"http send url 不合法!"
+
platformEntity
.
getSendUrl
());
}
}
}
super
.
updateAfter
(
entity
,
context
);
}
@Override
protected
void
removeBefore
(
Long
[]
ids
,
Context
context
)
throws
AppException
{
Arrays
.
asList
(
ids
).
stream
().
forEach
(
id
->
{
...
...
@@ -146,14 +211,35 @@ public class DeviceServiceImpl extends AbstractCRUDCacheServiceImpl<DeviceDao, D
public
void
onSuccess
(
TbQueueMsgMetadata
metadata
)
{
log
.
info
(
"队列删除成功"
);
}
@Override
public
void
onFailure
(
Throwable
t
)
{
log
.
error
(
"队列删除失败"
,
t
);
}
};
messageService
.
delQueue
(
Constant
.
UPLOAD_TOPIC
+
deviceEntity
.
getDeviceCode
(),
callback
);
messageService
.
delQueue
(
Constant
.
DOWN_TOPIC
+
deviceEntity
.
getDeviceCode
(),
callback
);
messageService
.
delQueue
(
Constant
.
UPLOAD_TOPIC
+
deviceEntity
.
getDeviceCode
(),
callback
);
messageService
.
delQueue
(
Constant
.
DOWN_TOPIC
+
deviceEntity
.
getDeviceCode
(),
callback
);
PlatformEntity
platformEntity
=
platformService
.
get
(
deviceEntity
.
getPlatformId
());
ProductEntity
productEntity
=
productService
.
get
(
deviceEntity
.
getProductId
());
if
(!
ObjectUtils
.
isEmpty
(
platformEntity
)
&&
!
ObjectUtils
.
isEmpty
(
productEntity
))
{
//新增设备通知第三方平台
DeviceReq
deviceReq
=
new
DeviceReq
();
BeanUtils
.
copyProperties
(
deviceEntity
,
deviceReq
,
BeanUtil
.
getNullPropertyNames
(
deviceEntity
));
deviceReq
.
setDeviceStatus
(
DeviceStatusEnum
.
DEL
.
getValue
());
deviceReq
.
setProductCode
(
productEntity
.
getProductCode
());
deviceReq
.
setPlatformCode
(
platformEntity
.
getPlatformSn
());
if
(!
ObjectUtils
.
isEmpty
(
platformEntity
.
getSendUrl
())
&&
platformEntity
.
getSendSwitch
()
==
SendSwitchEnum
.
启用
.
getValue
())
{
if
(
PatternPool
.
URL_HTTP
.
matcher
(
platformEntity
.
getSendUrl
()).
find
())
{
ApiResp
<
String
>
resp
=
messageService
.
sendThirdParty
(
platformEntity
.
getSendUrl
(),
MessageTypeEnum
.
CRUD
.
getValue
(),
deviceReq
);
}
else
{
throw
new
AppException
(
"http send url 不合法!"
+
platformEntity
.
getSendUrl
());
}
}
}
});
super
.
removeBefore
(
ids
,
context
);
...
...
device-manager/src/main/java/com/mortals/xhx/module/platform/model/PlatformEntity.java
View file @
229f8acb
...
...
@@ -7,125 +7,161 @@ import com.mortals.framework.annotation.Excel;
import
com.mortals.framework.model.BaseEntityLong
;
import
com.mortals.xhx.module.platform.model.vo.PlatformVo
;
/**
* 平台系统实体对象
*
* @author zxfei
* @date 2022-04-25
*/
* 平台系统实体对象
*
* @author zxfei
* @date 2022-05-30
*/
public
class
PlatformEntity
extends
PlatformVo
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* 平台名称,名称唯一
*/
* 平台名称,名称唯一
*/
@Excel
(
name
=
"平台名称,名称唯一"
)
private
String
platformName
;
/**
* 平台编码,编码唯一(编码加上站点编码,如phxt-51010251-1做Vhost虚拟机编码)
*/
* 平台编码,编码唯一(编码加上站点编码,如phxt-51010251-1做Vhost虚拟机编码)
*/
private
String
platformSn
;
/**
* 发送第三方平台消息类型(0.http,1.jms)
*/
* 发送第三方平台消息类型(0.http,1.jms)
*/
private
Integer
sendMsgType
;
/**
* 发送参数配置,如发送消息地址等,xml结构,根据消息类型变化
*/
private
String
send
Config
;
* 发送参数请求地址
*/
private
String
send
Url
;
/**
* 是否启用发送消息(0.停用,1.启用)
*/
* 回调参数地址
*/
private
String
callbackUrl
;
/**
* 是否启用发送消息(0.停用,1.启用)
*/
private
Integer
sendSwitch
;
/**
* 备注
*/
* 首页地址
*/
private
String
homeUrl
;
/**
* 备注
*/
private
String
platformRemark
;
public
PlatformEntity
(){}
/**
* 获取 平台名称,名称唯一
* @return String
*/
* 获取 平台名称,名称唯一
* @return String
*/
public
String
getPlatformName
(){
return
platformName
;
}
/**
* 设置 平台名称,名称唯一
* @param platformName
*/
* 设置 平台名称,名称唯一
* @param platformName
*/
public
void
setPlatformName
(
String
platformName
){
this
.
platformName
=
platformName
;
}
/**
* 获取 平台编码,编码唯一(编码加上站点编码,如phxt-51010251-1做Vhost虚拟机编码)
* @return String
*/
* 获取 平台编码,编码唯一(编码加上站点编码,如phxt-51010251-1做Vhost虚拟机编码)
* @return String
*/
public
String
getPlatformSn
(){
return
platformSn
;
}
/**
* 设置 平台编码,编码唯一(编码加上站点编码,如phxt-51010251-1做Vhost虚拟机编码)
* @param platformSn
*/
* 设置 平台编码,编码唯一(编码加上站点编码,如phxt-51010251-1做Vhost虚拟机编码)
* @param platformSn
*/
public
void
setPlatformSn
(
String
platformSn
){
this
.
platformSn
=
platformSn
;
}
/**
* 获取 发送第三方平台消息类型(0.http,1.jms)
* @return Integer
*/
* 获取 发送第三方平台消息类型(0.http,1.jms)
* @return Integer
*/
public
Integer
getSendMsgType
(){
return
sendMsgType
;
}
/**
* 设置 发送第三方平台消息类型(0.http,1.jms)
* @param sendMsgType
*/
* 设置 发送第三方平台消息类型(0.http,1.jms)
* @param sendMsgType
*/
public
void
setSendMsgType
(
Integer
sendMsgType
){
this
.
sendMsgType
=
sendMsgType
;
}
/**
* 获取 发送参数配置,如发送消息地址等,xml结构,根据消息类型变化
* @return String
*/
public
String
getSendConfig
(){
return
sendConfig
;
* 获取 发送参数请求地址
* @return String
*/
public
String
getSendUrl
(){
return
sendUrl
;
}
/**
* 设置 发送参数请求地址
* @param sendUrl
*/
public
void
setSendUrl
(
String
sendUrl
){
this
.
sendUrl
=
sendUrl
;
}
/**
* 获取 回调参数地址
* @return String
*/
public
String
getCallbackUrl
(){
return
callbackUrl
;
}
/**
* 设置 发送参数配置,如发送消息地址等,xml结构,根据消息类型变化
* @param sendConfig
*/
public
void
set
SendConfig
(
String
sendConfig
){
this
.
sendConfig
=
sendConfig
;
* 设置 回调参数地址
* @param callbackUrl
*/
public
void
set
CallbackUrl
(
String
callbackUrl
){
this
.
callbackUrl
=
callbackUrl
;
}
/**
* 获取 是否启用发送消息(0.停用,1.启用)
* @return Integer
*/
* 获取 是否启用发送消息(0.停用,1.启用)
* @return Integer
*/
public
Integer
getSendSwitch
(){
return
sendSwitch
;
}
/**
* 设置 是否启用发送消息(0.停用,1.启用)
* @param sendSwitch
*/
* 设置 是否启用发送消息(0.停用,1.启用)
* @param sendSwitch
*/
public
void
setSendSwitch
(
Integer
sendSwitch
){
this
.
sendSwitch
=
sendSwitch
;
}
/**
* 获取 备注
* @return String
*/
* 获取 首页地址
* @return String
*/
public
String
getHomeUrl
(){
return
homeUrl
;
}
/**
* 设置 首页地址
* @param homeUrl
*/
public
void
setHomeUrl
(
String
homeUrl
){
this
.
homeUrl
=
homeUrl
;
}
/**
* 获取 备注
* @return String
*/
public
String
getPlatformRemark
(){
return
platformRemark
;
}
/**
* 设置 备注
* @param platformRemark
*/
* 设置 备注
* @param platformRemark
*/
public
void
setPlatformRemark
(
String
platformRemark
){
this
.
platformRemark
=
platformRemark
;
}
...
...
@@ -135,7 +171,7 @@ public class PlatformEntity extends PlatformVo {
@Override
public
int
hashCode
()
{
return
this
.
getId
().
hashCode
();
return
this
.
getId
().
hashCode
();
}
@Override
public
boolean
equals
(
Object
obj
)
{
...
...
@@ -143,7 +179,7 @@ public class PlatformEntity extends PlatformVo {
if
(
obj
instanceof
PlatformEntity
)
{
PlatformEntity
tmp
=
(
PlatformEntity
)
obj
;
if
(
this
.
getId
()
==
tmp
.
getId
())
{
return
true
;
return
true
;
}
}
return
false
;
...
...
@@ -154,24 +190,30 @@ public class PlatformEntity extends PlatformVo {
sb
.
append
(
",platformName:"
).
append
(
getPlatformName
());
sb
.
append
(
",platformSn:"
).
append
(
getPlatformSn
());
sb
.
append
(
",sendMsgType:"
).
append
(
getSendMsgType
());
sb
.
append
(
",sendConfig:"
).
append
(
getSendConfig
());
sb
.
append
(
",sendUrl:"
).
append
(
getSendUrl
());
sb
.
append
(
",callbackUrl:"
).
append
(
getCallbackUrl
());
sb
.
append
(
",sendSwitch:"
).
append
(
getSendSwitch
());
sb
.
append
(
",homeUrl:"
).
append
(
getHomeUrl
());
sb
.
append
(
",platformRemark:"
).
append
(
getPlatformRemark
());
return
sb
.
toString
();
}
public
void
initAttrValue
(){
this
.
platformName
=
""
;
this
.
platformName
=
""
;
this
.
platformSn
=
""
;
this
.
sendMsgType
=
0
;
this
.
platformSn
=
""
;
this
.
sendUrl
=
""
;
this
.
sendMsgType
=
0
;
this
.
callbackUrl
=
""
;
this
.
sendConfig
=
""
;
this
.
sendSwitch
=
0
;
this
.
sendSwitch
=
0
;
this
.
homeUrl
=
""
;
this
.
platformRemark
=
""
;
this
.
platformRemark
=
""
;
}
}
\ No newline at end of file
device-manager/src/main/java/com/mortals/xhx/module/platform/model/PlatformQuery.java
View file @
229f8acb
This diff is collapsed.
Click to expand it.
device-manager/src/main/java/com/mortals/xhx/module/platform/web/PlatformController.java
View file @
229f8acb
...
...
@@ -49,10 +49,6 @@ public class PlatformController extends BaseCRUDJsonMappingController<PlatformSe
@Autowired
private
ParamService
paramService
;
private
ICacheService
cacheService
=
LocalCacheServiceImpl
.
getInstance
();
private
final
String
KEY
=
"base-platform:admin,admin"
;
//基础服务平台获取token
public
PlatformController
()
{
super
.
setFormClass
(
PlatformForm
.
class
);
super
.
setModuleDesc
(
"平台系统"
);
...
...
@@ -64,133 +60,4 @@ public class PlatformController extends BaseCRUDJsonMappingController<PlatformSe
this
.
addDict
(
model
,
"sendSwitch"
,
paramService
.
getParamBySecondOrganize
(
"Platform"
,
"sendSwitch"
));
super
.
init
(
request
,
response
,
form
,
model
,
context
);
}
@GetMapping
(
"getSite"
)
public
String
getSite
(
@RequestParam
(
"parentId"
)
String
parentId
)
{
log
.
info
(
"【获取站点】【请求体】-->parentId "
+
parentId
);
String
res
=
null
;
try
{
String
token
=
cacheService
.
get
(
KEY
);
if
(
token
==
null
){
token
=
getToken
();
if
(
token
==
null
){
throw
new
AppException
(
"未获取到token"
);
}
}
res
=
getSiteList
(
parentId
,
token
);
if
(
JSONObject
.
parseObject
(
res
).
get
(
"code"
).
equals
(-
1
)){
token
=
getToken
();
res
=
getSiteList
(
parentId
,
token
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
"接收数据失败"
,
e
);
return
res
;
}
log
.
info
(
"响应【获取站点】【响应体】--> "
+
res
);
return
res
;
}
//获取基础服务平台站点信息
private
String
getSiteList
(
String
parentId
,
String
token
){
CloseableHttpClient
httpClient
=
null
;
CloseableHttpResponse
response
=
null
;
String
result
=
""
;
try
{
// 通过址默认配置创建一个httpClient实例
httpClient
=
HttpClients
.
createDefault
();
// 创建httpGet远程连接实例
HttpGet
httpGet
=
new
HttpGet
(
"http://192.168.0.98:11071/zwfw/area/getListByParentId?parentId="
+
parentId
);
// 设置请求头信息,鉴权
httpGet
.
setHeader
(
"Authorization"
,
token
);
// 执行get请求得到返回对象
response
=
httpClient
.
execute
(
httpGet
);
// 通过返回对象获取返回数据
HttpEntity
entity
=
response
.
getEntity
();
// 通过EntityUtils中的toString方法将结果转换为字符串
result
=
EntityUtils
.
toString
(
entity
);
}
catch
(
Exception
e
)
{
log
.
error
(
"接收数据失败"
,
e
);
return
JSON
.
toJSONString
(
result
);
}
finally
{
if
(
response
!=
null
)
{
try
{
response
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
if
(
httpClient
!=
null
)
{
try
{
httpClient
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
JSONObject
object
=
JSONObject
.
parseObject
(
result
);
if
(
object
==
null
||
object
.
get
(
"code"
)
==
null
){
throw
new
AppException
(
"基础服务平台获取站点信息失败,响应值: "
+
response
);
}
return
result
;
}
//获取基础服务平台token
private
String
getToken
()
{
CloseableHttpResponse
httpResponse
=
null
;
String
response
=
""
;
Object
token
=
null
;
// 创建httpClient实例
CloseableHttpClient
httpClient
=
HttpClients
.
createDefault
();
// 创建httpPost远程连接实例
HttpPost
httpPost
=
new
HttpPost
(
"http://192.168.0.98:11071/zwfw/login/login"
);
JSONObject
request
=
null
;
try
{
request
=
new
JSONObject
();
request
.
put
(
"loginName"
,
"admin"
);
request
.
put
(
"password"
,
"admin"
);
request
.
put
(
"securityCode"
,
8888
);
log
.
info
(
"登录基础服务平台,参数-->"
+
request
);
StringEntity
entity
=
new
StringEntity
(
request
.
toString
());
entity
.
setContentType
(
"application/json;charset=UTF-8"
);
httpPost
.
setEntity
(
entity
);
// httpClient对象执行post请求,并返回响应参数对象
httpResponse
=
httpClient
.
execute
(
httpPost
);
// 从响应对象中获取响应内容
HttpEntity
httpEntity
=
httpResponse
.
getEntity
();
response
=
EntityUtils
.
toString
(
httpEntity
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
log
.
error
(
"基础服务平台登录失败,响应体:"
+
httpResponse
);
}
finally
{
// 关闭资源
if
(
null
!=
httpResponse
)
{
try
{
httpResponse
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
if
(
null
!=
httpClient
)
{
try
{
httpClient
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
JSONObject
object
=
JSONObject
.
parseObject
(
response
);
if
(
object
==
null
||
object
.
get
(
"code"
)
==
null
||
object
.
get
(
"code"
).
equals
(-
1
)){
throw
new
AppException
(
"基础服务平台登录获取token失败,响应值: "
+
response
);
}
if
(
object
.
get
(
"code"
).
equals
(
1
)){
token
=
JSONObject
.
parseObject
(
object
.
get
(
"data"
).
toString
()).
get
(
"token"
);
cacheService
.
sadd
(
KEY
,
token
);
return
token
.
toString
();
}
return
null
;
}
}
\ No newline at end of file
device-manager/src/main/resources/sqlmap/module/platform/PlatformMapper.xml
View file @
229f8acb
This diff is collapsed.
Click to expand it.
doc/api.md
View file @
229f8acb
...
...
@@ -165,24 +165,38 @@ data|object|数据对象|-
```
### 获取平台产品列表
**请求URL:**
m/api/getPlatformAndProduct
**请求方式:**
GET
### 新增或更新设备
**请求URL:**
m/api/saveOrUpdate
**请求方式:**
POST
**鉴权头信息:**
Authorization: {{token}}
**内容类型:**
application/json;charset=utf-8
**简要描述:**
查询平台产品列表数据,用于设备新增提交
**简要描述:**
保存或更新设备,设备deviceCode存在更新,不存在新增,
请求需添加接口鉴权token信息,来源getToken接口
**请求参数:**
参数名称|类型|备注|必填|其它
---|---|---|---|---
deviceName|String|设备名称|否|-
deviceCode|String|设备编码,如MAC地址|是|-
platformCode|String|平台系统编码|是|见平台编码附录
productCode|String|产品编码|是|见产品编码附录
siteCode|String|站点编号,来源基础服务平台|是|-
siteName|String|站点名称|是|-
homeUrl|String|首页地址|否|-
deviceRemark|String|备注|是|-
**请求样例:**
```
{
}
```
**响应参数:**
...
...
@@ -192,25 +206,16 @@ data|object|数据对象|-
code|Integer|结果码(-1.失败,1.成功)|-
msg|String|消息|-
data|object|数据对象|-
 
platformList|array|平台列表|数组
  
id|Long|ID|-
  
platformName|String|平台名称,名称唯一|-
  
platformSn|String|平台编码,编码唯一|-
 
productList|array|产品列表|数组
  
id|Long|ID|-
  
productName|String|产品名称,名称唯一|-
  
productCode|String|产品编码,编码唯一|-
**响应消息样例:**
```
```
```
###
新增或更新
设备
###
激活
设备
**请求URL:**
m/api/
saveOrUpdat
e
**请求URL:**
m/api/
activ
e
**请求方式:**
POST
...
...
@@ -218,37 +223,20 @@ data|object|数据对象|-
**内容类型:**
application/json;charset=utf-8
**简要描述:**
保存或更新设备,设备deviceCode存在更新,不存在新增,
请求需添加接口鉴权token信息,来源getToken接口
**简要描述:**
激活设备
请求需添加接口鉴权token信息,来源getToken接口
**请求参数:**
参数名称|类型|备注|必填|其它
---|---|---|---|---
deviceName|String|设备名称|否|-
deviceCode|String|设备编码|是|-
deviceMac|String|设备的MAC地址|否|-
platformId|Long|平台系统Id|是|来源接口获取平台产品列表
platformName|String|平台系统名称|是|-
productId|Long|产品Id|是|来源接口获取平台产品列表
productName|String|产品名称|是|-
siteCode|String|站点编号,来源基础服务平台|是|-
siteName|String|站点名称|是|-
deviceRemark|String|备注|是|-
**请求样例:**
```
{
"deviceName":"lmfrs8",
"deviceCode":"yte9s3",
"siteCode":"nmyc5u",
"siteName":"a4vxhg",
"deviceMac":"y9tuaw",
"platformId":3125,
"productId":362,
"deviceRemark":"ah98cp",
}
```
...
...
@@ -266,9 +254,9 @@ data|object|数据对象|-
```
###
激活
设备
###
删除
设备
**请求URL:**
m/api/
active
**请求URL:**
m/api/
deviceDel
**请求方式:**
POST
...
...
@@ -276,7 +264,7 @@ data|object|数据对象|-
**内容类型:**
application/json;charset=utf-8
**简要描述:**
激活
设备
**简要描述:**
删除
设备
请求需添加接口鉴权token信息,来源getToken接口
**请求参数:**
...
...
@@ -307,7 +295,52 @@ data|object|数据对象|-
```
### 回调各个平台通知消息
**请求URL:**
各平台通知地址
**请求方式:**
POST
**内容类型:**
application/json;charset=utf-8
**简要描述:**
设备新增激活下线等消息通知各个平台,当配置了地址时候
**请求参数:**
参数名称|类型|备注|必填|其它
:---|:---|:---|:---|:---
code|Integer|结果码(-1.失败,1.成功)|是|-
msg|String|消息|否|-
type|Integer|消息类型|是|0:设备增删改查,data数据域封装具体设备消息,1:设备消息类,数据域透传设备上行消息体。|-
data|object|数据对象|是|-
 
deviceStatus|Integer|状态,1:新增,2:修改,3:删除,4:激活,5:上线,6:下线|是|-
 
deviceName|String|设备名称|否|-
 
deviceCode|String|设备编码,如MAC地址|是|-
 
platformCode|String|平台系统编码|是|见平台编码附录
 
productCode|String|产品编码|是|见产品编码附录
 
siteCode|String|站点编号,来源基础服务平台|是|-
 
siteName|String|站点名称|是|-
 
deviceRemark|String|备注|是|-
**请求样例:**
```
{
}
```
**响应参数:**
参数名称 |参数类型|备注|其它
---|---|---|---
code|Integer|结果码(-1.失败,1.成功)|-
msg|String|消息|-
data|object|数据对象|-
**响应消息样例:**
```
```
## 设备消息
...
...
doc/设备管理系统.docx
View file @
229f8acb
No preview for this file type
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