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
package com.landtool.lanbase.modules.res.controller;
 
import java.sql.Timestamp;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
 
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.landtool.lanbase.common.annotation.LogAction;
import com.landtool.lanbase.common.utils.Result;
import com.landtool.lanbase.config.SysTemPropertyConfig;
import com.landtool.lanbase.modules.log.service.LogActionService;
import com.landtool.lanbase.modules.res.entity.Res_Catalog;
import com.landtool.lanbase.modules.res.entity.Res_MainInfo;
import com.landtool.lanbase.modules.res.service.ResCatalogService;
import com.landtool.lanbase.modules.res.service.ResMainInfoService;
import com.landtool.lanbase.modules.sys.controller.AbstractController;
 
/**
 * @Date: 2018-03-03 8:50
 * @Description:资源目录编目管理
 */
 
@Controller
@RequestMapping("/res")
public class ResCatalogController extends AbstractController {
    @Autowired
    private ResMainInfoService resMainInfoService;
    
    @Autowired
    private ResCatalogService resCatalogService;
    
    @Autowired
    private SysTemPropertyConfig sysConfig;
 
    @Autowired
    private LogActionService logActionService;
    
    /**
     * @Description: 后台访问目录编目管理页面
     * @author
     * @date 2018/3/19 16:29
     */
    /**@RequestMapping("/ResManage/ResRegister/IndexCatalog") public String IndexCatalog(Model model) {
    model.addAttribute("pubzyWebRoot", sysConfig.getPubzyWebRoot());
    return "ResManage/ResCatalog/Index";
    }
     */
    
    /**
     * @Description: 后台访问目录编目管理页面(新)
     */
    @RequestMapping("manage/catalog/index")
    public String CatalogIndex(Model model) {
        model.addAttribute("pubzyWebRoot", sysConfig.getPubzyWebRoot());
        model.addAttribute("systemName", sysConfig.getAppFullName());
        return "manage/catalog/index";
    }
    
    /**
     * @Description: 查询目录结构
     */
    @ResponseBody
    @RequiresPermissions("res:catalog:edit")
    @RequestMapping("manage/catalog/selectmulu")
    public String selectDirectoryStructure(int id) {
        List<Res_Catalog> resCatalogList = resCatalogService.selectResCatalogToParentid(id);
        String resCatalogJson = "";
 
        for (Res_Catalog resCatalog : resCatalogList) {
            int childCount = resCatalogService.selectResCatalogIsExistsSon(resCatalog.getCatlogid(),null);
            resCatalogJson += (resCatalogJson.length() > 0 ? "," : "") + "{id:" + resCatalog.getCatlogid() + ", name:'" + resCatalog.getTitle()
                    + "', pId:" + resCatalog.getParentid()
                    + ", rpId:" + resCatalog.getParentid();
            if(resCatalog.getIcon()==null || resCatalog.getIcon().equals("")){
                resCatalogJson +=(childCount > 0 ? ",isParent:true,iconOpen:'/image/classicons/folderOpen.png',iconClose:'/image/classicons/folder.png'" : ",icon:'/image/classicons/defaulticon.png'")
                    + ", code: '" + resCatalog.getCatlogcode() + "'}";
            }else {
                resCatalogJson +=((childCount > 0 ? ",isParent:true":"")+",icon:'"+"/uploadPath/"+resCatalog.getIcon())
                        + "', code: '" + resCatalog.getCatlogcode()+ "'}";
            }
        }
        return "[" + resCatalogJson + "]";
    }
    
    /**
     * @Description: 获取目录信息
     */
    @ResponseBody
    @RequiresPermissions("res:catalog:edit")
    @RequestMapping("manage/catalog/getcataloginfo")
    public Result getCatalogInfo(int id) {
        Res_Catalog resCatalog = resCatalogService.getResCatalogInfoById(id);
        String result = "";
        Map<String, Object> map = new HashMap<>();
        if (resCatalog == null) {
            map.put("success",true);
            map.put("id",0);
            map.put("name","资源目录");
            map.put("no",0);
            map.put("index", null);
            map.put("beizhu", null);
            map.put("icon",null);
//            result = "{ success: true,id:\"0\",name:\"资源目录\",no:0,index:null,beizhu:null,icon:null}";
        } else {
            map.put("success",true);
            map.put("id", resCatalog.getCatlogid());
            map.put("name", resCatalog.getTitle());
            map.put("no", resCatalog.getCatlogcode());
            map.put("index", resCatalog.getDescription());
            map.put("beizhu", resCatalog.getRemark());
            map.put("icon",resCatalog.getIcon());
//            result = "{ success: true,id:\"" + resCatalog.getCatlogid() + "\",name:\"" + resCatalog.getTitle() + "\",no:\"" + resCatalog.getCatlogcode() + "\",index:\"" + resCatalog.getDescription() + "\",beizhu:\"" + resCatalog.getRemark() +"\",icon:\"" + resCatalog.getIcon() + "\"}";
        }
        return Result.ok().put("result",map);
    }
    
