2
13693261870
2022-09-16 653761a31dfeb50dd3d007e892d69c90bf0cdafc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
package com.landtool.lanbase.modules.res.controller;
 
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
 
import com.landtool.lanbase.common.utils.HttpUtils;
import com.landtool.lanbase.modules.res.service.impl.ResExtMapUrlServiceImpl;
import com.qiniu.util.Json;
import org.apache.shiro.SecurityUtils;
import org.apache.velocity.runtime.resource.util.StringResource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.landtool.lanbase.common.annotation.LogAction;
import com.landtool.lanbase.common.utils.Result;
import com.landtool.lanbase.config.SysTemPropertyConfig;
import com.landtool.lanbase.modules.api.utils.PageBean;
import com.landtool.lanbase.modules.res.entity.Res_Catalog;
import com.landtool.lanbase.modules.res.entity.Res_ExtBaseMap;
import com.landtool.lanbase.modules.res.entity.Res_ExtMapUrl;
import com.landtool.lanbase.modules.res.entity.Res_MainInfo;
import com.landtool.lanbase.modules.res.service.ResExtBaseMapService;
import com.landtool.lanbase.modules.res.service.ResExtMapUrlService;
import com.landtool.lanbase.modules.res.service.ResMainInfoService;
import com.landtool.lanbase.modules.sys.controller.AbstractController;
import com.landtool.lanbase.modules.sys.service.SysFieldvalueService;
 
/**
 * @Author: lizhao
 * @Date: 2018-03-05 13:57
 * @Description:3系统资源扩展(基础底图)控制器
 */
@Controller
@RequestMapping("/res")
public class ResExtBaseMapController extends AbstractController {
 
    @Autowired
    private ResExtBaseMapService resExtBaseMapService;
 
    @Autowired
    private ResExtMapUrlService resExtMapUrlService;
 
    @Autowired
    private SysTemPropertyConfig sysConfig;
 
    @Autowired
    private ResMainInfoService resMainInfoService;
 
    @Autowired
    private SysFieldvalueService FieldUtils;
    /**
     * 访问资源基础底图新增页面
     */
    @RequestMapping("/ResManage/ResRegister/ExtBaseMap")
    public String ExtBaseMap(Integer resMainInfoId, Model model) {
        List<Res_ExtMapUrl> resExtMapUrlList = resExtMapUrlService.selectByCondition(resMainInfoId);
        model.addAttribute("resExtMapUrlList", resExtMapUrlList);
 
        LinkedHashMap<String, String> typeandurlList = FieldUtils.getFieldListByKey("TypeAndURL");//获取地理参考模型列表
        
        LinkedHashMap<String, String> layerTypeList = FieldUtils.getFieldListByKey("LayerTypeList");
        String layerTypeListJson = "";
        for (Map.Entry<String, String> entry : layerTypeList.entrySet()) {
            if (layerTypeListJson != "")
                layerTypeListJson += ",";
            layerTypeListJson += "{key:'" + entry.getKey() + "',value:'" + entry.getValue() + "'}";
        }
        model.addAttribute("layerTypeListJson", "[" + layerTypeListJson + "]");
        model.addAttribute("layertypeList", layerTypeList);
 
        model.addAttribute("typeandurlList", typeandurlList);
 
        String typeandurlListJson = "";
        for (Map.Entry<String, String> entry : typeandurlList.entrySet()) {
            if (typeandurlListJson != "")
                typeandurlListJson += ",";
            typeandurlListJson += "{key:'" + entry.getKey() + "',value:'" + entry.getValue() + "'}";
        }
        model.addAttribute("typeandurlListJson", "[" + typeandurlListJson + "]");
 
        Res_ExtBaseMap resExtBaseMap = resExtBaseMapService.selectByPrimaryKey(resMainInfoId);
        if (resExtBaseMap != null) {
            if (resExtBaseMap.getRefmarkinfid() != null) {
                Res_MainInfo title = resMainInfoService.selectByPrimaryKey(resExtBaseMap.getRefmarkinfid());
                if (title != null) {
                    model.addAttribute("refmarkinfname", title.getTitle());
                }
            }
            Res_MainInfo res_mainInfo = resMainInfoService.selectByPrimaryKey(resMainInfoId);
            model.addAttribute("resMainInfo", res_mainInfo);
 
            String[] arr = new String[2];
            arr[0] = "null";
            arr[1] = "null";
            if(resExtBaseMap.getDisplaylev() != null) {
                arr = resExtBaseMap.getDisplaylev().split("-");
            }
            model.addAttribute("xianshibiliStart", (arr[0] == null || arr[0].trim().equals("null")) ? "" : arr[0]);
            model.addAttribute("xianshibiliEnd", (arr[1] == null || arr[1].trim().equals("null")) ? "" : arr[1]);
            model.addAttribute("resExtBaseMap", resExtBaseMap);
            model.addAttribute("resMainInfoId", resMainInfoId);
        } else {
            Res_ExtBaseMap resExtBaseMap1 = new Res_ExtBaseMap();
            Res_MainInfo res_mainInfo = new Res_MainInfo();
            model.addAttribute("resMainInfo", res_mainInfo);
            model.addAttribute("resExtBaseMap", resExtBaseMap1);
            model.addAttribute("xianshibiliStart", "");
            model.addAttribute("xianshibiliEnd", "");
        }
 
        LinkedHashMap<String, String> PublishSoftList = FieldUtils.getFieldListByKey("PublishSoft");// 获取发布平台字典列表
        LinkedHashMap<String, String> BaseMapTypeList = FieldUtils.getFieldListByKey("BaseMapType");// 获取底图类型字典列表
        LinkedHashMap<String, String> ImageAccuracyList = FieldUtils.getFieldListByKey("ImageAccuracy");// 获取影像精度字典列表
        model.addAttribute("PublishSoftList", PublishSoftList);
        model.addAttribute("BaseMapTypeList", BaseMapTypeList);
        model.addAttribute("ImageAccuracyList", ImageAccuracyList);
        model.addAttribute("esbHost",sysConfig.getEsbHost());
        model.addAttribute("esbUrl",sysConfig.getEsbUrl());
        if(SecurityUtils.getSubject().isPermitted("org_user_admin")) {
            //判断当前用户是否是管理员,是管理员或是未提交的资源才可以修改资源相关信息
            model.addAttribute("admin",true);
        }
        else {
            model.addAttribute("admin",false);
        }
        String oldesbids = resExtBaseMap != null ? resExtMapUrlService.queryRsbidsByResourceid(resMainInfoId):"";
        model.addAttribute("oldesbids",oldesbids);
        model.addAttribute("ipHost",sysConfig.getIpHost());
        model.addAttribute("gisHost",sysConfig.getGisHost());
        return "ResManage/ResRegister/ExtBaseMap";
    }
 
    /**
     * 访问关联标注图列表页面
     */
    @RequestMapping("/ResManage/ResRegister/GuanLianBiaoZhuTu")
    public String GuanLianBiaoZhuTu(Model model, Integer resourceid) {
        model.addAttribute("resourceid", resourceid);
        model.addAttribute("pubzyWebRoot", sysConfig.getPubzyWebRoot());
        return "/ResManage/ResRegister/GuanLianBiaoZhuTu";
    }
 
    /**
     * 查询关联标注图层列表 关联标注图层列表:底图类型为标注的资源且不是它自身的资源
     */
    @ResponseBody
    @RequestMapping("/resExtBaseMap/selectByBaseMapType")
    public Result selectByBaseMapType(Res_MainInfo resMainInfo, PageBean pageBean) {
        PageHelper.startPage(pageBean.getPage(), pageBean.getLimit());
        List<Res_MainInfo> list = resExtBaseMapService.selectByBaseMapType(resMainInfo);
        int countNums = (int) ((Page) list).getTotal();
        PageBean<Res_MainInfo> pageData = new PageBean<>(pageBean.getPage(), pageBean.getLimit(), countNums);
        pageData.setItems(list);
        StringBuilder rsb = new StringBuilder();
//        rsb.append("{'totalCount':'" + countNums);
//        rsb.append("','topics':[");
        List<Map<String, Object>> maps = new LinkedList<>();
        for (Integer i = 0; i < list.size(); i++) {
            Map<String, Object> map = new HashMap<>();
            map.put("resourceid", list.get(i).getResourceid());
            map.put("title", list.get(i).getTitle());
            maps.add(map);
 
//            if (i != 0) {
//                rsb.append(",");
//            }
//            rsb.append("{'resourceid':'" + list.get(i).getResourceid() + "'");// 资源id
//            rsb.append(",'title':'" + list.get(i).getTitle() + "'");// 资源名称
//            rsb.append("}");
        }
//        rsb.append("]}");
        return Result.ok().put("totalCount", countNums).put("topics", maps);
    }
 
