admin
2021-01-04 aa6ef62aef83e277d4171df1d9f0803f91738216
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
package com.newvideo.controller.parser;
 
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
 
import org.springframework.stereotype.Controller;
 
import com.newvideo.domain.CategoryContry;
import com.newvideo.domain.DetailSystem;
import com.newvideo.domain.HomeVideo;
import com.newvideo.domain.HotStar;
import com.newvideo.domain.HotVideoType;
import com.newvideo.domain.SuperVideoType;
import com.newvideo.domain.UserInfo;
import com.newvideo.domain.VideoInfo;
import com.newvideo.domain.VideoType;
import com.newvideo.domain.ad.CommonAd;
import com.newvideo.domain.ad.CommonAdPositionAd;
import com.newvideo.domain.recommend.CategoryRecommendVideo;
import com.newvideo.domain.special.Special;
import com.newvideo.service.imp.AdService;
import com.newvideo.service.imp.BanQuanService;
import com.newvideo.service.imp.CategoryAreaService;
import com.newvideo.service.imp.ClassService;
import com.newvideo.service.imp.ConfigService;
import com.newvideo.service.imp.HomeTypeService;
import com.newvideo.service.imp.HotVideoTypeService;
import com.newvideo.service.imp.RecommendService;
import com.newvideo.service.imp.SpecialService;
import com.newvideo.service.imp.StarService;
import com.newvideo.service.imp.SystemService;
import com.newvideo.service.imp.UserService;
import com.newvideo.service.imp.recommend.CategoryRecommendVideoService;
import com.newvideo.util.CacheUtil;
import com.newvideo.util.Constant;
import com.newvideo.util.JsonUtil;
import com.newvideo.util.JuheVideoUtil;
import com.newvideo.util.StringUtil;
import com.newvideo.util.Utils;
import com.newvideo.util.VideoPictureUtil;
import com.newvideo.util.JuHe.VideoResouceUtil;
import com.newvideo.util.ad.CommonAdUtil;
 
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
 
@Controller
public class ClassParser {
    @Resource
    private SystemService systemService;
    @Resource
    private ClassService classService;
    @Resource
    private ConfigService configService;
    @Resource
    private StarService starService;
    @Resource
    private HomeTypeService homeTypeService;
    @Resource
    private CategoryAreaService categoryAreaService;
    @Resource
    private HotVideoTypeService hotVideoTypeService;
    @Resource
    private SpecialService specialService;
    @Resource
    private UserService userService;
    @Resource
    private VideoResouceUtil videoResouceUtil;
    @Resource
    private CategoryRecommendVideoService categoryRecommendVideoService;
    @Resource
    private AdService adService;
    @Resource
    private RecommendService recommendService;
    @Resource
    private BanQuanService banQuanService;
 
    public void getClass(String uid, HttpServletRequest request, PrintWriter out) {
        String method = request.getParameter("Method");
 
        String system = request.getParameter("System");
        String sign = request.getParameter("Sign");
        String platform = request.getParameter("Platform");
        String version = request.getParameter("Version");
        String packageName = request.getParameter("Package");
 
        if (StringUtil.isNullOrEmpty(method)) {
            out.print(JsonUtil.loadFalseJson("Method"));
            return;
        }
        if (StringUtil.isNullOrEmpty(uid)) {
            out.print(JsonUtil.loadFalseJson("Uid"));
            return;
        }
        if (StringUtil.isNullOrEmpty(system)) {
            out.print(JsonUtil.loadFalseJson("System"));
            return;
        }
        if (StringUtil.isNullOrEmpty(sign)) {
            out.print(JsonUtil.loadFalseJson("Sign"));
            return;
        }
        if (StringUtil.isNullOrEmpty(platform)) {
            out.print(JsonUtil.loadFalseJson("Platform"));
            return;
        }
 
        DetailSystem detailSystem = systemService.getDetailSystemByPackage(packageName);
        UserInfo user = userService.getUserInfo(uid);
        if (Utils.isTest(request, user, detailSystem.getId()))
            detailSystem = systemService.getDetailSystemById(40 + "");
 
        List<SuperVideoType> list = classService.getSuperVideoTypeList(detailSystem.getId());
 
        if (platform.equalsIgnoreCase("android")) {
            for (SuperVideoType type : list) {
                if (type.getType().getName().contains("资讯")) {
                    type.getType().setName("主播");
                    type.getType().setId(1111);
                    type.getType().setIcon("http://img.zcool.cn/community/017fdb57610d8a0000012e7e74b496.png");
                    break;
                }
            }
        }
 
        if ("android".equalsIgnoreCase(platform) && Integer.parseInt(version) > 53) {
            SuperVideoType sty = new SuperVideoType();
            sty.setCreatetime(0 + "");
            sty.setPicture("");
            VideoType vt = new VideoType(22222);
            vt.setName("头条");
            vt.setCategoryType("http://wap.baizhan.net/09");
            vt.setIcon("http://img.zcool.cn/community/01e299592fd75ba8012193a365723f.png@1280w_1l_2o_100sh.png");
            sty.setType(vt);
            boolean isC = false;
            for (SuperVideoType svt : list) {
                if (svt.getType().getId() == vt.getId()) {
                    isC = true;
                    break;
                }
            }
 
            if (!isC)
                list.add(sty);
        }
 
        List<VideoType> typeList = new ArrayList<VideoType>();
        for (int i = 0; i < list.size(); i++) {
            if (!StringUtil.isNullOrEmpty(list.get(i).getPicture())) {
                list.get(i).getType().setIcon(list.get(i).getPicture());
            }
            typeList.add(list.get(i).getType());
        }
 
        JSONObject object = new JSONObject();
        object.put("count", (new StringBuilder(String.valueOf(typeList.size()))).toString());
        JSONArray array = new JSONArray();
        for (int i = 0; i < typeList.size(); i++)
            array.add(StringUtil.outPutResultJson(typeList.get(i)));
 
        object.put("data", array);
        out.print(JsonUtil.loadTrueJson(object.toString()));
 
    }
 
