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
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
package com.landtool.lanbase.modules.api.controller.MapPortal;
 
import java.io.File;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
 
import javax.servlet.http.HttpServletRequest;
 
import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonObject;
import com.landtool.lanbase.common.utils.HttpUtils;
import com.qiniu.util.Json;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
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.landtool.lanbase.common.map.EsbToken;
import com.landtool.lanbase.common.utils.HttpOperateUtils;
import com.landtool.lanbase.config.SysTemPropertyConfig;
import com.landtool.lanbase.modules.org.entity.OrgUser;
import com.landtool.lanbase.modules.org.service.OrgUserService;
import com.landtool.lanbase.modules.res.entity.Res_BookMarks;
import com.landtool.lanbase.modules.res.entity.Res_BusinessRef;
import com.landtool.lanbase.modules.res.entity.Res_DiyLayerInfo;
import com.landtool.lanbase.modules.res.entity.Res_ExtBaseMap;
import com.landtool.lanbase.modules.res.entity.Res_ExtBusinessLayer;
import com.landtool.lanbase.modules.res.entity.Res_ExtFileSource;
import com.landtool.lanbase.modules.res.entity.Res_ExtIntegrate;
import com.landtool.lanbase.modules.res.entity.Res_ExtMapUrl;
import com.landtool.lanbase.modules.res.entity.Res_ExtSpaceServer;
import com.landtool.lanbase.modules.res.entity.Res_ExtThemeMap;
import com.landtool.lanbase.modules.res.entity.Res_MainInfo;
import com.landtool.lanbase.modules.res.entity.Res_QueryAround;
import com.landtool.lanbase.modules.res.entity.Res_SpacesParam;
import com.landtool.lanbase.modules.res.entity.Res_SymbolLibrary;
import com.landtool.lanbase.modules.res.entity.Res_User_LayerExtent;
import com.landtool.lanbase.modules.res.entity.UserDefined.UserDef_BaseMap;
import com.landtool.lanbase.modules.res.entity.UserDefined.UserDef_SpaceServer;
import com.landtool.lanbase.modules.res.entity.ViewModels.LayerObject;
import com.landtool.lanbase.modules.res.service.ResBookMarksService;
import com.landtool.lanbase.modules.res.service.ResBusinessRefService;
import com.landtool.lanbase.modules.res.service.ResDiyLayerInfoService;
import com.landtool.lanbase.modules.res.service.ResExtBaseMapService;
import com.landtool.lanbase.modules.res.service.ResExtBusinessLayerService;
import com.landtool.lanbase.modules.res.service.ResExtFileSourceService;
import com.landtool.lanbase.modules.res.service.ResExtIntegrateService;
import com.landtool.lanbase.modules.res.service.ResExtMapUrlService;
import com.landtool.lanbase.modules.res.service.ResExtSpaceServerService;
import com.landtool.lanbase.modules.res.service.ResExtThemeMapService;
import com.landtool.lanbase.modules.res.service.ResMainInfoService;
import com.landtool.lanbase.modules.res.service.ResQueryAroundService;
import com.landtool.lanbase.modules.res.service.ResSpacesParamService;
import com.landtool.lanbase.modules.res.service.ResSymbolLibraryService;
import com.landtool.lanbase.modules.res.service.ResUserLayerExtentService;
import com.landtool.lanbase.modules.res.service.ZhuanTiZhiTuService;
 
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
 
/**
 * @author 刘小波
 * @Description: 前端地图展示通用接口,获取底图、获取资源协议或自定义风格信息
 * @date 2018-05-26
 */
 
@Controller
@RequestMapping("/api/mapcommon/")
@Api(value = "", tags = {"前端地图展示通用接口"})
public class MapCommonController {
    @Autowired
    private ResExtBaseMapService resExtBaseMapService;
    
    @Autowired
    private ResExtMapUrlService resExtMapUrlService;
    
    @Autowired
    private ZhuanTiZhiTuService zhuanTiZhiTuService;
    
    @Autowired
    private OrgUserService orgUserService;
    
    @Autowired
    private SysTemPropertyConfig sysConfig;
    
    @Autowired
    private ResDiyLayerInfoService resDiyLayerInfoService;
    
    @Autowired
    private ResBusinessRefService resBusinessRefService;
    
    @Autowired
    private ResQueryAroundService resQueryAroundService;
    
    @Autowired
    private ResExtThemeMapService resExtThemeMapService;
    
    @Autowired
    private ResExtIntegrateService resExtIntegrateService;
    
    @Autowired
    private ResBookMarksService resBookMarksService;
    
    @Autowired
    private ResExtBusinessLayerService resExtBusinessLayerService;
    
    @Autowired
    private ResMainInfoService resMainInfoService;
    
    @Autowired
    private ResSymbolLibraryService resSymbolLibraryService;
    
    @Autowired
    private ResExtFileSourceService resExtFileSourceService;
    
    @Autowired
    private ResExtSpaceServerService resExtSpaceServerService;
    
    @Autowired
    private ResSpacesParamService resSpacesParamService;
    
    @Autowired
    private ResUserLayerExtentService resUserLayerExtentService;
    
    /**
     * 专题制图 - 底图切换 -- 获取基础底图列表
     */
    @ResponseBody
    @GetMapping("/basemaplist")
    @ApiOperation(value = "查询已审核的基础底图信息列表", notes = "")
    public List<Map<String, Object>> getBaseMapList(Long userid, String type, Boolean supportDynamic, HttpServletRequest request) {
        List<UserDef_BaseMap> list = zhuanTiZhiTuService.getBaseMapList(type, supportDynamic);
        StringBuilder str = new StringBuilder();
        str.append("[");
        List<Map<String, Object>> maps = new LinkedList<>();
        for (int i = 0; i < list.size(); i++) {
            //查询是否是专题地图,是专题地图则获取相关子图层ID
            String subzyids = "";
            boolean isPubzy = false;
            if (list.get(i).getSharprotocol().equals("完全公开")) {
                isPubzy = true;
            }
            
            Map<String, Object> map = new HashMap<>();
            map.put("resourceId", list.get(i).getResourceid());
            map.put("title", list.get(i).getTitle());
            map.put("imgurl", list.get(i).getImgurl());
            map.put("serverUrl", EsbToken.getEsbUrl(list.get(i).getServerurl(), userid.intValue(), request.getRemoteAddr(), list.get(i).getResourceid(), list.get(i).getEspproxy(), sysConfig, subzyids, isPubzy, list.get(i).getToken(), false));
            
            if (list.get(i).getRefmarkinfid() != null) { //判断关联标注图资源ID是否为空
                Res_ExtBaseMap resExtBaseMap = resExtBaseMapService.selectByPrimaryKey(list.get(i).getRefmarkinfid());
                if (resExtBaseMap != null) {
                    Res_MainInfo resMainInfo = resMainInfoService.selectByPrimaryKey(list.get(i).getRefmarkinfid());
                    
                    Map<String, Object> refmap = new HashMap<>();
                    refmap.put("resourceId", resExtBaseMap.getResourceid());
                    refmap.put("title", resMainInfo.getTitle());
                    refmap.put("publishsoft", resExtBaseMap.getPublishsoft());
                    
                    Res_ExtMapUrl resExtMapUrl = resExtMapUrlService.queryFirstOrderByResId(resExtBaseMap.getResourceid());// 获取资源支持协议与地址
                    if (resExtMapUrl != null) {
                        refmap.put("serverUrl", EsbToken.getEsbUrl(resExtMapUrl.getServerurl(), userid.intValue(), request.getRemoteAddr(), resExtBaseMap.getResourceid(), resMainInfo.getEspproxy(), sysConfig, subzyids, isPubzy, list.get(i).getToken(), false));
                    } else {
                        refmap.put("serverUrl", null);
                    }
                    map.put("AnnoLayer", refmap);
                } else {
                    map.put("AnnoLayer", null);
                }
            } else {
                map.put("AnnoLayer", null);
            }
            maps.add(map);
        }
        str.append("]");
        return maps;
    }
    
