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
package com.landtool.lanbase.modules.api.controller;
 
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import com.alibaba.fastjson.JSON;
import com.landtool.lanbase.common.utils.HttpUtils;
import com.landtool.lanbase.modules.res.service.impl.ResApplyRecommendServiceImpl;
import com.landtool.lanbase.modules.sys.controller.AbstractController;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
 
import com.alibaba.fastjson.JSONObject;
import com.landtool.lanbase.common.utils.HttpOperateUtils;
import com.landtool.lanbase.common.utils.Result;
import com.landtool.lanbase.config.SysTemPropertyConfig;
import com.landtool.lanbase.modules.org.service.OrgUserService;
import com.landtool.lanbase.modules.res.entity.Res_Ext3D;
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_ExtDataBase;
import com.landtool.lanbase.modules.res.entity.Res_ExtDataSource;
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_ExtSpaceServerWithBLOBs;
import com.landtool.lanbase.modules.res.entity.Res_ExtThemeMap;
import com.landtool.lanbase.modules.res.entity.Res_MainInfo;
import com.landtool.lanbase.modules.res.service.ResActionRecordService;
import com.landtool.lanbase.modules.res.service.ResBusinessRefService;
import com.landtool.lanbase.modules.res.service.ResCatalogService;
import com.landtool.lanbase.modules.res.service.ResDiyLayerInfoService;
import com.landtool.lanbase.modules.res.service.ResExt3DService;
import com.landtool.lanbase.modules.res.service.ResExtAppService;
import com.landtool.lanbase.modules.res.service.ResExtBaseMapService;
import com.landtool.lanbase.modules.res.service.ResExtBusinessLayerService;
import com.landtool.lanbase.modules.res.service.ResExtDataBaseService;
import com.landtool.lanbase.modules.res.service.ResExtDataSourceService;
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.ResQueryAroundService;
 
import cn.hutool.core.date.DateTime;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
 
import javax.security.auth.Subject;
 
@Controller
@RequestMapping("/api/")
@Api(value = "", tags = { "资源相关接口" })
public class ResApiController  extends AbstractController {
    @Autowired
    private ResCatalogService resCatalogService;
    @Autowired
    private ResMainInfoService resMainInfoService;
    @Autowired
    private ResActionRecordService resActionRecordService;
    @Autowired
    private ResExtBaseMapService resExtBaseMapService;
    @Autowired
    private ResExtBusinessLayerService resExtBusinessLayerService;
    @Autowired
    private ResExtSpaceServerService resExtSpaceServerService;
    @Autowired
    private ResExtThemeMapService resExtThemeMapService;
    @Autowired
    private ResExtAppService resExtAppService;
    @Autowired
    private ResExtIntegrateService resExtIntegrateService;
    @Autowired
    private ResExtFileSourceService resExtFileSourceService;
    @Autowired
    private ResExtDataBaseService resExtDataBaseService;
    @Autowired
    private ResExtInterFaceService resExtInterFaceService;
    @Autowired
    private ResExt3DService resExt3DService;
    @Autowired
    private ResDiyLayerInfoService resDiyLayerInfoService;
    @Autowired
    private ResExtMapUrlService resExtMapUrlService;
    @Autowired
    private ResBusinessRefService resBusinessRefService;
    @Autowired
    private ResQueryAroundService resQueryAroundService;
    @Autowired
    private OrgUserService orgUserService;
    @Autowired
    private SysTemPropertyConfig sysConfig;
 
    @Autowired
    private ResExtDataSourceService resExtDataSourceService;
 
