admin
2020-10-13 fc7a6634496066fe45dca8ea9832bdd2f7341db4
百度内容联盟前端分类,首页弹窗广告
9个文件已修改
12个文件已添加
1509 ■■■■■ 已修改文件
src/main/java/com/yeshi/buwan/controller/api/ApiControllerV2.java 37 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/controller/parser/BaiduParser.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/controller/parser/ClassParser.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/controller/parser/ConfigParser.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/dao/jump/JumpDetailDao.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/dao/recommend/FloatADDao.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/domain/jump/JumpDetail.java 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/domain/jump/JumpTypeEnum.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/domain/recommend/FloatAD.java 106 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/job/SolrJob.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/service/imp/ad/FloatADServiceImpl.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/service/imp/baidu/BaiDuCPUServiceImpl.java 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/service/imp/jump/JumpDetailServiceImpl.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/service/inter/ad/FloatADService.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/service/inter/baidu/BaiDuCPUService.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/service/inter/jump/JumpDetailService.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/util/SolrUtil.java 945 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/vo/baidu/BaiDuCPUTypeVO.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/baidu/videos.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/java/com/hxh/spring/test/Solr.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/java/com/hxh/spring/test/ad/AdTest.java 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/controller/api/ApiControllerV2.java
@@ -2,6 +2,7 @@
import com.yeshi.buwan.controller.parser.*;
import com.yeshi.buwan.service.imp.UserService;
import com.yeshi.buwan.service.inter.baidu.BaiDuCPUService;
import com.yeshi.buwan.util.IPUtil;
import com.yeshi.buwan.util.JsonUtil;
import com.yeshi.buwan.util.StringUtil;
@@ -51,6 +52,10 @@
    @Resource
    private ConfigParser configParser;
    @Resource
    private BaiduParser baiduParser;
    @Resource
    private UserService userService;
@@ -105,7 +110,7 @@
            classParser.getHotStarDetail(acceptData, request, out);
        } else if (method.equalsIgnoreCase("getVideoClass")) {
            classParser.getVideoClass(acceptData, request, out);
        }else if (method.equalsIgnoreCase("getHomeClass")) {
        } else if (method.equalsIgnoreCase("getHomeClass")) {
            classParser.getHomeClass(acceptData, request, out);
        } else if (method.equalsIgnoreCase("getNewClass")) {
            classParser.getNewClass(acceptData, request, out); // 分类
@@ -273,7 +278,7 @@
            userParser.suggestSearch(acceptData, request, out);
        } else if (method.equalsIgnoreCase("search")) {// 搜索
            userParser.search(acceptData, request, out);
        }else if (method.equalsIgnoreCase("searchNew")) {// 搜索
        } else if (method.equalsIgnoreCase("searchNew")) {// 搜索
            userParser.searchNew(acceptData, request, out);
        } else if (method.equalsIgnoreCase("getHotSearch")) {// 获取热门搜索
            userParser.getHotSearch(acceptData, request, out);
@@ -455,11 +460,35 @@
        if (!Utils.signIsRight(request))
            out.print(JsonUtil.loadFalseJson("签名错误"));
        if (method.equalsIgnoreCase("getConfig")) {// 获取用户编号
            configParser.getConfig(acceptData, request, out);
        switch (method) {
            case "getConfig":
                configParser.getConfig(acceptData, request, out);
                break;
            case "getHomeConfig"://获取首页配置信息
                configParser.getHomeConfig(acceptData, request, out);
                break;
        }
        out.close();
    }
    @RequestMapping(value = "/baidu", method = RequestMethod.POST)
    public void baidu(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
        String method = request.getParameter("Method");
        if (StringUtil.isNullOrEmpty(method))
            return;
        if (!Utils.signIsRight(request))
            out.print(JsonUtil.loadFalseJson("签名错误"));
        switch (method) {
            case "getNewsTypeList":
                baiduParser.getNewsTypeList(acceptData, request, out);
                break;
            case "getVideoTypeList":
                baiduParser.getVideoTypeList(acceptData, request, out);
                break;
        }
        out.close();
    }
}
src/main/java/com/yeshi/buwan/controller/parser/BaiduParser.java
@@ -1,20 +1,50 @@
package com.yeshi.buwan.controller.parser;
import com.google.gson.Gson;
import com.yeshi.buwan.service.imp.ConfigService;
import com.yeshi.buwan.service.inter.baidu.BaiDuCPUService;
import com.yeshi.buwan.util.JsonUtil;
import com.yeshi.buwan.vo.AcceptData;
import com.yeshi.buwan.vo.baidu.BaiDuCPUTypeVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.PrintWriter;
import java.util.List;
@Controller
public class BaiduParser {
    Logger logger = LoggerFactory.getLogger(BaiduParser.class);
    @Resource
    private ConfigService configService;
    private BaiDuCPUService baiDuCPUService;
    /**
     * 获取百度资讯的分类
     *
     * @param acceptData
     * @param request
     * @param out
     */
    public void getNewsTypeList(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
        List<BaiDuCPUTypeVO> list = baiDuCPUService.getNewsTypeListCache();
        out.print(JsonUtil.loadTrueJson(new Gson().toJson(list)));
    }
    /**
     * 获取百度视频的分类
     *
     * @param acceptData
     * @param request
     * @param out
     */
    public void getVideoTypeList(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
        List<BaiDuCPUTypeVO> list = baiDuCPUService.getVideoTypeListCache();
        out.print(JsonUtil.loadTrueJson(new Gson().toJson(list)));
    }
}
src/main/java/com/yeshi/buwan/controller/parser/ClassParser.java
@@ -277,7 +277,7 @@
        vo.setDataType(HomeClassVO.DATA_TYPE_NOVEL);
        vo.setName("小说");
        typelist.add(3, vo);
        typelist.add(1, vo);
        JSONObject object = new JSONObject();
        object.put("count", (new StringBuilder(String.valueOf(typelist.size()))).toString());
