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
<form class="form-horizontal" id="jkfwform" xmlns:th="http://www.w3.org/1999/xhtml">
    <div class="portlet box ltblue">
        <div class="portlet-title">
            接口服务信息
            <div class="caption">
                <i class="fa fa-reorder"></i>
            </div>
            <div class="tools">
                <a class="collapse" onclick="portlet_body_ShowOrHide(this);"></a>
            </div>
        </div>
        <div class="portlet-body" style="margin-top: 10px;">
            <div class="row">
                <div class="col-sm-6">
                    <div class="control-group">
                        <label class="control-label">服务分类<span style="color: red;">*</span></label>
                        <div class="controls input-icon">
                            <select id="servertype" name="servertype" class="form-control col-sm-9" required="">
                                <option value="">--请选择--</option>
                                <option th:selected="(${Res_ExtInterFaceService.servertype}=='WebService')?'true':'false'" value="WebService">WebService</option>
                                <option th:selected="(${Res_ExtInterFaceService.servertype}=='WEBAPI')?'true':'false'" value="WEBAPI">WEBAPI</option>
                            </select>
                            <span class="input-warning tooltips" data-original-title="">
                                <i class="fa-warning-sign" style="display: none;margin-left:30px;"></i>
                            </span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-12">
                    <div class="control-group">
                        <label class="control-label">服务地址</label>
                        <div class="controls input-icon">
                            <input th:value="${Res_ExtInterFaceService.serverurl}" id="serverurl" name="serverurl" class="form-control col-sm-10" />
                            <a th:if="${Res_ExtInterFaceService.esbid}==null and ${Res_ExtInterFaceService.resourceid} != null" name="esbbtn" style="cursor: pointer;vertical-align:sub;" onclick="showEsbInfo()"><span>注册</span></a>
                            <a th:if="${Res_ExtInterFaceService.esbid}!=null" style="cursor: pointer;vertical-align:sub;" onclick="showEsbInfo()"><span>更新</span></a>
                            <input type="hidden" id="esbid" th:value="${Res_ExtInterFaceService.esbid}" />
                            <input type="hidden" id="zyjc" th:value="${resMainInfo.abbreviation}" />
                            <input type="hidden" id="hidcontextpath" th:value="${Res_ExtInterFaceService.contextpath}" />
                            <input type="hidden" id="hidagentserverurl" th:value="${Res_ExtInterFaceService.agentserverurl}" />
                            <input type="hidden" id="hidservertype" th:value="${Res_ExtInterFaceService.servertype}" />
                            <span class="input-warning tooltips" data-original-title="">
                                <i class="fa-warning-sign" style="display: none;margin-left:30px;"></i>
                            </span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="control-group">
                        <label class="control-label">TOKEN</label>
                        <div class="controls input-icon">
                            <input type="text" id="token" name="token" class="form-control col-sm-9" th:value="${resMainInfo.token}" />
                            <input type="text" type="hidden" id="hidsharprotocol" name="hidsharprotocol" class="form-control col-sm-9" th:value="${resMainInfo.sharprotocol}" />
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="control-group">
                        <label class="control-label">ESB代理<span style="color: red;">*</span></label>
                        <div class="controls input-icon">
                            <select type="text" id="espproxy" name="espproxy" class="form-control col-sm-9" required="">
                                <option value="">--请选择--</option>
                                <option th:selected="(${resMainInfo.espproxy}==0)?'true':'false'" value="0">否</option>
                                <option th:selected="(${resMainInfo.espproxy}==1)?'true':'false'" value="1">是</option>
                            </select>
                            <span class="input-warning tooltips" data-original-title="">
                                <i class="fa-warning-sign" style="display: none;margin-left:30px;"></i>
                            </span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-12">
                    <div class="control-group">
                        <label class="control-label">帮助说明文档</label>
                        <div class="controls">
                            <!-- 加载编辑器的容器 -->
                            <script id="contents" name="contents" type="text/plain" class="col-sm-11" style="z-index: 0;" ></script>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</form>
<div id="resEsbInfo" style="display:none;padding:10px;" xmlns:th="http://www.w3.org/1999/xhtml">
    <div class="col-sm-12">
        <div class="control-group" style="height: 55px;">
            <label class="control-label" style="padding-right:0;">上下文地址:<br />(全局唯—,必须以/开头)</label>
            <div class="controls input-icon">
                <input id="contexturl" name="contexturl" class="form-control col-sm-12" value="" />
            </div>
        </div>
    </div>
    <div class="col-sm-12">
        <div class="control-group">
            <label class="control-label" style="line-height:38px;">代理服务地址:</label>
            <div class="controls input-icon">
                <input id="fuwuurl" name="fuwuurl" class="form-control col-sm-12" />
                <input type="hidden" id="wsService" />
                <input type="hidden" id="wsServiceTNS" />
            </div>
        </div>
    </div>
    <div class="col-sm-12" id="selectPort">
        <div class="control-group">
            <label class="control-label" style="line-height:38px;">选择版本:</label>
            <div class="controls input-icon">
                <select class="form-control col-sm-12" id="wsPort">
                </select>
            </div>
        </div>
    </div>
    <div class="col-sm-12">
        <div class="control-group">
            <label class="control-label" style="line-height:38px;">TOKEN:</label>
            <div class="controls input-icon">
                <input id="servicetoken" readonly="readonly" name="servicetoken" class="form-control col-sm-12" />
            </div>
        </div>
    </div>
    <div class="col-sm-12">
        <div class="control-group">
            <label class="control-label" style="line-height:38px;">代理前资源路径:</label>
            <div class="controls input-icon">
                <input id="oldserverurl" name="oldserverurl" class="form-control col-sm-12" th:value="${Res_ExtInterFaceService.oldserverurl}" />
            </div>
        </div>
    </div>
    <div class="col-sm-12">
        <div class="control-group">
            <label class="control-label" style="line-height:38px;">代理后资源路径:</label>
            <div class="controls input-icon">
                <input id="dailihouurl" readonly="readonly" name="dailihouurl" class="form-control col-sm-12" />
            </div>
        </div>
    </div>
    <input type="hidden" id="hidesbid" />
    <div style="margin-top:25px;float:right;">
        <button class="btn btn-primary" name="esbAgentbtn" onclick="esbSave()" type="button">
            <i class="fa fa-check"></i> 保存
        </button>
        <button class="btn btn-warning" type="button" onclick="colseLayer()">
            <i class="fa fa-remove"></i> 关闭
        </button>
    </div>
