Commit 7e104f4c by 杨林龙

Merge remote-tracking branch 'origin/master'

2 parents 3ebb408e dc5974c8
......@@ -12,6 +12,7 @@ public class SimpleTreeModel implements Serializable {
private Long id;
private String label;
private Long parentId;
private Integer type;
private boolean isRoot;
private List<SimpleTreeModel> children;
......
......@@ -26,6 +26,7 @@ import com.google.common.collect.Lists;
import com.google.gson.reflect.TypeToken;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -60,15 +61,21 @@ public class VehicleMonitorSevice {
public List<SimpleTreeModel> vTree(VehicleTreeSearch search) {
List<Organization> orgList = Lists.newArrayList();
if (search.getOrgId() == null) {
R<List<Organization>> listR = organizationService.getRootOrganizations();
orgList = listR.getDataList(new TypeToken<List<Organization>>() {
}.getType());
if (search.getTermType() != null && StringUtils.isNotBlank(search.getTerm())) {
} else {
R<List<Organization>> listR = organizationService.getSubOrganizations(search.getOrgId());
orgList = listR.getDataList(new TypeToken<List<Organization>>() {
}.getType());
if (search.getOrgId() == null) {
R<List<Organization>> listR = organizationService.getRootOrganizations();
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();
orgList.forEach(org -> {
SimpleTreeModel treeModel = new SimpleTreeModel();
......
package cn.com.glsx.test;
import cn.com.glsx.admin.modules.model.SimpleTreeModel;
import cn.com.glsx.usercenter.api.dto.response.User;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
......@@ -8,6 +9,8 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import java.util.List;
public class RestTest {
public static void main(String[] args) {
......@@ -15,7 +18,8 @@ public class RestTest {
// String url = "";
// R messageList = restTemplate.getForObject(url, R.class);
test();
// test();
testOrg();
}
public static void test() {
......@@ -32,4 +36,123 @@ public class RestTest {
}.getType());
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);
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!