Commit c290cdc0 authored by 高建强's avatar 高建强

item:【装备】优化pointTree接口查询慢问题

parent bb031d4e
...@@ -21,16 +21,16 @@ import com.yeejoin.equipmanage.common.datasync.entity.FireFightingSystem; ...@@ -21,16 +21,16 @@ import com.yeejoin.equipmanage.common.datasync.entity.FireFightingSystem;
import com.yeejoin.equipmanage.common.entity.*; import com.yeejoin.equipmanage.common.entity.*;
import com.yeejoin.equipmanage.common.entity.dto.EquipTypeAmountPageDTO; import com.yeejoin.equipmanage.common.entity.dto.EquipTypeAmountPageDTO;
import com.yeejoin.equipmanage.common.entity.vo.*; import com.yeejoin.equipmanage.common.entity.vo.*;
import com.yeejoin.equipmanage.common.enums.*; import com.yeejoin.equipmanage.common.enums.AlarmStatusEnum;
import com.yeejoin.equipmanage.common.enums.EquipmentSpeIndexEnum;
import com.yeejoin.equipmanage.common.enums.SystemTypeEnum;
import com.yeejoin.equipmanage.common.enums.TrueOrFalseEnum;
import com.yeejoin.equipmanage.common.utils.StringUtil; import com.yeejoin.equipmanage.common.utils.StringUtil;
import com.yeejoin.equipmanage.common.vo.*; import com.yeejoin.equipmanage.common.vo.*;
import com.yeejoin.equipmanage.mapper.*; import com.yeejoin.equipmanage.mapper.*;
import com.yeejoin.equipmanage.remote.RemoteSecurityService; import com.yeejoin.equipmanage.remote.RemoteSecurityService;
import com.yeejoin.equipmanage.service.*; import com.yeejoin.equipmanage.service.*;
import com.yeejoin.equipmanage.utils.BeanUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -453,72 +453,74 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste ...@@ -453,72 +453,74 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
//TODO id为空,为消防建筑使用;id不为空,为点位图使用 //TODO id为空,为消防建筑使用;id不为空,为点位图使用
List<PointTreeVo> pointData = fireFightingSystemMapper.getPointData(id); List<PointTreeVo> pointData = fireFightingSystemMapper.getPointData(id);
if (!CollectionUtils.isEmpty(pointData)) { if (!CollectionUtils.isEmpty(pointData)) {
// List<Long> idList = pointData.stream().map(PointTreeVo::getSequenceNbr).collect(Collectors.toList()); // 查询所有wl_source_scene,判断是否绑定
// List<SpeIndexVo> indexVoList = fireFightingSystemMapper.getSpeIndexIn(idList); List<SourceScene> sourceSceneList = sourceSceneMapper.selectList(null);
// if (!CollectionUtils.isEmpty(indexVoList)) { Map<Long, String> sourceSceneMap = null;
// Map<Long, List<SpeIndexVo>> indexMap = indexVoList.stream().collect(Collectors.groupingBy(SpeIndexVo::getEquipmentSpecificId)); String equipSpecificIds = null;
// pointData.forEach(p -> { if (!CollectionUtils.isEmpty(sourceSceneList)) {
// Map map = new HashMap(7); sourceSceneMap = sourceSceneList.stream().collect(Collectors.toMap(SourceScene::getSourceId, SourceScene::getPointInScene));
// map.put("imgPath", p.getImgPath()); List<String> equipSpecificIdList = sourceSceneList.stream().map(SourceScene::getPointInScene).collect(Collectors.toList());
// map.put("equipCode", p.getEquipCode()); equipSpecificIds = String.join(",", equipSpecificIdList);
// map.put("equipSyetemId", p.getEquipSyetemId()); }
// map.put("equipTypeId", p.getEquipId()); // 优化不查指标
// map.put("speindexList", makeStatus(indexMap.get(p.getSequenceNbr()))); for (PointTreeVo p : pointData) {
// map.put("speindexApi", speindexUrl + p.getSequenceNbr()); Long buildOrSysId = p.getParentId();
// map.put("detailInfoApi", equipmentDetailUrl + p.getSequenceNbr()); Long equipSpecificId = p.getSequenceNbr();
// map.put("detailApi", equipmentDetailUrl + p.getSequenceNbr()); Map map = new HashMap(7);
// p.setDataConfig(map); map.put("imgPath", p.getImgPath());
// }); map.put("equipCode", p.getEquipCode());
// } map.put("equipSyetemId", p.getEquipSyetemId());
} map.put("equipTypeId", p.getEquipId());
// for (PointTreeVo tree : allRiskSource) { map.put("speindexApi", speindexUrl + equipSpecificId);
// if (tree.getParentId() == null || tree.getParentId() == -1) { map.put("detailInfoApi", equipmentDetailUrl + p.getSequenceNbr());
// treeList.add(tree); map.put("detailApi", equipmentDetailUrl + p.getSequenceNbr());
// } p.setDataConfig(map);
// for (PointTreeVo treeNode : allRiskSource) { if (StringUtils.isEmpty(id)) {
// if (tree.getSequenceNbr().equals(treeNode.getParentId())) { // 建筑
// if (tree.getChildren() == null) { if (equipSpecificIds.contains(String.valueOf(equipSpecificId))) {
// tree.setChildren(new ArrayList<>()); p.setBinding(true);
// } } else {
// tree.getChildren().add(treeNode); p.setBinding(false);
// }
// }
// }
// 优化不查指标,
pointData.forEach(p -> {
Map map = new HashMap(7);
map.put("imgPath", p.getImgPath());
map.put("equipCode", p.getEquipCode());
map.put("equipSyetemId", p.getEquipSyetemId());
map.put("equipTypeId", p.getEquipId());
map.put("speindexApi", speindexUrl + p.getSequenceNbr());
map.put("detailInfoApi", equipmentDetailUrl + p.getSequenceNbr());
map.put("detailApi", equipmentDetailUrl + p.getSequenceNbr());
p.setDataConfig(map);
});
allRiskSource.addAll(pointData);
// 树组装优化
Map<Long, PointTreeVo> map = new HashMap<>(allRiskSource.size());
allRiskSource.forEach(e -> map.put(e.getSequenceNbr(), e));
Set<? extends Map.Entry<Long, ? extends PointTreeVo>> entries = map.entrySet();
List<PointTreeVo> treeList = new ArrayList<>();
entries.forEach(entry -> {
PointTreeVo value = entry.getValue();
if (value != null) {
PointTreeVo treeDto = map.get(value.getParentId());
if (treeDto != null) {
List<PointTreeVo> children = treeDto.getChildren();
if (children == null) {
children = new ArrayList<>();
treeDto.setChildren(children);
} }
children.add(value);
} else { } else {
treeList.add(value); if (sourceSceneMap != null) {
String pointInScene = sourceSceneMap.get(buildOrSysId);
if (!StringUtils.isEmpty(pointInScene)) {
// 系统
if (pointInScene.contains(String.valueOf(equipSpecificId))) {
p.setBinding(true);
} else {
p.setBinding(false);
}
}
}
} }
} }
}); allRiskSource.addAll(pointData);
return treeList; // 树组装优化
Map<Long, PointTreeVo> map = new HashMap<>(allRiskSource.size());
allRiskSource.forEach(e -> map.put(e.getSequenceNbr(), e));
Set<? extends Map.Entry<Long, ? extends PointTreeVo>> entries = map.entrySet();
List<PointTreeVo> treeList = new ArrayList<>();
entries.forEach(entry -> {
PointTreeVo value = entry.getValue();
if (value != null) {
PointTreeVo treeDto = map.get(value.getParentId());
if (treeDto != null) {
List<PointTreeVo> children = treeDto.getChildren();
if (children == null) {
children = new ArrayList<>();
treeDto.setChildren(children);
}
children.add(value);
} else {
treeList.add(value);
}
}
});
return treeList;
}
return Collections.emptyList();
} }
/** /**
......
...@@ -178,18 +178,6 @@ ...@@ -178,18 +178,6 @@
select select
'component' as template, 'component' as template,
true as openStatus, true as openStatus,
<if test="id == null">
if((select count(1) from `wl_source_scene` ss where
-- find_in_set(spe.id, ss.point_in_scene)
spe.id in (ss.point_in_scene)
and EXISTS
(SELECT es.instance_id FROM `wl_form_instance` es WHERE ss.source_id = es.instance_id)) = 0,0,1) as
isBinding, -- 一个装备只能在一个建筑使用
</if>
<if test="id != null and id !=''">
if((SELECT count(1) FROM `wl_source_scene` ss where ss.source_id = #{id} and
FIND_IN_SET(spe.id,ss.point_in_scene)) = 0,0,1) as isBinding,-- 一个装备可在多个系统使用
</if>
if(spe.code is null,eqdet.name,concat(eqdet.name,'(',spe.code,')')) as displayName, if(spe.code is null,eqdet.name,concat(eqdet.name,'(',spe.code,')')) as displayName,
'{\"width\": 42, \"height\": 42}'as initStyle, '{\"width\": 42, \"height\": 42}'as initStyle,
'CommonEquip' as componentName, 'CommonEquip' as componentName,
...@@ -226,15 +214,6 @@ ...@@ -226,15 +214,6 @@
'component' AS template, 'component' AS template,
TRUE AS openStatus, TRUE AS openStatus,
IF IF
(
( SELECT ss.id FROM wl_source_scene ss WHERE
-- ss.video_in_scene LIKE CONCAT( '%', vid.id, '%' )
vid.id in (ss.video_in_scene)
) IS NULL,
0,
1
) AS isBinding,
IF
( vid.CODE IS NULL, vid.NAME, concat( vid.NAME, '(', vid.CODE, ')' ) ) AS displayName, ( vid.CODE IS NULL, vid.NAME, concat( vid.NAME, '(', vid.CODE, ')' ) ) AS displayName,
'{\"width\": 42, \"height\": 42}' AS initStyle, '{\"width\": 42, \"height\": 42}' AS initStyle,
'CommonEquip' AS componentName, 'CommonEquip' AS componentName,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment