lyhzzz 8 mesiacov pred
rodič
commit
227e18ff9e

+ 9 - 1
src/main/java/com/fdkankan/agent/controller/CameraIncrementLogController.java

@@ -5,10 +5,13 @@ import com.fdkankan.agent.common.BaseController;
 import com.fdkankan.agent.common.ResultData;
 import com.fdkankan.agent.entity.CameraIncrementLog;
 import com.fdkankan.agent.request.CameraIncrementParam;
+import com.fdkankan.agent.service.IAgentNewCameraService;
 import com.fdkankan.agent.service.ICameraIncrementLogService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.List;
+
 /**
  * <p>
  *  前端控制器
@@ -23,11 +26,16 @@ public class CameraIncrementLogController extends BaseController {
 
     @Autowired
     private ICameraIncrementLogService cameraIncrementLogService;
-
+    @Autowired
+    IAgentNewCameraService agentNewCameraService;
 
     @PostMapping("/list")
     public ResultData list(@RequestBody CameraIncrementParam param){
         param.setAgentId(getAgent().getId());
+        if(getAgent().getParentId() != null) {
+            List<Long> cameraIds = agentNewCameraService.getBySubAgent(getAgent().getId());
+            param.setAuthCameraIds(cameraIds);
+        }
         return ResultData.ok(cameraIncrementLogService.pageList(param));
     }
 }

+ 1 - 0
src/main/java/com/fdkankan/agent/request/CameraIncrementParam.java

@@ -14,6 +14,7 @@ public class CameraIncrementParam extends RequestBase {
     private String operationUserName;
     private Integer agentId;
     private List<String> timeList;
+    private List<Long> authCameraIds;
 
     private String startTime;
     private String endTime;

+ 1 - 0
src/main/java/com/fdkankan/agent/service/impl/CameraIncrementLogServiceImpl.java

@@ -36,6 +36,7 @@ public class CameraIncrementLogServiceImpl extends ServiceImpl<ICameraIncrementL
 
     @Override
     public Object pageList(CameraIncrementParam param) {
+
         Page<CameraIncrementVo> page = this.getBaseMapper().pageList(new Page<>(param.getPageNum(),param.getPageSize()),param);
         return PageInfo.PageInfo(page);
     }

+ 34 - 19
src/main/resources/mapper/agent/CameraIncrementLogMapper.xml

@@ -10,25 +10,40 @@
             left join t_user_increment ui on cil.increment_id = ui.id
             left join t_user u on cil.operation_user = u.id
             left join t_increment_type uit on ui.increment_type_id = uit.id
-        where cil.rec_status = 'A' and d.agent_id = #{param.agentId}
-            <if test="param.snCode != null and param.snCode !=''">
-                and c.sn_code like concat ('%',#{param.snCode},'%')
-            </if>
-            <if test="param.operationType != null">
-                and cil.operation_type  = #{param.operationType}
-            </if>
-            <if test="param.incrementTypeId != null">
-                and ui.increment_type_id  = #{param.incrementTypeId}
-            </if>
-            <if test="param.operationUserName != null and param.operationUserName !=''">
-                and u.user_name like concat ('%',#{param.operationUserName},'%')
-            </if>
-            <if test="param.operationUserName != null and param.operationUserName !=''">
-                and u.user_name like concat ('%',#{param.operationUserName},'%')
-            </if>
-            <if test="param.startTime!= null and param.startTime != ''">
-                  and cil.create_time BETWEEN #{param.startTime} and #{param.endTime}
-            </if>
+            where cil.rec_status = 'A'
+            <include refid="commonSql"></include>
+
             order by cil.create_time desc
     </select>
+
+    <sql id="commonSql">
+        <if test="param.agentId != null and ( param.authCameraIds == null and 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>
+        <if test="param.snCode != null and param.snCode !=''">
+            and c.sn_code like concat ('%',#{param.snCode},'%')
+        </if>
+        <if test="param.operationType != null">
+            and cil.operation_type  = #{param.operationType}
+        </if>
+        <if test="param.incrementTypeId != null">
+            and ui.increment_type_id  = #{param.incrementTypeId}
+        </if>
+        <if test="param.operationUserName != null and param.operationUserName !=''">
+            and u.user_name like concat ('%',#{param.operationUserName},'%')
+        </if>
+        <if test="param.operationUserName != null and param.operationUserName !=''">
+            and u.user_name like concat ('%',#{param.operationUserName},'%')
+        </if>
+        <if test="param.startTime!= null and param.startTime != ''">
+            and cil.create_time BETWEEN #{param.startTime} and #{param.endTime}
+        </if>
+    </sql>
 </mapper>