    /**
     * 根据id 删除信息资源列表功能
     */
    @ResponseBody
    @RequestMapping("/resExtBaseMap/deleteByPrimaryKey")
    public int deleteByPrimaryKey(int resourceid) {
 
        return resExtBaseMapService.deleteByPrimaryKey(resourceid);
    }
 
    /**
     * 插入信息资源列表功能(所有元素不能为空)
     */
    @ResponseBody
    @RequestMapping("/resExtBaseMap/insert")
    public int insert(Res_ExtBaseMap record) {
        return resExtBaseMapService.insert(record);
    }
 
    /**
     * 插入信息资源列表功能(可以只填写必填字段)
     */
    @ResponseBody
    @RequestMapping("/resExtBaseMap/insertSelective")
    public int insertSelective(Res_ExtBaseMap record) {
        return resExtBaseMapService.insertSelective(record);
    }
 
    /**
     * 插入信息资源列表功能并且增加更新功能
     */
    @ResponseBody
    @RequestMapping("/resExtBaseMap/insertSelectiveAndUpdate")
    @LogAction("资源管理,资源发布,资源修改,修改|zy")
    public String insertSelectiveAndUpdate(Res_ExtBaseMap record, Res_MainInfo resMainInfo, Integer resourceid, String xianshibiliStart, String xianshibiliEnd, String extMapUrlStr) {
        extMapUrlStr+="servername="+resMainInfo.getTitle();
        resExtMapUrlService.deleteAndInsertMapUrlArray(record.getResourceid(),extMapUrlStr);
        // 判断 id是否存在 存在就更新 不存在就 添加
        Res_ExtBaseMap resExtBaseMap = resExtBaseMapService.selectByPrimaryKey(resourceid);
        if(!xianshibiliStart.isEmpty() && !xianshibiliEnd.isEmpty()) {
            record.setDisplaylev(xianshibiliStart + "-" + xianshibiliEnd);
        }
        record.setResourceid(resourceid);
 
        if (resExtBaseMap == null) {
            // 添加
            if (!record.getBasemaptype().equals("影像")) { // 判断底图类型是否是影像,不是则令影像精度为空
                record.setImageaccuracy(null);
            }
            //alter: Xxx 处理资源注册向导新增时没有ESB代理
            int mainInfoResult = 0;
            if(resMainInfo.getEspproxy() != null) {
                mainInfoResult = resMainInfoService.updateByPrimaryKeySelective(resMainInfo);
            } else {
                mainInfoResult = 1;
            }
            int baseMapresult = resExtBaseMapService.insertSelective(record);
//            // TODO:更改服务地址为代理后的
//            String proxyUrl=getProxyurl(record,resourceid); //代理后的地址
//            String serverUrl = record.getServerurl();//服务地址
//            Res_ExtMapUrl res_extMapUrl = new Res_ExtMapUrl();
//            res_extMapUrl.setOldserverurl(serverUrl);
//            res_extMapUrl.setServerurl(proxyUrl);
//            resExtMapUrlService.insertSelective(res_extMapUrl);
            int result;
            if (mainInfoResult == 1 && baseMapresult == 1) {
                result = 1;
            } else {
                result = 0;
            }
            return "{'result':'" + result + "','ziyuanId':'" + resourceid + "'}";
        } else {
            // 更新
            if (!record.getBasemaptype().equals("影像")) { // 判断底图类型是否是影像,不是则令影像精度为空
                record.setImageaccuracy(null);
            }
            int mainInfoResult = 0;
            if(resMainInfo.getEspproxy() != null) {
                mainInfoResult = resMainInfoService.updateByPrimaryKeySelective(resMainInfo);
            } else {
                mainInfoResult = 1;
            }
            int baseMapresult = resExtBaseMapService.updateByPrimaryKey(record);
            int result;
            if (mainInfoResult == 1 && baseMapresult == 1) {
                result = 1;
            } else {
                result = 0;
            }
            return "{'result':'" + result + "','ziyuanId':'" + resourceid + "'}";
        }
    }
 
 
 