    @Autowired
    private ResApplyRecommendServiceImpl resApplyRecommendService;
 
//    /**
//     * @param parentCatalogId
//     * @Description: 获取目录树信息 {@link ResCatalogService}
//     * @Author: xiaoxuan.xie
//     * @Date: 17:30 2018/3/15
//     * @return: String
//     * @see Res_Catalog
//     */
//    @ResponseBody
//    @GetMapping(path = "catalog/getTreeByParentID/{parentCatalogId}")
//    @ApiOperation(value = "获取目录树信息", notes = "")
//    public String getTreeByParentID(
//            @ApiParam(name = "parentCatalogId", value = "目录父节点Id", required = true) @PathVariable(name = "parentCatalogId") int parentCatalogId) {
//        String resCatalogTreeJson = getTreeChildrenNodeList(parentCatalogId);// 递归获取目录子节点列表
//        return "[" + resCatalogTreeJson + "]";
//    }
//
//    /**
//     * @param parentCatalogId
//     * @Description: 递归获取目录子节点列表 {@link ResCatalogService}
//     * @Author: xiaoxuan.xie
//     * @Date: 17:30 2018/3/15
//     * @return: String
//     */
//    private String getTreeChildrenNodeList(int parentCatalogId) {
//        String resCatalogTreeJson = "";// 定义目录树Json字符串存储对象
//        List<Res_Catalog> res_catalogList = resCatalogService.selectResCatalogToParentid(parentCatalogId);// 根据目录父Id获取子目录列表
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 实例化时间格式转换器
//        // 循环构造目录树结构Json
//        for (Res_Catalog resCatalog : res_catalogList) {
//            if (resCatalogTreeJson != "")
//                resCatalogTreeJson += ",";
//            resCatalogTreeJson += "{'catlogid':" + resCatalog.getCatlogid();
//            resCatalogTreeJson += ",'catlogcode':'" + resCatalog.getCatlogcode() + "'";
//            resCatalogTreeJson += ",'parentid':" + resCatalog.getParentid();
//            resCatalogTreeJson += ",'title':'" + resCatalog.getTitle() + "'";
//            resCatalogTreeJson += ",'pingyinfiirst':'" + resCatalog.getPingyinfiirst() + "'";
//            resCatalogTreeJson += ",'description':'" + resCatalog.getDescription() + "'";
//            resCatalogTreeJson += ",'imgurl':'" + resCatalog.getImgurl() + "'";
//            resCatalogTreeJson += ",'orderid':" + resCatalog.getOrderid();
//            resCatalogTreeJson += ",'createuser':'" + resCatalog.getCreateuser() + "'";
//            resCatalogTreeJson += ",'createdate':'" + sdf.format(resCatalog.getCreatedate()) + "'";
//            resCatalogTreeJson += ",'remark':'" + resCatalog.getRemark() + "'";
//            resCatalogTreeJson += ",'childnodes':[";
//            String resCatalogChildNode = getTreeChildrenNodeList(resCatalog.getCatlogid());// 递归获取目录子节点列表
//            if (resCatalogChildNode != "") {
//                resCatalogTreeJson += resCatalogChildNode;
//            }
//            resCatalogTreeJson += "]}";
//        }
//
//        return resCatalogTreeJson;
//    }
//
//    /**
//     * @param parentCatalogId
//     * @Description: 获取子目录信息列表{@link ResCatalogService}
//     * @Author: xiaoxuan.xie
//     * @Date: 17:30 2018/3/15
//     * @return: List<Res_Catalog>
//     * @see Res_Catalog
//     */
//    @ResponseBody
//    @GetMapping(path = "catalog/getListByParentID/{parentCatalogId}")
//    @ApiOperation(value = "获取子目录信息列表", notes = "")
//    public List<Res_Catalog> getListByParentID(
//            @ApiParam(name = "parentCatalogId", value = "目录父节点Id", required = true) @PathVariable(name = "parentCatalogId") int parentCatalogId) {
//        return resCatalogService.selectResCatalogToParentid(parentCatalogId);
//    }
//
//    /**
//     * @param catalogId
//     * @Description: 查询目录信息{@link ResCatalogService}
//     * @Author: xiaoxuan.xie
//     * @Date: 09:30 2018/3/16
//     * @return: Res_Catalog
//     * @see Res_Catalog
//     */
//    @ResponseBody
//    @GetMapping(path = "catalog/getById/{catalogId}")
//    @ApiOperation(value = "查询目录信息", notes = "")
//    public Res_Catalog getById(
//            @ApiParam(name = "catalogId", value = "目录Id", required = true) @PathVariable(name = "catalogId") int catalogId) {
//        return resCatalogService.getResCatalogInfoById(catalogId);
//    }
//
//    /**
//     * @param serverId
//     * @Description: 查询服务基本信息{@link ResMainInfoService}
//     * @Author: xiaoxuan.xie
//     * @Date: 09:30 2018/3/16
//     * @return: String
//     * @see Res_MainInfo
//     */
//    @ResponseBody
//    @GetMapping(path = "Server/getBaseInfoById/{serverId}")
//    @ApiOperation(value = "查询服务基本信息", notes = "")
//    public String getBaseInfoById(
//            @ApiParam(name = "serverId", value = "服务Id", required = true) @PathVariable(name = "serverId") int serverId) {
//        String BaseInfoJson = "";// 定义返回Json存储对象
//        Res_MainInfo resMainInfo = resMainInfoService.selectByPrimaryKey(serverId);// 获取资源基本信息
//        BaseInfoJson = JSONObject.toJSONStringWithDateFormat(resMainInfo, "YYYY-MM-dd HH:mm:ss");
//        BaseInfoJson = BaseInfoJson.substring(0, BaseInfoJson.length() - 1);
//        BaseInfoJson += ",resExtInfo:" + getResExtInfo(serverId, resMainInfo.getResourceclass()) + "}";
//
//        return BaseInfoJson;
//    }
//
//    /**
//     * @param resourceid
//     * @param userid
//     * @param actiontype
//     * @param appid
//     * @Description: 日志数据写入 {@link ResActionRecordService}
//     * @Author: xiaoxuan.xie
//     * @Date: 13:30 2018/3/28
//     * @return: Model
//     * @see Res_ActionRecord
//     */
//    @ResponseBody
//    @GetMapping(path = "/setActionRecordInfo")
//    @ApiOperation(value = "日志信息写入", notes = "")
//    public String setActionRecordInfo(Integer resourceid, Long userid, String actiontype, Integer appid) {
//        Timestamp audittime = new Timestamp(new Date().getTime());// 获取当前时间
//        int row = 0;// 操作数据库记录数
//
//        boolean success = false;// 操作状态
//        String msg = "";// 操作返回消息
//        Res_ActionRecord resRecord = new Res_ActionRecord();
//        resRecord.setResourceid(resourceid);
//        resRecord.setUserid(userid);
//        resRecord.setActiontype(actiontype);
//        Res_ActionRecord res_actionRecord = resActionRecordService.getUserActionRecord(resRecord);
//        if (res_actionRecord == null) {
//            resRecord.setActiontype(actiontype);
//            resRecord.setActiontime(audittime);
//            resRecord.setAppid(appid);
//            row = resActionRecordService.insertSelective(resRecord);
//            success = true;
//            msg = "写入成功!";
//        } else {
//            res_actionRecord.setAppid(appid);
//            res_actionRecord.setActiontime(audittime);
//            row = resActionRecordService.updateByPrimaryKeySelective(res_actionRecord);
//            success = true;
//            msg = "更新收藏!";
//        }
//        return "{success:" + success + ", msg:'" + msg + "'}";
//    }
 
