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
package com.landtool.lanbase.modules.res.controller;
 
import java.io.File;
import java.io.IOException;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
 
import javax.servlet.http.HttpServletResponse;
 
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
//import com.amazonaws.services.kms.model.ListResourceTagsRequest;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.landtool.lanbase.common.utils.HttpOperateUtils;
import com.landtool.lanbase.common.utils.HttpUtils;
import com.landtool.lanbase.common.utils.Result;
import com.landtool.lanbase.config.SysTemPropertyConfig;
import com.landtool.lanbase.modules.api.utils.Excel;
import com.landtool.lanbase.modules.api.utils.PageBean;
import com.landtool.lanbase.modules.org.entity.OrgUser;
import com.landtool.lanbase.modules.org.service.OrgUnitService;
import com.landtool.lanbase.modules.org.service.OrgUserService;
import com.landtool.lanbase.modules.res.entity.Res_Catalog;
import com.landtool.lanbase.modules.res.entity.Res_Ext3D;
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_ExtInterFaceService;
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_MainInfo;
import com.landtool.lanbase.modules.res.entity.SimpleZiYuan;
import com.landtool.lanbase.modules.res.entity.UserDefined.UserDef_ZYML_ChaXunQu;
import com.landtool.lanbase.modules.res.service.ResCatalogService;
import com.landtool.lanbase.modules.res.service.ResExt3DService;
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.ResExtInterFaceService;
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.ZiYuanMuLuService;
import com.landtool.lanbase.modules.sys.controller.AbstractController;
import com.landtool.lanbase.modules.sys.service.SysFieldvalueService;
 
/**
 * 前台展示 - 资源目录
 */
@Controller
@RequestMapping("res/ziyuanmulu")
public class ZiYuanMuLuController extends AbstractController {
    @Autowired
    private SysTemPropertyConfig sysConfig;
 
    @Autowired
    public ZiYuanMuLuService ziYuanMuLuService;
 
    @Autowired
    private SysFieldvalueService fieldUtils;
 
    @Autowired
    private ResMainInfoService resMainInfoService;
 
    @Autowired
    private OrgUserService orgUserService;
 
    @Autowired
    private OrgUnitService orgUnitService;
 
    @Autowired
    private ResCatalogService resCatalogService;
 
    @Autowired
    private ResExt3DService resExt3DService;
 
    @Autowired
    private ResExtIntegrateService resExtIntegrateService;
 
    @Autowired
    private ResExtBusinessLayerService resExtBusinessLayerService;
 
    @Autowired
    private ResExtMapUrlService resExtMapUrlService;
 
    @Autowired
    private ResExtThemeMapService resExtThemeMapService;
 
    @Autowired
    private ResExtInterFaceService resExtInterFaceService;
 
    @Autowired
    private ResExtFileSourceService resExtFileSourceService;
 
    @Autowired
    private ResExtSpaceServerService resExtSpaceServerService;
    
//
//    @Value("${ResCatalogAuthUrl}")
//    private String  ResCatalogAuthUrl;
    
