|
|
@@ -11,16 +11,11 @@ import com.zksy.base.domain.*;
|
|
|
import com.zksy.base.mapper.*;
|
|
|
import com.zksy.base.alarm.domain.WarningThreshold;
|
|
|
import com.zksy.base.alarm.mapper.WarningThresholdMapper;
|
|
|
-import com.zksy.base.domain.EquipmentBase;
|
|
|
-import com.zksy.base.domain.EquipmentMaintain;
|
|
|
-import com.zksy.base.domain.EquipmentStatus;
|
|
|
-import com.zksy.base.domain.EquipmentType;
|
|
|
+import com.zksy.base.domain.*;
|
|
|
+import com.zksy.base.domain.vo.EquipmentFullVO;
|
|
|
import com.zksy.base.manhole.domain.ManholeData;
|
|
|
import com.zksy.base.manhole.mapper.ManholeDataMapper;
|
|
|
-import com.zksy.base.mapper.EquipmentBaseMapper;
|
|
|
-import com.zksy.base.mapper.EquipmentMaintainMapper;
|
|
|
-import com.zksy.base.mapper.EquipmentStatusMapper;
|
|
|
-import com.zksy.base.mapper.EquipmentTypeMapper;
|
|
|
+import com.zksy.base.mapper.*;
|
|
|
import com.zksy.base.service.EquipmentBaseService;
|
|
|
import com.zksy.common.exception.ServiceException;
|
|
|
import com.zksy.manhole.dto.in.ManholeDeviceListInDTO;
|
|
|
@@ -66,6 +61,15 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
|
|
|
@Autowired
|
|
|
private ManholeDataMapper manholeDataMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private GasPipePointDeviceRelMapper gasPipePointDeviceRelMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private GasPipePointMapper gasPipePointMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PipeNetworkBaseMapper pipeNetworkBaseMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public Page<EquipmentBase> findByPage(long pageNum, long pageSize,
|
|
|
String equipmentCode, String equipmentName,
|
|
|
@@ -484,6 +488,112 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Page<EquipmentFullVO> findFullByPage(long pageNum, long pageSize,
|
|
|
+ String equipmentCode, String equipmentName,
|
|
|
+ String equipmentModel, String manufacturer) {
|
|
|
+ // 1. 分页查询设备基础信息
|
|
|
+ Page<EquipmentBase> page = new Page<>(pageNum, pageSize);
|
|
|
+ LambdaQueryWrapper<EquipmentBase> qw = new LambdaQueryWrapper<>();
|
|
|
+ if (equipmentCode != null && !equipmentCode.isEmpty()) {
|
|
|
+ qw.like(EquipmentBase::getEquipmentCode, equipmentCode);
|
|
|
+ }
|
|
|
+ if (equipmentName != null && !equipmentName.isEmpty()) {
|
|
|
+ qw.like(EquipmentBase::getEquipmentName, equipmentName);
|
|
|
+ }
|
|
|
+ if (equipmentModel != null && !equipmentModel.isEmpty()) {
|
|
|
+ qw.like(EquipmentBase::getEquipmentModel, equipmentModel);
|
|
|
+ }
|
|
|
+ if (manufacturer != null && !manufacturer.isEmpty()) {
|
|
|
+ qw.like(EquipmentBase::getManufacturer, manufacturer);
|
|
|
+ }
|
|
|
+ qw.orderByDesc(EquipmentBase::getCreateTime);
|
|
|
+ Page<EquipmentBase> basePage = this.page(page, qw);
|
|
|
+ List<EquipmentBase> equipmentList = basePage.getRecords();
|
|
|
+ if (CollUtil.isEmpty(equipmentList)) {
|
|
|
+ Page<EquipmentFullVO> emptyPage = new Page<>(pageNum, pageSize, 0);
|
|
|
+ emptyPage.setRecords(new ArrayList<>());
|
|
|
+ return emptyPage;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> equipmentIds = equipmentList.stream()
|
|
|
+ .map(EquipmentBase::getEquipmentId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 2. 批量查设备状态
|
|
|
+ List<EquipmentStatus> statusList = equipmentStatusMapper.selectList(
|
|
|
+ new LambdaQueryWrapper<EquipmentStatus>().in(EquipmentStatus::getEquipmentId, equipmentIds));
|
|
|
+ Map<String, EquipmentStatus> statusMap = statusList.stream()
|
|
|
+ .collect(Collectors.toMap(EquipmentStatus::getEquipmentId, Function.identity(), (a, b) -> a));
|
|
|
+
|
|
|
+ // 3. 批量查管点-设备关联 (gas_pipe_point_device_rel)
|
|
|
+ List<GasPipePointDeviceRel> allRels = gasPipePointDeviceRelMapper.selectList(
|
|
|
+ new LambdaQueryWrapper<GasPipePointDeviceRel>().in(GasPipePointDeviceRel::getEquipmentId, equipmentIds));
|
|
|
+ Map<String, GasPipePointDeviceRel> relMap = allRels.stream()
|
|
|
+ .collect(Collectors.toMap(GasPipePointDeviceRel::getEquipmentId, Function.identity(), (a, b) -> a));
|
|
|
+
|
|
|
+ // 4. 批量查管点
|
|
|
+ List<Long> pointIds = allRels.stream().map(GasPipePointDeviceRel::getPointId).distinct().collect(Collectors.toList());
|
|
|
+ Map<Long, GasPipePoint> pointMap = new HashMap<>();
|
|
|
+ if (CollUtil.isNotEmpty(pointIds)) {
|
|
|
+ List<GasPipePoint> pointList = gasPipePointMapper.selectBatchIds(pointIds);
|
|
|
+ pointMap = pointList.stream()
|
|
|
+ .collect(Collectors.toMap(GasPipePoint::getPointId, Function.identity(), (a, b) -> a));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 5. 批量查管线
|
|
|
+ List<String> networkIds = pointMap.values().stream()
|
|
|
+ .map(GasPipePoint::getNetworkId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
|
|
+ Map<String, PipeNetworkBase> networkMap = new HashMap<>();
|
|
|
+ if (CollUtil.isNotEmpty(networkIds)) {
|
|
|
+ List<PipeNetworkBase> networkList = pipeNetworkBaseMapper.selectBatchIds(networkIds);
|
|
|
+ networkMap = networkList.stream()
|
|
|
+ .collect(Collectors.toMap(PipeNetworkBase::getNetworkId, Function.identity(), (a, b) -> a));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 6. 组装VO
|
|
|
+ List<EquipmentFullVO> voList = new ArrayList<>();
|
|
|
+ for (EquipmentBase equip : equipmentList) {
|
|
|
+ EquipmentFullVO vo = new EquipmentFullVO();
|
|
|
+ BeanUtil.copyProperties(equip, vo);
|
|
|
+
|
|
|
+ EquipmentStatus status = statusMap.get(equip.getEquipmentId());
|
|
|
+ if (status != null) {
|
|
|
+ vo.setCurrentStatus(status.getCurrentStatus());
|
|
|
+ vo.setAlarmStatus(status.getAlarmStatus());
|
|
|
+ vo.setOnlineStatus(status.getOnlineStatus());
|
|
|
+ vo.setLastMaintainDate(status.getLastMaintainDate());
|
|
|
+ vo.setNextMaintainDate(status.getNextMaintainDate());
|
|
|
+ }
|
|
|
+
|
|
|
+ GasPipePointDeviceRel rel = relMap.get(equip.getEquipmentId());
|
|
|
+ if (rel != null) {
|
|
|
+ GasPipePoint point = pointMap.get(rel.getPointId());
|
|
|
+ if (point != null) {
|
|
|
+ vo.setPointId(point.getPointId());
|
|
|
+ vo.setPointCode(point.getPointCode());
|
|
|
+ vo.setPointName(point.getPointName());
|
|
|
+ vo.setPointType(point.getPointType());
|
|
|
+ vo.setPointAddress(point.getAddress());
|
|
|
+
|
|
|
+ PipeNetworkBase network = networkMap.get(point.getNetworkId());
|
|
|
+ if (network != null) {
|
|
|
+ vo.setNetworkId(network.getNetworkId());
|
|
|
+ vo.setNetworkCode(network.getNetworkCode());
|
|
|
+ vo.setNetworkName(network.getNetworkName());
|
|
|
+ vo.setNetworkType(network.getNetworkType());
|
|
|
+ vo.setNetworkLevel(network.getNetworkLevel());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ voList.add(vo);
|
|
|
+ }
|
|
|
+
|
|
|
+ Page<EquipmentFullVO> resultPage = new Page<>(pageNum, pageSize, basePage.getTotal());
|
|
|
+ resultPage.setRecords(voList);
|
|
|
+ return resultPage;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<EquipmentBase> getEquipmentByPoint(String pointId) {
|
|
|
LambdaQueryWrapper<EquipmentPointRel> relWrapper = new LambdaQueryWrapper<>();
|