Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-trialdrive-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 7e104f4c
authored
May 25, 2021
by
杨林龙
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
2 parents
3ebb408e
dc5974c8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
139 additions
and
8 deletions
src/main/java/cn/com/glsx/admin/modules/model/SimpleTreeModel.java
src/main/java/cn/com/glsx/admin/modules/service/VehicleMonitorSevice.java
src/test/java/cn/com/glsx/test/RestTest.java
src/main/java/cn/com/glsx/admin/modules/model/SimpleTreeModel.java
View file @
7e104f4
...
@@ -12,6 +12,7 @@ public class SimpleTreeModel implements Serializable {
...
@@ -12,6 +12,7 @@ public class SimpleTreeModel implements Serializable {
private
Long
id
;
private
Long
id
;
private
String
label
;
private
String
label
;
private
Long
parentId
;
private
Integer
type
;
private
Integer
type
;
private
boolean
isRoot
;
private
boolean
isRoot
;
private
List
<
SimpleTreeModel
>
children
;
private
List
<
SimpleTreeModel
>
children
;
...
...
src/main/java/cn/com/glsx/admin/modules/service/VehicleMonitorSevice.java
View file @
7e104f4
...
@@ -26,6 +26,7 @@ import com.google.common.collect.Lists;
...
@@ -26,6 +26,7 @@ import com.google.common.collect.Lists;
import
com.google.gson.reflect.TypeToken
;
import
com.google.gson.reflect.TypeToken
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -60,15 +61,21 @@ public class VehicleMonitorSevice {
...
@@ -60,15 +61,21 @@ public class VehicleMonitorSevice {
public
List
<
SimpleTreeModel
>
vTree
(
VehicleTreeSearch
search
)
{
public
List
<
SimpleTreeModel
>
vTree
(
VehicleTreeSearch
search
)
{
List
<
Organization
>
orgList
=
Lists
.
newArrayList
();
List
<
Organization
>
orgList
=
Lists
.
newArrayList
();
if
(
search
.
getOrgId
()
==
null
)
{
R
<
List
<
Organization
>>
listR
=
organizationService
.
getRootOrganizations
();
if
(
search
.
getTermType
()
!=
null
&&
StringUtils
.
isNotBlank
(
search
.
getTerm
()))
{
orgList
=
listR
.
getDataList
(
new
TypeToken
<
List
<
Organization
>>()
{
}.
getType
());
}
else
{
}
else
{
R
<
List
<
Organization
>>
listR
=
organizationService
.
getSubOrganizations
(
search
.
getOrgId
());
if
(
search
.
getOrgId
()
==
null
)
{
orgList
=
listR
.
getDataList
(
new
TypeToken
<
List
<
Organization
>>()
{
R
<
List
<
Organization
>>
listR
=
organizationService
.
getRootOrganizations
();
}.
getType
());
orgList
=
listR
.
getDataList
(
new
TypeToken
<
List
<
Organization
>>()
{
}.
getType
());
}
else
{
R
<
List
<
Organization
>>
listR
=
organizationService
.
getSubOrganizations
(
search
.
getOrgId
());
orgList
=
listR
.
getDataList
(
new
TypeToken
<
List
<
Organization
>>()
{
}.
getType
());
}
}
}
List
<
SimpleTreeModel
>
treeModelList
=
Lists
.
newArrayList
();
List
<
SimpleTreeModel
>
treeModelList
=
Lists
.
newArrayList
();
orgList
.
forEach
(
org
->
{
orgList
.
forEach
(
org
->
{
SimpleTreeModel
treeModel
=
new
SimpleTreeModel
();
SimpleTreeModel
treeModel
=
new
SimpleTreeModel
();
...
...
src/test/java/cn/com/glsx/test/RestTest.java
View file @
7e104f4
package
cn
.
com
.
glsx
.
test
;
package
cn
.
com
.
glsx
.
test
;
import
cn.com.glsx.admin.modules.model.SimpleTreeModel
;
import
cn.com.glsx.usercenter.api.dto.response.User
;
import
cn.com.glsx.usercenter.api.dto.response.User
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.TypeReference
;
import
com.alibaba.fastjson.TypeReference
;
...
@@ -8,6 +9,8 @@ import com.google.gson.Gson;
...
@@ -8,6 +9,8 @@ import com.google.gson.Gson;
import
com.google.gson.GsonBuilder
;
import
com.google.gson.GsonBuilder
;
import
com.google.gson.reflect.TypeToken
;
import
com.google.gson.reflect.TypeToken
;
import
java.util.List
;
public
class
RestTest
{
public
class
RestTest
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
...
@@ -15,7 +18,8 @@ public class RestTest {
...
@@ -15,7 +18,8 @@ public class RestTest {
// String url = "";
// String url = "";
// R messageList = restTemplate.getForObject(url, R.class);
// R messageList = restTemplate.getForObject(url, R.class);
test
();
// test();
testOrg
();
}
}
public
static
void
test
()
{
public
static
void
test
()
{
...
@@ -32,4 +36,123 @@ public class RestTest {
...
@@ -32,4 +36,123 @@ public class RestTest {
}.
getType
());
}.
getType
());
System
.
out
.
println
(
r3
);
System
.
out
.
println
(
r3
);
}
}
public
static
void
testOrg
()
{
String
json
=
"[\n"
+
" {\n"
+
" \"userNumber\": 0,\n"
+
" \"children\": [\n"
+
" {\n"
+
" \"userNumber\": 0,\n"
+
" \"children\": [\n"
+
" {\n"
+
" \"userNumber\": 0,\n"
+
" \"children\": [\n"
+
" {\n"
+
" \"userNumber\": 0,\n"
+
" \"children\": [\n"
+
" {\n"
+
" \"userNumber\": 3,\n"
+
" \"children\": [\n"
+
" {\n"
+
" \"userNumber\": 1,\n"
+
" \"children\": [],\n"
+
" \"id\": 165,\n"
+
" \"origin\": {\n"
+
" \"orgId\": 165,\n"
+
" \"orgName\": \"广州恒福店\",\n"
+
" \"parentId\": 162,\n"
+
" \"tenantId\": 33,\n"
+
" \"isRoot\": 0\n"
+
" },\n"
+
" \"depth\": 5,\n"
+
" \"parentId\": 162,\n"
+
" \"label\": \"广州恒福店\"\n"
+
" },\n"
+
" {\n"
+
" \"userNumber\": 1,\n"
+
" \"children\": [],\n"
+
" \"id\": 169,\n"
+
" \"origin\": {\n"
+
" \"orgId\": 169,\n"
+
" \"orgName\": \"广州恒源店\",\n"
+
" \"parentId\": 162,\n"
+
" \"tenantId\": 33,\n"
+
" \"isRoot\": 0\n"
+
" },\n"
+
" \"depth\": 5,\n"
+
" \"parentId\": 162,\n"
+
" \"label\": \"广州恒源店\"\n"
+
" }\n"
+
" ],\n"
+
" \"id\": 162,\n"
+
" \"origin\": {\n"
+
" \"orgId\": 162,\n"
+
" \"orgName\": \"广州店\",\n"
+
" \"parentId\": 161,\n"
+
" \"tenantId\": 33,\n"
+
" \"isRoot\": 0\n"
+
" },\n"
+
" \"depth\": 4,\n"
+
" \"parentId\": 161,\n"
+
" \"label\": \"广州店\"\n"
+
" }\n"
+
" ],\n"
+
" \"id\": 161,\n"
+
" \"origin\": {\n"
+
" \"orgId\": 161,\n"
+
" \"orgName\": \"广州市\",\n"
+
" \"parentId\": 160,\n"
+
" \"tenantId\": 33,\n"
+
" \"isRoot\": 0\n"
+
" },\n"
+
" \"depth\": 3,\n"
+
" \"parentId\": 160,\n"
+
" \"label\": \"广州市\"\n"
+
" }\n"
+
" ],\n"
+
" \"id\": 160,\n"
+
" \"origin\": {\n"
+
" \"orgId\": 160,\n"
+
" \"orgName\": \"广东省\",\n"
+
" \"parentId\": 157,\n"
+
" \"tenantId\": 33,\n"
+
" \"isRoot\": 0\n"
+
" },\n"
+
" \"depth\": 2,\n"
+
" \"parentId\": 157,\n"
+
" \"label\": \"广东省\"\n"
+
" }\n"
+
" ],\n"
+
" \"id\": 157,\n"
+
" \"origin\": {\n"
+
" \"orgId\": 157,\n"
+
" \"orgName\": \"华南区\",\n"
+
" \"parentId\": 156,\n"
+
" \"tenantId\": 33,\n"
+
" \"isRoot\": 0\n"
+
" },\n"
+
" \"depth\": 1,\n"
+
" \"parentId\": 156,\n"
+
" \"label\": \"华南区\"\n"
+
" }\n"
+
" ],\n"
+
" \"id\": 156,\n"
+
" \"origin\": {\n"
+
" \"orgId\": 156,\n"
+
" \"orgName\": \"广汽本田\",\n"
+
" \"parentId\": 156,\n"
+
" \"tenantId\": 33,\n"
+
" \"isRoot\": 1\n"
+
" },\n"
+
" \"depth\": 0,\n"
+
" \"parentId\": 156,\n"
+
" \"label\": \"广汽本田\"\n"
+
" }\n"
+
" ]"
;
Gson
gson
=
new
GsonBuilder
().
serializeNulls
().
create
();
List
<
SimpleTreeModel
>
r3
=
gson
.
fromJson
(
json
,
new
TypeToken
<
List
<
SimpleTreeModel
>>()
{
}.
getType
());
System
.
out
.
println
(
r3
);
}
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment