|
@@ -16,10 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Collection;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @description 设备参数
|
|
@@ -192,14 +189,14 @@ public class DeviceParmServiceImpl implements DeviceParmService {
|
|
|
}
|
|
|
//查询已经绑定的所有参数
|
|
|
List<DeviceParmInfoDto> deviceParmInfoList = deviceParmMapper.selectBindByDeviceId(sceneId, deviceId);
|
|
|
- List<Long> ids = new ArrayList<>();
|
|
|
+ Map<Long,Long> idMaps= new HashMap<>();
|
|
|
for (DeviceParmInfoDto info : deviceParmInfoList) {
|
|
|
- ids.add(info.getId());
|
|
|
+ idMaps.put(Long.valueOf(info.getAttributeId()),info.getId());
|
|
|
}
|
|
|
for (DeviceParmInfoDto item : deviceParmInfos) {
|
|
|
- if (ids.contains(item.getAttributeId().longValue())) {
|
|
|
- ids.remove(item.getAttributeId().longValue());
|
|
|
- } else if (!ids.contains(item.getAttributeId().longValue())) {
|
|
|
+ if (idMaps.containsKey(item.getAttributeId().longValue())) {
|
|
|
+ idMaps.remove(item.getAttributeId().longValue());
|
|
|
+ } else if (!idMaps.containsKey(item.getAttributeId().longValue())) {
|
|
|
//新增
|
|
|
DeviceParmEntity deviceParmEntity = new DeviceParmEntity();
|
|
|
deviceParmEntity.setSceneId(sceneId);
|
|
@@ -216,7 +213,7 @@ public class DeviceParmServiceImpl implements DeviceParmService {
|
|
|
}
|
|
|
}
|
|
|
//将ids 移除
|
|
|
- for(Long id : ids) {
|
|
|
+ for(Long id : idMaps.values()) {
|
|
|
deviceParmMapper.deleteById(id.intValue());
|
|
|
}
|
|
|
}
|