    /**
     * 根据id查询信息资源列表
     */
    @ResponseBody
    @RequestMapping("/resExtBaseMap/selectByPrimaryKey")
    public Res_ExtBaseMap selectByPrimaryKey(Integer resourceid) {
        return resExtBaseMapService.selectByPrimaryKey(resourceid);
    }
 
    /**
     * 根据id更新信息资源列表(更新部分数据)
     */
    @ResponseBody
    @RequestMapping("/resExtBaseMap/updateByPrimaryKeySelective")
    public int updateByPrimaryKeySelective(Res_ExtBaseMap record) {
        return resExtBaseMapService.updateByPrimaryKeySelective(record);
    }
 
    /**
     * 根据id更新信息资源列表(更新所有数据)
     */
    @ResponseBody
    @RequestMapping("/resExtBaseMap/updateByPrimaryKey")
    public int updateByPrimaryKey(Res_ExtBaseMap record) {
        return resExtBaseMapService.updateByPrimaryKey(record);
    }
 
    /**
     * 获取地图相关信息(专题地图地图设置)
     */
    @RequestMapping("/ResManage/ResRegister/BaseMapSelect")
    public String BaseMapSelect(Model model,String isNotOnlyBaseMap) {
        HashMap<String, String> DataSourceList = FieldUtils.getDataSourceList();// 获取数据来源列表
        model.addAttribute("datasourcelist", DataSourceList);
        model.addAttribute("pubzyWebRoot", sysConfig.getPubzyWebRoot());
        model.addAttribute("systemName", sysConfig.getAppFullName());
        model.addAttribute("isNotOnlyBaseMap",isNotOnlyBaseMap);
        return "ResManage/ResRegister/BaseMapSelect";
    }
 
    // 查询列表地图设置
    @ResponseBody
    @RequestMapping("/ResManage/ResRegister/selectBaseMapJoinMainInfo")
    public Result selectBaseMapJoinMainInfo(Res_MainInfo resMainInfo, PageBean pageBean) {
        PageHelper.startPage(pageBean.getPage(), pageBean.getLimit());
        List<Res_MainInfo> list = resExtBaseMapService.selectBaseMapJoinMainInfo(resMainInfo);
        int countNums = (int) ((Page) list).getTotal();
        PageBean<Res_MainInfo> pageData = new PageBean<>(pageBean.getPage(), pageBean.getLimit(), countNums);
        HashMap<String, String> DataSourceList = FieldUtils.getDataSourceList();// 获取数据来源列表
        pageData.setItems(list);
        StringBuilder rsb = new StringBuilder();
        String laiyuan = "";
        rsb.append("{'totalCount':'" + countNums);
        rsb.append("','topics':[");
 
        List<Map<String, Object>> maps = new LinkedList<>();
        for (Integer i = 0; i < list.size(); i++) {
            Map<String, Object> map = new HashMap<>();
            map.put("resourceid", list.get(i).getResourceid());
            map.put("title", list.get(i).getTitle());
            map.put("datasources", list.get(i).getDatasources());
            maps.add(map);
 
//            if (i != 0) {
//                rsb.append(",");
//            }
//            rsb.append("{'resourceid':'" + list.get(i).getResourceid() + "'");// 资源id
//            rsb.append(",'title':'" + list.get(i).getTitle() + "'");// 资源名称
////            laiyuan = DataSourceList.get(list.get(i).getDatasources());
//            rsb.append(",'datasources':'" + list.get(i).getDatasources() + "'");
//            rsb.append("}");
        }
//        rsb.append("]}");
        return Result.ok().put("totalCount", countNums).put("topics", maps);
    }
 