    public void getNewClass(String uid, HttpServletRequest request, PrintWriter out) {
        String method = request.getParameter("Method");
 
        String system = request.getParameter("System");
        String sign = request.getParameter("Sign");
        String platform = request.getParameter("Platform");
        String version = request.getParameter("Version");
        String packageName = request.getParameter("Package");
        if (StringUtil.isNullOrEmpty(method)) {
            out.print(JsonUtil.loadFalseJson("Method"));
            return;
        }
 
        if (StringUtil.isNullOrEmpty(uid)) {
            out.print(JsonUtil.loadFalseJson("Uid"));
            return;
        }
        if (StringUtil.isNullOrEmpty(system)) {
            out.print(JsonUtil.loadFalseJson("System"));
            return;
        }
        if (StringUtil.isNullOrEmpty(sign)) {
            out.print(JsonUtil.loadFalseJson("Sign"));
            return;
        }
        if (StringUtil.isNullOrEmpty(platform)) {
            out.print(JsonUtil.loadFalseJson("Platform"));
            return;
        }
 
        DetailSystem detailSystem = systemService.getDetailSystemByPackage(packageName);
        UserInfo user = userService.getUserInfo(uid);
        if (Utils.isTest(request, user, detailSystem.getId()))
            detailSystem = systemService.getDetailSystemById(40 + "");
 
        List<SuperVideoType> list = classService.getSuperVideoTypeList(detailSystem.getId());
 
        if (platform.equalsIgnoreCase("android")) {
            for (SuperVideoType type : list) {
                if (type.getType().getName().contains("资讯")) {
                    type.getType().setName("主播");
                    type.getType().setId(1111);
                    type.getType().setIcon("http://img.zcool.cn/community/017fdb57610d8a0000012e7e74b496.png");
                    break;
                }
            }
        }
 
//        if ("android".equalsIgnoreCase(platform) && Integer.parseInt(version) > 53) {
//            SuperVideoType sty = new SuperVideoType();
//            sty.setCreatetime(0 + "");
//            sty.setPicture("");
//            VideoType vt = new VideoType(22222);
//            vt.setName("头条");
//            vt.setCategoryType("http://wap.baizhan.net/09");
//            vt.setIcon("http://img.zcool.cn/community/01e299592fd75ba8012193a365723f.png@1280w_1l_2o_100sh.png");
//            sty.setType(vt);
//            boolean isC = false;
//            for (SuperVideoType svt : list) {
//                if (svt.getType().getId() == vt.getId()) {
//                    isC = true;
//                    break;
//                }
//            }
//
//            if (!isC)
//                list.add(sty);
//        }
 
        List<VideoType> typelist = new ArrayList<VideoType>();
        for (SuperVideoType sv : list) {
            if (!StringUtil.isNullOrEmpty(sv.getPicture())) {
                sv.getType().setIcon(sv.getPicture());
            }
            typelist.add(sv.getType());
        }
 
        JSONObject object = new JSONObject();
        object.put("count", (new StringBuilder(String.valueOf(typelist.size()))).toString());
        JSONArray array = new JSONArray();
        for (int j = 0; j < typelist.size(); j++)
            array.add(StringUtil.outPutResultJson(typelist.get(j)));
        object.put("data", array);
        out.print(JsonUtil.loadTrueJson(object.toString()));
    }
 
