|
|
|
@ -178,31 +178,60 @@ public class PsdcSceneServiceImpl implements IPsdcSceneService { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<Map<String, Object>> getStrategyList() { |
|
|
|
|
List<String> scenes = psdcSceneMapper.querySceneGroup(SecurityUtils.getUserId()); |
|
|
|
|
List<Map<String, Object>> collectList = scenes.stream() |
|
|
|
|
.map(scene -> { |
|
|
|
|
List<SceneVo> sceneVoList = psdcSceneMapper.queryBySceneName(scene); |
|
|
|
|
Integer[] flag = {null}; |
|
|
|
|
List<Map<String, Object>> collect = sceneVoList.stream() |
|
|
|
|
.filter(sceneVo -> !Objects.equals(flag[0], sceneVo.getDeviceId())) |
|
|
|
|
.peek(sceneVo -> flag[0] = sceneVo.getDeviceId()) |
|
|
|
|
.map(sceneVo -> { |
|
|
|
|
Map<String, Object> map1 = new HashMap<>(); |
|
|
|
|
map1.put("device_name", sceneVo.getDeviceName()); |
|
|
|
|
map1.put("device_id", sceneVo.getDeviceId()); |
|
|
|
|
List<SceneVo> sceneVoList1 = psdcSceneMapper.querySceneByDeviceIdAndSceneName(SecurityUtils.getUserId(), sceneVo.getDeviceId(), scene); |
|
|
|
|
map1.put("value", sceneVoList1); |
|
|
|
|
return map1; |
|
|
|
|
}) |
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
public List<PsdcSceneRes> getStrategyList() { |
|
|
|
|
Long userId = SecurityUtils.getUserId(); |
|
|
|
|
List<PsdcSceneRes> sceneRes = psdcSceneMapper.queryScenes(userId, null); |
|
|
|
|
for (PsdcSceneRes psr : sceneRes) { |
|
|
|
|
Long code = psr.getSceneCode(); |
|
|
|
|
List<SceneVo> listByCode = psdcSceneMapper.findSceneByUserAndSceneCode(userId, code, null); |
|
|
|
|
psr.setIsCheck(false); |
|
|
|
|
List<DeviceVo> ary = new ArrayList<>(); |
|
|
|
|
Integer deviceId = listByCode.get(0).getDeviceId(); |
|
|
|
|
DeviceVo deviceVo = new DeviceVo(); |
|
|
|
|
List<Map> list = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < listByCode.size(); i++) { |
|
|
|
|
SceneVo sv = listByCode.get(i); |
|
|
|
|
if (deviceId == sv.getDeviceId()) { |
|
|
|
|
deviceVo.setDeviceId(sv.getDeviceId()); |
|
|
|
|
deviceVo.setDeviceName(sv.getDeviceName()); |
|
|
|
|
deviceVo.setDeviceSn(sv.getDeviceSn()); |
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
map.put("label", sv.getSceneContext()); |
|
|
|
|
map.put("value", sv.getSceneValue()); |
|
|
|
|
list.add(map); |
|
|
|
|
deviceVo.setTempValue(list); |
|
|
|
|
if (1 == listByCode.size() || i == listByCode.size() - 1){ |
|
|
|
|
ary.add(deviceVo); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
ary.add(deviceVo); |
|
|
|
|
deviceId = sv.getDeviceId(); |
|
|
|
|
deviceVo = new DeviceVo(); |
|
|
|
|
list = new ArrayList<>(); |
|
|
|
|
deviceVo.setDeviceId(sv.getDeviceId()); |
|
|
|
|
deviceVo.setDeviceName(sv.getDeviceName()); |
|
|
|
|
deviceVo.setDeviceSn(sv.getDeviceSn()); |
|
|
|
|
if (i == listByCode.size() - 1) { |
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
map.put("label", sv.getSceneContext()); |
|
|
|
|
map.put("value", sv.getSceneValue()); |
|
|
|
|
list.add(map); |
|
|
|
|
deviceVo.setTempValue(list); |
|
|
|
|
ary.add(deviceVo); |
|
|
|
|
} else { |
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
map.put("sceneName", scene); |
|
|
|
|
map.put("data", collect); |
|
|
|
|
return map; |
|
|
|
|
}) |
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
return collectList; |
|
|
|
|
map.put("label", sv.getSceneContext()); |
|
|
|
|
map.put("value", sv.getSceneValue()); |
|
|
|
|
list.add(map); |
|
|
|
|
deviceVo.setTempValue(list); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
psr.setDeviceVos(ary); |
|
|
|
|
} |
|
|
|
|
return sceneRes; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -224,17 +253,6 @@ public class PsdcSceneServiceImpl implements IPsdcSceneService { |
|
|
|
|
deviceVo.setDeviceId(sv.getDeviceId()); |
|
|
|
|
deviceVo.setDeviceName(sv.getDeviceName()); |
|
|
|
|
deviceVo.setDeviceSn(sv.getDeviceSn()); |
|
|
|
|
// switch (sv.getSceneKey()) {
|
|
|
|
|
// case "intemp":
|
|
|
|
|
// deviceVo.setIntemp(sv.getSceneValue());
|
|
|
|
|
// break;
|
|
|
|
|
// case "outtemp":
|
|
|
|
|
// deviceVo.setOuttemp(sv.getSceneValue());
|
|
|
|
|
// break;
|
|
|
|
|
// case "temp":
|
|
|
|
|
// deviceVo.setTemp(sv.getSceneValue());
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
map.put("label", sv.getSceneContext()); |
|
|
|
|
map.put("value", sv.getSceneValue()); |
|
|
|
@ -253,15 +271,6 @@ public class PsdcSceneServiceImpl implements IPsdcSceneService { |
|
|
|
|
deviceVo.setDeviceName(sv.getDeviceName()); |
|
|
|
|
deviceVo.setDeviceSn(sv.getDeviceSn()); |
|
|
|
|
if (i == listByCode.size() - 1) { |
|
|
|
|
// 判断是否为最后1个元素
|
|
|
|
|
// switch (sv.getSceneKey()) {
|
|
|
|
|
// case "intemp":
|
|
|
|
|
// deviceVo.setIntemp(sv.getSceneValue());
|
|
|
|
|
// case "outtemp":
|
|
|
|
|
// deviceVo.setOuttemp(sv.getSceneValue());
|
|
|
|
|
// case "temp":
|
|
|
|
|
// deviceVo.setTemp(sv.getSceneValue());
|
|
|
|
|
// }
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
map.put("label", sv.getSceneContext()); |
|
|
|
|
map.put("value", sv.getSceneValue()); |
|
|
|
@ -269,17 +278,6 @@ public class PsdcSceneServiceImpl implements IPsdcSceneService { |
|
|
|
|
deviceVo.setTempValue(list); |
|
|
|
|
ary.add(deviceVo); |
|
|
|
|
} else { |
|
|
|
|
// switch (sv.getSceneKey()) {
|
|
|
|
|
// case "intemp":
|
|
|
|
|
// deviceVo.setIntemp(sv.getSceneValue());
|
|
|
|
|
// break;
|
|
|
|
|
// case "outtemp":
|
|
|
|
|
// deviceVo.setOuttemp(sv.getSceneValue());
|
|
|
|
|
// break;
|
|
|
|
|
// case "temp":
|
|
|
|
|
// deviceVo.setTemp(sv.getSceneValue());
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
map.put("label", sv.getSceneContext()); |
|
|
|
|
map.put("value", sv.getSceneValue()); |
|
|
|
|