    /**
     * @Description: 新增子集页面
     */
    @ResponseBody
    @RequestMapping("manage/catalog/addchildren")
    public String addChildren(int id) {
        Res_Catalog resCatalog = resCatalogService.getResCatalogInfoById(id);
        String orderid = "";
        if (resCatalog == null) {
            //根目录的排序ID为0,需要特殊处理
            orderid = resCatalogService.getMaxCATLOGCODEFromMainIndex(0);
            if (orderid == null) {
                orderid = "01";
            } else {
                int newOrderid = Integer.valueOf(orderid) + 1;
                if(newOrderid < 10) {
                    orderid = "0" + String.valueOf(newOrderid);
                } else {
                    orderid = String.valueOf(newOrderid);
                }
            }
        } else {
            orderid = resCatalogService.getMaxCATLOGCODE(id);
            if (orderid == null) {
                orderid = String.valueOf(resCatalog.getCatlogcode()) + "01";
            } else {
                int newOrderid = Integer.valueOf(orderid) + 1;
                if(orderid.startsWith("0")) {
                    orderid = "0" + String.valueOf(newOrderid);
                } else {
                    orderid = String.valueOf(newOrderid);
                }
            }
        }
        Object FatherName = "";
        if (id == 0) {
            //根目录的排序ID为0,需要特殊处理
            FatherName = "资源目录";
        } else {
            FatherName = resCatalog.getTitle();
        }
        String resCatalogJson = "";
        if (resCatalog == null) {
            resCatalogJson += "{id:" + 0 + ", name:'" + FatherName + "', pId:" + 0 + ", oId:'" + orderid + "'}";
        } else {
            resCatalogJson += "{id:" + resCatalog.getCatlogid() + ", name:'" + FatherName + "', pId:" + resCatalog.getParentid() + ", oId:'" + orderid + "'}";
        }
        //查询当前父节点的信息 返回到前台
        return resCatalogJson;
    }
    
    /**
     * @Description: 新增子目录方法
     */
    @ResponseBody
    @RequiresPermissions("res:catalog:edit")
    @RequestMapping("manage/catalog/insert")
    @LogAction("资源管理,资源编目,资源目录新增(子级),新增")
    public String insert(Res_Catalog model) {
        //录入人暂时名字,以后修改
        model.setCreateuser(getLoginName());
        Timestamp audittime = new Timestamp(new Date().getTime());
        //生成当前时间
        model.setCreatedate(audittime);
        String orderid = "";
        if (model.getParentid() == 0) {
            //根目录的排序ID为0,需要特殊处理
            orderid = resCatalogService.getMaxOrderIdFromMainIndex(model.getParentid());
            if (orderid == null) {
                orderid = "1";
            } else {
                int newOrderid = Integer.valueOf(orderid) + 1;
                orderid = String.valueOf(newOrderid);
            }
        } else {
            orderid = resCatalogService.getMaxOrderId(model.getParentid());
            //获取目标目录最大的排序ID
            if (orderid == null) {
                Res_Catalog resCatalog = resCatalogService.getResCatalogInfoById(model.getParentid());
                orderid = String.valueOf(resCatalog.getOrderid()) + "01";
            } else {
                int newOrderid = Integer.valueOf(orderid) + 1;
                orderid = String.valueOf(newOrderid);
            }
        }
        model.setOrderid(Integer.valueOf(orderid));
        int result = resCatalogService.insertSelective(model);
        if (result == 1) {
            return "新增成功";
        } else {
            return "失败";
        }
    }
    
    /**
     * @Description: 目录修改页面
     */
    @ResponseBody
    @RequiresPermissions("res:catalog:edit")
    @RequestMapping("manage/catalog/edit")
    public Result edit(int id) {
        Res_Catalog resCatalog = resCatalogService.getResCatalogInfoById(id);
        Res_Catalog resCatalogf = resCatalogService.getResCatalogInfoById(resCatalog.getParentid());
        //查询需要修改目录的信息返回
        String resCatalogJson = "";
        Map<String,Object> map = new HashMap<>();
 
        map.put("id", resCatalog.getCatlogid());
        map.put("name", resCatalog.getTitle());
        map.put("firstPY", resCatalog.getPingyinfiirst());
        map.put("remark", resCatalog.getRemark());
        map.put("icon", resCatalog.getIcon());
        map.put("oId", resCatalog.getCatlogcode());
        map.put("descrip", resCatalog.getDescription());
 
        if (resCatalogf != null) {
 
            map.put("Pid", resCatalog.getParentid());
            map.put("fname", resCatalogf.getTitle());
//            resCatalogJson += "{id:" + resCatalog.getCatlogid() + ", name:'" + resCatalog.getTitle() + "', Pid:" + resCatalog.getParentid() + ", firstPY:'" + resCatalog.getPingyinfiirst() + "', remark:'" + resCatalog.getRemark() + "', icon:'" + resCatalog.getIcon() + "', descrip:'" + resCatalog.getDescription() + "', fname:'" + resCatalogf.getTitle() + "', oId:'" + resCatalog.getCatlogcode() + "'}";
        } else {
            map.put("Pid", 0);
            map.put("fname", "资源目录");
 
            resCatalogJson += "{id:" + resCatalog.getCatlogid() + ", name:'" + resCatalog.getTitle() + "', Pid:" + 0 + ", firstPY:'" + resCatalog.getPingyinfiirst() + "', remark:'" + resCatalog.getRemark() + "', icon:'" + resCatalog.getIcon() + "', descrip:'" + resCatalog.getDescription() + "', fname:'" + "资源目录" + "', oId:'" + resCatalog.getCatlogcode() + "'}";
        }
        return Result.ok().put("result",map);
    }
    
    /**
     * @Description: 目录修改方法
     */
    @ResponseBody
    @RequiresPermissions("res:catalog:edit")
    @RequestMapping("manage/catalog/saveedit")
    @LogAction("资源管理,资源编目,资源目录修改,修改")
    public String saveEdit(Res_Catalog model) {
        int result = resCatalogService.updateByPrimaryKeySelective(model);
        if (result == 1) {
            return "修改成功";
        } else {
            return "修改失败";
        }
    }
 
 
    /**
     * 检查删除的目录下是都存在资源
     */
    @ResponseBody
    @RequestMapping("manage/catalog/isDelete")
    public String isDelete(int id) {
        Integer resMainInfos = resCatalogService.selectMuLuZiYuanCount(id);
        if (resMainInfos > 0) {
            return "-1";
        }
        else {
            logActionService.saveLogAction(("资源管理,资源编目,资源目录删除,删除"));
            int result = resCatalogService.deleteByPrimaryKey(id);
            if (result == 1) {
                return "删除成功";
            } else {
                return "删除失败";
            }
        }
    }
 
    /**
     * @Description: 目录删除方法
     */
    @ResponseBody
    @RequiresPermissions("res:catalog:edit")
    @RequestMapping("manage/catalog/delete")
//    @LogAction("资源管理,资源编目,资源目录删除,删除")
    public String delete(int id) {
        logActionService.saveLogAction(("资源管理,资源编目,资源目录删除,删除"));
        int childCount = resCatalogService.selectResCatalogIsExistsSon(id,null);
        if (childCount > 0) {
            DeleteChildNode(id);
        }
        List<Res_MainInfo> resMainInfos = resCatalogService.selectMuLuZiYuanList(id);
        if (resMainInfos != null) {
            for(Res_MainInfo resMainInfo : resMainInfos ) {
                resMainInfoService.deleteByPrimaryKey(resMainInfo.getResourceid());
            }
        }
        int result = resCatalogService.deleteByPrimaryKey(id);
        if (result == 1) {
            return "删除成功";
        } else {
            return "删除失败";
        }
    }
    
    public void DeleteChildNode(int id) {
        List<Res_Catalog> List = resCatalogService.selectResCatalogToParentid(id);
        for (Res_Catalog Model : List) {
            int childCount = resCatalogService.selectResCatalogIsExistsSon(Model.getCatlogid(),null);
            if (childCount > 0) {
                DeleteChildNode(Model.getCatlogid());
            }
            resCatalogService.deleteByPrimaryKey(Model.getCatlogid());
        }
    }
    
    /**
     * @Description: 新增同级页面
     */
    @ResponseBody
    @RequiresPermissions("res:catalog:edit")
    @RequestMapping("manage/catalog/addbrother")
    @LogAction("资源管理,资源编目,资源目录新增(同级),新增")
    public String addBrother(int id) {
        Res_Catalog resCatalog = resCatalogService.getResCatalogInfoById(id);
        int pid = resCatalog.getParentid();
        String orderid = "";
        if (pid == 0) {
            //根目录的排序ID为0,需要特殊处理
            orderid = resCatalogService.getMaxCATLOGCODEFromMainIndex(pid);
        } else {
            orderid = resCatalogService.getMaxCATLOGCODE(pid);
        }
        if (orderid == null) {
            orderid = String.valueOf(resCatalog.getCatlogcode())+"01";
        } else {
            int newOrderid = Integer.valueOf(orderid) + 1;
            if(newOrderid < 10) {
                orderid = "0" + String.valueOf(newOrderid);
            } else {
                orderid = String.valueOf(newOrderid);
            }
        }
        Object FatherName = "";
        if (pid == 0) {
            //根目录的排序ID为0,需要特殊处理
            FatherName = "资源目录";
        } else {
            FatherName = resCatalogService.getResCatalogInfoById(resCatalog.getParentid()).getTitle();
        }
        String resCatalogJson = "";
        resCatalogJson += "{id:" + resCatalog.getCatlogid() + ", name:'" + FatherName + "', pId:" + resCatalog.getParentid() + ", oId:'" + orderid + "'}";
        //查询当前父节点的信息 返回到前台
        return resCatalogJson;
    }
    
