Merge remote-tracking branch 'origin/master'

This commit is contained in:
zhouhao 2025-05-27 10:41:27 +08:00
commit 88e0dd4667
2 changed files with 25 additions and 6 deletions

View File

@ -219,15 +219,32 @@ public class SceneUtils {
}
}
public static void refactorUpperKey(DeviceSelectorSpec deviceSelectorSpec) {
@SuppressWarnings("all")
public static void refactorUpperKey(Object source) {
// 将变量格式改为与查询的别名一致
if (VariableSource.Source.upper.equals(deviceSelectorSpec.getSource())) {
if (source instanceof VariableSource) {
VariableSource variableSource = (VariableSource) source;
if (VariableSource.Source.upper.equals(variableSource.getSource())) {
variableSource.setUpperKey(transferSceneUpperKey(variableSource.getUpperKey()));
}
}
if (source instanceof Map) {
Map<String, Object> map = (Map<String, Object>) source;
VariableSource variableSource = VariableSource.of(source);
// 将变量格式改为与查询的别名一致
if (VariableSource.Source.upper.equals(variableSource.getSource())) {
map.put("upperKey", transferSceneUpperKey(variableSource.getUpperKey()));
}
}
}
public static String transferSceneUpperKey(String upperKey) {
// scene.xx.current -> scene.scene_xx_current
if (deviceSelectorSpec.getUpperKey().startsWith("scene.")) {
String alias = SceneUtils.createColumnAlias("properties", deviceSelectorSpec.getUpperKey(), false);
deviceSelectorSpec.setUpperKey("scene." + alias);
}
if (upperKey.startsWith("scene.")) {
String alias = SceneUtils.createColumnAlias("scene", upperKey, false);
return "scene." + alias;
}
return upperKey;
}
private static boolean isContainThis(String[] arr) {

View File

@ -148,11 +148,13 @@ public class Variable {
}
public void refactorPrefix(Variable main) {
id = SceneUtils.transferSceneUpperKey(id);
if (CollectionUtils.isNotEmpty(children)) {
for (Variable child : children) {
if (!child.getId().startsWith(main.id + ".")) {
child.setId(main.id + "." + child.getId());
}
child.setId(SceneUtils.transferSceneUpperKey(child.getId()));
if (StringUtils.hasText(child.getFullName()) && StringUtils.hasText(main.getFullName())) {
child.setFullName(main.getFullName() + "/" + child.getFullName());