    /**
     * 资源查询页面
     */
    @RequestMapping("/indexbak")
    public String index(String Message, Model model) {
        //资源浏览 - 资源类型下拉框
        LinkedHashMap<String, String> resourceTypeList = fieldUtils.getFieldListByKey("ResourceType");
        model.addAttribute("resourceTypeList", resourceTypeList);
        //资源类型Json
        String resourceTypeListJson = "";
        for (Map.Entry<String, String> entry : resourceTypeList.entrySet()) {
            if (resourceTypeListJson != "") {
                resourceTypeListJson += ",";
            }
            resourceTypeListJson += "{key:'" + entry.getKey() + "',value:'" + entry.getValue() + "'}";
        }
        //Message判断
        if (Message != null) {
            model.addAttribute("Message", Message);
        }
        model.addAttribute("resourceTypeListJson", "[" + resourceTypeListJson + "]");
        model.addAttribute("pubzyWebRoot", sysConfig.getPubzyWebRoot());
        model.addAttribute("systemName", sysConfig.getAppFullName());
        model.addAttribute("backstageWebRoot", sysConfig.getApiServer() + "/");
 
        //数据文件查询条件——文档类型
        LinkedHashMap<String, String> filetypelist = fieldUtils.getFieldListByKey("FileType");
        model.addAttribute("filetypelist", filetypelist);
 
        //基础底图查询条件——发布平台、地图类型
        LinkedHashMap<String, String> BaseMapTypeList = fieldUtils.getFieldListByKey("BaseMapType");// 获取底图类型字典列表
        LinkedHashMap<String, String> PublishSoftList = fieldUtils.getFieldListByKey("PublishSoft");// 获取发布平台字典列表
        LinkedHashMap<String, String> ImageAccuracyList = fieldUtils.getFieldListByKey("ImageAccuracy");// 获取影像精度字典列表
        model.addAttribute("ImageAccuracyList", ImageAccuracyList);
        model.addAttribute("PublishSoftList", PublishSoftList);
        model.addAttribute("BaseMapTypeList", BaseMapTypeList);
 
        //专题地图查询条件——专题类型
        LinkedHashMap<String, String> typeList = fieldUtils.getFieldListByKey("ThemeMapType");//获取专题类型字典列表
        model.addAttribute("typeList", typeList);
        LinkedHashMap<String, String> GongXiangXieYiList = fieldUtils.getFieldListByKey("SharProtocol");// 获取共享协议列表
        model.addAttribute("SharProtocolList", GongXiangXieYiList);
        model.addAttribute("gisPortal", sysConfig.getGisPortal());
 
        //获取统计图表数据
 
        //1.资源类型
 
        return "ziyuanmulu/index";
    }
 
    /**
     * 获取资源目录树数据
     * @param id       节点ID
     * @param treeType 目录树类型(0:资源目录 4:资源类型)
     * @param XZQHID   区域ID
     * @param NF       时间
     * @param IsSC     是否收藏
     * @return String
     */
    @ResponseBody
    @RequestMapping("/getTreeData")
    public String getTreeData(int id, int treeType, String XZQHID, String NF, int IsSC) {
        String jsonTree = ziYuanMuLuService.getTreeData(id, treeType, XZQHID, NF, IsSC);
        return jsonTree;
    }
 
    /**
     * 获取统计图
     */
    @ResponseBody
    @RequestMapping(value = "/getChart")
    public String getChart(String flag, UserDef_ZYML_ChaXunQu userDefZymlChaXunQu) {
        String jsonChart = "";
        if (flag.equals("zylx")) {
            jsonChart = ziYuanMuLuService.getZiYuanLeiXingChart();    //资源类型
        } else if (flag.equals("xzqh")) {
            jsonChart = ziYuanMuLuService.getZYTJ_XingZhengQuHuaChart(new UserDef_ZYML_ChaXunQu());   //行政区划
        } else if (flag.equals("gxxy")) {
            jsonChart = ziYuanMuLuService.getGongXiangXieYiChart();   //共享协议
        } else if (flag.equals("sjtj")) {
            jsonChart = ziYuanMuLuService.getShiJianTongJiChart(new UserDef_ZYML_ChaXunQu());    //时间统计
        } else if (flag.equals("dwtj")) {
            jsonChart = ziYuanMuLuService.getDanWeiTongJiChart();     //单位统计
        } else if (flag.equals("zytj_zylx")) {
            jsonChart = ziYuanMuLuService.getZYTJ_ZiYuanLeiXingChart(userDefZymlChaXunQu);  //资源统计 - 资源类型
        } else if (flag.equals("zytj_xzqh")) {
            jsonChart = ziYuanMuLuService.getZYTJ_XingZhengQuHuaChart(userDefZymlChaXunQu); //资源统计 - 行政区划
        } else if (flag.equals("zytj_fbsj")) {
            jsonChart = ziYuanMuLuService.getShiJianTongJiChart(userDefZymlChaXunQu); //资源统计-发布年份
        } else if (flag.equals("zytj_shzt")) {
            jsonChart = ziYuanMuLuService.getZYTJ_ShenHeZhuangTai();
        }
        return jsonChart;
    }
 