    /**
     * @Description: 获取目录以及所属资源列表
     */
    @ResponseBody
    @RequiresPermissions("res:catalog:edit")
    @RequestMapping("manage/catalog/selectmuluandziyuan")
    public String selectMuLuAndZiYuan(int id) {
        //先根据父节点ID获取子目录
        List<Res_Catalog> resCatalogList = resCatalogService.selectResCatalogToParentid(id);
        String resCatalogJson = "";
        List<Map<String, Object>> maps = new LinkedList<>();
        for (Res_Catalog resCatalog : resCatalogList) {
            int childCount = resCatalogService.selectResCatalogIsExistsSon(resCatalog.getCatlogid(),null);
 
            Map<String, Object> map = new HashMap<>();
            map.put("id", resCatalog.getCatlogid());
            map.put("name", resCatalog.getTitle());
            map.put("pId", resCatalog.getParentid());
            map.put("isParent", true);
            map.put("check", true);
            map.put("rpId", resCatalog.getParentid());
            map.put("iconOpen", "/image/classicons/folderOpen.png");
            map.put("iconClose", "/image/classicons/folder.png");
            maps.add(map);
 
//            resCatalogJson += (resCatalogJson.length() > 0 ? "," : "")
//                    + "{id:" + resCatalog.getCatlogid()
//                    + ", name:'" + resCatalog.getTitle()
//                    + "', pId:" + resCatalog.getParentid()
//                    + ",isParent:true,check:true,rpId:"+ resCatalog.getParentid() + (",iconOpen:'/image/classicons/folderOpen.png',iconClose:'/image/classicons/folder.png'") + "}";
        }
        //获取完子目录后获取资源
        List<Res_MainInfo> ZyList = resMainInfoService.selectZyByMuLuId(id);
        for (Res_MainInfo Zymodel : ZyList) {
            Map<String, Object> map = new HashMap<>();
            map.put("id", Zymodel.getResourceid());
            map.put("name", Zymodel.getTitle());
            map.put("pId", Zymodel.getCatlogid());
            map.put("rpId", Zymodel.getCatlogid());
            map.put("icon", "/image/classicons/"+Zymodel.getResourceclass()+".png");
            maps.add(map);
 
//            resCatalogJson += (resCatalogJson.length() > 0 ? "," : "") + "{id:" + Zymodel.getResourceid() + ", name:'" + Zymodel.getTitle() + "', pId:" + Zymodel.getCatlogid() + ", rpId:" + Zymodel.getCatlogid() + ",icon:'/image/classicons/"+Zymodel.getResourceclass()+".png'" +"}";//update:dsh(2018/12/05)
        }
        
        return JSON.toJSONString(maps, SerializerFeature.WriteMapNullValue);
    }
    
    /**
     * @Description: 资源位置调整方法
     */
    @ResponseBody
    @RequiresPermissions("res:catalog:edit")
    @RequestMapping("manage/catalog/merge")
    @LogAction("资源管理,资源编目,资源目录修改(资源调整),修改")
    public String merge(String ids, String fid) {
        String[] idArr = ids.split(";");
        //不修改目录编码,只修改目录ID会导致有些功能的查询只根据目录编码查询出错
        //同一资源的目录ID和目录编码会不一致  alert ykm 2018/12/28
        Res_Catalog resCatalog = resCatalogService.selectByPrimaryKey(Integer.valueOf(fid));
        for (String zyid : idArr) {
            Res_MainInfo Zymodel = resMainInfoService.selectByPrimaryKey(Integer.valueOf(zyid));
            Zymodel.setCatlogcode(resCatalog.getCatlogcode());
            Zymodel.setCatlogid(Integer.valueOf(fid));
            int result = resMainInfoService.updateByPrimaryKeySelective(Zymodel);
        }
        return "调整成功";
    }
    
    /**
     * @Description: 目录拖拉方法
     */
    @ResponseBody
    @RequestMapping("manage/catalog/changebianmu")
    @LogAction("资源管理,资源编目,资源目录修改(拖拉),修改")
    public String changeBianMu(String id, String newfid) {
        changeBianMuMethod(id, newfid);
        return "调整成功!";
    }
    
