1.单体电池批量新增修改
This commit is contained in:
@ -1144,6 +1144,16 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
List<EmsDevicesSetting> scopeBatteryList = getScopeBatteryList(scope.allSiteDevices, scopeClusterIdSet);
|
||||
result.setExistingBatteryCount(scopeBatteryList.size());
|
||||
Set<String> affectedBatteryIds = scopeBatteryList.stream()
|
||||
.map(EmsDevicesSetting::getDeviceId)
|
||||
.filter(StringUtils::isNotBlank)
|
||||
.map(String::trim)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
if (SINGLE_BATTERY_SCOPE_CLUSTER.equals(scope.scopeType) && !scopeBatteryList.isEmpty()) {
|
||||
deleteScopeSingleBatteries(scope.normalizedSiteId, scopeBatteryList, deviceMap);
|
||||
scopeBatteryList = new ArrayList<>();
|
||||
}
|
||||
|
||||
int targetCount = request.getTargetCount();
|
||||
if (targetCount > scopeBatteryList.size()) {
|
||||
@ -1219,11 +1229,11 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService
|
||||
));
|
||||
|
||||
List<EmsSiteMonitorPointMatch> insertList = new ArrayList<>();
|
||||
Set<String> affectedBatteryIds = scopeBatteryList.stream()
|
||||
affectedBatteryIds.addAll(scopeBatteryList.stream()
|
||||
.map(EmsDevicesSetting::getDeviceId)
|
||||
.filter(StringUtils::isNotBlank)
|
||||
.map(String::trim)
|
||||
.collect(Collectors.toSet());
|
||||
.collect(Collectors.toSet()));
|
||||
for (SingleBatteryFieldInitTask task : taskList) {
|
||||
boolean pointExists = pointConfigMap.containsKey(task.pointId);
|
||||
if (pointExists) {
|
||||
@ -1330,6 +1340,31 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
}
|
||||
|
||||
private void deleteScopeSingleBatteries(String siteId,
|
||||
List<EmsDevicesSetting> batteryList,
|
||||
Map<String, EmsDevicesSetting> deviceMap) {
|
||||
if (CollectionUtils.isEmpty(batteryList)) {
|
||||
return;
|
||||
}
|
||||
Long[] ids = batteryList.stream()
|
||||
.map(EmsDevicesSetting::getId)
|
||||
.filter(Objects::nonNull)
|
||||
.toArray(Long[]::new);
|
||||
for (EmsDevicesSetting battery : batteryList) {
|
||||
if (battery == null || StringUtils.isBlank(battery.getDeviceId())) {
|
||||
continue;
|
||||
}
|
||||
String batteryId = StringUtils.trim(battery.getDeviceId());
|
||||
emsSiteMonitorPointMatchMapper.deleteBySiteIdAndDeviceId(siteId, batteryId);
|
||||
if (deviceMap != null) {
|
||||
deviceMap.remove(batteryId);
|
||||
}
|
||||
}
|
||||
if (ids.length > 0) {
|
||||
emsDevicesMapper.deleteEmsDevicesSettingByIds(ids);
|
||||
}
|
||||
}
|
||||
|
||||
private List<EmsDevicesSetting> createMissingSingleBatteries(String siteId,
|
||||
String clusterDeviceId,
|
||||
int appendCount,
|
||||
|
||||
Reference in New Issue
Block a user