From fc7a6634496066fe45dca8ea9832bdd2f7341db4 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 13 十月 2020 10:25:39 +0800
Subject: [PATCH] 百度内容联盟前端分类,首页弹窗广告

---
 src/main/java/com/yeshi/buwan/util/SolrUtil.java |  945 +++++++++++++++++++++++++++++-----------------------------
 1 files changed, 476 insertions(+), 469 deletions(-)

diff --git a/src/main/java/com/yeshi/buwan/util/SolrUtil.java b/src/main/java/com/yeshi/buwan/util/SolrUtil.java
index a76a0d6..2bb03d3 100644
--- a/src/main/java/com/yeshi/buwan/util/SolrUtil.java
+++ b/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);
+    }
+
+    ;
 
 }

--
Gitblit v1.8.0