lyhzzz 4 月之前
父節點
當前提交
d64c25baab

+ 1 - 1
src/main/java/com/fdkankan/agent/mapper/ICameraDetailMapper.java

@@ -19,5 +19,5 @@ import java.util.List;
 @Mapper
 public interface ICameraDetailMapper extends BaseMapper<CameraDetail> {
 
-    List<GroupByCount> getCountGroupByUserId(@Param("userIdList") List<Long> userIdList);
+    List<GroupByCount> getCountGroupByUserId(@Param("userIdList") List<Long> userIdList,@Param("agentId")Integer agentId);
 }

+ 1 - 1
src/main/java/com/fdkankan/agent/mapper/IScenePlusMapper.java

@@ -20,7 +20,7 @@ import java.util.List;
 @Mapper
 public interface IScenePlusMapper extends BaseMapper<ScenePlus> {
 
-    List<GroupByCount> getCountGroupByUserId(@Param("userIdList") List<Long> userIdList);
+    List<GroupByCount> getCountGroupByUserId(@Param("userIdList") List<Long> userIdList,@Param("agentId")Integer agentId);
 
     List<CameraTimeVo> getMinCreateTimeGroupByCameraId(@Param("cameraIds") List<Long> voCameraIds);
 }

+ 1 - 1
src/main/java/com/fdkankan/agent/mapper/ISceneProMapper.java

@@ -24,5 +24,5 @@ public interface ISceneProMapper extends BaseMapper<ScenePro> {
 
     Page<SceneVo> pageList(Page<SceneVo> page, SceneParam param);
 
-    List<GroupByCount> getCountGroupByUserId(@Param("userIdList") List<Long> userIdLis);
+    List<GroupByCount> getCountGroupByUserId(@Param("userIdList") List<Long> userIdLis,@Param("agentId") Integer agentId);
 }

+ 1 - 1
src/main/java/com/fdkankan/agent/service/ICameraDetailService.java

@@ -26,5 +26,5 @@ public interface ICameraDetailService extends IService<CameraDetail> {
 
     List<CameraDetail> getByCameraIds(List<Long> cameraIds);
 
-    HashMap<Long, Long> getCountGroupByUserId(List<Long> userIdList);
+    HashMap<Long, Long> getCountGroupByUserId(List<Long> userIdList,Integer agentId);
 }

+ 1 - 1
src/main/java/com/fdkankan/agent/service/IScenePlusService.java

@@ -21,7 +21,7 @@ public interface IScenePlusService extends IService<ScenePlus> {
 
     Long getCountByCameraId(Long cameraId);
 
-    HashMap<Long, Long> getCountGroupByUserId(List<Long> userIdList);
+    HashMap<Long, Long> getCountGroupByUserId(List<Long> userIdList,Integer agentId);
 
     List<CameraTimeVo> getMinCreateTimeGroupByCameraId(List<Long> voCameraIds);
 

+ 1 - 1
src/main/java/com/fdkankan/agent/service/ISceneProService.java

@@ -26,5 +26,5 @@ public interface ISceneProService extends IService<ScenePro> {
 
     Long getCountByCameraId(Long cameraId);
 
-    HashMap<Long, Long> getCountGroupByUserId(List<Long> userIdList);
+    HashMap<Long, Long> getCountGroupByUserId(List<Long> userIdList,Integer agentId);
 }

+ 2 - 2
src/main/java/com/fdkankan/agent/service/impl/CameraDetailServiceImpl.java

@@ -124,9 +124,9 @@ public class CameraDetailServiceImpl extends ServiceImpl<ICameraDetailMapper, Ca
     }
 
     @Override
-    public HashMap<Long, Long> getCountGroupByUserId(List<Long> userIdList) {
+    public HashMap<Long, Long> getCountGroupByUserId(List<Long> userIdList,Integer agentId) {
         HashMap<Long,Long> map = new HashMap<>();
-        List<GroupByCount> result = this.getBaseMapper().getCountGroupByUserId(userIdList);
+        List<GroupByCount> result = this.getBaseMapper().getCountGroupByUserId(userIdList,agentId);
         result.forEach(entity ->map.put(entity.getId(),entity.getCount()));
         return map;
     }

+ 2 - 2
src/main/java/com/fdkankan/agent/service/impl/ScenePlusServiceImpl.java

@@ -45,9 +45,9 @@ public class ScenePlusServiceImpl extends ServiceImpl<IScenePlusMapper, ScenePlu
     }
 
     @Override
