Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄嘉阳
/
iot-platform-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
180b1bdc
authored
Sep 11, 2023
by
李小龙
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
整理代码
parent
7875e1b8
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
78 deletions
server-common/src/main/java/com/makeit/module/iot/mqtt/PushCallback.java
server-module/src/main/java/com/makeit/module/controller/system/ChinaAreaController.java
server-service/src/main/java/com/makeit/service/platform/auth/impl/PlatUserServiceImpl.java
server-service/src/main/java/com/makeit/task/IotSyncTask.java
server-service/src/main/java/com/makeit/vo/platform/auth/PlatPersonDTOVO.java
server-common/src/main/java/com/makeit/module/iot/mqtt/PushCallback.java
View file @
180b1bdc
...
...
@@ -33,8 +33,8 @@ public class PushCallback implements MqttCallback {
// 收到消息并设置返回字符串格式
String
payload
=
new
String
(
message
.
getPayload
(),
"UTF-8"
);
//
logger.info("接收消息主题:{}, 接收消息QoS:{}", topic, message.getQos());
//
logger.info("接收消息内容:payload格式:{}", payload);
logger
.
info
(
"接收消息主题:{}, 接收消息QoS:{}"
,
topic
,
message
.
getQos
());
logger
.
info
(
"接收消息内容:payload格式:{}"
,
payload
);
// 解析数据
DeviceInfo
device
=
JSON
.
parseObject
(
payload
,
DeviceInfo
.
class
);
...
...
server-module/src/main/java/com/makeit/module/controller/system/ChinaAreaController.java
deleted
100644 → 0
View file @
7875e1b8
package
com
.
makeit
.
module
.
controller
.
system
;
import
com.makeit.common.response.ApiResponseEntity
;
import
com.makeit.common.response.ApiResponseUtils
;
import
com.makeit.module.system.dto.ChinaAreaDTO
;
import
com.makeit.module.system.entity.ChinaArea
;
import
com.makeit.module.system.service.ChinaAreaService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
/**
* <p>
* 省市区表 前端控制器
* </p>
*
* @author ywc
* @since 2021-06-09
*/
@Api
(
tags
=
"租户端-省市区"
)
@RestController
@RequestMapping
(
"/sys/china-area"
)
public
class
ChinaAreaController
{
@Autowired
private
ChinaAreaService
chinaAreaService
;
@ApiOperation
(
value
=
"列表"
,
notes
=
"列表"
)
@PostMapping
(
"list"
)
public
ApiResponseEntity
<
List
<
ChinaArea
>>
list
(
@RequestBody
ChinaAreaDTO
dto
)
{
return
ApiResponseUtils
.
success
(
chinaAreaService
.
list
(
dto
));
}
@ApiOperation
(
value
=
"树形列表"
,
notes
=
"树形列表"
)
@PostMapping
(
"tree"
)
public
ApiResponseEntity
<
List
<
ChinaArea
>>
tree
(
@RequestBody
ChinaAreaDTO
dto
)
{
List
<
ChinaArea
>
list
=
chinaAreaService
.
tree
(
dto
);
return
ApiResponseUtils
.
success
(
list
);
}
@ApiOperation
(
value
=
"树形列表-有深度"
,
notes
=
"树形列表-有深度"
)
@PostMapping
(
"treeDepth"
)
public
ApiResponseEntity
<
List
<
ChinaArea
>>
treeDepth
(
@RequestBody
ChinaAreaDTO
dto
)
{
if
(
dto
.
getDepth
()
==
null
)
{
dto
.
setDepth
(
1
);
}
List
<
ChinaArea
>
list
=
chinaAreaService
.
tree
(
dto
);
return
ApiResponseUtils
.
success
(
list
);
}
}
server-service/src/main/java/com/makeit/service/platform/auth/impl/PlatUserServiceImpl.java
View file @
180b1bdc
...
...
@@ -787,8 +787,8 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
user
.
setAccount
(
dto
.
getMobile
());
PlatOrg
platOrg
=
platOrgService
.
getById
(
dto
.
getId
()
);
user
.
setOrgPath
(
platOrg
.
getPath
()+
","
+
platOrg
.
getId
());
fillOrgPath
(
dto
,
user
);
save
(
user
);
dto
.
setId
(
user
.
getId
());
setRoleList
(
dto
);
...
...
@@ -796,6 +796,13 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
return
user
.
getId
();
}
private
void
fillOrgPath
(
PlatPersonDTOVO
dto
,
PlatUser
user
)
{
PlatOrg
platOrg
=
platOrgService
.
getById
(
dto
.
getId
());
if
(
platOrg
!=
null
)
{
user
.
setOrgPath
(
platOrg
.
getPath
()
+
","
+
platOrg
.
getId
());
}
}
@Transactional
@Override
...
...
@@ -807,8 +814,8 @@ public class PlatUserServiceImpl extends ServiceImpl<PlatUserMapper, PlatUser>
setPassword
(
user
);
PlatOrg
platOrg
=
platOrgService
.
getById
(
dto
.
getId
()
);
user
.
setOrgPath
(
platOrg
.
getPath
()+
","
+
platOrg
.
getId
());
fillOrgPath
(
dto
,
user
);
updateById
(
user
);
setRoleList
(
dto
);
}
...
...
server-service/src/main/java/com/makeit/task/IotSyncTask.java
View file @
180b1bdc
...
...
@@ -8,6 +8,8 @@ import com.makeit.enums.CommonEnum;
import
com.makeit.global.aspect.tenant.TenantIdIgnore
;
import
com.makeit.module.iot.service.IotOrgService
;
import
com.makeit.module.iot.vo.DeviceInstanceEntity
;
import
com.makeit.module.system.service.SysDictionaryCategoryService
;
import
com.makeit.module.system.vo.DictionaryVo
;
import
com.makeit.service.platform.device.PlatDeviceService
;
import
com.makeit.service.saas.PlatTenantService
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -35,6 +37,8 @@ public class IotSyncTask {
private
PlatTenantService
platTenantService
;
@Autowired
private
PlatDeviceService
platDeviceService
;
@Autowired
private
SysDictionaryCategoryService
sysDictionaryCategoryService
;
/**
* 一小时同步一次
...
...
@@ -47,14 +51,18 @@ public class IotSyncTask {
log
.
info
(
"开始执行同步设备信息接口"
);
LambdaQueryWrapper
<
PlatTenant
>
tenantLambdaQueryWrapper
=
new
LambdaQueryWrapper
<
PlatTenant
>().
eq
(
PlatTenant:
:
getStatus
,
CommonEnum
.
YES
.
getValue
());
List
<
PlatTenant
>
platTenants
=
platTenantService
.
list
(
tenantLambdaQueryWrapper
);
List
<
DictionaryVo
>
dictionaryVos
=
sysDictionaryCategoryService
.
getByCategoryCode
(
"device.category"
);
Map
<
String
,
String
>
dicNameIdMap
=
dictionaryVos
.
stream
().
collect
(
Collectors
.
toMap
(
DictionaryVo:
:
getName
,
DictionaryVo:
:
getValue
,
(
v1
,
v2
)
->
v1
));
for
(
PlatTenant
platTenant
:
platTenants
)
{
String
iotOrgId
=
platTenant
.
getIotOrgId
();
if
(
StringUtils
.
isBlank
(
iotOrgId
))
{
if
(
StringUtils
.
isBlank
(
iotOrgId
))
{
continue
;
}
//查询iot设备
List
<
DeviceInstanceEntity
>
iotDeviceList
=
iotOrgService
.
getOrgDevice
(
iotOrgId
);
if
(
CollectionUtils
.
isEmpty
(
iotDeviceList
))
{
if
(
CollectionUtils
.
isEmpty
(
iotDeviceList
))
{
continue
;
}
//查询平台设备
...
...
@@ -63,7 +71,7 @@ public class IotSyncTask {
.
in
(
PlatDevice:
:
getOriDeviceId
,
iotDeviceIdSet
);
List
<
PlatDevice
>
deviceList
=
platDeviceService
.
list
(
deviceLambdaQueryWrapper
);
//更新平台设备
Collection
<
PlatDevice
>
platDevices
=
convertToPlatDevice
(
iotDeviceList
,
deviceList
,
platTenant
.
getId
()
);
Collection
<
PlatDevice
>
platDevices
=
convertToPlatDevice
(
iotDeviceList
,
deviceList
,
platTenant
.
getId
(),
dicNameIdMap
);
platDeviceService
.
saveOrUpdateBatch
(
platDevices
);
}
...
...
@@ -80,28 +88,28 @@ public class IotSyncTask {
}
private
Collection
<
PlatDevice
>
convertToPlatDevice
(
List
<
DeviceInstanceEntity
>
iotDeviceList
,
List
<
PlatDevice
>
deviceList
,
String
tenantId
)
{
private
Collection
<
PlatDevice
>
convertToPlatDevice
(
List
<
DeviceInstanceEntity
>
iotDeviceList
,
List
<
PlatDevice
>
deviceList
,
String
tenantId
,
Map
<
String
,
String
>
dicNameIdMap
)
{
Map
<
String
,
PlatDevice
>
deviceMap
=
deviceList
.
stream
().
collect
(
Collectors
.
toMap
(
PlatDevice:
:
getOriDeviceId
,
v
->
v
,
(
a
,
b
)
->
a
));
iotDeviceList
.
forEach
(
iotDevice
->
{
iotDeviceList
.
forEach
(
iotDevice
->
{
PlatDevice
platDevice
=
deviceMap
.
get
(
iotDevice
.
getId
());
if
(
platDevice
==
null
)
{
platDevice
=
new
PlatDevice
();
if
(
platDevice
==
null
)
{
platDevice
=
new
PlatDevice
();
platDevice
.
setTenantId
(
tenantId
);
deviceMap
.
put
(
iotDevice
.
getId
(),
platDevice
);
deviceMap
.
put
(
iotDevice
.
getId
(),
platDevice
);
}
platDevice
.
setOriDeviceId
(
iotDevice
.
getId
());
platDevice
.
setName
(
iotDevice
.
getName
());
platDevice
.
setProductName
(
iotDevice
.
getProductName
());
platDevice
.
setProductId
(
iotDevice
.
getProductId
());
LocalDateTime
registryTime
=
LocalDateTime
.
ofEpochSecond
(
iotDevice
.
getRegistryTime
()
/
1000
,
0
,
ZoneOffset
.
ofHours
(
8
));
LocalDateTime
registryTime
=
LocalDateTime
.
ofEpochSecond
(
iotDevice
.
getRegistryTime
()
/
1000
,
0
,
ZoneOffset
.
ofHours
(
8
));
platDevice
.
setRegistrationDate
(
registryTime
);
platDevice
.
setDescription
(
iotDevice
.
getDescribe
());
String
state
=
iotDevice
.
getState
();
platDevice
.
setStatus
(
StringUtils
.
equals
(
"online"
,
state
)?
CommonEnum
.
YES
.
getValue
()
:
CommonEnum
.
NO
.
getValue
());
platDevice
.
setStatus
(
StringUtils
.
equals
(
"online"
,
state
)
?
CommonEnum
.
YES
.
getValue
()
:
CommonEnum
.
NO
.
getValue
());
//todo 根据类型名称来匹配
// platDevice.setCategory(
);
platDevice
.
setCategory
(
dicNameIdMap
.
get
(
iotDevice
.
getProductName
())
);
// platDevice.setFirmwareVersion();
// platDevice.setLastOnlineData();
// platDevice.setOrgId();
...
...
server-service/src/main/java/com/makeit/vo/platform/auth/PlatPersonDTOVO.java
View file @
180b1bdc
...
...
@@ -40,6 +40,8 @@ public class PlatPersonDTOVO extends BaseIdDTO {
@ApiModelProperty
(
value
=
"手机号"
)
private
String
mobile
;
private
String
email
;
@NotBlank
(
message
=
"状态不能为空"
)
@Pattern
(
regexp
=
"0|1"
,
message
=
"状态可选值为 0禁用 1启用"
)
@ApiModelProperty
(
value
=
"状态 0禁用 1启用"
)
...
...
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