    /**
     * @Description: 主目录调整方法
     */
    public void changeBianMuMethod(String id, String newfid) {
        Res_Catalog model = resCatalogService.getResCatalogInfoById(Integer.valueOf(id));
        Integer rpid = model.getParentid();
        Res_Catalog modelf = new Res_Catalog();
        if (newfid.equals("0")) {
            modelf.setTitle("资源目录");
            modelf.setOrderid(0);
            modelf.setCatlogcode("0");
        } else {
            modelf = resCatalogService.getResCatalogInfoById(Integer.valueOf(newfid));
        }
        model.setParentid(Integer.valueOf(newfid));
        //首先更新新的父节点
        String neworderid = "";
        if (model.getParentid() == 0) {
            //根目录的排序ID为0,需要特殊处理
            neworderid = resCatalogService.getMaxOrderIdFromMainIndex(model.getParentid());
        } else {
            neworderid = resCatalogService.getMaxOrderId(model.getParentid());
        }
        if (neworderid == null) {
            //如果当前目录下无子目录,则父目录排序+01
            Res_Catalog resCatalog = resCatalogService.getResCatalogInfoById(model.getParentid());
            neworderid = String.valueOf(modelf.getOrderid()) + "01";
        } else {
            //有子目录则+1
            int newOrderid = Integer.valueOf(neworderid) + 1;
            neworderid = String.valueOf(newOrderid);
        }
        //目录编码同样处理
        String newcatlogcode = "";
        if (model.getParentid() == 0) {
            newcatlogcode = resCatalogService.getMaxCATLOGCODEFromMainIndex(model.getParentid());
            if (newcatlogcode == null) {
                newcatlogcode = "01";
            } else {
                int newCid = Integer.valueOf(newcatlogcode) + 1;
                newcatlogcode = "0" + String.valueOf(newCid);
            }
        } else {
            newcatlogcode = resCatalogService.getMaxCATLOGCODE(model.getParentid());
            if (newcatlogcode == null) {
                newcatlogcode = String.valueOf(modelf.getCatlogcode()) + "01";
            } else {
                int newCode = Integer.valueOf(newcatlogcode) + 1;
                newcatlogcode = "0" + String.valueOf(newCode);
            }
        }
        model.setCatlogcode(newcatlogcode);
        model.setOrderid(Integer.valueOf(neworderid));
        resCatalogService.updateByPrimaryKeySelective(model);
        List<Res_MainInfo> ZyList = resMainInfoService.selectZyByMuLuId(model.getCatlogid());
        //更新本目录下所属资源的编码
        for (Res_MainInfo ChZymodel : ZyList) {
            ChZymodel.setCatlogcode(model.getCatlogcode());
            resMainInfoService.updateByPrimaryKeySelective(ChZymodel);
        }
        //如果有子目录,则更新子目录
        int childCount = resCatalogService.selectResCatalogIsExistsSon(model.getCatlogid(),null);
        if (childCount > 0) {
            updateChildNode(model.getCatlogid());
        }
        //更新完子目录后,更新原目录的编码与排序,防止错乱
        updateOriginal(rpid);
    }
    
    /**
     * @Description: 子目录调整方法
     */
    public void updateChildNode(int id) {
        List<Res_Catalog> List = resCatalogService.selectResCatalogToParentid(id);
        for (Res_Catalog Cmodel : List) {
            //循环处理每个子目录的编码和排序
            Res_Catalog modelf = resCatalogService.getResCatalogInfoById(id);
            String newcatlogcode = resCatalogService.getMaxCATLOGCODE(modelf.getCatlogid());
            if (newcatlogcode == null) {
                newcatlogcode = String.valueOf(modelf.getCatlogcode()) + "01";
            } else {
                String Pcatlogcode = String.valueOf(modelf.getCatlogcode());
                if (newcatlogcode.length() > Pcatlogcode.length()) {
                    newcatlogcode = newcatlogcode.substring(0, Pcatlogcode.length());
                } else {
                    Pcatlogcode = Pcatlogcode.substring(0, newcatlogcode.length());
                }
                if (newcatlogcode.equals(Pcatlogcode)) {
                    newcatlogcode = "0" + String.valueOf(Integer.valueOf(resCatalogService.getMaxCATLOGCODE(modelf.getCatlogid())) + 1);
                } else {
                    newcatlogcode = String.valueOf(modelf.getCatlogcode()) + "01";
                }
            }
            Cmodel.setCatlogcode(newcatlogcode);
            String neworderid = resCatalogService.getMaxOrderId(modelf.getCatlogid());
            if (neworderid == null) {
                neworderid = String.valueOf(modelf.getOrderid()) + "01";
            } else {
                String Porderid = String.valueOf(modelf.getOrderid());
                if (neworderid.length() > Porderid.length()) {
                    neworderid = neworderid.substring(0, Porderid.length());
                } else {
                    Porderid = Porderid.substring(0, neworderid.length());
                }
                if (neworderid.equals(Porderid)) {
                    neworderid = String.valueOf(Integer.valueOf(resCatalogService.getMaxOrderId(modelf.getCatlogid())) + 1);
                } else {
                    neworderid = String.valueOf(modelf.getOrderid()) + "01";
                }
            }
            Cmodel.setOrderid(Integer.valueOf(neworderid));
            resCatalogService.updateByPrimaryKeySelective(Cmodel);
            List<Res_MainInfo> ZyList = resMainInfoService.selectZyByMuLuId(Cmodel.getCatlogid());
            //更新所属资源的编码
            for (Res_MainInfo ChZymodel : ZyList) {
                ChZymodel.setCatlogcode(Cmodel.getCatlogcode());
                resMainInfoService.updateByPrimaryKeySelective(ChZymodel);
            }
            int childCount = resCatalogService.selectResCatalogIsExistsSon(Cmodel.getCatlogid(),null);
            if (childCount > 0) {
                //如果子目录下还有下级目录,则再次循环此方法
                updateChildNode(Cmodel.getCatlogid());
            }
        }
    }
    