    /**
     * 地图对比 -- 获取基础底图列表
     */
    @ResponseBody
    @GetMapping("/incisionMap/basemaplist")
    @ApiOperation(value = "获取地图对比基础底图列表", notes = "")
    public String getIncisionMapBaseList(Long userid, HttpServletRequest request) {
        String[] typeList = new String[]{"矢量", "低精", "高精", "其它"};
        StringBuilder sb = new StringBuilder();
        List<Map<String, Object>> maps = new LinkedList<>();
        for (int i = 0; i < typeList.length; i++) {
            List<UserDef_BaseMap> list = zhuanTiZhiTuService.getBaseMapList(typeList[i], false);
            
            Map<String, Object> map = new HashMap<>();
            map.put("name", typeList[i]);
            map.put("nocheck", true);
            
            if (i > 0) sb.append(",");
            sb.append("{name: '" + typeList[i] + "', nocheck: true,children:[");
            List<Map<String, Object>> child = new LinkedList<>();
            for (int j = 0; j < list.size(); j++) {
                Map<String, Object> newmap = new HashMap<>();
                newmap.put("name", list.get(j).getTitle());
                newmap.put("id", list.get(j).getResourceid());
                newmap.put("checked", false);
                child.add(newmap);
            }
            map.put("children", child);
            maps.add(map);
        }
        
        return JSON.toJSONString(maps, SerializerFeature.WriteMapNullValue);
    }
    