    public void getHotStars(String uid, HttpServletRequest request, PrintWriter out) {
        String method = request.getParameter("Method");
 
        String page = request.getParameter("Page");
        String system = request.getParameter("System");
        String sign = request.getParameter("Sign");
        String platform = request.getParameter("Platform");
        String packageName = request.getParameter("Package");
        if (StringUtil.isNullOrEmpty(method)) {
            out.print(JsonUtil.loadFalseJson("Method"));
            return;
        }
        if (StringUtil.isNullOrEmpty(uid)) {
            out.print(JsonUtil.loadFalseJson("Uid"));
            return;
        }
        if (StringUtil.isNullOrEmpty(system)) {
            out.print(JsonUtil.loadFalseJson("System"));
            return;
        }
        if (StringUtil.isNullOrEmpty(sign)) {
            out.print(JsonUtil.loadFalseJson("Sign"));
            return;
        }
        if (StringUtil.isNullOrEmpty(platform)) {
            out.print(JsonUtil.loadFalseJson("Platform"));
            return;
        }
        int pageIndex = StringUtil.getPage(page);
        if (pageIndex == 0) {
            out.print(JsonUtil.loadFalseJson("Page"));
            return;
        }
 
        List<HotStar> list = starService.getHotStarList(pageIndex, 100);
 
        DetailSystem detailSystem = systemService.getDetailSystemByPackage(packageName);
        UserInfo user1 = userService.getUserInfo(uid);
        if (Utils.isTest(request, user1, detailSystem.getId()))
            list = new ArrayList<HotStar>();
 
        JSONObject object = new JSONObject();
        object.put("count", Constant.isUpdate ? "19"
                : ((Object) ((new StringBuilder(String.valueOf(starService.getHotStarCount()))).toString())));
        JSONArray array = new JSONArray();
        for (int i = 0; i < list.size(); i++)
            array.add(StringUtil.outPutResultJson(list.get(i)));
 
        object.put("data", array);
        out.print(JsonUtil.loadTrueJson(object.toString()));
    }
 
