|
@@ -300,8 +300,13 @@ public class ProjectService {
|
|
|
KwsDevice kwsDevice = deviceMapper.selectByPrimaryKey(deviceRelation.getDeviceId());
|
|
KwsDevice kwsDevice = deviceMapper.selectByPrimaryKey(deviceRelation.getDeviceId());
|
|
|
projectDeviceDTO.setParentName(kwsDevice == null ? null : kwsDevice.getName());
|
|
projectDeviceDTO.setParentName(kwsDevice == null ? null : kwsDevice.getName());
|
|
|
}
|
|
}
|
|
|
- if (projectDeviceDTO.getId().equals(projectDeviceDTO.getProjectId())) {
|
|
|
|
|
- projectDeviceDTO.setParentName(null);
|
|
|
|
|
|
|
+ if (StringUtils.isNotBlank(projectDeviceDTO.getParentId())) {
|
|
|
|
|
+ if (projectDeviceDTO.getId().equals(projectDeviceDTO.getParentId())) {
|
|
|
|
|
+ projectDeviceDTO.setParentName(null);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ KwsDevice device = deviceMapper.selectById(Long.parseLong(projectDeviceDTO.getParentId()));
|
|
|
|
|
+ projectDeviceDTO.setParentName(device == null ? null : device.getName());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return PageRes.build(info, list);
|
|
return PageRes.build(info, list);
|
|
@@ -1199,7 +1204,9 @@ public class ProjectService {
|
|
|
//如果删除主设备 子设备也要删除
|
|
//如果删除主设备 子设备也要删除
|
|
|
//id集合
|
|
//id集合
|
|
|
List<Long> deleteList = new ArrayList<>();
|
|
List<Long> deleteList = new ArrayList<>();
|
|
|
|
|
+ List<String> deleteDiviceList = new ArrayList<>();
|
|
|
if (deviceId.equals(deviceParentId)) {
|
|
if (deviceId.equals(deviceParentId)) {
|
|
|
|
|
+ deleteDiviceList.add(deviceId);
|
|
|
List<KwsDeviceRelation> deviceRelationList = deviceRelationMapper.selectList(
|
|
List<KwsDeviceRelation> deviceRelationList = deviceRelationMapper.selectList(
|
|
|
new LambdaQueryWrapper<KwsDeviceRelation>()
|
|
new LambdaQueryWrapper<KwsDeviceRelation>()
|
|
|
.eq(KwsDeviceRelation::getDeviceId, deviceId)
|
|
.eq(KwsDeviceRelation::getDeviceId, deviceId)
|
|
@@ -1230,15 +1237,23 @@ public class ProjectService {
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- deleteList.add(Long.parseLong(deviceId));
|
|
|
|
|
|
|
+ deleteList.add(Long.parseLong(bindDeviceId));
|
|
|
|
|
+ deleteDiviceList.add(deviceId);
|
|
|
|
|
+ deleteDiviceList.add(bindDeviceId);
|
|
|
deviceRelationMapper.update(null, new LambdaUpdateWrapper<KwsDeviceRelation>()
|
|
deviceRelationMapper.update(null, new LambdaUpdateWrapper<KwsDeviceRelation>()
|
|
|
- .eq(KwsDeviceRelation::getMountainId, headerData.getMountainId())
|
|
|
|
|
|
|
+ .eq(KwsDeviceRelation::getDeviceId, deviceParentId)
|
|
|
|
|
+ .eq(KwsDeviceRelation::getRelateDeviceId, deviceId)
|
|
|
.set(KwsDeviceRelation::getDelFlag, 1)
|
|
.set(KwsDeviceRelation::getDelFlag, 1)
|
|
|
- .in(KwsDeviceRelation::getRelateDeviceId, deleteList)
|
|
|
|
|
|
|
+ .in(KwsDeviceRelation::getId, deleteList)
|
|
|
);
|
|
);
|
|
|
|
|
+// projectDeviceMapper.update(null,
|
|
|
|
|
+// new LambdaUpdateWrapper<KwsProjectDevice>()
|
|
|
|
|
+// .eq(KwsProjectDevice::getDeviceId,deviceId)
|
|
|
|
|
+// .eq(KwsProjectDevice::getProjectId,projectId)
|
|
|
|
|
+// );
|
|
|
}
|
|
}
|
|
|
//矿山与设备解绑
|
|
//矿山与设备解绑
|
|
|
- if (!CollectionUtils.isEmpty(deleteList)) {
|
|
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(deleteDiviceList)) {
|
|
|
projectDeviceMapper.update(null, new LambdaUpdateWrapper<KwsProjectDevice>()
|
|
projectDeviceMapper.update(null, new LambdaUpdateWrapper<KwsProjectDevice>()
|
|
|
.set(KwsProjectDevice::getDelFlag, 1)
|
|
.set(KwsProjectDevice::getDelFlag, 1)
|
|
|
.set(KwsProjectDevice::getUpdateBy, headerData.getUpdateBy() == null ? null : Long.parseLong(headerData.getUpdateBy()))
|
|
.set(KwsProjectDevice::getUpdateBy, headerData.getUpdateBy() == null ? null : Long.parseLong(headerData.getUpdateBy()))
|
|
@@ -1246,13 +1261,13 @@ public class ProjectService {
|
|
|
.eq(KwsProjectDevice::getDelFlag, 0)
|
|
.eq(KwsProjectDevice::getDelFlag, 0)
|
|
|
.eq(KwsProjectDevice::getProjectId, projectId)
|
|
.eq(KwsProjectDevice::getProjectId, projectId)
|
|
|
.eq(KwsProjectDevice::getMountainId, headerData.getMountainId())
|
|
.eq(KwsProjectDevice::getMountainId, headerData.getMountainId())
|
|
|
- .in(KwsProjectDevice::getDeviceId, deviceId)
|
|
|
|
|
|
|
+ .in(KwsProjectDevice::getDeviceId, deleteDiviceList)
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
//设备修改状态
|
|
//设备修改状态
|
|
|
- if (!CollectionUtils.isEmpty(deleteList)) {
|
|
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(deleteDiviceList)) {
|
|
|
deviceMapper.update(null, new LambdaUpdateWrapper<KwsDevice>()
|
|
deviceMapper.update(null, new LambdaUpdateWrapper<KwsDevice>()
|
|
|
- .in(KwsDevice::getId, deviceId)
|
|
|
|
|
|
|
+ .in(KwsDevice::getId, deleteDiviceList)
|
|
|
.eq(KwsDevice::getMountainId, headerData.getMountainId())
|
|
.eq(KwsDevice::getMountainId, headerData.getMountainId())
|
|
|
.eq(KwsDevice::getDelFlag, 0)
|
|
.eq(KwsDevice::getDelFlag, 0)
|
|
|
.set(KwsDevice::getRelevanceLevel, 0)
|
|
.set(KwsDevice::getRelevanceLevel, 0)
|
|
@@ -1261,7 +1276,7 @@ public class ProjectService {
|
|
|
.set(KwsDevice::getUpdateBy, headerData.getUpdateBy() == null ? Long.parseLong(headerData.getCreateBy()) : Long.parseLong(headerData.getUpdateBy()))
|
|
.set(KwsDevice::getUpdateBy, headerData.getUpdateBy() == null ? Long.parseLong(headerData.getCreateBy()) : Long.parseLong(headerData.getUpdateBy()))
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
- if (!CollectionUtils.isEmpty(deleteList)) {
|
|
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(deleteDiviceList)) {
|
|
|
List<KwsDevice> kwsDevices = deviceMapper.selectList(new LambdaQueryWrapper<KwsDevice>().in(KwsDevice::getId, deviceId).eq(KwsDevice::getDelFlag, 0));
|
|
List<KwsDevice> kwsDevices = deviceMapper.selectList(new LambdaQueryWrapper<KwsDevice>().in(KwsDevice::getId, deviceId).eq(KwsDevice::getDelFlag, 0));
|
|
|
if (!CollectionUtils.isEmpty(kwsDevices)) {
|
|
if (!CollectionUtils.isEmpty(kwsDevices)) {
|
|
|
StringBuilder deviceName = new StringBuilder();
|
|
StringBuilder deviceName = new StringBuilder();
|
|
@@ -1406,6 +1421,9 @@ public class ProjectService {
|
|
|
bean.setLogicAlt(device.getLogicLat());
|
|
bean.setLogicAlt(device.getLogicLat());
|
|
|
bean.setAlias(device.getAlias());
|
|
bean.setAlias(device.getAlias());
|
|
|
bean.setDeviceId(device.getDeviceId());
|
|
bean.setDeviceId(device.getDeviceId());
|
|
|
|
|
+ String deviceId = device.getDeviceId();
|
|
|
|
|
+ String alarmStatus = getAlarmStatus(deviceId);
|
|
|
|
|
+ bean.setAlarmStatus(alarmStatus);
|
|
|
beans.add(bean);
|
|
beans.add(bean);
|
|
|
});
|
|
});
|
|
|
vo.setDeviceList(beans);
|
|
vo.setDeviceList(beans);
|
|
@@ -1415,6 +1433,52 @@ public class ProjectService {
|
|
|
return HttpResult.ok(returnList);
|
|
return HttpResult.ok(returnList);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private String getAlarmStatus(String deviceId) {
|
|
|
|
|
+ String alarmStatus = "0";
|
|
|
|
|
+ List<KwsThreshold> kwsThresholds = thresholdMapper.selectList(new LambdaQueryWrapper<KwsThreshold>()
|
|
|
|
|
+ .eq(KwsThreshold::getDeviceId, Long.parseLong(deviceId))
|
|
|
|
|
+ .eq(KwsThreshold::getDelFlag, NumberConstant.ZERO)
|
|
|
|
|
+ );
|
|
|
|
|
+ List<KwsAlarmDetail> deviceDetails = alarmDetailMapper.selectList(
|
|
|
|
|
+ new LambdaQueryWrapper<KwsAlarmDetail>()
|
|
|
|
|
+ .in(KwsAlarmDetail::getPid, deviceId)
|
|
|
|
|
+ .eq(KwsAlarmDetail::getDelFlag, NumberConstant.ZERO)
|
|
|
|
|
+ .eq(KwsAlarmDetail::getStatus, NumberConstant.ZERO)
|
|
|
|
|
+ );
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(deviceDetails)) {
|
|
|
|
|
+ alarmStatus = "1";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(kwsThresholds)) {
|
|
|
|
|
+ List<Long> longList = kwsThresholds.stream().map(KwsThreshold::getId).distinct().collect(Collectors.toList());
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(longList) && longList.size() > 0) {
|
|
|
|
|
+ List<KwsAlarmDetail> details = alarmDetailMapper.selectList(
|
|
|
|
|
+ new LambdaQueryWrapper<KwsAlarmDetail>()
|
|
|
|
|
+ .in(KwsAlarmDetail::getPid, longList)
|
|
|
|
|
+ .eq(KwsAlarmDetail::getDelFlag, NumberConstant.ZERO)
|
|
|
|
|
+ .eq(KwsAlarmDetail::getStatus, NumberConstant.ZERO)
|
|
|
|
|
+ );
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(details) && details.size() > 0) {
|
|
|
|
|
+ List<Long> thresholdIds = details.stream().map(KwsAlarmDetail::getPid).collect(Collectors.toList());
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(thresholdIds)) {
|
|
|
|
|
+ List<KwsThreshold> thresholds = thresholdMapper.selectList(
|
|
|
|
|
+ new LambdaQueryWrapper<KwsThreshold>()
|
|
|
|
|
+ .in(KwsThreshold::getId, thresholdIds)
|
|
|
|
|
+ .eq(KwsThreshold::getDelFlag, NumberConstant.ZERO)
|
|
|
|
|
+ .eq(KwsThreshold::getStatus, NumberConstant.ZERO)
|
|
|
|
|
+ );
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(thresholds)) {
|
|
|
|
|
+ List<Integer> levelList = thresholds.stream().map(KwsThreshold::getLevel).sorted().distinct().collect(Collectors.toList());
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(levelList)) {
|
|
|
|
|
+ alarmStatus = String.valueOf(levelList.get(0));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return alarmStatus;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 修改组网设备-关联设备-查询
|
|
* 修改组网设备-关联设备-查询
|
|
|
*
|
|
*
|