-    public HashMap<Long, Long> getCountGroupByUserId(List<Long> userIdList) {
+    public HashMap<Long, Long> getCountGroupByUserId(List<Long> userIdList,Integer agentId) {
         HashMap<Long,Long> map = new HashMap<>();
-        List<GroupByCount> result = this.getBaseMapper().getCountGroupByUserId(userIdList);
+        List<GroupByCount> result = this.getBaseMapper().getCountGroupByUserId(userIdList,agentId);
         result.forEach(entity ->map.put(entity.getId(),entity.getCount()));
         return map;
     }

+ 2 - 2
src/main/java/com/fdkankan/agent/service/impl/SceneProServiceImpl.java

@@ -255,9 +255,9 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
 
 
     @Override
-    public HashMap<Long, Long> getCountGroupByUserId(List<Long> userIdList) {
+    public HashMap<Long, Long> getCountGroupByUserId(List<Long> userIdList,Integer agentId) {
         HashMap<Long,Long> map = new HashMap<>();
-        List<GroupByCount> result = this.getBaseMapper().getCountGroupByUserId(userIdList);
+        List<GroupByCount> result = this.getBaseMapper().getCountGroupByUserId(userIdList,agentId);
         result.forEach(entity ->map.put(entity.getId(),entity.getCount()));
         return map;
     }

+ 5 - 5
src/main/java/com/fdkankan/agent/service/impl/UserServiceImpl.java

@@ -84,23 +84,23 @@ public class UserServiceImpl extends ServiceImpl<IUserMapper, User> implements I
     public PageInfo pageList(UserParam param) {
         Page<User> page =  this.getBaseMapper().pageList(new Page<>(param.getPageNum(), param.getPageSize()), param);
         List<User> records = page.getRecords();
-        List<UserVo> userVo = getUserVo(records);
+        List<UserVo> userVo = getUserVo(records,param.getAgentId());
         Page<UserVo> pageVo = new Page<>(page.getCurrent(),page.getSize());
         pageVo.setTotal(page.getTotal());
         pageVo.setRecords(userVo);
         return PageInfo.PageInfo(pageVo);
     }
 
-    private List<UserVo> getUserVo(List<User> userList){
+    private List<UserVo> getUserVo(List<User> userList,Integer agentId){
         List<UserVo> voList = new ArrayList<>();
         if(userList.size() >0){
             List<Long> userIdList = userList.parallelStream().map(User::getId).collect(Collectors.toList());
 
             HashMap<Long,Long> incrementCountMap = userIncrementService.getValidCountGroupByUserId(userIdList);
-            HashMap<Long,Long> cameraCountMap = cameraDetailService.getCountGroupByUserId(userIdList);
+            HashMap<Long,Long> cameraCountMap = cameraDetailService.getCountGroupByUserId(userIdList,agentId);
             HashMap<Long,Long> sceneCountMap = sceneService.getCountGroupByUserId(userIdList);
-            HashMap<Long,Long> sceneProCountMap = sceneProService.getCountGroupByUserId(userIdList);
-            HashMap<Long,Long> scenePlusCountMap = scenePlusService.getCountGroupByUserId(userIdList);
+            HashMap<Long,Long> sceneProCountMap = sceneProService.getCountGroupByUserId(userIdList,agentId);
+            HashMap<Long,Long> scenePlusCountMap = scenePlusService.getCountGroupByUserId(userIdList,agentId);
 
             for (User user :userList) {
                 long incrementCount = incrementCountMap.get(user.getId()) == null ? 0 : incrementCountMap.get(user.getId());

+ 7 - 1
src/main/resources/mapper/agent/CameraDetailMapper.xml

@@ -3,10 +3,16 @@
 <mapper namespace="com.fdkankan.agent.mapper.ICameraDetailMapper">
 
     <select id="getCountGroupByUserId" resultType="com.fdkankan.agent.response.GroupByCount">
-        SELECT user_id as id, count(id) as count FROM t_camera_detail  WHERE rec_status = 'A'   and agent_id is not null and user_id in
+        SELECT user_id as id, count(id) as count FROM t_camera_detail  WHERE rec_status = 'A'    and user_id in
         <foreach item="userId" collection="userIdList" open="(" separator="," close=")">
             #{userId}
         </foreach>
+        <if test="agentId != null">
+            and agent_id = #{agentId}
+        </if>
+        <if test="agentId == null">
+            and agent_id is not null
+        </if>
         GROUP BY user_id
     </select>
 </mapper>

+ 7 - 1
src/main/resources/mapper/agent/ScenePlusMapper.xml

@@ -4,10 +4,16 @@
 
     <select id="getCountGroupByUserId" resultType="com.fdkankan.agent.response.GroupByCount">
         SELECT p.user_id as id, count(p.id) as count FROM t_scene_plus p left join t_camera_detail d on p.camera_id = d.camera_id
-        WHERE  p.rec_status = 'A' and agent_id is not null and  p.user_id in
+        WHERE  p.rec_status = 'A'  and  p.user_id in
         <foreach item="userId" collection="userIdList" open="(" separator="," close=")">
             #{userId}
         </foreach>
+        <if test="agentId != null">
+            and agent_id = #{agentId}
+        </if>
+        <if test="agentId == null">
+            and agent_id is not null
+        </if>
         GROUP BY p.user_id
     </select>
     <select id="getMinCreateTimeGroupByCameraId" resultType="com.fdkankan.agent.response.CameraTimeVo">

+ 7 - 1
src/main/resources/mapper/agent/SceneProMapper.xml

@@ -30,11 +30,17 @@
 
     <select id="getCountGroupByUserId" resultType="com.fdkankan.agent.response.GroupByCount">
         SELECT p.user_id as id, count(p.id) as count FROM t_scene_pro p left join t_camera_detail d on p.camera_id = d.camera_id
-                                                 WHERE  p.rec_status = 'A' and is_upgrade = 0 and agent_id is not null
+                                                 WHERE  p.rec_status = 'A' and is_upgrade = 0
         and  p.user_id in
         <foreach item="userId" collection="userIdList" open="(" separator="," close=")">
             #{userId}
         </foreach>
+        <if test="agentId != null">
+            and agent_id = #{agentId}
+        </if>
+        <if test="agentId == null">
+            and agent_id is not null
+        </if>
         GROUP BY p.user_id
     </select>