lyhzzz 8 달 전
부모
커밋
0ce03823fc

+ 10 - 1
src/main/java/com/fdkankan/agent/controller/CameraController.java

@@ -2,7 +2,9 @@ package com.fdkankan.agent.controller;
 
 
 import com.alibaba.nacos.common.codec.Base64;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fdkankan.agent.common.BaseController;
+import com.fdkankan.agent.common.PageInfo;
 import com.fdkankan.agent.common.ResultCode;
 import com.fdkankan.agent.common.ResultData;
 import com.fdkankan.agent.common.util.JwtUtil;
@@ -55,7 +57,14 @@ public class CameraController extends BaseController {
     @PostMapping("/list")
     public ResultData list(@RequestBody CameraParam param){
         param.setAgentId(getAgent().getId());
-        param.setAgentNew(getAgent());
+        if(getAgent().getParentId() != null) {
+            List<Long> cameraIds = agentNewCameraService.getBySubAgent(getAgent().getId());
+            if(cameraIds.isEmpty()){
+                return ResultData.ok(PageInfo.PageInfo(new Page<>(param.getPageNum(),param.getPageSize())));
+            }
+            param.setAuthCameraIds(cameraIds);
+        }
+
         return ResultData.ok(cameraService.pageList(param));
     }
 

+ 5 - 0
src/main/java/com/fdkankan/agent/controller/CameraIncrementLogController.java

@@ -1,7 +1,9 @@
 package com.fdkankan.agent.controller;
 
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fdkankan.agent.common.BaseController;
+import com.fdkankan.agent.common.PageInfo;
 import com.fdkankan.agent.common.ResultData;
 import com.fdkankan.agent.entity.CameraIncrementLog;
 import com.fdkankan.agent.request.CameraIncrementParam;
@@ -34,6 +36,9 @@ public class CameraIncrementLogController extends BaseController {
         param.setAgentId(getAgent().getId());
         if(getAgent().getParentId() != null) {
             List<Long> cameraIds = agentNewCameraService.getBySubAgent(getAgent().getId());
+            if(cameraIds.isEmpty()){
+                return ResultData.ok(PageInfo.PageInfo(new Page<>(param.getPageNum(),param.getPageSize())));
+            }
             param.setAuthCameraIds(cameraIds);
         }
         return ResultData.ok(cameraIncrementLogService.pageList(param));

+ 2 - 0
src/main/java/com/fdkankan/agent/request/CameraParam.java

@@ -27,5 +27,7 @@ public class CameraParam extends RequestBase {
     private Integer subAgentId;
     private AgentNew agentNew;
 
+    private List<Long> authCameraIds;
+
 
 }

+ 4 - 38
src/main/java/com/fdkankan/agent/service/impl/CameraServiceImpl.java

@@ -41,37 +41,9 @@ public class CameraServiceImpl extends ServiceImpl<ICameraMapper, Camera> implem
 
     @Override
     public Object pageList(CameraParam param) {
-        if(param.getAgentNew().getParentId() != null){ //分销商
-            AgentNew agentNew = agentNewService.getById(param.getAgentNew().getParentId());
-            param.setSubAgentId(param.getAgentId());
-            param.setAgentId(agentNew.getId());
-        }
-        if(param.getIncrementStatus() != null){
-            List<Long> cameraIds = userIncrementService.getByAgentId(param);
-            param.setCameraIds(cameraIds);
-        }
-        if(param.getIncrementTypeId() != null){
-            List<Long> cameraIds = userIncrementService.getByAgentId(param);
-            param.setCameraIds(cameraIds);
-        }
-        if(param.getCameraIds() != null && param.getCameraIds().isEmpty()){
+        if(param.getAuthCameraIds() != null && param.getAuthCameraIds().isEmpty()){
             return PageInfo.PageInfo(new Page(param.getPageNum(),param.getPageSize()));
         }
-        if(param.getSubAgentId() != null){ //指定分销商查询
-            List<Long> subCameraIds = agentNewCameraService.getBySubAgent(param.getSubAgentId());
-            if(subCameraIds.isEmpty()){
-                return PageInfo.PageInfo(new Page(param.getPageNum(),param.getPageSize()));
-            }
-            if(param.getCameraIds() != null && !param.getCameraIds().isEmpty()){
-                List<Long> newCameraIds = param.getCameraIds().stream().filter(subCameraIds::contains).collect(Collectors.toList());
-                if(newCameraIds.isEmpty()){
-                    return PageInfo.PageInfo(new Page(param.getPageNum(),param.getPageSize()));
-                }
-                param.setCameraIds(newCameraIds);
-            }else {
-                param.setCameraIds(subCameraIds);
-            }
-        }
 
         Page<CameraDetailVo> voPage = this.getBaseMapper().pageList(new Page<>(param.getPageNum(),param.getPageSize()),param);
         List<Long> cameraIds = voPage.getRecords().stream().map(CameraDetailVo::getId).collect(Collectors.toList());
@@ -87,15 +59,9 @@ public class CameraServiceImpl extends ServiceImpl<ICameraMapper, Camera> implem
         HashMap<Integer,AgentNew> agentMap = agentNewService.getMapByIds(subAgentIds);
 
         for (CameraDetailVo record : voPage.getRecords()) {
-            UserIncrement userIncrement = userIncrementHashMap.get(record.getId());
-            if(userIncrement != null){
-                record.setIncrementStatus(userIncrement.getIsExpired());
-                record.setIncrementTypeId(userIncrement.getIncrementTypeId());
-                record.setIncrementEndTime(userIncrement.getIncrementEndTime());
-                IncrementType incrementType = typeMap.get(userIncrement.getIncrementTypeId());
-                if(incrementType != null){
-                    record.setValidTimeType(incrementType.getValidTimeType());
-                }
+            IncrementType incrementType = typeMap.get(record.getIncrementTypeId());
+            if(incrementType != null){
+                record.setValidTimeType(incrementType.getValidTimeType());
             }
             AgentNewCamera agentNewCamera = map.get(record.getId());
             if(agentNewCamera != null && agentNewCamera.getAgentId().equals( param.getAgentNew().getId())){

+ 1 - 1
src/main/resources/mapper/agent/AgentNewLogMapper.xml

@@ -23,7 +23,7 @@
     </select>
 
     <select id="pageUnList" resultType="com.fdkankan.agent.response.LogListVo">
-        select  l.*,u.nick_name,u.user_name,u.email,u.create_time as userCreateTime ,a.agent_name  from t_agent_new_log l
+        select  l.*,u.nick_name,u.user_name,u.email,u.create_time as userCreateTime ,a.agent_name as agentName  from t_agent_new_log l
             left join  t_agent a on l.agent_id = a.id
             left join  t_user u on l.user_id = u.id
         where l.agent_id in

+ 19 - 6
src/main/resources/mapper/agent/CameraMapper.xml

@@ -2,14 +2,15 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.fdkankan.agent.mapper.ICameraMapper">
 
+
     <select id="pageList" resultType="com.fdkankan.agent.response.CameraDetailVo">
         select c.id ,c.sn_code,c.activated_time ,d.create_time as outTime ,d.type,d.own as outType  ,u.user_name, c.wifi_name,
-        d.order_sn
+        d.order_sn,ui.is_expired as incrementStatus,ui.increment_type_id ,ui.increment_end_time
         from t_camera c
         left join t_camera_detail d on c.id = d.camera_id
         left join t_user u on d.user_id = u.id
+        left join t_user_increment ui on d.camera_id = ui.camera_id
         where c.rec_status = 'A'
-        and d.agent_id = #{param.agentId}
         <if test="param.userId !=null ">
             and d.user_id = #{param.userId}
         </if>
@@ -29,11 +30,23 @@
         <if test="param.bindStatus !=null and param.bindStatus == 1">
             and d.user_id is not null
         </if>
-        <if test="param.cameraIds != null">
-            and d.camera_id in
-            <foreach collection="param.cameraIds" item="cameraId" open="(" separator="," close=")">
-                #{cameraId}
+
+        <if test="param.incrementStatus !=null ">
+            and ui.is_expired = #{param.incrementStatus}
+        </if>
+        <if test="param.incrementTypeId !=null ">
+            and ui.increment_type_id = #{param.incrementTypeId}
+        </if>
+
+        <if test="param.agentId != null and ( param.authCameraIds == null or param.authCameraIds.size &lt; 0 )">
+            and d.agent_id = #{param.agentId}
+        </if>
+        <if test="param.authCameraIds != null and param.authCameraIds.size >0">
+            and (d.agent_id = #{param.agentId} or d.camera_id in
+            <foreach collection="param.authCameraIds"  item="cameraIds" open="(" separator="," close=")">
+                #{cameraIds}
             </foreach>
+            )
         </if>
 
         order by d.out_time desc,d.id desc