    /**
     * @Description: 获取资源服务地址信息
     * @Author: xiaoxuan.xie
     * @Date: 09:30 2018/3/31
     * @return: String
     * @see Res_MainInfo
     */
    @ResponseBody
    @GetMapping(path = {"layerinfo/{resourceid}/{userid}", "layerinfo/{resourceid}/{userid}/{diyid}"})
    @ApiOperation(value = "获取资源服务地址信息", notes = "")
    public String GetLayerObject(@ApiParam(name = "resourceid", value = "资源Id", required = true) @PathVariable(name = "resourceid") int resourceid, @ApiParam(name = "userid", value = "用户Id", required = true) @PathVariable(name = "userid") Integer userid, @ApiParam(name = "diyid", value = "自定义风格Id") @PathVariable(name = "diyid", required = false) Integer diyid, HttpServletRequest request) throws Exception {
        Map<String, Object> maps = new HashMap<>();
        String Json = "";
        OrgUser orgUser = orgUserService.queryObject(Long.parseLong(userid.toString()));
        
        if (resourceid > 0) {
            Res_MainInfo resMainInfo = resMainInfoService.selectByPrimaryKey(resourceid);// 获取资源主表信息
            if (resMainInfo != null) {
                String resourceType = resMainInfo.getResourceclass();// 获取资源类型
                if (resourceType == null) resourceType = "";
                LayerObject layer = null;
                switch (resourceType) {
                    case "KJ_YWTC":
                    case "KJ_JCDT":
                        String username = request.getRemoteUser();
                        Boolean GuanLian = false;//业务关联
                        Boolean ZhouBian = false;//周边查询
                        if (resourceType.equals("KJ_YWTC")) {
                            Res_BusinessRef res_businessRef = new Res_BusinessRef();
                            res_businessRef.setResourceid(resourceid);
                            List<Res_BusinessRef> resBusinessRefList = resBusinessRefService.selectResBusinesssRef(res_businessRef);//获取业务图层关联分析信息
                            if (resBusinessRefList.size() > 0) GuanLian = true;
                            List<Res_QueryAround> resQueryAroundList = resQueryAroundService.getZhouBianList(resourceid);//获取资源周边查询列表
                            if (resQueryAroundList.size() > 0) ZhouBian = true;
                        }
                        // 获取用户定义JSON
                        Res_DiyLayerInfo resDiyLayerInfo;
                        if (diyid != null && diyid > 0) {
                            resDiyLayerInfo = resDiyLayerInfoService.getById(diyid);//获取自定义风格信息
                        } else {
                            resDiyLayerInfo = resDiyLayerInfoService.queryUserObject(userid, resourceid, null);
                        }
                        if (resDiyLayerInfo != null) {
                            maps.put("diyId", resDiyLayerInfo.getDiyid());
                            maps.put("resourceId", resourceid);
                            maps.put("title", resMainInfo.getTitle());
                            maps.put("desurl", resMainInfo.getDesurl());
                            maps.put("content", JSON.parseObject(resDiyLayerInfo.getContent()));
                            maps.put("resourceclass", resourceType);
                            maps.put("GuanLian", GuanLian);
                            maps.put("ZhouBian", ZhouBian);
                        } else {
                            // 获取管理员定义JSON
                            resDiyLayerInfo = resDiyLayerInfoService.queryUserObject(userid, resourceid, 1);
                            if (resDiyLayerInfo != null) {
                                maps.put("diyId", resDiyLayerInfo.getDiyid());
                                maps.put("resourceId", resourceid);
                                maps.put("title", resMainInfo.getTitle());
                                maps.put("desurl", resMainInfo.getDesurl());
                                maps.put("content", JSON.parseObject(resDiyLayerInfo.getContent()));
                                maps.put("resourceclass", resourceType);
                                maps.put("GuanLian", GuanLian);
                                maps.put("ZhouBian", ZhouBian);
                            } else {
                                // 获取资源支持协议与地址
                                Res_ExtMapUrl resExtMapUrl = resExtMapUrlService.queryFirstOrderByResId(resourceid);
                                //查询是否是专题地图,是专题地图则获取相关子图层ID
                                //Res_ExtThemeMap resExtThemeMap = resExtThemeMapService.selectByPrimaryKey(resourceid);
                                String subzyids = "";
                                boolean isPubzy = false;
                                Res_MainInfo resMainInfo1 = resMainInfoService.selectByPrimaryKey(resourceid);
                                if (resMainInfo1 != null && resMainInfo1.getSharprotocol().equals("完全公开")) {
                                    isPubzy = true;
                                }
                                if (resExtMapUrl != null) {
                                    maps.put("resourceId", resourceid);
                                    maps.put("title", resMainInfo.getTitle());
                                    maps.put("desurl", resMainInfo.getDesurl());
                                    maps.put("typeandurl", resExtMapUrl.getTypeandurl());
                                    maps.put("serverUrl", EsbToken.getEsbUrl(resExtMapUrl.getServerurl(), orgUser.getUserid().intValue(), request.getRemoteAddr(), resourceid, resMainInfo.getEspproxy(), sysConfig, subzyids, isPubzy, resMainInfo.getToken(), false));
                                    maps.put("resourceclass", resourceType);
                                    maps.put("GuanLian", GuanLian);
                                    maps.put("ZhouBian", ZhouBian);
                                } else {
                                    maps.put("resourceId", resourceid);
                                    maps.put("title", resMainInfo.getTitle());
                                    maps.put("desurl", resMainInfo.getDesurl());
                                    maps.put("typeandurl", "");
                                    maps.put("serverUrl", "");
                                    maps.put("resourceclass", resourceType);
                                    maps.put("GuanLian", GuanLian);
                                    maps.put("ZhouBian", ZhouBian);
                                }
                            }
                        }
                        if (resourceType.equals("KJ_JCDT")) {
                            Res_ExtBaseMap resExtBaseMap = resExtBaseMapService.selectByPrimaryKey(resourceid);//获取基础底图拓展信息
                            if (resExtBaseMap.getRefmarkinfid() != null) {
                                Res_MainInfo AnnoMainInfo = resMainInfoService.selectByPrimaryKey(resExtBaseMap.getRefmarkinfid());
                                Res_ExtBaseMap AnnoLayer = resExtBaseMapService.selectByPrimaryKey(resExtBaseMap.getRefmarkinfid());
                                if (AnnoLayer != null) {
                                    Res_ExtThemeMap resExtThemeMap = resExtThemeMapService.selectByPrimaryKey(resourceid);
                                    String subzyids = "";
                                    if (resExtThemeMap != null) {
                                        subzyids = resExtThemeMap.getSublayerset();
                                    }
                                    boolean isPubzy = false;
                                    Res_MainInfo resMainInfo1 = resMainInfoService.selectByPrimaryKey(resourceid);
                                    if (resMainInfo1 != null && resMainInfo1.getSharprotocol().equals("完全公开")) {
                                        isPubzy = true;
                                    }
                                    Map<String, Object> AnnoLayerMap = new HashMap<>();
                                    AnnoLayerMap.put("resourceId", AnnoLayer.getResourceid());
                                    AnnoLayerMap.put("title", AnnoMainInfo.getTitle());
                                    AnnoLayerMap.put("publishsoft", AnnoLayer.getPublishsoft());
                                    Res_ExtMapUrl resExtMapUrl = resExtMapUrlService.queryFirstOrderByResId(AnnoLayer.getResourceid());// 获取资源支持协议与地址
                                    if (resExtMapUrl != null) {
                                        AnnoLayerMap.put("serverUrl", EsbToken.getEsbUrl(resExtMapUrl.getServerurl(), orgUser.getUserid().intValue(), request.getRemoteAddr(), AnnoLayer.getResourceid(), AnnoMainInfo.getEspproxy(), sysConfig, subzyids, isPubzy, AnnoMainInfo.getToken(), false));
                                    } else {
                                        AnnoLayerMap.put("serverUrl", null);
                                    }
                                    maps.put("AnnoLayer", AnnoLayerMap);
                                } else {
                                    maps.put("AnnoLayer", null);
                                }
                            } else {
                                maps.put("AnnoLayer", null);
                            }
                        } else {
                            Integer IsExistServiceConfig = 0;
                            Res_ExtBusinessLayer resExtBusinessLayer = resExtBusinessLayerService.selectByPrimaryKey(resourceid);
                            if (resExtBusinessLayer != null && resExtBusinessLayer.getServiceConfig() != null && !resExtBusinessLayer.getServiceConfig().equals("")) {
                                IsExistServiceConfig = 1;
                            }
                            maps.put("IsExistServiceConfig", IsExistServiceConfig);
                        }
                        break;
                    case "KJ_ZTDT"://专题地图
                        Res_ExtThemeMap resExtThemeMap = resExtThemeMapService.selectByPrimaryKey(resourceid);// 获取专题地图拓展信息
                        if (resExtThemeMap != null) {
                            Res_ExtMapUrl resExtMapUrl = resExtMapUrlService.queryFirstOrderByResId(resourceid);// 获取资源支持协议与地址
                            String typeandurl = null;
                            String serverurl = null;
                            if (resExtMapUrl != null) {
                                typeandurl = resExtMapUrl.getTypeandurl();
                                serverurl = resExtMapUrl.getServerurl();
                            }
                            maps.put("resourceId", resourceid);
                            maps.put("title", resMainInfo.getTitle());
                            maps.put("mapjson", resExtThemeMap.getType() != null && resExtThemeMap.getType().equals("系统制作") ? JSON.parseObject(resExtThemeMap.getMapjson()) : null);
                            maps.put("resourceclass", "KJ_ZTDT");
                            maps.put("childclass", resExtThemeMap.getType());
                            maps.put("publishsoft", resExtThemeMap.getPublishsoft());
                            maps.put("typeandurl", typeandurl);
                            maps.put("desurl", resMainInfo.getDesurl());
                            maps.put("legendUrl", resExtThemeMap.getLegendurl());
                            maps.put("serverUrl", EsbToken.getEsbUrl(serverurl, orgUser.getUserid().intValue(), request.getRemoteAddr(), resourceid, resMainInfo.getEspproxy(), sysConfig, resExtThemeMap.getSublayerset(), resMainInfo != null && resMainInfo.getSharprotocol().equals("完全公开"), resMainInfo.getToken(), false));
                            if (resExtThemeMap.getType().equals("ArcMap") && resExtThemeMap.getDefaultlayerset() != null) {
                                Res_ExtBaseMap resExtBaseMap = resExtBaseMapService.selectByPrimaryKey(resExtThemeMap.getDefaultlayerset());//获取关联底图信息
                                Res_ExtThemeMap resExtThemeMap1 = resExtThemeMapService.selectByPrimaryKey(resourceid);
                                String subzyids = "";
                                if (resExtThemeMap1 != null) {
                                    subzyids = resExtThemeMap1.getSublayerset();
                                }
                                boolean isPubzy = false;
                                Res_MainInfo resMainInfo1 = resMainInfoService.selectByPrimaryKey(resourceid);
                                if (resMainInfo1 != null && resMainInfo1.getSharprotocol().equals("完全公开")) {
                                    isPubzy = true;
                                }
                                if (resExtBaseMap != null) {
                                    Map<String, Object> BaseMapLayerObjectMap = new HashMap<>();
                                    Res_ExtMapUrl resExtMapUrl2 = resExtMapUrlService.queryFirstOrderByResId(resExtBaseMap.getResourceid());// 获取资源支持协议与地址
                                    
                                    if (resExtMapUrl2 != null) {
                                        BaseMapLayerObjectMap.put("typeandurl", resExtMapUrl2.getTypeandurl());
                                        BaseMapLayerObjectMap.put("serverUrl", EsbToken.getEsbUrl(resExtMapUrl2.getServerurl(), orgUser.getUserid().intValue(), request.getRemoteAddr(), resExtBaseMap.getResourceid(), resMainInfo.getEspproxy(), sysConfig, subzyids, isPubzy, resMainInfo.getToken(), false));
                                    } else {
                                        BaseMapLayerObjectMap.put("typeandurl", "");
                                        BaseMapLayerObjectMap.put("serverUrl", "");
                                    }
                                    Res_MainInfo baseMap = resMainInfoService.selectByPrimaryKey(resExtBaseMap.getResourceid());
                                    BaseMapLayerObjectMap.put("label", baseMap.getTitle());//底图名称
                                    BaseMapLayerObjectMap.put("basemaptype", resExtBaseMap.getBasemaptype());//底图类型
                                    BaseMapLayerObjectMap.put("displaylev", resExtBaseMap.getDisplaylev());//切片级别
                                    //关联标注图
                                    if (resExtBaseMap.getRefmarkinfid() != null) {
                                        Res_ExtBaseMap biaozhu = resExtBaseMapService.selectByPrimaryKey(resExtBaseMap.getRefmarkinfid());//获取关联底图标注图信息
                                        if (biaozhu != null) {
                                            Map<String, Object> AnnoLayerMap = new HashMap<>();
                                            Res_MainInfo res_mainInfo = resMainInfoService.selectByPrimaryKey(resExtBaseMap.getRefmarkinfid());
                                            AnnoLayerMap.put("resourceId", res_mainInfo.getResourceid());//标注图ID
                                            AnnoLayerMap.put("label", res_mainInfo.getTitle());//标注图标题
                                            Res_ExtMapUrl resExtMapUrl1 = resExtMapUrlService.queryFirstOrderByResId(resExtBaseMap.getRefmarkinfid());// 获取资源支持协议与地址
                                            if (resExtMapUrl1 != null) {
                                                AnnoLayerMap.put("typeandurl", resExtMapUrl1.getTypeandurl());//协议服务类型--BaseMapType
                                                AnnoLayerMap.put("serverUrl", EsbToken.getEsbUrl(resExtMapUrl1.getServerurl(), orgUser.getUserid().intValue(), request.getRemoteAddr(), biaozhu.getResourceid(), resMainInfo.getEspproxy(), sysConfig, subzyids, isPubzy, resMainInfo.getToken(), false));//协议服务地址--layerUrl
                                            } else {
                                                AnnoLayerMap.put("typeandurl", "");//协议服务类型--BaseMapType
                                                AnnoLayerMap.put("serverUrl", "");//协议服务地址--layerUrl
                                            }
                                            AnnoLayerMap.put("basemaptype", biaozhu.getBasemaptype());//底图类型--layerType
                                            AnnoLayerMap.put("displaylev", biaozhu.getDisplaylev());//切片级别--displayLevels
                                            BaseMapLayerObjectMap.put("AnnoLayer", AnnoLayerMap);
                                        } else {
                                            BaseMapLayerObjectMap.put("AnnoLayer", null);
                                        }
                                    }
                                    
                                    maps.put("BaseMapLayerObject", BaseMapLayerObjectMap);
                                } else {
                                    maps.put("BaseMapLayerObject", null);
                                }
                            } else {
                                maps.put("BaseMapLayerObject", null);
                            }
                        } else {
                            maps.put("resourceId", resourceid);
                            maps.put("title", resMainInfo.getTitle());
                            maps.put("mapjson", null);
                            maps.put("resourceclass", "KJ_ZTDT");
                            maps.put("childclass", null);
                            maps.put("publishsoft", null);
                            maps.put("typeandurl", null);
                            maps.put("desurl", resMainInfo.getDesurl());
                            maps.put("legendUrl", null);
                            maps.put("serverUrl", null);
                        }
                        break;
                    case "YWJC":
                        Res_ExtIntegrate resExtIntegrate = resExtIntegrateService.selectByPrimaryKey(resourceid);//获取业务集成拓展信息
                        maps.put("resourceId", resourceid);//业务集成服务地址
                        if (resMainInfo != null) {
                            maps.put("title", resMainInfo.getTitle());//业务集成资源名称
                            maps.put("desurl", resMainInfo.getDesurl());
                        } else {
                            maps.put("title", "");//业务集成资源名称
                            maps.put("desurl", null);
                        }
                        if (resExtIntegrate != null) {
                            maps.put("serverUrl", resExtIntegrate.getServerurl());//业务集成服务地址
                            //获取统计图表配置
                            try {
                                if (resExtIntegrate.getIntegratetype().equals("数据集成") && resExtIntegrate.getServerurl() != null && !resExtIntegrate.getServerurl().isEmpty()) {
                                    maps.put("jieShouContent", HttpOperateUtils.httpGet(resExtIntegrate.getServerurl()));
                                } else {
                                    maps.put("jieShouContent", null);
                                }
                            } catch (IOException e) {
                                maps.put("jieShouContent", null);
                            }
                            maps.put("reflayerfield", resExtIntegrate.getReflayerfield());//业务图层关联字段
                            maps.put("integratetype", resExtIntegrate.getIntegratetype());//业务集成集成类型
                            maps.put("showmodel", resExtIntegrate.getShowmodel());//业务集成页面展示方式
                            maps.put("rendermode", resExtIntegrate.getRendermode());//业务集成渲染方式
                            maps.put("refbasemapid", resExtIntegrate.getRefbasemapid());//关联底图资源ID
                            
                            if (resExtIntegrate.getRefbasemapid() != null) {
                                Res_ExtBaseMap resExtBaseMap = resExtBaseMapService.selectByPrimaryKey(resExtIntegrate.getRefbasemapid());//获取关联底图信息
                                if (resExtBaseMap != null) {
                                    Map<String, Object> BaseMapLayerObjectMap = new HashMap<>();
                                    Res_ExtMapUrl resExtMapUrl = resExtMapUrlService.queryFirstOrderByResId(resExtBaseMap.getResourceid());// 获取资源支持协议与地址
                                    Res_ExtThemeMap resExtThemeMap1 = resExtThemeMapService.selectByPrimaryKey(resourceid);
                                    String subzyids = "";
                                    if (resExtThemeMap1 != null) {
                                        subzyids = resExtThemeMap1.getSublayerset();
                                    }
                                    boolean isPubzy = false;
                                    Res_MainInfo resMainInfo1 = resMainInfoService.selectByPrimaryKey(resourceid);
                                    if (resMainInfo1 != null && resMainInfo1.getSharprotocol().equals("完全公开")) {
                                        isPubzy = true;
                                    }
                                    if (resExtMapUrl != null) {
                                        BaseMapLayerObjectMap.put("typeandurl", resExtMapUrl.getTypeandurl());//协议服务类型
                                        BaseMapLayerObjectMap.put("serverUrl", EsbToken.getEsbUrl(resExtMapUrl.getServerurl(), orgUser.getUserid().intValue(), request.getRemoteAddr(), resExtBaseMap.getResourceid(), resMainInfo.getEspproxy(), sysConfig, subzyids, isPubzy, resMainInfo.getToken(), false));//协议服务地址
                                    } else {
                                        BaseMapLayerObjectMap.put("typeandurl", "");//协议服务类型
                                        BaseMapLayerObjectMap.put("serverUrl", "");//协议服务地址
                                    }
                                    Res_MainInfo baseMap = resMainInfoService.selectByPrimaryKey(resExtBaseMap.getResourceid());
                                    BaseMapLayerObjectMap.put("label", baseMap.getTitle());//底图名称
                                    BaseMapLayerObjectMap.put("basemaptype", resExtBaseMap.getBasemaptype());//底图类型
                                    BaseMapLayerObjectMap.put("displaylev", resExtBaseMap.getDisplaylev());//切片级别
                                    //关联标注图
                                    if (resExtBaseMap.getRefmarkinfid() != null) {
                                        Res_ExtBaseMap biaozhu = resExtBaseMapService.selectByPrimaryKey(resExtBaseMap.getRefmarkinfid());//获取关联底图标注图信息
                                        if (biaozhu != null) {
                                            Map<String, Object> AnnoLayerMap = new HashMap<>();
                                            Res_MainInfo res_mainInfo = resMainInfoService.selectByPrimaryKey(resExtBaseMap.getRefmarkinfid());
                                            AnnoLayerMap.put("resourceId", res_mainInfo.getResourceid());//标注图ID
                                            AnnoLayerMap.put("label", res_mainInfo.getTitle());//标注图标题
                                            Res_ExtMapUrl resExtMapUrl1 = resExtMapUrlService.queryFirstOrderByResId(resExtBaseMap.getRefmarkinfid());// 获取资源支持协议与地址
                                            if (resExtMapUrl1 != null) {
                                                AnnoLayerMap.put("typeandurl", resExtMapUrl1.getTypeandurl());//协议服务类型--BaseMapType
                                                AnnoLayerMap.put("serverUrl", EsbToken.getEsbUrl(resExtMapUrl1.getServerurl(), orgUser.getUserid().intValue(), request.getRemoteAddr(), biaozhu.getResourceid(), resMainInfo.getEspproxy(), sysConfig, subzyids, isPubzy, resMainInfo.getToken(), false));//协议服务地址--layerUrl
                                            } else {
                                                AnnoLayerMap.put("typeandurl", "");//协议服务类型--BaseMapType
                                                AnnoLayerMap.put("serverUrl", "");//协议服务地址--layerUrl
                                            }
                                            AnnoLayerMap.put("basemaptype", biaozhu.getBasemaptype());//底图类型--layerType
                                            AnnoLayerMap.put("displaylev", biaozhu.getDisplaylev());//切片级别--displayLevels
                                            BaseMapLayerObjectMap.put("AnnoLayer", AnnoLayerMap);
                                        } else {
                                            BaseMapLayerObjectMap.put("AnnoLayer", null);
                                        }
                                    }
                                    
                                    maps.put("BaseMapLayerObject", BaseMapLayerObjectMap);
                                } else {
                                    maps.put("BaseMapLayerObject", null);
                                }
                            } else {
                                maps.put("BaseMapLayerObject", null);
                            }
                            
                            if (resExtIntegrate.getReflayerid() != null) {
                                Res_ExtBusinessLayer resExtBusinessLayer = resExtBusinessLayerService.selectByPrimaryKey(resExtIntegrate.getReflayerid());//获取关联业务图层信息
                                if (resExtBusinessLayer != null) {
                                    Res_MainInfo res_mainInfo = resMainInfoService.selectByPrimaryKey(resExtBusinessLayer.getResourceid());
                                    Map<String, Object> YwtcLayerObjectMap = new HashMap<>();
                                    YwtcLayerObjectMap.put("resourceId", res_mainInfo.getResourceid());//关联业务图层资源ID
                                    YwtcLayerObjectMap.put("label", res_mainInfo.getTitle());//关联业务图层标题
                                    YwtcLayerObjectMap.put("dataloadtype", resExtBusinessLayer.getDataloadtype());//加载方式
                                    YwtcLayerObjectMap.put("resourceclass", res_mainInfo.getResourceclass());//资源类型
                                    Res_ExtMapUrl resExtMapUrl = resExtMapUrlService.queryFirstOrderByResId(resExtBusinessLayer.getResourceid());// 获取资源支持协议与地址
                                    Res_ExtThemeMap resExtThemeMap1 = resExtThemeMapService.selectByPrimaryKey(resourceid);
                                    String subzyids = "";
                                    if (resExtThemeMap1 != null) {
                                        subzyids = resExtThemeMap1.getSublayerset();
                                    }
                                    boolean isPubzy = false;
                                    Res_MainInfo resMainInfo1 = resMainInfoService.selectByPrimaryKey(resourceid);
                                    if (resMainInfo1 != null && resMainInfo1.getSharprotocol().equals("完全公开")) {
                                        isPubzy = true;
                                    }
                                    if (resExtMapUrl != null) {
                                        YwtcLayerObjectMap.put("typeandurl", resExtMapUrl.getTypeandurl());//底图类型
                                        YwtcLayerObjectMap.put("serverUrl", EsbToken.getEsbUrl(resExtMapUrl.getServerurl(), orgUser.getUserid().intValue(), request.getRemoteAddr(), resourceid, resMainInfo.getEspproxy(), sysConfig, subzyids, isPubzy, resMainInfo.getToken(), false));//服务地址
                                    } else {
                                        YwtcLayerObjectMap.put("typeandurl", "");//底图类型
                                        YwtcLayerObjectMap.put("serverUrl", "");//服务地址
                                    }
                                    YwtcLayerObjectMap.put("layerName", resExtBusinessLayer.getLayername());//原图层名称
                                    maps.put("YwtcLayerObject", YwtcLayerObjectMap);
                                } else {
                                    maps.put("YwtcLayerObject", null);
                                }
                            } else {
                                maps.put("YwtcLayerObject", null);
                            }
                        } else {
                            maps.put("serverUrl", null);//业务集成服务地址
                            maps.put("jieShouContent", null);
                            maps.put("reflayerfield", null);//业务图层关联字段
                            maps.put("integratetype", null);//业务集成集成类型
                            maps.put("showmodel", null);//业务集成页面展示方式
                            maps.put("rendermode", null);//业务集成渲染方式
                            maps.put("refbasemapid", null);//关联底图资源ID
                            maps.put("BaseMapLayerObject", null);
                            maps.put("YwtcLayerObject", null);
                        }
                        maps.put("resourceclass", "YWJC");
                        break;
                    case "SJWJ":
                        Res_ExtFileSource model = resExtFileSourceService.selectByPrimaryKey(resourceid);
                        maps.put("resourceId", resourceid);
                        maps.put("title", resMainInfo.getTitle());
                        maps.put("resourceclass", "SJWJ");
                        if (model != null) {
                            maps.put("flag", "nc");
                            if (model.getSourcetype().equals("文件")) {
                                maps.put("serverUrl", model.getServerurl() != null ? (model.getServerurl().substring(0, model.getServerurl().indexOf("."))) : "");
                                String[] filename = {model.getFilename() != null ? model.getFilename().substring(0, model.getFilename().indexOf(".")) : ""};
                                maps.put("filename", filename);
                            } else {
                                maps.put("serverUrl", model.getServerurl() != null ? model.getServerurl() : "");
                                File file = new File(sysConfig.getUploadPath() + model.getServerurl());
                                String[] fileLists = file.list();
                                if (fileLists != null) {
                                    String[] filename = new String[fileLists.length];
                                    for (int i = 0; i < fileLists.length; i++) {
                                        File file1 = new File(fileLists[i]);
                                        filename[i] = file1.getName().substring(0, file1.getName().indexOf("."));
                                    }
                                    maps.put("filename", filename);
                                } else {
                                    maps.put("filename", null);
                                }
                            }
                            maps.put("ncconfig", model.getNcconfig() != null ? model.getNcconfig() : "");
                            maps.put("ncjsonpath", model.getNcjsonpath() != null ? model.getNcjsonpath() : "");
                            maps.put("ncjsonattribute", model.getNcjsonattribute() != null ? model.getNcjsonattribute() : "");
                        }
                        break;
                    case "KJ_KJFX":
                        maps.put("resourceId", resourceid);
                        if (resMainInfo != null) {
                            maps.put("title", resMainInfo.getTitle());
                            maps.put("desurl", resMainInfo.getDesurl());
                        } else {
                            maps.put("title", "");//业务集成资源名称
                            maps.put("desurl", null);
                        }
                        maps.put("resourceclass", "KJ_KJFX");
                        Res_ExtSpaceServer spaceServer = resExtSpaceServerService.selectByPrimaryKey(resourceid);
                        if (spaceServer != null) {
                            maps.put("serverUrl", spaceServer.getServerurl());
                            maps.put("postType", spaceServer.getPosttype());
                            maps.put("diyParamUrl", spaceServer.getDiyparamurl());
                        }
                        //Json += ",spaceParams: [";
                        List<Map<String, Object>> spaceParamsMaps = new LinkedList<>();
                        List<Res_SpacesParam> resSpacesParams = resSpacesParamService.selectByResSourceId(resourceid);
                        if (resSpacesParams != null && resSpacesParams.size() > 0) {
                            for (int i = 0; i < resSpacesParams.size(); i++) {
                                Map<String, Object> spaceParamsMap = new HashMap<>();
                                spaceParamsMap.put("paramId", resSpacesParams.get(i).getParamid());
                                spaceParamsMap.put("orderIndex", resSpacesParams.get(i).getOrderindex());
                                spaceParamsMap.put("paramType", resSpacesParams.get(i).getParamtype());
                                spaceParamsMap.put("paramName", resSpacesParams.get(i).getParamname());
                                spaceParamsMap.put("dataType", resSpacesParams.get(i).getDatatype());
                                spaceParamsMap.put("paramAlias", resSpacesParams.get(i).getParamalias());
                                spaceParamsMap.put("layerStyle", resSpacesParams.get(i).getLayerstyle() == null ? "" : resSpacesParams.get(i).getLayerstyle());
                                spaceParamsMaps.add(spaceParamsMap);
                            }
                        }
                        break;
                }
                String serverUrl =(String) maps.get("serverUrl");
                String content =(String) maps.get("content");
                String url=null;
                if(null!=content){
                     url = JSONObject.parseObject(content).getString("url");
                }
                serverUrl=serverUrl==null?url:serverUrl;
                if(null!=serverUrl&&serverUrl.contains("104:8066")&& !StringUtils.equals("完全公开",resMainInfo.getSharprotocol())){
                    String param="resourceid="+resourceid+"&isPubzy=0&"+"appId=0&"+"applyuserid="+userid;
                    String data = HttpUtils.get(sysConfig.getProxyUrl()+"/genToken" + "?" + param);
                    JSONObject jsonObject = JSON.parseObject(data);
                    String token = jsonObject.get("data").toString();
                    maps.put("serverUrl", serverUrl+"?token="+token);
                }
            }
        }
        
        return JSON.toJSONString(maps, SerializerFeature.WriteMapNullValue);
    }
    
