企业查看项目列表接口添加在线离线数量

This commit is contained in:
guoshengxiong 2025-11-17 18:40:50 +08:00
parent b112cb9f75
commit 9cdc8edcbe
2 changed files with 38 additions and 2 deletions

View File

@ -235,6 +235,7 @@ public class CompanyController {
@ApiImplicitParam(name = "videoType", value = "查询类型0无视频1有视频", paramType = "body", required = true, dataType = "String"),
@ApiImplicitParam(name = "standardType", value = "是否查询标养室0否1是", paramType = "body", required = true, dataType = "String"),
@ApiImplicitParam(name = "projectType", value = "是否展示0否1是", paramType = "body", required = true, dataType = "String"),
@ApiImplicitParam(name = "showVideoNum", value = "是否展示(在线)监控数量0否1是", paramType = "body", required = false, dataType = "String"),
})
@PostMapping("/getComapnyStatisticsList")
@PreAuthorize("@perm.hasSnAccess(#map['sn'])")

View File

@ -2,6 +2,7 @@ package com.zhgd.xmgl.modules.basicdata.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
@ -357,6 +358,7 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
secondComapnyList = getGroupStatisticsCompany(secondComapnyList, childComapnyList);
fistComapnyList = getGroupStatisticsCompany(fistComapnyList, secondComapnyList);
fistComapnyList = filterCompanyByProject(fistComapnyList, map);
addVideoTotalAndOnlineNum(fistComapnyList, type);
data.put("companyList", fistComapnyList);
addSnForTree(data);
} else if (Objects.equals(tempCompany.getCompanyType(), CompanyTypeEnum.REGIONS.getValue())) {
@ -373,6 +375,7 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
}
fistComapnyList = getGroupStatisticsCompany(fistComapnyList, companyList);
fistComapnyList = filterCompanyByProject(fistComapnyList, map);
addVideoTotalAndOnlineNum(fistComapnyList, type);
data.put("companyList", fistComapnyList);
} else if (Objects.equals(tempCompany.getCompanyType(), CompanyTypeEnum.CITIES.getValue())) {
Company parentCompany = companyMapper.selectById(tempCompany.getParentId());
@ -387,6 +390,7 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
}
}
companyList = filterCompanyByProject(companyList, map);
addVideoTotalAndOnlineNum(companyList, type);
data.put("companyList", companyList);
} else {
Company parentCompany = companyMapper.selectById(tempCompany.getParentId());
@ -396,6 +400,7 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
data.put("firstCompany", firstCompany);
map.put("companyType", "5");
List<EntityMap> projectList = getProjectEntityMaps(map, type, standardType);
addVideoTotalAndOnlineNum(projectList, type);
data.put("projectList", projectList);
}
@ -410,6 +415,24 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
return data;
}
/**
* 添加在线离线数量
*
* @param fistComapnyList
* @param type
*/
private void addVideoTotalAndOnlineNum(List<EntityMap> fistComapnyList, Integer type) {
if (type == 1) {
for (int i = 0; i < fistComapnyList.size(); i++) {
EntityMap entityMap = fistComapnyList.get(i);
String childName = "list";
JSONObject jsonObject = BeanUtil.toBean(entityMap, JSONObject.class);
Map<String, Integer> integerMap = VideoItemServiceImpl.getTotalAndOnlineNum(jsonObject, childName);
entityMap.putAll(integerMap);
}
}
}
private List<EntityMap> getChildCompanyStatisticsList(Map<String, Object> map, Integer type, Integer standardType, List<EntityMap> childComapnyList) {
List<EntityMap> projectList = getProjectEntityMaps(map, type, standardType);
childComapnyList = getGroupStatisticsProject(childComapnyList, projectList);
@ -430,6 +453,20 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
List<Map<String, Object>> standardList = standardDevMapper.selectProjecDevAlarmCount(map);
projectList = addProjectStandardData(projectList, standardList);
}
if (Objects.equals(MapUtils.getInteger(map, "showVideoNum"), 1)) {
List<EntityMap> videoList = projectMapper.selectVideoList(map);
Map<String, List<EntityMap>> projectSn2VideosMap = videoList.stream().collect(Collectors.groupingBy(entityMap -> Convert.toStr(entityMap.get("projectSn"))));
for (EntityMap projectMap : projectList) {
List<EntityMap> mapList = projectSn2VideosMap.get(projectMap.get("projectSn"));
Integer videoNum = Optional.ofNullable(mapList).map(m -> m.size()).orElse(0);
Long onlineVideoNum = 0L;
if (mapList != null) {
onlineVideoNum = mapList.stream().filter(entityMap -> Objects.equals(entityMap.get("deviceState"), 1)).count();
}
projectMap.put("video_num", videoNum);
projectMap.put("online_video_num", onlineVideoNum);
}
}
return projectList;
}
@ -458,8 +495,6 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
if (CollUtil.isNotEmpty(videoJa)) {
for (int i = 0; i < videoJa.size(); i++) {
JSONObject jsonObject = videoJa.getJSONObject(i);
Map<String, Integer> integerMap = VideoItemServiceImpl.getTotalAndOnlineNum(jsonObject, childName);
jsonObject.putAll(integerMap);
rtList.add(BeanUtil.toBean(jsonObject, EntityMapV2.class));
}
}