    /**
     * @Description: 查询服务列表{@link ResMainInfoService}  //change ykm
     * @Author: xiaoxuan.xie
     * @Date: 09:30 2018/3/16
     * @return: String
     * @see Res_MainInfo
     */
    @ResponseBody
    @GetMapping(path = "Server/getServerList")
    @ApiOperation(value = "查询服务列表", notes = "")
    public String getServerList(@ApiParam(name = "catalogid", value = "目录ID") @RequestParam(name = "catalogid", required = false) Integer catalogid,
                                @ApiParam(name = "resourceclass", value = "资源类型") @RequestParam(name = "resourceclass", required = false) String resourceclass,
                                @ApiParam(name = "resourceid", value = "资源ID") @RequestParam(name = "resourceid", required = false) Integer resourceid ) {
        String BaseInfoListJson = "";// 定义返回Json存储对象
            Map<String,Object> map = new HashMap<String,Object>();
            map.put("catalogid",catalogid);
            map.put("resourceclass",resourceclass);
            map.put("resourceid",resourceid);
 
//            List<Res_MainInfo> resMainInfoList = resMainInfoService.getAll();// 获取所有资源信息
            List<Res_MainInfo> resMainInfoList = resMainInfoService.getListByMap(map);// 获取所有资源信息
 
 
            for (Res_MainInfo resMainInfo : resMainInfoList) {
                String BaseInfoJson = "";
                BaseInfoJson = JSONObject.toJSONStringWithDateFormat(resMainInfo, "YYYY-MM-dd HH:mm:ss");
                JSONObject obj = JSONObject.parseObject(BaseInfoJson);
                Map m = obj;
                m.remove("remark");
                BaseInfoJson = m.toString();
                BaseInfoJson = BaseInfoJson.substring(0, BaseInfoJson.length() - 1);
                BaseInfoJson += ",resExtInfo:" + getResExtInfo(resMainInfo.getResourceid(), resMainInfo.getResourceclass())
                        + "}";
                if (!BaseInfoListJson.isEmpty())
                    BaseInfoListJson += ",";
                BaseInfoListJson += BaseInfoJson;
            }
            BaseInfoListJson = htmlDecodeByRegExp(BaseInfoListJson);
            BaseInfoListJson = URLDecoder.decode(BaseInfoListJson.replaceAll("%","%25"));
//        }
        return "[" + BaseInfoListJson + "]";
    }
 
    /**
     * @param Resourceid
     * @param leixing
     * @return String
     * @Description: 获取资源拓展信息
     */
    private String getResExtInfo(int Resourceid, String leixing) {
        String ResExtInfo = "";
        String ResourceType = leixing;
        if (ResourceType == null)
            ResourceType = "";
        // 根据资源类型获取资源拓展信息
        //alert ykm 2019/02/26
        if(ResourceType.equals("KJ_SWMX") || ResourceType.equals("KJ_SWDX") || ResourceType.equals("KJ_SWYX")) ResourceType = "KJ_SW";
        switch (ResourceType) {
        case "KJ_JCDT":// 基础底图
            Res_ExtBaseMap resExtBaseMap = resExtBaseMapService.selectByPrimaryKey(Resourceid);// 获取基础底图信息
            ResExtInfo = JSONObject.toJSONString(resExtBaseMap);
            break;
        case "KJ_YWTC":// 业务图层
            Res_ExtBusinessLayer resExtBusinessLayer = resExtBusinessLayerService.selectByPrimaryKey(Resourceid);// 获取业务图层信息
            if(resExtBusinessLayer != null && resExtBusinessLayer.getServiceHTML() != null) {
                resExtBusinessLayer.setServiceHTML(htmlDecodeByRegExp(resExtBusinessLayer.getServiceHTML()));
            }
            ResExtInfo = JSONObject.toJSONString(resExtBusinessLayer);
            break;
        case "KJ_KJFX":// 空间分析
            Res_ExtSpaceServerWithBLOBs resExtSpaceServerWithBLOBs = resExtSpaceServerService
                    .selectByPrimaryKey(Resourceid);// 获取空间服务信息
            if(resExtSpaceServerWithBLOBs != null && resExtSpaceServerWithBLOBs.getHelpurl() != null){
                resExtSpaceServerWithBLOBs.setHelpurl(htmlDecodeByRegExp(resExtSpaceServerWithBLOBs.getHelpurl()));
            }
            ResExtInfo += JSONObject.toJSONString(resExtSpaceServerWithBLOBs);
            break;
        case "KJ_ZTDT":// 专题地图
            Res_ExtThemeMap resExtThemeMap = resExtThemeMapService.selectByPrimaryKey(Resourceid);// 获取专题地图信息
            ResExtInfo += JSONObject.toJSONString(resExtThemeMap);
            break;
        case "YWJC":// 业务集成
            Res_ExtIntegrate resExtIntegrate = resExtIntegrateService.selectByPrimaryKey(Resourceid);// 获取业务集成信息
            ResExtInfo += JSONObject.toJSONString(resExtIntegrate);
            break;
        case "SJWJ":// 文档数据
            Res_ExtFileSource resExtFileSource = resExtFileSourceService.selectByPrimaryKey(Resourceid);// 获取文档数据信息
            ResExtInfo += JSONObject.toJSONString(resExtFileSource);
            break;
        case "SJKB":// 数据库表
            Res_ExtDataBase res_extDataBase = resExtDataBaseService.selectByMainInfoId(Resourceid);
            if(res_extDataBase!=null && res_extDataBase.getDatasourceid() != null) {
                Res_ExtDataSource resExtDataSource = resExtDataSourceService.selectByPrimaryKey(res_extDataBase.getDatasourceid()); //add ykm
                JSONObject obj = JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(res_extDataBase,"YYYY-MM-dd HH:mm:ss"));
                obj.put("DataSourceInfo", JSONObject.parseObject(JSONObject.toJSONStringWithDateFormat(resExtDataSource,"YYYY-MM-dd HH:mm:ss")));
                ResExtInfo += obj.toJSONString();
            }
            else {
                ResExtInfo += JSONObject.toJSONString(res_extDataBase);
            }
            break;
        case "JKFW":// 接口服务
            Res_ExtInterFaceService res_extInterFaceService = resExtInterFaceService.selectByPrimaryKey(Resourceid);
            if(res_extInterFaceService != null && res_extInterFaceService.getHelpurl() != null) {
                res_extInterFaceService.setHelpurl(htmlDecodeByRegExp(res_extInterFaceService.getHelpurl()));
            }
            ResExtInfo += JSONObject.toJSONString(res_extInterFaceService);
            break;
//        case "KJ_SWMX":// 三维模型
        case "KJ_SW":// 三维类型,三维模型,三维地形,三维影像
            Res_Ext3D res_ext3D = resExt3DService.selectByPrimaryKey(Resourceid);
            ResExtInfo += JSONObject.toJSONString(res_ext3D);
            break;
        default:
            ResExtInfo += "{}";
            break;
        }
 