    /**
     * @Description: 获取资源服务协议与地址信息
     * @Author: xiaoxuan.xie
     * @Date: 09:30 2018/4/2
     * @return: String
     * @see Res_MainInfo
     */
    @ResponseBody
    @GetMapping(path = "resurlinfo/{userid}/{resourceid}/{type}/{id}")
    @ApiOperation(value = "获取资源服务协议与地址信息", notes = "")
    public String GetMapUrlObject(@ApiParam(name = "userid", value = "用户ID", required = true) @PathVariable(name = "userid") Long userid, @ApiParam(name = "resourceid", value = "资源Id", required = true) @PathVariable(name = "resourceid") Integer resourceid, @ApiParam(name = "type", value = "type", required = true) @PathVariable(name = "type") String type, @ApiParam(name = "id", value = "id", required = true) @PathVariable(name = "id") Integer id, HttpServletRequest request) {
        String Json = "";
        Map<String, Object> maps = new HashMap<>();
        Res_MainInfo resMainInfo = resMainInfoService.selectByPrimaryKey(resourceid);// 获取资源主表信息
        if (type.equals("Url")) {
            Res_ExtMapUrl resExtMapUrl = resExtMapUrlService.selectByPrimaryKey(id);// 获取资源支持协议与地址
            Res_ExtThemeMap resExtThemeMap = resExtThemeMapService.selectByPrimaryKey(resourceid);
            String subzyids = "";
            if (resExtThemeMap != null) {
                subzyids = resExtThemeMap.getSublayerset();
            }
            boolean isPubzy = false;
            Res_MainInfo resMainInfo1 = resMainInfoService.selectByPrimaryKey(resourceid);
            if (resMainInfo1 != null && resMainInfo1.getSharprotocol().equals("完全公开")) {
                isPubzy = true;
            }
            if (resExtMapUrl != null) {
                OrgUser orgUser = orgUserService.queryObject(userid);
                maps.put("resourceId", resourceid);
                maps.put("title", resMainInfo.getTitle());
                maps.put("desurl", resMainInfo.getDesurl());
                maps.put("typeandurl", resExtMapUrl.getTypeandurl());
                maps.put("serverUrl", EsbToken.getEsbUrl(resExtMapUrl.getServerurl(), orgUser.getUserid().intValue(), request.getRemoteAddr(), resourceid, resMainInfo.getEspproxy(), sysConfig, subzyids, isPubzy, resMainInfo.getToken(), false));
            } else {
                maps.put("resourceId", resourceid);
                maps.put("title", resMainInfo.getTitle());
                maps.put("desurl", resMainInfo.getDesurl());
                maps.put("typeandurl", "");
                maps.put("serverUrl", "");
            }
        } else {
            Res_DiyLayerInfo resDiyLayerInfo = resDiyLayerInfoService.getById(id);// 获取自定义风格信息
            if (resDiyLayerInfo != null) {
                maps.put("diyId", resDiyLayerInfo.getDiyid());
                maps.put("resourceId", resourceid);
                maps.put("title", resMainInfo.getTitle());
                maps.put("desurl", resMainInfo.getDesurl());
                maps.put("content", JSON.parseObject(resDiyLayerInfo.getContent()));
            } else {
                maps.put("diyId", id);
                maps.put("resourceId", resourceid);
                maps.put("title", "");
                maps.put("desurl", resMainInfo.getDesurl());
                maps.put("content", null);
            }
        }
        
        return JSON.toJSONString(maps, SerializerFeature.WriteMapNullValue);
    }
    