    /**
     * 自动补全输入首字母查询
     * @param keyWord
     * @return
     */
    @ResponseBody
    @GetMapping("/resExtBaseMap/findPinyinByKeyWord")
    public String[] findpinyinByKeyWord(@RequestParam(name = "keyWord") String keyWord,String isNotOnlyBaseMap){
        keyWord = URLDecoder.decode(keyWord);
        Res_MainInfo resMainInfo = new Res_MainInfo();
        Map<String, Object> map = new HashMap<>();
        map.put("keyWord", keyWord);
        map.put("isNotOnlyBaseMap", isNotOnlyBaseMap);
        List<Res_MainInfo> list = null;
        list = resExtBaseMapService.selectBaseMapJoinMainInfoTree(map);
        String[] arr = new String[list.size()];
        for (int i =0;i<list.size();i++) {
            String title = list.get(i).getTitle();
            arr[i] = title;
        }
        return arr;
    }
 
 
    @RequestMapping("/ResManage/ResRegister/selectBaseMapJoinMainInfoTree")
    @ResponseBody
    public String selectBaseMapJoinMainInfoTree(Res_MainInfo resMainInfo,String parentid,String isNotOnlyBaseMap) {
        StringBuilder sb = new StringBuilder();
        Map<String, Object> map = new HashMap<>();
        map.put("title", resMainInfo.getTitle());
        map.put("parentid", parentid);
        map.put("isNotOnlyBaseMap", isNotOnlyBaseMap);
        List<Res_Catalog> resCatalogs = resExtBaseMapService.selectBaseMapJoinMainInfoNode(map);
 
        // 循环构造子目录节点
        List<Map<String, Object>> maps = new LinkedList<>();
        for (Res_Catalog resCatalog : resCatalogs) {
            Map<String, Object> nodemap = new HashMap<>();
            nodemap.put("title", resMainInfo.getTitle());
            nodemap.put("parentid", resCatalog.getCatlogid());
            nodemap.put("isNotOnlyBaseMap", isNotOnlyBaseMap);
            int childCount = resExtBaseMapService.selectBaseMapJoinMainInfoTree(nodemap).size();
 
            Map<String, Object> catlogmap = new HashMap<>();
            if(childCount > 0) {
                catlogmap.put("id", resCatalog.getCatlogid());
                catlogmap.put("name", resCatalog.getTitle());
                catlogmap.put("title", resCatalog.getTitle());
                catlogmap.put("isParent", true);
                catlogmap.put("iconOpen", "/image/classicons/folderOpen.png");
                catlogmap.put("iconClose", "/image/classicons/folder.png");
                maps.add(catlogmap);
 
//                if (!"".equals(sb.toString())) {
//                    sb.append(',');
//                }
//                sb.append("{id: " + resCatalog.getCatlogid() + ",name:'" + resCatalog.getTitle() + "',title:'" + resCatalog.getTitle() + "',isParent: true,iconOpen:'/image/classicons/folderOpen.png',iconClose:'/image/classicons/folder.png'}");
            }
            else {
                if(!getTreeNode(nodemap).isEmpty()) {
                    catlogmap.put("id", resCatalog.getCatlogid());
                    catlogmap.put("name", resCatalog.getTitle());
                    catlogmap.put("title", resCatalog.getTitle());
                    catlogmap.put("isParent", true);
                    catlogmap.put("iconOpen", "/image/classicons/folderOpen.png");
                    catlogmap.put("iconClose", "/image/classicons/folder.png");
                    maps.add(catlogmap);
 
//                    if (!"".equals(sb.toString())) {
//                        sb.append(',');
//                    }
//                    sb.append("{id: " + resCatalog.getCatlogid() + ",name:'" + resCatalog.getTitle() + "',title:'" + resCatalog.getTitle() + "',isParent: true,iconOpen:'/image/classicons/folderOpen.png',iconClose:'/image/classicons/folder.png'}");
//                    sb.append(getTreeNode(nodemap));
                }
            }
 
        }
 
        List<Res_MainInfo> list = resExtBaseMapService.selectBaseMapJoinMainInfoTree(map);
        HashMap<String, String> DataSourceList = FieldUtils.getDataSourceList();// 获取数据来源列表
        // 循环构造资源节点
        for (Res_MainInfo resMainInfo1 : list) {
            Map<String, Object> catlogmap  = new HashMap<>();
            catlogmap.put("id", "ZiYuan_" + resMainInfo1.getResourceid());
            catlogmap.put("name", resMainInfo1.getTitle());
            catlogmap.put("title", resMainInfo1.getTitle());
            catlogmap.put("isParent", false);
            catlogmap.put("icon", "/image/classicons/KJ_JCDT.png");
            maps.add(catlogmap);
 
//            if (!"".equals(sb.toString())) {
//                sb.append(',');
//            }
//            sb.append("{id: 'ZiYuan_" + resMainInfo1.getResourceid() + "',name:'" + resMainInfo1.getTitle()
//                    + "', title: '"
//                    + resMainInfo1.getDatasources() + "',isParent:false,icon:'/image/classicons/KJ_JCDT.png'}");
        }
//        System.out.println(sb.toString());
        return JSON.toJSONString(maps, SerializerFeature.WriteMapNullValue);
    }
 
