2
13693261870
2022-09-16 653761a31dfeb50dd3d007e892d69c90bf0cdafc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
<style type="text/css">
    td {
        border: 1px solid #ccc;
    }
 
    #tbGKList input {
        text-align: center;
        width: 100%;
        min-height: 30px;
    }
 
    #tbGKListYuanCheng tr {
        text-align: center;
        width: 100%;
        min-height: 30px;
    }
</style>
<form class="form-horizontal" id="wdsjform" method="post" 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>
        <input id="ncSyncStorageUrl" name="ncSyncStorageUrl" th:value="${ncSyncStorageUrl}" class="form-control col-sm-7" type="hidden" />
        <input id="readNcFileURL" name="readNcFileURL" th:value="${readNcFileURL}" class="form-control col-sm-7" type="hidden" />
        <div class="portlet-body">
            <div id="div_upload" style="text-align:center;display:none">
                <img src="/image/loading.gif" alt='正在上传' />
            </div>
            <div id="div_id" style="text-align:center;display:none">
                <input id="input_logs" value="1" type="hidden" />
                <img id="img_load" src="/image/loading.gif" alt='正在加载' />
                <a id="showlog" onclick="showLog();">正在分析中...</a>
                <div id="logs_div" style="overflow-y:auto;width:100%;height:150px;display:none">
                    <table style="border-spacing: 0px 0px;">
                        <tbody id="logs"></tbody>
                    </table>
                </div>
            </div>
            <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="sourcetype" name="sourcetype" class="form-control col-sm-9" required="" onchange="changeLX(this);">
                                <option value="">--请选择--</option>
                                <option th:selected="(${Res_ExtFileSource.sourcetype} == '文件')?'true':'false'" value="文件">文件</option>
                                <option th:selected="(${Res_ExtFileSource.sourcetype} == '文件夹')?'true':'false'" value="文件夹">文件目录</option>
                            </select>
                            <span class="input-warning tooltips" data-original-title="">
                                <i class="fa-warning-sign" style="display: none;margin-left:30px;"></i>
                            </span>
                            <input type="file" name="filepath" id="filesourcepath" style="display:none;" />
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="control-group">
                        <label class="control-label">存储方式</label>
                        <div class="controls input-icon">
                            <select id="storagemode" name="storagemode" class="form-control col-sm-9" onchange="changeCCFS(this);">
                                <option value="">--请选择--</option>
                                <option th:selected="(${Res_ExtFileSource.storagemode}=='本地')?'true':'false'" value="本地">本地</option>
                                <option th:selected="(${Res_ExtFileSource.storagemode}=='远程')?'true':'false'" value="远程">远程</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 wenjian">
                <div class="col-sm-6">
                    <div class="control-group">
                        <label class="control-label">文件名称</label>
                        <div class="controls input-icon">
                            <input th:value="${Res_ExtFileSource.filename}" id="filename" name="filename" type="text" class="form-control col-sm-8" />
                            <span class="input-warning tooltips" data-original-title="">
                                <i class="fa-warning-sign" style="display: none;margin-left:30px;"></i>
                            </span>
                            <input type="file" name="filepath2" id="filepath2" style="display:none;" onchange="uploadfile('filepath2')" />
                            <button type="button" id="filebutton" class="btn btn-primary wenjian" style="vertical-align: baseline;" onclick="openDialog('filepath2')">
                                <span class="fa fa-upload"></span> 上传
                            </button>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="control-group">
                        <label class="control-label">文档页数</label>
                        <div class="controls input-icon">
                            <input th:value="${Res_ExtFileSource.filepages}" id="filepages" name="filepages" type="text" class="form-control col-sm-9" />
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="control-group">
                        <label class="control-label">文件类型</label>
                        <div class="controls input-icon">
                            <select id="filetype" name="filetype" class="form-control col-sm-9">
                                <option value="">--请选择--</option>
                                <option th:each="item:${filetypelist}" th:value="${item.key}" th:text="${item.value}" th:selected="(${Res_ExtFileSource.filetype}==${item.key})?'true':'false'"></option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="control-group">
                        <label class="control-label">大小<span style="color: red;">*</span></label>
                        <div class="controls input-icon" th:switch="${unitConvert}">
                            <input th:case="1" th:value="${Res_ExtFileSource.filesize*1000}" type="text" id="filesize" name="filesize" class="form-control col-sm-7" required="" />
                            <input th:case="2" th:value="${Res_ExtFileSource.filesize}" type="text" id="filesize" name="filesize" class="form-control col-sm-7" required="" />
                            <input th:case="3" th:value="${Res_ExtFileSource.filesize/1000}" type="text" id="filesize" name="filesize" class="form-control col-sm-7" required="" />
                            <input th:case="4" th:value="${Res_ExtFileSource.filesize/(1000*1000)}" type="text" id="filesize" name="filesize" class="form-control col-sm-7" required="" />
                            <input th:case="5" value="" type="text" id="filesize" name="filesize" class="form-control col-sm-7" required="" />
                            <select id="unit" name="unit" class="form-control col-sm-2" style="width:15%">
                                <option th:selected="(${unit}=='bytes')?'true':'false'" vaule="bytes">B</option>
                                <option th:selected="(${unit}=='KB')?'true':'false'" value="KB">KB</option>
                                <option th:selected="(${unit}=='MB')?'true':'false'" value="MB">MB</option>
                                <option th:selected="(${unit}=='GB')?'true':'false'" value="GB">GB</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 yuancheng">
                <div class="col-sm-12">
                    <div class="control-group">
                        <label class="control-label">服务地址</label>
                        <div class="controls input-icon">
                            <input th:value="${Res_ExtFileSource.serverurl}" id="serverurl" name="serverurl" class="form-control col-sm-10" style="width:93%" />
                            <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" style="display: none;">
                <div class="col-sm-6">
                    <div class="control-group">
                        <label class="control-label">下载方式</label>
                        <div class="controls input-icon">
                            <select id="downloadmodel" name="downloadmodel" class="form-control col-sm-9" onchange="DownLoadModeChange(this)">
                                <option value="">--请选择--</option>
                                <option th:selected="(${Res_ExtFileSource.downloadmodel}=='FTP')?'true':'false'" value="FTP">FTP</option>
                                <option th:selected="(${Res_ExtFileSource.downloadmodel}=='HTTP')?'true':'false'" value="HTTP">HTTP</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 class="col-sm-6" id="httpType">
                    <div class="control-group">
                        <div class="control-group">
                            <label class="control-label">获取方式</label>
                            <div class="controls input-icon">
                                <select id="gettype" name="gettype" class="form-control col-sm-9">
                                    <option value="">--请选择--</option>
                                    <option th:selected="(${Res_ExtFileSource.gettype}=='跳转')?'true':'false'" value="跳转">跳转</option>
                                    <option th:selected="(${Res_ExtFileSource.gettype}=='代理')?'true':'false'" value="代理">代理</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>
            <div class="row" id="XiaZaiSet" style="display: none">
                <div class="col-sm-6">
                    <div class="control-group">
                        <label class="control-label">FTP用户名</label>
                        <div class="controls input-icon">
                            <input th:value="${Res_ExtFileSource.ftpusername}" id="ftpusername" name="ftpusername" type="text" class="form-control col-sm-9" />
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="control-group">
                        <label class="control-label">FTP密码</label>
                        <div class="controls input-icon">
                            <input th:value="${Res_ExtFileSource.ftppwd}" id="ftppwd" name="ftppwd" type="password" class="form-control col-sm-9" />
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div id="div_ncconfig" style="margin-left: 80px;display:none;">
            <button class="btn btn-primary" type="button" onclick="ncSet();" style="width:100px;">
                <i class="icon-save"></i>NC配置
            </button>
            <button class="btn btn-primary" onclick="storageSet()" type="button" style="width:100px;">
                <i class="icon-save"></i>入库配置
            </button>
        </div>
    </div>
    <div class="portlet box ltblue yuancheng">
        <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">
            <div style="width:100%;text-align: center;">
                <table id="tbGKListYuanCheng" style="width:80%;margin:auto">
                    <tr style="text-align:center;height:30px;width:100%;background-color: transparent;color:#999;">
                        <td style="width:5%;background-color:#DDD;color:#666;">序号</td>
                        <td style="width:30%;background-color:#DDD;color:#666;">文件名称</td>
                        <td style="width:20%;background-color:#DDD;color:#666">文件大小</td>
                        <td style="width:15%;background-color:#DDD;color:#666">数据生成</td>
                        <td style="width:15%;background-color:#DDD;color:#666">入库</td>
                    </tr>
                </table>
                <div style="height:20px;"></div>
            </div>
        </div>
    </div>
    <div class="portlet box ltblue wenjianjia">
        <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">
            <div style="width:100%;text-align: center;">
                <div style="text-align:center;height:40px;line-height:40px;font-size:15px;margin-top:5px;"></div>
                <table id="tbGKList" style="width:80%;margin:auto">
                    <tr style="text-align:center;height:30px;width:100%;background-color: transparent;color:#999;">
                        <td style="width:5%;background-color:#DDD;color:#666;">序号</td>
                        <td style="width:25%;background-color:#DDD;color:#666;">文件名称</td>
                        <td style="width:15%;background-color:#DDD;color:#666">文件大小</td>
                        <td style="width:15%;background-color:#DDD;color:#666">数据生成</td>
                        <td style="width:15%;background-color:#DDD;color:#666">入库</td>
                        <td style="width:25%;background-color:#DDD;color:#666">操作
                        </td>
                    </tr>
                    <tr th:each="file,fileStat:${filelist}">
                        <td style="padding: 2px">
                            <input type="text" th:value="${fileStat.count}" id="count" name="count" class="m-warp span12" style="border:0px;" />
                        </td>
                        <td style="padding: 2px">
                            <input type="text" th:value="${file.name}" id="upfilename" name="upfilename" class="m-warp span12" style="border:0px;" />
                        </td>
                        <td>
                            <input type="text" th:value="${file.size}" id="upfilesize" name="upfilesize" class="m-warp span12" style="border:0px;" />
                        </td>
                        <td>
                            <input type="text" th:value="${file.ncjson}" id="ncjson" name="ncjson" class="m-warp span12" style="border:0px;" />
                        </td>
                        <td>
                            <input type="text" th:value="${file.storageConfig}" id="storageConfig" name="storageConfig" class="m-warp span12" style="border:0px;" />
                        </td>
                        <td style="text-align:center;padding: 2px">
                            <button type="button" th:value="${file.name}" id="delectFile" class="btn btn-primary  btn-sm" style="vertical-align: baseline;" onclick="deletefile(this)">
                                <i class="fa"></i> 删除
                            </button>
                            <button class="btn btn-primary btn-sm" style="vertical-align: baseline;" type="button" onclick="dataGeneration(this);">
                                <i class="fa"></i>数据生成
                            </button>
                            <button class="btn btn-primary btn-sm" style="vertical-align: baseline;" name="storage" onclick="findParams(this);" type="button">
                                <i class="fa"></i>入库
                            </button>
                            <input type="file" id="upfilepath" name="upfilepath" style="display: none;" />
                        </td>
                    </tr>
                </table>
                <div style="padding: 10px">
                    <input type="file" name="upfilepath1" id="upfilepath1" style="display: none;" multiple="multiple" onchange="uploadfile('upfilepath1')" />
                    <button type="button" id="piliang" class="btn btn-primary" style="vertical-align: baseline;margin-left: 63%;" onclick="openDialog('upfilepath1')">
                        <i class="fa fa-upload"></i>批量上传
                    </button>
                    <button class="btn btn-primary" id="generation" type="button" onclick="dataAllGeneration();" style="width:80px;display:none!important;">
                        <i class="icon-save"></i>全部生成
                    </button>
                    <button class="btn btn-primary" id="allstorage" type="button" onclick="AllStorage();" style="width:80px;display:none!important;">
                        <i class="icon-save"></i>全部入库
                    </button>
                </div>
                <div style="height:20px;"></div>
            </div>
        </div>
    </div>
