|
@@ -1,17 +1,27 @@
|
|
package com.huimv.video.service.impl;
|
|
package com.huimv.video.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.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;
|
|
import com.huimv.video.entity.Camera;
|
|
import com.huimv.video.entity.Camera;
|
|
|
|
+import com.huimv.video.entity.CameraBrand;
|
|
|
|
+import com.huimv.video.entity.vo.CameraListVo;
|
|
|
|
+import com.huimv.video.entity.vo.CameraListsVo;
|
|
|
|
+import com.huimv.video.entity.vo.CameraVo;
|
|
|
|
+import com.huimv.video.mapper.CameraAreaMapper;
|
|
|
|
+import com.huimv.video.mapper.CameraBrandMapper;
|
|
import com.huimv.video.mapper.CameraMapper;
|
|
import com.huimv.video.mapper.CameraMapper;
|
|
|
|
+import com.huimv.video.mapper.PublicNetworkMapper;
|
|
import com.huimv.video.service.ICameraService;
|
|
import com.huimv.video.service.ICameraService;
|
|
-import com.huimv.admin.utils.Result;
|
|
|
|
-import com.huimv.admin.utils.ResultCode;
|
|
|
|
|
|
+import com.huimv.common.utils.Result;
|
|
|
|
+import com.huimv.common.utils.ResultCode;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
@@ -24,19 +34,170 @@ import java.util.Map;
|
|
@Service
|
|
@Service
|
|
public class CameraServiceImpl extends ServiceImpl<CameraMapper, Camera> implements ICameraService {
|
|
public class CameraServiceImpl extends ServiceImpl<CameraMapper, Camera> implements ICameraService {
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private PublicNetworkMapper publicNetworkMapper;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private CameraBrandMapper cameraBrandMapper;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private CameraAreaMapper cameraAreaMapper;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
- public Result listPage(Map<String, Object> params) {
|
|
|
|
- Long current = (Long)params.get("current");
|
|
|
|
- Long size = (Long) params.get("size");
|
|
|
|
- String strchStr = (String) params.get("strchStr");
|
|
|
|
|
|
+ public Result listPage(CameraListVo cameraListVo) {
|
|
|
|
+ Integer current = cameraListVo.getCurrent();
|
|
|
|
+ String strchStr = cameraListVo.getStrchStr();
|
|
|
|
+ Integer size = cameraListVo.getSize();
|
|
|
|
+ Integer areaId = cameraListVo.getAreaId();
|
|
|
|
+ Integer brandId = cameraListVo.getBrandId();
|
|
|
|
+ Integer sort = cameraListVo.getSort();
|
|
|
|
+
|
|
QueryWrapper<Camera> wrapper = new QueryWrapper<>();
|
|
QueryWrapper<Camera> wrapper = new QueryWrapper<>();
|
|
|
|
+ if (areaId!=null){
|
|
|
|
+ wrapper.eq("area_id",areaId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(brandId != null ){
|
|
|
|
+ wrapper.eq("brand_id",brandId);
|
|
|
|
+ }
|
|
if (StringUtils.isNotEmpty(strchStr)){
|
|
if (StringUtils.isNotEmpty(strchStr)){
|
|
- wrapper.like("area_name",strchStr)
|
|
|
|
- .or().like("camera_name",strchStr)
|
|
|
|
- .or().like("area_name",strchStr);
|
|
|
|
|
|
+ wrapper.like("camera_name",strchStr)
|
|
|
|
+ .or().like("camera_ip",strchStr);
|
|
|
|
+ }
|
|
|
|
+ if (sort == null){
|
|
|
|
+ wrapper.orderByDesc("id");
|
|
|
|
+ }else if (sort == 1){
|
|
|
|
+ wrapper.orderByDesc("sort");
|
|
|
|
+ }else {
|
|
|
|
+ wrapper.orderByAsc("sort");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
return new Result(ResultCode.SUCCESS,page(new Page<>(current, size), wrapper));
|
|
return new Result(ResultCode.SUCCESS,page(new Page<>(current, size), wrapper));
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List getCameraDetails(CameraListsVo cameraListsVo) {
|
|
|
|
+ List<Integer> cameraIds = cameraListsVo.getCameraIds();
|
|
|
|
+ CameraListVo cameraListVo = new CameraListsVo();
|
|
|
|
+ cameraListVo.setCurrent(1);
|
|
|
|
+ cameraListVo.setSize(10000);
|
|
|
|
+ cameraListVo.setStrchStr(cameraListsVo.getStrchStr());
|
|
|
|
+ cameraListVo.setAreaId(cameraListsVo.getAreaId());
|
|
|
|
+ cameraListVo.setBrandId(cameraListsVo.getBrandId());
|
|
|
|
+ cameraListVo.setSort(cameraListsVo.getSort());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (cameraIds == null || cameraIds.size() == 0){
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ List cameraDetailsList = new ArrayList();
|
|
|
|
+ IPage<Camera> page = (IPage<Camera>)this.listPage(cameraListVo).getData();
|
|
|
|
+ List<Camera> list = page.getRecords();
|
|
|
|
+ int i = 0;
|
|
|
|
+ for (Camera camera : list) {
|
|
|
|
+ for (Integer cameraId : cameraIds) {
|
|
|
|
+ if (cameraId.equals( camera.getId())){
|
|
|
|
+ String url = publicNetworkMapper.selectOne(null).getUrl();
|
|
|
|
+
|
|
|
|
+ String cameraAccount = camera.getAccount();
|
|
|
|
+ String cameraPassword = camera.getPassword();
|
|
|
|
+ String camerIp = camera.getCameraIp();
|
|
|
|
+ String cameraName = camera.getCameraName();
|
|
|
|
+ Integer areaId = camera.getAreaId();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ String rtsp ;
|
|
|
|
+ CameraBrand cameraBrand = cameraBrandMapper.selectById(camera.getBrandId());
|
|
|
|
+ Integer type = cameraBrand.getStreamType();
|
|
|
|
+ if (type == 0){
|
|
|
|
+ rtsp = cameraBrand.getMainStream();
|
|
|
|
+ }else {
|
|
|
|
+ rtsp = cameraBrand.getAssistStream();
|
|
|
|
+ }
|
|
|
|
+ CameraVo cameraVo= new CameraVo();
|
|
|
|
+ cameraVo.setAreaId(areaId);
|
|
|
|
+ cameraVo.setWsUrl("ws://" + url + "/camera_relay?tcpaddr=" + cameraAccount + "%3A" + cameraPassword + "%40" + camerIp);
|
|
|
|
+ cameraVo.setRtspUrl("rtsp://" + cameraAccount + ":" + cameraPassword + "@" + camerIp + rtsp);
|
|
|
|
+ cameraVo.setCameraName(cameraName);
|
|
|
|
+ if (i > 0){
|
|
|
|
+ cameraVo.setLastId(list.get(i-1).getId());
|
|
|
|
+ }
|
|
|
|
+ if (i < list.size()-1 ){
|
|
|
|
+ cameraVo.setNextId(list.get(i+1).getId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ cameraDetailsList.add(cameraVo);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ i++;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return cameraDetailsList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result updateStatus(Integer id) {
|
|
|
|
+ Camera byId = this.getById(id);
|
|
|
|
+
|
|
|
|
+ if (byId.getRunStatus()) {
|
|
|
|
+ byId.setRunStatus(false);
|
|
|
|
+ this.updateById(byId);
|
|
|
|
+ return new Result(10000,"已停用",true);
|
|
|
|
+ } else {
|
|
|
|
+ byId.setRunStatus(true);
|
|
|
|
+ this.updateById(byId);
|
|
|
|
+ return new Result(10000,"已启用",true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result add(Camera camera) {
|
|
|
|
+ Integer areaId = camera.getAreaId();
|
|
|
|
+ Integer brandId = camera.getBrandId();
|
|
|
|
+
|
|
|
|
+ int brandName = this.count(new QueryWrapper<Camera>().eq("camera_name", camera.getCameraName()));
|
|
|
|
+ if (brandName >0){
|
|
|
|
+ return new Result(ResultCode.FAIL,"该摄像头已经存在");
|
|
|
|
+ }
|
|
|
|
+ if (areaId != null){
|
|
|
|
+ camera.setAreaName(cameraAreaMapper.selectById(areaId).getAreaName());
|
|
|
|
+ }
|
|
|
|
+ if ( brandId!= null){
|
|
|
|
+ camera.setBrandName(cameraBrandMapper.selectById(brandId).getBrandName());
|
|
|
|
+ }
|
|
|
|
+ this.save(camera);
|
|
|
|
+
|
|
|
|
+ return new Result(ResultCode.SUCCESS,"添加成功");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result updates(Camera camera) {
|
|
|
|
+ Integer areaId = camera.getAreaId();
|
|
|
|
+ Integer brandId = camera.getBrandId();
|
|
|
|
+
|
|
|
|
+ if (areaId != null){
|
|
|
|
+ camera.setAreaName(cameraAreaMapper.selectById(areaId).getAreaName());
|
|
|
|
+ }
|
|
|
|
+ if ( brandId!= null){
|
|
|
|
+ camera.setBrandName(cameraBrandMapper.selectById(brandId).getBrandName());
|
|
|
|
+ }
|
|
|
|
+ this.updateById(camera);
|
|
|
|
+
|
|
|
|
+ return new Result(ResultCode.SUCCESS,"修改成功");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List getByAreaId(Integer areaId) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|