Commit b4ee0983 authored by chenzhao's avatar chenzhao

需求 优化消防建筑点位图加载树

parent 3bc16182
...@@ -158,6 +158,22 @@ public class BuildingController extends AbstractBaseController { ...@@ -158,6 +158,22 @@ public class BuildingController extends AbstractBaseController {
return buildService.getBuildTree(bizOrgCode,instanceId); return buildService.getBuildTree(bizOrgCode,instanceId);
} }
@GetMapping(value = "/buuildTree")
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "按需加载建筑装备树", notes = "楼层点位图使用")
public Object getBuildTreeNew(@RequestParam(required = false) String bizOrgCode,@RequestParam(required = false) String instanceId,@RequestParam(required = false) String displayName) {
return buildService.getEquipTree(bizOrgCode,instanceId,displayName);
}
@GetMapping(value = "/equipTree")
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "按需加载建筑装备树", notes = "楼层点位图使用")
public Object getEquipTreeNew(@RequestParam(required = false) String bizOrgCode,@RequestParam(required = false) String instanceId) {
return buildService.getBuildTreeNew(bizOrgCode,instanceId);
}
@GetMapping(value = "/pointTreeNotEqu") @GetMapping(value = "/pointTreeNotEqu")
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "建筑装备树", notes = "楼层点位") @ApiOperation(value = "建筑装备树", notes = "楼层点位")
...@@ -168,11 +184,6 @@ public class BuildingController extends AbstractBaseController { ...@@ -168,11 +184,6 @@ public class BuildingController extends AbstractBaseController {
return buildService.getBuildTreeNot(bizOrgCode); return buildService.getBuildTreeNot(bizOrgCode);
} }
@GetMapping(value = "/3dPointTree") @GetMapping(value = "/3dPointTree")
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "建筑装备树", notes = "三维使用") @ApiOperation(value = "建筑装备树", notes = "三维使用")
......
...@@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.RequestMethod; ...@@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
...@@ -154,6 +155,7 @@ public class MaintenanceResourceDataController extends AbstractBaseController { ...@@ -154,6 +155,7 @@ public class MaintenanceResourceDataController extends AbstractBaseController {
public IPage<MaintenanceResourceData> listPage(Integer pageNum, Integer pageSize, MaintenanceResourceDataVo resourceData) { public IPage<MaintenanceResourceData> listPage(Integer pageNum, Integer pageSize, MaintenanceResourceDataVo resourceData) {
MaintenanceResourceData data = new MaintenanceResourceData(); MaintenanceResourceData data = new MaintenanceResourceData();
List<Long> buildingIds = resourceData.getBuildingIds(); List<Long> buildingIds = resourceData.getBuildingIds();
Long fireFacilityId = resourceData.getFireFacilityId();
BeanUtils.copyProperties(resourceData, data); BeanUtils.copyProperties(resourceData, data);
Page<MaintenanceResourceData> pageBean; Page<MaintenanceResourceData> pageBean;
QueryWrapper<MaintenanceResourceData> queryWrapper = new QueryWrapper<>(); QueryWrapper<MaintenanceResourceData> queryWrapper = new QueryWrapper<>();
...@@ -188,6 +190,9 @@ public class MaintenanceResourceDataController extends AbstractBaseController { ...@@ -188,6 +190,9 @@ public class MaintenanceResourceDataController extends AbstractBaseController {
if (!CollectionUtils.isEmpty(buildingIds)) { if (!CollectionUtils.isEmpty(buildingIds)) {
queryWrapper.in("building_id", buildingIds); queryWrapper.in("building_id", buildingIds);
} }
if (!ValidationUtil.isEmpty(fireFacilityId)) {
queryWrapper.eq("fire_fight_sys_id", fireFacilityId);
}
IPage<MaintenanceResourceData> page; IPage<MaintenanceResourceData> page;
if (pageNum != null && pageSize != null) { if (pageNum != null && pageSize != null) {
pageBean = new Page<>(pageNum, pageSize); pageBean = new Page<>(pageNum, pageSize);
......
...@@ -68,6 +68,9 @@ public interface BuildingMapper extends BaseMapper<Building> { ...@@ -68,6 +68,9 @@ public interface BuildingMapper extends BaseMapper<Building> {
* @param bizOrgCode * @param bizOrgCode
*/ */
List<PointTreeVo> getBuildList(@Param("bizOrgCode") String bizOrgCode,@Param("instanceId") String instanceId); List<PointTreeVo> getBuildList(@Param("bizOrgCode") String bizOrgCode,@Param("instanceId") String instanceId);
List<PointTreeVo> getBuildListNew(@Param("bizOrgCode") String bizOrgCode,@Param("instanceId") String instanceId);
List<PointTreeVo> getBuildAll(@Param("displayName") String displayName);
/** /**
* 获取建筑树主干 * 获取建筑树主干
......
...@@ -77,6 +77,11 @@ public interface FireFightingSystemMapper extends BaseMapper<FireFightingSystemE ...@@ -77,6 +77,11 @@ public interface FireFightingSystemMapper extends BaseMapper<FireFightingSystemE
*/ */
List<PointTreeVo> getPointData(@Param("id") String id,@Param("instanceId") String instanceId); List<PointTreeVo> getPointData(@Param("id") String id,@Param("instanceId") String instanceId);
List<PointTreeVo> getPointDataNew(@Param("id") String id,@Param("instanceId") String instanceId,@Param("displayName") String displayName);
List<PointTreeVo> getPointDataNum(@Param("id") String id);
/** /**
* 获取装备数据 * 获取装备数据
* *
......
...@@ -110,6 +110,10 @@ public interface IBuilldService extends IService<Building> { ...@@ -110,6 +110,10 @@ public interface IBuilldService extends IService<Building> {
* @param bizOrgCode * @param bizOrgCode
*/ */
List<PointTreeVo> getBuildTree(String bizOrgCode,String instanceId); List<PointTreeVo> getBuildTree(String bizOrgCode,String instanceId);
List<PointTreeVo> getEquipTree(String bizOrgCode,String instanceId,String displayName);
List<PointTreeVo> getBuildTreeNew(String bizOrgCode,String instanceId);
List<PointTreeVo> getBuildTreeNot(String bizOrgCode); List<PointTreeVo> getBuildTreeNot(String bizOrgCode);
/** /**
* 获取 建筑装备树 * 获取 建筑装备树
......
...@@ -18,10 +18,7 @@ import com.yeejoin.equipmanage.common.entity.*; ...@@ -18,10 +18,7 @@ import com.yeejoin.equipmanage.common.entity.*;
import com.yeejoin.equipmanage.common.entity.dto.BuildIsRiskDTO; import com.yeejoin.equipmanage.common.entity.dto.BuildIsRiskDTO;
import com.yeejoin.equipmanage.common.entity.dto.BuildSearchDTO; import com.yeejoin.equipmanage.common.entity.dto.BuildSearchDTO;
import com.yeejoin.equipmanage.common.entity.vo.*; import com.yeejoin.equipmanage.common.entity.vo.*;
import com.yeejoin.equipmanage.common.enums.GroupCodeEnum; import com.yeejoin.equipmanage.common.enums.*;
import com.yeejoin.equipmanage.common.enums.GroupTypeEnum;
import com.yeejoin.equipmanage.common.enums.IndustryEnum;
import com.yeejoin.equipmanage.common.enums.StroageTankEnum;
import com.yeejoin.equipmanage.common.utils.EnumsUtils; import com.yeejoin.equipmanage.common.utils.EnumsUtils;
import com.yeejoin.equipmanage.common.utils.StringUtil; import com.yeejoin.equipmanage.common.utils.StringUtil;
import com.yeejoin.equipmanage.common.vo.AlarmDataVO; import com.yeejoin.equipmanage.common.vo.AlarmDataVO;
...@@ -555,6 +552,64 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i ...@@ -555,6 +552,64 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
return fireFightingSystemService.transferListToPointTree(responses, null,instanceId); return fireFightingSystemService.transferListToPointTree(responses, null,instanceId);
} }
public List<PointTreeVo> getEquipTree(String bizOrgCode,String instanceId,String displayName) {
//根据关键字筛选建筑树
List<PointTreeVo> responses = this.baseMapper.getBuildAll(displayName);
if(ValidationUtil.isEmpty(bizOrgCode) && ValidationUtil.isEmpty(instanceId) && ValidationUtil.isEmpty(displayName) ){
return getTree(responses);
} else {
//组装 建筑和装备树
List<PointTreeVo> pointTreeVos = fireFightingSystemService.transferListToPointTreeNew(responses, null, instanceId, displayName);
if(!ValidationUtil.isEmpty(pointTreeVos)){
return pointTreeVos ;
}
//如果筛选的关键字没有装备 返回建筑树
return getTree(responses);
}
}
//组装接口
public List<PointTreeVo> getTree( List<PointTreeVo> responses) {
List<PointTreeVo> pointDataNum = fireFightingSystemMapper.getPointDataNum(null);
if (pointDataNum.size() > 0 && pointDataNum.size() == responses.size()) {
responses.addAll(pointDataNum);
}else {
List<String> ids = Lists.newArrayList();
responses.forEach(r->ids.add(r.getSequenceNbr().toString()));
List<PointTreeVo> collect = pointDataNum.stream().filter(e -> ids.toString().contains(e.getParentId().toString())).collect(Collectors.toList());
responses.addAll(collect);
}
Map<Long, PointTreeVo> map = new HashMap<>(responses.size());
responses.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;
}
@Override
public List<PointTreeVo> getBuildTreeNew(String bizOrgCode,String instanceId) {
List<PointTreeVo> responses = this.baseMapper.getBuildListNew(bizOrgCode,instanceId);
// id为null 避免查询时按系统点位图逻辑查询
return fireFightingSystemService.transferListToPointTree(responses, null,instanceId);
}
@Override @Override
public List<PointTreeVo> getBuildTreeNot(String bizOrgCode) { public List<PointTreeVo> getBuildTreeNot(String bizOrgCode) {
List<PointTreeVo> responses = this.baseMapper.getBuildList(bizOrgCode,null); List<PointTreeVo> responses = this.baseMapper.getBuildList(bizOrgCode,null);
......
...@@ -558,6 +558,88 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste ...@@ -558,6 +558,88 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
* 生成树结构 * 生成树结构
* *
* @param allRiskSource * @param allRiskSource
* @param id
* @return
*/
public List<PointTreeVo> transferListToPointTreeNew(List<PointTreeVo> allRiskSource, String id,String instanceId,String displayName) {
//TODO id为空,为消防建筑使用;id不为空,为点位图使用
List<PointTreeVo> pointData = fireFightingSystemMapper.getPointDataNew(id,instanceId,displayName);
if (!CollectionUtils.isEmpty(pointData)) {
// 查询所有wl_source_scene,判断是否绑定
List<SourceScene> sourceSceneList = sourceSceneMapper.selectList(null);
Map<Long, String> sourceSceneMap = null;
String equipSpecificIds = null;
if (!CollectionUtils.isEmpty(sourceSceneList)) {
sourceSceneMap = sourceSceneList.stream().collect(Collectors.toMap(SourceScene::getSourceId, SourceScene::getPointInScene));
List<String> equipSpecificIdList = sourceSceneList.stream().map(SourceScene::getPointInScene).collect(Collectors.toList());
equipSpecificIds = String.join(",", equipSpecificIdList);
}
// 优化不查指标
for (PointTreeVo p : pointData) {
Long buildOrSysId = p.getParentId();
Long equipSpecificId = p.getSequenceNbr();
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 + equipSpecificId);
map.put("detailInfoApi", equipmentDetailUrl + p.getSequenceNbr());
map.put("detailApi", equipmentDetailUrl + p.getSequenceNbr());
p.setDataConfig(map);
if (StringUtils.isEmpty(id)) {
// 建筑
if (equipSpecificIds.contains(String.valueOf(equipSpecificId))) {
p.setBinding(true);
} else {
p.setBinding(false);
}
} else {
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);
// 树组装优化
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();
}
/**
* 生成树结构
*
* @param allRiskSource
* @return * @return
*/ */
public List<PointTreeVo> transferListTo3dPointTree(List<PointTreeVo> allRiskSource) { public List<PointTreeVo> transferListTo3dPointTree(List<PointTreeVo> allRiskSource) {
......
...@@ -229,6 +229,98 @@ ...@@ -229,6 +229,98 @@
) t ) t
</select> </select>
<select id="getBuildListNew" resultType="com.yeejoin.equipmanage.common.entity.vo.PointTreeVo">
SELECT
t.*
FROM
(
SELECT
ins.instance_id AS sequenceNbr,
nam.field_value AS displayName,
par.field_value AS parentId,
cd.field_value AS equipCode,
bzc.field_value AS bizOrgCode,
ins.group_type as groupType
FROM
wl_form_instance AS ins
LEFT JOIN wl_form_instance AS nam ON nam.instance_id = ins.instance_id
AND nam.field_name = 'name'
LEFT JOIN wl_form_instance AS par ON par.instance_id = ins.instance_id
AND par.field_name = 'parentId'
LEFT JOIN wl_form_instance AS cd ON cd.instance_id = ins.instance_id
AND cd.field_name = 'code'
LEFT JOIN wl_form_instance AS bzc ON bzc.instance_id = ins.instance_id
AND bzc.field_name = 'bizOrgCode'
<where>
1 =1
<if test="bizOrgCode != null and bizOrgCode != ''">
and bzc.field_value LIKE CONCAT(#{bizOrgCode},'%')
</if>
<if test="instanceId != null and instanceId != ''">
and ins.instance_id IN
(
select instance_id from wl_form_instance where field_name = 'parentId' AND field_value in(
select instance_id from wl_form_instance where field_name = 'parentId' AND field_value = #{instanceId})
union
select instance_id from wl_form_instance where field_name = 'parentId' AND field_value = #{instanceId} or
instance_id = #{instanceId}
)
</if>
</where>
GROUP BY
ins.instance_id
ORDER BY
parentId
) t
</select>
<select id="getBuildAll" resultType="com.yeejoin.equipmanage.common.entity.vo.PointTreeVo">
SELECT
t.*
FROM
(
SELECT
id AS sequenceNbr,
group_name AS displayName,
- 1 AS parentId,
NULL AS equipCode,
NULL AS bizOrgCode,
NULL AS groupType
FROM
wl_form_group
WHERE
id = 0 UNION ALL
SELECT
ins.instance_id AS sequenceNbr,
nam.field_value AS displayName,
par.field_value AS parentId,
cd.field_value AS equipCode,
bzc.field_value AS bizOrgCode,
ins.group_type as groupType
FROM
wl_form_instance AS ins
LEFT JOIN wl_form_instance AS nam ON nam.instance_id = ins.instance_id
AND nam.field_name = 'name'
LEFT JOIN wl_form_instance AS par ON par.instance_id = ins.instance_id
AND par.field_name = 'parentId'
LEFT JOIN wl_form_instance AS cd ON cd.instance_id = ins.instance_id
AND cd.field_name = 'code'
LEFT JOIN wl_form_instance AS bzc ON bzc.instance_id = ins.instance_id
AND bzc.field_name = 'bizOrgCode'
<where>
<if test="displayName != null and displayName != ''">
nam.field_value like concat ('%',#{displayName},'%')
</if>
</where>
GROUP BY
ins.instance_id
ORDER BY
parentId
) t
</select>
<select id="get3dBuildList" resultType="com.yeejoin.equipmanage.common.entity.vo.PointTreeVo"> <select id="get3dBuildList" resultType="com.yeejoin.equipmanage.common.entity.vo.PointTreeVo">
select select
id as sequenceNbr, id as sequenceNbr,
......
...@@ -186,6 +186,46 @@ ...@@ -186,6 +186,46 @@
SET scene_id=#{sceneId} SET scene_id=#{sceneId}
where id =#{id} where id =#{id}
</update> </update>
<!-- 全部建筑下不应该存在装备-->
<select id="getPointDataNum" resultType="com.yeejoin.equipmanage.common.entity.vo.PointTreeVo">
SELECT b.* from (
select
'正在加载中...' as displayName,
da.parentId,
da.sequenceNbr
from (
select
stru.source_id as parentId,
spe.id as sequenceNbr
from wl_stock_detail as det
join wl_warehouse_structure as stru on det.warehouse_structure_id = stru.id
join wl_equipment_specific as spe on det.qr_code = spe.qr_code
join wl_equipment_detail as eqdet on det.equipment_detail_id = eqdet.id
join wl_equipment as equ on eqdet.equipment_id = equ.id
join wl_equipment_category as cat on equ.category_id = cat.id
where det.amount > 0
and spe.single = true and stru.source_id != '0'
) as da
GROUP BY da.parentId
<if test="id != null and id !=''">
where find_in_set(#{id}, da.equipSyetemId)
</if>
<if test="id == null">
union all
SELECT
'正在加载中...' as displayName,
vis.source_id AS parentId,
vid.id AS sequenceNbr
FROM
wl_video AS vid
JOIN wl_video_source AS vis ON vid.id = vis.video_id
JOIN wl_warehouse_structure AS stru ON stru.id = vis.source_id
GROUP BY parentId ) as b
GROUP BY b.parentId
</if>
</select>
<select id="getPointData" resultType="com.yeejoin.equipmanage.common.entity.vo.PointTreeVo"> <select id="getPointData" resultType="com.yeejoin.equipmanage.common.entity.vo.PointTreeVo">
select * from ( select * from (
select select
...@@ -273,6 +313,107 @@ ...@@ -273,6 +313,107 @@
) )
</if> </if>
</select> </select>
<select id="getPointDataNew" resultType="com.yeejoin.equipmanage.common.entity.vo.PointTreeVo">
select * from (
select
'component' as template,
true as openStatus,
if(spe.code is null,eqdet.name,concat(eqdet.name,'(',spe.code,')')) as displayName,
'{\"width\": 20, \"height\": 20}'as initStyle,
'CommonEquip' as componentName,
spe.id as sequenceNbr,
'equipment' as componentKey,
'equipment' as `key`,
equ.img as imgPath,
spe.qr_code as equipCode,
-- spe.code as equipCode,
spe.code AS code,
stru.source_id as parentId,
cat.id as equipId,
cat.code as categoryCode,
cat.name as equipName,
spe.system_id as equipSyetemId,
spe.iot_code as iotCode,
equ.id as groupId,
equ.name as groupName,
'' as ip,
'' as token,
'' as address
from wl_stock_detail as det
join wl_warehouse_structure as stru on det.warehouse_structure_id = stru.id
join wl_equipment_specific as spe on det.qr_code = spe.qr_code
join wl_equipment_detail as eqdet on det.equipment_detail_id = eqdet.id
join wl_equipment as equ on eqdet.equipment_id = equ.id
join wl_equipment_category as cat on equ.category_id = cat.id
where det.amount > 0
and spe.single = true
<if test="instanceId != null and instanceId !=''">
and stru.id IN
( select id from wl_warehouse_structure where parent_id in(
select id from wl_warehouse_structure where parent_id = #{instanceId})
union
select id from wl_warehouse_structure where parent_id = #{instanceId}or
id = #{instanceId} )
</if>
) as da
<where>
<if test="displayName != null and displayName != '' ">
da.displayName like concat ('%',#{displayName},'%')
</if>
<choose>
<when test="id != null and id !=''">
find_in_set(#{id}, da.equipSyetemId)
</when>
<when test="id == null">
union all
SELECT * from (
SELECT
'component' AS template,
TRUE AS openStatus,
IF
( vid.CODE IS NULL, vid.NAME, concat( vid.NAME, '(', vid.CODE, ')' ) ) AS displayName,
'{\"width\": 20, \"height\": 20}' AS initStyle,
'CommonEquip' AS componentName,
vid.id AS sequenceNbr,
'equipment' AS componentKey,
'video' AS `key`,
img AS imgPath,
vid.code AS equipCode,
vid.code AS code,
vis.source_id AS parentId,
vid.id AS equipId,
vid.CODE AS categoryCode,
vid.NAME AS equipName,
'' AS equipSyetemId,
'' AS iotCode,
'1000000000000000' AS groupId,
'监控摄像' AS groupName,
url AS ip,
token,
stru.full_name AS address
FROM
wl_video AS vid
JOIN wl_video_source AS vis ON vid.id = vis.video_id
JOIN wl_warehouse_structure AS stru ON stru.id = vis.source_id
<if test="instanceId != null and instanceId !=''">
and stru.id IN
( select id from wl_warehouse_structure where parent_id in(
select id from wl_warehouse_structure where parent_id = #{instanceId})
union
select id from wl_warehouse_structure where parent_id = #{instanceId}or
id = #{instanceId} )
</if>
) as video
<where>
<if test="displayName != null and displayName != '' ">
video.displayName like concat ('%',#{displayName},'%')
</if>
</where>
</when>
</choose>
</where>
</select>
<select id="get3dPointData" resultType="com.yeejoin.equipmanage.common.entity.vo.PointTreeVo"> <select id="get3dPointData" resultType="com.yeejoin.equipmanage.common.entity.vo.PointTreeVo">
SELECT SELECT
* *
......
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