| | |
| | | import com.yeshi.buwan.service.inter.system.SystemConfigService; |
| | | import com.yeshi.buwan.util.rank.IqiyiRankUtil; |
| | | import com.yeshi.buwan.util.rank.TencentRankUtil; |
| | | import org.json.JSONArray; |
| | | import org.json.JSONObject; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.io.IOException; |
| | | import java.util.*; |
| | | |
| | | //10409568 |
| | | @Component |
| | |
| | | @Resource |
| | | private SystemConfigService systemConfigService; |
| | | |
| | | private static List<String> concatRank(int count, List<String>... ranks) { |
| | | List<String> flist = new ArrayList<>(); |
| | | Set<String> keys=new HashSet<>(); |
| | | for (int i = 0; i < count; i++) { |
| | | for (List<String> rank : ranks) { |
| | | if (rank == null) { |
| | | continue; |
| | | } |
| | | if (rank.size() > i) { |
| | | if (!keys.contains(rank.get(i).replace(" ",""))) { |
| | | flist.add(rank.get(i)); |
| | | keys.add(rank.get(i).replace(" ","")); |
| | | } |
| | | } |
| | | if (flist.size() >= count) { |
| | | break; |
| | | } |
| | | } |
| | | if (flist.size() >= count) { |
| | | break; |
| | | } |
| | | } |
| | | return flist; |
| | | } |
| | | |
| | | |
| | | //爱奇艺排行 |
| | | @XxlJob("rank-iqiyi-update") |
| | | public ReturnT<String> updateIqiyiRank(String params) throws Exception { |
| | | public ReturnT<String> updateRank(String params) throws Exception { |
| | | Map<String, List<String>> map = IqiyiRankUtil.getRank(10); |
| | | Map<String, List<String>> tencentMap = TencentRankUtil.getRank(10); |
| | | if(tencentMap.get("总榜单")!=null) { |
| | | map.put("热搜", tencentMap.get("总榜单")); |
| | | } |
| | | map.put("动漫", tencentMap.get("动漫")); |
| | | Map<String,Integer> typeRank=new HashMap<>(); |
| | | typeRank.put("热搜",0); |
| | | typeRank.put("电视剧",1); |
| | | typeRank.put("动漫",2); |
| | | typeRank.put("电影",3); |
| | | typeRank.put("综艺",4); |
| | | |
| | | Map<String,List<String>> fmap=new TreeMap<>(new Comparator<String>() { |
| | | @Override |
| | | public int compare(String o1, String o2) { |
| | | return typeRank.get(o1) - typeRank.get(o2); |
| | | } |
| | | }); |
| | | fmap.put("热搜", concatRank(10, map.get("总榜"), tencentMap.get("热搜"))); |
| | | fmap.put("电视剧", concatRank(10, map.get("电视剧"), tencentMap.get("电视剧"))); |
| | | fmap.put("动漫", tencentMap.get("动漫")); |
| | | fmap.put("电影", concatRank(10, map.get("电影"), tencentMap.get("电影"))); |
| | | fmap.put("综艺", concatRank(10, map.get("综艺"), tencentMap.get("综艺"))); |
| | | if (map != null && map.size() > 0) { |
| | | String json = new Gson().toJson(map); |
| | | String json = new Gson().toJson(fmap); |
| | | systemConfigService.setValue("searchRank", json); |
| | | } |
| | | return ReturnT.SUCCESS; |
| | |
| | | return ReturnT.SUCCESS; |
| | | } |
| | | |
| | | public static void main(String[] args) throws Exception { |
| | | new RankJob().updateRank(""); |
| | | } |
| | | |
| | | |
| | | } |