查询企业的树形项目和监控分组和监控列表添加总数和在线视频监控数量
This commit is contained in:
parent
070206603d
commit
fc70952695
@ -37,6 +37,16 @@ public class TreeProjectVideoListVo {
|
|||||||
private VideoItem videoItem;
|
private VideoItem videoItem;
|
||||||
private ProjectVideoConfig projectVideoConfig;
|
private ProjectVideoConfig projectVideoConfig;
|
||||||
private List<TreeProjectVideoListVo> children;
|
private List<TreeProjectVideoListVo> children;
|
||||||
|
/**
|
||||||
|
*监控总数
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("监控总数")
|
||||||
|
private Integer totalNum;
|
||||||
|
/**
|
||||||
|
*监控在线总数
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("监控在线总数")
|
||||||
|
private Integer onlineNum;
|
||||||
/**
|
/**
|
||||||
* 监控类型枚举
|
* 监控类型枚举
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -108,7 +108,6 @@ import org.springframework.util.CollectionUtils;
|
|||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@ -531,9 +530,46 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|||||||
String name = MapUtils.getString(map, "name");
|
String name = MapUtils.getString(map, "name");
|
||||||
List<TreeProjectVideoListVo> rtVoList = BeanUtil.copyToList(TreeUtils.listToTree(JSONArray.parseArray(JSON.toJSONString(voList)), "id", "parentId", "children", "name", name), TreeProjectVideoListVo.class);
|
List<TreeProjectVideoListVo> rtVoList = BeanUtil.copyToList(TreeUtils.listToTree(JSONArray.parseArray(JSON.toJSONString(voList)), "id", "parentId", "children", "name", name), TreeProjectVideoListVo.class);
|
||||||
rtVoList = rtVoList.stream().filter(v -> Objects.equals(v.getType(), TreeProjectVideoListVo.MonitorType.PROJECT.getCode())).collect(Collectors.toList());
|
rtVoList = rtVoList.stream().filter(v -> Objects.equals(v.getType(), TreeProjectVideoListVo.MonitorType.PROJECT.getCode())).collect(Collectors.toList());
|
||||||
|
for (TreeProjectVideoListVo vo : rtVoList) {
|
||||||
|
getAndSetTotalAndOnlineNum(vo);
|
||||||
|
}
|
||||||
return rtVoList;
|
return rtVoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递归统计总数和在线视频监控数量
|
||||||
|
*
|
||||||
|
* @param vo
|
||||||
|
* @return 包含totalNum和onlineNum的Map
|
||||||
|
*/
|
||||||
|
public static Map<String, Integer> getAndSetTotalAndOnlineNum(TreeProjectVideoListVo vo) {
|
||||||
|
Map<String, Integer> result = new HashMap<>();
|
||||||
|
int totalNum = 0;
|
||||||
|
int onlineNum = 0;
|
||||||
|
if (Objects.equals(vo.getType(), TreeProjectVideoListVo.MonitorType.VIDEO.getCode())) {
|
||||||
|
totalNum = 1;
|
||||||
|
if (Objects.equals(vo.getVideoItem().getDeviceState(), 1)) {
|
||||||
|
onlineNum = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 递归处理子节点
|
||||||
|
List<TreeProjectVideoListVo> children = vo.getChildren();
|
||||||
|
if (CollUtil.isNotEmpty(children)) {
|
||||||
|
for (int i = 0; i < children.size(); i++) {
|
||||||
|
TreeProjectVideoListVo child = children.get(i);
|
||||||
|
Map<String, Integer> childStats = getAndSetTotalAndOnlineNum(child);
|
||||||
|
// 累加子节点的统计结果
|
||||||
|
totalNum += childStats.getOrDefault("totalNum", 0);
|
||||||
|
onlineNum += childStats.getOrDefault("onlineNum", 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.put("totalNum", totalNum);
|
||||||
|
result.put("onlineNum", onlineNum);
|
||||||
|
vo.setTotalNum(totalNum);
|
||||||
|
vo.setOnlineNum(onlineNum);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveZwProject(ZwProjectDataVo zwProjectDataVo) {
|
public void saveZwProject(ZwProjectDataVo zwProjectDataVo) {
|
||||||
Project project = new Project();
|
Project project = new Project();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user