Merge remote-tracking branch 'origin/2.0' into 2.0
This commit is contained in:
commit
b61f452d46
|
|
@ -11,6 +11,8 @@ import org.jetlinks.supports.protocol.management.ProtocolSupportDefinition;
|
|||
import org.jetlinks.supports.protocol.management.ProtocolSupportLoader;
|
||||
import org.jetlinks.supports.protocol.management.ProtocolSupportManager;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.time.Duration;
|
||||
|
|
@ -21,6 +23,7 @@ import java.util.function.Consumer;
|
|||
@Slf4j
|
||||
@Getter
|
||||
@Setter
|
||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||
public class LazyInitManagementProtocolSupports extends StaticProtocolSupports implements CommandLineRunner {
|
||||
|
||||
private ProtocolSupportManager manager;
|
||||
|
|
|
|||
|
|
@ -46,9 +46,6 @@ public class AlarmHistoryInfo {
|
|||
@Schema(description = "告警信息")
|
||||
private String alarmInfo;
|
||||
|
||||
@Schema(description = "绑定信息")
|
||||
private List<Map<String, Object>> bindings;
|
||||
|
||||
|
||||
public static AlarmHistoryInfo of(String alarmRecordId,
|
||||
AlarmTargetInfo targetInfo,
|
||||
|
|
@ -66,31 +63,7 @@ public class AlarmHistoryInfo {
|
|||
info.setTargetType(targetInfo.getTargetType());
|
||||
info.setAlarmInfo(JSON.toJSONString(data.getOutput()));
|
||||
info.setDescription(alarmConfig.getDescription());
|
||||
info.setBindings(convertBindings(targetInfo, data, alarmConfig));
|
||||
return info;
|
||||
}
|
||||
|
||||
@SuppressWarnings("all")
|
||||
static List<Map<String, Object>> convertBindings(AlarmTargetInfo targetInfo,
|
||||
SceneData data,
|
||||
AlarmConfigEntity alarmConfig){
|
||||
List<Map<String, Object>> bindings = new ArrayList<>();
|
||||
|
||||
bindings.addAll((List) data.getOutput().getOrDefault("_bindings",Collections.emptyList()));
|
||||
|
||||
//添加告警配置创建人到bindings中。作为用户维度信息
|
||||
Map<String, Object> userDimension = new HashMap<>(2);
|
||||
userDimension.put("type","user");
|
||||
userDimension.put("id", alarmConfig.getCreatorId());
|
||||
bindings.add(userDimension);
|
||||
//添加组织纬度信息
|
||||
if ("org".equals(alarmConfig.getTargetType())) {
|
||||
Map<String, Object> orgDimension = new HashMap<>(2);
|
||||
userDimension.put("type", targetInfo.getTargetType());
|
||||
userDimension.put("id", targetInfo.getTargetId());
|
||||
bindings.add(userDimension);
|
||||
}
|
||||
return bindings;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,13 +52,12 @@ public class ElasticSearchAlarmHistoryService implements AlarmHistoryService {
|
|||
.addProperty("alarmRecordId", StringType.GLOBAL)
|
||||
.addProperty("level", IntType.GLOBAL)
|
||||
.addProperty("description", StringType.GLOBAL)
|
||||
.addProperty("alarmTime", LongType.GLOBAL)
|
||||
.addProperty("alarmTime", DateTimeType.GLOBAL)
|
||||
.addProperty("targetType", StringType.GLOBAL)
|
||||
.addProperty("targetName", StringType.GLOBAL)
|
||||
.addProperty("targetId", StringType.GLOBAL)
|
||||
.addProperty("alarmInfo", StringType.GLOBAL)
|
||||
.addProperty("creatorId", StringType.GLOBAL)
|
||||
.addProperty("bindings", new ArrayType().elementType(new ObjectType()))
|
||||
).block(Duration.ofSeconds(10));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue