admin
2023-04-12 f06a592dd1a7e995bf313ccb5efe7dff73ccfc4e
增加本地获取IP归属地/广告优化
17个文件已修改
3个文件已添加
1605 ■■■■ 已修改文件
pom.xml 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/controller/admin/api/StatisticsController.java 359 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/controller/parser/ConfigParser.java 229 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/controller/parser/UserParser.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/job/RankJob.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/service/imp/user/UserDPContentWatchStatisticServiceImpl.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/service/manager/IPManager.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/util/COSManager.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/util/IPUtil.java 234 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/util/Utils.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/util/log/SearchKeyLogUtil.java 219 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/yeshi/buwan/vo/ad/AdConfigTypeVO.java 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/consumer.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/ip2region.xdb 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/admin/new/fenqu.html 165 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/admin/new/login.html 162 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/admin/new/shuju.html 86 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/java/com/hxh/spring/test/DES.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/java/com/hxh/spring/test/IPTest.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/java/com/hxh/spring/test/video/YouKuTest.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pom.xml
@@ -936,6 +936,13 @@
            <version>2.3.1</version>
        </dependency>
        <dependency>
            <groupId>org.lionsoul</groupId>
            <artifactId>ip2region</artifactId>
            <version>2.6.5</version>
        </dependency>
    </dependencies>