    /**
     * 资源图文列表
     */
    @RequestMapping("/ZiYuanDataList")
    public String ziYuanDataList(UserDef_ZYML_ChaXunQu userDef_zyml_chaXunQu, Model model, PageBean pageBean) {
        //alert ykm 2019/01/15
        if(userDef_zyml_chaXunQu.getCreateuserid() == null && userDef_zyml_chaXunQu.getFaburen() != null && !userDef_zyml_chaXunQu.getFaburen().equals("")) {
            String name = getUserIds(userDef_zyml_chaXunQu.getFaburen());
            userDef_zyml_chaXunQu.setFaburen(name);
        }
        if(userDef_zyml_chaXunQu.getCreateuserid() != null) {
            userDef_zyml_chaXunQu.setFaburen(null);
        }
        //接口服务和基础地理特殊处理 平台数据
        if("1".equals(userDef_zyml_chaXunQu.getSpcStatus()) &&
                ("JKFW".equals(userDef_zyml_chaXunQu.getResourceclass()))){
            userDef_zyml_chaXunQu.setSpcStatus(null);
        }
        //update:dsh(2018/12/05)
        Page<Res_MainInfo> page = PageHelper.startPage(pageBean.getPage(), 14);
        List<Res_MainInfo> ziYuanMuLuList = ziYuanMuLuService.selectZiYuanMuLuList(userDef_zyml_chaXunQu);
        // added by qfx at 2021-09-14 09:44
        int countNums =(int)((Page)ziYuanMuLuList).getTotal();
 
        List<Integer> ResCatalogAuthlist=new ArrayList<>();
        List<Res_MainInfo> zylist=new ArrayList<>();
 
        //根据用户id获取用户信息,找到该用户所属的角色,由角色找到该用户能看的资源目录
//        try {
//            ResCatalogAuthlist=(List<Integer>) JSONObject.parseArray(HttpUtils.get(ResCatalogAuthUrl+getUserId()), Integer.class);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
 
//         for(Res_MainInfo res : ziYuanMuLuList){
//             if(ResCatalogAuthlist.contains(res.getCatlogid())||"完全公开".equals(res.getSharprotocol())){
//                 zylist.add(res);
//             }
//
//         }
//
//         ziYuanMuLuList=zylist;
 
        PageBean<Res_MainInfo> pageData = new PageBean<>(pageBean.getPage(), pageBean.getLimit(), countNums);
        pageData.setItems(ziYuanMuLuList);
        List<SimpleZiYuan> simpleZiYuans = new ArrayList<>();
        LinkedHashMap<String, String> ResourceTypeList = fieldUtils.getFieldListByKey("ResourceType");
        for (Integer j = 0; j < ziYuanMuLuList.size(); j++) {
            Res_MainInfo zy = ziYuanMuLuList.get(j);
            SimpleZiYuan model1 = new SimpleZiYuan();
            model1.setResourceid(zy.getResourceid());
            model1.setTitle(zy.getTitle());
            model1.setCreateuserid(zy.getCreateuserid());
            String chinesename = orgUserService.getChinesename(zy.getCreateuserid());// 查询发布人id对应的 name
            String unitname = orgUnitService.getUnitName((long) zy.getPubunitid());
            model1.setCreateusername(chinesename);
            model1.setDatasources(zy.getDatasources());
            model1.setPubunitid(zy.getPubunitid());
            model1.setPubunitname(unitname==null?"":unitname);
            model1.setKeywords(zy.getKeywords());
 
            model1.setStatus(zy.getResourcestatus());
 
            model1.setSecuritylev(zy.getSecuritylev());
            model1.setResourceclass(ResourceTypeList.get(zy.getResourceclass()));
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            model1.setPubdate(sdf.format(zy.getPubdate()));
            String imgUrl = "";
            String defClassImg = "/image/classimg/" + zy.getResourceclass() + ".gif";  //默认资源类型图片
            if (zy.getImgurl() != null && zy.getImgurl().length() != 0) {
                if(zy.getImgurl().startsWith("Atkas")){//图集
                    imgUrl = "/image/" + zy.getImgurl();
                    File file = new File(System.getProperty("user.dir")+ "\\src\\main\\resources\\static" + ("/image/"+zy.getImgurl()).replace("/","\\"));
                    if (!file.exists()) {  //判断物理路径是否存在,不存在则默认
                        imgUrl = defClassImg;
                    }
                }else {
                    imgUrl = "/uploadPath/" + zy.getImgurl();
                    File file = new File(sysConfig.getUploadPath() + zy.getImgurl());
                    if (!file.exists()) {  //判断物理路径是否存在,不存在则默认
                        imgUrl = defClassImg;
                    }
                }
            } else {
                imgUrl = defClassImg;
            }
            model1.setImgurl(imgUrl);
            List list = new ArrayList();
            if (zy.getKeywords() != "") {
                String keywords = zy.getKeywords();
                if (keywords != null && !keywords.equals("")) {
                    String key[] = keywords.split(",");
                    for (int i = 0; i < key.length; i++) {
                        String s = key[i];
                        list.add(s);
                    }
                }
            }
            model1.setList(list);
            simpleZiYuans.add(model1);
        }
 
        model.addAttribute("ZyList", simpleZiYuans);
        model.addAttribute("Count", countNums);
        model.addAttribute("Page", pageBean.getPage());
 
        model.addAttribute("pageSize", ziYuanMuLuList.size()); //用于判断CSS样式
        return "FuWuZiYuan/ZiYuanDataList";
    }
 