    /**
     * 根据用户ID查询书签列表
     */
    @ResponseBody
    @GetMapping(path = "getBookmarksList/{userid}")
    @ApiOperation(value = "根据用户ID查询书签列表", notes = "")
    public String GetBookmarksList(@ApiParam(name = "userid", value = "用户ID", required = true) @PathVariable(name = "userid") Integer userid) {
        List<Res_BookMarks> resBookMarksList = resBookMarksService.getBookMarksByUserid(userid);
        StringBuilder sb = new StringBuilder();
        List<Map<String, Object>> maps = new LinkedList<>();
        for (int i = 0; i < resBookMarksList.size(); i++) {
            Map<String, Object> map = new HashMap<>();
            map.put("OBJECTID", resBookMarksList.get(i).getObjectid());
            map.put("name", resBookMarksList.get(i).getTitle());
            map.put("extent", JSON.parseObject(resBookMarksList.get(i).getExtent()));
            maps.add(map);
        }
        
        return JSON.toJSONString(maps, SerializerFeature.WriteMapNullValue);
    }
    
    /**
     * 书签新增、修改
     */
    @PostMapping(path = "/addBookMark")
    @ApiOperation(value = "新增、修改地图书签", notes = "")
    @ResponseBody
    public int addMap(@ApiParam(name = "objectid", value = "标签ID") Integer objectid, @ApiParam(name = "userid", value = "用户Id", required = true) Integer userid, @ApiParam(name = "title", value = "标签名称", required = true) String title, @ApiParam(name = "extent", value = "标签地图范围", required = true) String extent) {
        if (objectid == null) objectid = -1;
        int id = 0;
        
        Res_BookMarks resBookMarks = resBookMarksService.getById(objectid);
        if (resBookMarks != null) {
            resBookMarks.setTitle(title);
            resBookMarksService.updateByPrimaryKey(resBookMarks);
            id = resBookMarks.getObjectid();
        } else {
            resBookMarks = new Res_BookMarks();
            resBookMarks.setTitle(title);
            resBookMarks.setCreateuserid(userid);
            resBookMarks.setExtent(extent);
            Timestamp time = new Timestamp(new Date().getTime());
            resBookMarks.setAddtime(time);
            resBookMarksService.insert(resBookMarks);
            id = resBookMarksService.getCurrentObjectId();
        }
        
        return id;
    }
    