src/main/java/com/yeshi/buwan/controller/admin/api/StatisticsController.java
@@ -1,12 +1,20 @@
package com.yeshi.buwan.controller.admin.api;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.Type;
import java.sql.Time;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.yeshi.buwan.util.JsonUtil;
import com.yeshi.buwan.util.RedisManager;
import com.yeshi.buwan.util.log.SearchKeyLogUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -24,173 +32,226 @@
@RequestMapping("admin/new/api/statistics")
public class StatisticsController {
    @Resource
    private SystemService systemService;
    @Resource
    private StatisticsService statisticsService;
    @Resource
    private SystemService systemService;
    @Resource
    private StatisticsService statisticsService;
    @RequestMapping(value = "/gettesterdaydata", method = RequestMethod.POST)
    public void getYesterdayData(String startdate, String enddate, String fastdate, int detailsystem, PrintWriter out) {
    @Resource
    private RedisManager redisManager;
        startdate = StringUtil.isNullOrEmpty(startdate) ? "" : startdate;
        enddate = StringUtil.isNullOrEmpty(enddate) ? "" : enddate;
        fastdate = StringUtil.isNullOrEmpty(fastdate) ? "0" : fastdate;
        if (!"0".equalsIgnoreCase(fastdate)) {
            enddate = TimeUtil.getGernalTime(System.currentTimeMillis());
            startdate = TimeUtil.getGernalTime(
                    System.currentTimeMillis() - 24 * 60 * 60 * 1000L * (Integer.parseInt(fastdate) - 1));
        }
    @RequestMapping(value = "/gettesterdaydata", method = RequestMethod.POST)
    public void getYesterdayData(String startdate, String enddate, String fastdate, int detailsystem, PrintWriter out) {
        long registerCount = statisticsService.getRegisterCount(startdate, enddate, detailsystem + "");
        long totalRegisterCount = statisticsService.getTotalRegisterCount(detailsystem + "");
        List<StatisticXY> xyList = statisticsService.getDetailSystemWatchCount(startdate, enddate, detailsystem + "");
        long watchCount = 0;
        if (xyList != null && xyList.size() > 0)
            watchCount = xyList.get(0).getY();
        startdate = StringUtil.isNullOrEmpty(startdate) ? "" : startdate;
        enddate = StringUtil.isNullOrEmpty(enddate) ? "" : enddate;
        fastdate = StringUtil.isNullOrEmpty(fastdate) ? "0" : fastdate;
        if (!"0".equalsIgnoreCase(fastdate)) {
            enddate = TimeUtil.getGernalTime(System.currentTimeMillis());
            startdate = TimeUtil.getGernalTime(
                    System.currentTimeMillis() - 24 * 60 * 60 * 1000L * (Integer.parseInt(fastdate) - 1));
        }
        JSONObject object = new JSONObject();
        object.put("code", 0);
        JSONObject data = new JSONObject();
        data.put("rcount", registerCount);
        data.put("trcount", totalRegisterCount);
        data.put("wcount", watchCount);
        object.put("data", data);
        out.print(object);
    }
        long registerCount = statisticsService.getRegisterCount(startdate, enddate, detailsystem + "");
        long totalRegisterCount = statisticsService.getTotalRegisterCount(detailsystem + "");
        List<StatisticXY> xyList = statisticsService.getDetailSystemWatchCount(startdate, enddate, detailsystem + "");
        long watchCount = 0;
        if (xyList != null && xyList.size() > 0)
            watchCount = xyList.get(0).getY();
    @RequestMapping(value = "/gettopplay", method = RequestMethod.POST)
    public void getTopPlay(String startdate, String enddate, String fastdate, int detailsystem, PrintWriter out) {
        JSONObject object = new JSONObject();
        object.put("code", 0);
        JSONObject data = new JSONObject();
        data.put("rcount", registerCount);
        data.put("trcount", totalRegisterCount);
        data.put("wcount", watchCount);
        object.put("data", data);
        out.print(object);
    }
        startdate = StringUtil.isNullOrEmpty(startdate) ? "" : startdate;
        enddate = StringUtil.isNullOrEmpty(enddate) ? "" : enddate;
        fastdate = StringUtil.isNullOrEmpty(fastdate) ? "0" : fastdate;
        if (!"0".equalsIgnoreCase(fastdate)) {
            enddate = TimeUtil.getGernalTime(System.currentTimeMillis());
            startdate = TimeUtil.getGernalTime(
                    System.currentTimeMillis() - 24 * 60 * 60 * 1000L * (Integer.parseInt(fastdate) - 1));
        }
    @RequestMapping(value = "/gettopplay", method = RequestMethod.POST)
    public void getTopPlay(String startdate, String enddate, String fastdate, int detailsystem, PrintWriter out) {
        List<StatisticXY> xyList = statisticsService.getWatchDetail(startdate, enddate, detailsystem + "");
        startdate = StringUtil.isNullOrEmpty(startdate) ? "" : startdate;
        enddate = StringUtil.isNullOrEmpty(enddate) ? "" : enddate;
        fastdate = StringUtil.isNullOrEmpty(fastdate) ? "0" : fastdate;
        if (!"0".equalsIgnoreCase(fastdate)) {
            enddate = TimeUtil.getGernalTime(System.currentTimeMillis());
            startdate = TimeUtil.getGernalTime(
                    System.currentTimeMillis() - 24 * 60 * 60 * 1000L * (Integer.parseInt(fastdate) - 1));
        }
        JSONArray nameArray = new JSONArray();
        JSONArray countArray = new JSONArray();
        for (StatisticXY xy : xyList) {
            if ((xy.getTime() + "").length() > 15)
                xy.setTime(xy.getTime().substring(0, 15) + "..");
            nameArray.add(xy.getTime());
            countArray.add(xy.getY());
        }
        JSONObject object = new JSONObject();
        object.put("code", 0);
        JSONObject data = new JSONObject();
        data.put("name", nameArray);
        data.put("count", countArray);
        object.put("data", data);
        out.print(object);
    }
        List<StatisticXY> xyList = statisticsService.getWatchDetail(startdate, enddate, detailsystem + "");
    @RequestMapping(value = "/totalplay", method = RequestMethod.POST)
    public void totalPlay(String startdate, String enddate, String fastdate, int detailsystem, PrintWriter out) {
        JSONArray nameArray = new JSONArray();
        JSONArray countArray = new JSONArray();
        for (StatisticXY xy : xyList) {
            if ((xy.getTime() + "").length() > 15)
                xy.setTime(xy.getTime().substring(0, 15) + "..");
            nameArray.add(xy.getTime());
            countArray.add(xy.getY());
        }
        JSONObject object = new JSONObject();
        object.put("code", 0);
        JSONObject data = new JSONObject();
        data.put("name", nameArray);
        data.put("count", countArray);
        object.put("data", data);
        out.print(object);
    }
        startdate = StringUtil.isNullOrEmpty(startdate) ? "" : startdate;
        enddate = StringUtil.isNullOrEmpty(enddate) ? "" : enddate;
        fastdate = StringUtil.isNullOrEmpty(fastdate) ? "0" : fastdate;
        if (!"0".equalsIgnoreCase(fastdate)) {
            enddate = TimeUtil.getGernalTime(System.currentTimeMillis());
            startdate = TimeUtil.getGernalTime(
                    System.currentTimeMillis() - 24 * 60 * 60 * 1000L * (Integer.parseInt(fastdate) - 1));
        }
    @RequestMapping(value = "/gettopsearch", method = RequestMethod.POST)
    public void getTopSearch(int detailsystem, PrintWriter out) {
        //是否最近1小时更新过
        String updateTime = redisManager.getCommonString("search_key_updatetime");
        if (StringUtil.isNullOrEmpty(updateTime)) {
            //更新数据
            refreshTopSearch(detailsystem, out);
        }
        List<StatisticXY> xyList = statisticsService.getDetailSystemWatchCount(startdate, enddate, detailsystem + "");
        JSONArray dateArray = new JSONArray();
        JSONArray countArray = new JSONArray();
        for (StatisticXY xy : xyList) {
            dateArray.add(xy.getTime());
            countArray.add(xy.getY());
        }
        JSONObject object = new JSONObject();
        object.put("code", 0);
        JSONObject data = new JSONObject();
        data.put("date", dateArray);
        data.put("count", countArray);
        object.put("data", data);
        out.print(object);
    }
    @RequestMapping(value = "/typeplay", method = RequestMethod.POST)
    public void typePlay(String startdate, String enddate, String fastdate, int detailsystem, PrintWriter out) {
        startdate = StringUtil.isNullOrEmpty(startdate) ? "" : startdate;
        enddate = StringUtil.isNullOrEmpty(enddate) ? "" : enddate;
        fastdate = StringUtil.isNullOrEmpty(fastdate) ? "0" : fastdate;
        if (!"0".equalsIgnoreCase(fastdate)) {
            enddate = TimeUtil.getGernalTime(System.currentTimeMillis());
            startdate = TimeUtil.getGernalTime(
                    System.currentTimeMillis() - 24 * 60 * 60 * 1000L * (Integer.parseInt(fastdate) - 1));
        }
        String day = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyyMMdd");
        String key = "search_key-" + day;
        String value = redisManager.getCommonString(key);
        JSONArray countList = new JSONArray();
        JSONArray nameList = new JSONArray();
        if (!StringUtil.isNullOrEmpty(value)) {
            Type type = new TypeToken<List<SearchKeyLogUtil.RankInfo>>() {
            }.getType();
            List<SearchKeyLogUtil.RankInfo> resultList = new Gson().fromJson(value, type);
            for (SearchKeyLogUtil.RankInfo rank : resultList) {
                countList.add(rank.getCount());
                nameList.add(rank.getKey());
            }
        }
        JSONObject data = new JSONObject();
        data.put("name", nameList);
        data.put("count", countList);
        out.print(JsonUtil.loadTrueAdmin(data));
    }
        Map<String, List<StatisticXY>> map = statisticsService.getCategoryPlayStatistics(startdate, enddate,
                detailsystem + "");
        Iterator<String> its = map.keySet().iterator();
        JSONArray countArray = new JSONArray();
        while (its.hasNext()) {
            String key = its.next();
            List<StatisticXY> list = map.get(key);
            JSONObject item = new JSONObject();
            item.put("name", key);
            JSONArray itemtA = new JSONArray();
            for (StatisticXY xy : list) {
                itemtA.add(xy.getY());
            }
            item.put("data", itemtA);
            countArray.add(item);
        }
    @RequestMapping(value = "/refreshtopsearch", method = RequestMethod.POST)
    public void refreshTopSearch(int detailsystem, PrintWriter out) {
        String day = TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyyMMdd");
        List<SearchKeyLogUtil.RankInfo> rankList = null;
        try {
            rankList = SearchKeyLogUtil.getTodayRankList(50);
        } catch (IOException e) {
            e.printStackTrace();
        }
        JSONArray dateArray = new JSONArray();
        its = map.keySet().iterator();
        if (its.hasNext()) {
            List<StatisticXY> list = map.get(its.next());
            for (StatisticXY xy : list) {
                dateArray.add(xy.getTime());
            }
        }
        JSONObject object = new JSONObject();
        object.put("code", 0);
        JSONObject data = new JSONObject();
        data.put("date", dateArray);
        data.put("count", countArray);
        object.put("data", data);
        out.print(object);
        if (rankList == null) {
            out.print(JsonUtil.loadFalseAdmin("更新失败"));
        } else {
            String key = "search_key-" + day;
            redisManager.cacheCommonString(key, new Gson().toJson(rankList));
            redisManager.cacheCommonString("search_key_updatetime", System.currentTimeMillis() + "",3600);
            out.print(JsonUtil.loadTrueAdmin("更新成功"));
        }
    }
    }
    @RequestMapping(value = "/totalplay", method = RequestMethod.POST)
    public void totalPlay(String startdate, String enddate, String fastdate, int detailsystem, PrintWriter out) {
    @RequestMapping(value = "/singleplay", method = RequestMethod.POST)
    public void singlePlay(String videoid, String startdate, String enddate, String fastdate, int detailsystem,
            PrintWriter out) {
        startdate = StringUtil.isNullOrEmpty(startdate) ? "" : startdate;
        enddate = StringUtil.isNullOrEmpty(enddate) ? "" : enddate;
        fastdate = StringUtil.isNullOrEmpty(fastdate) ? "0" : fastdate;
        if (!"0".equalsIgnoreCase(fastdate)) {
            enddate = TimeUtil.getGernalTime(System.currentTimeMillis());
            startdate = TimeUtil.getGernalTime(
                    System.currentTimeMillis() - 24 * 60 * 60 * 1000L * (Integer.parseInt(fastdate) - 1));
        }
        startdate = StringUtil.isNullOrEmpty(startdate) ? "" : startdate;
        enddate = StringUtil.isNullOrEmpty(enddate) ? "" : enddate;
        fastdate = StringUtil.isNullOrEmpty(fastdate) ? "0" : fastdate;
        if (!"0".equalsIgnoreCase(fastdate)) {
            enddate = TimeUtil.getGernalTime(System.currentTimeMillis());
            startdate = TimeUtil.getGernalTime(
                    System.currentTimeMillis() - 24 * 60 * 60 * 1000L * (Integer.parseInt(fastdate) - 1));
        }
        List<StatisticXY> list = statisticsService.getVideoWatchDetail(videoid, startdate, enddate, detailsystem + "");
        JSONArray countArray = new JSONArray();
        JSONArray dateArray = new JSONArray();
        for (StatisticXY xy : list) {
            countArray.add(xy.getY());
            dateArray.add(xy.getTime());
        }
        List<StatisticXY> xyList = statisticsService.getDetailSystemWatchCount(startdate, enddate, detailsystem + "");
        JSONArray dateArray = new JSONArray();
        JSONArray countArray = new JSONArray();
        for (StatisticXY xy : xyList) {
            dateArray.add(xy.getTime());
            countArray.add(xy.getY());
        }
        JSONObject object = new JSONObject();
        object.put("code", 0);
        JSONObject data = new JSONObject();
        data.put("date", dateArray);
        data.put("count", countArray);
        object.put("data", data);
        out.print(object);
    }
        JSONObject object = new JSONObject();
        object.put("code", 0);
        JSONObject data = new JSONObject();
        data.put("date", dateArray);
        data.put("count", countArray);
        object.put("data", data);
        out.print(object);
    @RequestMapping(value = "/typeplay", method = RequestMethod.POST)
    public void typePlay(String startdate, String enddate, String fastdate, int detailsystem, PrintWriter out) {
        startdate = StringUtil.isNullOrEmpty(startdate) ? "" : startdate;
        enddate = StringUtil.isNullOrEmpty(enddate) ? "" : enddate;
        fastdate = StringUtil.isNullOrEmpty(fastdate) ? "0" : fastdate;
        if (!"0".equalsIgnoreCase(fastdate)) {
            enddate = TimeUtil.getGernalTime(System.currentTimeMillis());
            startdate = TimeUtil.getGernalTime(
                    System.currentTimeMillis() - 24 * 60 * 60 * 1000L * (Integer.parseInt(fastdate) - 1));
        }
    }
        Map<String, List<StatisticXY>> map = statisticsService.getCategoryPlayStatistics(startdate, enddate,
                detailsystem + "");
        Iterator<String> its = map.keySet().iterator();
        JSONArray countArray = new JSONArray();
        while (its.hasNext()) {
            String key = its.next();
            List<StatisticXY> list = map.get(key);
            JSONObject item = new JSONObject();
            item.put("name", key);
            JSONArray itemtA = new JSONArray();
            for (StatisticXY xy : list) {
                itemtA.add(xy.getY());
            }
            item.put("data", itemtA);
            countArray.add(item);
        }
        JSONArray dateArray = new JSONArray();
        its = map.keySet().iterator();
        if (its.hasNext()) {
            List<StatisticXY> list = map.get(its.next());
            for (StatisticXY xy : list) {
                dateArray.add(xy.getTime());
            }
        }
        JSONObject object = new JSONObject();
        object.put("code", 0);
        JSONObject data = new JSONObject();
        data.put("date", dateArray);
        data.put("count", countArray);
        object.put("data", data);
        out.print(object);
    }
    @RequestMapping(value = "/singleplay", method = RequestMethod.POST)
    public void singlePlay(String videoid, String startdate, String enddate, String fastdate, int detailsystem,
                           PrintWriter out) {
        startdate = StringUtil.isNullOrEmpty(startdate) ? "" : startdate;
        enddate = StringUtil.isNullOrEmpty(enddate) ? "" : enddate;
        fastdate = StringUtil.isNullOrEmpty(fastdate) ? "0" : fastdate;
        if (!"0".equalsIgnoreCase(fastdate)) {
            enddate = TimeUtil.getGernalTime(System.currentTimeMillis());
            startdate = TimeUtil.getGernalTime(
                    System.currentTimeMillis() - 24 * 60 * 60 * 1000L * (Integer.parseInt(fastdate) - 1));
        }
        List<StatisticXY> list = statisticsService.getVideoWatchDetail(videoid, startdate, enddate, detailsystem + "");
        JSONArray countArray = new JSONArray();
        JSONArray dateArray = new JSONArray();
        for (StatisticXY xy : list) {
            countArray.add(xy.getY());
            dateArray.add(xy.getTime());
        }
        JSONObject object = new JSONObject();
        object.put("code", 0);
        JSONObject data = new JSONObject();
        data.put("date", dateArray);
        data.put("count", countArray);
        object.put("data", data);
        out.print(object);
    }
}
src/main/java/com/yeshi/buwan/controller/parser/ConfigParser.java
@@ -22,6 +22,8 @@
import com.yeshi.buwan.util.log.LoggerUtil;
import com.yeshi.buwan.util.log.UserActiveLogFactory;
import com.yeshi.buwan.vo.AcceptData;
import com.yeshi.buwan.vo.ad.AdConfigTypeVO;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -107,188 +109,53 @@
        return adConfig;
    }
    /**
     * 屏蔽所有的广告
     *
     * @param channel
     * @param version
     * @param shieldInfo
     * @param ip
     * @return
     */
    private boolean shieldAllAd(String channel, Integer version, String shieldInfo, String ip) {
        if (StringUtil.isNullOrEmpty(shieldInfo)) {
            return false;
        }
        Type type = new TypeToken<List<ADShieldIPConfig>>() {
        }.getType();
        List<ADShieldIPConfig> list = new Gson().fromJson(shieldInfo, type);
        Map<String, ADShieldIPConfig.IPShieldRule> map = new HashMap<>();
        for (ADShieldIPConfig config : list) {
            map.put(config.getChannel().toLowerCase(), config.getRule());
        }
        if (map.get(channel.toLowerCase()) != null) {
            ADShieldIPConfig.IPShieldRule rule = map.get(channel.toLowerCase());
            if (version >= rule.getVersion()) {
                //请求
    // 获取广告配置信息
    private void loadAdConfig(AcceptData acceptData, Map<String, String> map, String ip, boolean isDPUser,JSONObject data) {
        Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
        Map<String, Boolean> shieldMap = new HashMap<>();
        // 获取区域屏蔽信息
        String shieldInfo = map.get("ad_shield_province_rules");
        if (!StringUtil.isNullOrEmpty(shieldInfo)) {
            JSONObject json = JSONObject.fromObject(shieldInfo);
            //获取渠道需要屏蔽的城市
            JSONObject shieldProvinceRules = json.optJSONObject(acceptData.getChannel().toLowerCase());
            if (shieldProvinceRules != null) {
                IPUtil.IPInfo ipInfo = null;
                try {
                    ipInfo = ipManager.getIPInfo(ip);
                } catch (Exception e) {
                    e.printStackTrace();
                    logger.error("IP地址位置信息获取失败:" + ip);
                }
                if (ipInfo != null) {
                    //先判断省
                    if (!StringUtil.isNullOrEmpty(rule.getProvince())) {
                        if (ipInfo.getProvince() != null && ipInfo.getProvince().contains(rule.getProvince())) {
                            if (!StringUtil.isNullOrEmpty(rule.getCity())) {//同时判断省和市
                                if (ipInfo.getCity() != null && ipInfo.getCity().contains(rule.getCity())) {
                                    return true;
                    //获取是否需要屏蔽开屏
                    for (AdConfigTypeVO adType : AdConfigTypeVO.values()) {
                        JSONArray splashProvinces = shieldProvinceRules.optJSONArray(adType.getSettingKey());
                        if (splashProvinces != null) {
                            for (int i = 0; i < splashProvinces.size(); i++) {
                                String p = splashProvinces.optString(i);
                                if (p.equalsIgnoreCase(ipInfo.getProvince())) {
                                    shieldMap.put(adType.getSettingKey(), true);
                                    break;
                                }
                            } else {
                                //只判断省
                                return true;
                            }
                        }
                    } else if (!StringUtil.isNullOrEmpty(rule.getCity())) {
                        //只判断市
                        if (ipInfo.getCity() != null && ipInfo.getCity().contains(rule.getCity())) {
                            return true;
                        }
                    }
                }
            }
        }
        return false;
    }
    public void getConfig(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
        LoggerUtil.getUserActiveLogger().info(UserActiveLogFactory.createAppSplash(new BaseLog(acceptData, "")));
        DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName());
        Map<String, String> map = configService.getConfigAsMap(acceptData.getChildDetailSystem(), acceptData.getVersion());
        JSONObject data = new JSONObject();
        JSONObject ad = new JSONObject();
        JSONObject adNew = new JSONObject();
        String ip = IPUtil.getRemotIP(request);
        //会员链接
        String vipLink = map.get("vip_link");
        data.put("vipLink", vipLink);
        ADConfig splashConfig = getAdShowType("ad_splash_config", acceptData.getChannel(), acceptData.getVersion(), map);
        //开屏的地区屏蔽规则
        String shieldInfo = map.get("shield_province");
        boolean hiddenSplash = false;
        if (!StringUtil.isNullOrEmpty(shieldInfo)) {
            JSONObject json = JSONObject.fromObject(shieldInfo);
            //获取渠道需要屏蔽的城市
            String province = json.optString(acceptData.getChannel().toLowerCase());
            if (splashConfig != null && !StringUtil.isNullOrEmpty(province)) {
                IPUtil.IPInfo ipInfo = null;
                try {
                    ipInfo = ipManager.getIPInfo(ip);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (ipInfo != null && ipInfo.getProvince().contains(province)) {//屏蔽IP
                    hiddenSplash = true;
                    LogHelper.print("城市屏蔽:" + province);
                }
        JSONObject ad = new JSONObject();
        for (AdConfigTypeVO adType: AdConfigTypeVO.values()){
            ADConfig    adConfig = getAdShowType(adType.getDbKey(), acceptData.getChannel(), acceptData.getVersion(), map);
            if (shieldMap.get(adType.getSettingKey())!=null&&shieldMap.get(adType.getSettingKey())) {
                //屏蔽广告
                adConfig = null;
            }
            ad.put(adType.getVoKey(), adConfig == null ? "" : adConfig.getType());
            adNew.put(adType.getVoKey(), gson.toJson(adConfig));
        }
        //是否为内容阅读用户
        boolean isDPUser = false;
        try {
            isDPUser = userDPContentWatchStatisticService.isDPUser(acceptData);
        } catch (Exception e) {
        }
        //广告全部屏蔽区域
        String shieldAdLocationInfo = map.get("shield_ad_ip_location");
        boolean hiddenAll = shieldAllAd(acceptData.getChannel(), acceptData.getVersion(), shieldAdLocationInfo, ip);
        if (hiddenSplash)
            splashConfig = null;
        String splash = "";
        if (splashConfig != null)
            splash = splashConfig.getType();
        Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
        if (hiddenAll)
            splashConfig = null;
        //开屏
        ad.put("splash", splash);
        if (!isDPUser)
            adNew.put("splash", gson.toJson(splashConfig));
            ADConfig adConfig = null;
        //视频前贴
        adConfig = getAdShowType("ad_play_video_pre", acceptData.getChannel(), acceptData.getVersion(), map);
        if (hiddenAll)
            adConfig = null;
        ad.put("videoPlayPre", adConfig == null ? "" : adConfig.getType());
        adNew.put("videoPlayPre", gson.toJson(adConfig));
        //APP退出
        adConfig = getAdShowType("ad_exit_app", acceptData.getChannel(), acceptData.getVersion(), map);
        if (hiddenAll)
            adConfig = null;
        ad.put("exitApp", adConfig == null ? "" : adConfig.getType());
        if (!isDPUser)
            adNew.put("exitApp", gson.toJson(adConfig));
        //全屏广告控制
        adConfig = getAdShowType("ad_video_detail_full_video", acceptData.getChannel(), acceptData.getVersion(), map);
        if (hiddenAll)
            adConfig = null;
        ad.put("videoDetailFullVideo", adConfig == null ? "" : adConfig.getType());
        if (!isDPUser)
            adNew.put("videoDetailFullVideo", gson.toJson(adConfig));
        //搜索页广告控制
        adConfig = getAdShowType("ad_video_search", acceptData.getChannel(), acceptData.getVersion(), map);
        if (hiddenAll)
            adConfig = null;
        ad.put("videoSearch", adConfig == null ? "" : adConfig.getType());
        adNew.put("videoSearch", gson.toJson(adConfig));
        //pptv免广告激励视频
        adConfig = getAdShowType("pptv_no_ad_reward", acceptData.getChannel(), acceptData.getVersion(), map);
        if (hiddenAll)
            adConfig = null;
        adNew.put("pptvNoAdReward", gson.toJson(adConfig));
        //热启动开屏
        adConfig = getAdShowType("ad_splash_hot_start", acceptData.getChannel(), acceptData.getVersion(), map);
        if (hiddenAll)
            adConfig = null;
        adNew.put("splashHotStart", gson.toJson(adConfig));
        //首页插屏
        adConfig = getAdShowType("home_ad_interstitial", acceptData.getChannel(), acceptData.getVersion(), map);
        if (hiddenAll)
            adConfig = null;
        if (!isDPUser)
            adNew.put("homeInterstitial", gson.toJson(adConfig));
        //应用退出全屏
        adConfig = getAdShowType("ad_exit_app_fullvideo", acceptData.getChannel(), acceptData.getVersion(), map);
        if (hiddenAll)
            adConfig = null;
        if (!isDPUser)
            adNew.put("exitAppFullvideo", gson.toJson(adConfig));
        //其他广告
        adConfig = getAdShowType("ad_other", acceptData.getChannel(), acceptData.getVersion(), map);
        if (hiddenAll)
            adConfig = null;
        adNew.put("other", gson.toJson(adConfig));
        //广告ID
        if (!StringUtil.isNullOrEmpty(map.get("gdt_app_id"))) {
@@ -301,6 +168,31 @@
        data.put("ad", ad);
        data.put("adNew", adNew);
    }
    public void getConfig(AcceptData acceptData, HttpServletRequest request, PrintWriter out) {
        LoggerUtil.getUserActiveLogger().info(UserActiveLogFactory.createAppSplash(new BaseLog(acceptData, "")));
        DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName());
        Map<String, String> map = configService.getConfigAsMap(acceptData.getChildDetailSystem(), acceptData.getVersion());
        JSONObject data = new JSONObject();
        String ip = IPUtil.getRemotIP(request);
        //会员链接
        String vipLink = map.get("vip_link");
        data.put("vipLink", vipLink);
        //是否为内容阅读用户
        boolean isDPUser = false;
        try {
            isDPUser = userDPContentWatchStatisticService.isDPUser(acceptData);
        } catch (Exception e) {
        }
        // 加载广告配置
        loadAdConfig(acceptData,map,ip,isDPUser,data);
        //PPTV免广告权益时长,暂时设置为3小时
        data.put("pptvNoAdRewardHour", 3);
        //设置网页加速域名
@@ -334,7 +226,12 @@
        } catch (Exception e) {
        }
        data.put("onLining", onLine);
        String aidao = map.get("ai_dao_mode");
        if ("1".equalsIgnoreCase((aidao + "").trim())) {
            data.put("aiDaoMode", true);
        } else {
            data.put("aiDaoMode", false);
        }
        out.print(JsonUtil.loadTrueJson(data.toString()));
    }
src/main/java/com/yeshi/buwan/controller/parser/UserParser.java
@@ -795,6 +795,32 @@
                        break;
                }
            }
            if (map.get(0) == null) {
                //如果没有热搜榜就填充所有榜单的前几个数据
                List<String> list = new ArrayList<>();
                Type type = new TypeToken<List<String>>() {
                }.getType();
                for (int i = 1; i < 5; i++) {
                    if (map.get(i) != null) {
                        JSONObject json = map.get(i);
                        String key = json.keySet().iterator().next() + "";
                        JSONArray array = json.optJSONArray(key);
                        List<String> keys = new Gson().fromJson(array.toString(), type);
                        if (keys.size() > 3) {
                            list.addAll(keys.subList(0, 3));
                        } else {
                            list.addAll(keys);
                        }
                    }
                }
                if (list.size() > 10) {
                    list = list.subList(0, 10);
                }
                JSONObject data = new JSONObject();
                data.put("热搜榜", list);
                map.put(0, data);
            }
        }
        JSONObject data = new JSONObject();
@@ -1475,7 +1501,7 @@
        String path = session.getServletContext().getRealPath("upload") + "/" + fileName;
        if (!new File(session.getServletContext().getRealPath("upload") + "/").exists())
            new File(session.getServletContext().getRealPath("upload") + "/").mkdirs();
        boolean isS = StringUtil.generateImageFromBase64(base64.replace("\n",""), path);
        boolean isS = StringUtil.generateImageFromBase64(base64.replace("\n", ""), path);
        if (!isS)
            return "";
@@ -1506,7 +1532,11 @@
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getRemoteAddr();
        }
        out.print(ip + "-----" + IPUtil.getIPContry(request.getRemoteAddr()));
        try {
            out.print(ip + "-----" + new Gson().toJson(IPUtil.getLocalIPInfo(request.getRemoteAddr())));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
src/main/java/com/yeshi/buwan/job/RankJob.java
@@ -26,7 +26,9 @@
    public ReturnT<String> updateIqiyiRank(String params) throws Exception {
        Map<String, List<String>> map = IqiyiRankUtil.getRank(10);
        Map<String, List<String>> tencentMap = TencentRankUtil.getRank(10);
        map.put("热搜", tencentMap.get("总榜单"));
        if(tencentMap.get("总榜单")!=null) {
            map.put("热搜", tencentMap.get("总榜单"));
        }
        map.put("动漫", tencentMap.get("动漫"));
        if (map != null && map.size() > 0) {
            String json = new Gson().toJson(map);
src/main/java/com/yeshi/buwan/service/imp/user/UserDPContentWatchStatisticServiceImpl.java
@@ -136,6 +136,10 @@
    @Override
    public boolean isDPUser(AcceptData acceptData) {
        //暂时设置
        if(true){
            return false;
        }
        String id = getIdentityId(acceptData);
        if (StringUtil.isNullOrEmpty(id)) {
            return false;
src/main/java/com/yeshi/buwan/service/manager/IPManager.java
@@ -9,7 +9,7 @@
    @Cacheable(value = "ipCache", key = "'getIPInfo-'+#ip")
    public IPUtil.IPInfo getIPInfo(String ip) throws Exception {
        IPUtil.IPInfo ipInfo = IPUtil.getIPInfo(ip);
        IPUtil.IPInfo ipInfo = IPUtil.getLocalIPInfo(ip);
        if (ipInfo == null) {
            throw new Exception("获取IP信息失败");
        }
src/main/java/com/yeshi/buwan/util/COSManager.java
@@ -3,7 +3,10 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import com.qcloud.cos.model.COSObjectSummary;
import com.qcloud.cos.model.ObjectListing;
import org.apache.commons.codec.digest.HmacUtils;
import org.apache.commons.lang.ArrayUtils;
@@ -29,6 +32,8 @@
        cosClient = new COSClient(cred, clientConfig);
        // bucket的命名规则为{name}-{appid} ,此处填写的存储桶名称必须为此格式
        totalBucketName = bucketName + "-" + appId;
    }
    static COSManager instance;
@@ -120,4 +125,9 @@
        return sign;
    }
    public static List<COSObjectSummary> listObject(String bucketName, String prefix){
        ObjectListing result = cosClient.listObjects(bucketName,prefix);
        return result.getObjectSummaries();
    }
}
src/main/java/com/yeshi/buwan/util/IPUtil.java
@@ -1,13 +1,16 @@
package com.yeshi.buwan.util;
import com.google.gson.Gson;
import com.show.api.ShowApiRequest;
import net.sf.json.JSONObject;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.methods.GetMethod;
import org.lionsoul.ip2region.xdb.Searcher;
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URL;
@@ -15,6 +18,19 @@
import java.net.URLEncoder;
public class IPUtil {
    private static Searcher searcher;
    static {
        try {
            URL url = IPUtil.class.getClassLoader().getResource("ip2region.xdb");
            String path = new File(url.toURI()).getAbsolutePath();
            byte[] vIndex = Searcher.loadVectorIndexFromFile(path);
            searcher = Searcher.newWithVectorIndex(path, vIndex);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    // http://verx.daili666.com/ip/?tid=558287898012218&num=1&operator=2
    public static void changeIp() {
        System.getProperties().setProperty("proxySet", "true"); // 如果不设置,只要代理IP和代理端口正确,此项不设置也可以
@@ -57,177 +73,6 @@
        return result;
    }
    // 没有找到代理IP
    // 重庆
    public static String getDaiLiIP(String area) {
        HttpClient client = new HttpClient();
        GetMethod get = null;
        try {
            get = new GetMethod(
                    "http://verx.daili666.com/ip/?tid=559511877530791&num=1&operator=2&filter=on&area="
                            + URLEncoder.encode(area, "UTF-8") + "");
        } catch (UnsupportedEncodingException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        try {
            client.executeMethod(get);
            String result = get.getResponseBodyAsString();
            sendNoticeEmail(result);
            LogUtil.i(result);
            if (!result.contains("没有找到"))
                return result;
            else
                return null;
        } catch (HttpException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
    public static String getDaiLiIP1(String area) {
        HttpClient client = new HttpClient();
        GetMethod get = null;
        try {
            get = new GetMethod(
                    "http://verx.daili666.com/ip/?tid=559186334744019&num=1&area=" + URLEncoder.encode(area, "UTF-8")
                            + "");
        } catch (UnsupportedEncodingException e1) {
            e1.printStackTrace();
        }
        try {
            client.executeMethod(get);
            String result = get.getResponseBodyAsString();
            sendNoticeEmail(result);
            LogUtil.i(result);
            if (!result.contains("没有找到"))
                return result;
            else
                return null;
        } catch (HttpException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
    // 成都
    public static String getDaiLiIP2(String area) {
        HttpClient client = new HttpClient();
        GetMethod get = null;
        try {
            get = new GetMethod("http://verx.daili666.com/ip/?tid=558287898012218&num=1&filter=on&area="
                    + URLEncoder.encode(area, "UTF-8"));// &area="+
            // URLEncoder.encode(area,
            // "UTF-8") + "
        } catch (Exception e1) {
            e1.printStackTrace();
        }
        try {
            client.executeMethod(get);
            String result = get.getResponseBodyAsString();
            sendNoticeEmail(result);
            LogUtil.i(result);
            if (!result.contains("没有找到"))
                return result;
            else
                return null;
        } catch (HttpException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
    public static String getDaiLiIP3(String area) {
        HttpClient client = new HttpClient();
        GetMethod get = null;
        try {
            get = new GetMethod("http://verx.daili666.com/ip/?tid=557489926231876&num=1&filter=on&area="
                    + URLEncoder.encode(area, "UTF-8") + "");
        } catch (UnsupportedEncodingException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        try {
            client.executeMethod(get);
            String result = get.getResponseBodyAsString();
            sendNoticeEmail(result);
            LogUtil.i(result);
            if (!result.contains("没有找到"))
                return result;
            else
                return null;
        } catch (HttpException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
    public static String getDaiLiIP4(String area) {
        HttpClient client = new HttpClient();
        GetMethod get = null;
        try {
            get = new GetMethod("http://verx.daili666.com/ip/?tid=556436495975069&num=1&area="
                    + URLEncoder.encode(area, "UTF-8") + "");
        } catch (UnsupportedEncodingException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        try {
            client.executeMethod(get);
            String result = get.getResponseBodyAsString();
            sendNoticeEmail(result);
            LogUtil.i(result);
            if (!result.contains("没有找到"))
                return result;
            else
                return null;
        } catch (HttpException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
    public static String getDaiLiIP5(String area) {
        HttpClient client = new HttpClient();
        GetMethod get = null;
        try {
            get = new GetMethod("http://verx.daili666.com/ip/?tid=559418280288916&num=1&filter=on&area="
                    + URLEncoder.encode(area, "UTF-8") + "");
        } catch (UnsupportedEncodingException e1) {
            e1.printStackTrace();
        }
        try {
            client.executeMethod(get);
            String result = get.getResponseBodyAsString();
            LogUtil.i(result);
            sendNoticeEmail(result);
            if (!result.contains("没有找到"))
                return result;
            else
                return null;
        } catch (HttpException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
    private static void sendNoticeEmail(String get) {
        if (get != null && get.contains("订单剩余数量不足")) {
            /*
@@ -268,37 +113,12 @@
        return request.getRemotePort();
    }
    public static String getIPContry(String ip) {
        IPInfo ipInfo = getIPInfo(ip);
        return ipInfo == null ? "" : ipInfo.getCountry();
    public static IPInfo getLocalIPInfo(String ip) throws Exception {
        String info = searcher.search(ip);
        String[] infos = info.split("\\|");
        IPInfo ipInfo = new IPInfo(infos[0], infos[2], infos[3]);
        return ipInfo;
    }
    public static String getIPProvince(String ip) {
        IPInfo ipInfo = getIPInfo(ip);
        return ipInfo == null ? "" : ipInfo.getProvince();
    }
    public static IPInfo getIPInfo(String ip) {
        try {
            String res = new ShowApiRequest("http://route.showapi.com/2152-1", "49053", "983e020ce60042cd95f39b3ebd4b9563")
                    .addTextPara("ip", ip)
                    .post();
            JSONObject json = JSONObject.fromObject(res);
            if (json.optInt("showapi_res_code") == 0) {
                JSONObject body = json.optJSONObject("showapi_res_body");
                if (body != null) {
                    String country = body.optString("country");
                    String state = body.optString("state");
                    String city = body.optString("city");
                    return new IPInfo(country, state, city);
                }
            }
        } catch (Exception e) {
        }
        return null;
    }
    public static class IPInfo {
        private String province;
@@ -336,4 +156,16 @@
        }
    }
    public static void main(String[] args) {
        try {
            IPInfo info =     getLocalIPInfo("113.250.254.8");
            System.out.println(new Gson().toJson(info));
            info = getLocalIPInfo("193.112.35.168");
            System.out.println(new Gson().toJson(info));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
src/main/java/com/yeshi/buwan/util/Utils.java
@@ -320,39 +320,6 @@
    public final static int TYPE_DANGER = 3;
    public static int getType(HttpServletRequest request, UserInfo user, String detailSystemId) {
        String ip = getIP(request);
        if (!(ip + "").equalsIgnoreCase(user.getIp())) {
            IPUtil.IPInfo ipInfo = IPUtil.getIPInfo(ip);
            user.setIp(ip);
            if (ipInfo != null && !StringUtil.isNullOrEmpty(ipInfo.getCity())) {
                user.setCity(ipInfo.getCity());
            }
            if (ipInfo != null && !StringUtil.isNullOrEmpty(ipInfo.getCountry())) {
                user.setCountry(ipInfo.getCountry());
            }
            new UserService().updateUserInfo(user);
        }
        Map<String, String> map = new DetailSystemConfigService().getConfigAsMap(new DetailSystem(SystemUtil.getDetailSystemId() + ""), SystemUtil.getDefaultVersion());
        String[] detailsystemIds = new String[]{"1", "2", "3", "4", "5", "6", "14", "12", "20", "11"};
        for (String d : detailsystemIds) {
            if (detailSystemId.equalsIgnoreCase(d)) {
                String dangers = map.get("danger_city");
                String[] dangerCitys = dangers.split(",");
                for (String c : dangerCitys)
                    if (c.equalsIgnoreCase(user.getCity())) {// 北上广深
                        return TYPE_DANGER_AREA;
                    }
                return TYPE_DANGER;
            }
        }
        return TYPE_NORMAL;
    }
    public static String getIP(HttpServletRequest request) {
        String ip = request.getHeader("x-forwarded-for");
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
src/main/java/com/yeshi/buwan/util/log/SearchKeyLogUtil.java
New file
@@ -0,0 +1,219 @@
package com.yeshi.buwan.util.log;
import com.google.gson.Gson;
import com.qcloud.cos.model.COSObjectSummary;
import com.yeshi.buwan.util.COSManager;
import com.yeshi.buwan.util.HttpUtil;
import com.yeshi.buwan.util.StringUtil;
import com.yeshi.buwan.util.TimeUtil;
import net.sf.json.JSONObject;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.zip.GZIPInputStream;
/**
 * @author hxh
 * @title: SearchKeyLogUtil
 * @description: 搜索关键字日志帮助类
 * @date 2022/11/10 17:28
 */
public class SearchKeyLogUtil {
    private final static String BUCKET_NAME = "log-1255749512";
    private static List<SearchKey> download(String url) throws IOException {
        InputStream inputStream = HttpUtil.getAsInputStream(url);
        GZIPInputStream gzin = new GZIPInputStream(inputStream);
        ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
        int num;
        byte[] buf = new byte[1024];
        while ((num = gzin.read(buf, 0, buf.length)) != -1) {
            byteOutputStream.write(buf, 0, num);
        }
        List<SearchKey> searchKeyList = new ArrayList<>();
        String finalString
                = new String(byteOutputStream.toByteArray(),"UTF-8");
        Scanner scanner = new Scanner(finalString);
        while (scanner.hasNextLine()) {
            String data = scanner.nextLine();
            System.out.println(new String(data.getBytes("ISO-8859-1"), "UTF-8"));
            System.out.println(new String(data.getBytes("GBK"), "UTF-8"));
            System.out.println(new String(data.getBytes("GB2312"), "UTF-8"));
            JSONObject json = JSONObject.fromObject(data);
            if (!StringUtil.isNullOrEmpty(json.optString("message"))) {
                try {
                    searchKeyList.add(new Gson().fromJson(json.optString("message"), SearchKey.class));
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        scanner.close();
        return searchKeyList;
    }
    public static List<SearchKey> downLoadData(Date dateTime) throws IOException {
        String day = TimeUtil.getGernalTime(dateTime.getTime(), "yyyy/MM/dd");
        List<COSObjectSummary> resultList = COSManager.getInstance().listObject(BUCKET_NAME, "ap-guangzhou-buwan-search-key-1652433911/" + day);
        List<String> urlList = new ArrayList<>();
        for (COSObjectSummary object : resultList) {
            String key = object.getKey();
            String url = String.format("https://%s.cos.ap-guangzhou.myqcloud.com/%s", BUCKET_NAME, key);
            urlList.add(url);
        }
        //下载文件
        List<SearchKey> finalList = new ArrayList<>();
        for (String url : urlList) {
            List<SearchKey> list = download(url);
            finalList.addAll(list);
        }
        return finalList;
    }
    public static List<RankInfo> rank(List<SearchKey> keyList, int num) {
        Map<String, Integer> countMap = new HashMap<>();
        Set<String> identitySet = new HashSet<>();
        for (SearchKey key : keyList) {
            String id = key.getKey() + "-" + key.getDevice();
            if (!identitySet.contains(id)) {
                identitySet.add(id);
                if (countMap.get(key.getKey()) == null) {
                    countMap.put(key.getKey(), 0);
                }
                countMap.put(key.getKey(), countMap.get(key.getKey()) + 1);
            }
        }
        List<RankInfo> rankList = new ArrayList<>();
        for (Iterator<String> its = countMap.keySet().iterator(); its.hasNext(); ) {
            String key = its.next();
            rankList.add(new RankInfo(key, countMap.get(key)));
        }
        Comparator<RankInfo> cm = ((o1, o2) -> o2.getCount() - o1.getCount());
        Collections.sort(rankList, cm);
        if (rankList.size() > num) {
            return rankList.subList(0, num);
        }
        return rankList;
    }
    /**
     * @return java.util.List<com.yeshi.buwan.util.log.SearchKeyLogUtil.RankInfo>
     * @author hxh
     * @description 获取今日搜索排行
     * @date 18:54 2022/11/10
     * @param: num
     **/
    public static List<RankInfo> getTodayRankList(int num) throws IOException {
        List<SearchKey> dataList = downLoadData(new Date());
        List<RankInfo> rankList = rank(dataList, 100);
        return rankList;
    }
    /**
     * @return java.util.List<com.yeshi.buwan.util.log.SearchKeyLogUtil.RankInfo>
     * @author hxh
     * @description 获取日期搜索排行
     * @date 18:54 2022/11/10
     * @param: num
     **/
    public static List<RankInfo> getDayRankList(Date date, int num) throws IOException {
        List<SearchKey> dataList = downLoadData(date);
        List<RankInfo> rankList = rank(dataList, 100);
        return rankList;
    }
    public static void main(String[] args) throws IOException {
        List<RankInfo> rankList = getTodayRankList(100);
        for (RankInfo rank : rankList) {
            System.out.println(rank.getKey() + " : " + rank.getCount());
        }
    }
    static class SearchKey {
        /**
         * key : 排球少年
         * type : 153
         * detailSystemId : 44
         * device : 75f425d9-95e7-383a-914b-a33bad909280
         * createTime : 1668010401229
         */
        private String key;
        private String type;
        private String detailSystemId;
        private String device;
        private long createTime;
        public String getKey() {
            return key;
        }
        public void setKey(String key) {
            this.key = key;
        }
        public String getType() {
            return type;
        }
        public void setType(String type) {
            this.type = type;
        }
        public String getDetailSystemId() {
            return detailSystemId;
        }
        public void setDetailSystemId(String detailSystemId) {
            this.detailSystemId = detailSystemId;
        }
        public String getDevice() {
            return device;
        }
        public void setDevice(String device) {
            this.device = device;
        }
        public long getCreateTime() {
            return createTime;
        }
        public void setCreateTime(long createTime) {
            this.createTime = createTime;
        }
    }
    public static class RankInfo {
        private String key;
        private int count;
        public RankInfo(String key, int count) {
            this.key = key;
            this.count = count;
        }
        public String getKey() {
            return key;
        }
        public void setKey(String key) {
            this.key = key;
        }
        public int getCount() {
            return count;
        }
        public void setCount(int count) {
            this.count = count;
        }
    }
}
src/main/java/com/yeshi/buwan/vo/ad/AdConfigTypeVO.java
New file
@@ -0,0 +1,44 @@
package com.yeshi.buwan.vo.ad;
/**
 * @author hxh
 * @title: AdConfigTypeVO
 * @description: 前端广告种类输出
 * @date 2023/4/12 13:28
 */
public enum AdConfigTypeVO {
    splash("ad_splash_config","splash","splash"),
    playVideoPre("ad_play_video_pre","videoPlayPre","play_video_pre"),
    exitApp("ad_exit_app","exitApp","exit_app"),
    videoDetailFullVideo("ad_video_detail_full_video","videoDetailFullVideo","video_detail_full_video"),
    videoSearch("ad_video_search","videoSearch","video_search"),
    pptvNoAdReward("pptv_no_ad_reward","pptvNoAdReward","pptv_no_ad_reward"),
    splashHotStart("ad_splash_hot_start","splashHotStart","splash_hot_start"),
    homeInterstitial("home_ad_interstitial","homeInterstitial","home_interstitial"),
    exitFullVideo("ad_exit_app_fullvideo","exitAppFullvideo","exit_app_fullvideo"),
    other("ad_other","other","other");
    private String dbKey;
    private String voKey;
    //配置文件里面的键
    private String settingKey;
    private AdConfigTypeVO(String dbKey, String voKey,String settingKey) {
        this.dbKey = dbKey;
        this.voKey = voKey;
        this.settingKey = settingKey;
    }
    public String getDbKey(){
        return dbKey;
    }
    public String getVoKey(){
        return voKey;
    }
    public String getSettingKey(){
        return settingKey;
    }
}
src/main/resources/consumer.xml
@@ -9,9 +9,9 @@
        <dubbo:parameter key="qos.port" value="33333"></dubbo:parameter>
    </dubbo:application>
    <!--<dubbo:registry address="zookeeper://172.16.16.46:2181"/>-->
    <dubbo:registry address="zookeeper://172.16.16.46:2181"/>
    <dubbo:registry address="zookeeper://193.112.35.168:2182"/>
    <!--<dubbo:registry address="zookeeper://193.112.35.168:2182"/>-->
    <dubbo:annotation package="com"/>
src/main/resources/ip2region.xdb
Binary files differ
src/main/webapp/admin/new/fenqu.html
@@ -231,95 +231,86 @@
            <div class="liebiao">
                <table class="table">
                    <thead>
                    <th width="7%">选择</th>
                    <th width="7%">编号</th>
                    <th width="12%">横版封面</th>
                    <th width="8%">竖版封面</th>
                    <th width="17%">标题</th>
                    <th width="8%">来源</th>
                    <th width="12%">时间</th>
                    <th width="12%">标签</th>
                    <th width="5%">区域</th>
                    <th width="4%">显示</th>
                    <th width="8%">操作</th>
                    <th width="7%">删除</th>
                    <th width="7%">编辑</th>
                        <th width="6%">选择</th>
                        <th width="12%">横版封面</th>
                        <th width="8%">竖版封面</th>
                        <th width="17%">标题</th>
                        <th width="12%">操作</th>
                        <th width="8%">来源</th>
                        <th width="12%">时间</th>
                        <th width="12%">标签</th>
                        <th width="5%">区域</th>
                        <th width="6%">编号</th>
                        <th width="4%">显示</th>
                        <th width="6%">删除</th>
                        <th width="6%">编辑</th>
                    </thead>
                    <tbody>
                    <tr v-for="(item,index) in videos" class="video">
                        <td width="7%">
                            <div class="xuanze">
                                <label> <input type="checkbox" class="check-item" v-bind:key="item.id"
                                               value="#">
                                </label>
                            </div>
                        </td>
                        <td width="7%">
                            <div class="bianhao videoid">{{item.id}}</div>
                        </td>
                        <td width="12%">
                            <div style="position: relative">
                                <img v-bind:src="item.hpicture" class="cover-h">
                                <img v-if="item.freeType>0" src="image/icon_vip.png"
                                     style="position: absolute;right: 0;bottom: 0;height: 20px;">
                            </div>
                        </td>
                        <td width="8%">
                            <img v-bind:src="item.vpicture" class="cover-v">
                        </td>
                        <td width="17%">
                            <div class="title">{{item.name}}</div>
                        </td>
                        <td width="8%">
                            <div class="resource">
                                <div v-for="resource in item.resourceList">{{resource}}</div>
                            </div>
                        </td>
                        <td width="12%">
                            <div>
                                创建:{{item.createTime}}<br>
                                更新:{{item.updatetime}}
                            </div>
                        </td>
                        <td width="8%">
                            <div>
                                {{item.tag}}
                            </div>
                        </td>
                        <td width="8%">
                            <div>
                                {{item.area}}
                            </div>
                        </td>
                        <td width="4%">
                            <div class="xuanze">
                                <label> <input type="checkbox" value="#" class="video-show" v-bind:checked="item.show"
                                               v-on:click="changeShow($event,item.id)">
                                </label>
                            </div>
                        </td>
                        <td width="8%">
                            <div class="bianhao addrecommend">
                                <a href="javascript:void(0)" v-on:click="addRecommend(item)">添加<br>推荐</a>
                            </div>
                        </td>
                        <td width="7%">
                            <div class="anniu">
                                <img src="image/dustbin.png" class="delete" v-on:click="deleteItem(index,item.id)">
                            </div>
                        </td>
                        <td width="7%">
                            <div class="anniu">
                                <a key="370" target="_blank" class="edit"
                                   v-bind:href="'edit-lmneirong-video.html?id='+item.id"><img
                                        src="image/bianji.png"></a>
                            </div>
                        </td>
                    </tr>
                        <tr v-for="(item,index) in videos" class="video">
                            <td width="7%">
                                <div class="xuanze">
                                    <label> <input type="checkbox" class="check-item" v-bind:key="item.id" value="#">
                                    </label>
                                </div>
                            </td>
                            <td width="12%">
                                <div style="position:relative">
                                    <img v-bind:src="item.hpicture" class="cover-h">
                                    <img v-if="item.freeType>0" src="image/icon_vip.png" style="position:absolute; right:0;bottom:0; height:20px;">
                                </div>
                            </td>
                            <td width="8%">
                                <img v-bind:src="item.vpicture" class="cover-v">
                            </td>
                            <td width="17%">
                                <div class="title">{{item.name}}</div>
                            </td>
                            <td width="8%">
                                <button class="btn btn-primary pl-addrecommend" type="button" v-on:click="addRecommend(item)" style="height: 100px;width: 160px;">添加推荐</button>
                            </td>
                            <td width="8%">
                                <div class="resource" style="font-size: 12px;">
                                    <div v-for="resource in item.resourceList ">{{resource}}</div>
                                </div>
                            </td>
                            <td width="12%">
                                <div style="font-size:12px;">
                                    创建:{{item.createTime}}<br> 更新:{{item.updatetime}}
                                </div>
                            </td>
                            <td width="8%" style="font-size:12px;">
                                <div>
                                    {{item.tag}}
                                </div>
                            </td>
                            <td width="8%" style="font-size:12px;">
                                <div>
                                    {{item.area}}
                                </div>
                            </td>
                            <td width="7%" style="font-size: 12px;">
                                <div class="bianhao videoid ">{{item.id}}</div>
                            </td>
                            <td width="4%">
                                <div class="xuanze">
                                    <label> <input type="checkbox" value="#" class="video-show" v-bind:checked="item.show"
                                           v-on:click="changeShow($event,item.id)">
                            </label>
                                </div>
                            </td>
                            <td width="7%">
                                <div class="anniu">
                                    <img src="image/dustbin.png" class="delete" v-on:click="deleteItem(index,item.id)">
                                </div>
                            </td>
                            <td width="7%">
                                <div class="anniu">
                                    <a key="370" target="_blank" class="edit" v-bind:href="'edit-lmneirong-video.html?id='+item.id"><img src="image/bianji.png"></a>
                                </div>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
src/main/webapp/admin/new/login.html
@@ -1,92 +1,100 @@
<html lang="zh-cn">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>视频后台管理系统</title>
        <link href="css/bootstrap.min.css" rel="stylesheet">
        <link href="css/main.css" rel="stylesheet">
        <!--[if lt IE 9]>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>视频后台管理系统</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/main.css" rel="stylesheet">
    <!--[if lt IE 9]>
      <script src="js/html5shiv.js"></script>
      <script src="js/respond.min.js"></script>
    <![endif]-->
    </head>
</head>
    <body background="image/airlift-bg.png">
        <h1>视频后台管理系统</h1>
        <div class="shurukuang">
            <h2>用户登录</h2>
            <div class="auth-form-body mt-3">
                <form role="form" class="form-horizontal">
                    <label for="login_field">用户名</label>
                    <input autocapitalize="off" autocorrect="off" autofocus class="form-control input-block input-lg" id="account" name="account" tabindex="1" type="text" /></br>
                    <label for="password">密码</label>
                    <input class="form-control form-control input-block input-lg" id="password" name="password" tabindex="2" type="password" />
<body background="image/airlift-bg.png">
    <h1>视频后台管理系统</h1>
    <div class="shurukuang">
        <h2>用户登录</h2>
        <div class="auth-form-body mt-3">
            <form role="form" class="form-horizontal">
                <label for="login_field">用户名</label>
                <input autocapitalize="off" autocorrect="off" autofocus class="form-control input-block input-lg" id="account" name="account" tabindex="1" type="text" /></br>
                <label for="password">密码</label>
                <input class="form-control form-control input-block input-lg" id="password" name="password" tabindex="2" type="password" />
                    <div class="form-group">
                        <div class="col-xs-12">
                            <div class="col-xs-7" style="padding-left: 0;">
                                <input class="form-control input-lg" type="text" name="verifycode" id="verifycode" placeholder="请输入验证码">
                            </div>
                            <div class="col-xs-5" style="padding-right: 0;">
                                <img class="codeimg" style="width: 100px;height: 48px;border-radius: 5px;" src="#" />
                            </div>
                        </div>
                    </div>
                <div class="form-group">
                    <div class="col-xs-12">
                        <div class="col-xs-7" style="padding-left: 0;">
                            <input class="form-control input-lg" type="text" name="verifycode" id="verifycode" placeholder="请输入验证码">
                        </div>
                        <div class="col-xs-5" style="padding-right: 0;">
                            <img class="codeimg" style="width: 100px;height: 48px;border-radius: 5px;" src="#" />
                        </div>
                    </div>
                </div>
                </form>
                <input class="btn btn-primary btn-block btn-lg submit" data-disable-with="Signing in…" name="commit" tabindex="3" type="button" value="登&nbsp;&nbsp;&nbsp;&nbsp;录" />
            </div>
            </form>
            <input class="btn btn-primary btn-block btn-lg submit" data-disable-with="Signing in…" name="commit" tabindex="3" type="button" value="登&nbsp;&nbsp;&nbsp;&nbsp;录" />
        </div>
        </div>
        <script type="text/javascript" src="./js/jquery.min.js"></script>
        <script type="text/javascript" src="./js/bootstrap.min.js"></script>
        <script type="text/javascript" src="./layer/layer.js"></script>
        <script>
            $(function() {
                $(".codeimg").attr("src",getSrc());
                $(".codeimg").click(function() {
                    $(".codeimg").attr("src", getSrc());
                });
    </div>
    <script type="text/javascript" src="./js/jquery.min.js"></script>
    <script type="text/javascript" src="./js/bootstrap.min.js"></script>
    <script type="text/javascript" src="./layer/layer.js"></script>
    <script>
        $(function() {
            $(".codeimg").attr("src", getSrc());
            $(".codeimg").click(function() {
                $(".codeimg").attr("src", getSrc());
            });
                $(".submit").click(function(e) {
                    if($("#account").val().length < 1) {
                        layer.msg("请输入正确的账号");
                        return false;
                    }
            $(".submit").click(function(e) {
                if ($("#account").val().length < 1) {
                    layer.msg("请输入正确的账号");
                    return false;
                }
                    if($("#password").val().length < 1) {
                        layer.msg("请输入正确的密码");
                        return false;
                    }
                if ($("#password").val().length < 1) {
                    layer.msg("请输入正确的密码");
                    return false;
                }
                    if($("#verifycode").val().length < 4) {
                        layer.msg("请输入正确的验证码");
                        return false;
                    }
                if ($("#verifycode").val().length < 4) {
                    layer.msg("请输入正确的验证码");
                    return false;
                }
                    $.post('api/login/adminLogin', {
                        'username': $("#account").val(),
                        'pwd': $("#password").val(),
                        'code': $("#verifycode").val()
                    }, function(data) {
                        if(data.code == 0) { //登录成功
                            window.location.href = "shuju.html";
                        } else {
                            layer.msg(data.error);
                        }
                    }, "json");
                    return true;
                });
            });
        </script>
<script>
    function getSrc(){
        return "api/validate/imgcode?temp="+new Date().getTime();
    }
</script>
    </body>
                $.post('api/login/adminLogin', {
                    'username': $("#account").val(),
                    'pwd': $("#password").val(),
                    'code': $("#verifycode").val()
                }, function(data) {
                    if (data.code == 0) { //登录成功
                        window.location.href = "shuju.html";
                    } else {
                        layer.msg(data.error);
                    }
                }, "json");
                return true;
            });
            //点击Enter键,直接调取登录的按键函数
            $(document).keydown(function(event) {
                if (event.keyCode == 13) {
                    // alert("回车了");
                    $(".submit").click();
                };
            });
        });
    </script>
    <script>
        function getSrc() {
            return "api/validate/imgcode?temp=" + new Date().getTime();
        }
    </script>
</body>
</html>
src/main/webapp/admin/new/shuju.html
@@ -60,6 +60,29 @@
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-12">
                            <div class="card1">
                                <div class="content">
                                    <div class="footer">
                                        <div class="legend" style="display: flex;justify-content: space-between">
                                            <h4>今日视频搜索数据TOP50</h4>
                                            <button type="button" id="refresh_search" class="btn btn-default">刷新</button>
                                        </div>
                                        <hr>
                                    </div>
                                    <div>
                                        <div id="container_search" style="min-width:400px;height: 1800px;"></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-12">
                            <div class="card1">
@@ -138,6 +161,52 @@
                });
            }
            function fillSearchData(names, datas) {
                $('#container_search').highcharts({
                    chart: {
                        type: 'bar'
                    },
                    title: {
                        text: '搜索用户数'
                    },
                    xAxis: {
                        categories: names,
                    },
                    yAxis: {
                        min: 0,
                        labels: {
                            overflow: 'justify'
                        }
                    },
                    plotOptions: {
                        bar: {
                            dataLabels: {
                                enabled: true
                            }
                        }
                    },
                    legend: {
                        layout: 'vertical',
                        align: 'right',
                        verticalAlign: 'top',
                        x: -40,
                        y: 100,
                        floating: true,
                        borderWidth: 1,
                        backgroundColor: ((Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'),
                        shadow: true
                    },
                    credits: {
                        enabled: false
                    },
                    series: [{
                        name: '搜索用户数',
                        data: datas
                    }]
                });
            }
            function fillYData(data) {
                $("#rcount").html(data.data.rcount);
                $("#trcount").html(data.data.trcount);
@@ -170,6 +239,23 @@
                    doResponse(data, fillYData(data));
                }, 'json');
                $.post('api/statistics/gettopsearch', {
                    'detailsystem': 0
                }, function(data) {
                    doResponse(data,fillSearchData(data.data.name, data.data.count));
                }, 'json');
                //刷新搜索关键字
                $("#refresh_search").click(function () {
                    $.post('api/statistics/refreshtopsearch', {
                        'detailsystem': 0
                    }, function(data) {
                        doResponse(data,function(){
                        });
                    }, 'json');
                });
            });
        </script>
    </body>
src/test/java/com/hxh/spring/test/DES.java
@@ -9,7 +9,7 @@
public class DES {
    @org.junit.Test
    public void test1() {
        String st = "iDp+mknN2urZPWPAdmBTv1ME3YqW7QwsBhPMkixAysNg2DZ9i+GKm9I3ghM2n+Hblt8frlqOqy9WyuKBJYan9rKU+dY8dpyINl7NT9ZM1/sxUOpCZYRqewXfO7csXUtRja5PaHCXBO7b23mdwY/YezI51deZjbGSpvsNYeP9NYzDdczVBQ/c+8RaWISN1JmYGDyjYWbVWGXWg5hmpP5SNInhiaI0ikbbwnV+FizRDqHeD7/iIMWZS9+TLwc7epMdQgHX0QaW7T0EDhwclOKBDqEuKWyM/dm+4BboAHZPUDIv3L/9Fk/jhV5dpHVj52qvBDGqW/co3cutnscZRcj74tVcSr4TzqG/";
        String st = "iDp+mknN2urZPWPAdmBTv1ME3YqW7QwsYdyNZlGbD4OM41zjK4t7VF6W3TtXskAAKgHKl39hNukwNhMUNfS8M21fJsLuZLdUX4vMxG/vcfnVK/UzMgpLwgQA5AYOCg6VWB+hF/zZGV1dIP3MCdfoApdCu6L8R25es8r97ZM5ttxS7JLFjMHXNjV27aCWdsSk30wzjueSW7zJGnUPkP3ZxQIyIy/dNVXSGKyI1dFn2089VOBeOPZP9T0ZJPsob95qv7B2t7zUFDe5U94UL6rmVf2Gpo1fiyTNa8COHMXyLHBMz27Q5kvm+4TngTe5hzHaN+D9Svm3o0xJiMKFmvc6t9BoLPl1aSQh3FqVZL4fhzIZAA6K7SYODH1dMGf2m8tkr7vC/zPXrIt7AQeiqSiUyQxqQYKc7+ucEk5qnF1hK/cA4fHj7TznWIQFkzDPrr4PS1KPuiJ0SMZ9UGQSeWXAUMgoxOUvKSu9W4PzTlnqlsZvo72q94wZVhEzd0SIv2Fb7239DLpiNKb/FHyiv0P8uljlWITabTq0vIBR1cggUOshsCfGUeYLQY42eoKoE87RVoQg5cn7Ef8EksIkYzUo/yizLyFsqhmNYmMcd4bquAN9fNFLSAdIIx+s0kHj3YY+QE1GlFaPEFj1N8na4IukTPNmD1LEpsr1bUexIAiQMtBNEgAxHN51iRswCsZhynSjWaN/xEvYcxEISjfGOAP2d0uBwCe0yEuSbGvWACYEhXRl8EJj0KShaA==";
        System.out.println(DESUtil.decode(st));
    }
src/test/java/com/hxh/spring/test/IPTest.java
@@ -1,16 +1,11 @@
package com.hxh.spring.test;
import com.yeshi.buwan.util.IPUtil;
import org.junit.Test;
public class IPTest {
    @Test
    public void test1() {
//        for (int i = 0; i < 10; i++)
            System.out.println(IPUtil.getIPProvince("134.175.68.214"));
//         com.tencentcloudapi.cls.producer.common.Logs$Log$Builder.toString();
    }
}
src/test/java/com/hxh/spring/test/video/YouKuTest.java
@@ -35,7 +35,7 @@
    @Test
    public void test1() {
        try {
            youKuVideoUpdate.updateLatestVideo("bb8e820fe05d414a8232");
            youKuVideoUpdate.updateLatestVideo("ffca07f611cf426c99af");
        } catch (Exception e) {
            e.printStackTrace();
        }