企业视频增加分组
This commit is contained in:
parent
c7668679fa
commit
2a2e42fe5e
37
src/main/java/com/zhgd/jeecg/common/mybatis/EntityMapV2.java
Normal file
37
src/main/java/com/zhgd/jeecg/common/mybatis/EntityMapV2.java
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package com.zhgd.jeecg.common.mybatis;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||||
|
import com.zhgd.mybatis.Aes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义MapV2
|
||||||
|
*/
|
||||||
|
public class EntityMapV2 extends EntityMap {
|
||||||
|
@Override
|
||||||
|
public EntityMap put(String key, Object value) {
|
||||||
|
if (ObjectUtils.isNotEmpty(interceptors)) {
|
||||||
|
interceptors.convert(this, key, value);
|
||||||
|
}
|
||||||
|
if (key.startsWith(ASE)) {
|
||||||
|
super.put(underlineToCamel(key.substring(ASE.length())), Aes.decrypt(value.toString()), true);
|
||||||
|
} else {
|
||||||
|
String newk = key;
|
||||||
|
if (StrUtil.contains(key, "_")) {
|
||||||
|
newk = underlineToCamel(key);
|
||||||
|
}
|
||||||
|
if (ObjectUtils.isNotNull(value)) {
|
||||||
|
//判断数据是否是Long类型,如果是则转为字符串
|
||||||
|
if (Long.class.isAssignableFrom(value.getClass())) {
|
||||||
|
super.put(newk, String.valueOf(value), true);
|
||||||
|
} else {
|
||||||
|
super.put(newk, value, true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
super.put(newk, "", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -20,6 +20,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||||||
import com.gexin.fastjson.TypeReference;
|
import com.gexin.fastjson.TypeReference;
|
||||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||||
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||||
|
import com.zhgd.jeecg.common.mybatis.EntityMapV2;
|
||||||
import com.zhgd.xmgl.constant.Cts;
|
import com.zhgd.xmgl.constant.Cts;
|
||||||
import com.zhgd.xmgl.modules.basicdata.entity.Company;
|
import com.zhgd.xmgl.modules.basicdata.entity.Company;
|
||||||
import com.zhgd.xmgl.modules.basicdata.entity.CompanyConfig;
|
import com.zhgd.xmgl.modules.basicdata.entity.CompanyConfig;
|
||||||
@ -41,6 +42,7 @@ import com.zhgd.xmgl.modules.risk.entity.RiskListRuleItem;
|
|||||||
import com.zhgd.xmgl.modules.risk.service.IRiskListRuleItemService;
|
import com.zhgd.xmgl.modules.risk.service.IRiskListRuleItemService;
|
||||||
import com.zhgd.xmgl.modules.risk.service.IRiskListRuleService;
|
import com.zhgd.xmgl.modules.risk.service.IRiskListRuleService;
|
||||||
import com.zhgd.xmgl.modules.standard.mapper.StandardDevMapper;
|
import com.zhgd.xmgl.modules.standard.mapper.StandardDevMapper;
|
||||||
|
import com.zhgd.xmgl.modules.video.service.impl.VideoItemServiceImpl;
|
||||||
import com.zhgd.xmgl.modules.xz.security.entity.XzSecurityDangerField;
|
import com.zhgd.xmgl.modules.xz.security.entity.XzSecurityDangerField;
|
||||||
import com.zhgd.xmgl.modules.xz.security.entity.vo.XzSecurityDangerFieldVo;
|
import com.zhgd.xmgl.modules.xz.security.entity.vo.XzSecurityDangerFieldVo;
|
||||||
import com.zhgd.xmgl.modules.xz.security.service.IXzSecurityDangerFieldService;
|
import com.zhgd.xmgl.modules.xz.security.service.IXzSecurityDangerFieldService;
|
||||||
@ -350,17 +352,7 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
|
|||||||
List<EntityMap> childComapnyList = companyMapper.getFirstCompanyList(map);
|
List<EntityMap> childComapnyList = companyMapper.getFirstCompanyList(map);
|
||||||
map.put("companyType", "1");
|
map.put("companyType", "1");
|
||||||
if (1 == projectType) {
|
if (1 == projectType) {
|
||||||
List<EntityMap> projectList = projectMapper.selectProjectStatisticsList(map);
|
childComapnyList = getChildCompanyStatisticsList(map, type, standardType, childComapnyList);
|
||||||
if (1 == type) {
|
|
||||||
List<EntityMap> videoList = projectMapper.selectVideoList(map);
|
|
||||||
hidePasswordName(videoList);
|
|
||||||
projectList = getGroupProjectVideo(projectList, videoList);
|
|
||||||
}
|
|
||||||
if (standardType == 1) {
|
|
||||||
List<Map<String, Object>> standardList = standardDevMapper.selectProjecDevAlarmCount(map);
|
|
||||||
projectList = addProjectStandardData(projectList, standardList);
|
|
||||||
}
|
|
||||||
childComapnyList = getGroupStatisticsProject(childComapnyList, projectList);
|
|
||||||
}
|
}
|
||||||
secondComapnyList = getGroupStatisticsCompany(secondComapnyList, childComapnyList);
|
secondComapnyList = getGroupStatisticsCompany(secondComapnyList, childComapnyList);
|
||||||
fistComapnyList = getGroupStatisticsCompany(fistComapnyList, secondComapnyList);
|
fistComapnyList = getGroupStatisticsCompany(fistComapnyList, secondComapnyList);
|
||||||
@ -376,17 +368,7 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
|
|||||||
if (1 == projectType) {
|
if (1 == projectType) {
|
||||||
if (companyList != null && companyList.size() > 0) {
|
if (companyList != null && companyList.size() > 0) {
|
||||||
map.put("companyType", "2");
|
map.put("companyType", "2");
|
||||||
List<EntityMap> projectList = projectMapper.selectProjectStatisticsList(map);
|
companyList = getChildCompanyStatisticsList(map, type, standardType, companyList);
|
||||||
if (1 == type) {
|
|
||||||
List<EntityMap> videoList = projectMapper.selectVideoList(map);
|
|
||||||
hidePasswordName(videoList);
|
|
||||||
projectList = getGroupProjectVideo(projectList, videoList);
|
|
||||||
}
|
|
||||||
if (standardType == 1) {
|
|
||||||
List<Map<String, Object>> standardList = standardDevMapper.selectProjecDevAlarmCount(map);
|
|
||||||
projectList = addProjectStandardData(projectList, standardList);
|
|
||||||
}
|
|
||||||
companyList = getGroupStatisticsProject(companyList, projectList);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fistComapnyList = getGroupStatisticsCompany(fistComapnyList, companyList);
|
fistComapnyList = getGroupStatisticsCompany(fistComapnyList, companyList);
|
||||||
@ -401,17 +383,7 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
|
|||||||
if (1 == projectType) {
|
if (1 == projectType) {
|
||||||
if (companyList != null && companyList.size() > 0) {
|
if (companyList != null && companyList.size() > 0) {
|
||||||
map.put("companyType", "3");
|
map.put("companyType", "3");
|
||||||
List<EntityMap> projectList = projectMapper.selectProjectStatisticsList(map);
|
companyList = getChildCompanyStatisticsList(map, type, standardType, companyList);
|
||||||
if (1 == type) {
|
|
||||||
List<EntityMap> videoList = projectMapper.selectVideoList(map);
|
|
||||||
hidePasswordName(videoList);
|
|
||||||
projectList = getGroupProjectVideo(projectList, videoList);
|
|
||||||
}
|
|
||||||
if (standardType == 1) {
|
|
||||||
List<Map<String, Object>> standardList = standardDevMapper.selectProjecDevAlarmCount(map);
|
|
||||||
projectList = addProjectStandardData(projectList, standardList);
|
|
||||||
}
|
|
||||||
companyList = getGroupStatisticsProject(companyList, projectList);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
companyList = filterCompanyByProject(companyList, map);
|
companyList = filterCompanyByProject(companyList, map);
|
||||||
@ -423,16 +395,7 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
|
|||||||
data.put("companyInfo", tempCompany);
|
data.put("companyInfo", tempCompany);
|
||||||
data.put("firstCompany", firstCompany);
|
data.put("firstCompany", firstCompany);
|
||||||
map.put("companyType", "5");
|
map.put("companyType", "5");
|
||||||
List<EntityMap> projectList = projectMapper.selectProjectStatisticsList(map);
|
List<EntityMap> projectList = getProjectEntityMaps(map, type, standardType);
|
||||||
if (1 == type) {
|
|
||||||
List<EntityMap> videoList = projectMapper.selectVideoList(map);
|
|
||||||
hidePasswordName(videoList);
|
|
||||||
projectList = getGroupProjectVideo(projectList, videoList);
|
|
||||||
}
|
|
||||||
if (standardType == 1) {
|
|
||||||
List<Map<String, Object>> standardList = standardDevMapper.selectProjecDevAlarmCount(map);
|
|
||||||
projectList = addProjectStandardData(projectList, standardList);
|
|
||||||
}
|
|
||||||
data.put("projectList", projectList);
|
data.put("projectList", projectList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,6 +410,62 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
return childComapnyList;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<EntityMap> getProjectEntityMaps(Map<String, Object> map, Integer type, Integer standardType) {
|
||||||
|
List<EntityMap> projectList = projectMapper.selectProjectStatisticsList(map);
|
||||||
|
if (1 == type) {
|
||||||
|
List<EntityMap> videoList = projectMapper.selectVideoList(map);
|
||||||
|
List<EntityMap> groupList = projectMapper.selectVideoGroupList(map);
|
||||||
|
putVideo(projectList, videoList);
|
||||||
|
hidePasswordName(videoList);
|
||||||
|
groupList = getGroupVideoList(groupList, videoList);
|
||||||
|
projectList = getGroupProjectVideo(projectList, groupList);
|
||||||
|
}
|
||||||
|
if (standardType == 1) {
|
||||||
|
List<Map<String, Object>> standardList = standardDevMapper.selectProjecDevAlarmCount(map);
|
||||||
|
projectList = addProjectStandardData(projectList, standardList);
|
||||||
|
}
|
||||||
|
return projectList;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void putVideo(List<EntityMap> projectList, List<EntityMap> videoList) {
|
||||||
|
Map<Object, List<EntityMap>> projectSnMap = videoList.stream().collect(Collectors.groupingBy(entityMap -> entityMap.get("projectSn")));
|
||||||
|
for (EntityMap entityMap : projectList) {
|
||||||
|
entityMap.put("allVideoList", projectSnMap.get(entityMap.get("projectSn")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<EntityMap> getGroupVideoList(List<EntityMap> groupList, List<EntityMap> videoList) {
|
||||||
|
JSONArray newArray = new JSONArray();
|
||||||
|
groupList.addAll(videoList);
|
||||||
|
JSONArray jsonArray = JSONArray.parseArray(JSON.toJSONString(groupList));
|
||||||
|
for (int i = 0; i < jsonArray.size(); i++) {
|
||||||
|
JSONObject jo = jsonArray.getJSONObject(i);
|
||||||
|
if (jo.containsKey("videoName")) {
|
||||||
|
jo.put("id", jo.getString("itemId"));
|
||||||
|
jo.put("parentId", jo.getString("groupId"));
|
||||||
|
}
|
||||||
|
newArray.add(jo);
|
||||||
|
}
|
||||||
|
String childName = "list";
|
||||||
|
JSONArray videoJa = ListUtils.listToTree(newArray, "id", "parentId", childName);
|
||||||
|
List<EntityMap> rtList = new ArrayList<>();
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rtList;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 监控的password字段改名为port
|
* 监控的password字段改名为port
|
||||||
*
|
*
|
||||||
@ -1113,6 +1132,23 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
|
|||||||
return projectList;
|
return projectList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<EntityMap> getGroupProjectVideoGroup(List<EntityMap> projectList, List<EntityMap> groupList) {
|
||||||
|
if (projectList != null && projectList.size() > 0) {
|
||||||
|
for (EntityMap data1 : projectList) {
|
||||||
|
List<EntityMap> tempList = new ArrayList<>();
|
||||||
|
if (groupList != null && groupList.size() > 0) {
|
||||||
|
for (EntityMap data2 : groupList) {
|
||||||
|
if (MapUtils.getString(data1, "projectSn").equals(MapUtils.getString(data2, "projectSn"))) {
|
||||||
|
tempList.add(data2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data1.put(LIST, tempList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return projectList;
|
||||||
|
}
|
||||||
|
|
||||||
public List<EntityMap> addProjectStandardData(List<EntityMap> projectList, List<Map<String, Object>> standardList) {
|
public List<EntityMap> addProjectStandardData(List<EntityMap> projectList, List<Map<String, Object>> standardList) {
|
||||||
if (projectList != null && projectList.size() > 0) {
|
if (projectList != null && projectList.size() > 0) {
|
||||||
for (EntityMap data1 : projectList) {
|
for (EntityMap data1 : projectList) {
|
||||||
|
|||||||
@ -123,6 +123,8 @@ public interface ProjectMapper extends BaseMapper<Project> {
|
|||||||
@DataScope(includeTable = "video_item")
|
@DataScope(includeTable = "video_item")
|
||||||
List<EntityMap> selectVideoList(Map<String, Object> map);
|
List<EntityMap> selectVideoList(Map<String, Object> map);
|
||||||
|
|
||||||
|
List<EntityMap> selectVideoGroupList(Map<String, Object> map);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据sn统计各种设备数量
|
* 根据sn统计各种设备数量
|
||||||
*
|
*
|
||||||
|
|||||||
@ -270,14 +270,39 @@
|
|||||||
order by t1.sort_num
|
order by t1.sort_num
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectVideoGroupList" resultType="com.zhgd.jeecg.common.mybatis.EntityMap">
|
||||||
|
SELECT a.*,a.group_name name
|
||||||
|
FROM video_group a
|
||||||
|
INNER JOIN project p ON p.project_sn = a.project_sn
|
||||||
|
INNER JOIN company cp ON p.company_sn = cp.company_sn
|
||||||
|
INNER JOIN company b ON cp.parent_id = b.company_id
|
||||||
|
Left JOIN company f ON b.parent_id = f.company_id
|
||||||
|
WHERE 1=1
|
||||||
|
<if test="companyType == '1'.toString()">
|
||||||
|
and f.headquarters_sn = #{sn}
|
||||||
|
</if>
|
||||||
|
<if test="companyType == '2'.toString()">
|
||||||
|
and f.company_sn = #{sn}
|
||||||
|
</if>
|
||||||
|
<if test="companyType == '3'.toString()">
|
||||||
|
and b.company_sn = #{sn}
|
||||||
|
</if>
|
||||||
|
<if test="companyType == '4'.toString()">
|
||||||
|
and a.project_sn = #{sn}
|
||||||
|
</if>
|
||||||
|
<if test="companyType == '5'.toString()">
|
||||||
|
and cp.company_sn = #{sn}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="selectVideoSimpleInfoList" resultType="java.util.Map">
|
<select id="selectVideoSimpleInfoList" resultType="java.util.Map">
|
||||||
SELECT t1.serial_number serialNumber, t2.project_sn projectSn, t1.video_name videoName
|
SELECT t1.serial_number serialNumber, t2.project_sn projectSn, t1.video_name videoName
|
||||||
FROM video_item t1
|
FROM video_item t1
|
||||||
INNER JOIN project_video_config t2 ON t2.id = t1.video_id
|
INNER JOIN project_video_config t2 ON t2.id = t1.video_id
|
||||||
INNER JOIN project a ON t2.project_sn = a.project_sn
|
INNER JOIN project a ON t2.project_sn = a.project_sn
|
||||||
INNER JOIN company cp ON a.company_sn = cp.company_sn
|
INNER JOIN company cp ON a.company_sn = cp.company_sn
|
||||||
INNER JOIN company b ON cp.parent_id = b.company_id
|
INNER JOIN company b ON cp.parent_id = b.company_id
|
||||||
Left JOIN company f ON b.parent_id = f.company_id
|
Left JOIN company f ON b.parent_id = f.company_id
|
||||||
WHERE t2.is_enable = 1
|
WHERE t2.is_enable = 1
|
||||||
<if test="companyType == '1'.toString()">
|
<if test="companyType == '1'.toString()">
|
||||||
and f.headquarters_sn = #{sn}
|
and f.headquarters_sn = #{sn}
|
||||||
|
|||||||
@ -717,7 +717,7 @@ public class VideoItemServiceImpl extends ServiceImpl<VideoItemMapper, VideoItem
|
|||||||
if (CollUtil.isNotEmpty(videoList)) {
|
if (CollUtil.isNotEmpty(videoList)) {
|
||||||
for (int i = 0; i < videoList.size(); i++) {
|
for (int i = 0; i < videoList.size(); i++) {
|
||||||
JSONObject jsonObject = videoList.getJSONObject(i);
|
JSONObject jsonObject = videoList.getJSONObject(i);
|
||||||
Map<String, Integer> integerMap = getTotalAndOnlineNum(jsonObject);
|
Map<String, Integer> integerMap = getTotalAndOnlineNum(jsonObject, "children");
|
||||||
jsonObject.putAll(integerMap);
|
jsonObject.putAll(integerMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -730,9 +730,10 @@ public class VideoItemServiceImpl extends ServiceImpl<VideoItemMapper, VideoItem
|
|||||||
* 并设置总数和在线视频监控数量
|
* 并设置总数和在线视频监控数量
|
||||||
*
|
*
|
||||||
* @param jsonObject JSON对象
|
* @param jsonObject JSON对象
|
||||||
|
* @param childName
|
||||||
* @return 包含totalNum和onlineNum的Map
|
* @return 包含totalNum和onlineNum的Map
|
||||||
*/
|
*/
|
||||||
private static Map<String, Integer> getTotalAndOnlineNum(JSONObject jsonObject) {
|
public static Map<String, Integer> getTotalAndOnlineNum(JSONObject jsonObject, String childName) {
|
||||||
Map<String, Integer> result = new HashMap<>();
|
Map<String, Integer> result = new HashMap<>();
|
||||||
int totalNum = 0;
|
int totalNum = 0;
|
||||||
int onlineNum = 0;
|
int onlineNum = 0;
|
||||||
@ -745,11 +746,11 @@ public class VideoItemServiceImpl extends ServiceImpl<VideoItemMapper, VideoItem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 递归处理子节点
|
// 递归处理子节点
|
||||||
JSONArray children = jsonObject.getJSONArray("children");
|
JSONArray children = jsonObject.getJSONArray(childName);
|
||||||
if (CollUtil.isNotEmpty(children)) {
|
if (CollUtil.isNotEmpty(children)) {
|
||||||
for (int i = 0; i < children.size(); i++) {
|
for (int i = 0; i < children.size(); i++) {
|
||||||
JSONObject child = children.getJSONObject(i);
|
JSONObject child = children.getJSONObject(i);
|
||||||
Map<String, Integer> childStats = getTotalAndOnlineNum(child);
|
Map<String, Integer> childStats = getTotalAndOnlineNum(child, childName);
|
||||||
// 累加子节点的统计结果
|
// 累加子节点的统计结果
|
||||||
totalNum += childStats.getOrDefault("totalNum", 0);
|
totalNum += childStats.getOrDefault("totalNum", 0);
|
||||||
onlineNum += childStats.getOrDefault("onlineNum", 0);
|
onlineNum += childStats.getOrDefault("onlineNum", 0);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user