Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
项目统一框架
amos-boot-biz
Commits
eda2c3e4
Commit
eda2c3e4
authored
Jan 04, 2022
by
chenhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改树信息中count显示不出来的问题
parent
9776c531
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
117 additions
and
2 deletions
+117
-2
DataDictionaryServiceImpl.java
...ot/biz/common/service/impl/DataDictionaryServiceImpl.java
+2
-2
TreeParser.java
...va/com/yeejoin/amos/boot/biz/common/utils/TreeParser.java
+115
-0
No files found.
amos-boot-biz-common/src/main/java/com/yeejoin/amos/boot/biz/common/service/impl/DataDictionaryServiceImpl.java
View file @
eda2c3e4
...
@@ -118,8 +118,8 @@ public class DataDictionaryServiceImpl extends BaseService<DataDictionaryDto, Da
...
@@ -118,8 +118,8 @@ public class DataDictionaryServiceImpl extends BaseService<DataDictionaryDto, Da
public
List
<
Menu
>
getFireTeamTypeTree
(
String
bizOrgCode
)
throws
Exception
{
public
List
<
Menu
>
getFireTeamTypeTree
(
String
bizOrgCode
)
throws
Exception
{
// Menu root = new Menu(null, "消防队伍类型", null, null,0);
// Menu root = new Menu(null, "消防队伍类型", null, null,0);
List
<
DataDictionary
>
list
=
dataDictionaryMapper
.
getFireTeamTypeTree
(
bizOrgCode
);
List
<
DataDictionary
>
list
=
dataDictionaryMapper
.
getFireTeamTypeTree
(
bizOrgCode
);
List
<
Menu
>
menus
=
TreeParser
.
getTree
(
null
,
list
,
DataDictionary
.
class
.
getName
(),
"getCode"
,
0
,
"getName"
,
List
<
Menu
>
menus
=
TreeParser
.
getTree
ContainsCount
(
null
,
list
,
DataDictionary
.
class
.
getName
(),
"getCode"
,
0
,
"getName"
,
"getParent"
,
null
);
"getParent"
,
"getCount"
);
// root.setChildren(menus);
// root.setChildren(menus);
return
Lists
.
newArrayList
(
menus
);
return
Lists
.
newArrayList
(
menus
);
}
}
...
...
amos-boot-biz-common/src/main/java/com/yeejoin/amos/boot/biz/common/utils/TreeParser.java
View file @
eda2c3e4
...
@@ -343,4 +343,119 @@ public class TreeParser {
...
@@ -343,4 +343,119 @@ public class TreeParser {
}
}
return
sb
.
toString
();
return
sb
.
toString
();
}
}
@SuppressWarnings
(
"unchecked"
)
public
static
List
<
Menu
>
getTreeContainsCount
(
Long
topId
,
@SuppressWarnings
(
"rawtypes"
)
Collection
entityList
,
String
packageURL
,
String
IDMethodName
,
int
IDHierarchy
,
String
NAMEMethodName
,
String
PARENTIDMethodName
,
String
COUNTMethodName
)
throws
Exception
{
List
<
Menu
>
resultList
=
new
ArrayList
<>();
@SuppressWarnings
(
"rawtypes"
)
Class
clazz
=
Class
.
forName
(
packageURL
);
Method
IDMethodNameme
=
null
;
switch
(
IDHierarchy
)
{
case
1
:
IDMethodNameme
=
clazz
.
getDeclaredMethod
(
IDMethodName
);
break
;
case
2
:
IDMethodNameme
=
clazz
.
getSuperclass
().
getDeclaredMethod
(
IDMethodName
);
break
;
case
3
:
IDMethodNameme
=
clazz
.
getSuperclass
().
getSuperclass
().
getDeclaredMethod
(
IDMethodName
);
break
;
default
:
IDMethodNameme
=
clazz
.
getDeclaredMethod
(
IDMethodName
);
break
;
}
Method
NAMEMethodNameme
=
clazz
.
getDeclaredMethod
(
NAMEMethodName
);
Method
PARENTIDMethodNameme
=
clazz
.
getDeclaredMethod
(
PARENTIDMethodName
);
Method
COUNTMethodName1
=
clazz
.
getDeclaredMethod
(
COUNTMethodName
);
//获取顶层元素集合
Long
parentId
;
for
(
Object
ob
:
entityList
)
{
Object
entity
=
clazz
.
cast
(
ob
);
parentId
=
PARENTIDMethodNameme
.
invoke
(
entity
)
!=
null
?
Long
.
valueOf
(
String
.
valueOf
(
PARENTIDMethodNameme
.
invoke
(
entity
)))
:
null
;
if
(
parentId
==
null
||
parentId
.
equals
(
topId
)
)
{
//陈浩2021-12-01修改 topId == parentId 的判断
String
codeString
=
String
.
valueOf
(
IDMethodNameme
.
invoke
(
entity
));
Integer
num
=
Integer
.
parseInt
(
String
.
valueOf
(
COUNTMethodName1
.
invoke
(
entity
)));
Menu
menu
=
new
Menu
(
Long
.
valueOf
(
codeString
),
String
.
valueOf
(
NAMEMethodNameme
.
invoke
(
entity
)),
parentId
,
num
);
resultList
.
add
(
menu
);
}
}
//获取每个顶层元素的子数据集合
for
(
Menu
entity
:
resultList
)
{
entity
.
setChildren
(
getSubContainsCount
(
entity
.
getId
(),
entityList
,
packageURL
,
IDMethodName
,
IDHierarchy
,
NAMEMethodName
,
PARENTIDMethodName
,
COUNTMethodName
));
}
return
resultList
;
}
/**
* 获取子数据集合
*/
@SuppressWarnings
(
"unchecked"
)
private
static
List
<
Menu
>
getSubContainsCount
(
Long
topId
,
@SuppressWarnings
(
"rawtypes"
)
Collection
entityList
,
String
packageURL
,
String
IDMethodName
,
int
IDHierarchy
,
String
NAMEMethodName
,
String
PARENTIDMethodName
,
String
COUNTMethodName
)
throws
Exception
{
List
<
Menu
>
childList
=
new
ArrayList
<>();
@SuppressWarnings
(
"rawtypes"
)
Class
clazz
=
Class
.
forName
(
packageURL
);
Method
IDMethodNameme
=
null
;
switch
(
IDHierarchy
)
{
case
1
:
IDMethodNameme
=
clazz
.
getDeclaredMethod
(
IDMethodName
);
break
;
case
2
:
IDMethodNameme
=
clazz
.
getSuperclass
().
getDeclaredMethod
(
IDMethodName
);
break
;
case
3
:
IDMethodNameme
=
clazz
.
getSuperclass
().
getSuperclass
().
getDeclaredMethod
(
IDMethodName
);
break
;
default
:
IDMethodNameme
=
clazz
.
getDeclaredMethod
(
IDMethodName
);
break
;
}
Method
NAMEMethodNameme
=
clazz
.
getDeclaredMethod
(
NAMEMethodName
);
Method
PARENTIDMethodNameme
=
clazz
.
getDeclaredMethod
(
PARENTIDMethodName
);
Method
COUNTMethodName1
=
clazz
.
getDeclaredMethod
(
COUNTMethodName
);
Long
parentId
;
//子集的直接子对象
for
(
Object
ob
:
entityList
)
{
Object
entity
=
clazz
.
cast
(
ob
);
parentId
=
PARENTIDMethodNameme
.
invoke
(
entity
)
!=
null
?
Long
.
valueOf
(
String
.
valueOf
(
PARENTIDMethodNameme
.
invoke
(
entity
)))
:
null
;
if
(
parentId
==
null
)
{
if
(
topId
==
parentId
)
{
String
codeString
=
String
.
valueOf
(
IDMethodNameme
.
invoke
(
entity
));
Integer
num
=
Integer
.
parseInt
(
String
.
valueOf
(
COUNTMethodName1
.
invoke
(
entity
)));
Menu
menu
=
new
Menu
(
Long
.
valueOf
(
codeString
),
String
.
valueOf
(
NAMEMethodNameme
.
invoke
(
entity
)),
parentId
,
num
);
childList
.
add
(
menu
);
}
}
else
{
if
(
topId
.
longValue
()
==
parentId
.
longValue
())
{
String
codeString
=
String
.
valueOf
(
IDMethodNameme
.
invoke
(
entity
));
Integer
num
=
Integer
.
parseInt
(
String
.
valueOf
(
COUNTMethodName1
.
invoke
(
entity
)));
Menu
menu
=
new
Menu
(
Long
.
valueOf
(
codeString
),
String
.
valueOf
(
NAMEMethodNameme
.
invoke
(
entity
)),
parentId
,
num
);
childList
.
add
(
menu
);
}
}
}
//子集的间接子对象
for
(
Menu
entity
:
childList
)
{
entity
.
setChildren
(
getSubContainsCount
(
entity
.
getId
(),
entityList
,
packageURL
,
IDMethodName
,
IDHierarchy
,
NAMEMethodName
,
PARENTIDMethodName
,
COUNTMethodName
));
}
//递归退出条件
if
(
childList
.
size
()
==
0
)
{
return
null
;
}
return
childList
;
}
}
}
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