    /**
     * 查询资源列表功能
     */
    @ResponseBody
    @RequestMapping("/selectResMainInfojoinCatalog")
    public Result selectResMainInfojoinCatalog(UserDef_ZYML_ChaXunQu userDef_zyml_chaXunQu, PageBean pageBean) {
        //alert ykm 2019/01/15
        if(userDef_zyml_chaXunQu.getCreateuserid() == null && userDef_zyml_chaXunQu.getFaburen() != null && !userDef_zyml_chaXunQu.getFaburen().equals("")) {
            String name = getUserIds(userDef_zyml_chaXunQu.getFaburen());
            userDef_zyml_chaXunQu.setFaburen(name);
        }
        if(userDef_zyml_chaXunQu.getCreateuserid() != null) {
            userDef_zyml_chaXunQu.setFaburen(null);
        }
        if("1".equals(userDef_zyml_chaXunQu.getSpcStatus()) &&
                ("JKFW".equals(userDef_zyml_chaXunQu.getResourceclass())
                )){
            userDef_zyml_chaXunQu.setSpcStatus(null);
        }
        Page<Res_MainInfo> page = PageHelper.startPage(pageBean.getPage(), pageBean.getLimit());
        //        if(!SecurityUtils.getSubject().isPermitted("org_user_admin")) {
        ////            // 如果是超级管理员,不添加用户id,查询所有。如果不是 添加id 查询单个
        ////            resMainInfo.setExistPermission(getUserId().toString());
        ////        }
        List<Res_MainInfo> ziYuanMuLuList = ziYuanMuLuService.selectZiYuanMuLuList(userDef_zyml_chaXunQu);
        int countNums = (int) ((Page) ziYuanMuLuList).getTotal();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        PageBean<Res_MainInfo> pageData = new PageBean<>(pageBean.getPage(), pageBean.getLimit(), countNums);
        pageData.setItems(ziYuanMuLuList);
        LinkedHashMap<String, String> ResourceTypeList = fieldUtils.getFieldListByKey("ResourceType");// 获取资源类型列表
        StringBuilder rsb = new StringBuilder();
        String leixin = "";
        List<Map<String, Object>> maps = new LinkedList<>();
        for (Integer i = 0; i < ziYuanMuLuList.size(); i++) {
            leixin = ResourceTypeList.get(ziYuanMuLuList.get(i).getResourceclass());
            String chinesename = orgUserService.getChinesename(ziYuanMuLuList.get(i).getCreateuserid());// 查询发布人id对应的 name
            String unitname = orgUnitService.getUnitName((long) ziYuanMuLuList.get(i).getPubunitid());
            unitname = unitname == null?"":unitname;
            Map<String, Object> map = new HashMap<>();
            map.put("resourceid", ziYuanMuLuList.get(i).getResourceid());
            map.put("title", ziYuanMuLuList.get(i).getTitle());
            map.put("mulu", GetBianMu(ziYuanMuLuList.get(i).getCatlogid() == null ? 0 : ziYuanMuLuList.get(i).getCatlogid()));
            map.put("resourceclass", leixin);
            map.put("pubdate", sdf.format(ziYuanMuLuList.get(i).getPubdate()));
            map.put("pubunitid", unitname);
            map.put("insteadaudit", ziYuanMuLuList.get(i).getInsteadaudit());
            map.put("createuserid", chinesename);
            maps.add(map);
 
        }
        return Result.ok().put("totalCount", countNums).put("topics", maps);
    }
 