    /**
     * 标签删除
     */
    @ResponseBody
    @GetMapping(path = "delBookMark")
    @ApiOperation(value = "删除地图书签", notes = "")
    public String delBookMark(@ApiParam(name = "objectid", value = "书签ID", required = true) @RequestParam(name = "objectid") Integer objectid) {
        resBookMarksService.deleteByPrimaryKey(objectid);
        
        return "删除成功";
    }
    
    /**
     * 获取符号库对应空间类型符号风格列表
     * @return
     */
    @ResponseBody
    @GetMapping(path = "symbolLibrary/list/{geotype}")
    @ApiOperation(value = "获取符号库对应空间类型符号风格列表", notes = "")
    public String getSymbolLibraryList(@ApiParam(name = "geotype", value = "空间类型", required = true) @PathVariable(name = "geotype") String geotype) {
        List<Res_SymbolLibrary> list = resSymbolLibraryService.getListByGeoType(geotype);
        Map<String, Object> maps = new HashMap<>();
        maps.put("success", true);
        List<Map<String, Object>> SymbolLibraryMaps = new LinkedList<>();
        for (int i = 0; i < list.size(); i++) {
            Map<String, Object> SymbolLibraryMap = new HashMap<>();
            SymbolLibraryMap.put(list.get(i).getFhid(), list.get(i).getSymbol());
            SymbolLibraryMaps.add(SymbolLibraryMap);
        }
        maps.put("data", SymbolLibraryMaps);
        return JSON.toJSONString(maps, SerializerFeature.WriteMapNullValue);
    }
    
