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
c83849e4
authored
Sep 25, 2023
by
朱淼
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
空间导入
parent
f876ca74
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
7 deletions
server-module/src/main/java/com/makeit/module/controller/space/PlatSpaceController.java
server-service/src/main/java/com/makeit/service/platform/device/impl/PlatDeviceServiceImpl.java
server-service/src/main/java/com/makeit/service/platform/space/impl/PlatRegionSettingServiceImpl.java
server-service/src/main/java/com/makeit/service/platform/space/impl/PlatSpaceServiceImpl.java
server-module/src/main/java/com/makeit/module/controller/space/PlatSpaceController.java
View file @
c83849e4
...
...
@@ -3,22 +3,24 @@ package com.makeit.module.controller.space;
import
com.makeit.common.dto.BaseIdDTO
;
import
com.makeit.common.response.ApiResponseEntity
;
import
com.makeit.common.response.ApiResponseUtils
;
import
com.makeit.common.vo.ExcelImportVo
;
import
com.makeit.dto.platform.elder.PlatElderImportDTO
;
import
com.makeit.dto.platform.space.PlatSpaceAddDTO
;
import
com.makeit.dto.platform.space.PlatSpaceImportDTO
;
import
com.makeit.dto.platform.space.PlatSpaceQueryDTO
;
import
com.makeit.dto.platform.space.PlatSpaceVO
;
import
com.makeit.enums.CodeMessageEnum
;
import
com.makeit.enums.FileSuffixEnum
;
import
com.makeit.exception.BusinessException
;
import
com.makeit.global.annotation.Action
;
import
com.makeit.service.platform.space.PlatSpaceService
;
import
com.makeit.utils.data.excel.ExcelUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
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
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.List
;
...
...
@@ -92,6 +94,16 @@ public class PlatSpaceController {
}
@ApiOperation
(
"批量导入"
)
@PostMapping
(
"import"
)
public
ApiResponseEntity
<
ExcelImportVo
>
importExcel
(
@RequestParam
(
value
=
"excelFile"
,
required
=
false
)
MultipartFile
excelFile
){
if
(
excelFile
==
null
){
throw
new
BusinessException
(
CodeMessageEnum
.
SYSTEM_ERROR_EXCEL_UPLOAD_EXIT
);
}
ExcelImportVo
excelImportVo
=
spaceService
.
importSpaceExcel
(
excelFile
);
return
ApiResponseUtils
.
success
(
excelImportVo
);
}
@ApiOperation
(
"树-上级空间"
)
@PostMapping
(
"parentListTree"
)
public
ApiResponseEntity
<
List
<
PlatSpaceVO
>>
parentListTree
(
@RequestBody
PlatSpaceQueryDTO
dto
)
{
...
...
server-service/src/main/java/com/makeit/service/platform/device/impl/PlatDeviceServiceImpl.java
View file @
c83849e4
...
...
@@ -2,6 +2,7 @@ package com.makeit.service.platform.device.impl;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.makeit.common.dto.BaseTenantDTO
;
...
...
@@ -19,6 +20,7 @@ import com.makeit.dto.wechat.device.PlatDeviceSetupDTO;
import
com.makeit.entity.platform.auth.PlatOrg
;
import
com.makeit.entity.platform.device.PlatDevice
;
import
com.makeit.entity.platform.device.PlatDeviceOther
;
import
com.makeit.entity.platform.space.PlatRegionSetting
;
import
com.makeit.enums.CodeMessageEnum
;
import
com.makeit.exception.BusinessException
;
import
com.makeit.mapper.platform.device.PlatDeviceMapper
;
...
...
@@ -26,6 +28,7 @@ import com.makeit.module.iot.service.IotDevicePropertiesOperateService;
import
com.makeit.service.platform.auth.PlatOrgService
;
import
com.makeit.service.platform.device.PlatDeviceOtherService
;
import
com.makeit.service.platform.device.PlatDeviceService
;
import
com.makeit.service.platform.space.PlatRegionSettingService
;
import
com.makeit.service.saas.PlatTenantService
;
import
com.makeit.utils.DeviceCacheUtil
;
import
com.makeit.utils.data.convert.BeanDtoVoUtils
;
...
...
@@ -64,6 +67,8 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
private
IotDevicePropertiesOperateService
devicePropertiesOperateService
;
@Autowired
private
PlatTenantService
platTenantService
;
@Autowired
private
PlatRegionSettingService
platRegionSettingService
;
@Override
public
PageVO
<
PlatDeviceListVO
>
page
(
PageReqDTO
<
PlatDeviceQueryDTO
>
pageReqDTO
)
{
...
...
@@ -196,6 +201,11 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
deviceCacheUtil
.
put
(
db
);
platDeviceOtherService
.
saveOrUpdate
(
other
);
//更新区域设置设备安装方式
platRegionSettingService
.
update
(
new
UpdateWrapper
<
PlatRegionSetting
>().
lambda
()
.
set
(
PlatRegionSetting:
:
getInstallType
,
other
.
getInstallation
())
.
eq
(
PlatRegionSetting:
:
getDeviceId
,
other
.
getDeviceId
()));
}
@Override
...
...
server-service/src/main/java/com/makeit/service/platform/space/impl/PlatRegionSettingServiceImpl.java
View file @
c83849e4
...
...
@@ -22,6 +22,7 @@ import com.makeit.utils.data.convert.BeanDtoVoUtils;
import
com.makeit.utils.data.convert.JsonUtil
;
import
com.makeit.utils.data.validate.CollectionUtils
;
import
com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO
;
import
jodd.util.StringUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -103,7 +104,6 @@ public class PlatRegionSettingServiceImpl extends ServiceImpl<PlatRegionSettingM
List
<
PlatRegionSetting
>
list
=
list
(
queryWrapper
);
List
<
PlatRegionSettingDTO
>
data
=
BeanDtoVoUtils
.
listVo
(
list
,
PlatRegionSettingDTO
.
class
);
if
(!
list
.
isEmpty
()){
List
<
String
>
listDeviceIds
=
data
.
stream
().
map
(
item
->
item
.
getDeviceId
()).
collect
(
Collectors
.
toList
());
LambdaQueryWrapper
<
PlatDevice
>
queryWrapper1
=
new
LambdaQueryWrapper
<>();
...
...
@@ -112,11 +112,15 @@ public class PlatRegionSettingServiceImpl extends ServiceImpl<PlatRegionSettingM
List
<
PlatDevice
>
devices
=
platDeviceService
.
list
(
queryWrapper1
);
Map
<
String
,
String
>
map
=
devices
.
stream
().
collect
(
Collectors
.
toMap
(
PlatDevice:
:
getId
,
PlatDevice:
:
getName
,(
k1
,
k2
)->
k1
));
Map
<
String
,
String
>
oriDeviceIdMap
=
devices
.
stream
().
collect
(
Collectors
.
toMap
(
PlatDevice:
:
getId
,
PlatDevice:
:
getOriDeviceId
,(
k1
,
k2
)->
k1
));
List
<
String
>
deviceIds
=
devices
.
stream
().
map
(
PlatDevice:
:
getId
).
collect
(
Collectors
.
toList
());
data
.
forEach
(
item
->{
item
.
setDeviceName
(
map
.
get
(
item
.
getDeviceId
()));
item
.
setOriDeviceId
(
oriDeviceIdMap
.
get
(
item
.
getDeviceId
()));
});
//过滤删除的设备
data
=
data
.
stream
().
filter
(
t
->
deviceIds
.
contains
(
t
.
getDeviceId
())).
collect
(
Collectors
.
toList
());
}
return
data
;
}
...
...
server-service/src/main/java/com/makeit/service/platform/space/impl/PlatSpaceServiceImpl.java
View file @
c83849e4
...
...
@@ -30,6 +30,7 @@ import jodd.util.StringUtil;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.interceptor.TransactionAspectSupport
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.ArrayList
;
...
...
@@ -297,7 +298,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
}
@Override
@Transactional
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
ExcelImportVo
importSpaceExcel
(
MultipartFile
excelFile
)
{
ExcelImportVo
excelImportVo
=
new
ExcelImportVo
();
...
...
@@ -339,7 +340,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
errorFlag
=
true
;
}
if
(
StringUtil
.
isEmpty
(
item
.
get
Floor
())){
if
(
StringUtil
.
isEmpty
(
item
.
get
RoomName
())){
errorVoList
.
add
(
new
ExcelErrorVo
(
i
+
3
,
excelField
.
get
(
4
),
"房间名必填"
));
errorFlag
=
true
;
}
...
...
@@ -380,6 +381,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
PlatSpaceImportDTO
item
=
list
.
get
(
i
);
String
spacePath
=
null
;
//第一层级
String
firstId
=
null
;
if
(!
firstSpaceNameMap
.
containsKey
(
item
.
getCommunity
())){
...
...
@@ -390,6 +392,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
save
(
platSpace
);
firstSpaceNameMap
.
put
(
platSpace
.
getName
(),
platSpace
.
getId
());
firstId
=
platSpace
.
getId
();
spacePath
=
firstId
;
}
else
{
firstId
=
firstSpaceNameMap
.
get
(
item
.
getCommunity
());
}
...
...
@@ -412,6 +415,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
}
else
{
secondId
=
childrenIdMap
.
get
(
secondKey
);
}
spacePath
=
spacePath
+
","
+
secondId
;
}
//第三级
...
...
@@ -432,6 +436,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
}
else
{
threeId
=
childrenIdMap
.
get
(
threeKey
);
}
spacePath
=
spacePath
+
","
+
threeId
;
}
//第四级
...
...
@@ -452,6 +457,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
}
else
{
fourId
=
childrenIdMap
.
get
(
fourKey
);
}
spacePath
=
spacePath
+
","
+
fourId
;
}
//房间
...
...
@@ -469,6 +475,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
spaceId
=
fourId
;
}
platRoomDTO
.
setSpaceId
(
spaceId
);
platRoomDTO
.
setSpacePath
(
spacePath
);
platRoomService
.
add
(
platRoomDTO
);
}
}
...
...
@@ -478,6 +485,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
excelImportVo
.
setList
(
errorVoList
);
return
excelImportVo
;
}
catch
(
Exception
e
){
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
e
.
printStackTrace
();
}
...
...
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