|
|
|
@ -663,17 +663,18 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService { |
|
|
|
} |
|
|
|
|
|
|
|
logger.info("---111-------mainDevices:{}", mainDevices); |
|
|
|
|
|
|
|
// 第一层处理:主设备预置点检查 |
|
|
|
List<Long> deviceIds = mainDevices.stream().map(BasedataDevice::getDeviceId) |
|
|
|
.filter(Objects::nonNull) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
List<BasedataPatrolPoint> basedataPatrolpoints = this.basedataPatrolPointMapper.selectBasedataPatrolPointPresetByMainDeviceIds(deviceIds); |
|
|
|
for (BasedataDevice mainDevice : mainDevices) { |
|
|
|
BasedataPatrolPoint patrolPointMainDevQuery = new BasedataPatrolPoint(); |
|
|
|
patrolPointMainDevQuery.setMainDeviceId(mainDevice.getDeviceId()); |
|
|
|
|
|
|
|
// 查询设备下的预置点 |
|
|
|
BasedataPatrolPoint basedataPatrolpoint = this.basedataPatrolPointMapper.selectBasedataPatrolPointPresetForOne(patrolPointMainDevQuery); |
|
|
|
|
|
|
|
if (basedataPatrolpoint != null) { |
|
|
|
// 复制设备信息到新对象 |
|
|
|
// 查询设备下的预置点是否存在 |
|
|
|
boolean exists = basedataPatrolpoints.stream() |
|
|
|
.filter(Objects::nonNull) |
|
|
|
.anyMatch(device -> mainDevice.getDeviceId().equals(device.getMainDeviceId())); |
|
|
|
if (exists) { |
|
|
|
// 复制设备信息到新对象 |
|
|
|
BasedataDevice mainDeviceForQuery = new BasedataDevice(); |
|
|
|
BeanUtils.copyBeanProp(mainDeviceForQuery, mainDevice); |
|
|
|
mainDeviceExistPointList.add(mainDeviceForQuery); |
|
|
|
@ -695,32 +696,89 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService { |
|
|
|
logger.info("---222------存在预置位的点位设备-mainDeviceExistPointList:{}", mainDeviceExistPointList); |
|
|
|
|
|
|
|
// 第二层处理:设备下的点位信息 |
|
|
|
for (BasedataDevice mainDevice : mainDeviceExistPointList) { |
|
|
|
String mainDeviceName = mainDevice.getDeviceName(); |
|
|
|
|
|
|
|
BasedataPatrolPoint basedataPatrolpoint = new BasedataPatrolPoint(); |
|
|
|
basedataPatrolpoint.setMainDeviceId(mainDevice.getDeviceId()); |
|
|
|
if (!mainDeviceExistPointList.isEmpty()) { |
|
|
|
// 批量获取所有相关点位信息 |
|
|
|
List<Long> mainDeviceIds = mainDeviceExistPointList.stream() |
|
|
|
.map(BasedataDevice::getDeviceId) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
// 查询所有设备下的所有点位信息 |
|
|
|
List<BasedataPatrolPoint> allPatrolPoints = basedataPatrolPointMapper |
|
|
|
.selectBasedataPatrolPointListByMainDeviceIds(mainDeviceIds); |
|
|
|
|
|
|
|
// 按mainDeviceId分组点位信息 |
|
|
|
Map<Long, List<BasedataPatrolPoint>> patrolPointsByMainDevice = allPatrolPoints.stream() |
|
|
|
.filter(Objects::nonNull) |
|
|
|
.collect(Collectors.groupingBy(BasedataPatrolPoint::getMainDeviceId)); |
|
|
|
|
|
|
|
// 批量获取所有相关点位的预置信息 |
|
|
|
List<Long> allPatrolPointIds = allPatrolPoints.stream() |
|
|
|
.filter(Objects::nonNull) |
|
|
|
.map(BasedataPatrolPoint::getPatrolPointId) |
|
|
|
.filter(Objects::nonNull) |
|
|
|
.distinct() |
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
List<BasedataPatrolPointPreset> allPresets = new ArrayList<>(); |
|
|
|
if (!allPatrolPointIds.isEmpty()) { |
|
|
|
allPresets = basedataPatrolPointPresetMapper |
|
|
|
.selectBasedataPatrolPointPresetListByPointIds(allPatrolPointIds); |
|
|
|
} |
|
|
|
|
|
|
|
// 查询设备下的所有点位信息 |
|
|
|
List<BasedataPatrolPoint> patrolpointList = this.basedataPatrolPointMapper.selectBasedataPatrolPointList(basedataPatrolpoint); |
|
|
|
if (patrolpointList.isEmpty()) { |
|
|
|
continue; |
|
|
|
// 按点位ID分组预置信息 |
|
|
|
Map<Long, List<BasedataPatrolPointPreset>> presetsByPointId = allPresets.stream() |
|
|
|
.filter(Objects::nonNull) |
|
|
|
.collect(Collectors.groupingBy(BasedataPatrolPointPreset::getPatrolPointId)); |
|
|
|
|
|
|
|
// 批量获取所有相关的设备信息 |
|
|
|
List<Long> pointDeviceIds = allPatrolPoints.stream() |
|
|
|
.filter(Objects::nonNull) |
|
|
|
.map(BasedataPatrolPoint::getDeviceId) |
|
|
|
.filter(Objects::nonNull) |
|
|
|
.distinct() |
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
// 批量获取所有相关的设备手册信息 |
|
|
|
List<Long> eqpBookIds = allPresets.stream() |
|
|
|
.filter(Objects::nonNull) |
|
|
|
.map(BasedataPatrolPointPreset::getEqpBookId) |
|
|
|
.filter(Objects::nonNull) |
|
|
|
.distinct() |
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
|
|
List<BasedataEqpBook> allEqpBooks = new ArrayList<>(); |
|
|
|
if (!eqpBookIds.isEmpty()) { |
|
|
|
allEqpBooks = basedataEqpbookMapper.selectBasedataEqpBookByEqpBookIds(eqpBookIds); |
|
|
|
} |
|
|
|
|
|
|
|
logger.info("---333-------patrolpointList:{}", patrolpointList); |
|
|
|
Map<Long, BasedataEqpBook> eqpBookMap = allEqpBooks.stream() |
|
|
|
.filter(Objects::nonNull) |
|
|
|
.collect(Collectors.toMap(BasedataEqpBook::getEqpBookId, e -> e)); |
|
|
|
|
|
|
|
Map<Long, BasedataDevice> mapDevToPoint = new HashMap<>(); |
|
|
|
for (BasedataDevice mainDevice : mainDeviceExistPointList) { |
|
|
|
String mainDeviceName = mainDevice.getDeviceName(); |
|
|
|
Long mainDeviceId = mainDevice.getDeviceId(); |
|
|
|
|
|
|
|
// 处理每个点位 |
|
|
|
for (BasedataPatrolPoint patrolpoint : patrolpointList) { |
|
|
|
BasedataPatrolPoint patrolPointIsExistPreset = new BasedataPatrolPoint(); |
|
|
|
patrolPointIsExistPreset.setPatrolPointId(patrolpoint.getPatrolPointId()); |
|
|
|
List<BasedataPatrolPoint> patrolpointList = patrolPointsByMainDevice.getOrDefault( |
|
|
|
mainDeviceId, new ArrayList<>()); |
|
|
|
|
|
|
|
// 检查点位是否存在预置信息 |
|
|
|
BasedataPatrolPoint patrolPointExistOne = this.basedataPatrolPointMapper.selectBasedataPatrolPointPresetForOne(patrolPointIsExistPreset); |
|
|
|
if (patrolpointList.isEmpty()) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
logger.info("---333-------patrolpointList:{}", patrolpointList); |
|
|
|
|
|
|
|
Map<Long, BasedataDevice> mapDevToPoint = new HashMap<>(); |
|
|
|
|
|
|
|
// 合并处理每个点位及其预置位,避免重复查询与循环 |
|
|
|
for (BasedataPatrolPoint patrolpoint : patrolpointList) { |
|
|
|
Long patrolPointId = patrolpoint.getPatrolPointId(); |
|
|
|
List<BasedataPatrolPointPreset> presets = presetsByPointId.getOrDefault( |
|
|
|
patrolPointId, new ArrayList<>()); |
|
|
|
|
|
|
|
if (presets.isEmpty()) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
if (patrolPointExistOne != null) { |
|
|
|
Long mainDeviceId = patrolpoint.getMainDeviceId(); |
|
|
|
Long deviceId = patrolpoint.getDeviceId(); |
|
|
|
|
|
|
|
// 处理非主设备的情况 |
|
|
|
@ -728,10 +786,11 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService { |
|
|
|
this.recursionGetProMainDevice(mainDeviceId, mainDeviceName, deviceId, mainDevVOS, mapDevToPoint); |
|
|
|
} |
|
|
|
|
|
|
|
String pointKey = deviceId + "-" + patrolPointId; |
|
|
|
// 创建点位节点 |
|
|
|
ProMainDevicePatrolEquTreeSelect pointTreeVO = new ProMainDevicePatrolEquTreeSelect(); |
|
|
|
pointTreeVO.setPatrolpointId(patrolpoint.getPatrolPointId()); |
|
|
|
pointTreeVO.setDataId(deviceId + "-" + patrolpoint.getPatrolPointId()); |
|
|
|
pointTreeVO.setPatrolpointId(patrolPointId); |
|
|
|
pointTreeVO.setDataId(pointKey); |
|
|
|
pointTreeVO.setLabel(patrolpoint.getPatrolPointName()); |
|
|
|
pointTreeVO.setPatrolpointName(patrolpoint.getPatrolPointName()); |
|
|
|
pointTreeVO.setMainDeviceName(mainDeviceName); |
|
|
|
@ -741,50 +800,35 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService { |
|
|
|
pointTreeVO.setPositionY(patrolpoint.getPositionY()); |
|
|
|
pointTreeVO.setPositionZ(patrolpoint.getPositionZ()); |
|
|
|
mainDevVOS.add(pointTreeVO); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 处理点位下的预置位 |
|
|
|
for (BasedataPatrolPoint patrolpoint : patrolpointList) { |
|
|
|
BasedataPatrolPointPreset basedataPatrolpointPreset = new BasedataPatrolPointPreset(); |
|
|
|
basedataPatrolpointPreset.setPatrolPointId(patrolpoint.getPatrolPointId()); |
|
|
|
|
|
|
|
// 查询点位下的预置位信息 |
|
|
|
List<BasedataPatrolPointPreset> patrolpointPresetS = this.basedataPatrolPointPresetMapper.selectBasedataPatrolPointPresetList(basedataPatrolpointPreset); |
|
|
|
if (patrolpointPresetS.isEmpty()) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
logger.info("---444-------patrolpointPresetS:{}", patrolpointPresetS); |
|
|
|
|
|
|
|
Map<Long, Long> map = new HashMap<>(); |
|
|
|
logger.info("---444-------patrolpointPresetS:{}", presets); |
|
|
|
|
|
|
|
for (BasedataPatrolPointPreset preset : patrolpointPresetS) { |
|
|
|
if (map.containsKey(preset.getEqpBookId())) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
// 添加预置位节点(去重eqpBookId) |
|
|
|
Set<Long> addedEqpBookIds = new HashSet<>(); |
|
|
|
for (BasedataPatrolPointPreset preset : presets) { |
|
|
|
Long eqpBookId = preset.getEqpBookId(); |
|
|
|
if (eqpBookId == null || addedEqpBookIds.contains(eqpBookId)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
ProMainDevicePatrolEquTreeSelect pointPreSetTreeVO = new ProMainDevicePatrolEquTreeSelect(); |
|
|
|
pointPreSetTreeVO.setParentId(patrolpoint.getDeviceId() + "-" + patrolpoint.getPatrolPointId()); |
|
|
|
pointPreSetTreeVO.setEqpbookId(preset.getEqpBookId()); |
|
|
|
pointPreSetTreeVO.setPresetCode(preset.getPresetCode()); |
|
|
|
|
|
|
|
logger.info("---555-------BasedataPatrolPointPreset:{}", preset); |
|
|
|
|
|
|
|
if (preset.getEqpBookId() != null) { |
|
|
|
BasedataEqpBook basedataEqpbook = this.basedataEqpbookMapper.selectBasedataEqpBookByEqpBookId(preset.getEqpBookId()); |
|
|
|
if (basedataEqpbook != null) { |
|
|
|
pointPreSetTreeVO.setPatroldeviceName(basedataEqpbook.getPatrolDeviceName()); |
|
|
|
pointPreSetTreeVO.setMainDeviceName(basedataEqpbook.getPatrolDeviceName()); |
|
|
|
pointPreSetTreeVO.setLabel(basedataEqpbook.getPatrolDeviceName()); |
|
|
|
pointPreSetTreeVO.setPatroldeviceCode(basedataEqpbook.getPatrolDeviceCode()); |
|
|
|
pointPreSetTreeVO.setPatroldeviceName(basedataEqpbook.getPatrolDeviceName()); |
|
|
|
pointPreSetTreeVO.setDataId(patrolpoint.getDeviceId() + "-" + patrolpoint.getPatrolPointId() + basedataEqpbook.getEqpBookId()); |
|
|
|
pointPreSetTreeVO.setPatroldeviceFlag("Yes"); |
|
|
|
|
|
|
|
map.put(basedataEqpbook.getEqpBookId(), basedataEqpbook.getEqpBookId()); |
|
|
|
mainDevVOS.add(pointPreSetTreeVO); |
|
|
|
BasedataEqpBook basedataEqpbook = eqpBookMap.get(eqpBookId); |
|
|
|
if (basedataEqpbook == null) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
ProMainDevicePatrolEquTreeSelect pointPreSetTreeVO = new ProMainDevicePatrolEquTreeSelect(); |
|
|
|
pointPreSetTreeVO.setParentId(pointKey); |
|
|
|
pointPreSetTreeVO.setEqpbookId(eqpBookId); |
|
|
|
pointPreSetTreeVO.setPresetCode(preset.getPresetCode()); |
|
|
|
pointPreSetTreeVO.setPatroldeviceName(basedataEqpbook.getPatrolDeviceName()); |
|
|
|
pointPreSetTreeVO.setMainDeviceName(basedataEqpbook.getPatrolDeviceName()); |
|
|
|
pointPreSetTreeVO.setLabel(basedataEqpbook.getPatrolDeviceName()); |
|
|
|
pointPreSetTreeVO.setPatroldeviceCode(basedataEqpbook.getPatrolDeviceCode()); |
|
|
|
pointPreSetTreeVO.setDataId(pointKey + basedataEqpbook.getEqpBookId()); |
|
|
|
pointPreSetTreeVO.setPatroldeviceFlag("Yes"); |
|
|
|
|
|
|
|
mainDevVOS.add(pointPreSetTreeVO); |
|
|
|
addedEqpBookIds.add(eqpBookId); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|