    /**
     * @Description: 原目录调整方法
     */
    public void updateOriginal(int id) {
        Res_Catalog model = new Res_Catalog();
        if (id == 0) {
            model.setTitle("资源目录");
            model.setOrderid(Integer.valueOf(0));
            model.setCatlogcode("");
        } else {
            model = resCatalogService.getResCatalogInfoById(id);
        }
        //预先定义目录的第一个编码和排序ID
        String minCode = String.valueOf(model.getCatlogcode());
        minCode = minCode + "01";
        String minOrderid = String.valueOf(model.getOrderid());
        minOrderid = minOrderid + "01";
        int i = 0;
        List<Res_Catalog> Childrens = resCatalogService.selectResCatalogToParentid(id);
        //查询目录下所有子目录
        for (Res_Catalog item : Childrens) {
            if (i == 0) {
                //第一个子目录使用定义的编码和排序ID
                item.setCatlogcode(minCode);
                item.setOrderid(Integer.valueOf(minOrderid));
                resCatalogService.updateByPrimaryKeySelective(item);
                i++;
            } else {
                //第二个以后的目录则是在第一个目录的编码和排序ID基础上+1
                String newCode = "";
                if (id == 0) {
                    newCode = resCatalogService.getMinCATLOGCODEFromMainIndex(id);
                    newCode = "0" + String.valueOf(Integer.valueOf(newCode) + i);
                } else {
                    newCode = resCatalogService.getMinCATLOGCODE(id);
                    newCode = "0" + String.valueOf(Integer.valueOf(newCode) + i);
                }
                String newOid = "";
                if (id == 0) {
                    newOid = resCatalogService.getMinOrderIdFromMainIndex(id);
                } else {
                    newOid = resCatalogService.getMinOrderId(id);
                }
                newOid = String.valueOf(Integer.valueOf(newOid) + i);
                item.setOrderid(Integer.valueOf(newOid));
                item.setCatlogcode(newCode);
                resCatalogService.updateByPrimaryKeySelective(item);
                List<Res_MainInfo> ZyList = resMainInfoService.selectZyByMuLuId(item.getCatlogid());
                //更新所属资源
                for (Res_MainInfo ChZymodel : ZyList) {
                    ChZymodel.setCatlogcode(item.getCatlogcode());
                    resMainInfoService.updateByPrimaryKeySelective(ChZymodel);
                }
                i++;
            }
            int childCount = resCatalogService.selectResCatalogIsExistsSon(item.getCatlogid(),null);
            if (childCount > 0) {
                //如果含有子目录,则一并更新
                updateOriginal(item.getCatlogid());
            }
        }
    }
    
    /**
     * @Description: 编目排序页面
     */
    @ResponseBody
    @RequestMapping("manage/catalog/initsort")
    public Result initSort(String id) {
        List<Res_Catalog> List = resCatalogService.selectResCatalogToParentid(Integer.valueOf(id));
//        String Result = "{count:" + List.size() + "," + "children:[";
        List<Map<String, Object>> maps = new LinkedList<>();
        for (Res_Catalog model : List) {
            Map<String, Object> map = new HashMap<>();
            map.put("id", model.getCatlogid());
            map.put("name", model.getTitle());
            maps.add(map);
//            Result = Result + "{id:" + model.getCatlogid() + ",name:'" + model.getTitle() + "'},";
        }
//        if (List.size() != 0) {
//            Result = Result.substring(0, Result.length() - 1);
//        }
//        Result = Result + "]}";
        return Result.ok().put("count", List.size()).put("children", maps);
    }
    
    /**
     * @Description: 编目排序方法
     */
    @ResponseBody
    @RequiresPermissions("res:catalog:edit")
    @RequestMapping("manage/catalog/sort")
    @LogAction("资源管理,资源编目,资源目录修改(编目排序),修改")
    public Result sort(String id, int pid) {
        if(!"".equals(id)) {
            String[] arr = id.split("\\|");//排序后资源ID列表
            for (int i = 0; i < arr.length; i++) {
                Res_Catalog resCatalog = resCatalogService.selectByPrimaryKey(Integer.parseInt(arr[i]));
                resCatalog.setOrderid(i);
                resCatalogService.updateByPrimaryKeySelective(resCatalog);
            }
        }
        //修改完后把新的序列树返回到前台
        List<Res_Catalog> List = resCatalogService.selectResCatalogToParentid(pid);
//        String Result = "{count:" + List.size() + "," + "children:[";
        List<Map<String, Object>> maps = new LinkedList<>();
        for (Res_Catalog model : List) {
            Map<String, Object> map = new HashMap<>();
            map.put("id", model.getCatlogid());
            map.put("name", model.getTitle());
            maps.add(map);
//            Result = Result + "{id:" + model.getCatlogid() + ",name:'" + model.getTitle() + "'},";
        }
//        if (List.size() != 0) {
//            Result = Result.substring(0, Result.length() - 1);
//        }
//        Result = Result + "]}";
        return Result.ok().put("count", List.size()).put("children", maps);
    }
    
