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
b1a0a64a
authored
Dec 21, 2023
by
汪志阳
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fix:bug修复
parent
c8d2e6be
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
9 deletions
server-module/src/main/java/com/makeit/module/controller/space/PlatSpaceController.java
server-service/src/main/java/com/makeit/service/platform/space/PlatSpaceService.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 @
b1a0a64a
...
@@ -123,4 +123,11 @@ public class PlatSpaceController {
...
@@ -123,4 +123,11 @@ public class PlatSpaceController {
return
ApiResponseUtils
.
success
(
data
);
return
ApiResponseUtils
.
success
(
data
);
}
}
@ApiOperation
(
"修复空间层级数据"
)
@GetMapping
(
"fixPlacePath"
)
public
ApiResponseEntity
<
String
>
fixPlacePath
(
@RequestParam
String
spaceId
)
{
spaceService
.
fixPlacePath
(
spaceId
);
return
ApiResponseUtils
.
success
();
}
}
}
server-service/src/main/java/com/makeit/service/platform/space/PlatSpaceService.java
View file @
b1a0a64a
...
@@ -96,4 +96,6 @@ public interface PlatSpaceService extends IService<PlatSpace> {
...
@@ -96,4 +96,6 @@ public interface PlatSpaceService extends IService<PlatSpace> {
List
<
PlatSpace
>
listChildAndOrgIds
(
List
<
String
>
spaceIds
,
List
<
String
>
orgIds
);
List
<
PlatSpace
>
listChildAndOrgIds
(
List
<
String
>
spaceIds
,
List
<
String
>
orgIds
);
void
fixPlacePath
(
String
spaceId
);
}
}
server-service/src/main/java/com/makeit/service/platform/space/impl/PlatSpaceServiceImpl.java
View file @
b1a0a64a
...
@@ -70,7 +70,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
...
@@ -70,7 +70,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
private
void
check
(
PlatSpaceAddDTO
dto
)
{
private
void
check
(
PlatSpaceAddDTO
dto
)
{
if
(
StrUtil
.
isNotBlank
(
dto
.
getParentPath
())
if
(
StrUtil
.
isNotBlank
(
dto
.
getParentPath
())
&&
dto
.
getParentPath
().
split
(
","
).
length
>
=
4
)
{
&&
dto
.
getParentPath
().
split
(
","
).
length
>
4
)
{
throw
new
BusinessException
(
CodeMessageEnum
.
PLATFORM_ERROR_SPACE_OVER_LEVEL
);
throw
new
BusinessException
(
CodeMessageEnum
.
PLATFORM_ERROR_SPACE_OVER_LEVEL
);
}
}
...
@@ -224,8 +224,8 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
...
@@ -224,8 +224,8 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
private
void
checkAndUpdateSonSpace
(
PlatSpace
space
)
{
private
void
checkAndUpdateSonSpace
(
PlatSpace
space
)
{
String
parentPath
=
space
.
getParentPath
();
String
parentPath
=
space
.
getParentPath
();
int
level
=
StrUtil
.
isBlank
(
parentPath
)
?
0
:
parentPath
.
split
(
","
).
length
;
int
level
=
StrUtil
.
isBlank
(
parentPath
)
?
1
:
parentPath
.
split
(
","
).
length
+
1
;
if
(
level
>
3
)
{
if
(
level
>
4
)
{
throw
new
BusinessException
(
CodeMessageEnum
.
PLATFORM_ERROR_SPACE_OVER_LEVEL
);
throw
new
BusinessException
(
CodeMessageEnum
.
PLATFORM_ERROR_SPACE_OVER_LEVEL
);
}
}
String
spaceId
=
space
.
getId
();
String
spaceId
=
space
.
getId
();
...
@@ -238,16 +238,14 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
...
@@ -238,16 +238,14 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
if
(
StrUtil
.
isBlank
(
s
.
getParentPath
()))
{
if
(
StrUtil
.
isBlank
(
s
.
getParentPath
()))
{
return
;
return
;
}
}
List
<
String
>
parentSpaceIds
=
Lists
.
newArrayList
(
s
.
getParentPath
().
split
(
","
));
int
maxSpacePath
=
getMaxSpacePath
(
s
.
getParentPath
(),
spaceId
);
parentSpaceIds
.
remove
(
space
.
getId
());
if
(
maxSpacePath
>
maxLength
.
get
())
{
if
(
parentSpaceIds
.
size
()
>
maxLength
.
get
())
{
maxLength
.
set
(
maxSpacePath
);
maxLength
.
set
(
parentSpaceIds
.
size
());
}
}
maxLength
.
set
(
parentSpaceIds
.
size
());
});
});
sonLevel
=
maxLength
.
get
();
sonLevel
=
maxLength
.
get
();
}
}
if
(
level
+
sonLevel
>
3
)
{
if
(
level
+
sonLevel
>
4
)
{
throw
new
BusinessException
(
CodeMessageEnum
.
PLATFORM_ERROR_SPACE_OVER_LEVEL
);
throw
new
BusinessException
(
CodeMessageEnum
.
PLATFORM_ERROR_SPACE_OVER_LEVEL
);
}
}
// 更新下级空间的parentPath
// 更新下级空间的parentPath
...
@@ -268,6 +266,12 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
...
@@ -268,6 +266,12 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
}
}
private
Integer
getMaxSpacePath
(
String
path
,
String
splitSpace
)
{
List
<
String
>
pathList
=
Arrays
.
asList
(
path
.
split
(
","
));
return
pathList
.
size
()
-
pathList
.
indexOf
(
splitSpace
);
}
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
del
(
String
id
)
{
public
void
del
(
String
id
)
{
...
@@ -1093,7 +1097,48 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
...
@@ -1093,7 +1097,48 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
return
data
;
return
data
;
}
}
@Override
public
void
fixPlacePath
(
String
spaceId
)
{
PlatSpace
space
=
getById
(
spaceId
);
if
(
space
==
null
||
StrUtil
.
isNotBlank
(
space
.
getParentId
()))
{
return
;
}
List
<
PlatSpace
>
allList
=
new
ArrayList
<>();
recursionSetParentPath
(
spaceId
,
space
.
getParentPath
(),
allList
);
if
(
CollUtil
.
isNotEmpty
(
allList
))
{
updateBatchById
(
allList
);
}
// fixAllSpacePath();
}
private
void
fixAllSpacePath
()
{
List
<
PlatSpace
>
allData
=
list
();
List
<
PlatSpace
>
firstSpaceList
=
allData
.
stream
().
filter
(
f
->
StrUtil
.
isBlank
(
f
.
getParentId
())
&&
StrUtil
.
isBlank
(
f
.
getParentPath
())).
collect
(
Collectors
.
toList
());
if
(
CollUtil
.
isEmpty
(
firstSpaceList
))
{
return
;
}
firstSpaceList
.
forEach
(
f
->
{
List
<
PlatSpace
>
allList
=
new
ArrayList
<>();
recursionSetParentPath
(
f
.
getId
(),
f
.
getParentPath
(),
allList
);
if
(
CollUtil
.
isNotEmpty
(
allList
))
{
updateBatchById
(
allList
);
}
});
}
private
void
recursionSetParentPath
(
String
spaceId
,
String
parentPath
,
List
<
PlatSpace
>
allList
)
{
List
<
PlatSpace
>
firstSonList
=
list
(
Wrappers
.<
PlatSpace
>
lambdaQuery
().
eq
(
PlatSpace:
:
getParentId
,
spaceId
));
if
(
CollUtil
.
isEmpty
(
firstSonList
))
{
return
;
}
firstSonList
.
forEach
(
s
->
{
s
.
setParentPath
(
StrUtil
.
isNotBlank
(
parentPath
)
?
parentPath
+
","
+
s
.
getParentId
()
:
spaceId
);
allList
.
add
(
s
);
recursionSetParentPath
(
s
.
getId
(),
s
.
getParentPath
(),
allList
);
});
}
}
}
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