Просмотр исходного кода

首页接口增加根据用户下的appId过滤

小杜 3 месяцев назад
Родитель
Сommit
eac423cd3e
18 измененных файлов с 197 добавлено и 50 удалено
  1. 68 26
      yt-agent/agent-service/src/main/java/com/ytpm/controller/AgentIndexController.java
  2. 7 0
      yt-agent/agent-service/src/main/java/com/ytpm/dao/AgentAppMapper.java
  3. 3 0
      yt-agent/agent-service/src/main/java/com/ytpm/service/AgentAppService.java
  4. 6 0
      yt-agent/agent-service/src/main/java/com/ytpm/service/impl/AgentAppServiceImpl.java
  5. 4 0
      yt-agent/agent-service/src/main/resources/mapper/AgentAppMapper.xml
  6. 2 1
      yt-app/app-feign/src/main/java/com/ytpm/feign/AppFeign.java
  7. 4 3
      yt-app/app-service/src/main/java/com/ytpm/controller/UserController.java
  8. 5 2
      yt-app/app-service/src/main/java/com/ytpm/dao/AppUserMapper.java
  9. 24 0
      yt-app/app-service/src/main/resources/mapper/AppUserMapper.xml
  10. 17 4
      yt-app/app-service/src/main/resources/mapper/LoginRecordMapper.xml
  11. 10 0
      yt-common/src/main/java/com/ytpm/app/param/AppQueryUserTodayTimeParam.java
  12. 3 0
      yt-common/src/main/java/com/ytpm/app/param/AppUserQueryParam.java
  13. 3 2
      yt-risk/risk-feign/src/main/java/com/ytpm/feign/RiskFeign.java
  14. 5 4
      yt-risk/risk-manage/src/main/java/com/ytpm/controller/RiskManageController.java
  15. 2 2
      yt-risk/risk-manage/src/main/java/com/ytpm/dao/RiskManageMapper.java
  16. 2 2
      yt-risk/risk-manage/src/main/java/com/ytpm/service/RiskService.java
  17. 4 4
      yt-risk/risk-manage/src/main/java/com/ytpm/service/impl/RiskServiceImpl.java
  18. 28 0
      yt-risk/risk-manage/src/main/resources/mapper/RiskManageMapper.xml

+ 68 - 26
yt-agent/agent-service/src/main/java/com/ytpm/controller/AgentIndexController.java

@@ -9,26 +9,33 @@ import com.ytpm.advertise.param.HourReportParam;
 import com.ytpm.advertise.view.ComprehensiveAppReport;
 import com.ytpm.advertise.view.HourReportRes;
 import com.ytpm.advertise.view.HourReportView;
+import com.ytpm.agent.param.AppListParam;
 import com.ytpm.agent.param.DateRangeParams;
 import com.ytpm.agent.param.IndexResParam;
+import com.ytpm.agent.view.AgentAppView;
 import com.ytpm.agent.view.AgentChannelView;
+import com.ytpm.agent.view.AgentUserInfo;
 import com.ytpm.agent.view.IndexHourReportView;
 import com.ytpm.app.model.YtDyzUser;
+import com.ytpm.app.param.AppQueryUserTodayTimeParam;
 import com.ytpm.app.param.AppUserQueryParam;
 import com.ytpm.dao.ChannelMapper;
 import com.ytpm.feign.AdvertiseFeign;
 import com.ytpm.feign.AppFeign;
 import com.ytpm.feign.RiskFeign;
 import com.ytpm.general.Result;
+import com.ytpm.service.AgentAppService;
 import com.ytpm.util.DateUtil;
 import com.ytpm.util.RedisService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.core.annotation.AuthenticationPrincipal;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