</div>
<script th:inline="javascript">
    /*<![CDATA[*/
    var resMainInfoId = [[${resMainInfoId}]];
    /*]]>*/
    $(function () {
        var content = [[${content}]];
        if (content == null) content = "";
        cheackForm("jkfwform");
        initEditor(content != "" ? htmlDecodeByRegExp(content) : "");
    });
 
    //实例化编辑器
    function initEditor(content) {
        UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
        UE.Editor.prototype.getActionUrl = function (action) {
            if (action == 'uploadimage' || action == 'uploadfile') {
                return "/res/common/uploadueditorfile";
            } else {
                return this._bkGetActionUrl.call(this, action);
            }
        };
        //建议使用工厂方法getEditor创建和引用编辑器实例,如果在某个闭包下引用该编辑器,直接调用UE.getEditor('editor')就能拿到相关的实例
        var ue = UE.getEditor('contents', {
            toolbars: [
                [
                    'source',
                    'undo', //撤销
                    'redo', //重做
                    '|',
                    'bold', //加粗
                    'italic', //斜体
                    'strikethrough', //删除线
                    'underline', //下划线
                    '|',
                    'forecolor', //字体颜色
                    'backcolor', //背景色
                    '|',
                    'insertorderedlist', //有序列表
                    'insertunorderedlist', //无序列表
                    '|',
                    'fontfamily', //字体
                    'fontsize', //字号
                    '|',
                    'justifyleft', //居左对齐
                    'justifyright', //居右对齐
                    'justifycenter', //居中对齐
                    'justifyjustify', //两端对齐
                    '|',
                    'link', //超链接
                    'unlink', //取消链接
                    '|',
                    'simpleupload' //单图上传
                ]
            ],
            initialContent: content, //初始化显示内容
            initialFrameHeight: 300, //初始化高度
            enableAutoSave: false //是否启用自动保存
        });
    }
 
    //解码
    function htmlDecodeByRegExp(str) {
        var s = "";
        if (str.length == 0) return "";
        s = str.replace(/&amp;/g, "&");
        s = s.replace(/&lt;/g, "<");
        s = s.replace(/&gt;/g, ">");
        s = s.replace(/&nbsp;/g, " ");
        s = s.replace(/&#39;/g, "\'");
        s = s.replace(/&quot;/g, "\"");
        return s;
    }
 
    //转码
    function htmlEncodeByRegExp(str) {
        var s = "";
        if (str.length == 0) return "";
        s = str.replace(/&/g, "&amp;");
        s = s.replace(/</g, "&lt;");
        s = s.replace(/>/g, "&gt;");
        s = s.replace(/ /g, "&nbsp;");
        s = s.replace(/\'/g, "&#39;");
        s = s.replace(/\"/g, "&quot;");
        return s;
    }
</script>
<script th:inline="javascript">
    var esbWebServiceHost = [[${esbWebServiceHost}]];
    var esbHost = [[${esbHost}]];
    var esbUrl = [[${esbUrl}]];
 
    //弹出ESB代理
    function showEsbInfo() {
        if ($("#servertype").val() == "") {
            alert("请选择服务分类!");
            return false;
        }
        $("#resEsbInfo input").val("");//清空文本框
        $("[name=esbAgentbtn]").show();//按钮显示
        var isService = $("#servertype").val() == "WebService" ? true : false;
        var oldserverurl = $("#oldserverurl").attr("value");//代理前路径
        layer.open({
            type: 1,
            title: 'ESB代理',
            shadeClose: true,
            shade: false,
            maxmin: false, //开启最大化最小化按钮
            area: ['720px', '470px'],
            content: jQuery("#resEsbInfo")
        });
        $("#servicetoken").val($("#token").val());
        var isChangeType = $("#servertype").val() != $("#hidservertype").val() ? true : false;
        $("#oldserverurl").val(oldserverurl);
        if (oldserverurl == "" || isChangeType || (isService && oldserverurl.indexOf("wsdl") == -1)) {
            $("#oldserverurl").val($("#serverurl").val());
            $("#fuwuurl").val($("#serverurl").val());
        } else {
            $("#fuwuurl").val(oldserverurl);
        }
        if ($("#hidagentserverurl").val() != "" && !isChangeType && (isService && oldserverurl.indexOf("wsdl") != -1)) {
            $("#fuwuurl").val($("#hidagentserverurl").val());
        }
        if (isService) {
            $("#selectPort").show();
            getWsPort($("#oldserverurl").val());
        } else {
            $("#selectPort").hide();
        }
        //上下文地址
        if ($("#hidcontextpath").val() != "" && !isChangeType && (isService && oldserverurl.indexOf("wsdl") != -1)) {
            $("#contexturl").val($("#hidcontextpath").val());
        } else {
            if (isService) {
                var surl = oldserverurl.indexOf("wsdl") != -1 ? oldserverurl : $("#serverurl").val();
                $("#contexturl").val("/" + resMainInfoId + "/" + surl.substring(surl.lastIndexOf('/') + 1, surl.lastIndexOf(".")));
            } else {
                var surl = $("#oldserverurl").val();
                var url = surl.indexOf("//") != -1 ? surl.split("://")[1].substring(surl.split("://")[1].indexOf("/"), surl.split("://")[1].length) : surl.substring(surl.indexOf("/"), surl.length);
                $("#contexturl").val((url.indexOf(resMainInfoId) != -1 ? "" : ("/" + resMainInfoId)) + url);
            }
        }
    }
 
    //ESB代理注册、更新
    function esbSave() {
        if ($("#contexturl").val() == "") {
            alert("上下文地址不能为空!");
            return false;
        }
        if ($("#contexturl").val().substring(0, 1) != "/") {
            alert("请输入正确的上下文地址!");
            return false;
        }
        var isService = $("#servertype").val() == "WebService" ? true : false;
        if (isService && $("#wsPort").val() == "") {
            alert("请选择版本!");
            return false;
        }
        if (isService) {
            if ($("#oldserverurl").val().indexOf(esbWebServiceHost) != -1) {
                alert("代理前资源路径错误,请重新输入!");
                return false;
            }
        } else {
            if ($("#oldserverurl").val().indexOf(esbHost) != -1) {
                alert("代理前资源路径错误,请重新输入!");
                return false;
            }
        }
        //检验上下文地址是否唯一(若为更新,上下文地址与原来一样则不用校验)
        if ($("#esbid").val() == "" || ($("#esbid").val() != "" && $("#contexturl").val() != $("#hidcontextpath").val())) {
            $.ajax({
                url: '/res/resExtInterFaceService/isExistContextPath',
                type: 'post',
                dataType: 'text',
                data: {
                    'contextpath': deleteSprit($("#contexturl").val()),
                },
                success: function (data) {
                    if (data > 0) {
                        alert("上下文地址已存在,请检查!");
                        return false;
                    } else {
                        submit();
                    }
                }
            });
        } else {
            submit();
        }
    }
 
    //提交
    function submit() {
        var lasturl = $("#oldserverurl").val().replace($("#fuwuurl").val(), "");
        lasturl += (lasturl.indexOf("?wsdl") == -1) ? ("?wsdl") : "";
        var newurl = "";
        if ($("#servertype").val() == "WebService") {
            newurl = esbWebServiceHost + $("#contexturl").val() + lasturl;
        } else {
            newurl = esbHost + $("#contexturl").val();
        }
        var url = esbUrl + "/esb/";
        var isPublic = $("#hidsharprotocol").val() == "完全公开" ? 1 : 0;
        if ($("#esbid").val() != "") {
            if ($("#servertype").val() == "WebService") {
                url += "updateArcgisServer?esbId=" + $("#esbid").val() + "&zyid=" + $("#resMainInfoId").val()
                    + "&serverUrl=" + encodeURI($("#oldserverurl").val()) + "&zyjc=" + encodeURI($("#zyjc").val()) + "&arcgisToken="
                    + encodeURI($("#servicetoken").val()) + "&contextPath=" + encodeURI($("#contexturl").val()) + "&urlid=&sublayer=&isWS=1&wsPort="
                    + $("#wsPort").val() + "&wsService=" + $("#wsService").val() + "&wsServiceTNS=" + $("#wsServiceTNS").val() + "&isPublic=" + isPublic;
            } else {
                url += "updateArcgisServer?esbId=" + $("#esbid").val() + "&zyid=" + $("#resMainInfoId").val()
                    + "&serverUrl=" + encodeURI(deleteSprit($("#oldserverurl").val())) + "&zyjc=" + encodeURI($("#zyjc").val()) + "&arcgisToken="
                    + encodeURI($("#servicetoken").val()) + "&contextPath=" + encodeURI(deleteSprit($("#contexturl").val())) + "&urlid=&isPublic=" + isPublic + "&isWS=0&sublayer=";
            }
        } else {
            if ($("#servertype").val() == "WebService") {
                url += "addArcgisServer?zyid=" + $("#resMainInfoId").val() + "&serverUrl=" + encodeURI($("#oldserverurl").val()) + "&zyjc=" + encodeURI($("#zyjc").val())
                    + "&arcgisToken=" + encodeURI($("#servicetoken").val()) + "&contextPath=" + encodeURI($("#contexturl").val())
                    + "&urlid=&sublayer=&isWS=1&wsPort=" + $("#wsPort").val() + "&wsService=" + $("#wsService").val() + "&wsServiceTNS=" + $("#wsServiceTNS").val() + "&isPublic=" + isPublic;
            } else {
                url += "addArcgisServer?zyid=" + $("#resMainInfoId").val() + "&serverUrl=" + encodeURI(deleteSprit($("#oldserverurl").val())) + "&zyjc=" + encodeURI($("#zyjc").val())
                    + "&arcgisToken=" + encodeURI($("#servicetoken").val()) + "&contextPath=" + encodeURI(deleteSprit($("#contexturl").val()))
                    + "&urlid=&isPublic=" + isPublic + "&isWS=0&sublayer=";
            }
        }
        $.ajax({
            url: url,
            type: "GET",
            dataType: 'jsonp',
            callback: "callback",
            success: function (data) {
                $("[name=esbAgentbtn]").hide();
                if (data.result == 0) {
                    var esbid = data.esbId;
                    $("#dailihouurl").val(deleteSprit(newurl));
                    $("#serverurl").val(deleteSprit(newurl));
                    updateEsbinfo(resMainInfoId, newurl, esbid);
                } else {
                    alert($("#esbid").val() != "" ? "更新失败" : "注册失败");
                }
            },
            error: function (e) {
                console.log(e);
            }
        });
    }
 
    //获取webservice
    function getWsPort(oldserverurl) {
        $.ajax({
            url: "/res/webservice/getWebServiceInfo?webServiceUrl=" + oldserverurl,
            type: 'get',
            async: false,
            success: function (result) {
                if (result != "") {
                    var data = eval("(" + result + ")");
                    var wsports = data.wsports;
                    $("#wsPort").empty().append("<option value=\"\">--请选择--</option>");
                    for (var i = 0; i < wsports.split(",").length; i++) {
                        $("#wsPort").append("<option>" + wsports.split(",")[i] + "</option>");
                    }
                    $("#wsService").val(data.servicename);
                    $("#wsServiceTNS").val(data.tns);
                }
            },
            error: function (e) {
                console.log("error");
            }
        });
    }
 
    //更新esb信息
    function updateEsbinfo(resMainInfoId, newurl, esbid) {
        $.ajax({
            url: '/res/resExtInterFaceService/insertSelectiveAndUpdate?resourceid=' + resMainInfoId,
            type: 'post',
            data: {
                serverurl: deleteSprit(newurl),
                oldserverurl: deleteSprit($("#oldserverurl").val()),
                esbid: esbid,
                token: $("#servicetoken").val(),
                contextpath: deleteSprit($("#contexturl").val()),
                agentserverurl: deleteSprit($("#fuwuurl").val())
            },
            success: function (data) {
                if (data == "1") {
                    alert($("#esbid").val() != "" ? "更新成功" : "注册成功");
                    $("#hidcontextpath").val($("#contexturl").val());
                    $("#hidagentserverurl").val($("#fuwuurl").val());
                    UE.getEditor('contents').destroy();
                    parent.FTabPages.resetTab();
                }
            },
            error: function (e) {
                alert(e.message);
            }
        });
    }
 
    //WEBAPI注册取掉斜杠
    function deleteSprit(str) {
        var restr = str;
        if (str != "" && str.length != 0 && str.substring(str.length - 1, str.length) == "/") {
            restr = str.substring(0, str.length - 1);
        }
        return restr;
    }
</script>