Browse Source

/*

1. 绍兴站新需求-卡片-数据趋势:只显示有表计读数点位的区域间隔设备,完成开发后端接口-treeAreaDeviceSelectFilterByMeter;
2. 绍兴站新需求-卡片-点位管理:巡视点位设备树不显示无人机、机器人、安防摄像头、生活区域、新增相机、机器狗,完成开发后端接口-treeAreaDeviceSelectFilterByPreset;
3. 绍兴站新需求-卡片-缺陷汇总:要求不显示没有点位的区域间隔设备,完成接口-treeAreaDeviceSelectFilterByFault。
*/
master
htjcAdmin 3 months ago
parent
commit
2a6691726c
6 changed files with 180 additions and 12 deletions
  1. +9
    -0
      inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/controller/BasedataDeviceController.java
  2. +39
    -9
      inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/domain/vo/AreaDeviceTreeSelect.java
  3. +2
    -0
      inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/mapper/BasedataDeviceMapper.java
  4. +2
    -0
      inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/service/IBasedataDeviceService.java
  5. +70
    -2
      inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/service/impl/BasedataDeviceServiceImpl.java
  6. +58
    -1
      inspect-metadata/src/main/resources/mapper/prodevmnt/BasedataDeviceMapper.xml

+ 9
- 0
inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/controller/BasedataDeviceController.java View File

@ -209,6 +209,15 @@ public class BasedataDeviceController extends BaseController {
: AjaxResult.success(new JSONArray());
}
@GetMapping({"/treeAreaDeviceSelectFilterByFault"})
public AjaxResult treeAreaDeviceSelectFilterByFault(BaseDataArea baseDataArea) {
log.info("treeAreaDeviceSelectFilterByFault param: {}", baseDataArea);
List<BaseDataArea> areaList = baseDataAreaService.selectAreaList(baseDataArea);
return !areaList.isEmpty()
? AjaxResult.success(basedataDeviceService.buildAreaDeviceTreeSelectByAreasFilterByFault(areaList))
: AjaxResult.success(new JSONArray());
}
@GetMapping({"/treeProMainDevicePatrolEquSelect"})
public AjaxResult treeProMainDevicePatrolEquSelect(BasedataDevice basedataDevice) {
logger.info("[META] device: {}", basedataDevice);


+ 39
- 9
inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/domain/vo/AreaDeviceTreeSelect.java View File

@ -6,7 +6,9 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
public class AreaDeviceTreeSelect implements Serializable {
@ -218,20 +220,48 @@ public class AreaDeviceTreeSelect implements Serializable {
public void setPatrolPointName(String patrolPointName) {
this.patrolPointName = patrolPointName;
}
// public List<AreaDeviceTreeSelect> cleanEmptyPatrolPoints() {
// // 递归清理
// if (children != null) {
// // 清理子节点
// for (int i = children.size() - 1; i >= 0; i--) {
// AreaDeviceTreeSelect child = children.get(i);
// child.cleanEmptyPatrolPoints(); // 递归清理子节点
// // 如果子节点是叶子节点且 patrolPointId 为空则移除
// if (child.getChildren() == null || child.getChildren().isEmpty()) {
// if (child.getPatrolPointId() == null) {
// children.remove(i);
// }
// }
// }
// }
// return children;
// }
public List<AreaDeviceTreeSelect> cleanEmptyPatrolPoints() {
// 递归清理
if (children != null) {
// 清理子节点
for (int i = children.size() - 1; i >= 0; i--) {
AreaDeviceTreeSelect child = children.get(i);
child.cleanEmptyPatrolPoints(); // 递归清理子节点
// 如果子节点是叶子节点且 patrolPointId 为空则移除
if (child.getChildren() == null || child.getChildren().isEmpty()) {
if (child.getPatrolPointId() == null) {
children.remove(i);
}
Set<String> seenDataIds = new HashSet<>();
List<AreaDeviceTreeSelect> uniqueChildren = new ArrayList<>();
for (AreaDeviceTreeSelect child : children) {
// 递归清理子节点
child.cleanEmptyPatrolPoints();
// 检查 patrolPointId 是否为空且没有子节点
if (child.getPatrolPointId() == null && (child.getChildren() == null || child.getChildren().isEmpty())) {
continue; // 跳过此子节点
}
// 检查 dataId 是否已存在
if (!seenDataIds.contains(child.getDataId())) {
seenDataIds.add(child.getDataId());
uniqueChildren.add(child); // 只保留第一个出现的子节点
}
}
// 更新 children 列表为唯一的子节点
this.children = uniqueChildren;
}
return children;
}


+ 2
- 0
inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/mapper/BasedataDeviceMapper.java View File

@ -17,6 +17,8 @@ public interface BasedataDeviceMapper {
List<BasedataDevice> selectBasedataDeviceListFilterByMeter(BasedataDevice device);
List<BasedataDevice> selectBasedataDeviceListWithPreset(BasedataDevice device);
List<TreeModule> selectAreaAndDeviceTree(BasedataDevice device);
List<TreeModule> selectPointList();


+ 2
- 0
inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/service/IBasedataDeviceService.java View File

@ -52,4 +52,6 @@ public interface IBasedataDeviceService {
List<AreaDeviceTreeSelect> buildAreaDeviceTreeSelectByAreasFilterByPreset(List<BaseDataArea> areas, List<String> filterNameList);
List<AreaDeviceTreeSelect> buildAreaDeviceTreeSelectByAreasFilterByMeter(List<BaseDataArea> areas);
List<AreaDeviceTreeSelect> buildAreaDeviceTreeSelectByAreasFilterByFault(List<BaseDataArea> areas);
}

+ 70
- 2
inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/service/impl/BasedataDeviceServiceImpl.java View File

@ -281,7 +281,7 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService {
while (iterator.hasNext()) {
basedataDevice = iterator.next();
logger.info("!!!!!!!!!patrolPointId: {}, patrolPointName: {}", basedataDevice.getPatrolPointId(), basedataDevice.getPatrolPointName());
logger.info("DEVICE_TREE_BY_METER patrolPointId: {}, patrolPointName: {}", basedataDevice.getPatrolPointId(), basedataDevice.getPatrolPointName());
AreaDeviceTreeSelect deviceVO = new AreaDeviceTreeSelect();
StringBuilder idBuilder = new StringBuilder();
StringBuilder pIdBuilder = new StringBuilder();
@ -301,7 +301,7 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService {
deviceVO.setDeviceHigh(basedataDevice.getDeviceHeight());
deviceVO.setPatrolPointId(basedataDevice.getPatrolPointId());
deviceVO.setPatrolPointName(basedataDevice.getPatrolPointName());
deviceVO.setDeviceName(basedataDevice.getPatrolPointName());
//deviceVO.setDeviceName(basedataDevice.getPatrolPointName());
areaVOS.add(deviceVO);
}
@ -312,6 +312,74 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService {
return results;
}
public List<AreaDeviceTreeSelect> buildAreaDeviceTreeSelectByAreasFilterByFault(List<BaseDataArea> areas) {
ArrayList<Long> areaIdList = new ArrayList<>();
HashMap<Long, BaseDataArea> areaMap = new HashMap<>();
HashMap<Long, BasedataDevice> deviceHashMap = new HashMap<>();
List<AreaDeviceTreeSelect> areaVOS = new ArrayList<>();
for (BaseDataArea area : areas) {
areaIdList.add(area.getAreaId());
areaMap.put(area.getAreaId(), area);
AreaDeviceTreeSelect areaVO = new AreaDeviceTreeSelect();
areaVO.setDataId(String.valueOf(area.getAreaId()));
areaVO.setParentId(String.valueOf(area.getParentId()));
areaVO.setAreaId(area.getAreaId());
areaVO.setAreaFlag("Yes");
areaVO.setAreaParentId(area.getParentId());
areaVO.setAreaName(area.getAreaName());
areaVO.setAreaType(area.getAreaType());
areaVOS.add(areaVO);
}
BasedataDevice basedataDeviceQuery = new BasedataDevice();
Map<String, Object> params = new HashMap<>();
params.put("areaIdList", areaIdList);
basedataDeviceQuery.setParams(params);
List<BasedataDevice> deviceList = basedataDeviceMapper.selectBasedataDeviceListWithPreset(basedataDeviceQuery);
Iterator<BasedataDevice> iterator = deviceList.iterator();
BasedataDevice basedataDevice;
while (iterator.hasNext()) {
basedataDevice = iterator.next();
deviceHashMap.put(basedataDevice.getDeviceId(), basedataDevice);
}
iterator = deviceList.iterator();
while (iterator.hasNext()) {
basedataDevice = iterator.next();
logger.info("DEVICE_TREE_BY_FAULT patrolPointId: {}, patrolPointName: {}", basedataDevice.getPatrolPointId(), basedataDevice.getPatrolPointName());
AreaDeviceTreeSelect deviceVO = new AreaDeviceTreeSelect();
StringBuilder idBuilder = new StringBuilder();
StringBuilder pIdBuilder = new StringBuilder();
getAreaDeviceTreeDeviceCode(basedataDevice.getDeviceId(), areaMap, deviceHashMap, idBuilder, pIdBuilder);
deviceVO.setDataId(idBuilder.toString());
deviceVO.setParentId(pIdBuilder.toString());
deviceVO.setAreaId(basedataDevice.getAreaId());
deviceVO.setDeviceParentId(basedataDevice.getParentId());
deviceVO.setDeviceId(basedataDevice.getDeviceId());
deviceVO.setDeviceName(basedataDevice.getDeviceName());
deviceVO.setPowerMainEquFlag(basedataDevice.getPowerMainEquFlag());
deviceVO.setPositionX(basedataDevice.getPositionX());
deviceVO.setPositionY(basedataDevice.getPositionY());
deviceVO.setPositionZ(basedataDevice.getPositionZ());
deviceVO.setDeviceLength(basedataDevice.getDeviceLength());
deviceVO.setDeviceWidth(basedataDevice.getDeviceWidth());
deviceVO.setDeviceHigh(basedataDevice.getDeviceHeight());
deviceVO.setPatrolPointId(basedataDevice.getPatrolPointId());
deviceVO.setPatrolPointName(basedataDevice.getPatrolPointName());
//deviceVO.setDeviceName(basedataDevice.getPatrolPointName());
areaVOS.add(deviceVO);
}
List<AreaDeviceTreeSelect> results = AreaDeviceTreeSelectUtil.buildDeviceTreeByAreaMeter(areaVOS);
for (AreaDeviceTreeSelect area : results) {
area.cleanEmptyPatrolPoints();
}
return results;
}
private void getAreaDeviceTreeDeviceCode(Long deviceId, HashMap<Long, BaseDataArea> areaMap, HashMap<Long, BasedataDevice> deviceHashMap, StringBuilder idBuilder, StringBuilder pIdBuilder) {


+ 58
- 1
inspect-metadata/src/main/resources/mapper/prodevmnt/BasedataDeviceMapper.xml View File

@ -139,7 +139,64 @@
<select id="selectBasedataDeviceListFilterByMeter" parameterType="BasedataDevice" resultMap="BasedataDeviceResult">
select a.*,b.patrol_point_id as patrol_point_id,b.patrol_point_name as patrol_point_name
from basedata_device a
inner join basedata_patrolpoint b on a.device_id=b.main_device_id and b.alg_subtype_ids like concat('%', '52', '%')
-- left join basedata_patrolpoint b on (a.device_id=b.device_id or a.device_id=b.main_device_id) and b.alg_subtype_ids like concat('%', '52', '%')
left join basedata_patrolpoint b on (a.device_id=b.device_id and b.alg_subtype_ids like concat('%', '52', '%'))
<where>
<if test="deviceId != null and deviceId != ''">and a.device_id = #{deviceId}</if>
<if test="deviceCode != null and deviceCode != ''">and a.device_code = #{deviceCode}</if>
<if test="deviceName != null and deviceName != ''">and a.device_name like concat('%', #{deviceName}, '%')
</if>
<if test="manufacturer != null and manufacturer != ''">and a.manufacturer = #{manufacturer}</if>
<if test="parentId != null ">and a.parent_id = #{parentId}</if>
<if test="ancestors != null and ancestors != ''">and a.ancestors = #{ancestors}</if>
<if test="areaId != null and areaId != ''">and a.area_id = #{areaId}</if>
<if test="areaName != null and areaName != ''">and a.area_name like concat('%', #{areaName}, '%')</if>
<if test="deviceTypeId != null and deviceTypeId != ''">and a.device_type_id = #{deviceTypeId}</if>
<if test="deviceTypeName != null and deviceTypeName != ''">and a.device_type_name like concat('%',
#{deviceTypeName}, '%')
</if>
<if test="powerMainEquFlag != null and powerMainEquFlag != ''">and a.power_main_equ_flag =
#{powerMainEquFlag}
</if>
<if test="deviceModel != null and deviceModel != ''">and a.device_model = #{deviceModel}</if>
<if test="phyAssetId != null and phyAssetId != ''">and a.phy_asset_id = #{phyAssetId}</if>
<if test="stationNo != null and stationNo != ''">and a.station_no = #{stationNo}</if>
<if test="monitorIndexNo != null and monitorIndexNo != ''">and a.monitor_index_no = #{monitorIndexNo}</if>
<if test="phaseNum != null and phaseNum != ''">and a.phase_num = #{phaseNum}</if>
<if test="phase != null and phase != ''">and a.phase = #{phase}</if>
<if test="status != null and status != ''">and a.status = #{status}</if>
<if test="positionX != null and positionX != ''">and a.position_x = #{positionX}</if>
<if test="positionY != null and positionY != ''">and a.position_y = #{positionY}</if>
<if test="positionZ != null and positionZ != ''">and a.position_z = #{positionZ}</if>
<if test="deviceLength != null and deviceLength != ''">and a.device_length = #{deviceLength}</if>
<if test="deviceWidth != null and deviceWidth != ''">and a.device_width = #{deviceWidth}</if>
<if test="deviceHeight != null and deviceHeight != ''">and a.device_height = #{deviceHeight}</if>
<if test="installPosition != null and installPosition != ''">and a.install_position = #{installPosition}</if>
<if test="orderNum != null and orderNum != ''">and a.order_num = #{orderNum}</if>
<if test="oldDeviceId != null and oldDeviceId != ''">and a.old_device_id = #{oldDeviceId}</if>
<if test="deviceIdAll != null and deviceIdAll != ''">
and a.device_id in
<foreach item="algId" collection="deviceIdListAll" open="(" separator="," close=")">
#{algId}
</foreach>
</if>
<!-- 区域数组查询 -->
<if test="params != null">
<if test="params.areaIdList != null">
and a.area_id in
<foreach item="item" collection="params.areaIdList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</if>
</where>
</select>
<select id="selectBasedataDeviceListWithPreset" parameterType="BasedataDevice" resultMap="BasedataDeviceResult">
select a.*,b.patrol_point_id as patrol_point_id,b.patrol_point_name as patrol_point_name
from basedata_device a
left join basedata_patrolpoint b on a.device_id=b.device_id
<where>
<if test="deviceId != null and deviceId != ''">and a.device_id = #{deviceId}</if>
<if test="deviceCode != null and deviceCode != ''">and a.device_code = #{deviceCode}</if>


Loading…
Cancel
Save