    public String getTreeNode(Map<String,Object> map) {
        StringBuilder sb = new StringBuilder();
        List<Res_Catalog> resCatalogs = resExtBaseMapService.selectBaseMapJoinMainInfoNode(map);
        // 循环构造子目录节点
        for (Res_Catalog resCatalog : resCatalogs) {
            Map<String, Object> nodemap = new HashMap<>();
            nodemap = map;
            nodemap.put("parentid", resCatalog.getCatlogid());
            nodemap.put("isNotOnlyBaseMap", map.get("isNotOnlyBaseMap"));
            int childCount = resExtBaseMapService.selectBaseMapJoinMainInfoTree(nodemap).size();
            if(childCount > 0) {
                if (!"".equals(sb.toString())) {
                    sb.append(',');
                }
                sb.append("{id: " + resCatalog.getCatlogid() + ",name:'" + resCatalog.getTitle() + "',title:'" + resCatalog.getTitle() + "',isParent: true,iconOpen:'/image/classicons/folderOpen.png',iconClose:'/image/classicons/folder.png'}"); //alter ykm 2018/12/9
            }
            else {
                if(!getTreeNode(nodemap).isEmpty()) {
                    if (!"".equals(sb.toString())) {
                        sb.append(',');
                    }
                    sb.append("{id: " + resCatalog.getCatlogid() + ",name:'" + resCatalog.getTitle() + "',title:'" + resCatalog.getTitle() + "',isParent: true,icon:'/image/classicons/defaulticon.png'}");//update:dsh(2018/12/05)
//                    sb.append(getTreeNode(nodemap));
                }
            }
        }
        System.out.println(sb.toString());
        return sb.toString();
    }
 
 
    /**
     * 自动补全输入首字母查询
     * @param keyWord
     * @return
     */
    @ResponseBody
    @GetMapping("/resExtBaseMap/getBaseMapForBZTree/findPinyinByKeyWord")
    public String[] getBaseMapForBZTreeByKeyWord(@RequestParam(name = "keyWord") String keyWord,Integer resourceid){
        keyWord = URLDecoder.decode(keyWord);
        Map<String, Object> map = new HashMap<>();
        map.put("keyWord", keyWord);
        map.put("resourceid", resourceid);
        List<Res_MainInfo> list = null;
        list = resExtBaseMapService.getBaseMapForBZTree(map);
        String[] arr = new String[list.size()];
        for (int i =0;i<list.size();i++) {
            String title = list.get(i).getTitle();
            arr[i] = title;
        }
        return arr;
    }
 
 
    @RequestMapping("/ResManage/ResRegister/getBaseMapForBZTree")
    @ResponseBody
    public String getBaseMapForBZTree(Res_MainInfo resMainInfo,String parentid) {
        StringBuilder sb = new StringBuilder();
        Map<String, Object> map = new HashMap<>();
        map.put("title", resMainInfo.getTitle());
        map.put("parentid", parentid);
        map.put("resourceid", resMainInfo.getResourceid());
        List<Res_Catalog> resCatalogs = resExtBaseMapService.getBaseMapForBZNode(map);
 
        // 循环构造子目录节点
        List<Map<String, Object>> maps = new LinkedList<>();
        for (Res_Catalog resCatalog : resCatalogs) {
            Map<String, Object> nodemap = new HashMap<>();
            nodemap.put("title", resMainInfo.getTitle());
            nodemap.put("parentid", resCatalog.getCatlogid());
            nodemap.put("resourceid", resMainInfo.getResourceid());
            int childCount = resExtBaseMapService.getBaseMapForBZTree(nodemap).size();
 
            if(childCount > 0) {
                Map<String, Object> catlogmap = new HashMap<>();
                catlogmap.put("id", resCatalog.getCatlogid());
                catlogmap.put("name", resCatalog.getTitle());
                catlogmap.put("title", resCatalog.getTitle());
                catlogmap.put("isParent", true);
                catlogmap.put("iconOpen", "/image/classicons/folderOpen.png");
                catlogmap.put("iconClose", "/image/classicons/folder.png");
                maps.add(catlogmap);
//
//                if (!"".equals(sb.toString())) {
//                    sb.append(',');
//                }
//                sb.append("{id: " + resCatalog.getCatlogid() + ",name:'" + resCatalog.getTitle() + "',title:'" + resCatalog.getTitle() + "',isParent: true,iconOpen:'/image/classicons/folderOpen.png',iconClose:'/image/classicons/folder.png'}");
            }
            else {
                if(!getBaseMapForBZTreeNode(nodemap).isEmpty()) {
                    Map<String, Object> catlogmap = new HashMap<>();
                    catlogmap.put("id", resCatalog.getCatlogid());
                    catlogmap.put("name", resCatalog.getTitle());
                    catlogmap.put("title", resCatalog.getTitle());
                    catlogmap.put("isParent", true);
                    catlogmap.put("iconOpen", "/image/classicons/folderOpen.png");
                    catlogmap.put("iconClose", "/image/classicons/folder.png");
                    maps.add(catlogmap);
 
 
//                    if (!"".equals(sb.toString())) {
//                        sb.append(',');
//                    }
//                    sb.append("{id: " + resCatalog.getCatlogid() + ",name:'" + resCatalog.getTitle() + "',title:'" + resCatalog.getTitle() + "',isParent: true,iconOpen:'/image/classicons/folderOpen.png',iconClose:'/image/classicons/folder.png'}");
//                    sb.append(getBaseMapForBZTreeNode(nodemap));
                }
            }
        }
 
        List<Res_MainInfo> list = resExtBaseMapService.getBaseMapForBZTree(map);
        // 循环构造资源节点
        for (Res_MainInfo resMainInfo1 : list) {
            Map<String, Object> catlogmap  = new HashMap<>();
            catlogmap.put("id", "ZiYuan_" + resMainInfo1.getResourceid());
            catlogmap.put("name", resMainInfo1.getTitle());
            catlogmap.put("title", resMainInfo1.getTitle());
            catlogmap.put("isParent", false);
            catlogmap.put("icon", "/image/classicons/KJ_JCDT.png");
            maps.add(catlogmap);
 
//            if (!"".equals(sb.toString())) {
//                sb.append(',');
//            }
//            sb.append("{id: 'ZiYuan_" + resMainInfo1.getResourceid() + "',name:'" + resMainInfo1.getTitle()
//                    + "', title: '"
//                    + resMainInfo1.getDatasources() + "',isParent:false,icon:'/image/classicons/KJ_JCDT.png'}");
        }
//        System.out.println(sb.toString());
        return JSON.toJSONString(maps, SerializerFeature.WriteMapNullValue);
    }
 