src/main/java/com/yeshi/buwan/controller/parser/ConfigParser.java
@@ -1,14 +1,19 @@
package com.yeshi.buwan.controller.parser;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import com.google.gson.GsonBuilder;
import com.yeshi.buwan.domain.Config;
import com.yeshi.buwan.domain.DetailSystem;
import com.yeshi.buwan.domain.recommend.FloatAD;
import com.yeshi.buwan.log.LogHelper;
import com.yeshi.buwan.service.imp.SystemService;
import com.yeshi.buwan.service.inter.ad.FloatADService;
import com.yeshi.buwan.util.IPUtil;
import com.yeshi.buwan.util.StringUtil;
import com.yeshi.buwan.vo.AcceptData;
@@ -30,6 +35,9 @@
    private ConfigService configService;
    @Resource
    private SystemService systemService;
    @Resource
    private FloatADService floatADService;
    public String getAdShowType(String key, String channel, int version, Map<String, String> map) {
        String splash = map.get(key);
@@ -92,6 +100,27 @@
        out.print(JsonUtil.loadTrueJson(data.toString()));
    }
    /**
     * 获取首页配置信息
     *
     * @param acceptData
     * @param request
     * @param out
     */
    public void getHomeConfig(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
        DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName());
        List<FloatAD> adList = floatADService.listShowAD(1, 1);
        Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
        JSONObject data = new JSONObject();
        if (adList != null && adList.size() > 0) {
            FloatAD ad = adList.get(0);
            data.put("floatAD", gson.toJson(ad));
        }
        out.print(JsonUtil.loadTrueJson(data.toString()));
    }
    class ADConfig {
        int version;
        String type;
src/main/java/com/yeshi/buwan/dao/jump/JumpDetailDao.java
New file
@@ -0,0 +1,27 @@
package com.yeshi.buwan.dao.jump;
import com.yeshi.buwan.dao.base.MongodbBaseDao;
import com.yeshi.buwan.domain.jump.JumpDetail;
import com.yeshi.buwan.domain.jump.JumpTypeEnum;
import com.yeshi.buwan.domain.recommend.FloatAD;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;
@Repository
public class JumpDetailDao extends MongodbBaseDao<JumpDetail> {
    /**
     * 根据类型查询
     *
     * @param jumpTypeEnum
     * @return
     */
    public JumpDetail selectByType(JumpTypeEnum jumpTypeEnum) {
        Query query = new Query();
        query.addCriteria(Criteria.where("type").is(jumpTypeEnum));
        return findOne(query);
    }
}
src/main/java/com/yeshi/buwan/dao/recommend/FloatADDao.java
New file
@@ -0,0 +1,37 @@
package com.yeshi.buwan.dao.recommend;
import com.yeshi.buwan.dao.base.MongodbBaseDao;
import com.yeshi.buwan.domain.recommend.FloatAD;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;
import java.util.ArrayList;
import java.util.List;
@Repository
public class FloatADDao extends MongodbBaseDao<FloatAD> {
    /**
     * 根据是否显示查询
     *
     * @param show
     * @return
     */
    public List<FloatAD> list(Boolean show, int start, int count) {
        Query query = new Query();
        if (show != null)
            query.addCriteria(Criteria.where("show").is(show));
        List<Sort.Order> orders = new ArrayList<>();
        orders.add(new Sort.Order(Sort.Direction.DESC, "weight"));
        query.with(new Sort(orders));
        query.limit(count);
        query.skip(start);
        return findList(query);
    }
}
src/main/java/com/yeshi/buwan/domain/jump/JumpDetail.java
New file
@@ -0,0 +1,45 @@
package com.yeshi.buwan.domain.jump;
import com.google.gson.annotations.Expose;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
@Document(collection = "jumpDetail")
public class JumpDetail {
    @Expose
    @Indexed
    @Field
    private JumpTypeEnum type;
    @Expose
    @Field
    private String activity;
    @Expose
    @Field
    private String controller;
    public JumpTypeEnum getType() {
        return type;
    }
    public void setType(JumpTypeEnum type) {
        this.type = type;
    }
    public String getActivity() {
        return activity;
    }
    public void setActivity(String activity) {
        this.activity = activity;
    }
    public String getController() {
        return controller;
    }
    public void setController(String controller) {
        this.controller = controller;
    }
}
src/main/java/com/yeshi/buwan/domain/jump/JumpTypeEnum.java
New file
@@ -0,0 +1,13 @@
package com.yeshi.buwan.domain.jump;
public enum JumpTypeEnum {
    baichuan("百川"), web("网页"),clazz("类");
    private String name;
    private JumpTypeEnum(String name) {
        this.name = name;
    }
}
src/main/java/com/yeshi/buwan/domain/recommend/FloatAD.java
New file
@@ -0,0 +1,106 @@
package com.yeshi.buwan.domain.recommend;
import com.google.gson.annotations.Expose;
import com.yeshi.buwan.domain.jump.JumpDetail;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
import java.util.Date;
//悬浮大图广告
@Document(collection = "floatAd")
public class FloatAD {
    @Expose
    @Id
    private String id;//主键ID
    @Expose
    @Field
    private String picture;//图片
    @Expose
    @Field
    private JumpDetail jumpDetail;//跳转方式
    @Expose
    @Field
    private String params;//跳转参数
    @Field
    private Integer weight;//权重
    @Field
    private Boolean show;//是否显示
    @Field
    private Date createTime;//创建时间
    @Field
    private Date updateTime;//更新时间
    public Integer getWeight() {
        return weight;
    }
    public void setWeight(Integer weight) {
        this.weight = weight;
    }
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getPicture() {
        return picture;
    }
    public void setPicture(String picture) {
        this.picture = picture;
    }
    public JumpDetail getJumpDetail() {
        return jumpDetail;
    }
    public void setJumpDetail(JumpDetail jumpDetail) {
        this.jumpDetail = jumpDetail;
    }
    public String getParams() {
        return params;
    }
    public void setParams(String params) {
        this.params = params;
    }
    public Boolean getShow() {
        return show;
    }
    public void setShow(Boolean show) {
        this.show = show;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}
src/main/java/com/yeshi/buwan/job/SolrJob.java
@@ -2,8 +2,12 @@
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.yeshi.buwan.service.manager.SolrAlbumDataManager;
import com.yeshi.buwan.util.SolrUtil;
import org.springframework.stereotype.Component;
import org.yeshi.utils.LinuxRemoteCommandUtil;
import javax.annotation.Resource;
/**
@@ -12,6 +16,9 @@
@Component
public class SolrJob {
    @Resource
    private SolrAlbumDataManager solrAlbumDataManager;
    @XxlJob("solr-watch")
    public ReturnT<String> reStartSolr(String param) throws Exception {
        String solrIP = "172.16.16.12";
@@ -21,4 +28,32 @@
        return ReturnT.SUCCESS;
    }
    /**
     * 同步专辑
     *
     * @param param
     * @return
     * @throws Exception
     */
    @XxlJob("solr-syncAlbum")
    public ReturnT<String> syncAlbum(String param) throws Exception {
        solrAlbumDataManager.syncAllAlbum();
        return ReturnT.SUCCESS;
    }
    /**
     * 同步常规搜索
     *
     * @param param
     * @return
     * @throws Exception
     */
    @XxlJob("solr-syncVideoCore")
    public ReturnT<String> syncCore(String param) throws Exception {
        //同步视频
        SolrUtil.dataimportVideo(param);
        return ReturnT.SUCCESS;
    }
}
src/main/java/com/yeshi/buwan/service/imp/ad/FloatADServiceImpl.java
New file
@@ -0,0 +1,21 @@
package com.yeshi.buwan.service.imp.ad;
import com.yeshi.buwan.dao.recommend.FloatADDao;
import com.yeshi.buwan.domain.recommend.FloatAD;
import com.yeshi.buwan.service.inter.ad.FloatADService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class FloatADServiceImpl implements FloatADService {
    @Resource
    private FloatADDao floatADDao;
    @Override
    public List<FloatAD> listShowAD(int page, int pageSize) {
        return floatADDao.list(true, (page - 1) * pageSize, pageSize);
    }
}
src/main/java/com/yeshi/buwan/service/imp/baidu/BaiDuCPUServiceImpl.java
New file
@@ -0,0 +1,38 @@
package com.yeshi.buwan.service.imp.baidu;
import com.yeshi.buwan.service.inter.baidu.BaiDuCPUService;
import com.yeshi.buwan.util.BaiDuCPUUtil;
import com.yeshi.buwan.vo.baidu.BaiDuCPUTypeVO;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class BaiDuCPUServiceImpl implements BaiDuCPUService {
    @Cacheable(value = "classCache", key = "'baidu-getNewsTypeList'")
    @Override
    public List<BaiDuCPUTypeVO> getNewsTypeListCache() {
        return BaiDuCPUUtil.getNewsTotalTypes();
    }
    @Cacheable(value = "classCache", key = "'baidu-getVideoTypeList'")
    @Override
    public List<BaiDuCPUTypeVO> getVideoTypeListCache() {
        return BaiDuCPUUtil.getVideosTotalTypes();
    }
    @Cacheable(value = "classCache", key = "'baidu-getNewsSafeTypeList'")
    @Override
    public List<BaiDuCPUTypeVO> getNewsSafeTypeListCache() {
        return BaiDuCPUUtil.getNewsSafeTypes();
    }
    @Cacheable(value = "classCache", key = "'baidu-getVideoSafeTypeList'")
    @Override
    public List<BaiDuCPUTypeVO> getVideoSafeTypeListCache() {
        return BaiDuCPUUtil.getVideoSafeTypes();
    }
}
src/main/java/com/yeshi/buwan/service/imp/jump/JumpDetailServiceImpl.java
New file
@@ -0,0 +1,21 @@
package com.yeshi.buwan.service.imp.jump;
import com.yeshi.buwan.dao.jump.JumpDetailDao;
import com.yeshi.buwan.domain.jump.JumpDetail;
import com.yeshi.buwan.domain.jump.JumpTypeEnum;
import com.yeshi.buwan.service.inter.jump.JumpDetailService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service
public class JumpDetailServiceImpl implements JumpDetailService {
    @Resource
    private JumpDetailDao jumpDetailDao;
    @Override
    public JumpDetail selectByType(JumpTypeEnum type) {
        return jumpDetailDao.selectByType(type);
    }
}
src/main/java/com/yeshi/buwan/service/inter/ad/FloatADService.java
New file
@@ -0,0 +1,18 @@
package com.yeshi.buwan.service.inter.ad;
import com.yeshi.buwan.domain.recommend.FloatAD;
import java.util.List;
public interface FloatADService {
    /**
     * 查询正在显示的广告
     *
     * @param page
     * @param pageSize
     * @return
     */
    public List<FloatAD> listShowAD(int page, int pageSize);
}
src/main/java/com/yeshi/buwan/service/inter/baidu/BaiDuCPUService.java
New file
@@ -0,0 +1,23 @@
package com.yeshi.buwan.service.inter.baidu;
import com.yeshi.buwan.vo.baidu.BaiDuCPUTypeVO;
import java.util.List;
/**
 * 百度内容联盟服务
 */
public interface BaiDuCPUService {
    /**
     * @return
     */
    public List<BaiDuCPUTypeVO> getNewsTypeListCache();
    public List<BaiDuCPUTypeVO> getVideoTypeListCache();
    public List<BaiDuCPUTypeVO> getNewsSafeTypeListCache();
    public List<BaiDuCPUTypeVO> getVideoSafeTypeListCache();
}
src/main/java/com/yeshi/buwan/service/inter/jump/JumpDetailService.java
New file
@@ -0,0 +1,10 @@
package com.yeshi.buwan.service.inter.jump;
import com.yeshi.buwan.domain.jump.JumpDetail;
import com.yeshi.buwan.domain.jump.JumpTypeEnum;
public interface JumpDetailService {
    public JumpDetail selectByType(JumpTypeEnum type);
}
src/main/java/com/yeshi/buwan/util/SolrUtil.java
@@ -18,535 +18,542 @@
public class SolrUtil {
    // 腾讯云
    static String IP_OUT = "203.195.196.115";
    static String IP_IN = "172.16.16.12";// 10.165.56.110 10.129.37.198
    // 腾讯云
    static String IP_OUT = "203.195.196.115";
    static String IP_IN = "172.16.16.12";// 10.165.56.110 10.129.37.198
    private static String escapeQueryChars(String s) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            // These characters are part of the query syntax and must be escaped
            if (c == '\\' || c == '+' || c == '-' || c == '!' || c == '(' || c == ')' || c == ':' || c == '^'
                    || c == '[' || c == ']' || c == '\"' || c == '{' || c == '}' || c == '~' || c == '*' || c == '?'
                    || c == '|' || c == '&' || c == ';' || c == '/' || Character.isWhitespace(c)) {
                sb.append('\\');
            }
            sb.append(c);
        }
        return sb.toString();
    }
    private static String escapeQueryChars(String s) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            // These characters are part of the query syntax and must be escaped
            if (c == '\\' || c == '+' || c == '-' || c == '!' || c == '(' || c == ')' || c == ':' || c == '^'
                    || c == '[' || c == ']' || c == '\"' || c == '{' || c == '}' || c == '~' || c == '*' || c == '?'
                    || c == '|' || c == '&' || c == ';' || c == '/' || Character.isWhitespace(c)) {
                sb.append('\\');
            }
            sb.append(c);
        }
        return sb.toString();
    }
    public static List<VideoInfo> searchStarVideos(String key, int pageIndex) {
        List<VideoInfo> list = new ArrayList<VideoInfo>();
        try {
            String url = String.format("http://%s:8983/solr/buwan/select?q=%s&fq=show:1&fq=contenttype:1&start="
                    + (pageIndex - 1) * Constant.pageCount + "&rows=" + Constant.pageCount + "&wt=json&indent=true&_="// 10.165.56.110
                    // 121.42.58.49
                    + System.currentTimeMillis(), Constant.IsOutNet ? IP_IN : IP_OUT,
                    "mainactor:" + URLEncoder.encode(escapeQueryChars(key), "UTF-8"));
            Map<String, String> map = new HashMap<String, String>();
            map.put("Accept", "application/json, text/javascript, */*; q=0.01");
    public static List<VideoInfo> searchStarVideos(String key, int pageIndex) {
        List<VideoInfo> list = new ArrayList<VideoInfo>();
        try {
            String url = String.format("http://%s:8983/solr/buwan/select?q=%s&fq=show:1&fq=contenttype:1&start="
                            + (pageIndex - 1) * Constant.pageCount + "&rows=" + Constant.pageCount + "&wt=json&indent=true&_="// 10.165.56.110
                            // 121.42.58.49
                            + System.currentTimeMillis(), Constant.IsOutNet ? IP_IN : IP_OUT,
                    "mainactor:" + URLEncoder.encode(escapeQueryChars(key), "UTF-8"));
            Map<String, String> map = new HashMap<String, String>();
            map.put("Accept", "application/json, text/javascript, */*; q=0.01");
            InputStream is = HttpUtil.getAsInputStream(url);
            BufferedReader in = new BufferedReader(new InputStreamReader(is, "UTF-8"));
            StringBuffer buffer = new StringBuffer();
            String line = "";
            try {
                while ((line = in.readLine()) != null) {
                    buffer.append(line);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            InputStream is = HttpUtil.getAsInputStream(url);
            BufferedReader in = new BufferedReader(new InputStreamReader(is, "UTF-8"));
            StringBuffer buffer = new StringBuffer();
            String line = "";
            try {
                while ((line = in.readLine()) != null) {
                    buffer.append(line);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            JSONObject data = JSONObject.fromObject(buffer.toString());
            JSONArray array = data.optJSONObject("response").optJSONArray("docs");
            for (int i = 0; i < array.size(); i++) {
                JSONObject obj = array.optJSONObject(i);
                list.add(convertJSONTOVideo(obj));
            }
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return list;
    }
            JSONObject data = JSONObject.fromObject(buffer.toString());
            JSONArray array = data.optJSONObject("response").optJSONArray("docs");
            for (int i = 0; i < array.size(); i++) {
                JSONObject obj = array.optJSONObject(i);
                list.add(convertJSONTOVideo(obj));
            }
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return list;
    }
    public static List<VideoInfo> search(String key, int pageIndex) {
        List<VideoInfo> list = new ArrayList<VideoInfo>();
        try {
            String url = String.format("http://%s:8983/solr/buwan/select?q=%s&fq=show:1&start="
                    + (pageIndex - 1) * Constant.pageCount + "&rows=" + Constant.pageCount + "&wt=json&indent=true&_="// 10.165.56.110
                    // 121.42.58.49
                    + System.currentTimeMillis(), Constant.IsOutNet ? IP_IN : IP_OUT,
                    "name:" + URLEncoder.encode("\""+escapeQueryChars(key) + "\"", "UTF-8"));
            Map<String, String> map = new HashMap<String, String>();
            map.put("Accept", "application/json, text/javascript, */*; q=0.01");
    public static List<VideoInfo> search(String key, int pageIndex) {
        List<VideoInfo> list = new ArrayList<VideoInfo>();
        try {
            String url = String.format("http://%s:8983/solr/buwan/select?q=%s&fq=show:1&start="
                            + (pageIndex - 1) * Constant.pageCount + "&rows=" + Constant.pageCount + "&wt=json&indent=true&_="// 10.165.56.110
                            // 121.42.58.49
                            + System.currentTimeMillis(), Constant.IsOutNet ? IP_IN : IP_OUT,
                    "name:" + URLEncoder.encode("\"" + escapeQueryChars(key) + "\"", "UTF-8"));
            Map<String, String> map = new HashMap<String, String>();
            map.put("Accept", "application/json, text/javascript, */*; q=0.01");
            InputStream is = HttpUtil.getAsInputStream(url);
            BufferedReader in = new BufferedReader(new InputStreamReader(is, "UTF-8"));
            StringBuffer buffer = new StringBuffer();
            String line = "";
            try {
                while ((line = in.readLine()) != null) {
                    buffer.append(line);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            InputStream is = HttpUtil.getAsInputStream(url);
            BufferedReader in = new BufferedReader(new InputStreamReader(is, "UTF-8"));
            StringBuffer buffer = new StringBuffer();
            String line = "";
            try {
                while ((line = in.readLine()) != null) {
                    buffer.append(line);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            JSONObject data = JSONObject.fromObject(buffer.toString());
            JSONArray array = data.optJSONObject("response").optJSONArray("docs");
            for (int i = 0; i < array.size(); i++) {
                JSONObject obj = array.optJSONObject(i);
                list.add(convertJSONTOVideo(obj));
            }
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return list;
    }
            JSONObject data = JSONObject.fromObject(buffer.toString());
            JSONArray array = data.optJSONObject("response").optJSONArray("docs");
            for (int i = 0; i < array.size(); i++) {
                JSONObject obj = array.optJSONObject(i);
                list.add(convertJSONTOVideo(obj));
            }
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return list;
    }
    public static List<VideoInfo> searchZhengPian(String key, int pageIndex) {
        List<VideoInfo> list = new ArrayList<VideoInfo>();
        try {
            String url = String.format("http://%s:8983/solr/buwan/select?q=%s&fq=%s&fq=show:1&start="
                    + (pageIndex - 1) * Constant.pageCount + "&rows=" + Constant.pageCount + "&wt=json&indent=true&_="// 10.165.56.110
                                                                                                                        // //
                                                                                                                        // 121.42.58.49
                    + System.currentTimeMillis(), Constant.IsOutNet ? IP_IN : IP_OUT,
                    "name:" + URLEncoder.encode(escapeQueryChars(key), "UTF-8"), "contenttype:1");
            Map<String, String> map = new HashMap<String, String>();
            map.put("Accept", "application/json, text/javascript, */*; q=0.01");
    public static List<VideoInfo> searchZhengPian(String key, int pageIndex) {
        List<VideoInfo> list = new ArrayList<VideoInfo>();
        try {
            String url = String.format("http://%s:8983/solr/buwan/select?q=%s&fq=%s&fq=show:1&start="
                            + (pageIndex - 1) * Constant.pageCount + "&rows=" + Constant.pageCount + "&wt=json&indent=true&_="// 10.165.56.110
                            // //
                            // 121.42.58.49
                            + System.currentTimeMillis(), Constant.IsOutNet ? IP_IN : IP_OUT,
                    "name:" + URLEncoder.encode(escapeQueryChars(key), "UTF-8"), "contenttype:1");
            Map<String, String> map = new HashMap<String, String>();
            map.put("Accept", "application/json, text/javascript, */*; q=0.01");
            InputStream is = HttpUtil.getAsInputStream(url);
            BufferedReader in = new BufferedReader(new InputStreamReader(is, "UTF-8"));
            StringBuffer buffer = new StringBuffer();
            String line = "";
            try {
                while ((line = in.readLine()) != null) {
                    buffer.append(line);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            InputStream is = HttpUtil.getAsInputStream(url);
            BufferedReader in = new BufferedReader(new InputStreamReader(is, "UTF-8"));
            StringBuffer buffer = new StringBuffer();
            String line = "";
            try {
                while ((line = in.readLine()) != null) {
                    buffer.append(line);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            JSONObject data = JSONObject.fromObject(buffer.toString());
            JSONArray array = data.optJSONObject("response").optJSONArray("docs");
            for (int i = 0; i < array.size(); i++) {
                JSONObject obj = array.optJSONObject(i);
                list.add(convertJSONTOVideo(obj));
            }
            JSONObject data = JSONObject.fromObject(buffer.toString());
            JSONArray array = data.optJSONObject("response").optJSONArray("docs");
            for (int i = 0; i < array.size(); i++) {
                JSONObject obj = array.optJSONObject(i);
                list.add(convertJSONTOVideo(obj));
            }
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return list;
    }
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return list;
    }
    public static List<VideoInfo> searchZhuanJi(String key, int pageIndex) {
        List<VideoInfo> list = new ArrayList<VideoInfo>();
        try {
            String url = String.format("http://%s:8983/solr/buwan/select?q=%s&fq=%s&fq=show:1&start="
                    + (pageIndex - 1) * Constant.pageCount + "&rows=" + Constant.pageCount + "&wt=json&indent=true&_="// 10.165.56.110
                                                                                                                        // //
                                                                                                                        // 121.42.58.49
                    + System.currentTimeMillis(), Constant.IsOutNet ? IP_IN : IP_OUT,
                    "name:" + URLEncoder.encode(escapeQueryChars(key), "UTF-8"),
                    URLEncoder.encode(("videocount:[2 TO *]"), "UTF-8"));
            Map<String, String> map = new HashMap<String, String>();
            map.put("Accept", "application/json, text/javascript, */*; q=0.01");
    public static List<VideoInfo> searchZhuanJi(String key, int pageIndex) {
        List<VideoInfo> list = new ArrayList<VideoInfo>();
        try {
            String url = String.format("http://%s:8983/solr/buwan/select?q=%s&fq=%s&fq=show:1&start="
                            + (pageIndex - 1) * Constant.pageCount + "&rows=" + Constant.pageCount + "&wt=json&indent=true&_="// 10.165.56.110
                            // //
                            // 121.42.58.49
                            + System.currentTimeMillis(), Constant.IsOutNet ? IP_IN : IP_OUT,
                    "name:" + URLEncoder.encode(escapeQueryChars(key), "UTF-8"),
                    URLEncoder.encode(("videocount:[2 TO *]"), "UTF-8"));
            Map<String, String> map = new HashMap<String, String>();
            map.put("Accept", "application/json, text/javascript, */*; q=0.01");
            InputStream is = HttpUtil.getAsInputStream(url);
            BufferedReader in = new BufferedReader(new InputStreamReader(is, "UTF-8"));
            StringBuffer buffer = new StringBuffer();
            String line = "";
            try {
                while ((line = in.readLine()) != null) {
                    buffer.append(line);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            InputStream is = HttpUtil.getAsInputStream(url);
            BufferedReader in = new BufferedReader(new InputStreamReader(is, "UTF-8"));
            StringBuffer buffer = new StringBuffer();
            String line = "";
            try {
                while ((line = in.readLine()) != null) {
                    buffer.append(line);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            JSONObject data = JSONObject.fromObject(buffer.toString());
            JSONArray array = data.optJSONObject("response").optJSONArray("docs");
            for (int i = 0; i < array.size(); i++) {
                JSONObject obj = array.optJSONObject(i);
                list.add(convertJSONTOVideo(obj));
            }
            JSONObject data = JSONObject.fromObject(buffer.toString());
            JSONArray array = data.optJSONObject("response").optJSONArray("docs");
            for (int i = 0; i < array.size(); i++) {
                JSONObject obj = array.optJSONObject(i);
                list.add(convertJSONTOVideo(obj));
            }
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return list;
    }
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return list;
    }
    private static VideoInfo convertJSONTOVideo(JSONObject obj) {
        VideoInfo info = new VideoInfo();
        info.setId(obj.optString("id"));
        info.setArea(obj.optString("area"));
        info.setContentType(obj.optInt("contenttype"));
        info.setDirector(obj.optString("director"));
        info.setDuration(obj.optString("duration"));
        info.setHpicture(obj.optString("hpicture"));
        info.setMainActor(obj.optString("mainactor"));
        info.setName(obj.optString("name"));
        info.setPicture(obj.optString("picture"));
        info.setScore(obj.optString("score"));
        info.setShow(obj.optString("show"));
        info.setTag(obj.optString("tag"));
        info.setVpicture(obj.optString("vpicture"));
        info.setWatchCount(obj.optString("watchcount"));
        info.setUpdatetime(obj.optString("updatetime"));
        info.setCreatetime(obj.optLong("createtime"));
        info.setCommentCount(StringUtil.isNullOrEmpty(obj.optString("commentcount")) ? 0
                : Integer.parseInt(obj.optString("commentcount")));
        info.setVideocount(obj.optInt("videocount"));
        return info;
    }
    private static VideoInfo convertJSONTOVideo(JSONObject obj) {
        VideoInfo info = new VideoInfo();
        info.setId(obj.optString("id"));
        info.setArea(obj.optString("area"));
        info.setContentType(obj.optInt("contenttype"));
        info.setDirector(obj.optString("director"));
        info.setDuration(obj.optString("duration"));
        info.setHpicture(obj.optString("hpicture"));
        info.setMainActor(obj.optString("mainactor"));
        info.setName(obj.optString("name"));
        info.setPicture(obj.optString("picture"));
        info.setScore(obj.optString("score"));
        info.setShow(obj.optString("show"));
        info.setTag(obj.optString("tag"));
        info.setVpicture(obj.optString("vpicture"));
        info.setWatchCount(obj.optString("watchcount"));
        info.setUpdatetime(obj.optString("updatetime"));
        info.setCreatetime(obj.optLong("createtime"));
        info.setCommentCount(StringUtil.isNullOrEmpty(obj.optString("commentcount")) ? 0
                : Integer.parseInt(obj.optString("commentcount")));
        info.setVideocount(obj.optInt("videocount"));
        return info;
    }
    @SuppressWarnings("deprecation")
    public static void deleteVideoIndex(String id) {
        String url = String.format(
                "http://%s:8983/solr/buwan/update?stream.body=%s&stream.contentType=text/xml;charset=utf-8&commit=true",
                Constant.IsOutNet ? IP_IN : IP_OUT, URLEncoder.encode("<delete><id>" + id + "</id></delete>"));
        String result = HttpUtil.get(url);
        System.out.println(result);
    }
    @SuppressWarnings("deprecation")
    public static void deleteVideoIndex(String id) {
        String url = String.format(
                "http://%s:8983/solr/buwan/update?stream.body=%s&stream.contentType=text/xml;charset=utf-8&commit=true",
                Constant.IsOutNet ? IP_IN : IP_OUT, URLEncoder.encode("<delete><id>" + id + "</id></delete>"));
        String result = HttpUtil.get(url);
        System.out.println(result);
    }
    public static Map<String, Object> getCategoryVideoList(int pageIndex, String key, int contenttype,
            List<Long> videoTypeIds, String sort) {
        Map<String, Object> map = new HashMap<String, Object>();
    public static Map<String, Object> getCategoryVideoList(int pageIndex, String key, int contenttype,
                                                           List<Long> videoTypeIds, String sort) {
        Map<String, Object> map = new HashMap<String, Object>();
        String q = "";
        q += "q=";
        if (videoTypeIds != null && videoTypeIds.size() > 0) {
        String q = "";
        q += "q=";
        if (videoTypeIds != null && videoTypeIds.size() > 0) {
            String qparmas = "(";
            for (Long type : videoTypeIds) {
                qparmas += String.format("videotypeid:%s OR ", type + "");
            }
            String qparmas = "(";
            for (Long type : videoTypeIds) {
                qparmas += String.format("videotypeid:%s OR ", type + "");
            }
            if (qparmas.endsWith("OR "))
                qparmas = qparmas.substring(0, qparmas.length() - 3);
            if (qparmas.endsWith("OR "))
                qparmas = qparmas.substring(0, qparmas.length() - 3);
            qparmas += ")";
            if (!StringUtil.isNullOrEmpty(key)) {
                qparmas += String.format(" AND (name:%s)", "\"" + key + "\"");
            }
            qparmas += ")";
            if (!StringUtil.isNullOrEmpty(key)) {
                qparmas += String.format(" AND (name:%s)", "\"" + key + "\"");
            }
            try {
                q += URLEncoder.encode(qparmas, "UTF-8");
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        } else {
            String qparmas = "";
            if (!StringUtil.isNullOrEmpty(key)) {
                qparmas += String.format("name:%s", "\"" + key + "\"");
            } else {
                qparmas += "*:*";
            }
            try {
                q += URLEncoder.encode(qparmas, "UTF-8");
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
            try {
                q += URLEncoder.encode(qparmas, "UTF-8");
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        } else {
            String qparmas = "";
            if (!StringUtil.isNullOrEmpty(key)) {
                qparmas += String.format("name:%s", "\"" + key + "\"");
            } else {
                qparmas += "*:*";
            }
            try {
                q += URLEncoder.encode(qparmas, "UTF-8");
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }
        }
        if (sort != null) {
            try {
                sort = URLEncoder.encode(sort, "UTF-8");
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }
        if (sort != null) {
            try {
                sort = URLEncoder.encode(sort, "UTF-8");
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }
        String fq = "";
        String fq = "";
        if (contenttype == 1)
            fq += "contenttype:1";
        else if (contenttype > 1) {
            fq += "contenttype:[2 TO 100]";
        }
        if (contenttype == 1)
            fq += "contenttype:1";
        else if (contenttype > 1) {
            fq += "contenttype:[2 TO 100]";
        }
        fq = StringUtil.isNullOrEmpty(fq) ? "" : "fq=" + URLEncoder.encode(fq);
        fq = StringUtil.isNullOrEmpty(fq) ? "" : "fq=" + URLEncoder.encode(fq);
        String url = String.format(
                "http://%s:8983/solr/buwan_videotype_video/select?%s&%s&group=true&group.field=videoid&sort=%s&start="
                        + (pageIndex - 1) * Constant.pageCount + "&rows=" + Constant.pageCount
                        + "&wt=json&indent=true&_=" + System.currentTimeMillis(),
                Constant.IsOutNet ? IP_IN : IP_OUT, q, fq, sort);
        String url = String.format(
                "http://%s:8983/solr/buwan_videotype_video/select?%s&%s&group=true&group.field=videoid&sort=%s&start="
                        + (pageIndex - 1) * Constant.pageCount + "&rows=" + Constant.pageCount
                        + "&wt=json&indent=true&_=" + System.currentTimeMillis(),
                Constant.IsOutNet ? IP_IN : IP_OUT, q, fq, sort);
        try {
            InputStream is = HttpUtil.getAsInputStream(url);
            BufferedReader in = new BufferedReader(new InputStreamReader(is, "UTF-8"));
            StringBuffer buffer = new StringBuffer();
            String line = "";
            try {
                while ((line = in.readLine()) != null) {
                    buffer.append(line);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        try {
            InputStream is = HttpUtil.getAsInputStream(url);
            BufferedReader in = new BufferedReader(new InputStreamReader(is, "UTF-8"));
            StringBuffer buffer = new StringBuffer();
            String line = "";
            try {
                while ((line = in.readLine()) != null) {
                    buffer.append(line);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            JSONObject data = JSONObject.fromObject(buffer.toString());
            int count = data.optJSONObject("grouped").optJSONObject("videoid").optInt("matches");
            map.put("count", count);
            JSONArray array = data.optJSONObject("grouped").optJSONObject("videoid").optJSONArray("groups");
            List<Long> videoIdList = new ArrayList<Long>();
            for (int i = 0; i < array.size(); i++) {
                JSONArray docsArray = array.optJSONObject(i).optJSONObject("doclist").optJSONArray("docs");
                if (docsArray.size() > 0) {
                    videoIdList.add(docsArray.optJSONObject(0).optLong("videoid"));
                }
            }
            JSONObject data = JSONObject.fromObject(buffer.toString());
            int count = data.optJSONObject("grouped").optJSONObject("videoid").optInt("matches");
            map.put("count", count);
            JSONArray array = data.optJSONObject("grouped").optJSONObject("videoid").optJSONArray("groups");
            List<Long> videoIdList = new ArrayList<Long>();
            for (int i = 0; i < array.size(); i++) {
                JSONArray docsArray = array.optJSONObject(i).optJSONObject("doclist").optJSONArray("docs");
                if (docsArray.size() > 0) {
                    videoIdList.add(docsArray.optJSONObject(0).optLong("videoid"));
                }
            }
            if (videoIdList.size() > 0) {// 有视频数据
                List<VideoInfo> videoList = new ArrayList<VideoInfo>();
            if (videoIdList.size() > 0) {// 有视频数据
                List<VideoInfo> videoList = new ArrayList<VideoInfo>();
                q = "q=";
                String qparams = "";
                for (long videoid : videoIdList) {
                    qparams += String.format("id:%s or ", videoid);
                }
                if (qparams.endsWith("or "))
                    qparams = qparams.substring(0, qparams.length() - 3);
                q += URLEncoder.encode(qparams, "UTF-8");
                url = String.format(
                        "http://%s:8983/solr/buwan/select?%s&sort=%s&rows=" + Constant.pageCount + ""
                                + "&wt=json&indent=true&_t=" + System.currentTimeMillis(),
                        Constant.IsOutNet ? IP_IN : IP_OUT, q, sort);
                is = HttpUtil.getAsInputStream(url);
                in = new BufferedReader(new InputStreamReader(is, "UTF-8"));
                buffer = new StringBuffer();
                line = "";
                try {
                    while ((line = in.readLine()) != null) {
                        buffer.append(line);
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
                q = "q=";
                String qparams = "";
                for (long videoid : videoIdList) {
                    qparams += String.format("id:%s or ", videoid);
                }
                if (qparams.endsWith("or "))
                    qparams = qparams.substring(0, qparams.length() - 3);
                q += URLEncoder.encode(qparams, "UTF-8");
                url = String.format(
                        "http://%s:8983/solr/buwan/select?%s&sort=%s&rows=" + Constant.pageCount + ""
                                + "&wt=json&indent=true&_t=" + System.currentTimeMillis(),
                        Constant.IsOutNet ? IP_IN : IP_OUT, q, sort);
                is = HttpUtil.getAsInputStream(url);
                in = new BufferedReader(new InputStreamReader(is, "UTF-8"));
                buffer = new StringBuffer();
                line = "";
                try {
                    while ((line = in.readLine()) != null) {
                        buffer.append(line);
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
                data = JSONObject.fromObject(buffer.toString());
                array = data.optJSONObject("response").optJSONArray("docs");
                for (int i = 0; i < array.size(); i++) {
                    JSONObject obj = array.optJSONObject(i);
                    videoList.add(convertJSONTOVideo(obj));
                }
                map.put("data", videoList);
                return map;
            }
                data = JSONObject.fromObject(buffer.toString());
                array = data.optJSONObject("response").optJSONArray("docs");
                for (int i = 0; i < array.size(); i++) {
                    JSONObject obj = array.optJSONObject(i);
                    videoList.add(convertJSONTOVideo(obj));
                }
                map.put("data", videoList);
                return map;
            }
        } catch (Exception e) {
            e.fillInStackTrace();
        }
        return null;
        } catch (Exception e) {
            e.fillInStackTrace();
        }
        return null;
    }
    }
    public static Map<String, Object> getCategoryVideoList(int pageIndex, String key, int contenttype,
            List<Long> videoTypeIds) {
        Map<String, Object> map = new HashMap<String, Object>();
    public static Map<String, Object> getCategoryVideoList(int pageIndex, String key, int contenttype,
                                                           List<Long> videoTypeIds) {
        Map<String, Object> map = new HashMap<String, Object>();
        String q = "";
        q += "q=";
        if (videoTypeIds != null && videoTypeIds.size() > 0) {
        String q = "";
        q += "q=";
        if (videoTypeIds != null && videoTypeIds.size() > 0) {
            String qparmas = "(";
            for (Long type : videoTypeIds) {
                qparmas += String.format("videotypeid:%s or ", type + "");
            }
            String qparmas = "(";
            for (Long type : videoTypeIds) {
                qparmas += String.format("videotypeid:%s or ", type + "");
            }
            if (qparmas.endsWith("or "))
                qparmas = qparmas.substring(0, qparmas.length() - 3);
            if (qparmas.endsWith("or "))
                qparmas = qparmas.substring(0, qparmas.length() - 3);
            qparmas += ")";
            if (!StringUtil.isNullOrEmpty(key)) {
                qparmas += String.format(" and (name:%s)", key);
            }
            qparmas += ")";
            if (!StringUtil.isNullOrEmpty(key)) {
                qparmas += String.format(" and (name:%s)", key);
            }
            try {
                q += URLEncoder.encode(qparmas, "UTF-8");
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        } else {
            String qparmas = "";
            if (!StringUtil.isNullOrEmpty(key)) {
                qparmas += String.format("name:%s", key);
            } else {
                qparmas += "*:*";
            }
            try {
                q += URLEncoder.encode(qparmas, "UTF-8");
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
            try {
                q += URLEncoder.encode(qparmas, "UTF-8");
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        } else {
            String qparmas = "";
            if (!StringUtil.isNullOrEmpty(key)) {
                qparmas += String.format("name:%s", key);
            } else {
                qparmas += "*:*";
            }
            try {
                q += URLEncoder.encode(qparmas, "UTF-8");
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }
        }
        String sort = "";
        try {
            if (StringUtil.isNullOrEmpty(key))
                sort = URLEncoder.encode("createtime desc", "UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        String sort = "";
        try {
            if (StringUtil.isNullOrEmpty(key))
                sort = URLEncoder.encode("createtime desc", "UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        String fq = "";
        String fq = "";
        if (contenttype == 1)
            fq += "contenttype:1";
        else if (contenttype > 1) {
            fq += "contenttype:[2 TO 100]";
        }
        if (contenttype == 1)
            fq += "contenttype:1";
        else if (contenttype > 1) {
            fq += "contenttype:[2 TO 100]";
        }
        fq = StringUtil.isNullOrEmpty(fq) ? "" : "fq=" + URLEncoder.encode(fq);
        fq = StringUtil.isNullOrEmpty(fq) ? "" : "fq=" + URLEncoder.encode(fq);
        String url = String.format(
                "http://%s:8983/solr/buwan_videotype_video/select?%s&%s&group=true&group.field=videoid&sort=%s&start="
                        + (pageIndex - 1) * Constant.pageCount + "&rows=" + Constant.pageCount
                        + "&wt=json&indent=true&_=" + System.currentTimeMillis(),
                Constant.IsOutNet ? IP_IN : IP_OUT, q, fq, sort);
        String url = String.format(
                "http://%s:8983/solr/buwan_videotype_video/select?%s&%s&group=true&group.field=videoid&sort=%s&start="
                        + (pageIndex - 1) * Constant.pageCount + "&rows=" + Constant.pageCount
                        + "&wt=json&indent=true&_=" + System.currentTimeMillis(),
                Constant.IsOutNet ? IP_IN : IP_OUT, q, fq, sort);
        try {
            InputStream is = HttpUtil.getAsInputStream(url);
            BufferedReader in = new BufferedReader(new InputStreamReader(is, "UTF-8"));
            StringBuffer buffer = new StringBuffer();
            String line = "";
            try {
                while ((line = in.readLine()) != null) {
                    buffer.append(line);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        try {
            InputStream is = HttpUtil.getAsInputStream(url);
            BufferedReader in = new BufferedReader(new InputStreamReader(is, "UTF-8"));
            StringBuffer buffer = new StringBuffer();
            String line = "";
            try {
                while ((line = in.readLine()) != null) {
                    buffer.append(line);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            JSONObject data = JSONObject.fromObject(buffer.toString());
            int count = data.optJSONObject("grouped").optJSONObject("videoid").optInt("matches");
            map.put("count", count);
            JSONArray array = data.optJSONObject("grouped").optJSONObject("videoid").optJSONArray("groups");
            List<Long> videoIdList = new ArrayList<Long>();
            for (int i = 0; i < array.size(); i++) {
                JSONArray docsArray = array.optJSONObject(i).optJSONObject("doclist").optJSONArray("docs");
                if (docsArray.size() > 0) {
                    videoIdList.add(docsArray.optJSONObject(0).optLong("videoid"));
                }
            }
            JSONObject data = JSONObject.fromObject(buffer.toString());
            int count = data.optJSONObject("grouped").optJSONObject("videoid").optInt("matches");
            map.put("count", count);
            JSONArray array = data.optJSONObject("grouped").optJSONObject("videoid").optJSONArray("groups");
            List<Long> videoIdList = new ArrayList<Long>();
            for (int i = 0; i < array.size(); i++) {
                JSONArray docsArray = array.optJSONObject(i).optJSONObject("doclist").optJSONArray("docs");
                if (docsArray.size() > 0) {
                    videoIdList.add(docsArray.optJSONObject(0).optLong("videoid"));
                }
            }
            if (videoIdList.size() > 0) {// 有视频数据
                List<VideoInfo> videoList = new ArrayList<VideoInfo>();
            if (videoIdList.size() > 0) {// 有视频数据
                List<VideoInfo> videoList = new ArrayList<VideoInfo>();
                q = "q=";
                String qparams = "";
                for (long videoid : videoIdList) {
                    qparams += String.format("id:%s or ", videoid);
                }
                if (qparams.endsWith("or "))
                    qparams = qparams.substring(0, qparams.length() - 3);
                q += URLEncoder.encode(qparams, "UTF-8");
                url = String.format(
                        "http://%s:8983/solr/buwan/select?%s&sort=%s&rows=" + Constant.pageCount + ""
                                + "&wt=json&indent=true&_t=" + System.currentTimeMillis(),
                        Constant.IsOutNet ? IP_IN : IP_OUT, q, sort);
                is = HttpUtil.getAsInputStream(url);
                in = new BufferedReader(new InputStreamReader(is, "UTF-8"));
                buffer = new StringBuffer();
                line = "";
                try {
                    while ((line = in.readLine()) != null) {
                        buffer.append(line);
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
                q = "q=";
                String qparams = "";
                for (long videoid : videoIdList) {
                    qparams += String.format("id:%s or ", videoid);
                }
                if (qparams.endsWith("or "))
                    qparams = qparams.substring(0, qparams.length() - 3);
                q += URLEncoder.encode(qparams, "UTF-8");
                url = String.format(
                        "http://%s:8983/solr/buwan/select?%s&sort=%s&rows=" + Constant.pageCount + ""
                                + "&wt=json&indent=true&_t=" + System.currentTimeMillis(),
                        Constant.IsOutNet ? IP_IN : IP_OUT, q, sort);
                is = HttpUtil.getAsInputStream(url);
                in = new BufferedReader(new InputStreamReader(is, "UTF-8"));
                buffer = new StringBuffer();
                line = "";
                try {
                    while ((line = in.readLine()) != null) {
                        buffer.append(line);
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }
                data = JSONObject.fromObject(buffer.toString());
                array = data.optJSONObject("response").optJSONArray("docs");
                for (int i = 0; i < array.size(); i++) {
                    JSONObject obj = array.optJSONObject(i);
                    videoList.add(convertJSONTOVideo(obj));
                }
                map.put("data", videoList);
                return map;
            }
                data = JSONObject.fromObject(buffer.toString());
                array = data.optJSONObject("response").optJSONArray("docs");
                for (int i = 0; i < array.size(); i++) {
                    JSONObject obj = array.optJSONObject(i);
                    videoList.add(convertJSONTOVideo(obj));
                }
                map.put("data", videoList);
                return map;
            }
        } catch (Exception e) {
        } catch (Exception e) {
        }
        return null;
    }
        }
        return null;
    }
    // 增量更新Video
    public static void deltaimportVideo() {
        String url = String.format(
                "http://%s:8983/solr/buwan/deltaimport?command=delta-import&commit=true&wt=json&indent=true&verbose=false&clean=false&optimize=false&debug=false",
                Constant.IsOutNet ? IP_IN : IP_OUT);
        HttpUtil.get(url);
        // Map<String, String> map = new HashMap<String, String>();
        // map.put("command", "delta-import");
        // map.put("commit", "true");
        // map.put("wt", "json");
        // map.put("indent", "true");
        // map.put("entity", "juhe");
        // map.put("start", "0");
        // map.put("rows", "50000");
        // map.put("verbose", "false");
        // map.put("clean", "false");
        // map.put("optimize", "false");
        // map.put("debug", "false");
        // String result = HttpUtil.post("http://" + (Constant.IsOutNet ? IP_IN
        // : IP_OUT) + ":8983/solr/buwan/deltaimport",
        // map);
    }
    // 增量更新Video
    public static void deltaimportVideo() {
        String url = String.format(
                "http://%s:8983/solr/buwan/deltaimport?command=delta-import&commit=true&wt=json&indent=true&verbose=false&clean=false&optimize=false&debug=false",
                Constant.IsOutNet ? IP_IN : IP_OUT);
        HttpUtil.get(url);
        // Map<String, String> map = new HashMap<String, String>();
        // map.put("command", "delta-import");
        // map.put("commit", "true");
        // map.put("wt", "json");
        // map.put("indent", "true");
        // map.put("entity", "juhe");
        // map.put("start", "0");
        // map.put("rows", "50000");
        // map.put("verbose", "false");
        // map.put("clean", "false");
        // map.put("optimize", "false");
        // map.put("debug", "false");
        // String result = HttpUtil.post("http://" + (Constant.IsOutNet ? IP_IN
        // : IP_OUT) + ":8983/solr/buwan/deltaimport",
        // map);
    }
    // 全量更新
    public static void dataimportVideo() {
        // 分页请求
        int pageSize = 10000;
        for (int i = 0; i < 200; i++) {
            String url = String.format("http://%s:8983/solr/new_video/dataimport?_=%s&indent=on&wt=json",
                    Constant.IsOutNet ? IP_IN : IP_OUT, System.currentTimeMillis() + "");
    // 全量更新
    public static void dataimportVideo() {
        dataimportVideo("new_video");
            Map<String, String> map = new HashMap<>();
            map.put("command", "full-import");
            map.put("verbose", "false");
            map.put("clean", "false");
            map.put("commit", "true");
            map.put("core", "new_video");
            map.put("entity", "video");
            map.put("startIndex", i * pageSize + "");
            map.put("count", pageSize + "");
            map.put("name", "dataimport");
            HttpUtil.post(url, map);
            try {
                Thread.sleep(1000 * 20);// 间隔1分钟
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
    }
    public static void dataimportVideo(String core) {
        // 分页请求
        int pageSize = 10000;
        for (int i = 0; i < 200; i++) {
            String url = String.format("http://%s:8983/solr/%s/dataimport?_=%s&indent=on&wt=json",
                    Constant.IsOutNet ? IP_IN : IP_OUT, core, System.currentTimeMillis() + "");
    // 全量更新
    public static void dataimportCategoryVideo() {
        String url = String.format(
                "http://%s:8983/solr/buwan_videotype_video/dataimport?command=full-import&commit=true&wt=json&indent=true&verbose=false&optimize=false&debug=false",
                Constant.IsOutNet ? IP_IN : IP_OUT);
        HttpUtil.get(url);
    }
            Map<String, String> map = new HashMap<>();
            map.put("command", "full-import");
            map.put("verbose", "false");
            map.put("clean", "false");
            map.put("commit", "true");
            map.put("core", core);
            map.put("entity", "video");
            map.put("startIndex", i * pageSize + "");
            map.put("count", pageSize + "");
            map.put("name", "dataimport");
            HttpUtil.post(url, map);
            try {
                Thread.sleep(1000 * 20);// 间隔20s
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    // 增量更新
    public static void deltaimportCategoryVideo() {
        String url = String.format(
                "http://%s:8983/solr/buwan_videotype_video/deltaimport?command=delta-import&commit=true&wt=json&indent=true&verbose=false&clean=false&optimize=false&debug=false",
                Constant.IsOutNet ? IP_IN : IP_OUT);
        HttpUtil.get(url);
    };
    }
    // 全量更新
    public static void dataimportCategoryVideo() {
        String url = String.format(
                "http://%s:8983/solr/buwan_videotype_video/dataimport?command=full-import&commit=true&wt=json&indent=true&verbose=false&optimize=false&debug=false",
                Constant.IsOutNet ? IP_IN : IP_OUT);
        HttpUtil.get(url);
    }
    // 增量更新
    public static void deltaimportCategoryVideo() {
        String url = String.format(
                "http://%s:8983/solr/buwan_videotype_video/deltaimport?command=delta-import&commit=true&wt=json&indent=true&verbose=false&clean=false&optimize=false&debug=false",
                Constant.IsOutNet ? IP_IN : IP_OUT);
        HttpUtil.get(url);
    }
    ;
}
src/main/java/com/yeshi/buwan/vo/baidu/BaiDuCPUTypeVO.java
@@ -8,6 +8,7 @@
    private int id;
    public BaiDuCPUTypeVO() {
    }
    public BaiDuCPUTypeVO(String name, int id) {
src/main/resources/baidu/videos.xml
@@ -6,10 +6,6 @@
            <id>1060</id>
        </item>
        <item>
            <name>小视频</name>
            <id>1085</id>
        </item>
        <item>
            <name>小品</name>
            <id>1062</id>
        </item>
src/test/java/com/hxh/spring/test/Solr.java
@@ -35,9 +35,7 @@
    @Test
    public void test3() {
        String appId = "10409568";
        String version = AppMarketUtil.getHWLatestVersion(appId);
        System.out.println(version);
     SolrUtil.dataimportVideo();
    }
}
src/test/java/com/hxh/spring/test/ad/AdTest.java
New file
@@ -0,0 +1,59 @@
package com.hxh.spring.test.ad;
import com.yeshi.buwan.dao.jump.JumpDetailDao;
import com.yeshi.buwan.dao.recommend.FloatADDao;
import com.yeshi.buwan.domain.jump.JumpDetail;
import com.yeshi.buwan.domain.jump.JumpTypeEnum;
import com.yeshi.buwan.domain.recommend.FloatAD;
import com.yeshi.buwan.util.StringUtil;
import org.json.JSONObject;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import javax.annotation.Resource;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:spring.xml"})
@WebAppConfiguration
public class AdTest {
    @Resource
    private JumpDetailDao jumpDetailDao;
    @Resource
    private FloatADDao floatADDao;
    @Test
    public void addJumpDetail() {
        JumpDetail detail = new JumpDetail();
        detail.setActivity("");
        detail.setController("");
        detail.setType(JumpTypeEnum.baichuan);
        jumpDetailDao.save(detail);
    }
    @Test
    public void getJumpDetail() {
        JumpDetail detail = jumpDetailDao.selectByType(JumpTypeEnum.baichuan);
        System.out.println(detail);
    }
    @Test
    public void addFloatAd() {
        JumpDetail detail = jumpDetailDao.selectByType(JumpTypeEnum.baichuan);
        JSONObject params = new JSONObject();
        params.put("url", "https://s.click.taobao.com/2K0Nxtv");
        FloatAD ad = new FloatAD();
        ad.setId(StringUtil.Md5(System.currentTimeMillis() + ""));
        ad.setJumpDetail(detail);
        ad.setParams(params.toString());
        ad.setPicture("http://ec-1255749512.file.myqcloud.com/img/FloatAD/5cba7bfd927e4c1d958808acd22bab58.png");
        ad.setShow(true);
        ad.setWeight(1);
        floatADDao.save(ad);
    }
}