|
|
|
@ -26,11 +26,7 @@ import com.inspect.base.core.utils.DateUtils; |
|
|
|
import com.inspect.base.core.utils.StringUtils; |
|
|
|
import com.inspect.base.core.utils.bean.BeanUtils; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.Iterator; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
import org.slf4j.Logger; |
|
|
|
@ -323,7 +319,7 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService { |
|
|
|
return !this.getChildList(list, t).isEmpty(); |
|
|
|
} |
|
|
|
|
|
|
|
public List<ProMainDevicePatrolEquTreeSelect> treeProMainDevicePatrolEquSelect(List<BasedataDevice> mainDevices) { |
|
|
|
public List<ProMainDevicePatrolEquTreeSelect> treeProMainDevicePatrolEquSelectOld(List<BasedataDevice> mainDevices) { |
|
|
|
List<ProMainDevicePatrolEquTreeSelect> mainDevVOS = new ArrayList<>(); |
|
|
|
List<BasedataDevice> mainDeviceExistPointList = new ArrayList<>(); |
|
|
|
if (!mainDevices.isEmpty()) { |
|
|
|
@ -335,7 +331,9 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService { |
|
|
|
mainDevice = iterator.next(); |
|
|
|
BasedataPatrolPoint patrolPointMainDevQuery = new BasedataPatrolPoint(); |
|
|
|
patrolPointMainDevQuery.setMainDeviceId(mainDevice.getDeviceId()); |
|
|
|
// 查询设备下有预置点的点位信息(一个) |
|
|
|
basedataPatrolpoint = this.basedataPatrolPointMapper.selectBasedataPatrolPointPresetForOne(patrolPointMainDevQuery); |
|
|
|
// 该设备下存在预置点位信息 |
|
|
|
if (null != basedataPatrolpoint) { |
|
|
|
BasedataDevice mainDeviceForQuery = new BasedataDevice(); |
|
|
|
BeanUtils.copyBeanProp(mainDeviceForQuery, mainDevice); |
|
|
|
@ -349,12 +347,13 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService { |
|
|
|
mainDevVO.setPositionX(mainDevice.getPositionX()); |
|
|
|
mainDevVO.setPositionY(mainDevice.getPositionY()); |
|
|
|
mainDevVO.setPositionZ(mainDevice.getPositionZ()); |
|
|
|
// 添加设备信息 |
|
|
|
mainDevVOS.add(mainDevVO); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
iterator = mainDeviceExistPointList.iterator(); |
|
|
|
logger.info("---222-------mainDeviceExistPointList:{}", mainDeviceExistPointList); |
|
|
|
logger.info("---222------存在预置位的点位设备-mainDeviceExistPointList:{}", mainDeviceExistPointList); |
|
|
|
label70: |
|
|
|
while (true) { |
|
|
|
List patrolpointList; |
|
|
|
@ -370,6 +369,7 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService { |
|
|
|
basedataPatrolpoint = new BasedataPatrolPoint(); |
|
|
|
basedataPatrolpoint.setMainDeviceId(mainDevice.getDeviceId()); |
|
|
|
mapDevToPoint = new HashMap<>(); |
|
|
|
// 查询设备下的所有点位信息 |
|
|
|
patrolpointList = this.basedataPatrolPointMapper.selectBasedataPatrolPointList(basedataPatrolpoint); |
|
|
|
} while (patrolpointList.isEmpty()); |
|
|
|
|
|
|
|
@ -380,7 +380,9 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService { |
|
|
|
patrolpoint = (BasedataPatrolPoint) iterator1.next(); |
|
|
|
BasedataPatrolPoint patrolPointIsExistPreset = new BasedataPatrolPoint(); |
|
|
|
patrolPointIsExistPreset.setPatrolPointId(patrolpoint.getPatrolPointId()); |
|
|
|
// 判断点位下是否存在预置信息 |
|
|
|
BasedataPatrolPoint patrolPointExistOne = this.basedataPatrolPointMapper.selectBasedataPatrolPointPresetForOne(patrolPointIsExistPreset); |
|
|
|
// 存在预置信息 |
|
|
|
if (null != patrolPointExistOne) { |
|
|
|
Long mainDeviceId = patrolpoint.getMainDeviceId(); |
|
|
|
Long deviceId = patrolpoint.getDeviceId(); |
|
|
|
@ -399,6 +401,7 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService { |
|
|
|
pointTreeVO.setPositionX(patrolpoint.getPositionX()); |
|
|
|
pointTreeVO.setPositionY(patrolpoint.getPositionY()); |
|
|
|
pointTreeVO.setPositionZ(patrolpoint.getPositionZ()); |
|
|
|
// 添加点位信息 |
|
|
|
mainDevVOS.add(pointTreeVO); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -415,6 +418,7 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService { |
|
|
|
patrolpoint = (BasedataPatrolPoint) iterator1.next(); |
|
|
|
BasedataPatrolPointPreset basedataPatrolpointPreset = new BasedataPatrolPointPreset(); |
|
|
|
basedataPatrolpointPreset.setPatrolPointId(patrolpoint.getPatrolPointId()); |
|
|
|
// 查询点位下预置位信息 |
|
|
|
patrolpointPresetS = this.basedataPatrolPointPresetMapper.selectBasedataPatrolPointPresetList(basedataPatrolpointPreset); |
|
|
|
} while (patrolpointPresetS.isEmpty()); |
|
|
|
logger.info("---444-------patrolpointPresetS:{}", patrolpointPresetS); |
|
|
|
@ -438,6 +442,7 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService { |
|
|
|
pointPreSetTreeVO.setDataId(patrolpoint.getDeviceId() + "-" + patrolpoint.getPatrolPointId() + basedataEqpbook.getEqpBookId()); |
|
|
|
pointPreSetTreeVO.setPatroldeviceFlag("Yes"); |
|
|
|
map.put(basedataEqpbook.getEqpBookId(), basedataEqpbook.getEqpBookId()); |
|
|
|
// 添加巡视设备(ebook)信息 |
|
|
|
mainDevVOS.add(pointPreSetTreeVO); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -450,7 +455,193 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService { |
|
|
|
return (List<ProMainDevicePatrolEquTreeSelect>) ProMainDevicePatrolEquTreeSelectUtil.buildDeviceTree(mainDevVOS); |
|
|
|
} |
|
|
|
|
|
|
|
public void recursionGetProMainDevice(Long mainDeviceId, String mainDeviceName, Long deviceId, List<ProMainDevicePatrolEquTreeSelect> mainDevVOS, HashMap<Long, BasedataDevice> mapDevToPoint) { |
|
|
|
|
|
|
|
public List<ProMainDevicePatrolEquTreeSelect> treeProMainDevicePatrolEquSelect(List<BasedataDevice> mainDevices) { |
|
|
|
List<ProMainDevicePatrolEquTreeSelect> mainDevVOS = new ArrayList<>(); |
|
|
|
List<BasedataDevice> mainDeviceExistPointList = new ArrayList<>(); |
|
|
|
|
|
|
|
if (mainDevices == null || mainDevices.isEmpty()) { |
|
|
|
return mainDevVOS; |
|
|
|
} |
|
|
|
|
|
|
|
logger.info("---111-------mainDevices:{}", mainDevices); |
|
|
|
|
|
|
|
// 第一层处理:主设备预置点检查 |
|
|
|
for (BasedataDevice mainDevice : mainDevices) { |
|
|
|
BasedataPatrolPoint patrolPointMainDevQuery = new BasedataPatrolPoint(); |
|
|
|
patrolPointMainDevQuery.setMainDeviceId(mainDevice.getDeviceId()); |
|
|
|
|
|
|
|
// 查询设备下的预置点 |
|
|
|
BasedataPatrolPoint basedataPatrolpoint = this.basedataPatrolPointMapper.selectBasedataPatrolPointPresetForOne(patrolPointMainDevQuery); |
|
|
|
|
|
|
|
if (basedataPatrolpoint != null) { |
|
|
|
// 复制设备信息到新对象 |
|
|
|
BasedataDevice mainDeviceForQuery = new BasedataDevice(); |
|
|
|
BeanUtils.copyBeanProp(mainDeviceForQuery, mainDevice); |
|
|
|
mainDeviceExistPointList.add(mainDeviceForQuery); |
|
|
|
|
|
|
|
// 创建主设备节点 |
|
|
|
ProMainDevicePatrolEquTreeSelect mainDevVO = new ProMainDevicePatrolEquTreeSelect(); |
|
|
|
mainDevVO.setDataId(String.valueOf(mainDevice.getDeviceId())); |
|
|
|
mainDevVO.setMainDeviceId(mainDevice.getDeviceId()); |
|
|
|
mainDevVO.setLabel(mainDevice.getDeviceName()); |
|
|
|
mainDevVO.setMainDeviceName(mainDevice.getDeviceName()); |
|
|
|
mainDevVO.setPowerMainEquFlag("Yes"); |
|
|
|
mainDevVO.setPositionX(mainDevice.getPositionX()); |
|
|
|
mainDevVO.setPositionY(mainDevice.getPositionY()); |
|
|
|
mainDevVO.setPositionZ(mainDevice.getPositionZ()); |
|
|
|
mainDevVOS.add(mainDevVO); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
logger.info("---222------存在预置位的点位设备-mainDeviceExistPointList:{}", mainDeviceExistPointList); |
|
|
|
|
|
|
|
// 第二层处理:设备下的点位信息 |
|
|
|
for (BasedataDevice mainDevice : mainDeviceExistPointList) { |
|
|
|
String mainDeviceName = mainDevice.getDeviceName(); |
|
|
|
|
|
|
|
BasedataPatrolPoint basedataPatrolpoint = new BasedataPatrolPoint(); |
|
|
|
basedataPatrolpoint.setMainDeviceId(mainDevice.getDeviceId()); |
|
|
|
|
|
|
|
// 查询设备下的所有点位信息 |
|
|
|
List<BasedataPatrolPoint> patrolpointList = this.basedataPatrolPointMapper.selectBasedataPatrolPointList(basedataPatrolpoint); |
|
|
|
if (patrolpointList.isEmpty()) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
logger.info("---333-------patrolpointList:{}", patrolpointList); |
|
|
|
|
|
|
|
Map<Long, BasedataDevice> mapDevToPoint = new HashMap<>(); |
|
|
|
|
|
|
|
// 处理每个点位 |
|
|
|
for (BasedataPatrolPoint patrolpoint : patrolpointList) { |
|
|
|
BasedataPatrolPoint patrolPointIsExistPreset = new BasedataPatrolPoint(); |
|
|
|
patrolPointIsExistPreset.setPatrolPointId(patrolpoint.getPatrolPointId()); |
|
|
|
|
|
|
|
// 检查点位是否存在预置信息 |
|
|
|
BasedataPatrolPoint patrolPointExistOne = this.basedataPatrolPointMapper.selectBasedataPatrolPointPresetForOne(patrolPointIsExistPreset); |
|
|
|
|
|
|
|
if (patrolPointExistOne != null) { |
|
|
|
Long mainDeviceId = patrolpoint.getMainDeviceId(); |
|
|
|
Long deviceId = patrolpoint.getDeviceId(); |
|
|
|
|
|
|
|
// 处理非主设备的情况 |
|
|
|
if (deviceId.longValue() != mainDeviceId.longValue() && !mapDevToPoint.containsKey(deviceId)) { |
|
|
|
this.recursionGetProMainDevice(mainDeviceId, mainDeviceName, deviceId, mainDevVOS, mapDevToPoint); |
|
|
|
} |
|
|
|
|
|
|
|
// 创建点位节点 |
|
|
|
ProMainDevicePatrolEquTreeSelect pointTreeVO = new ProMainDevicePatrolEquTreeSelect(); |
|
|
|
pointTreeVO.setPatrolpointId(patrolpoint.getPatrolPointId()); |
|
|
|
pointTreeVO.setDataId(deviceId + "-" + patrolpoint.getPatrolPointId()); |
|
|
|
pointTreeVO.setLabel(patrolpoint.getPatrolPointName()); |
|
|
|
pointTreeVO.setPatrolpointName(patrolpoint.getPatrolPointName()); |
|
|
|
pointTreeVO.setMainDeviceName(mainDeviceName); |
|
|
|
pointTreeVO.setParentId(String.valueOf(deviceId)); |
|
|
|
pointTreeVO.setPatrolpointFlag("Yes"); |
|
|
|
pointTreeVO.setPositionX(patrolpoint.getPositionX()); |
|
|
|
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<>(); |
|
|
|
|
|
|
|
for (BasedataPatrolPointPreset preset : patrolpointPresetS) { |
|
|
|
if (map.containsKey(preset.getEqpBookId())) { |
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
logger.info("----------------mainDevVOS:{} ", mainDevVOS); |
|
|
|
return ProMainDevicePatrolEquTreeSelectUtil.buildDeviceTree(mainDevVOS); |
|
|
|
} |
|
|
|
|
|
|
|
public void recursionGetProMainDevice(Long mainDeviceId, String mainDeviceName, Long deviceId, |
|
|
|
List<ProMainDevicePatrolEquTreeSelect> mainDevVOS, |
|
|
|
Map<Long, BasedataDevice> mapDevToPoint) { |
|
|
|
if (mapDevToPoint.containsKey(deviceId)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (mainDeviceId.longValue() != deviceId.longValue()) { |
|
|
|
BasedataDevice basedataDevice = this.basedataDeviceMapper.selectBasedataDeviceByDeviceId(deviceId); |
|
|
|
if (basedataDevice == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
ProMainDevicePatrolEquTreeSelect mainDevVO = new ProMainDevicePatrolEquTreeSelect(); |
|
|
|
mainDevVO.setDataId(String.valueOf(deviceId)); |
|
|
|
mainDevVO.setLabel(basedataDevice.getDeviceName()); |
|
|
|
mainDevVO.setParentId(String.valueOf(basedataDevice.getParentId())); |
|
|
|
mainDevVO.setMainDeviceId(mainDeviceId); |
|
|
|
mainDevVO.setMainDeviceName(mainDeviceName); |
|
|
|
mainDevVO.setComponentName(basedataDevice.getDeviceName()); |
|
|
|
mainDevVO.setDeviceId(deviceId); |
|
|
|
mainDevVO.setPowerMainEquFlag("No"); |
|
|
|
mainDevVO.setComponentFlag("Yes"); |
|
|
|
mainDevVO.setPositionX(basedataDevice.getPositionX()); |
|
|
|
mainDevVO.setPositionY(basedataDevice.getPositionY()); |
|
|
|
mainDevVO.setPositionZ(basedataDevice.getPositionZ()); |
|
|
|
|
|
|
|
mainDevVOS.add(mainDevVO); |
|
|
|
mapDevToPoint.put(deviceId, basedataDevice); |
|
|
|
|
|
|
|
if (basedataDevice.getParentId() == null || |
|
|
|
mainDeviceId.longValue() == basedataDevice.getParentId().longValue()) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
this.recursionGetProMainDevice( |
|
|
|
mainDeviceId, |
|
|
|
mainDeviceName, |
|
|
|
basedataDevice.getParentId(), |
|
|
|
mainDevVOS, |
|
|
|
mapDevToPoint |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void recursionGetProMainDeviceOld(Long mainDeviceId, String mainDeviceName, Long deviceId, List<ProMainDevicePatrolEquTreeSelect> mainDevVOS, HashMap<Long, BasedataDevice> mapDevToPoint) { |
|
|
|
if (!mapDevToPoint.containsKey(deviceId)) { |
|
|
|
if (mainDeviceId.longValue() != deviceId.longValue()) { |
|
|
|
BasedataDevice basedataDevice = this.basedataDeviceMapper.selectBasedataDeviceByDeviceId(deviceId); |
|
|
|
@ -475,7 +666,7 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService { |
|
|
|
} |
|
|
|
|
|
|
|
deviceId = basedataDevice.getParentId(); |
|
|
|
this.recursionGetProMainDevice(mainDeviceId, mainDeviceName, deviceId, mainDevVOS, mapDevToPoint); |
|
|
|
this.recursionGetProMainDeviceOld(mainDeviceId, mainDeviceName, deviceId, mainDevVOS, mapDevToPoint); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|