    /**
     * 获取空间分析列表接口
     */
    @ResponseBody
    @GetMapping(path = {"spaceserverlist", "spaceserverlist/{userid}"})
    @ApiOperation(value = "查询已审核的空间分析信息列表", notes = "")
    public String getSpaceServerList(@ApiParam(name = "userid", value = "userid") @PathVariable(name = "userid", required = false) Integer userid, HttpServletRequest request) {
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("userid", userid);
        List<UserDef_SpaceServer> list = zhuanTiZhiTuService.getSpaceServerList(paramMap);
        List<Map<String, Object>> listMaps = new LinkedList<>();
        for (int i = 0; i < list.size(); i++) {
            String subzyids = "";
            boolean isPubzy = false;
            if (list.get(i).getSharprotocol().equals("完全公开")) {
                isPubzy = true;
            }
            Map<String, Object> map = new HashMap<>();
            map.put("resourceId", list.get(i).getResourceid());
            map.put("title", list.get(i).getTitle());
            map.put("imgurl", list.get(i).getImgurl());
            map.put("serverUrl", list.get(i).getServerurl());
            map.put("postType", list.get(i).getPosttype());
            map.put("diyParamUrl", list.get(i).getDiyparamurl());
            map.put("createuserid", list.get(i).getCreateuserid());
            List<Map<String, Object>> spaceParamsMaps = new LinkedList<>();
            List<Res_SpacesParam> resSpacesParams = resSpacesParamService.selectByResSourceId(list.get(i).getResourceid());
            if (resSpacesParams != null && resSpacesParams.size() > 0) {
                for (int j = 0; j < resSpacesParams.size(); j++) {
                    Map<String, Object> spaceParams = new HashMap<>();
                    spaceParams.put("paramId", resSpacesParams.get(j).getParamid());
                    spaceParams.put("orderIndex", resSpacesParams.get(j).getOrderindex());
                    spaceParams.put("paramType", resSpacesParams.get(j).getParamtype());
                    spaceParams.put("paramName", resSpacesParams.get(j).getParamname());
                    spaceParams.put("dataType", resSpacesParams.get(j).getDatatype());
                    spaceParams.put("paramAlias", resSpacesParams.get(j).getParamalias());
                    spaceParams.put("required", resSpacesParams.get(j).getRequired());
                    spaceParams.put("defaultValue", resSpacesParams.get(j).getDefaultValue());
                    spaceParams.put("layerStyle", resSpacesParams.get(j).getLayerstyle() == null ? "" : resSpacesParams.get(j).getLayerstyle());
                    spaceParamsMaps.add(spaceParams);
                }
            }
            map.put("spaceParams", spaceParamsMaps);
            listMaps.add(map);
        }
        
        return JSON.toJSONString(listMaps, SerializerFeature.WriteMapNullValue);
    }
    
