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
d3a8dc00
authored
Sep 19, 2023
by
lzy
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
空间导入
parent
3e229647
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
159 additions
and
7 deletions
server-api/server-api.iml
server-service/src/main/java/com/makeit/dto/platform/space/PlatSpaceVO.java
server-service/src/main/java/com/makeit/service/platform/space/impl/PlatSpaceServiceImpl.java
server-api/server-api.iml
View file @
d3a8dc00
...
...
@@ -157,6 +157,7 @@
<orderEntry
type=
"library"
name=
"Maven: org.springframework.integration:spring-integration-core:5.5.5"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework:spring-messaging:5.3.12"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.retry:spring-retry:1.3.1"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: javax.annotation:javax.annotation-api:1.3.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.springframework.integration:spring-integration-mqtt:5.5.5"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.aliyun:dysmsapi20170525:2.0.9"
level=
"project"
/>
...
...
@@ -183,7 +184,6 @@
<orderEntry
type=
"library"
name=
"Maven: org.apache.poi:poi-ooxml:5.2.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.poi:poi-ooxml-lite:5.2.2"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.xmlbeans:xmlbeans:5.0.3"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: xml-apis:xml-apis:1.4.01"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.commons:commons-compress:1.21"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.github.virtuald:curvesapi:1.07"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: cn.hutool:hutool-all:5.3.5"
level=
"project"
/>
...
...
@@ -205,6 +205,7 @@
<orderEntry
type=
"library"
name=
"Maven: org.apache.xmlgraphics:batik-bridge:1.14"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.xmlgraphics:batik-script:1.14"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.xmlgraphics:batik-dom:1.14"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: xml-apis:xml-apis:1.4.01"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.xmlgraphics:batik-gvt:1.14"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.xmlgraphics:batik-shared-resources:1.14"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.apache.xmlgraphics:batik-svggen:1.14"
level=
"project"
/>
...
...
server-service/src/main/java/com/makeit/dto/platform/space/PlatSpaceVO.java
View file @
d3a8dc00
...
...
@@ -22,6 +22,9 @@ public class PlatSpaceVO extends BaseIdDTO {
@ApiModelProperty
(
"父级Id"
)
private
String
parentId
;
@ApiModelProperty
(
"父级名称"
)
private
String
parentName
;
@ApiModelProperty
(
"子集"
)
private
List
<
PlatSpaceVO
>
children
;
}
server-service/src/main/java/com/makeit/service/platform/space/impl/PlatSpaceServiceImpl.java
View file @
d3a8dc00
...
...
@@ -6,15 +6,13 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import
com.makeit.common.dto.BaseIdDTO
;
import
com.makeit.common.vo.ExcelErrorVo
;
import
com.makeit.common.vo.ExcelImportVo
;
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.dto.platform.space.*
;
import
com.makeit.entity.platform.auth.PlatOrg
;
import
com.makeit.entity.platform.space.PlatBed
;
import
com.makeit.entity.platform.space.PlatRoom
;
import
com.makeit.entity.platform.space.PlatSpace
;
import
com.makeit.enums.CodeMessageEnum
;
import
com.makeit.enums.platform.space.PlatSpaceEnum
;
import
com.makeit.exception.BusinessException
;
import
com.makeit.mapper.platform.space.PlatSpaceMapper
;
import
com.makeit.service.platform.auth.PlatOrgService
;
...
...
@@ -23,6 +21,7 @@ import com.makeit.service.platform.space.PlatRoomService;
import
com.makeit.service.platform.space.PlatSpaceService
;
import
com.makeit.utils.data.convert.BeanDtoVoUtils
;
import
com.makeit.utils.data.excel.ExcelUtil
;
import
com.makeit.utils.user.TokenUtil
;
import
com.makeit.utils.user.plat.PlatUserUtil
;
import
com.makeit.utils.user.plat.PlatUserVO
;
import
com.makeit.vo.platform.space.PlatSpaceAndRoomVO
;
...
...
@@ -274,12 +273,22 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
}
@Override
@Transactional
public
ExcelImportVo
importSpaceExcel
(
MultipartFile
excelFile
)
{
ExcelImportVo
excelImportVo
=
new
ExcelImportVo
();
try
{
List
<
PlatSpace
>
listPlatSpace
=
list
(
new
LambdaQueryWrapper
<>());
List
<
PlatSpace
>
firstSpace
=
listPlatSpace
.
stream
().
filter
(
item
->
item
.
getParentId
()
==
null
).
collect
(
Collectors
.
toList
());
Map
<
String
,
String
>
firstSpaceNameMap
=
firstSpace
.
stream
().
collect
(
Collectors
.
toMap
(
PlatSpace:
:
getName
,
PlatSpace:
:
getId
,(
k1
,
k2
)->
k1
));
List
<
PlatSpace
>
listChildren
=
listPlatSpace
.
stream
().
filter
(
item
->
item
.
getParentId
()
!=
null
).
collect
(
Collectors
.
toList
());
Map
<
String
,
List
<
PlatSpace
>>
childrenMap
=
listChildren
.
stream
().
collect
(
Collectors
.
groupingBy
(
PlatSpace:
:
getParentId
));
Map
<
String
,
String
>
childrenIdMap
=
listChildren
.
stream
().
collect
(
Collectors
.
toMap
(
item
->
item
.
getParentId
()+
item
.
getName
(),
item
->
item
.
getId
(),(
k1
,
k2
)->
k1
));
List
<
PlatSpaceImportDTO
>
list
=
ExcelUtil
.
importExcel
(
null
,
3
,
excelFile
,
PlatSpaceImportDTO
.
class
);
List
<
ExcelErrorVo
>
errorVoList
=
new
ArrayList
<>(
10
);
...
...
@@ -287,19 +296,158 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
int
startRow
=
3
;
List
<
PlatSpace
>
listFirst
=
new
ArrayList
<>(
10
);
// List<PlatSpaceVO> listFirst = new ArrayList<>(10);
// List<PlatSpaceVO> listSecond = new ArrayList<>(10);
// List<PlatSpaceVO> listThree = new ArrayList<>(10);
// List<PlatSpaceVO> listFour = new ArrayList<>(10);
List
<
PlatRoomDTO
>
listRoom
=
new
ArrayList
<>(
10
);
List
<
String
>
listKey
=
new
ArrayList
<>();
Integer
errorCount
=
0
;
Integer
successCount
=
0
;
boolean
errorFlag
=
false
;
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++){
PlatSpaceImportDTO
item
=
list
.
get
(
i
);
if
(
StringUtil
.
isEmpty
(
item
.
getCommunity
())){
errorVoList
.
add
(
new
ExcelErrorVo
(
i
+
3
,
excelField
.
get
(
0
),
"第一层级必填"
));
errorFlag
=
true
;
}
if
(
StringUtil
.
isEmpty
(
item
.
getFloor
())){
errorVoList
.
add
(
new
ExcelErrorVo
(
i
+
3
,
excelField
.
get
(
4
),
"房间名必填"
));
errorFlag
=
true
;
}
String
key
=
item
.
getCommunity
();
//第二层级
if
(
StringUtil
.
isNotEmpty
(
item
.
getBuilding
())){
key
=
key
+
"-"
+
item
.
getBuilding
();
}
}
//第三层级
if
(
StringUtil
.
isNotEmpty
(
item
.
getUnit
())){
key
=
key
+
"-"
+
item
.
getUnit
();
}
//第四层级
if
(
StringUtil
.
isNotEmpty
(
item
.
getFloor
())){
key
=
key
+
"-"
+
item
.
getFloor
();
}
if
(
listKey
.
contains
(
key
)){
errorVoList
.
add
(
new
ExcelErrorVo
(
i
+
3
,
excelField
.
get
(
0
),
"该空间下,房间名已存在"
));
errorFlag
=
true
;
}
if
(
errorFlag
){
errorCount
++;
}
else
{
successCount
++;
}
}
String
orgId
=
TokenUtil
.
getTntUserDetail
().
getOrgId
();
if
(
errorVoList
.
isEmpty
()){
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++){
PlatSpaceImportDTO
item
=
list
.
get
(
i
);
//第一层级
String
firstId
=
null
;
if
(!
firstSpaceNameMap
.
containsKey
(
item
.
getCommunity
())){
PlatSpace
platSpace
=
new
PlatSpace
();
platSpace
.
setName
(
item
.
getCommunity
());
platSpace
.
setType
(
PlatSpaceEnum
.
TypeEnum
.
COMMUNITY
.
getValue
());
platSpace
.
setOrgId
(
orgId
);
save
(
platSpace
);
firstSpaceNameMap
.
put
(
platSpace
.
getName
(),
platSpace
.
getId
());
firstId
=
platSpace
.
getId
();
}
else
{
firstId
=
firstSpaceNameMap
.
get
(
item
.
getCommunity
());
}
//第二层级
String
secondId
=
null
;
if
(
StringUtil
.
isNotEmpty
(
item
.
getBuilding
())){
String
secondKey
=
firstId
+
"-"
+
item
.
getBuilding
();
if
(!
childrenIdMap
.
containsKey
(
secondKey
)){
PlatSpace
platSpace
=
new
PlatSpace
();
platSpace
.
setName
(
item
.
getBuilding
());
platSpace
.
setType
(
PlatSpaceEnum
.
TypeEnum
.
BUILDING
.
getValue
());
platSpace
.
setOrgId
(
orgId
);
platSpace
.
setParentId
(
firstId
);
platSpace
.
setParentPath
(
firstId
);
save
(
platSpace
);
childrenIdMap
.
put
(
secondKey
,
platSpace
.
getId
());
secondId
=
platSpace
.
getId
();
}
else
{
secondId
=
childrenIdMap
.
get
(
secondKey
);
}
}
//第三级
String
threeId
=
null
;
if
(
StringUtil
.
isNotEmpty
(
item
.
getUnit
())){
String
threeKey
=
secondId
+
"-"
+
item
.
getUnit
();
if
(!
childrenIdMap
.
containsKey
(
threeKey
)){
PlatSpace
platSpace
=
new
PlatSpace
();
platSpace
.
setName
(
item
.
getBuilding
());
platSpace
.
setType
(
PlatSpaceEnum
.
TypeEnum
.
UNIT
.
getValue
());
platSpace
.
setOrgId
(
orgId
);
platSpace
.
setParentId
(
secondId
);
platSpace
.
setParentPath
(
firstId
+
","
+
secondId
);
save
(
platSpace
);
childrenIdMap
.
put
(
threeKey
,
platSpace
.
getId
());
threeId
=
platSpace
.
getId
();
}
else
{
threeId
=
childrenIdMap
.
get
(
threeKey
);
}
}
//第四级
String
fourId
=
null
;
if
(
StringUtil
.
isNotEmpty
(
item
.
getFloor
())){
String
fourKey
=
threeId
+
"-"
+
item
.
getFloor
();
if
(!
childrenIdMap
.
containsKey
(
fourKey
)){
PlatSpace
platSpace
=
new
PlatSpace
();
platSpace
.
setName
(
item
.
getBuilding
());
platSpace
.
setType
(
PlatSpaceEnum
.
TypeEnum
.
FLOOR
.
getValue
());
platSpace
.
setOrgId
(
orgId
);
platSpace
.
setParentId
(
threeId
);
platSpace
.
setParentPath
(
firstId
+
","
+
secondId
+
","
+
threeId
);
save
(
platSpace
);
childrenIdMap
.
put
(
fourKey
,
platSpace
.
getId
());
fourId
=
platSpace
.
getId
();
}
else
{
fourId
=
childrenIdMap
.
get
(
fourKey
);
}
}
//房间
PlatRoomDTO
platRoomDTO
=
new
PlatRoomDTO
();
platRoomDTO
.
setName
(
item
.
getRoomName
());
platRoomDTO
.
setBedNumber
(
item
.
getBedNumber
());
String
spaceId
=
null
;
if
(
firstId
!=
null
){
spaceId
=
firstId
;
}
else
if
(
secondId
!=
null
){
spaceId
=
secondId
;
}
else
if
(
threeId
!=
null
){
spaceId
=
threeId
;
}
else
if
(
fourId
!=
null
){
spaceId
=
fourId
;
}
platRoomDTO
.
setSpaceId
(
spaceId
);
platRoomService
.
add
(
platRoomDTO
);
}
}
excelImportVo
.
setTotalCount
(
list
.
size
());
excelImportVo
.
setErrorCount
(
errorCount
);
excelImportVo
.
setSuccessCount
(
successCount
);
...
...
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