|
@@ -2,6 +2,7 @@ package com.huimv.farm.musk.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -9,6 +10,7 @@ import com.huimv.farm.musk.common.utils.Result;
|
|
import com.huimv.farm.musk.common.utils.ResultCode;
|
|
import com.huimv.farm.musk.common.utils.ResultCode;
|
|
import com.huimv.farm.musk.entity.SysAccountMultilevel;
|
|
import com.huimv.farm.musk.entity.SysAccountMultilevel;
|
|
import com.huimv.farm.musk.entity.SysCamera;
|
|
import com.huimv.farm.musk.entity.SysCamera;
|
|
|
|
+import com.huimv.farm.musk.entity.SysCameraArea;
|
|
import com.huimv.farm.musk.entity.SysCameraBrand;
|
|
import com.huimv.farm.musk.entity.SysCameraBrand;
|
|
import com.huimv.farm.musk.entity.vo.*;
|
|
import com.huimv.farm.musk.entity.vo.*;
|
|
import com.huimv.farm.musk.mapper.SysAccountMultilevelMapper;
|
|
import com.huimv.farm.musk.mapper.SysAccountMultilevelMapper;
|
|
@@ -19,9 +21,7 @@ import com.huimv.farm.musk.service.ISysCameraService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.Arrays;
|
|
|
|
-import java.util.List;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
@@ -43,6 +43,9 @@ public class SysCameraServiceImpl extends ServiceImpl<SysCameraMapper, SysCamera
|
|
@Autowired
|
|
@Autowired
|
|
private SysCameraBrandMapper cameraBrandMapper;
|
|
private SysCameraBrandMapper cameraBrandMapper;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private SysCameraMapper cameraMapper;
|
|
|
|
+
|
|
// @Autowired
|
|
// @Autowired
|
|
// private BaseScreenCameraAccountMapper cameraAccountMapper;
|
|
// private BaseScreenCameraAccountMapper cameraAccountMapper;
|
|
|
|
|
|
@@ -216,55 +219,32 @@ public class SysCameraServiceImpl extends ServiceImpl<SysCameraMapper, SysCamera
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Result listApp(CameraListVo cameraListVo, Integer userId) {
|
|
public Result listApp(CameraListVo cameraListVo, Integer userId) {
|
|
- Integer current = cameraListVo.getCurrent();
|
|
|
|
- String strchStr = cameraListVo.getStrchStr();
|
|
|
|
- Integer size = cameraListVo.getSize();
|
|
|
|
- Integer areaId = cameraListVo.getAreaId();
|
|
|
|
- Integer brandId = cameraListVo.getBrandId();
|
|
|
|
- Integer sort = cameraListVo.getSort();
|
|
|
|
- Integer farmId = cameraListVo.getFarmId();
|
|
|
|
- Integer isOnline = cameraListVo.getIsOnline();
|
|
|
|
-
|
|
|
|
- QueryWrapper<SysCamera> wrapper = new QueryWrapper<>();
|
|
|
|
- if (StringUtils.isNotBlank(strchStr)) {
|
|
|
|
- wrapper.and(i -> i.like("camera_name", strchStr)
|
|
|
|
- .or().like("camera_ip", strchStr));
|
|
|
|
- }
|
|
|
|
|
|
+ List endList = new ArrayList();
|
|
|
|
+ List<SysCameraArea> cameraAreaList = cameraAreaMapper.selectList(new QueryWrapper<SysCameraArea>().eq("farm_id", cameraListVo.getFarmId()).eq("run_status",1).orderByAsc("sort"));
|
|
|
|
+ SysAccountMultilevel sysAccountMultilevel = sysAccountMultilevelMapper.selectById(userId);
|
|
if (userId != 1){
|
|
if (userId != 1){
|
|
- SysAccountMultilevel sysAccountMultilevel = sysAccountMultilevelMapper.selectById(userId);
|
|
|
|
- String cameraIds = sysAccountMultilevel.getCameraIds();
|
|
|
|
- List<String> list = new ArrayList();
|
|
|
|
- if (StringUtils.isNotBlank(cameraIds)){
|
|
|
|
- list = Arrays.asList(cameraIds);
|
|
|
|
|
|
+ for (SysCameraArea cameraArea : cameraAreaList) {
|
|
|
|
+ List<SysCamera> sysCameras = cameraMapper.selectList(new QueryWrapper<SysCamera>().eq("area_id", cameraArea.getId()).eq("run_status", 1).in("id", Arrays.asList(sysAccountMultilevel.getCameraIds())).orderByAsc("sort"));
|
|
|
|
+ if(ObjectUtils.isNotEmpty(sysCameras)){
|
|
|
|
+ Map map = new HashMap();
|
|
|
|
+ map.put("cameraName", cameraArea.getAreaName());
|
|
|
|
+ map.put("id", cameraArea.getId());
|
|
|
|
+ map.put("cameraList",sysCameras );
|
|
|
|
+ endList.add(map);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- wrapper.in("id",list);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (farmId != null) {
|
|
|
|
- wrapper.eq("farm_id", farmId);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (areaId != null) {
|
|
|
|
- wrapper.eq("area_id", areaId);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (brandId != null) {
|
|
|
|
- wrapper.eq("brand_id", brandId);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (isOnline != null) {
|
|
|
|
- wrapper.eq("is_online", isOnline);
|
|
|
|
|
|
+ return new Result(ResultCode.SUCCESS, endList);
|
|
|
|
+ }else {
|
|
|
|
+ for (SysCameraArea cameraArea : cameraAreaList) {
|
|
|
|
+ Map map = new HashMap();
|
|
|
|
+ map.put("cameraName", cameraArea.getAreaName());
|
|
|
|
+ map.put("id", cameraArea.getId());
|
|
|
|
+ map.put("cameraList", cameraMapper.selectList(new QueryWrapper<SysCamera>().eq("area_id", cameraArea.getId()).eq("run_status",1).orderByAsc("sort")));
|
|
|
|
+ endList.add(map);
|
|
|
|
+ }
|
|
|
|
+ return new Result(ResultCode.SUCCESS, endList);
|
|
}
|
|
}
|
|
|
|
|
|
- if (sort == null) {
|
|
|
|
- wrapper.orderByDesc("id");
|
|
|
|
- } else if (sort == 1) {
|
|
|
|
- wrapper.orderByDesc("sort");
|
|
|
|
- } else {
|
|
|
|
- wrapper.orderByAsc("sort");
|
|
|
|
- }
|
|
|
|
-// wrapper.orderByDesc("id");
|
|
|
|
- return new Result(ResultCode.SUCCESS, page(new Page<>(current, size), wrapper));
|
|
|
|
}
|
|
}
|
|
|
|
|
|
// @Override
|
|
// @Override
|