    /**
     * 新增/修改用户图层范围
     */
    @PostMapping(path = "/addUserLayerExtent")
    @ApiOperation(value = "新增/修改用户图层范围", notes = "")
    @ResponseBody
    public int addUserLayerExtent(@ApiParam(name = "id", value = "ID") Integer id, @ApiParam(name = "userid", value = "用户Id", required = true) Integer userid, @ApiParam(name = "resourceid", value = "资源Id", required = true) Integer resourceid, @ApiParam(name = "title", value = "名称", required = true) String title, @ApiParam(name = "extent", value = "范围", required = true) String extent) {
        if (id == null) id = -1;
        int newid = 0;
        
        Res_User_LayerExtent resUserLayerExtent = resUserLayerExtentService.selectByPrimaryKey(id);
        if (resUserLayerExtent != null) {
            resUserLayerExtent.setTitle(title);
            resUserLayerExtent.setExtent(extent);
            resUserLayerExtentService.updateByPrimaryKeySelective(resUserLayerExtent);
            newid = resUserLayerExtent.getId();
        } else {
            resUserLayerExtent = new Res_User_LayerExtent();
            resUserLayerExtent.setTitle(title);
            resUserLayerExtent.setUserid(userid);
            resUserLayerExtent.setExtent(extent);
            resUserLayerExtent.setResourceid(resourceid);
            resUserLayerExtentService.insertSelective(resUserLayerExtent);
            newid = resUserLayerExtentService.getCurrentObjectId();
        }
        
        return newid;
    }
    
    /**
     * 根据用户ID和资源ID查询图层范围列表
     */
    @ResponseBody
    @GetMapping(path = "getLayerExtentList/{userid}/{resourceid}")
    @ApiOperation(value = "根据用户ID和资源ID查询图层范围列表", notes = "")
    public String getLayerExtentList(@ApiParam(name = "userid", value = "用户ID", required = true) @PathVariable(name = "userid") Integer userid, @ApiParam(name = "resourceid", value = "资源ID", required = true) @PathVariable(name = "resourceid") Integer resourceid) {
        Res_User_LayerExtent resUserLayerExtent = new Res_User_LayerExtent();
        resUserLayerExtent.setResourceid(resourceid);
        resUserLayerExtent.setUserid(userid);
        List<Res_User_LayerExtent> resUserLayerExtents = resUserLayerExtentService.selectByResidAndUserid(resUserLayerExtent);
        List<Map<String, Object>> maps = new LinkedList<>();
        for (int i = 0; i < resUserLayerExtents.size(); i++) {
            Map<String, Object> map = new HashMap<>();
            map.put("id", resUserLayerExtents.get(i).getId());
            map.put("title", resUserLayerExtents.get(i).getTitle());
            map.put("userid", resUserLayerExtents.get(i).getUserid());
            map.put("resourceid", resUserLayerExtents.get(i).getResourceid());
            map.put("extent", resUserLayerExtents.get(i).getExtent());
            maps.add(map);
        }
        
        return JSON.toJSONString(maps, SerializerFeature.WriteMapNullValue);
    }
    
    /**
     * 根据ID查询图层范围
     */
    @ResponseBody
    @GetMapping(path = "getLayerExtentInfo/{id}")
    @ApiOperation(value = "根据ID查询图层范围", notes = "")
    public String getLayerExtentInfo(@ApiParam(name = "id", value = "ID", required = true) @PathVariable(name = "id") Integer id) {
        Res_User_LayerExtent resUserLayerExtent = resUserLayerExtentService.selectByPrimaryKey(id);
        Map<String, Object> map = new HashMap<>();
        if (resUserLayerExtent != null) {
            map.put("id", resUserLayerExtent.getId());
            map.put("title", resUserLayerExtent.getTitle());
            map.put("userid", resUserLayerExtent.getUserid());
            map.put("resourceid", resUserLayerExtent.getResourceid());
            map.put("extent", resUserLayerExtent.getExtent());
        }
        
        return JSON.toJSONString(map, SerializerFeature.WriteMapNullValue);
    }
}