    // 导出excel
    @ResponseBody
    @RequestMapping("/excel")
    public String excel(HttpServletResponse response, UserDef_ZYML_ChaXunQu userDef_zyml_chaXunQu) {
        //alert ykm 2019/01/15
        if(userDef_zyml_chaXunQu.getCreateuserid() == null && userDef_zyml_chaXunQu.getFaburen() != null && !userDef_zyml_chaXunQu.getFaburen().equals("")) {
            String name = getUserIds(userDef_zyml_chaXunQu.getFaburen());
            userDef_zyml_chaXunQu.setFaburen(name);
        }
        if(userDef_zyml_chaXunQu.getCreateuserid() != null) {
            userDef_zyml_chaXunQu.setFaburen(null);
        }
 
        List<Res_MainInfo> mainInfoJoinCatalogList = ziYuanMuLuService.selectZiYuanMuLuList(userDef_zyml_chaXunQu);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        LinkedHashMap<String, String> ResourceTypeList = fieldUtils.getFieldListByKey("ResourceType");// 获取资源类型列表
        StringBuilder rsb = new StringBuilder();
        String leixin = "";
//        alert ykm 2019/03/04
        OrgUser user = getUser();
        Map<String, Object> checkmap = new HashMap<>();
        checkmap.put("userid", user.getUserid());
        checkmap.put("unitid", orgUserService.getDefaultUnit(user.getUserid()).getUnitid());
        List<Map<String,Object>> maps = new LinkedList<>();
        for (Integer i = 0; i < mainInfoJoinCatalogList.size(); i++) {
            leixin = ResourceTypeList.get(mainInfoJoinCatalogList.get(i).getResourceclass());
            String chinesename = orgUserService.getChinesename(mainInfoJoinCatalogList.get(i).getCreateuserid()); // obj.getString("chinesename");
            String unitname = orgUnitService.getUnitName((long) mainInfoJoinCatalogList.get(i).getPubunitid()); // obj1.getString("unitname");
            String mulu = GetBianMu(mainInfoJoinCatalogList.get(i).getCatlogid() == null ? 0 : mainInfoJoinCatalogList.get(i).getCatlogid());
 
            Map<String,Object> map = new HashMap<>();
            map.put("resourceid",mainInfoJoinCatalogList.get(i).getResourceid());
            map.put("title",mainInfoJoinCatalogList.get(i).getTitle());
            map.put("mulu",mulu);
            map.put("resourceclass",leixin);
            map.put("pubdate",sdf.format(mainInfoJoinCatalogList.get(i).getPubdate()));
            map.put("pubunitid",unitname);
            map.put("createuserid",chinesename);
//            alert ykm 2019/03/04
            map.put("sharprotocol",mainInfoJoinCatalogList.get(i).getSharprotocol());
            //判断是否有权限
            String serverUrl = "";
            //判断当前用户是否是管理员,是则可以获取全部的资源地址,不是则判断是否具有权限
            if(SecurityUtils.getSubject().isPermitted("org_user_admin")) {
                serverUrl = getServerUrl(mainInfoJoinCatalogList.get(i).getResourceid(), mainInfoJoinCatalogList.get(i).getResourceclass());
            }
            else {
                //当前用户不是管理员,发布人或是完全公开资源则直接获取资源地址
                if (!mainInfoJoinCatalogList.get(i).getSharprotocol().equals("完全公开") && mainInfoJoinCatalogList.get(i).getCreateuserid() != user.getUserid()) {
                    checkmap.remove("resourceid");
                    checkmap.put("resourceid", mainInfoJoinCatalogList.get(i).getResourceid());
                    int count = resMainInfoService.checkZiYuanQuanXian(checkmap);
                    if (count > 0) {
                        serverUrl = getServerUrl(mainInfoJoinCatalogList.get(i).getResourceid(), mainInfoJoinCatalogList.get(i).getResourceclass());
                    }
                } else {
                    serverUrl = getServerUrl(mainInfoJoinCatalogList.get(i).getResourceid(), mainInfoJoinCatalogList.get(i).getResourceclass());
                }
            }
            map.put("serverurl",serverUrl);
 
            maps.add(map);
        }
        rsb.append("]}");
        String a[] = {"资源id", "资源名称", "所属目录编码", "资源类型","共享协议","资源地址", "发布时间", "发布单位id", "发布添加人"};
        try {
            String Filename = Excel.going(response, a, JSON.toJSONString(maps, SerializerFeature.WriteMapNullValue), sysConfig.getUploadPath() + "excel\\");
            String path2 = "/uploadPath/excel/";
            String desFile = path2 + Filename;
            return desFile;
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }
 
    /**
     * 查询资源所属目录
     * @param Catlogid
     * @return
     */
    private String GetBianMu(int Catlogid) {
        String str = "";
        if (Catlogid > 0) {
            Res_Catalog zymlBianMu = resCatalogService.selectByPrimaryKey(Catlogid);
            if (zymlBianMu != null) {
                str += zymlBianMu.getTitle();
                while (zymlBianMu.getParentid()>0)
                {
                    zymlBianMu=resCatalogService.selectByPrimaryKey(zymlBianMu.getParentid());
                    str = zymlBianMu.getTitle()+ " > "+str;
                }
            }
        }
        return str;
    }
 
    //获取用户或单位Map
    private LinkedHashMap<String, String> queryUserOrUnitList(String gettype) {
        String url = sysConfig.getApiServer() + (gettype == "unit" ? "/api/org/unit/queryAllList" : "/api/org/user/queryAllList");
        LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
        try {
            String jsonStr = HttpOperateUtils.httpGet(url.trim());
            if (jsonStr.length() != 0) {
                JSONArray list = JSON.parseArray(jsonStr);
                for (int i = 0; i < list.size(); i++) {
                    Map maps = (Map) JSON.parse(list.get(i).toString());
                    map.put(maps.get("id").toString(), maps.get("name").toString());
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return map;
    }
 
    /**
     * 资源目录页面新设计
     */
 
    /**
     * 资源查询页面
     */
    @RequestMapping("/index")
    public String indexNew(String Message, Model model, String isDiTuwu) {
        //资源浏览 - 资源类型下拉框
        LinkedHashMap<String, String> resourceTypeList = fieldUtils.getFieldListByKey("ResourceType");
        model.addAttribute("resourceTypeList", resourceTypeList);
        //资源类型Json
        String resourceTypeListJson = "";
        for (Map.Entry<String, String> entry : resourceTypeList.entrySet()) {
            if (resourceTypeListJson != "") {
                resourceTypeListJson += ",";
            }
            resourceTypeListJson += "{key:'" + entry.getKey() + "',value:'" + entry.getValue() + "'}";
        }
        //Message判断
        if (Message != null) {
            model.addAttribute("Message", Message);
        }
 
        //是否地图服务搜索判断
        if (isDiTuwu != null) {
            model.addAttribute("isDiTuwu", isDiTuwu);
        }
        model.addAttribute("resourceTypeListJson", "[" + resourceTypeListJson + "]");
        model.addAttribute("pubzyWebRoot", sysConfig.getPubzyWebRoot());
        model.addAttribute("systemName", sysConfig.getAppFullName());
        model.addAttribute("backstageWebRoot", sysConfig.getApiServer() + "/");
 
        //数据文件查询条件——文档类型
        LinkedHashMap<String, String> filetypelist = fieldUtils.getFieldListByKey("FileType");
        model.addAttribute("filetypelist", filetypelist);
 
        //基础底图查询条件——发布平台、地图类型
        LinkedHashMap<String, String> BaseMapTypeList = fieldUtils.getFieldListByKey("BaseMapType");// 获取底图类型字典列表
        LinkedHashMap<String, String> PublishSoftList = fieldUtils.getFieldListByKey("PublishSoft");// 获取发布平台字典列表
        LinkedHashMap<String, String> ImageAccuracyList = fieldUtils.getFieldListByKey("ImageAccuracy");// 获取影像精度字典列表
        model.addAttribute("ImageAccuracyList", ImageAccuracyList);
        model.addAttribute("PublishSoftList", PublishSoftList);
        model.addAttribute("BaseMapTypeList", BaseMapTypeList);
 
        //专题地图查询条件——专题类型
        LinkedHashMap<String, String> typeList = fieldUtils.getFieldListByKey("ThemeMapType");//获取专题类型字典列表
        model.addAttribute("typeList", typeList);
        LinkedHashMap<String, String> GongXiangXieYiList = fieldUtils.getFieldListByKey("SharProtocol");// 获取共享协议列表
        model.addAttribute("SharProtocolList", GongXiangXieYiList);
        model.addAttribute("gisPortal", sysConfig.getGisPortal());
 
        //获取统计图表数据
 
        //1.资源类型
 
        model.addAttribute("logourl","ziyuanmulutitle");
        return "ziyuanmulu/index_New";
    }
 
    //根据输入的用户名获取用户ID
    private String getUserIds(String name) {
        String url = sysConfig.getApiServer() + "/api/org/user/findUserByWord/" + URLEncoder.encode(URLEncoder.encode(name));
 
        String username = null;
        try {
            username = HttpOperateUtils.httpGet(url);
        } catch (IOException e) {
            e.printStackTrace();
        }
        JSONArray object = JSONArray.parseArray(username);
        StringBuilder t = new StringBuilder();
        if(!name.equals( "%")) {
            for (int i = 0; i < object.size(); i++) {
                if (i != 0) t.append(",");
                t.append(object.getJSONObject(i).getString("id"));
            }
        }
        if(t.toString().equals("") && !name.equals( "%")) {
            t.append("-1");
        }
        return t.toString();
    }
 
    // alert ykm 2019/03/04
 
    /**
     * 获取资源地址
     * @param id
     * @param resourceclass
     * @return
     */
    private String getServerUrl(Integer id, String resourceclass) {
        //获取资源地址,多个默认取第一个
        String firstMapUrl = "";
        List<Res_ExtMapUrl> urlList = resExtMapUrlService.selectByCondition(id);
        if (urlList != null && urlList.size() > 0 && urlList.get(0).getServerurl() != null) {
            firstMapUrl = urlList.get(0).getServerurl();
        }
        else {
            if(resourceclass.equals("JKFW")) {
                Res_ExtInterFaceService res_extInterFaceService = resExtInterFaceService.selectByPrimaryKey(id);
                if(res_extInterFaceService != null) {
                    firstMapUrl = res_extInterFaceService.getServerurl() == null ? "" : "\"" + res_extInterFaceService.getServerurl() + "\"";
                }
            }
            if(resourceclass.equals("SJWJ")) {
                Res_ExtFileSource resExtFileSource = resExtFileSourceService.selectByPrimaryKey(id);
                if(resExtFileSource != null) {
                    firstMapUrl = resExtFileSource.getServerurl() == null ? "" : "\"" + resExtFileSource.getServerurl() + "\"";
                }
            }
            if(resourceclass.equals("YWJC")) {
                Res_ExtIntegrate resExtIntegrate = resExtIntegrateService.selectByPrimaryKey(id);
                if(resExtIntegrate != null) {
                    firstMapUrl = resExtIntegrate.getServerurl() == null ? "" : "\"" + resExtIntegrate.getServerurl() + "\"";
                }
            }
            if(resourceclass.equals("KJ_KJFX")) {
                Res_ExtSpaceServer resExtSpaceServer = resExtSpaceServerService.selectByPrimaryKey(id);
                if(resExtSpaceServer != null) {
                    firstMapUrl = resExtSpaceServer.getServerurl() == null ? "" : "\"" + resExtSpaceServer.getServerurl() + "\"";
                }
            }
//            添加三维地形和三维影像 alert 2019/08/01
            if(resourceclass.equals("KJ_SWMX") || resourceclass.equals("KJ_SWDX") || resourceclass.equals("KJ_SWYX")) {
                Res_Ext3D resExt3D = resExt3DService.selectByPrimaryKey(id);
                if(resExt3D != null) {
                    firstMapUrl = resExt3D.getServerurl() == null ? "" : "\"" + resExt3D.getServerurl() + "\"";
                }
            }
        }
        return firstMapUrl;
    }
}