    /**
     * @Description: 资源排序方法
     */
    @ResponseBody
    @RequiresPermissions("res:catalog:edit")
    @RequestMapping("manage/catalog/zysort")
    @LogAction("资源管理,资源编目,资源目录修改(资源排序),修改")
    public Result zySort(String ids, Integer pid) {
        if(!"".equals(ids)) {
            String[] arr = ids.split("\\|");//排序后资源ID列表
            //更新资源排序
            for (int i = 0; i < arr.length; i++) {
                Res_MainInfo resMainInfo = resMainInfoService.selectByPrimaryKey(Integer.parseInt(arr[i]));
                resMainInfo.setOrderid(i);
                resMainInfoService.updateByPrimaryKeySelective(resMainInfo);
            }
        }
        
        List<Res_MainInfo> List = resMainInfoService.selectZyByMuLuId(pid);
//        String Result = "{count:" + List.size() + "," + "children:[";
 
        List<Map<String, Object>> maps = new LinkedList<>();
        for (Res_MainInfo model : List) {
            Map<String, Object> map = new HashMap<>();
            map.put("id", model.getResourceid());
            map.put("name", model.getTitle());
            maps.add(map);
//            Result = Result + "{id:" + model.getResourceid() + ",name:'" + model.getTitle() + "'},";
        }
//        if (List.size() != 0) {
//            Result = Result.substring(0, Result.length() - 1);
//        }
//        Result = Result + "]}";
        return Result.ok().put("count", List.size()).put("children", maps);
    }
    
    /**
     * @Description: 编目上移方法
     */
    public int UpSort(int id, int pid) {
        List<Res_Catalog> List = resCatalogService.selectResCatalogToParentid(pid);
        int index = -1;
        for (Res_Catalog model : List) {
            if (model.getCatlogid() == id) {
                if (index == -1) {
                    return 0;
                } else {
                    //当前目录的排序ID和前一个交换
                    int newoid = List.get(index).getOrderid();
                    List.get(index).setOrderid(model.getOrderid());
                    model.setOrderid(newoid);
                    resCatalogService.updateByPrimaryKeySelective(model);
                    resCatalogService.updateByPrimaryKeySelective(List.get(index));
                    int childCount = resCatalogService.selectResCatalogIsExistsSon(model.getCatlogid(),null);
                    if (childCount > 0) {
                        updateChildrenOid(model.getCatlogid());
                    }
                    int childCount1 = resCatalogService.selectResCatalogIsExistsSon(List.get(index).getCatlogid(),null);
                    if (childCount1 > 0) {
                        //子目录自动修改
                        updateChildrenOid(List.get(index).getCatlogid());
                    }
                }
            }
            index++;
        }
        return 1;
    }
    
    /**
     * @Description: 编目下移方法
     */
    public int DownSort(int id, int pid) {
        List<Res_Catalog> List = resCatalogService.selectResCatalogToParentid(pid);
        int index = 1;
        for (Res_Catalog model : List) {
            if (model.getCatlogid() == id) {
                if (index >= List.size()) {
                    return 0;
                } else {
                    //当前目录的排序ID和后一个交换
                    int newoid = List.get(index).getOrderid();
                    List.get(index).setOrderid(model.getOrderid());
                    model.setOrderid(newoid);
                    resCatalogService.updateByPrimaryKeySelective(model);
                    resCatalogService.updateByPrimaryKeySelective(List.get(index));
                    int childCount = resCatalogService.selectResCatalogIsExistsSon(model.getCatlogid(),null);
                    if (childCount > 0) {
                        updateChildrenOid(model.getCatlogid());
                    }
                    int childCount1 = resCatalogService.selectResCatalogIsExistsSon(List.get(index).getCatlogid(),null);
                    if (childCount1 > 0) {
                        //子目录自动修改
                        updateChildrenOid(List.get(index).getCatlogid());
                    }
                }
            }
            index++;
        }
        return 1;
    }
    
    /**
     * @Description: 目录顶置方法
     */
    public int TopSort(int id, int pid) {
        List<Res_Catalog> List = resCatalogService.selectResCatalogToParentid(pid);
        int index = 0;
        for (Res_Catalog model : List) {
            //当前目录的排序ID和第一个交换,从第一个到当前目录的所有目录依次往后退一位
            if (model.getCatlogid() == id) {
                if (index == 0) {
                    return 0;
                } else {
                    int newoid = List.get(0).getOrderid();
                    for (int i = 0; i <= index - 1; i++) {
                        List.get(i).setOrderid(List.get(i + 1).getOrderid());
                        resCatalogService.updateByPrimaryKeySelective(List.get(i));
                        int childCount = resCatalogService.selectResCatalogIsExistsSon(List.get(i).getCatlogid(),null);
                        if (childCount > 0) {
                            updateChildrenOid(List.get(i).getCatlogid());
                        }
                    }
                    model.setOrderid(newoid);
                    resCatalogService.updateByPrimaryKeySelective(model);
                    int childCount1 = resCatalogService.selectResCatalogIsExistsSon(model.getCatlogid(),null);
                    if (childCount1 > 0) {
                        //子目录自动修改
                        updateChildrenOid(model.getCatlogid());
                    }
                }
            }
            index++;
        }
        return 1;
    }
    