</form>
<form id="nc_form" style="display:none;" xmlns:th="http://www.w3.org/1999/xhtml">
    <div>
        <input id="uploadPath" name="uploadPath" th:value="${uploadPath}" class="form-control col-sm-7" type="hidden" />
        <input id="fileName" name="fileName" class="form-control col-sm-7" type="hidden" />
        <input id="resourceType" name="resourceType" th:value="2" class="form-control col-sm-7" type="hidden" />
        <input id="absolutePath" name="absolutePath" th:value="${absolutePath}" class="form-control col-sm-7" type="hidden" />
        <input id="lonName" name="lonName" class="form-control col-sm-7" type="hidden" />
        <input id="timeName" name="timeName" class="form-control col-sm-7" type="hidden" />
        <input id="uName" name="uName" class="form-control col-sm-7" type="hidden" />
        <input id="latName" name="latName" class="form-control col-sm-7" type="hidden" />
        <input id="vName" name="vName" class="form-control col-sm-7" type="hidden" />
        <input id="type" name="type" class="form-control col-sm-7" type="hidden" />
    </div>
</form>
<script>
    var isExit = true;
    $(function () {
        cheackForm("wdsjform");
        var filename = $("#filename").val();
        if (filename == '') {
            isExit = false;
        }
        if (filename.indexOf(".nc") != -1) {
            $("#div_ncconfig").css("display", "");
            $("#generation").css("display", "");
            $("#allstorage").css("display", "");
        }
        var xiazai = $("#downloadmodel").val();
        if (xiazai == "FTP") {
            $('#XiaZaiSet').css('display', '');
            $('#httpType').css("display", "none");
        } else if (xiazai == "HTTP") {
            $('#XiaZaiSet').css('display', 'none');
            $('#httpType').css("display", "");
        } else if (xiazai == null || xiazai == "") {
            $('#XiaZaiSet').css('display', 'none');
            $('#httpType').css("display", "none");
        }
 
        var leixing = $("#sourcetype").val();
        var ccfs = $("#storagemode").val();
        if (leixing == "文件") {
            $(".wenjianjia").css("display", "none");
            if (ccfs == "远程") {
                $('.wenjian').css("display", "none");
                $('.yuancheng').css("display", "");
            }
            if (ccfs == "本地") {
                $('.wenjian').css("display", "");
                $('.yuancheng').css("display", "none");
            }
        }
        if (leixing == "文件夹") {
            $('.wenjian').css("display", "none");
            if (ccfs == "远程") {
                $(".wenjianjia").css("display", "none");
                $('.yuancheng').css("display", "");
            }
            if (ccfs == "本地") {
                $(".wenjianjia").css("display", "");
                $('.yuancheng').css("display", "none");
            }
        }
        if (leixing == "" || leixing == null) {
            $('.wenjian').css("display", "none");
            $(".wenjianjia").css("display", "none");
        }
        if (ccfs == null || ccfs == "") {
            $('.yuancheng').css("display", "none");
        }
 
        var FuWuUrl = $("#serverurl").val();
        //判断服务地址有没有,如果有
 
        if (ccfs == "远程" && FuWuUrl != "") {
            $.ajax({
                url: '/res/resExtFileSource/getUrlList?url=' + FuWuUrl,
                type: 'post',
                dataType: 'text',
                data: {},
                success: function (data) {
                    var json = eval('(' + data + ')');
                    if (json.length == 1) {
                        if (json[0].filename == "无法获取该地址下的目录!") {
                            alert(json[0].filename);
                            return false;
                        }
                    }
                    for (var i = 0; i < json.length; i++) {
                        var html = "<tr>" +
                            "<td style=\"padding: 2px\">" + i + "</td >" +
                            "<td style=\"padding: 2px\">" + json[i].filename + "</td >" +
                            "<td style=\"padding: 2px\">" + json[i].size + "</td ></tr>";
 
                        $("#tbGKListYuanCheng").append(html);
                    }
                },
                error: function (e) {
                    alert(e.message);
                }
            });
        }
    });
 
    //新增行
    function AddFile() {
        var lg = $("#tbGKList").find("tr").length;
        var html =
            "<tr><td style=\"padding: 2px\">" +
            "<input type=\"text\" value=\"" + lg + "\" class=\"m-warp span12\" style=\"border:0px;\" />" +
            "</td>" +
            "<tr><td style=\"padding: 2px\">" +
            "<input type=\"text\" id=\"filename" + lg + "\" name=\"filename" + lg + "\" class=\"m-warp span12\" style=\"border:0px;\" />" +
            "</td>" +
            "<td style=\"padding: 2px\">" +
            "<input type=\"text\" id=\"filesize" + lg + "\" name=\"filesize" + lg + "\" class=\"m-warp span12\" style=\"border:0px;\" />" +
            "</td>" +
            "<td class='savebutton' style=\"text-align:center;padding: 2px\">" +
            "<input type=\"file\" id=\"filepath" + lg + "\" name=\"filepath" + lg + "\" style=\"display: none;\" multiple=\"true\" />" +
            "</td>" +
            "<td class='delbutton' style=\"text-align:center;display: none;padding: 2px\">" +
            "<button type=\"button\"   class=\"btn btn-primary  btn-sm\" style=\"vertical-align: baseline;\" onclick=\"deletefile(this)\">" +
            "<i class=\"fa\"></i> 删除" +
            "</button>" +
            "<input type=\"file\" id=\"upfilepath\" name=\"upfilepath\" style=\"display: none;\"/>" +
            "</td></tr>";
 
        $("#tbGKList").append(html);
    }
 
    function DownLoadModeChange(obj) {
        if ($(obj).val() == "FTP") {
            $('#XiaZaiSet').css('display', '');
            $('#httpType').css("display", "none");
        } else if ($(obj).val() == "HTTP") {
            $('#XiaZaiSet').css('display', 'none');
            $('#httpType').css("display", "");
        } else if ($(obj).val() == "") {
            $('#XiaZaiSet').css('display', 'none');
            $('#httpType').css("display", "none");
        }
    }
 
    function openDialog(id) {
        document.getElementById(id).click();
    }
 
    function uploadfile(id) {
        var resMainInfoId = $("#resMainInfoId").val();
        if(id == "upfilepath1" && resMainInfoId == "") {
            return;
        }
        $("#div_upload").css("display", "");
        setTimeout("upload_file('" + id + "')", 2000);//延迟二秒
    }
 
    function upload_file(id) {
        if (document.getElementById(id).value != '') {
            var formdata = new FormData();
            formdata.append('sourcetype', $("#sourcetype").val());
            formdata.append('resourceid', $("#resMainInfoId").val());
            var fileName = document.getElementById(id).value;
            formdata.append("json_filesNameArray", fileName);
            var files = document.getElementById(id).files;
            for (var i = 0; i < files.length; i++) {
                formdata.append("myFile", files[i]);   // 文件对象
            }
            $.ajax({
                url: "/res/resExtFileSource/uploadfile",
                type: "POST",
                data: formdata,
                cache: false,
                async: false,
                processData: false,  // 告诉jQuery不要去处理发送的数据
                contentType: false,  // 告诉jQuery不要去设置Content-Type请求头
                success: function (data) {
                    $("#div_upload").css("display", "none");
                    var json = eval('(' + data + ')');
 
                    if (json.result == '0') {
                        alert("上传失败");
                    } else if (json.result == '3') {
                        alert("上传失败,此文件名已存在!");
                    } else {
                        var names = json.name.replace("[", "").replace("]", "").split(",");
                        var finasizess = json.finasizes.replace("[", "").replace("]", "").split(",");
                        for (var j = 1; j < names.length + 1; j++) {
                            //添加html 因为原先有一个,所以要循环少一次
                            var lg = $("#tbGKList").find("tr").length;
                            var html = "<tr>" +
                                "<td style=\"padding: 2px\">" +
                                "<input type=\"text\"  class=\"m-warp span12\" style=\"border:0px;\" value=\"" + lg + "\"/>" +
                                "</td>" +
                                "<td style=\"padding: 2px\">" +
                                "<input type=\"text\" id=\"filename" + lg + "\" name=\"filename" + lg + "\" class=\"m-warp span12\" style=\"border:0px;\" value=\"" + names[j - 1].trim() + "\"/>" +
                                "</td>" +
                                "<td style=\"padding: 2px\">" +
                                "<input type=\"text\" id=\"filesize" + lg + "\" name=\"filesize" + lg + "\" class=\"m-warp span12\" style=\"border:0px;\" value=\"" + finasizess[j - 1].trim() + "\" />" +
                                "</td>" +
                                "<td class='savebutton' style=\"text-align:center;padding: 2px\">" +
                                "<input type=\"file\" id=\"filepath" + lg + "\" name=\"filepath" + lg + "\" style=\"display: none;\" multiple=\"true\" />" +
                                "</td>" +
                                "<td>" +
                                "<input type='text' value='' id='ncjson' name='ncjson' class='m-warp span12' style='border:0px;'  />" +
                                "</td>" +
                                "<td>" +
                                "<input type='text' value='' id='storageConfig' name='storageConfig' class='m-warp span12' style='border:0px;'  />" +
                                "</td>" +
                                "<td class='delbutton' style=\"text-align:center;display: none;padding: 2px\">" +
                                "<button type=\"button\" id='buttonname" + lg + "'  class=\"btn btn-primary btn-sm\" style=\"vertical-align: baseline;\" value=\"" + names[j - 1].trim() + "\" onclick=\"deletefile(this)\">" +
                                "<i class=\"fa\"></i> 删除" +
                                "</button>" +
                                "<input type=\"file\" id=\"upfilepath\" name=\"upfilepath\" style=\"display: none;\"/>" +
                                "</td></tr>";
 
                            $("#tbGKList").append(html);
                        }
                        $("#filename").val(names);
                        $('#filesize').val(json.size);
                        $('#serverurl').val(json.Path);
                        $('#unit').val(json.unit);
                        $(".delbutton").css("display", "");
                        $(".savebutton").css("display", "none");
                        if (isExit) {
                            clearStorage();
                            openDialog('addZiYuanWDSJSave');
                        }
                    }
                }
            });
        }
    }
 
    function changeLX(obj) {
        if ($(obj).val() == "文件夹") {
            $(".wenjian").css("display", "none");
            if ($("#storagemode").val() == "本地") {
                $(".wenjianjia").css("display", "");
            }
        } else if ($(obj).val() == "文件") {
            $(".wenjianjia").css("display", "none");
            if ($("#storagemode").val() == "本地") {
                $(".wenjian").css("display", "");
            }
        }
    }
 
    function changeCCFS(obj) {
        if ($(obj).val() == "本地") {
            $(".yuancheng").css("display", "none");
            if ($("#sourcetype").val() == "文件夹") {
                $(".wenjianjia").css("display", "");
            }
            if ($("#sourcetype").val() == "文件") {
                $(".wenjian").css("display", "");
            }
        }
        else if ($(obj).val() == "远程") {
            $(".yuancheng").css("display", "");
            $('#serverurl').val("");
            $(".wenjianjia").css("display", "none");
            $(".wenjian").css("display", "none");
        }
    }
 
    function fileSizeTest(size) {
        //如果字节数少于1024,则直接以B为单位,否则先除于1024,后3位因太少无意义
        if (size < 1024) {
            return size.toString() + "B";
        } else {
            size = size / 1024;
        }
        //如果原字节数除于1024之后,少于1024,则可以直接以KB作为单位
        //因为还没有到达要使用另一个单位的时候
        //接下去以此类推
        if (size < 1024) {
            return size.toString() + "KB";
        } else {
            size = size / 1024;
        }
        if (size < 1024) {
            //因为如果以MB为单位的话,要保留最后1位小数,
            //因此,把此数乘以100之后再取余
            size = size * 100;
            return (size / 100).toString() + "." + (size % 100).toString() + "MB";
        } else {
            //否则如果要以GB为单位的,先除于1024再作同样的处理
            size = size * 100 / 1024;
            return (size / 100).toString() + "." + (size % 100).toString() + "GB";
        }
    }
 
    function deletefile(obj) {
        var sourcetype = $("#leixing").val();
        var serverurl = $("#path").val();
        $.ajax({
            url: '/res/resExtFileSource/deletefile?resourceid=' + resMainInfoId,
            type: 'post',
            dataType: 'text',
            data: {'filepath': serverurl, 'sourcetype': sourcetype, 'name': $(obj).val()},
            success: function (data) {
                var json = eval('(' + data + ')');
                if (json.result == "true") {
                    alert("删除成功!");
                    parent.FTabPages.resetTab();
                } else {
                    alert("删除失败!");
                }
            },
            error: function (e) {
                alert(e.message);
            }
        })
    }
 
    function ncSet() {
        var resMainInfoId = $("#resMainInfoId").val();
        var sourcetype = $("#sourcetype").val();
        var resourceType;
        if (sourcetype == '文件') {
            resourceType = 1;//文件
            if (filename == '') {
                alert("文件名称不能为空");
                return;
            }
        } else {
            resourceType = 2;//文件夹
        }
        var filePath = $('#serverurl').val();
 
        var left = (screen.availWidth - 1200) / 2;//居中
        var top = (screen.availHeight - 600) / 2;//居中
        var ncSetUrl = "/res/ResManage/ResRegister/NcFileConfig?resourceType=" + resourceType + "&resourceid=" + resMainInfoId + "&filePath=" + filePath;
        window.open(ncSetUrl, "", "height=600,width=1200,left=" + left + ",top=" + top + "");
    }
 
    function storageSet() {
        var resMainInfoId = $("#resMainInfoId").val();
        var sourcetype = $("#sourcetype").val();
        var resourceType;
        if (sourcetype == '文件') {
            resourceType = 1;//文件
            if (filename == '') {
                alert("文件名称不能为空");
                return;
            }
        } else {
            resourceType = 2;//文件夹
        }
 
        var filePath = $('#serverurl').val();
 
        var left = (screen.availWidth - 1200) / 2;//居中
        var top = (screen.availHeight - 600) / 2;//居中
        var storageSetUrl = "/res/ResManage/ResRegister/StorageConfig?filePath=" + filePath + "&resourceType=" + resourceType + "&resourceid=" + resMainInfoId;
        window.open(storageSetUrl, "", "height=600,width=1200,left=" + left + ",top=" + top + "");
    }
 
    function dataAllGeneration() {
        $("#fileName").val("");
        $("#type").val(2);
        var storage_buts = $("#tbGKList").find("[name='storage']");
        for (var i = 0; i < storage_buts.length; i++) {
            var tr = $(storage_buts[i]).parent("td").parent("tr");
            var fileName = tr.find("[name='upfilename']").val();
            nc_files.push(fileName);
        }
        var resourceid = $("#resMainInfoId").val();
        $.ajax({
            type: 'post',
            url: '/res/ResManage/ResRegister/getNcConfig?resourceid=' + resourceid,
            success: function (data) {
                if (data == null || data == '') {
                    alert("暂无配置,请补充!");
                    $("#div_id").css("display", "none");
                } else {
                    getData(data);
                }
            },
            error: function () {
                alert("请求失败,网络异常!");
                $("#div_id").css("display", "none");
            }
        })
    }
 
    function dataGeneration(obj) {
        var tr = $(obj).parent("td").parent("tr");
        var fileName = tr.find("[name='upfilename']").val();
        nc_fileName = fileName;
        $("#fileName").val(fileName);
        $("#type").val(1);
        var resourceid = $("#resMainInfoId").val();
        $.ajax({
            type: 'post',
            url: '/res/ResManage/ResRegister/getNcConfig?resourceid=' + resourceid,
            success: function (data) {
                if (data == null || data == '') {
                    alert("暂无配置,请补充!");
                    $("#div_id").css("display", "none");
                } else {
                    $("#div_id").css("display", "");
                    getData(data);
                }
            },
            error: function () {
                alert("请求失败,网络异常!");
                $("#div_id").css("display", "none");
            }
        })
    }
 
    function getData(data) {
        data = JSON.parse(data);
        var resourceid = $("#resMainInfoId").val();
        $("#lonName").val(data.ncconfig[0].lonName);
        $("#timeName").val(data.ncconfig[0].timeName);
        $("#latName").val(data.ncconfig[0].latName);
        $("#vName").val(data.ncconfig[0].vName);
        $("#uName").val(data.ncconfig[0].uName);
        var readNcFileURL = $("#readNcFileURL").val();
        $('#nc_form').ajaxSubmit({
            url: readNcFileURL,
            type: 'post',
            dataType: 'text',
            success: function (data) {
                data = JSON.parse(data);
                var ncjsonattribute = JSON.stringify(data.ncjsonattribute);
                $("#div_id").css("display", "none");
                if (ncjsonattribute != null && ncjsonattribute != '') {
                    $.ajax({
                        url: "/res/ResManage/ResRegister/updateNcJsonPath?ncjsonpath=" + data.ncjsonpath + "&resourceid=" + resourceid + "&ncjsonattribute=" + encodeURIComponent(ncjsonattribute) + "&ncconfig=" + "",
                        type: 'post',
                        async: false,
                        dataType: 'text',
                        success: function (result) {
                            if (result > 0) {
                                alert("数据生成成功!");
                            }
                            $("#div_id").css("display", "none");
                            insertStorageRelation();
                        },
                        error: function () {
                            alert("数据生成成功,配置保存失败!");
                            $("#div_id").css("display", "none");
                        }
                    })
                } else {
                    alert("数据生成失败!");
                    $("#div_id").css("display", "none");
                }
            },
            error: function () {
                $("#div_id").css("display", "none");
                alert("请求服务失败,网络异常!");
            }
        });
    }
 
    function AllStorage() {
        storageNumber = 1;
        var storage_buts = $("#tbGKList").find("[name='storage']");
        for (var i = 0; i < storage_buts.length; i++) {
            storageButlen = storage_buts.length;
            findParams(storage_buts[index_totals]);
            break;
        }
    }
 
    function findParams(obj) {
        storage_botton = obj;
        var resourceid = $("#resMainInfoId").val();
        $.ajax({
            url: '/res/ResManage/ResRegister/findParams?resourceid=' + resourceid,
            type: 'post',
            success: function (data) {
                if (data == '') {
                    $("#div_id").css("display", "none");
                    alert("暂无入库配置信息,请先配置!");
                    return;
                } else {
                    $("#div_id").css("display", "");
                    var result = JSON.parse(data);
                    if (result.length > 0) {
                        for (var i = 0; i < result.length; i++) {
                            if (result[i].nc_data_var != null && result[i].nc_data_var != "" && result[i].nc_data_var != "undefined" && result[i].open_cbx == 1) {
                                params.push(JSON.stringify(result[i]));
                            }
                            if (result[i].uvariables != null && result[i].uvariables != "" && result[i].uvariables != "undefined" && result[i].open_cbx == 1) {
                                params.push(JSON.stringify(result[i]));
                            }
                        }
                        saveStorage(obj);
                        return;
                    }
                }
            },
            error: function () {
                alert("请求失败,网络异常!");
                $("#div_id").css("display", "none");
            }
        })
    }
 
    function saveStorage(obj) {
        $("#showlog").text("正在分析中...");
        $("#img_load").css("display", "");
        var param;
        var resourceid = $("#resMainInfoId").val();
        var tr = $(obj).parent("td").parent("tr");
        var fileName = tr.find("[name='upfilename']").val();
        storage_fileName = fileName;
        if (params.length > 0) {
            for (var j = 0; j < params.length; j++) {
                param = params[index_storage];
                break;
            }
        } else {
            alert("暂无启用配置!");
            $("#div_id").css("display", "none");
            return;
        }
        $.ajax({
            url: '/res/ResManage/ResRegister/saveStorage?fileName=' + fileName + '&param=' + encodeURIComponent(param) + '&resourceid=' + resourceid,
            type: 'post',
            dataType: 'text',
            async: true,
            success: function (data) {
                var result = JSON.parse(data);
                var falg = true;
                if (result.code == 1) {
                    scheduled = window.setInterval("syncSaveStorage('" + result.jobids[0] + "')", 3000);
                    return;
                } else {
                    if (index_totals == storageButlen - 1) {
                        if (result.message == "error") {
                            falg = false;
                            alert("入库失败!");
                            index_storage = 0;
                            params = new Array();
                            index_totals = 0;
                            storageNumber = 0;
                            $("#showlog").text("错误信息");
                            $("#img_load").css("display", "none");
                        }
                        if (falg) {
                            if (index_storage == params.length - 1) {
                                alert("入库成功!");
                                index_totals = 0;
                                storageNumber = 0;
                                params = new Array();
                                $("#div_id").css("display", "none");
                                saveStorageRelation();
                            } else {
                                index_storage++;
                                saveStorage(storage_botton);
                            }
                        }
                    } else {
                        index_totals++;
                        index_storage = 0;
                        params = new Array();
                        AllStorage();
                    }
                }
            }
        })
    }
 
    function syncSaveStorage(id) {
        var url = $("#ncSyncStorageUrl").val() + id + "?f=pjson";
        $.ajax({
            url: url,
            type: 'post',
            async: false,
            success: function (result) {
                var json = JSON.parse(result).messages;
                var jsontext = "";
                for (var i = 0; i < json.length; i++) {
                    jsontext += "<tr><td style='border:0px;'><span style='font-size:11pt;'>" + json[i].description + "</span></td></tr>";
                }
                $("#logs").html(jsontext);
                $("#logs_div").scrollTop($("#logs_div")[0].scrollHeight);
                if (result.indexOf("esriJobSucceeded") != -1) {
                    window.clearInterval(scheduled);    //清除定时器
                    if (storageNumber == 1) {    //全部入库
                        if (index_storage == params.length - 1) {
                            if (index_totals == storageButlen - 1) {
                                alert("入库成功!");
                                index_storage = 0;
                                index_totals = 0;
                                storageNumber = 0;
                                params = new Array();
                                $("#div_id").css("display", "none");
                                saveStorageRelation();
                            } else {
                                index_totals++;
                                index_storage = 0;
                                params = new Array();
                                saveStorageRelation();
                                AllStorage();
                            }
                        } else {
                            index_storage++;
                            saveStorage(storage_botton);
                        }
                    } else {
                        if (index_storage == params.length - 1) {
                            alert("入库成功!");
                            index_storage = 0;
                            index_totals = 0;
                            storageNumber = 0;
                            params = new Array();
                            $("#div_id").css("display", "none");
                            saveStorageRelation();
                        } else {
                            index_storage++;
                            saveStorage(storage_botton);
                        }
                    }
                }
                if (result.indexOf("esriJobFailed") != -1) {
                    window.clearInterval(scheduled);    //清除定时器
                    alert("入库失败!");
                    index_storage = 0;
                    index_totals = 0;
                    storageNumber = 0;
                    params = new Array();
                    $("#showlog").text("错误信息");
                    $("#img_load").css("display", "none");
                }
            },
            error: function () {
                window.clearInterval(scheduled);
                index_storage = 0;
                index_totals = 0;
                storageNumber = 0;
                params = new Array();
                $("#showlog").text("错误信息");
                $("#img_load").css("display", "none");
                alert("请求失败,网络异常!");
            }
        })
    }
 
    function showLog() {
        var input_logs = $("#input_logs").val();
        if (input_logs == '1') {
            $("#logs_div").css("display", "");
            $("#input_logs").val(2);
        } else {
            $("#logs_div").css("display", "none");
            $("#input_logs").val(1);
        }
    }
 
    function clearStorage() {
        var resMainInfoId = $("#resMainInfoId").val();
        $.ajax({
            type: 'post',
            url: '/res/ResManage/ResRegister/clearConfig?resourceid=' + resMainInfoId + "&type=3"
        })
    }
 
    function saveStorageRelation() {
        var resourceid = $("#resMainInfoId").val();
        $.ajax({
            type: 'post',
            url: '/res/ResManage/ResRegister/saveStorageRelation?resourceid=' + resourceid + "&filename=" + storage_fileName
        })
    }
 
    function insertStorageRelation() {
        var resourceid = $("#resMainInfoId").val();
        if (nc_files.length > 0) {
            for (var i = 0; i < nc_files.length; i++) {
                $.ajax({
                    type: 'post',
                    url: '/res/ResManage/ResRegister/insertStorageRelation?resourceid=' + resourceid + "&filename=" + nc_files[i]
                })
            }
            nc_files = new Array();
        } else {
            $.ajax({
                type: 'post',
                url: '/res/ResManage/ResRegister/insertStorageRelation?resourceid=' + resourceid + "&filename=" + nc_fileName
            })
        }
    }
 
    var params = new Array();    //存所有的入库配置
    var index_storage = 0;//当前入库到第几条 index_storage=params.length-1结束入库
    var storage_botton;//当前入库对象,主要获取文件名
    var scheduled;//定时器
    var storageButlen = 1;//入库按钮总个数
    var index_totals = 0;//当前入库到第几个文件
    var storageNumber = 0;//0代表点击入库 1代表点击全部入库
    var storage_fileName = "";//当前入库文件名
    var nc_files = new Array();//全部数据生成文件名
    var nc_fileName = "";//当前数据生成文件名
</script>