        return ResExtInfo;
    }
 
    public String htmlDecodeByRegExp(String str){
        String s = "";
        if(str.equals("")) return "";
        s = str.replace("&amp;","&");
        s = s.replace("&lt;","<");
        s = s.replace("&gt;",">");
        s = s.replace("&nbsp;"," ");
        s = s.replace("&#39;","\'");
        s = s.replace("&quot;","\"");
        s = s.replace("\\","");
        return s;
    }
 
//    /**
//     * @Description: 获取资源服务地址信息
//     * @Author: xiaoxuan.xie
//     * @Date: 09:30 2018/3/31
//     * @return: String
//     * @see Res_MainInfo
//     */
//    @ResponseBody
//    @GetMapping(path = "Server/getLayerObject/{resourceid}/{userid}")
//    @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,
//            HttpServletRequest request) {
//        String Json = "";
//        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 = resDiyLayerInfoService.queryUserObject(userid, resourceid);
//                    if (resDiyLayerInfo != null) {
//                        Json = "{ diyId: " + resDiyLayerInfo.getDiyid() + ", resourceId: " + resourceid + ", title: '"
//                                + resDiyLayerInfo.getTitle() + "', content: " + resDiyLayerInfo.getContent() + ", GuanLian: " + GuanLian + ", ZhouBian: " + ZhouBian + "}";
//                    } else {
//                        // 获取管理员定义JSON
//                        resDiyLayerInfo = resDiyLayerInfoService.queryUserObject(0, resourceid);
//                        if (resDiyLayerInfo != null) {
//                            Json = "{ diyId: " + resDiyLayerInfo.getDiyid() + ", resourceId: " + resourceid
//                                    + ", title: '" + resDiyLayerInfo.getTitle() + "', content: "
//                                    + resDiyLayerInfo.getContent() + ", GuanLian: " + GuanLian + ", ZhouBian: " + ZhouBian + " }";
//                        } else {
//                            // 获取资源支持协议与地址
//                            Res_ExtMapUrl resExtMapUrl = resExtMapUrlService.queryFirstOrderByResId(resourceid);
//                            if (resExtMapUrl != null) {
//                                // 获取token
//                                //String token = "";// token
//                                //String urlEncode = "";
//                                //if (resMainInfo.getEspproxy() == 1) {
//                                //    try {
//                                //        urlEncode = java.net.URLEncoder.encode(resExtMapUrl.getServerurl(), "UTF-8");
//                                //        String getTokenUrl = sysConfig.getTokenWebRoot() + "?loginName=" + username
//                                //                + "&resourceId=" + resourceid + "&resourceUrl=" + urlEncode
//                                //                + "&expireSeconds=360000&clientIp=" + request.getRemoteAddr();// token获取地址
//                                //        String TokenResponse = HttpOperateUtils.httpGet(getTokenUrl);// 请求token
//                                //        if (!TokenResponse.isEmpty()) {
//                                //            JSONObject object = JSONObject.parseObject(TokenResponse);// 转换返回JSON字符串
//                                //            token = object.getString("token");// 获取返回token
//                                //        }
//                                //        Json = "{ resourceId: " + resourceid + ", title: '" + resMainInfo.getTitle()
//                                //                + "', typeandurl: '" + resExtMapUrl.getTypeandurl() + "', serverUrl: '"
//                                //                + resExtMapUrl.getServerurl() + "?token=" + token + "' }";
//                                //    } catch (java.io.IOException e) {
//                                //        Json = "{ resourceId: " + resourceid + ", title: '" + resMainInfo.getTitle()
//                                //                + "', typeandurl: '" + resExtMapUrl.getTypeandurl() + "', serverUrl: '"
//                                //                + resExtMapUrl.getServerurl() + "?token=" + token + "' }";
//                                //    }
//                                //} else {
//                                //    Json = "{ resourceId: " + resourceid + ", title: '" + resMainInfo.getTitle()
//                                //            + "', typeandurl: '" + resExtMapUrl.getTypeandurl() + "', serverUrl: '"
//                                //            + resExtMapUrl.getServerurl() + "' }";
//                                //}
//                                OrgUser orgUser = orgUserService.queryObject(Long.parseLong(userid.toString()));
//                                Json = "{ resourceId: " + resourceid + ", title: '" + resMainInfo.getTitle()
//                                        + "', typeandurl: '" + resExtMapUrl.getTypeandurl() + "', serverUrl: '"
//                                        + EsbToken.getEsbUrl(resExtMapUrl.getServerurl(), orgUser.getLoginname(), request.getRemoteAddr(), resourceid, resMainInfo.getEspproxy(), sysConfig)
//                                        + "', GuanLian: " + GuanLian + ", ZhouBian: " + ZhouBian + " }";
//                            } else {
//                                Json = "{ resourceId: " + resourceid + ", title: '" + resMainInfo.getTitle()
//                                        + "', typeandurl: '', serverUrl: '' , GuanLian: " + GuanLian + ", ZhouBian: " + ZhouBian + "}";
//                            }
//                        }
//                    }
//                    break;
//                case "KJ_ZTDT":
//                    Res_ExtThemeMap resExtThemeMap = resExtThemeMapService.selectByPrimaryKey(resourceid);// 获取专题地图拓展信息
//                    if (resExtThemeMap != null && resExtThemeMap.getMapjson() != null
//                            && !resExtThemeMap.getMapjson().isEmpty()) {
//                        Json = "{resourceId: " + resourceid + ", title: '" + resMainInfo.getTitle() + "', mapjson: "
//                                + resExtThemeMap.getMapjson() + "}";
//                    } else {
//                        Json = "{resourceId: " + resourceid + ", title: '" + resMainInfo.getTitle()
//                                + "', mapjson: null}";
//                    }
//                    break;
//                }
//            }
//        }
//
//        return Json;
//    }
//
//    /**
//     * @Description: 获取资源服务协议与地址信息
//     * @Author: xiaoxuan.xie
//     * @Date: 09:30 2018/4/2
//     * @return: String
//     * @see Res_MainInfo
//     */
//    @ResponseBody
//    @GetMapping(path = "Server/getMapUrlObject/{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 = "";
//        if (type.equals("Url")) {
//            Res_ExtMapUrl resExtMapUrl = resExtMapUrlService.selectByPrimaryKey(id);// 获取资源支持协议与地址
//            Res_MainInfo resMainInfo = resMainInfoService.selectByPrimaryKey(resourceid);// 获取资源主表信息
//            if (resExtMapUrl != null) {
//                // 获取token
//                //String token = "";// token
//                //String urlEncode = "";
//                //if (resMainInfo.getEspproxy() == 1) {
//                //    try {
//                //        urlEncode = java.net.URLEncoder.encode(resExtMapUrl.getServerurl(), "UTF-8");
//                //        String getTokenUrl = sysConfig.getTokenWebRoot() + "?resourceId=" + resourceid
//                //                + "&resourceUrl=" + urlEncode + "&expireSeconds=360000&clientIp="
//                //                + request.getRemoteAddr();// token获取地址
//                //        String TokenResponse = HttpOperateUtils.httpGet(getTokenUrl);// 请求token
//                //        JSONObject object = JSONObject.parseObject(TokenResponse);// 转换返回JSON字符串
//                //        token = object.getString("token");// 获取返回token
//                //        Json = "{ resourceId: " + resourceid + ", title: '" + resMainInfo.getTitle()
//                //                + "', typeandurl: '" + resExtMapUrl.getTypeandurl() + "', serverUrl: '"
//                //                + resExtMapUrl.getServerurl() + "?token=" + token + "' }";
//                //    } catch (UnsupportedEncodingException e) {
//                //        Json = "{ resourceId: " + resourceid + ", title: '" + resMainInfo.getTitle()
//                //                + "', typeandurl: '" + resExtMapUrl.getTypeandurl() + "', serverUrl: '"
//                //                + resExtMapUrl.getServerurl() + "?token=" + token + "' }";
//                //    } catch (Exception e) {
//                //        Json = "{ resourceId: " + resourceid + ", title: '" + resMainInfo.getTitle()
//                //                + "', typeandurl: '" + resExtMapUrl.getTypeandurl() + "', serverUrl: '"
//                //                + resExtMapUrl.getServerurl() + "?token=" + token + "' }";
//                //    }
//                //} else {
//                //    Json = "{ resourceId: " + resourceid + ", title: '" + resMainInfo.getTitle() + "', typeandurl: '"
//                //            + resExtMapUrl.getTypeandurl() + "', serverUrl: '" + resExtMapUrl.getServerurl() + "' }";
//                //}
//                OrgUser orgUser = orgUserService.queryObject(userid);
//                Json = "{ resourceId: " + resourceid + ", title: '" + resMainInfo.getTitle()
//                        + "', typeandurl: '" + resExtMapUrl.getTypeandurl() + "', serverUrl: '"
//                        + EsbToken.getEsbUrl(resExtMapUrl.getServerurl(), orgUser.getLoginname(), request.getRemoteAddr(), resourceid, resMainInfo.getEspproxy(), sysConfig) + "' }";
//            } else {
//                Json = "{ resourceId: " + resourceid + ", title: '" + resMainInfo.getTitle()
//                        + "', typeandurl: '', serverUrl: '' }";
//            }
//        } else {
//            Res_DiyLayerInfo resDiyLayerInfo = resDiyLayerInfoService.getById(id);// 获取自定义风格信息
//            if (resDiyLayerInfo != null) {
//                Json = "{ diyId: " + resDiyLayerInfo.getDiyid() + ", resourceId: " + resourceid + ", title: '"
//                        + resDiyLayerInfo.getTitle() + "', content: " + resDiyLayerInfo.getContent() + " }";
//            } else {
//                Json = "{ diyId: " + id + ", resourceId: " + resourceid + ", title: '', content: null }";
//            }
//        }
//
//        return Json;
//    }
//
//    /**
//     * @Description: 获取业务集成-页面集成-Iframe区块目录树
//     */
//    @ResponseBody
//    @GetMapping(path = "Server/getYWJCTreeData/{id}")
//    @ApiOperation(value = "获取业务集成-页面集成-Iframe区块目录树", notes = "")
//    public String getYWJCTreeData(
//            @ApiParam(name = "id", value = "id", required = true) @PathVariable(name = "id") String id,
//            HttpServletRequest request) {
//        StringBuilder resCatalogJson = new StringBuilder();
//        String leixiId = "YWJC";
//        Res_MainInfo resMainInfoTWO = new Res_MainInfo();
//        resMainInfoTWO.setResourceclass(leixiId);
//        resMainInfoTWO.setCParentid(Integer.parseInt(id));
//        resMainInfoTWO.setCatlogid(Integer.parseInt(id));
//        List<Res_Catalog> resCatalogList = resCatalogService.getYWJCMuLuTree(Integer.parseInt(id));// 获取子目录列表
//        // 循环构造子目录节点
//        for (Res_Catalog resCatalog : resCatalogList) {
//            if (!"".equals(resCatalogJson.toString())) {
//                resCatalogJson.append(',');
//            }
//            resCatalogJson.append(
//                    "{id: " + resCatalog.getCatlogid() + ",name:'" + resCatalog.getTitle() + "', isParent: true}");
//        }
//        // 获取资源类型列表
//        List<Res_MainInfo> resMainInfo = resMainInfoService.getYWJCTreeData(resMainInfoTWO); // 获取目录下业务集成--页面集成--Iframe区块资源列表
//        // 循环构造资源节点
//        for (Res_MainInfo resMainInfo1 : resMainInfo) {
//            Res_ExtIntegrate res_extIntegrate = resExtIntegrateService.selectByPrimaryKey(resMainInfo1.getResourceid());// 获取业务集成拓展信息
//            if (!"".equals(resCatalogJson.toString())) {
//                resCatalogJson.append(',');
//            }
//
//            String title = resMainInfo1.getTitle();
//            if (resMainInfo1.getTitle().length() > 16) {
//                title = resMainInfo1.getTitle().substring(0, 16) + "..";
//            }
//
//            String serverUrl = res_extIntegrate.getServerurl();
//            if (serverUrl == null)
//                serverUrl = "";
//
//            resCatalogJson.append("{id: 'ZiYuan_" + resMainInfo1.getResourceid() + "',name:'" + title + "', title: '"
//                    + resMainInfo1.getTitle() + "',isParent:false, ServerUrl: '" + serverUrl + "'}");
//        }
//        return "[" + resCatalogJson.toString() + "]";
//    }
 
    /**
     * @Description: 查询资源是否存在
     * @Author: dengshuhua
     * @return: Boolean
     */
    @ResponseBody
    @GetMapping(path = "/cheackZYIsExist")
    @ApiOperation(value = "查询服务列表", notes = "")
    public Boolean getServerList(@ApiParam(name = "resourceid", value = "资源ID") @RequestParam(name = "resourceid", required = true) Integer resourceid) {
        Boolean result = false;
        Res_MainInfo mainInfo =  resMainInfoService.selectByPrimaryKey(resourceid);
        if(mainInfo != null) result = true;
        return result;
    }
 
    @ResponseBody
    @GetMapping(path = "/GetStationDataSearch")
    @ApiOperation(value = "海洋站监测数据数据信息检索", notes = "")
    public Result GetStationDataSearch(Integer stationCode,String startDate,String endDate,String factorCode) {
        String data = "";
        String path = sysConfig.getUploadPath() + "cache\\"+"Search.txt";
        try {
            String url = "http://192.168.4.124:8100/stations/data/search?stationCode=" + stationCode + "&startDate=" + startDate + "&endDate=" + endDate + "&factorCode=" + factorCode;
            data = HttpOperateUtils.httpGet(url);
            File file = new File(path);
            file.createNewFile();
            FileWriter writer = new FileWriter(file);
            BufferedWriter out = new BufferedWriter(writer);
            out.write(data);
            out.flush();
        } catch (Exception ex) {
 
        }
        return Result.ok().put("path",sysConfig.getUploadRootPath()+"cache/"+"Search.txt");
    }
 
    @ResponseBody
    @GetMapping(path = "/GetCXDataByTaiZhanNameAndTime")
    @ApiOperation(value = "获取台站预报数据", notes = "")
    public Result GetCXDataByTaiZhanNameAndTime(String name,String timeStr) {
        String ycdata = "";
        String parpath = sysConfig.getUploadPath() + "cache\\yc";
        String date = DateTime.now().toString().substring(0,10);
        String todayData = parpath +"\\"+date+".txt";
        try {
            File parentDir = new File(parpath);
            if(parentDir.isDirectory()){
                File[] files = parentDir.listFiles();
                //是否存在当天的预测数据
                boolean isExits = false;
                for(File f : files){
                    String n = f.getName();
                    if(f.getName().equals(date+".txt")){
                        isExits = true;
                        break;
                    }
                }
                //不存在则从接口获取数据写入当天缓存
                if(!isExits){
                    //删除文件夹下的文件
                    for(File f : files){
                        f.delete();
                    }
                    String url = "http://192.168.20.106/Ocean/WebServices/ElecTable/X_CWYG_Server.asmx/GetCXDataByTaiZhanNameAndTime";
                    SearchZscg searchZscg = new SearchZscg();
                    searchZscg.setName(URLDecoder.decode(name));
                    searchZscg.setTimeStr(timeStr);
                    ycdata = HttpOperateUtils.httpPost(url,searchZscg);
                    File newfile = new File(todayData);
                    newfile.createNewFile();
                    FileWriter writer = new FileWriter(newfile);
                    BufferedWriter out = new BufferedWriter(writer);
                    out.write(ycdata);
                    out.flush();
                }
            }
        } catch (Exception ex) {
 
        }
        return Result.ok().put("path",sysConfig.getUploadRootPath()+"cache/yc/"+date+".txt");
    }
 
    public class SearchZscg{
         private String name;
         private String timeStr;
 
        public String getName() {
            return name;
        }
 
        public void setName(String name) {
            this.name = name;
        }
 
        public String getTimeStr() {
            return timeStr;
        }
 
        public void setTimeStr(String timeStr) {
            this.timeStr = timeStr;
        }
    }
 
 
 
 
}