    /**
     * @Description: 目录底置方法
     */
    public int BottomSort(int id, int pid) {
        List<Res_Catalog> List = resCatalogService.selectResCatalogToParentid(pid);
        int index = 0;
        for (Res_Catalog model : List) {
            //当前目录的排序ID和最后一个交换,从最后一个到当前目录的所有目录依次往前进一位
            if (model.getCatlogid() == id) {
                if (index >= List.size()) {
                    return 0;
                } else {
                    int newoid = List.get(List.size() - 1).getOrderid();
                    for (int i = List.size() - 1; i >= index + 1; i--) {
                        List.get(i).setOrderid(List.get(i - 1).getOrderid());
                        resCatalogService.updateByPrimaryKeySelective(List.get(i));
                        int childCount = resCatalogService.selectResCatalogIsExistsSon(List.get(i).getCatlogid());
                        if (childCount > 0) {
                            updateChildrenOid(List.get(i).getCatlogid());
                        }
                    }
                    model.setOrderid(newoid);
                    resCatalogService.updateByPrimaryKeySelective(model);
                    int childCount1 = resCatalogService.selectResCatalogIsExistsSon(model.getCatlogid());
                    if (childCount1 > 0) {
                        //子目录自动修改
                        updateChildrenOid(model.getCatlogid());
                    }
                }
            }
            index++;
        }
        return 1;
    }
    
    /**
     * @Description: 子目录自动拍戏方法
     */
    public void updateChildrenOid(int pid) {
        Res_Catalog pmodel = resCatalogService.getResCatalogInfoById(pid);
        List<Res_Catalog> List = resCatalogService.selectResCatalogToParentid(pid);
        for (Res_Catalog model : List) {
            String neworderid = "";
            neworderid = resCatalogService.getMaxOrderId(pid);
            if (neworderid == null) {
                neworderid = String.valueOf(pmodel.getOrderid()) + "01";
            } else {
                int newOrderid = Integer.valueOf(neworderid) + 1;
                neworderid = String.valueOf(newOrderid);
            }
            model.setOrderid(Integer.valueOf(neworderid));
            resCatalogService.updateByPrimaryKeySelective(model);
            int childCount = resCatalogService.selectResCatalogIsExistsSon(model.getCatlogid());
            if (childCount > 0) {
                updateChildrenOid(model.getCatlogid());
            }
        }
    }
    
    /**
     * @Description: 资源排序页面
     */
    @ResponseBody
    @RequiresPermissions("res:catalog:edit")
    @RequestMapping("manage/catalog/initzysort")
    public Result initZySort(Integer id) {
        List<Res_MainInfo> List = resMainInfoService.selectZyByMuLuId(id);
//        String Result = "{count:" + List.size() + ", children:[";
        List<Map<String, Object>> maps = new LinkedList<>();
        for (Res_MainInfo model : List) {
            Map<String, Object> map = new HashMap<>();
            map.put("id", model.getResourceid());
            map.put("name", model.getTitle());
            maps.add(map);
//            Result = Result + "{id:" + model.getResourceid() + ", name:'" + model.getTitle() + "'},";
        }
//        if (List.size() != 0) {
//            Result = Result.substring(0, Result.length() - 1);
//        }
//        Result = Result + "]}";
        return com.landtool.lanbase.common.utils.Result.ok().put("count", List.size()).put("children", maps);
    }
    
    
    /**
     * @Description: 资源上移方法
     */
    public int zyUpSort(int id, int pid) {
        List<Res_MainInfo> List = resMainInfoService.selectZyByMuLuId(pid);
        int index = -1;
        for (Res_MainInfo model : List) {
            if (model.getResourceid() == id) {
                if (index == -1) {
                    return 0;
                } else {
                    int newoid = List.get(index).getOrderid();
                    List.get(index).setOrderid(model.getOrderid());
                    model.setOrderid(newoid);
                    resMainInfoService.updateByPrimaryKeySelective(model);
                    resMainInfoService.updateByPrimaryKeySelective(List.get(index));
                }
            }
            index++;
        }
        return 1;
    }
    
    /**
     * @Description: 资源下移方法
     */
    public int zyDownSort(int id, int pid) {
        List<Res_MainInfo> List = resMainInfoService.selectZyByMuLuId(pid);
        int index = 1;
        for (Res_MainInfo model : List) {
            if (model.getResourceid() == id) {
                if (index >= List.size()) {
                    return 0;
                } else {
                    int newoid = List.get(index).getOrderid();
                    List.get(index).setOrderid(model.getOrderid());
                    model.setOrderid(newoid);
                    resMainInfoService.updateByPrimaryKeySelective(model);
                    resMainInfoService.updateByPrimaryKeySelective(List.get(index));
                }
            }
            index++;
        }
        return 1;
    }
 
 
 
//
//    @RequestMapping("manage/catalog/text1")
//    public String text1(Model model) throws WSDLException {
//        String wsdluri = "http://18.1.2.13:9090/gpsdateconversion/DateConversion.asmx?wsdl";
//        List<String> operations = new ArrayList<String>();
//        List<Object> list=new ArrayList<>();
//        WAWsdlUtil.getOperationList(wsdluri, operations);
//        for (String operationName : operations) {
//            String Json = text(operationName,wsdluri);
//            list.add(Json);
//        }
//
//        model.addAttribute("pubzyWebRoot", sysConfig.getPubzyWebRoot());
//        model.addAttribute("Obj", list);
//        return "manage/catalog/text";
//    }
 
 
 
}