1.单体电池批量新增修改
This commit is contained in:
@ -1144,6 +1144,16 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService
|
|||||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||||
List<EmsDevicesSetting> scopeBatteryList = getScopeBatteryList(scope.allSiteDevices, scopeClusterIdSet);
|
List<EmsDevicesSetting> scopeBatteryList = getScopeBatteryList(scope.allSiteDevices, scopeClusterIdSet);
|
||||||
result.setExistingBatteryCount(scopeBatteryList.size());
|
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();
|
int targetCount = request.getTargetCount();
|
||||||
if (targetCount > scopeBatteryList.size()) {
|
if (targetCount > scopeBatteryList.size()) {
|
||||||
@ -1219,11 +1229,11 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService
|
|||||||
));
|
));
|
||||||
|
|
||||||
List<EmsSiteMonitorPointMatch> insertList = new ArrayList<>();
|
List<EmsSiteMonitorPointMatch> insertList = new ArrayList<>();
|
||||||
Set<String> affectedBatteryIds = scopeBatteryList.stream()
|
affectedBatteryIds.addAll(scopeBatteryList.stream()
|
||||||
.map(EmsDevicesSetting::getDeviceId)
|
.map(EmsDevicesSetting::getDeviceId)
|
||||||
.filter(StringUtils::isNotBlank)
|
.filter(StringUtils::isNotBlank)
|
||||||
.map(String::trim)
|
.map(String::trim)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet()));
|
||||||
for (SingleBatteryFieldInitTask task : taskList) {
|
for (SingleBatteryFieldInitTask task : taskList) {
|
||||||
boolean pointExists = pointConfigMap.containsKey(task.pointId);
|
boolean pointExists = pointConfigMap.containsKey(task.pointId);
|
||||||
if (pointExists) {
|
if (pointExists) {
|
||||||
@ -1330,6 +1340,31 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService
|
|||||||
.collect(Collectors.toCollection(ArrayList::new));
|
.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,
|
private List<EmsDevicesSetting> createMissingSingleBatteries(String siteId,
|
||||||
String clusterDeviceId,
|
String clusterDeviceId,
|
||||||
int appendCount,
|
int appendCount,
|
||||||
|
|||||||
Reference in New Issue
Block a user