|
@@ -2,11 +2,10 @@ package com.huimv.management.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
-import com.huimv.management.dao.CameraBrandDao;
|
|
|
-import com.huimv.management.dao.PastureAreaDao;
|
|
|
-import com.huimv.management.dao.PublicNetworkDao;
|
|
|
+import com.huimv.management.dao.*;
|
|
|
import com.huimv.management.entity.CameraBrandEntity;
|
|
|
import com.huimv.management.entity.PublicNetworkEntity;
|
|
|
+import com.huimv.management.entity.UserAttentionEntity;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.checkerframework.checker.units.qual.A;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -16,6 +15,7 @@ import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
@@ -23,7 +23,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.huimv.common.utils.PageUtils;
|
|
|
import com.huimv.common.utils.Query;
|
|
|
|
|
|
-import com.huimv.management.dao.CameraInfoDao;
|
|
|
import com.huimv.management.entity.CameraInfoEntity;
|
|
|
import com.huimv.management.service.CameraInfoService;
|
|
|
|
|
@@ -44,10 +43,10 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoDao, CameraInfo
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public PageUtils queryPage(Map<String, Object> params) {
|
|
|
+ public PageUtils queryPage(Map<String, Object> params,Long userId) {
|
|
|
|
|
|
//根据牧场查询
|
|
|
- String farmId = (String) params.get("formFarmId");
|
|
|
+ String farmId = (String) params.get("farmId");
|
|
|
|
|
|
QueryWrapper<CameraInfoEntity> wrapper = new QueryWrapper<>();
|
|
|
wrapper.eq(StringUtils.isNotBlank(farmId), "farm_id",farmId);
|
|
@@ -71,6 +70,8 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoDao, CameraInfo
|
|
|
new Query<CameraInfoEntity>().getPage(params),
|
|
|
wrapper
|
|
|
);
|
|
|
+ List<CameraInfoEntity> records = page.getRecords();
|
|
|
+ addAttention(records,userId);
|
|
|
|
|
|
return new PageUtils(page);
|
|
|
}
|
|
@@ -111,11 +112,113 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoDao, CameraInfo
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List getByAreaId(Integer areaId) {
|
|
|
+ public List getByAreaId(Integer areaId,Long userId) {
|
|
|
+ List cameraDetailsList = new ArrayList();
|
|
|
+
|
|
|
LambdaQueryWrapper<CameraInfoEntity> wrapper = Wrappers.lambdaQuery();
|
|
|
wrapper.eq(CameraInfoEntity::getAreaId, areaId);
|
|
|
-
|
|
|
List<CameraInfoEntity> cameraInfoEntities = cameraInfoDao.selectList(wrapper);
|
|
|
+
|
|
|
+ QueryWrapper<PublicNetworkEntity> urlWrapper = new QueryWrapper<PublicNetworkEntity>();
|
|
|
+
|
|
|
+ List<CameraInfoEntity> cameraInfoEntities1 = addAttention(cameraInfoEntities, userId);
|
|
|
+
|
|
|
+ for (CameraInfoEntity cameraInfo : cameraInfoEntities) {
|
|
|
+ String rtsp ;
|
|
|
+
|
|
|
+ Map map = new HashMap();
|
|
|
+ Integer farmId = cameraInfo.getFarmId();
|
|
|
+ urlWrapper.eq("farm_id", farmId);
|
|
|
+ String url = publicNetworkDao.selectOne(urlWrapper).getUrl();
|
|
|
+ urlWrapper.clear();
|
|
|
+
|
|
|
+ String cameraAccount = cameraInfo.getAccount();
|
|
|
+ String cameraPassword = cameraInfo.getPassword();
|
|
|
+ String camerIp = cameraInfo.getIp();
|
|
|
+ CameraBrandEntity cameraBrandEntity = cameraBrandDao.selectById(cameraInfo.getCameraBrandId());
|
|
|
+ Boolean type = cameraBrandEntity.getType();
|
|
|
+ if (type){
|
|
|
+ rtsp = cameraBrandEntity.getMainStream();
|
|
|
+ }else {
|
|
|
+ rtsp = cameraBrandEntity.getAssistStream();
|
|
|
+ }
|
|
|
+ map.put("wsUrl", "ws://" + url + "/camera_relay?tcpaddr=" + cameraAccount + "%3A" + cameraPassword + "%40" + camerIp);
|
|
|
+ map.put("rtspUrl", "rtsp://" + cameraAccount + ":" + cameraPassword + "@" + camerIp + rtsp);
|
|
|
+ map.put("areaId", areaId);
|
|
|
+ map.put("name",cameraInfo.getName());
|
|
|
+ map.put("id",cameraInfo.getId());
|
|
|
+ map.put("attention",cameraInfo.getAttention());
|
|
|
+ map.put("areaName",cameraInfo.getAreaName());
|
|
|
+
|
|
|
+
|
|
|
+ cameraDetailsList.add(map);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return cameraDetailsList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List findAttention(Integer farmId,Long userId) {
|
|
|
+ List cameraDetailsList = new ArrayList();
|
|
|
+ LambdaQueryWrapper<CameraInfoEntity> wrapper = Wrappers.lambdaQuery();
|
|
|
+ wrapper.eq(CameraInfoEntity::getFarmId,farmId);
|
|
|
+ List<CameraInfoEntity> cameraInfoEntities = baseMapper.selectList(wrapper);
|
|
|
+ QueryWrapper<PublicNetworkEntity> urlWrapper = new QueryWrapper<PublicNetworkEntity>();
|
|
|
+
|
|
|
+ List<CameraInfoEntity> cameraInfoEntities1 = addAttention(cameraInfoEntities, userId);
|
|
|
+ List<CameraInfoEntity> collect = cameraInfoEntities1.stream()
|
|
|
+ .filter(o -> o.getAttention() == 1)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ for (CameraInfoEntity cameraInfo : collect) {
|
|
|
+ String rtsp ;
|
|
|
+ Map map = new HashMap();
|
|
|
+ urlWrapper.eq("farm_id", farmId);
|
|
|
+ String url = publicNetworkDao.selectOne(urlWrapper).getUrl();
|
|
|
+ urlWrapper.clear();
|
|
|
+
|
|
|
+ String cameraAccount = cameraInfo.getAccount();
|
|
|
+ String cameraPassword = cameraInfo.getPassword();
|
|
|
+ String camerIp = cameraInfo.getIp();
|
|
|
+ Integer areaId = cameraInfo.getAreaId();
|
|
|
+ CameraBrandEntity cameraBrandEntity = cameraBrandDao.selectById(cameraInfo.getCameraBrandId());
|
|
|
+ Boolean type = cameraBrandEntity.getType();
|
|
|
+ if (type){
|
|
|
+ rtsp = cameraBrandEntity.getMainStream();
|
|
|
+ }else {
|
|
|
+ rtsp = cameraBrandEntity.getAssistStream();
|
|
|
+ }
|
|
|
+ map.put("wsUrl", "ws://" + url + "/camera_relay?tcpaddr=" + cameraAccount + "%3A" + cameraPassword + "%40" + camerIp);
|
|
|
+ map.put("rtspUrl", "rtsp://" + cameraAccount + ":" + cameraPassword + "@" + camerIp + rtsp);
|
|
|
+ map.put("areaId", areaId);
|
|
|
+ map.put("name",cameraInfo.getName());
|
|
|
+ map.put("id",cameraInfo.getId());
|
|
|
+ map.put("attention",cameraInfo.getAttention());
|
|
|
+ map.put("areaName",cameraInfo.getAreaName());
|
|
|
+
|
|
|
+ cameraDetailsList.add(map);
|
|
|
+ }
|
|
|
+ return cameraDetailsList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserAttentionDao userAttentionDao;
|
|
|
+ //是否关注
|
|
|
+ public List<CameraInfoEntity> addAttention(List<CameraInfoEntity> cameraInfoEntities,Long userId){
|
|
|
+ LambdaQueryWrapper<UserAttentionEntity> wrapper = Wrappers.lambdaQuery();
|
|
|
+ wrapper.eq(UserAttentionEntity::getUserId,userId);
|
|
|
+ List<UserAttentionEntity> userAttentionEntities = userAttentionDao.selectList(wrapper);
|
|
|
+
|
|
|
+ for (UserAttentionEntity userAttentionEntity : userAttentionEntities) {
|
|
|
+ for (CameraInfoEntity cameraInfoEntity : cameraInfoEntities) {
|
|
|
+ if (cameraInfoEntity.getId().equals(userAttentionEntity.getCameraId())){
|
|
|
+ cameraInfoEntity.setAttention(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
return cameraInfoEntities;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|