+import springfox.documentation.annotations.ApiIgnore;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
@@ -74,17 +81,20 @@ public class AgentIndexController {
     @Autowired
     private RedisService redisService;
 
+    @Resource
+    private AgentAppService agentAppService;
+
     /**
      * 查询广告平台收益
      */
     @ApiOperation("查询广告平台收益")
     @PostMapping("/profit")
-    public Result<?> profit() {
+    public Result<?> profit(@ApiIgnore @AuthenticationPrincipal AgentUserInfo userInfo) {
         // 1. 准备日期参数
         DateRangeParams dateParams = prepareDateParams();
 
         // 2. 构建查询参数
-        ComprehensiveReportParam reportParam = buildReportParam(dateParams);
+        ComprehensiveReportParam reportParam = buildReportParam(dateParams, userInfo);
 
         // 3. 获取报表数据
         List<ComprehensiveAppReport> appReport = fetchReportData(reportParam);
@@ -113,7 +123,7 @@ public class AgentIndexController {
     /**
      * 构建报表查询参数
      */
-    private ComprehensiveReportParam buildReportParam(DateRangeParams dateParams) {
+    private ComprehensiveReportParam buildReportParam(DateRangeParams dateParams, AgentUserInfo userInfo) {
         ComprehensiveReportParam param = new ComprehensiveReportParam();
 
         // 设置日期范围
@@ -124,9 +134,19 @@ public class AgentIndexController {
         param.setNetwork_firm_id_list(Arrays.stream(AdPlatformTypeEnum.values())
                 .map(AdPlatformTypeEnum::getCode)
                 .collect(Collectors.toList()));
-
+        AppListParam appListParam = new AppListParam();
+        appListParam.setUserId(userInfo.getUserId());
+        //增加appId查询
+        List<AgentAppView> agentAppViews = agentAppService.searchAppIdList(appListParam);
+        ArrayList<String> list = new ArrayList<>();
+        if (CollUtil.isNotEmpty(agentAppViews)) {
+          param.setApp_id_list(agentAppViews.stream().map(AgentAppView::getAppId).collect(Collectors.toList()));
+        }
+        else {
+            param.setApp_id_list(list);
+        }
         // 设置分组
-        param.setGroup_by(Arrays.asList("date", "network_firm_id"));
+        param.setGroup_by(Arrays.asList("date", "network_firm_id","app"));
 
         return param;
     }
@@ -136,8 +156,12 @@ public class AgentIndexController {
      */
     private List<ComprehensiveAppReport> fetchReportData(ComprehensiveReportParam param) {
         long startTime = System.currentTimeMillis();
-        List<ComprehensiveAppReport> appReport = advertiseFeign.getAppReport(param);
-        log.info("调用API接口耗时: {}ms", System.currentTimeMillis() - startTime);
+        List<ComprehensiveAppReport> appReport = new ArrayList<>();
+        if (CollUtil.isNotEmpty(param.getApp_id_list())){
+            appReport=advertiseFeign.getAppReport(param);
+            log.info("调用API接口耗时: {}ms", System.currentTimeMillis() - startTime);
+        }
+        //appIdList为空 返回空数据
         return appReport;
     }
 
@@ -261,19 +285,17 @@ public class AgentIndexController {
     }
 
 
-
     /**
      * 查询分小时报表 折线图数据
      * 预估收益以及ecpm
      */
     @ApiOperation("查询分小时报表")
     @PostMapping("/hourReport")
-    public Result<?> hourReport() {
-        if (redisService.hasKey("hourReport")) {
-            List<IndexHourReportView> hourReportResList = JSON.parseArray(redisService.getStr("hourReport"), IndexHourReportView.class);
+    public Result<?> hourReport(@ApiIgnore @AuthenticationPrincipal AgentUserInfo userInfo) {
+        if (redisService.hasKey("hourReport"+userInfo.getUserId())) {
+            List<IndexHourReportView> hourReportResList = JSON.parseArray(redisService.getStr("hourReport"+userInfo.getUserId()), IndexHourReportView.class);
             return Result.resultObjOk(hourReportResList);
-        }
-        else {
+        } else {
             // 1. 准备日期参数
             LocalDate today = LocalDate.now();
             DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
@@ -285,6 +307,16 @@ public class AgentIndexController {
             ArrayList<IndexHourReportView> indexHourReportViews = new ArrayList<>();
             ArrayList<HourReportParam> hourReportParams = new ArrayList<>();
             ConcurrentHourReportsParams concurrentHourReportsParams = new ConcurrentHourReportsParams();
+            AppListParam appListParam = new AppListParam();
+            appListParam.setUserId(userInfo.getUserId());
+            List<AgentAppView> agentAppViews = agentAppService.searchAppIdList(appListParam);
+            List<String> appIdList;
+            if (CollUtil.isNotEmpty(agentAppViews)){
+                appIdList = agentAppViews.stream().map(AgentAppView::getAppId).collect(Collectors.toList());
+            }
+            else {
+                return Result.resultObjOk(indexHourReportViews);
+            }
             for (AgentChannelView agentChannelView : agentChannelViews) {
                 HourReportParam param = new HourReportParam();
                 Integer networkId = agentChannelView.getNetworkId();
@@ -296,6 +328,7 @@ public class AgentIndexController {
                 param.setStart(0);
                 param.setTime_zone("UTC+8");
                 param.setChannelName(agentChannelView.getChannelName());
+                param.setApp_id_list(appIdList);
                 hourReportParams.add(param);
             }
             concurrentHourReportsParams.setParam(hourReportParams);
@@ -309,7 +342,7 @@ public class AgentIndexController {
                 indexHourReportViews.add(indexHourReportView);
             }
             //50分钟过期
-            redisService.setTimeOutStr("hourReport",JSON.toJSONString(indexHourReportViews),50*60*1000);
+            redisService.setTimeOutStr("hourReport"+userInfo.getUserId(), JSON.toJSONString(indexHourReportViews), 50 * 60 * 1000);
             return Result.resultObjOk(indexHourReportViews);
         }
 
@@ -317,6 +350,7 @@ public class AgentIndexController {
 
     /**
      * 对返回的小时报表数据进行处理
+     *
      * @param hourReportRes 小时数据
      * @return
      */
@@ -343,26 +377,31 @@ public class AgentIndexController {
     }
 
 
-
     @ApiOperation("查询用户行为数据统计")
     @PostMapping("/userStatistic")
-    public Result<Map<String, Object>> getDashboardData() throws InterruptedException {
+    public Result<Map<String, Object>> getDashboardData(@ApiIgnore @AuthenticationPrincipal AgentUserInfo userInfo) throws InterruptedException {
         Map<String, Object> result = new ConcurrentHashMap<>();
-
+        AppListParam appListParam = new AppListParam();
+        appListParam.setUserId(userInfo.getUserId());
+        List<String> appIdList = null;
+        List<AgentAppView> agentAppViews = agentAppService.searchAppIdList(appListParam);
+        if (CollUtil.isNotEmpty(agentAppViews)){
+            appIdList = agentAppViews.stream().map(AgentAppView::getAppId).collect(Collectors.toList());
+        }
         processPeriodData(result, "today",
                 DateUtil.getTodayStart(),
                 DateUtil.getTodayEnd(),
-                true);
+                true,appIdList);
 
         processPeriodData(result, "yesterday",
                 DateUtil.getYesterdayStart(),
                 DateUtil.getYesterdayEnd(),
-                false);
+                false,appIdList);
 
         processPeriodData(result, "month",
                 DateUtil.getMonthStart(),
                 DateUtil.getMonthEnd(),
-                false);
+                false,appIdList);
 
         return Result.resultObjOk(result);
 
@@ -373,10 +412,11 @@ public class AgentIndexController {
                                    String prefix,
                                    Date startTime,
                                    Date endTime,
-                                   boolean isToday) {
+                                   boolean isToday,List<String> appIdList) {
         AppUserQueryParam param = new AppUserQueryParam();
         param.setStartTime(startTime);
         param.setEndTime(endTime);
+        param.setAppIdList(appIdList);
 
         // 获取基础数据
         int userCount = appFeign.queryUserByTime(param).size();
@@ -388,7 +428,7 @@ public class AgentIndexController {
             // 拆解调用步骤
             Result<Map<String, Integer>> response = riskFeign.queryBanned(param);
 
-            if(response == null) {
+            if (response == null) {
                 log.error("Feign调用返回null!");
                 return;
             }
@@ -397,14 +437,14 @@ public class AgentIndexController {
             log.info("服务返回消息: {}", response.getMessage());
             Map<String, Integer> riskMap = response.getData();
 
-            if(riskMap == null) {
+            if (riskMap == null) {
                 log.warn("服务返回data字段为null");
             } else {
                 log.info("获取风险数据: {}", riskMap);
             }
             result.put(prefix + "Risk", riskMap.get("risk"));
             result.put(prefix + "Lock", riskMap.get("lock"));
-        } catch(Exception e) {
+        } catch (Exception e) {
             log.error("Feign调用异常", e); // 捕获Feign异常
         }
 
@@ -415,8 +455,10 @@ public class AgentIndexController {
 
         // 今日特有逻辑
         if (isToday) {
-            int[] todayUser = appFeign.queryUserByTodayTime();
-            Map<String, int[]> data = riskFeign.queryBannedByHourToday().getData();
+            AppQueryUserTodayTimeParam appQueryUserTodayTimeParam = new AppQueryUserTodayTimeParam();
+            appQueryUserTodayTimeParam.setAppIdList(appIdList);
+            int[] todayUser = appFeign.queryUserByTodayTime(appQueryUserTodayTimeParam);
+            Map<String, int[]> data = riskFeign.queryBannedByHourToday(appQueryUserTodayTimeParam).getData();
 
             result.put("todayUser", todayUser);
             result.put("todayRiskHour", data.get("riskHour"));

+ 7 - 0
yt-agent/agent-service/src/main/java/com/ytpm/dao/AgentAppMapper.java

@@ -20,6 +20,13 @@ public interface AgentAppMapper {
      * 查询应用列表
      */
     List<AgentAppView> searchAppList(AppListParam appListParam);
+
+    /**
+     * 查询APPList
+     * @param appListParam
+     * @return
+     */
+    List<AgentAppView> searchAppIdList(AppListParam appListParam);
     /**
      * 查询加盟商上架应用列表
      */

+ 3 - 0
yt-agent/agent-service/src/main/java/com/ytpm/service/AgentAppService.java

@@ -9,6 +9,8 @@ import com.ytpm.agent.view.AgentEnableAppView;
 import com.ytpm.general.Result;
 import com.ytpm.general.ResultTable;
 
+import java.util.List;
+
 public interface AgentAppService {
     /**
      * 查询渠道启用的应用列表
@@ -19,6 +21,7 @@ public interface AgentAppService {
      * 查询应用列表
      */
     ResultTable<AgentAppView> searchAppList(AppListParam appListParam);
+    List<AgentAppView> searchAppIdList(AppListParam appListParam);
 
     /**
      * 保存应用

+ 6 - 0
yt-agent/agent-service/src/main/java/com/ytpm/service/impl/AgentAppServiceImpl.java

@@ -81,6 +81,12 @@ public class AgentAppServiceImpl implements AgentAppService {
         return ResultTable.resultTableOk(new PageInfo<>(views));
     }
 
+    @Override
+    public List<AgentAppView> searchAppIdList(AppListParam appListParam) {
+        List<AgentAppView> agentAppViews = agentAppMapper.searchAppIdList(appListParam);
+        return agentAppViews;
+    }
+
     /**
      * 新增应用
      */

+ 4 - 0
yt-agent/agent-service/src/main/resources/mapper/AgentAppMapper.xml

@@ -80,6 +80,10 @@
         GROUP BY
             ya.app_id
     </select>
+
+    <select id="searchAppIdList" resultType="com.ytpm.agent.view.AgentAppView">
+        select app_id from yt_app  where user_id =#{userId}
+    </select>
     <select id="getIssuedAppList" resultType="com.ytpm.agent.model.YtPlatformUserApp">
         select
            app_id, app_name, user_id, app_type, detail_url, package_name, domain, issued_time, wx_app_id

+ 2 - 1
yt-app/app-feign/src/main/java/com/ytpm/feign/AppFeign.java

@@ -2,6 +2,7 @@ package com.ytpm.feign;
 
 import com.ytpm.app.model.YtDyzAdRecord;
 import com.ytpm.app.model.YtDyzUser;
+import com.ytpm.app.param.AppQueryUserTodayTimeParam;
 import com.ytpm.app.param.AppUserParam;
 import com.ytpm.app.param.YtAppUserListParam;
 import com.ytpm.app.param.AppUserQueryParam;
@@ -37,7 +38,7 @@ public interface AppFeign {
     List<YtDyzUser> queryUserByTime(@RequestBody AppUserQueryParam appUserQueryParam);
 
     @PostMapping("/user/queryUserByTodayTime")
-    int[] queryUserByTodayTime();
+    int[] queryUserByTodayTime(@RequestBody AppQueryUserTodayTimeParam appQueryUserTodayTimeParam);
 
     @PostMapping("/user/queryLoginRecords")
      List<String> queryLoginRecords(@RequestBody AppUserQueryParam appUserQueryParam);

+ 4 - 3
yt-app/app-service/src/main/java/com/ytpm/controller/UserController.java

@@ -6,6 +6,7 @@ import com.github.pagehelper.PageInfo;
 import com.ytpm.advertise.enums.AdSourceTypeEnum;
 import com.ytpm.app.model.YtDyzAdRecord;
 import com.ytpm.app.model.YtDyzUser;
+import com.ytpm.app.param.AppQueryUserTodayTimeParam;
 import com.ytpm.app.param.AppUserParam;
 import com.ytpm.app.param.AppUserQueryParam;
 import com.ytpm.app.param.YtAppUserListParam;
@@ -214,12 +215,12 @@ public class UserController {
 
     @PostMapping("/queryUserByTime")
     public List<YtDyzUser> queryUserByTime(@RequestBody AppUserQueryParam appUserQueryParam) {
-        List<YtDyzUser> ytDyzUsers = appUserMapper.queryAllByTime(appUserQueryParam.getStartTime(), appUserQueryParam.getEndTime());
+        List<YtDyzUser> ytDyzUsers = appUserMapper.queryAllByTime(appUserQueryParam.getStartTime(), appUserQueryParam.getEndTime(),appUserQueryParam.getAppIdList());
         return ytDyzUsers;
     }
 
     @PostMapping("/queryUserByTodayTime")
-    public int[] queryUserByTodayTime() {
+    public int[] queryUserByTodayTime(@RequestBody AppQueryUserTodayTimeParam appQueryUserTodayTimeParam) {
         // 获取当前日期
         LocalDate localDate = LocalDate.now();
 
@@ -230,7 +231,7 @@ public class UserController {
         Date startTime = Date.from(startOfDay.atZone(ZoneId.systemDefault()).toInstant());
         Date endTime = Date.from(endOfDay.atZone(ZoneId.systemDefault()).toInstant());
         // 查询用户注册数据
-        List<HourCountView> hourCountViews = appUserMapper.countUsersByHour(startTime, endTime);
+        List<HourCountView> hourCountViews = appUserMapper.countUsersByHour(startTime, endTime,appQueryUserTodayTimeParam.getAppIdList());
         // 初始化每小时用户数量数组
         int[] hourlyCounts = new int[24];
         for (HourCountView hc : hourCountViews) {

+ 5 - 2
yt-app/app-service/src/main/java/com/ytpm/dao/AppUserMapper.java

@@ -61,11 +61,14 @@ public interface AppUserMapper {
      */
     List<YtDyzUser> queryAllByTime(
             @Param("startTime") Date startTime,
-            @Param("endTime") Date endTime
+            @Param("endTime") Date endTime,
+            @Param("appIdList") List<String> appIdList
     );
 
     List<HourCountView> countUsersByHour(@Param("startTime") Date startTime,
-                                         @Param("endTime") Date endTime);
+                                         @Param("endTime") Date endTime,
+                                         @Param("appIdList") List<String> appIdList
+    );
 
     /**
      * 查询用户信息

+ 24 - 0
yt-app/app-service/src/main/resources/mapper/AppUserMapper.xml

@@ -237,6 +237,18 @@
             <if test="endTime != null">
                 AND registry_time &lt;= #{endTime}
             </if>
+            <choose>
+                <when test="appIdList == null or appIdList.isEmpty()">
+                    AND 1 = 0
+                </when>
+                <otherwise>
+                    AND app_id IN
+                    <foreach collection="appIdList" item="item"
+                             open="(" close=")" separator=",">
+                        #{item}
+                    </foreach>
+                </otherwise>
+            </choose>
         </where>
         ORDER BY registry_time DESC
     </select>
@@ -244,6 +256,18 @@
         SELECT HOUR(registry_time) AS hour, COUNT(*) AS count
         FROM yt_dyz_user
         WHERE registry_time BETWEEN #{startTime} AND #{endTime}
+        <choose>
+            <when test="appIdList == null or appIdList.isEmpty()">
+                AND 1 = 0
+            </when>
+            <otherwise>
+                AND app_id IN
+                <foreach collection="appIdList" item="item"
+                         open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </otherwise>
+        </choose>
         GROUP BY HOUR(registry_time)
     </select>
 

+ 17 - 4
yt-app/app-service/src/main/resources/mapper/LoginRecordMapper.xml

@@ -34,15 +34,28 @@
     </select>
 
     <select id="queryLoginCount" resultType="String">
-        select user_id
-        from yt_dyz_login_record
+        select ydlr.user_id
+        from yt_dyz_login_record ydlr
+        left join yt_dyz_user ydu on ydlr.user_id=ydu.user_id
         <where>
             <if test="startTime != null">
-                AND login_time >= #{startTime}
+                AND ydlr.login_time >= #{startTime}
             </if>
             <if test="endTime != null">
-                AND login_time &lt;= #{endTime}
+                AND ydlr.login_time &lt;= #{endTime}
             </if>
+            <choose>
+                <when test="appIdList == null or appIdList.isEmpty()">
+                    AND 1 = 0
+                </when>
+                <otherwise>
+                    AND ydu.app_id IN
+                    <foreach collection="appIdList" item="item"
+                             open="(" close=")" separator=",">
+                        #{item}
+                    </foreach>
+                </otherwise>
+            </choose>
         </where>
         group by user_id
     </select>

+ 10 - 0
yt-common/src/main/java/com/ytpm/app/param/AppQueryUserTodayTimeParam.java

@@ -0,0 +1,10 @@
+package com.ytpm.app.param;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class AppQueryUserTodayTimeParam {
+    private List<String> appIdList;
+}

+ 3 - 0
yt-common/src/main/java/com/ytpm/app/param/AppUserQueryParam.java

@@ -3,6 +3,7 @@ package com.ytpm.app.param;
 import lombok.Data;
 
 import java.util.Date;
+import java.util.List;
 
 @Data
 public class AppUserQueryParam {
@@ -11,4 +12,6 @@ public class AppUserQueryParam {
     private Date endTime;
 
     private Integer status;
+
+    private List<String> appIdList;
 }

+ 3 - 2
yt-risk/risk-feign/src/main/java/com/ytpm/feign/RiskFeign.java

@@ -2,6 +2,7 @@ package com.ytpm.feign;
 
 import com.ytpm.app.model.YtDyzAdRecord;
 import com.ytpm.app.model.YtDyzUser;
+import com.ytpm.app.param.AppQueryUserTodayTimeParam;
 import com.ytpm.app.param.AppUserQueryParam;
 import com.ytpm.feign.fallback.RiskFeignFallBack;
 import com.ytpm.general.Result;
@@ -84,6 +85,6 @@ public interface RiskFeign {
     @PostMapping("/riskManage/queryBanned")
     Result<Map<String, Integer>> queryBanned(@RequestBody AppUserQueryParam appUserQueryParam);
 
-    @GetMapping("/riskManage/queryBannedByHourToday")
-    Result<Map<String, int[]>> queryBannedByHourToday();
+    @PostMapping ("/riskManage/queryBannedByHourToday")
+    Result<Map<String, int[]>> queryBannedByHourToday(@RequestBody AppQueryUserTodayTimeParam appQueryUserTodayTimeParam);
 }

+ 5 - 4
yt-risk/risk-manage/src/main/java/com/ytpm/controller/RiskManageController.java

@@ -5,6 +5,7 @@ import com.ytpm.agent.enums.UserStatusEnum;
 import com.ytpm.agent.model.YtPlatformBanned;
 import com.ytpm.agent.view.AgentUserInfo;
 import com.ytpm.app.model.YtDyzUser;
+import com.ytpm.app.param.AppQueryUserTodayTimeParam;
 import com.ytpm.app.param.AppUserParam;
 import com.ytpm.app.param.AppUserQueryParam;
 import com.ytpm.feign.AppFeign;
@@ -130,7 +131,7 @@ public class RiskManageController {
 //        List<YtPlatformBanned> ytPlatformBanneds =
 //                riskService.queryBannedRecord(appUserQueryParam.getStartTime(), appUserQueryParam.getEndTime());
         List<YtPlatformBanned> bannedList =
-                riskService.queryBannedRecordGroupByUserId(appUserQueryParam.getStartTime(), appUserQueryParam.getEndTime());
+                riskService.queryBannedRecordGroupByUserId(appUserQueryParam.getStartTime(), appUserQueryParam.getEndTime(),appUserQueryParam.getAppIdList());
         if (bannedList!=null || !bannedList.isEmpty()){
             map.put("lock", bannedList.size());
         }
@@ -158,8 +159,8 @@ public class RiskManageController {
     }
 
     @ApiOperation("查询今日每小时的封禁数和封控数(按封禁记录时间)")
-    @GetMapping("/queryBannedByHourToday")
-    public Result<Map<String, int[]>> queryBannedByHourToday() {
+    @PostMapping ("/queryBannedByHourToday")
+    public Result<Map<String, int[]>> queryBannedByHourToday(@RequestBody AppQueryUserTodayTimeParam appQueryUserTodayTimeParam) {
         Map<String, int[]> resultMap = new HashMap<>();
         int[] lockCounts = new int[24];
         int[] riskCounts = new int[24];
@@ -172,7 +173,7 @@ public class RiskManageController {
         Date endTime = Date.from(endOfDay.atZone(ZoneId.systemDefault()).toInstant());
 
         // 查询今天封禁记录(根据封禁时间字段过滤)
-        List<YtPlatformBanned> bannedList = riskService.queryBannedRecord(startTime, endTime);
+        List<YtPlatformBanned> bannedList = riskService.queryBannedRecord(startTime, endTime,appQueryUserTodayTimeParam.getAppIdList());
 
         if (CollUtil.isNotEmpty(bannedList)) {
             for (YtPlatformBanned banned : bannedList) {

+ 2 - 2
yt-risk/risk-manage/src/main/java/com/ytpm/dao/RiskManageMapper.java

@@ -45,7 +45,7 @@ public interface RiskManageMapper {
      */
     void deleteRelatives(@Param("templateId") String templateId);
 
-    List<YtPlatformBanned> queryBannedRecord(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
+    List<YtPlatformBanned> queryBannedRecord(@Param("startTime") Date startTime, @Param("endTime") Date endTime,@Param("appIdList")List<String> appList);
 
-    List<YtPlatformBanned> queryBannedRecordGroupByUserId(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
+    List<YtPlatformBanned> queryBannedRecordGroupByUserId(@Param("startTime") Date startTime, @Param("endTime") Date endTime,@Param("appIdList")List<String> appList);
 }

+ 2 - 2
yt-risk/risk-manage/src/main/java/com/ytpm/service/RiskService.java

@@ -101,7 +101,7 @@ public interface RiskService {
      */
     Result<?> checkAdRisk(YtDyzUser dyzUser);
 
-    List<YtPlatformBanned> queryBannedRecord(Date startTime,Date endTime);
+    List<YtPlatformBanned> queryBannedRecord(Date startTime,Date endTime,List<String> appIdList);
 
-    List<YtPlatformBanned> queryBannedRecordGroupByUserId(Date startTime,Date endTime);
+    List<YtPlatformBanned> queryBannedRecordGroupByUserId(Date startTime,Date endTime,List<String> appIdList);
 }

+ 4 - 4
yt-risk/risk-manage/src/main/java/com/ytpm/service/impl/RiskServiceImpl.java

@@ -830,13 +830,13 @@ public class RiskServiceImpl extends ReflectUtil implements RiskService {
     }
 
     @Override
-    public List<YtPlatformBanned> queryBannedRecord(Date startTime, Date endTime) {
-        return riskManageMapper.queryBannedRecord(startTime, endTime);
+    public List<YtPlatformBanned> queryBannedRecord(Date startTime, Date endTime,List<String> appIdList) {
+        return riskManageMapper.queryBannedRecord(startTime, endTime,appIdList);
     }
 
     @Override
-    public List<YtPlatformBanned> queryBannedRecordGroupByUserId(Date startTime, Date endTime) {
-        List<YtPlatformBanned> bannedList = riskManageMapper.queryBannedRecordGroupByUserId(startTime, endTime);
+    public List<YtPlatformBanned> queryBannedRecordGroupByUserId(Date startTime, Date endTime,List<String> appIdList) {
+        List<YtPlatformBanned> bannedList = riskManageMapper.queryBannedRecordGroupByUserId(startTime, endTime,appIdList);
         return bannedList;
     }
 }

+ 28 - 0
yt-risk/risk-manage/src/main/resources/mapper/RiskManageMapper.xml

@@ -152,6 +152,21 @@
             <if test="endTime != null">
                 AND banned_time &lt;= #{endTime}
             </if>
+
+            <choose>
+                <when test="appIdList == null or appIdList.isEmpty()">
+                    <!-- 为空直接查询不到数据 -->
+                    AND 1 = 0
+                </when>
+                <otherwise>
+                    AND app_id IN
+                    <foreach collection="appIdList" item="item"
+                             open="(" close=")" separator=",">
+                        #{item}
+                    </foreach>
+                </otherwise>
+            </choose>
+
         </where>
     </select>
 
@@ -167,6 +182,19 @@
             <if test="endTime != null">
                 AND banned_time &lt;= #{endTime}
             </if>
+            <choose>
+                <when test="appIdList == null or appIdList.isEmpty()">
+                    <!-- 为空直接查询不到数据 -->
+                    AND 1 = 0
+                </when>
+                <otherwise>
+                    AND app_id IN
+                    <foreach collection="appIdList" item="item"
+                             open="(" close=")" separator=",">
+                        #{item}
+                    </foreach>
+                </otherwise>
+            </choose>
         </where>
         group by user_id
     </select>