    public void getHotStarDetail(String uid, HttpServletRequest request, PrintWriter out) {
        String method = request.getParameter("Method");
 
        String id = request.getParameter("Id");
        String system = request.getParameter("System");
        String sign = request.getParameter("Sign");
        String platform = request.getParameter("Platform");
        if (StringUtil.isNullOrEmpty(method)) {
            out.print(JsonUtil.loadFalseJson("Method"));
            return;
        }
        if (StringUtil.isNullOrEmpty(uid)) {
            out.print(JsonUtil.loadFalseJson("Uid"));
            return;
        }
        if (StringUtil.isNullOrEmpty(system)) {
            out.print(JsonUtil.loadFalseJson("System"));
            return;
        }
        if (StringUtil.isNullOrEmpty(sign)) {
            out.print(JsonUtil.loadFalseJson("Sign"));
            return;
        }
        if (StringUtil.isNullOrEmpty(platform)) {
            out.print(JsonUtil.loadFalseJson("Platform"));
            return;
        }
 
        HotStar hot = starService.getHotStarDetail(id);
        out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(hot)));
 
    }
 
    public void getHotStarsVideo(String uid, HttpServletRequest request, PrintWriter out) {
        String method = request.getParameter("Method");
 
        String system = request.getParameter("System");
        String starId = request.getParameter("StarId");
        String sign = request.getParameter("Sign");
        String page = request.getParameter("Page");
        String platform = request.getParameter("Platform");
        String packageName = request.getParameter("Package");
        String version = request.getParameter("Version");
        if (StringUtil.isNullOrEmpty(method)) {
            out.print(JsonUtil.loadFalseJson("Method"));
            return;
        }
        if (StringUtil.isNullOrEmpty(uid)) {
            out.print(JsonUtil.loadFalseJson("Uid"));
            return;
        }
        if (StringUtil.isNullOrEmpty(system)) {
            out.print(JsonUtil.loadFalseJson("System"));
            return;
        }
        if (StringUtil.isNullOrEmpty(sign)) {
            out.print(JsonUtil.loadFalseJson("Sign"));
            return;
        }
        if (StringUtil.isNullOrEmpty(starId)) {
            out.print(JsonUtil.loadFalseJson("StarId"));
            return;
        }
        if (StringUtil.isNullOrEmpty(platform)) {
            out.print(JsonUtil.loadFalseJson("Platform"));
            return;
        }
        int pageIndex = StringUtil.getPage(page);
        if (pageIndex <= 0) {
            out.print(JsonUtil.loadFalseJson("Page"));
            return;
        }
 
        List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(platform, Integer.parseInt(version));
 
        DetailSystem detailSystem = systemService.getDetailSystemByPackage(packageName);
        List<VideoInfo> list = starService.getStarVideo(detailSystem.getId(), starId, pageIndex,
                CacheUtil.getMD5Long(resourceList));
 
        String cacheMD5 = "";
        if (list != null) {
            for (VideoInfo info : list) {
                cacheMD5 += info.getId() + "#";
            }
        }
 
        list = banQuanService.getBanQuanVideo(list, detailSystem.getId(), cacheMD5);
 
        JSONObject object = new JSONObject();
        object.put("count",
                Constant.isUpdate ? "19"
                        : ((Object) ((new StringBuilder(
                                String.valueOf(starService.getStarVideoCount(detailSystem.getId(), starId))))
                                        .toString())));
        JSONArray array = new JSONArray();
 
        for (int i = 0; i < list.size(); i++) {
            list.get(i).setPicture(VideoPictureUtil.getShowPicture(list.get(i), platform, version));
            array.add(StringUtil.outPutResultJson(list.get(i)));
        }
 
        object.put("data", array);
        UserInfo user = userService.getUserInfo(uid);
        if (Utils.isTest(request, user, detailSystem.getId()))
            out.print("");
        else
            out.print(JsonUtil.loadTrueJson(object.toString()));
 
    }
 
    public void getVideoList(String uid, HttpServletRequest request, PrintWriter out) {
        String method = request.getParameter("Method");
 
        String system = request.getParameter("System");
        String starId = request.getParameter("StarId");
        String homeType = request.getParameter("HomeType");
        String videoType = request.getParameter("VideoType");
        String order = request.getParameter("Order");// 1-最新 2-最热4-评分最高
        String sign = request.getParameter("Sign");
        String page = request.getParameter("Page");
        String platform = request.getParameter("Platform");
        String packageName = request.getParameter("Package");
        String version = request.getParameter("Version");
        String yearId = request.getParameter("YearId");
        String categoryType = request.getParameter("CategoryType");// 新版接口使用
 
        if (StringUtil.isNullOrEmpty(method)) {
            out.print(JsonUtil.loadFalseJson("Method"));
            return;
        }
 
        if (StringUtil.isNullOrEmpty(uid)) {
            out.print(JsonUtil.loadFalseJson("Uid"));
            return;
        }
 
        if (StringUtil.isNullOrEmpty(system)) {
            out.print(JsonUtil.loadFalseJson("System"));
            return;
        }
 
        if (StringUtil.isNullOrEmpty(sign)) {
            out.print(JsonUtil.loadFalseJson("Sign"));
            return;
        }
        if (StringUtil.isNullOrEmpty(starId) && StringUtil.isNullOrEmpty(homeType)
                && StringUtil.isNullOrEmpty(videoType)) {
            out.print(JsonUtil.loadFalseJson("StarId\u6216\u8005HomeType\u6216\u8005 VideoType"));
            return;
        }
        if (StringUtil.isNullOrEmpty(platform)) {
            out.print(JsonUtil.loadFalseJson("Platform"));
            return;
        }
        int pageIndex = StringUtil.getPage(page);
        if (pageIndex <= 0) {
            out.print(JsonUtil.loadFalseJson("Page"));
            return;
        }
        
        int pageCount=20;
        if("com.mugua.sqvideo".equalsIgnoreCase(packageName)){ //前端有BUG。20170912前客户端只能接收20条数据
            pageCount=30;
        }
        
        List<Long> resourceList = videoResouceUtil.getAvailableResourceIds(platform, Integer.parseInt(version));
        DetailSystem detailSystem = systemService.getDetailSystemByPackage(packageName);
        UserInfo user = userService.getUserInfo(uid);
        if (Utils.isTest(request, user, detailSystem.getId()))
            detailSystem = systemService.getDetailSystemById(40 + "");
 
        List<VideoInfo> list = null;
        String count = "";
        if (!StringUtil.isNullOrEmpty(starId)) {
 
            list = starService.getStarVideo(detailSystem.getId(), starId, pageIndex, resourceList,
                    CacheUtil.getMD5Long(resourceList));
            count = (new StringBuilder(String.valueOf(starService.getStarVideoCount(detailSystem.getId(), starId))))
                    .toString();
 
        } else if (!StringUtil.isNullOrEmpty(homeType)) {
 
            list = new ArrayList<VideoInfo>();
            List<HomeVideo> homeVideoList = homeTypeService.getVideoByTypes(homeType, pageIndex, detailSystem);
 
            for (HomeVideo hv : homeVideoList) {
                if (detailSystem.getPackageName().contains("doudou")) {
                    if (!StringUtil.isNullOrEmpty(hv.getPicture()))
                        hv.getVideo().setPicture(hv.getPicture());
                }
                list.add(hv.getVideo());
            }
            count = (new StringBuilder(String.valueOf(homeTypeService.getVideoCountByTypes(homeType, pageIndex))))
                    .toString();
        } else if (!StringUtil.isNullOrEmpty(videoType)) {
            if (StringUtil.isNullOrEmpty(categoryType) || "genre".equalsIgnoreCase(categoryType)) {// 按分类检索数据
                if (!StringUtil.isNullOrEmpty(order)) {
                    Long startTime = System.currentTimeMillis();
                    List<VideoInfo> list1 = classService.getTypeVideoList(videoType, detailSystem, pageIndex, pageCount,
                            Integer.parseInt(order), resourceList, CacheUtil.getMD5Long(resourceList));
                    list = new ArrayList<VideoInfo>();
                    if (list1 != null)
                        for (VideoInfo info : list1)
                            list.add(info);
 
                    System.out.println("列表获取时间:" + (System.currentTimeMillis() - startTime));
                } else {
                    List<VideoInfo> list1 = classService.getTypeVideoList(videoType, detailSystem, pageIndex, pageCount, 1,
                            resourceList, CacheUtil.getMD5Long(resourceList));
                    list = new ArrayList<VideoInfo>();
                    if (list1 != null)
                        for (VideoInfo info : list1)
                            list.add(info);
                }
                count = 1200 + "";
            } else {// 按地区检索数据
                String areaId = videoType;// 国籍ID
                CategoryContry cc = categoryAreaService.getCategoryArea(areaId);
                String country = cc.getName();
                long typeid = cc.getParent().getCid();
                if (StringUtil.isNullOrEmpty(order))
                    order = 1 + "";
                list = categoryAreaService.getVideoInfoByArea(typeid + "", detailSystem, pageIndex,pageCount,
                        Integer.parseInt(order), resourceList, country, StringUtil.Md5(typeid + "-" + detailSystem + "-"
                                + pageIndex + "-" + order + "-" + country + "-" + CacheUtil.getMD5Long(resourceList)));
                System.out.println("列表最终数量:" + list.size());
                count = 1000 + "";
            }
        }
        list = banQuanService.getBanQuanVideo(list, detailSystem.getId(), CacheUtil.getMD5VideoInfo(list));
 
        for (int i = 0; i < list.size(); i++) {
            list.get(i).setPicture(VideoPictureUtil.getShowPicture(list.get(i), platform, version));
            if (JuheVideoUtil.isNeedDelete(list.get(i), detailSystem.getId())) {
                list.remove(i);
                i--;
            }
        }
 
        JSONObject object = new JSONObject();
        object.put("count", Constant.isUpdate ? "19" : ((Object) (count)));
        JSONArray array = new JSONArray();
        for (int i = 0; i < list.size(); i++) {
            list.get(i).setPicture(VideoPictureUtil.getShowPicture(list.get(i), platform, version));
            array.add(StringUtil.outPutResultJson(list.get(i)));
        }
        object.put("data", array);
        object.put("Column", 2);
        System.out.println(object.optString("Column"));
        out.print(JsonUtil.loadTrueJson(object.toString()));
        out.flush();
        out.close();
    }
 
    // getFirstChildType
    public void getFirstChildType(String uid, HttpServletRequest request, PrintWriter out) {
        String method = request.getParameter("Method");
 
        String system = request.getParameter("System");
        String parentId = request.getParameter("ParentId");
        String sign = request.getParameter("Sign");
 
        String platform = request.getParameter("Platform");
        if (StringUtil.isNullOrEmpty(method)) {
            out.print(JsonUtil.loadFalseJson("Method"));
            return;
        }
        if (StringUtil.isNullOrEmpty(uid)) {
            out.print(JsonUtil.loadFalseJson("Uid"));
            return;
        }
        if (StringUtil.isNullOrEmpty(system)) {
            out.print(JsonUtil.loadFalseJson("System"));
            return;
        }
        if (StringUtil.isNullOrEmpty(sign)) {
            out.print(JsonUtil.loadFalseJson("Sign"));
            return;
        }
        if (StringUtil.isNullOrEmpty(parentId)) {
            out.print(JsonUtil.loadFalseJson("ParentId"));
            return;
        }
        if (StringUtil.isNullOrEmpty(platform)) {
            out.print(JsonUtil.loadFalseJson("Platform"));
            return;
        }
 
        List<VideoType> list = classService.getFirstTypeList(parentId);
        JSONObject object = new JSONObject();
        object.put("count", list.size());
        JSONArray array = new JSONArray();
 
        for (int i = 0; i < list.size(); i++)
            array.add(StringUtil.outPutResultJson(list.get(i)));
 
        object.put("data", array);
        out.print(JsonUtil.loadTrueJson(object.toString()));
 
    }
 
    public void getFirstChildTypeNew(String uid, HttpServletRequest request, PrintWriter out) {
        String method = request.getParameter("Method");
        String system = request.getParameter("System");
        String parentId = request.getParameter("ParentId");
        String sign = request.getParameter("Sign");
        String version = request.getParameter("Version");
 
        String platform = request.getParameter("Platform");
        if (StringUtil.isNullOrEmpty(method)) {
            out.print(JsonUtil.loadFalseJson("请上传Method"));
            return;
        }
        if (StringUtil.isNullOrEmpty(uid)) {
            out.print(JsonUtil.loadFalseJson("请上传Uid"));
            return;
        }
        if (StringUtil.isNullOrEmpty(system)) {
            out.print(JsonUtil.loadFalseJson("请上传System"));
            return;
        }
        if (StringUtil.isNullOrEmpty(sign)) {
            out.print(JsonUtil.loadFalseJson("请上传Sign"));
            return;
        }
        if (StringUtil.isNullOrEmpty(parentId)) {
            out.print(JsonUtil.loadFalseJson("请上传ParentId"));
            return;
        }
        if (StringUtil.isNullOrEmpty(platform)) {
            out.print(JsonUtil.loadFalseJson("请上传Platform"));
            return;
        }
 
        JSONArray array = new JSONArray();
        JSONObject object = new JSONObject();
        List<VideoType> list = new ArrayList<VideoType>();
 
        boolean isVersionV2 = false;
 
        if (platform.equalsIgnoreCase("android"))
            isVersionV2 = Integer.parseInt(version) >= Constant.VERSION_NEW_ANDROID_V2;
        else
            isVersionV2 = Integer.parseInt(version) >= Constant.VERSION_NEW_IOS_V2;
 
        if ("150".equalsIgnoreCase(parentId) || "151".equalsIgnoreCase(parentId) || "152".equalsIgnoreCase(parentId)
                || "153".equalsIgnoreCase(parentId)) {
 
            List<CategoryContry> clist = categoryAreaService.getCategoryContryListByCid(parentId);
 
            List<CategoryContry> areaList = categoryAreaService.categoryContryList(clist.get(0).getId() + "");
 
            if (isVersionV2) {
                VideoType type = new VideoType(Integer.parseInt(parentId));
                type.setName("推荐");
                type.setShow("1");
                type.setCategoryType("genre");
                list.add(0, type);
            }
 
            if ("150".equalsIgnoreCase(parentId)) {
                VideoType vt = classService.getType(282);
                vt.setParent(null);
                vt.setCategoryType("genre");
                list.add(vt);
            } else if ("151".equalsIgnoreCase(parentId)) {
                VideoType vt = classService.getType(281);
                vt.setParent(null);
                vt.setCategoryType("genre");
                list.add(vt);
            } else if ("153".equalsIgnoreCase(parentId)) {
                VideoType vt = classService.getType(283);
                vt.setParent(null);
                vt.setCategoryType("genre");
                list.add(vt);
            }
 
            for (CategoryContry cc : areaList) {
                VideoType type = new VideoType(cc.getId());
                type.setName(cc.getName());
                type.setShow("1");
                type.setCategoryType("area");
                list.add(type);
            }
 
        } else {
            List<VideoType> clist = classService.getFirstTypeList(parentId);
            list = new ArrayList<VideoType>();
            if (clist != null)
                for (VideoType vt : clist)
                    list.add(vt);
 
            VideoType type = new VideoType(Integer.parseInt(parentId));
            if (!isVersionV2)
                type.setName("全部");
            else
                type.setName("推荐");
            type.setShow("1");
            type.setCategoryType("genre");
            list.add(0, type);
        }
        object.put("count", list.size());
 
        for (int i = 0; i < list.size(); i++)
            array.add(StringUtil.outPutResultJson(list.get(i)));
        object.put("data", array);
        out.print(JsonUtil.loadTrueJson(object.toString()));
    }
 
    public void getHotType(String uid, HttpServletRequest request, PrintWriter out) {
        String method = request.getParameter("Method");
 
        String system = request.getParameter("System");
        String sign = request.getParameter("Sign");
        String packageName = request.getParameter("Package");
 
        String platform = request.getParameter("Platform");
        if (StringUtil.isNullOrEmpty(method)) {
            out.print(JsonUtil.loadFalseJson("Method"));
            return;
        }
        if (StringUtil.isNullOrEmpty(uid)) {
            out.print(JsonUtil.loadFalseJson("Uid"));
            return;
        }
        if (StringUtil.isNullOrEmpty(system)) {
            out.print(JsonUtil.loadFalseJson("System"));
            return;
        }
        if (StringUtil.isNullOrEmpty(sign)) {
            out.print(JsonUtil.loadFalseJson("Sign"));
            return;
        }
 
        if (StringUtil.isNullOrEmpty(platform)) {
            out.print(JsonUtil.loadFalseJson("Platform"));
            return;
        }
 
        DetailSystem detailSystem = systemService.getDetailSystemByPackage(packageName);
        UserInfo user = userService.getUserInfo(uid);
        if (Utils.isTest(request, user, detailSystem.getId()))
            detailSystem = systemService.getDetailSystemById(40 + "");
 
        List<HotVideoType> list = hotVideoTypeService.getSuperHotTypeList(detailSystem.getId());
 
        JSONObject object = new JSONObject();
        object.put("count", list.size());
        JSONArray array = new JSONArray();
        for (int i = 0; i < list.size(); i++)
            array.add(StringUtil.outPutResultJson(list.get(i)));
        object.put("data", array);
        out.print(JsonUtil.loadTrueJson(object.toString()));
    }
 
    public void getSpecialList(String uid, HttpServletRequest request, PrintWriter out) {
        request.getParameterMap();
        String method = request.getParameter("Method");
 
        String system = request.getParameter("System");
        String sign = request.getParameter("Sign");
        String packageName = request.getParameter("Package");
        String page = request.getParameter("Page");
 
        String platform = request.getParameter("Platform");
        if (StringUtil.isNullOrEmpty(method)) {
            out.print(JsonUtil.loadFalseJson("Method"));
            return;
        }
        if (StringUtil.isNullOrEmpty(uid)) {
            out.print(JsonUtil.loadFalseJson("Uid"));
            return;
        }
        if (StringUtil.isNullOrEmpty(system)) {
            out.print(JsonUtil.loadFalseJson("System"));
            return;
        }
        if (StringUtil.isNullOrEmpty(sign)) {
            out.print(JsonUtil.loadFalseJson("Sign"));
            return;
        }
 
        if (StringUtil.isNullOrEmpty(platform)) {
            out.print(JsonUtil.loadFalseJson("Platform"));
            return;
        }
 
        int pageIndex = 1;
        pageIndex = Integer.parseInt(page);
 
        DetailSystem detailSystem = systemService.getDetailSystemByPackage(packageName);
        UserInfo user = userService.getUserInfo(uid);
        if (Utils.isTest(request, user, detailSystem.getId()))
            detailSystem = systemService.getDetailSystemById(40 + "");
 
        List<Special> list = specialService.getSpecialList(detailSystem.getId(), pageIndex);
        long count = specialService.getSpecialCount(detailSystem.getId());
 
        JSONObject object = new JSONObject();
        object.put("count", count);
        JSONArray array = new JSONArray();
        for (int i = 0; i < list.size(); i++)
            array.add(StringUtil.outPutResultJson(list.get(i)));
 
        object.put("data", array);
        out.print(JsonUtil.loadTrueJson(object.toString()));
    }
 
    public void getSpecialDetail(String uid, HttpServletRequest request, PrintWriter out) {
        String method = request.getParameter("Method");
 
        String system = request.getParameter("System");
        String sign = request.getParameter("Sign");
        String packageName = request.getParameter("Package");
        String specialid = request.getParameter("Id");
        String version = request.getParameter("Version");
 
        String platform = request.getParameter("Platform");
        if (StringUtil.isNullOrEmpty(method)) {
            out.print(JsonUtil.loadFalseJson("Method"));
            return;
        }
        if (StringUtil.isNullOrEmpty(uid)) {
            out.print(JsonUtil.loadFalseJson("Uid"));
            return;
        }
        if (StringUtil.isNullOrEmpty(system)) {
            out.print(JsonUtil.loadFalseJson("System"));
            return;
        }
        if (StringUtil.isNullOrEmpty(sign)) {
            out.print(JsonUtil.loadFalseJson("Sign"));
            return;
        }
 
        if (StringUtil.isNullOrEmpty(platform)) {
            out.print(JsonUtil.loadFalseJson("Platform"));
            return;
        }
 
        Special special = specialService.getSpecial(specialid);
        List<VideoInfo> list = specialService.getSpecialVideoList(specialid);
 
        JSONObject object = new JSONObject();
        object.put("count", list.size());
        JSONArray array = new JSONArray();
        for (int i = 0; i < list.size(); i++) {
            list.get(i).setPicture(VideoPictureUtil.getShowPicture(list.get(i), platform, version));
            array.add(StringUtil.outPutResultJson(list.get(i)));
        }
        object.put("data", array);
 
        object.put("special", StringUtil.outPutResultJson(special));
 
        DetailSystem detailSystem = systemService.getDetailSystemByPackage(packageName);
        UserInfo user = userService.getUserInfo(uid);
        if (Utils.isTest(request, user, detailSystem.getId()))
            out.print("");
        else
            out.print(JsonUtil.loadTrueJson(object.toString()));
 
    }
 
    public void getRecommendCategoryVideoBanner(String uid, HttpServletRequest request, PrintWriter out) {
        String method = request.getParameter("Method");
 
        String system = request.getParameter("System");
        String sign = request.getParameter("Sign");
        String packageName = request.getParameter("Package");
        String typeid = request.getParameter("Type");
        String platform = request.getParameter("Platform");
        if (StringUtil.isNullOrEmpty(method)) {
            out.print(JsonUtil.loadFalseJson("Method"));
            return;
        }
        if (StringUtil.isNullOrEmpty(uid)) {
            out.print(JsonUtil.loadFalseJson("Uid"));
            return;
        }
        if (StringUtil.isNullOrEmpty(system)) {
            out.print(JsonUtil.loadFalseJson("System"));
            return;
        }
        if (StringUtil.isNullOrEmpty(sign)) {
            out.print(JsonUtil.loadFalseJson("Sign"));
            return;
        }
 
        if (StringUtil.isNullOrEmpty(platform)) {
            out.print(JsonUtil.loadFalseJson("Platform"));
            return;
        }
 
        DetailSystem detailSystem = systemService.getDetailSystemByPackage(packageName);
        List<CategoryRecommendVideo> crvList = categoryRecommendVideoService
                .getCategoryRecommendVideoBannerList(detailSystem.getId(), Integer.parseInt(typeid));
 
        int pid = CommonAdUtil.getCommonAdPositionByVideoType(Integer.parseInt(typeid), platform);
        List<CommonAdPositionAd> adList = adService.getCommonAdByPid("" + pid);
 
        if (adList != null && adList.size() > 0) {
            for (int i = 0; i < adList.size(); i++) {
                int p = adList.get(i).getPosition();
                CategoryRecommendVideo sc = new CategoryRecommendVideo();
                CommonAd ca = adList.get(i).getAd();
                ca.setPid(pid + "");
                sc.setPicture(ca.getPicture());
                sc.setDesc(ca.getDesc());
                sc.setAd(ca);
                if (p < crvList.size()) {
                    crvList.add(p, sc);
                } else {// 直接加到末尾
                    crvList.add(sc);
                }
            }
        }
 
        JSONObject object = new JSONObject();
        object.put("count", crvList.size());
        JSONArray array = new JSONArray();
        for (int i = 0; i < crvList.size(); i++)
            array.add(StringUtil.outPutResultJson(crvList.get(i)));
        object.put("data", array);
        out.print(JsonUtil.loadTrueJson(object.toString()));
    }
 
    public void getRecommendCategoryVideoList(String uid, HttpServletRequest request, PrintWriter out) {
        String method = request.getParameter("Method");
 
        String system = request.getParameter("System");
        String sign = request.getParameter("Sign");
        String packageName = request.getParameter("Package");
        String typeid = request.getParameter("Type");
        String platform = request.getParameter("Platform");
        String version = request.getParameter("Version");
        if (StringUtil.isNullOrEmpty(method)) {
            out.print(JsonUtil.loadFalseJson("Method"));
            return;
        }
        if (StringUtil.isNullOrEmpty(uid)) {
            out.print(JsonUtil.loadFalseJson("Uid"));
            return;
        }
        if (StringUtil.isNullOrEmpty(system)) {
            out.print(JsonUtil.loadFalseJson("System"));
            return;
        }
        if (StringUtil.isNullOrEmpty(sign)) {
            out.print(JsonUtil.loadFalseJson("Sign"));
            return;
        }
 
        if (StringUtil.isNullOrEmpty(platform)) {
            out.print(JsonUtil.loadFalseJson("Platform"));
            return;
        }
 
        DetailSystem detailSystem = systemService.getDetailSystemByPackage(packageName);
        int count = categoryRecommendVideoService.getRankVideoNumber(Integer.parseInt(typeid));
        List<VideoInfo> list = recommendService.getCategoryRecommendVideoList(Integer.parseInt(typeid), count);
 
        list = banQuanService.getBanQuanVideo(list, detailSystem.getId(), CacheUtil.getMD5VideoInfo(list));
        for (VideoInfo vi : list) {// 清除无用数据,防止浪费带宽
            vi.setIntroduction("");
            vi.setMainActor("");
            vi.setPicture(VideoPictureUtil.getShowPicture(vi, platform, version));
        }
        JSONObject object = new JSONObject();
        object.put("count", list.size());
        JSONArray array = new JSONArray();
        for (int i = 0; i < list.size(); i++)
            array.add(StringUtil.outPutResultJson(list.get(i)));
        object.put("data", array);
        out.print(JsonUtil.loadTrueJson(object.toString()));
    }
 
}