    public String getBaseMapForBZTreeNode(Map<String,Object> map) {
        StringBuilder sb = new StringBuilder();
        List<Res_Catalog> resCatalogs = resExtBaseMapService.getBaseMapForBZNode(map);
        // 循环构造子目录节点
        for (Res_Catalog resCatalog : resCatalogs) {
            Map<String, Object> nodemap = new HashMap<>();
            nodemap = map;
            nodemap.put("parentid", resCatalog.getCatlogid());
            int childCount = resExtBaseMapService.getBaseMapForBZTree(nodemap).size();
            if(childCount > 0) {
                if (!"".equals(sb.toString())) {
                    sb.append(',');
                }
                sb.append("{id: " + resCatalog.getCatlogid() + ",name:'" + resCatalog.getTitle() + "',title:'" + resCatalog.getTitle() + "',isParent: true}");
            }
            else {
                if(!getBaseMapForBZTreeNode(nodemap).isEmpty()) {
                    if (!"".equals(sb.toString())) {
                        sb.append(',');
                    }
                    sb.append("{id: " + resCatalog.getCatlogid() + ",name:'" + resCatalog.getTitle() + "',title:'" + resCatalog.getTitle() + "',isParent: true,icon:'/image/classicons/defaulticon.png'}");
                    //sb.append(getBaseMapForBZTreeNode(nodemap));
                }
            }
        }
        System.out.println(sb.toString());
        return sb.toString();
    }
 
    public static void main(String[] args) {
//        Res_ExtBaseMap record = new Res_ExtBaseMap();
//        record.setIsPublic(1);
//        record.setResourceid(15);
//        record.setServerurl("http://192.168.20.106:8066/test");
//        String proxyurl = getProxyurl(record, 15);
//        System.out.println("proxyurl = " + proxyurl);
    }
}