企业查看项目列表接口添加在线离线数量
This commit is contained in:
parent
b112cb9f75
commit
9cdc8edcbe
@ -235,6 +235,7 @@ public class CompanyController {
|
|||||||
@ApiImplicitParam(name = "videoType", value = "查询类型,0无视频,1有视频", paramType = "body", required = true, dataType = "String"),
|
@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 = "standardType", value = "是否查询标养室,0否,1是", paramType = "body", required = true, dataType = "String"),
|
||||||
@ApiImplicitParam(name = "projectType", 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")
|
@PostMapping("/getComapnyStatisticsList")
|
||||||
@PreAuthorize("@perm.hasSnAccess(#map['sn'])")
|
@PreAuthorize("@perm.hasSnAccess(#map['sn'])")
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.zhgd.xmgl.modules.basicdata.service.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.date.DateTime;
|
import cn.hutool.core.date.DateTime;
|
||||||
import cn.hutool.core.date.DateUnit;
|
import cn.hutool.core.date.DateUnit;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
@ -357,6 +358,7 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
|
|||||||
secondComapnyList = getGroupStatisticsCompany(secondComapnyList, childComapnyList);
|
secondComapnyList = getGroupStatisticsCompany(secondComapnyList, childComapnyList);
|
||||||
fistComapnyList = getGroupStatisticsCompany(fistComapnyList, secondComapnyList);
|
fistComapnyList = getGroupStatisticsCompany(fistComapnyList, secondComapnyList);
|
||||||
fistComapnyList = filterCompanyByProject(fistComapnyList, map);
|
fistComapnyList = filterCompanyByProject(fistComapnyList, map);
|
||||||
|
addVideoTotalAndOnlineNum(fistComapnyList, type);
|
||||||
data.put("companyList", fistComapnyList);
|
data.put("companyList", fistComapnyList);
|
||||||
addSnForTree(data);
|
addSnForTree(data);
|
||||||
} else if (Objects.equals(tempCompany.getCompanyType(), CompanyTypeEnum.REGIONS.getValue())) {
|
} 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 = getGroupStatisticsCompany(fistComapnyList, companyList);
|
||||||
fistComapnyList = filterCompanyByProject(fistComapnyList, map);
|
fistComapnyList = filterCompanyByProject(fistComapnyList, map);
|
||||||
|
addVideoTotalAndOnlineNum(fistComapnyList, type);
|
||||||
data.put("companyList", fistComapnyList);
|
data.put("companyList", fistComapnyList);
|
||||||
} else if (Objects.equals(tempCompany.getCompanyType(), CompanyTypeEnum.CITIES.getValue())) {
|
} else if (Objects.equals(tempCompany.getCompanyType(), CompanyTypeEnum.CITIES.getValue())) {
|
||||||
Company parentCompany = companyMapper.selectById(tempCompany.getParentId());
|
Company parentCompany = companyMapper.selectById(tempCompany.getParentId());
|
||||||
@ -387,6 +390,7 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
companyList = filterCompanyByProject(companyList, map);
|
companyList = filterCompanyByProject(companyList, map);
|
||||||
|
addVideoTotalAndOnlineNum(companyList, type);
|
||||||
data.put("companyList", companyList);
|
data.put("companyList", companyList);
|
||||||
} else {
|
} else {
|
||||||
Company parentCompany = companyMapper.selectById(tempCompany.getParentId());
|
Company parentCompany = companyMapper.selectById(tempCompany.getParentId());
|
||||||
@ -396,6 +400,7 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
|
|||||||
data.put("firstCompany", firstCompany);
|
data.put("firstCompany", firstCompany);
|
||||||
map.put("companyType", "5");
|
map.put("companyType", "5");
|
||||||
List<EntityMap> projectList = getProjectEntityMaps(map, type, standardType);
|
List<EntityMap> projectList = getProjectEntityMaps(map, type, standardType);
|
||||||
|
addVideoTotalAndOnlineNum(projectList, type);
|
||||||
data.put("projectList", projectList);
|
data.put("projectList", projectList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -410,6 +415,24 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
|
|||||||
return data;
|
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) {
|
private List<EntityMap> getChildCompanyStatisticsList(Map<String, Object> map, Integer type, Integer standardType, List<EntityMap> childComapnyList) {
|
||||||
List<EntityMap> projectList = getProjectEntityMaps(map, type, standardType);
|
List<EntityMap> projectList = getProjectEntityMaps(map, type, standardType);
|
||||||
childComapnyList = getGroupStatisticsProject(childComapnyList, projectList);
|
childComapnyList = getGroupStatisticsProject(childComapnyList, projectList);
|
||||||
@ -430,6 +453,20 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
|
|||||||
List<Map<String, Object>> standardList = standardDevMapper.selectProjecDevAlarmCount(map);
|
List<Map<String, Object>> standardList = standardDevMapper.selectProjecDevAlarmCount(map);
|
||||||
projectList = addProjectStandardData(projectList, standardList);
|
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;
|
return projectList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -458,8 +495,6 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
|
|||||||
if (CollUtil.isNotEmpty(videoJa)) {
|
if (CollUtil.isNotEmpty(videoJa)) {
|
||||||
for (int i = 0; i < videoJa.size(); i++) {
|
for (int i = 0; i < videoJa.size(); i++) {
|
||||||
JSONObject jsonObject = videoJa.getJSONObject(i);
|
JSONObject jsonObject = videoJa.getJSONObject(i);
|
||||||
Map<String, Integer> integerMap = VideoItemServiceImpl.getTotalAndOnlineNum(jsonObject, childName);
|
|
||||||
jsonObject.putAll(integerMap);
|
|
||||||
rtList.add(BeanUtil.toBean(jsonObject, EntityMapV2.class));
|
rtList.add(BeanUtil.toBean(jsonObject, EntityMapV2.class));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user