|
@@ -1,21 +1,19 @@
|
|
|
package org.dromara.service.impl;
|
|
|
|
|
|
-import cn.hutool.core.collection.CollUtil;
|
|
|
-import cn.hutool.core.lang.tree.Tree;
|
|
|
-import cn.hutool.core.util.ObjectUtil;
|
|
|
-import org.dromara.common.core.constant.UserConstants;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
-import org.dromara.common.core.utils.TreeBuildUtils;
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import org.dromara.domain.SenMonitorPointMedia;
|
|
|
+import org.dromara.mapper.SenMonitorPointMediaMapper;
|
|
|
import org.dromara.system.domain.SysArea;
|
|
|
-import org.dromara.system.domain.bo.SysAreaBo;
|
|
|
-import org.dromara.system.domain.vo.SysAreaVo;
|
|
|
+import org.dromara.system.mapper.SysAreaMapper;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.dromara.domain.bo.SenMonitorPointBo;
|
|
|
import org.dromara.domain.vo.SenMonitorPointVo;
|
|
@@ -23,9 +21,8 @@ import org.dromara.domain.SenMonitorPoint;
|
|
|
import org.dromara.mapper.SenMonitorPointMapper;
|
|
|
import org.dromara.service.ISenMonitorPointService;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Collection;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 监控点位信息Service业务层处理
|
|
@@ -38,6 +35,8 @@ import java.util.Collection;
|
|
|
public class SenMonitorPointServiceImpl implements ISenMonitorPointService {
|
|
|
|
|
|
private final SenMonitorPointMapper baseMapper;
|
|
|
+ private final SysAreaMapper areaMapper;
|
|
|
+ private final SenMonitorPointMediaMapper mediaMapper;
|
|
|
|
|
|
/**
|
|
|
* 查询监控点位信息
|
|
@@ -46,7 +45,7 @@ public class SenMonitorPointServiceImpl implements ISenMonitorPointService {
|
|
|
* @return 监控点位信息
|
|
|
*/
|
|
|
@Override
|
|
|
- public SenMonitorPointVo queryById(Long pointId){
|
|
|
+ public SenMonitorPointVo queryById(Long pointId) {
|
|
|
return baseMapper.selectVoById(pointId);
|
|
|
}
|
|
|
|
|
@@ -97,6 +96,15 @@ public class SenMonitorPointServiceImpl implements ISenMonitorPointService {
|
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
|
if (flag) {
|
|
|
bo.setPointId(add.getPointId());
|
|
|
+ //实时视频
|
|
|
+ if (Objects.equals(bo.getVideoType(), "1")) {
|
|
|
+ SenMonitorPointMedia media =new SenMonitorPointMedia();
|
|
|
+ media.setPointId(bo.getPointId());
|
|
|
+ media.setVideoType(bo.getVideoType());
|
|
|
+ media.setDeviceNo(bo.getDeviceNo());
|
|
|
+ media.setStreamUrl(bo.getStreamUrl());
|
|
|
+ mediaMapper.insert(media);
|
|
|
+ }
|
|
|
}
|
|
|
return flag;
|
|
|
}
|
|
@@ -117,7 +125,7 @@ public class SenMonitorPointServiceImpl implements ISenMonitorPointService {
|
|
|
/**
|
|
|
* 保存前的数据校验
|
|
|
*/
|
|
|
- private void validEntityBeforeSave(SenMonitorPoint entity){
|
|
|
+ private void validEntityBeforeSave(SenMonitorPoint entity) {
|
|
|
//TODO 做一些数据校验,如唯一约束
|
|
|
}
|
|
|
|
|
@@ -130,55 +138,108 @@ public class SenMonitorPointServiceImpl implements ISenMonitorPointService {
|
|
|
*/
|
|
|
@Override
|
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
- if(isValid){
|
|
|
+ if (isValid) {
|
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
|
|
}
|
|
|
return baseMapper.deleteByIds(ids) > 0;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<Tree<Long>> selectAreaTreeList(SenMonitorPointBo bo) {
|
|
|
- SysAreaBo sysAreaBo = new SysAreaBo();
|
|
|
- // 只查询未禁用区域
|
|
|
- sysAreaBo.setStatus(UserConstants.DEPT_NORMAL);
|
|
|
- LambdaQueryWrapper<SysArea> lqw = Wrappers.lambdaQuery();
|
|
|
- lqw.eq(SysArea::getDelFlag, "0");
|
|
|
- lqw.eq(StringUtils.isNotBlank(sysAreaBo.getStatus()), SysArea::getStatus, sysAreaBo.getStatus());
|
|
|
- lqw.orderByAsc(SysArea::getParentId);
|
|
|
- lqw.orderByAsc(SysArea::getOrderNum);
|
|
|
- lqw.orderByAsc(SysArea::getAreaId);
|
|
|
- List<SysAreaVo> areas = baseMapper.selectAreaList(lqw);
|
|
|
- List<Tree<Long>> areaTrees = buildAreaTreeSelect(areas);
|
|
|
- for (Tree<Long> tree : areaTrees) {
|
|
|
- if(tree.getWeight().equals(2)){
|
|
|
- loadPointData(tree,bo);
|
|
|
- }
|
|
|
-
|
|
|
+ public List<SenMonitorPoint> getListByAreaId(SenMonitorPointBo bo) {
|
|
|
+ List<SysArea> resultList = new ArrayList<>();
|
|
|
+ // 直接获取该节点的信息
|
|
|
+ SysArea root = areaMapper.selectOne(new LambdaQueryWrapper<SysArea>()
|
|
|
+ .eq(SysArea::getAreaId, bo.getAreaId()));
|
|
|
+ if (root != null) {
|
|
|
+ resultList.add(root);
|
|
|
}
|
|
|
+ // 获取所有子节点
|
|
|
+ String ancestorPattern = "%" + bo.getAreaId() + "%";
|
|
|
+ List<SysArea> children = areaMapper.selectList(new LambdaQueryWrapper<SysArea>()
|
|
|
+ .like(StringUtils.isNotBlank(ancestorPattern), SysArea::getAncestors, ancestorPattern));
|
|
|
+ resultList.addAll(children);
|
|
|
+ List<Long> areaIds = resultList.stream()
|
|
|
+ .map(SysArea::getAreaId)
|
|
|
+ .toList();
|
|
|
+ return baseMapper.selectList(
|
|
|
+ Wrappers.<SenMonitorPoint>lambdaQuery()
|
|
|
+ .in(SenMonitorPoint::getAreaId, areaIds)
|
|
|
+ .like(StringUtils.isNotBlank(bo.getPointName()), SenMonitorPoint::getPointName, bo.getPointName())
|
|
|
+ .orderByAsc(SenMonitorPoint::getPointId)
|
|
|
+ );
|
|
|
|
|
|
- return buildAreaTreeSelect(areas);
|
|
|
- }
|
|
|
- /**
|
|
|
- * 构建前端所需要下拉树结构
|
|
|
- *
|
|
|
- * @param areas 区域列表
|
|
|
- * @return 下拉树结构列表
|
|
|
- */
|
|
|
- public List<Tree<Long>> buildAreaTreeSelect(List<SysAreaVo> areas) {
|
|
|
- if (CollUtil.isEmpty(areas)) {
|
|
|
- return CollUtil.newArrayList();
|
|
|
- }
|
|
|
- return TreeBuildUtils.build(areas, (area, tree) ->
|
|
|
- tree.setId(area.getAreaId())
|
|
|
- .setParentId(area.getParentId())
|
|
|
- .setName(area.getAreaName())
|
|
|
- .setWeight(area.getAreaLevel()));
|
|
|
}
|
|
|
- public void loadPointData(Tree<Long> tree ,SenMonitorPointBo bo) {
|
|
|
- LambdaQueryWrapper<SenMonitorPoint> lqw = Wrappers.lambdaQuery();
|
|
|
- lqw.eq(StringUtils.isNotBlank(bo.getPointName()), SenMonitorPoint::getPointName, bo.getPointName());
|
|
|
- List<SenMonitorPointVo> points = baseMapper.selectVoList(lqw);
|
|
|
|
|
|
-// tree.setId()
|
|
|
- }
|
|
|
+
|
|
|
+// @Override
|
|
|
+// public MonitorTreeVo selectAreaTreeList(SenMonitorPointBo bo) {
|
|
|
+// // 查询所有区域数据
|
|
|
+// List<SysArea> allAreas = areaMapper.selectList(Wrappers.<SysArea>lambdaQuery().orderByAsc(SysArea::getOrderNum));
|
|
|
+// // 构建节点映射表
|
|
|
+// Map<Long, MonitorTreeVo> nodeMap = new HashMap<>();
|
|
|
+// for (SysArea area : allAreas) {
|
|
|
+// MonitorTreeVo node = new MonitorTreeVo(area);
|
|
|
+// nodeMap.put(area.getAreaId(), node);
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 构建树形结构
|
|
|
+// for (SysArea area : allAreas) {
|
|
|
+// Long parentId = area.getParentId();
|
|
|
+// if (parentId != 0) {
|
|
|
+// MonitorTreeVo parentNode = nodeMap.get(parentId);
|
|
|
+// if (parentNode != null) {
|
|
|
+// parentNode.getChildren().add(nodeMap.get(area.getAreaId()));
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 查找根节点
|
|
|
+// MonitorTreeVo root = null;
|
|
|
+// for (MonitorTreeVo node : nodeMap.values()) {
|
|
|
+// if (node.getParentId() == 0) {
|
|
|
+// if (root == null) {
|
|
|
+// root = node;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 关联监控点数据
|
|
|
+// associateMonitorPoints(root, 3, bo);
|
|
|
+// return root;
|
|
|
+// }
|
|
|
+//
|
|
|
+// private void associateMonitorPoints(MonitorTreeVo node, Integer level, SenMonitorPointBo bo) {
|
|
|
+// if (node != null) {
|
|
|
+// if (node.getAreaLevel().equals(level)) {
|
|
|
+// List<SenMonitorPoint> points = baseMapper.selectList(
|
|
|
+// Wrappers.<SenMonitorPoint>lambdaQuery()
|
|
|
+// .eq(SenMonitorPoint::getAreaId, node.getAreaId())
|
|
|
+// .like(StringUtils.isNotBlank(bo.getPointName()),SenMonitorPoint::getPointName, bo.getPointName())
|
|
|
+// .orderByAsc(SenMonitorPoint::getPointId)
|
|
|
+// );
|
|
|
+// List<MonitorTreeVo> treePoints = getMonitorTreeVos(points);
|
|
|
+// node.setChildren(treePoints);
|
|
|
+//
|
|
|
+// }
|
|
|
+// for (MonitorTreeVo child : node.getChildren()) {
|
|
|
+// associateMonitorPoints(child, level, bo);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// @NotNull
|
|
|
+// private static List<MonitorTreeVo> getMonitorTreeVos(List<SenMonitorPoint> points) {
|
|
|
+// List<MonitorTreeVo> treePoints = new ArrayList<>();
|
|
|
+// for (SenMonitorPoint point : points) {
|
|
|
+// SysArea area = new SysArea();
|
|
|
+// area.setAreaId(point.getPointId());
|
|
|
+// area.setAreaName(point.getPointName());
|
|
|
+// area.setParentId(point.getAreaId());
|
|
|
+// area.setAreaLevel(4);
|
|
|
+// MonitorTreeVo tree = new MonitorTreeVo(area);
|
|
|
+// treePoints.add(tree);
|
|
|
+// }
|
|
|
+// return treePoints;
|
|
|
+// }
|
|
|
+
|
|
|
}
|