From 9cdc8edcbec99aac4198ebd25b017a85970d1c17 Mon Sep 17 00:00:00 2001 From: guoshengxiong <1923636941@qq.com> Date: Mon, 17 Nov 2025 18:40:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=81=E4=B8=9A=E6=9F=A5=E7=9C=8B=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=9C=A8=E7=BA=BF=E7=A6=BB=E7=BA=BF=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CompanyController.java | 1 + .../service/impl/CompanyServiceImpl.java | 39 ++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/zhgd/xmgl/modules/basicdata/controller/CompanyController.java b/src/main/java/com/zhgd/xmgl/modules/basicdata/controller/CompanyController.java index 6063017c9..272632827 100644 --- a/src/main/java/com/zhgd/xmgl/modules/basicdata/controller/CompanyController.java +++ b/src/main/java/com/zhgd/xmgl/modules/basicdata/controller/CompanyController.java @@ -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'])") diff --git a/src/main/java/com/zhgd/xmgl/modules/basicdata/service/impl/CompanyServiceImpl.java b/src/main/java/com/zhgd/xmgl/modules/basicdata/service/impl/CompanyServiceImpl.java index 4909c0b24..a5edcb917 100644 --- a/src/main/java/com/zhgd/xmgl/modules/basicdata/service/impl/CompanyServiceImpl.java +++ b/src/main/java/com/zhgd/xmgl/modules/basicdata/service/impl/CompanyServiceImpl.java @@ -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 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 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 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 impl data.put("firstCompany", firstCompany); map.put("companyType", "5"); List projectList = getProjectEntityMaps(map, type, standardType); + addVideoTotalAndOnlineNum(projectList, type); data.put("projectList", projectList); } @@ -410,6 +415,24 @@ public class CompanyServiceImpl extends ServiceImpl impl return data; } + /** + * 添加在线离线数量 + * + * @param fistComapnyList + * @param type + */ + private void addVideoTotalAndOnlineNum(List 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 integerMap = VideoItemServiceImpl.getTotalAndOnlineNum(jsonObject, childName); + entityMap.putAll(integerMap); + } + } + } + private List getChildCompanyStatisticsList(Map map, Integer type, Integer standardType, List childComapnyList) { List projectList = getProjectEntityMaps(map, type, standardType); childComapnyList = getGroupStatisticsProject(childComapnyList, projectList); @@ -430,6 +453,20 @@ public class CompanyServiceImpl extends ServiceImpl impl List> standardList = standardDevMapper.selectProjecDevAlarmCount(map); projectList = addProjectStandardData(projectList, standardList); } + if (Objects.equals(MapUtils.getInteger(map, "showVideoNum"), 1)) { + List videoList = projectMapper.selectVideoList(map); + Map> projectSn2VideosMap = videoList.stream().collect(Collectors.groupingBy(entityMap -> Convert.toStr(entityMap.get("projectSn")))); + for (EntityMap projectMap : projectList) { + List 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 impl if (CollUtil.isNotEmpty(videoJa)) { for (int i = 0; i < videoJa.size(); i++) { JSONObject jsonObject = videoJa.getJSONObject(i); - Map integerMap = VideoItemServiceImpl.getTotalAndOnlineNum(jsonObject, childName); - jsonObject.putAll(integerMap); rtList.add(BeanUtil.toBean(jsonObject, EntityMapV2.class)); } }