Windows环境下IDEA等JetBrains系列软件自动更新文件最后编辑时间(update last modify time)方案

本文介绍了一种在IntelliJ IDEA中自动更新文件中特定日期字段的方法,通过使用FileWatchers插件配合自定义Python脚本,实现每次文件修改后自动更新日期,提高开发效率。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

刚实现的方案,趁热公布一下,网上找了一下官方还没有支持( https://youtrack.jetbrains.com/issue/IDEABKL-7178 ),也没找到这种小功能的插件。
话不多说:
0,安装File Watchers插件(用于监控文件更新)
1,设置File Watchers配置,红框中的配置在后续中说明
在这里插入图片描述
2,其中updateTime.exe是本人用Python实现的一个字符串替换脚本转换成都exe程序(File Watchers插件限制只支持win32程序不支持脚本),代码如下

# encoding: utf-8
import sys
import datetime

changeFlag = False
with open(sys.argv[1],'r') as f:
    l = f.readlines()
    for i in range(len(l)):
        if l[i].find(sys.argv[2]) != -1:
            if l[i].find(datetime.datetime.now().strftime(sys.argv[3])) != -1:
                sys.exit(0)
            l[i]=l[i][0:l[i].find(sys.argv[2])] + sys.argv[2] + datetime.datetime.now().strftime(sys.argv[3]) + '\n'
            changeFlag = True
if changeFlag:
    with open(sys.argv[1],'w') as f:
        f.writelines(l)

再通过exe文件生成工具pyinstaller ,通过pyinstaller -F -w updateTime.py命令转换而来。
这里也提供一份转换后的exe文件
3,$FilePath$ " * Modify Date " "%Y/%m/%d %H:%M"这行配置是传入程序的三个参数,第一个是文件路径,第二个用于标记更新日期所在行,第三个是日期格式
4,最终效果如图,每次修改文件后,Modify Date 后的日期会自动更新
在这里插入图片描述

package com.tongchuang.realtime.mds; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.tongchuang.realtime.bean.ULEParamConfig; import com.tongchuang.realtime.util.KafkaUtils; import org.apache.flink.api.common.eventtime.WatermarkStrategy; import org.apache.flink.api.common.state.; import org.apache.flink.api.common.time.Time; import org.apache.flink.api.common.typeinfo.BasicTypeInfo; import org.apache.flink.api.common.typeinfo.TypeHint; import org.apache.flink.api.common.typeinfo.TypeInformation; import org.apache.flink.configuration.Configuration; import org.apache.flink.connector.kafka.source.KafkaSource; import org.apache.flink.connector.kafka.source.enumerator.initializer.OffsetsInitializer; import org.apache.flink.streaming.api.datastream.; import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; import org.apache.flink.streaming.api.functions.co.KeyedBroadcastProcessFunction; import org.apache.flink.streaming.api.functions.source.RichSourceFunction; import org.apache.flink.util.Collector; import org.apache.flink.util.OutputTag; import java.io.Serializable; import java.sql.; import java.text.ParseException; import java.text.SimpleDateFormat; import java.time.Duration; import java.util.; import java.util.Date; import java.util.concurrent.TimeUnit; public class ULEDataanomalyanalysis { public static void main(String[] args) throws Exception { final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(1); env.getConfig().setAutoWatermarkInterval(1000); // Kafka消费者配置 KafkaSource<String> kafkaConsumer = KafkaUtils.getKafkaConsumer( "realdata_minute", "minutedata_uledataanomalyanalysis", OffsetsInitializer.latest() ); // 修改Watermark策略 DataStreamSource<String> kafkaDS = env.fromSource( kafkaConsumer, WatermarkStrategy.<String>forBoundedOutOfOrderness(Duration.ofMinutes(1)) .withTimestampAssigner((event, timestamp) -> { try { JSONObject json = JSON.parseObject(event); return new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(json.getString("times")).getTime(); } catch (ParseException e) { return System.currentTimeMillis(); } }), "realdata_uledataanomalyanalysis" ); kafkaDS.print("分钟数据流"); // 解析JSON并拆分tag SingleOutputStreamOperator<JSONObject> splitStream = kafkaDS .map(JSON::parseObject) .returns(TypeInformation.of(JSONObject.class)) .flatMap((JSONObject value, Collector<JSONObject> out) -> { JSONObject data = value.getJSONObject("datas"); String time = value.getString("times"); for (String tag : data.keySet()) { JSONObject tagData = data.getJSONObject(tag); JSONObject newObj = new JSONObject(); newObj.put("time", time); newObj.put("tag", tag); newObj.put("ontime", tagData.getDouble("ontime")); newObj.put("avg", tagData.getDouble("avg")); out.collect(newObj); } }) .returns(TypeInformation.of(JSONObject.class)) .name("Split-By-Tag"); // 配置数据源 DataStream<ConfigCollection> configDataStream = env .addSource(new MysqlConfigSource()) .setParallelism(1) .filter(Objects::nonNull) .name("Config-Source"); // 标签值数据流 DataStream<Map<String, Object>> tagValueStream = splitStream .map(json -> { Map<String, Object> valueMap = new HashMap<>(); valueMap.put("tag", json.getString("tag")); valueMap.put("value", "436887485805570949".equals(json.getString("datatype")) ? json.getDouble("ontime") : json.getDouble("avg")); return valueMap; }) .returns(new TypeHint<Map<String, Object>>() {}) .name("Tag-Value-Stream"); // 合并配置流和标签值流 DataStream<Object> broadcastStream = configDataStream .map(config -> (Object) config) .returns(TypeInformation.of(Object.class)) .union( tagValueStream.map(tagValue -> (Object) tagValue) .returns(TypeInformation.of(Object.class)) ); // 广播流 BroadcastStream<Object> finalBroadcastStream = broadcastStream .broadcast(Descriptors.configStateDescriptor, Descriptors.tagValuesDescriptor); // 按tag分组 KeyedStream<JSONObject, String> keyedStream = splitStream .keyBy(json -> json.getString("tag")); BroadcastConnectedStream<JSONObject, Object> connectedStream = keyedStream.connect(finalBroadcastStream); // 异常检测处理 SingleOutputStreamOperator<JSONObject> anomalyStream = connectedStream .process(new OptimizedAnomalyDetectionFunction()) .name("Anomaly-Detection"); anomalyStream.print("异常检测结果"); // 离线检测结果侧输出 DataStream<String> offlineCheckStream = anomalyStream.getSideOutput(OptimizedAnomalyDetectionFunction.OFFLINE_CHECK_TAG); offlineCheckStream.print("离线检测结果"); env.execute("uledataanomalyanalysis"); } // 配置集合类 public static class ConfigCollection implements Serializable { private static final long serialVersionUID = 1L; public final Map<String, List<ULEParamConfig>> tagToConfigs; public final Map<String, ULEParamConfig> encodeToConfig; public final Set<String> allTags; public final long checkpointTime; public ConfigCollection(Map<String, List<ULEParamConfig>> tagToConfigs, Map<String, ULEParamConfig> encodeToConfig) { this.tagToConfigs = new HashMap<>(tagToConfigs); this.encodeToConfig = new HashMap<>(encodeToConfig); this.allTags = new HashSet<>(tagToConfigs.keySet()); this.checkpointTime = System.currentTimeMillis(); } } // MySQL配置源 public static class MysqlConfigSource extends RichSourceFunction<ConfigCollection> { private volatile boolean isRunning = true; private final long interval = TimeUnit.MINUTES.toMillis(5); @Override public void run(SourceContext<ConfigCollection> ctx) throws Exception { while (isRunning) { ConfigCollection newConfig = loadParams(); if (newConfig != null) { ctx.collect(newConfig); System.out.println("配置加载完成,检查点时间: " + new Date(newConfig.checkpointTime)); } else { System.out.println("配置加载失败"); } Thread.sleep(interval); } } private ConfigCollection loadParams() { Map<String, List<ULEParamConfig>> tagToConfigs = new HashMap<>(5000); Map<String, ULEParamConfig> encodeToConfig = new HashMap<>(5000); String url = "jdbc:mysql://10.51.37.73:3306/eps?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8"; String user = "root"; String password = "6CKIm5jDVsLrahSw"; String query = "SELECT F_tag AS tag, F_enCode AS encode, F_dataTypes AS datatype, " + "F_isConstantValue AS constantvalue, F_isOnline AS isonline, " + "F_isSync AS issync, F_syncParaEnCode AS syncparaencode, " + "F_isZero AS iszero, F_isHigh AS ishigh, F_highThreshold AS highthreshold, " + "F_isLow AS islow, F_lowThreshold AS lowthreshold, F_duration AS duration " + "FROM t_equipmentparameter " + "WHERE F_enabledmark = '1' AND (F_isConstantValue='1' OR F_isZero='1' " + "OR F_isHigh='1' OR F_isLow='1' OR F_isOnline='1' OR F_isSync='1')"; try (Connection conn = DriverManager.getConnection(url, user, password); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(query)) { while (rs.next()) { ULEParamConfig config = new ULEParamConfig(); config.tag = rs.getString("tag"); config.encode = rs.getString("encode"); config.datatype = rs.getString("datatype"); config.constantvalue = rs.getInt("constantvalue"); config.iszero = rs.getInt("iszero"); config.ishigh = rs.getInt("ishigh"); config.highthreshold = rs.getDouble("highthreshold"); config.islow = rs.getInt("islow"); config.lowthreshold = rs.getDouble("lowthreshold"); config.duration = rs.getLong("duration"); config.isonline = rs.getInt("isonline"); config.issync = rs.getInt("issync"); config.syncparaencode = rs.getString("syncparaencode"); if (config.encode == null || config.encode.isEmpty()) { System.err.println("忽略无效配置: 空encode"); continue; } String tag = config.tag; tagToConfigs.computeIfAbsent(tag, k -> new ArrayList<>(10)).add(config); encodeToConfig.put(config.encode, config); } System.out.println("加载配置: " + encodeToConfig.size() + " 个参数"); return new ConfigCollection(tagToConfigs, encodeToConfig); } catch (SQLException e) { System.err.println("加载参数配置错误:"); e.printStackTrace(); return null; } } @Override public void cancel() { isRunning = false; } } // 状态描述符 public static class Descriptors { public static final MapStateDescriptor<Void, ConfigCollection> configStateDescriptor = new MapStateDescriptor<>( "configState", TypeInformation.of(Void.class), TypeInformation.of(ConfigCollection.class) ); public static final MapStateDescriptor<String, Double> tagValuesDescriptor = new MapStateDescriptor<>( "tagValuesBroadcastState", BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.DOUBLE_TYPE_INFO ); } // 重构后的异常检测函数(重点修复离线检测) public static class OptimizedAnomalyDetectionFunction extends KeyedBroadcastProcessFunction<String, JSONObject, Object, JSONObject> { public static final OutputTag<String> OFFLINE_CHECK_TAG = new OutputTag<String>("offline-check"){}; // 状态管理 private transient MapState<String, AnomalyState> stateMap; private transient MapState<String, Long> lastDataTimeMap; private transient MapState<String, Long> lastUpdateTimeState; // 最后更新时间(处理时间) private transient MapState<String, Long> processingTimerState; // 处理时间定时器状态 private transient SimpleDateFormat timeFormat; private transient long lastSyncLogTime = 0; @Override public void open(Configuration parameters) { StateTtlConfig ttlConfig = StateTtlConfig.newBuilder(Time.days(30)) .setUpdateType(StateTtlConfig.UpdateType.OnCreateAndWrite) .setStateVisibility(StateTtlConfig.StateVisibility.NeverReturnExpired) .cleanupFullSnapshot() .build(); // 异常状态存储 MapStateDescriptor<String, AnomalyState> stateDesc = new MapStateDescriptor<>( "anomalyState", BasicTypeInfo.STRING_TYPE_INFO, TypeInformation.of(AnomalyState.class) ); stateDesc.enableTimeToLive(ttlConfig); stateMap = getRuntimeContext().getMapState(stateDesc); // 最后数据时间存储(事件时间) MapStateDescriptor<String, Long> timeDesc = new MapStateDescriptor<>( "lastDataTimeState", BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO ); timeDesc.enableTimeToLive(ttlConfig); lastDataTimeMap = getRuntimeContext().getMapState(timeDesc); // 最后更新时间状态(处理时间) MapStateDescriptor<String, Long> updateTimeDesc = new MapStateDescriptor<>( "lastUpdateTimeState", BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO ); updateTimeDesc.enableTimeToLive(ttlConfig); lastUpdateTimeState = getRuntimeContext().getMapState(updateTimeDesc); // 处理时间定时器状态 MapStateDescriptor<String, Long> timerDesc = new MapStateDescriptor<>( "processingTimerState", BasicTypeInfo.STRING_TYPE_INFO, BasicTypeInfo.LONG_TYPE_INFO ); timerDesc.enableTimeToLive(ttlConfig); processingTimerState = getRuntimeContext().getMapState(timerDesc); timeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); } @Override public void processElement(JSONObject data, ReadOnlyContext ctx, Collector<JSONObject> out) throws Exception { String tag = ctx.getCurrentKey(); String timeStr = data.getString("time"); long eventTime = timeFormat.parse(timeStr).getTime(); long currentProcessingTime = System.currentTimeMillis(); // 更新最后数据时间(事件时间lastDataTimeMap.put(tag, eventTime); // 更新最后处理时间(关键修改lastUpdateTimeState.put(tag, currentProcessingTime); // 取消现有定时器(如有) Long existingTimer = processingTimerState.get(tag); if (existingTimer != null) { ctx.timerService().deleteProcessingTimeTimer(existingTimer); } // 获取广播配置 ConfigCollection configCollection = getBroadcastConfig(ctx); if (configCollection == null) return; List<ULEParamConfig> configs = configCollection.tagToConfigs.get(tag); if (configs == null || configs.isEmpty()) return; // 清理无效状态 List<String> keysToRemove = new ArrayList<>(); for (String encode : stateMap.keys()) { boolean found = false; for (ULEParamConfig cfg : configs) { if (cfg.encode.equals(encode)) { found = true; break; } } if (!found) { System.out.println("清理过期状态: " + encode); keysToRemove.add(encode); } } for (String encode : keysToRemove) { stateMap.remove(encode); } double value = 0; boolean valueSet = false; // 重置离线状态(数据到达表示恢复) for (ULEParamConfig config : configs) { if (config.isonline == 1) { AnomalyState state = getOrCreateState(config.encode); AnomalyStatus status = state.getStatus(6); if (status.reported) { reportAnomaly(6, 0, 0.0, timeStr, config, out); status.reset(); stateMap.put(config.encode, state); System.out.println("离线恢复: tag=" + tag + ", encode=" + config.encode); } } } // 注册新定时器(使用处理时间) long minDuration = getMinDuration(configs); if (minDuration != Long.MAX_VALUE) { long nextCheckTime = currentProcessingTime + minDuration * 60 * 1000; ctx.timerService().registerProcessingTimeTimer(nextCheckTime); processingTimerState.put(tag, nextCheckTime); } // 遍历配置项进行异常检测 for (ULEParamConfig config : configs) { if (!valueSet) { value = "436887485805570949".equals(config.datatype) ? data.getDouble("ontime") : data.getDouble("avg"); valueSet = true; } AnomalyState state = getOrCreateState(config.encode); // 处理异常类型 checkConstantValueAnomaly(config, value, timeStr, state, out); // 1. 恒值检测 checkZeroValueAnomaly(config, value, timeStr, state, out); // 2. 零值检测 checkThresholdAnomaly(config, value, timeStr, state, out); // 3. 上阈值, 4. 下阈值 checkSyncAnomaly(config, value, timeStr, state, configCollection, ctx, out); // 5. 同步检测 stateMap.put(config.encode, state); } } @Override public void onTimer(long timestamp, OnTimerContext ctx, Collector<JSONObject> out) throws Exception { String tag = ctx.getCurrentKey(); long currentTime = System.currentTimeMillis(); ConfigCollection configCollection = getBroadcastConfig(ctx); if (configCollection == null) return; List<ULEParamConfig> configs = configCollection.tagToConfigs.get(tag); if (configs == null) return; // 获取标签最后更新时间 Long lastUpdateTime = lastUpdateTimeState.get(tag); boolean hasOnlineConfig = false; long minDuration = Long.MAX_VALUE; for (ULEParamConfig config : configs) { if (config.isonline == 1) { hasOnlineConfig = true; minDuration = Math.min(minDuration, config.duration); AnomalyState state = getOrCreateState(config.encode); AnomalyStatus status = state.getStatus(6); // 检查是否超时 boolean isOffline = false; if (lastUpdateTime == null) { // 从未收到数据 Long initTime = state.getInitTime(); if (initTime == null) { initTime = configCollection.checkpointTime; state.setInitTime(initTime); } isOffline = (currentTime - initTime) >= config.duration * 60 * 1000; } else { // 已有数据但超时 isOffline = (currentTime - lastUpdateTime) >= config.duration * 60 * 1000; } if (isOffline) { if (!status.reported) { String triggerTime = timeFormat.format(new Date(currentTime)); reportAnomaly(6, 1, 0.0, triggerTime, config, out); status.reported = true; // 侧输出流日志 String message = lastUpdateTime == null ? String.format("离线异常(从未收到数据): tag=%s, encode=%s, 阈值=%d分钟", config.tag, config.encode, config.duration) : String.format("离线异常: tag=%s, encode=%s, 最后更新时间=%s, 当前时间=%s, 时间差=%.1f分钟 (阈值=%d分钟)", config.tag, config.encode, timeFormat.format(new Date(lastUpdateTime)), triggerTime, (currentTime - lastUpdateTime) / 60000.0, config.duration); ctx.output(OFFLINE_CHECK_TAG, message); System.out.println(message); } } else if (status.reported) { // 恢复在线状态 reportAnomaly(6, 0, 0.0, timeFormat.format(new Date()), config, out); status.reset(); System.out.println("离线恢复: tag=" + tag + ", encode=" + config.encode); } stateMap.put(config.encode, state); } } // 重新注册定时器(每分钟检查一次) if (hasOnlineConfig) { long nextCheckTime = currentTime + TimeUnit.MINUTES.toMillis(1); ctx.timerService().registerProcessingTimeTimer(nextCheckTime); processingTimerState.put(tag, nextCheckTime); } } // 辅助方法:获取最小duration private long getMinDuration(List<ULEParamConfig> configs) { long minDuration = Long.MAX_VALUE; for (ULEParamConfig config : configs) { if (config.isonline == 1) { minDuration = Math.min(minDuration, config.duration); } } return minDuration; } // 恒值检测 - 异常类型1 private void checkConstantValueAnomaly(ULEParamConfig config, double currentValue, String timeStr, AnomalyState state, Collector<JSONObject> out) { if (config.constantvalue != 1) return; try { AnomalyStatus status = state.getStatus(1); long durationThreshold = config.duration * 60 * 1000; Date timestamp = timeFormat.parse(timeStr); if (status.lastValue == null) { status.lastValue = currentValue; status.lastChangeTime = timestamp; return; } if (Math.abs(currentValue - status.lastValue) > 0.001) { status.lastValue = currentValue; status.lastChangeTime = timestamp; if (status.reported) { reportAnomaly(1, 0, currentValue, timeStr, config, out); } status.reset(); return; } long elapsed = timestamp.getTime() - status.lastChangeTime.getTime(); if (elapsed > durationThreshold) { if (!status.reported) { reportAnomaly(1, 1, currentValue, timeStr, config, out); status.reported = true; } } } catch (Exception e) { System.err.println("恒值检测错误: " + config.encode + " - " + e.getMessage()); } } // 零值检测 - 异常类型2 private void checkZeroValueAnomaly(ULEParamConfig config, double currentValue, String timeStr, AnomalyState state, Collector<JSONObject> out) { if (config.iszero != 1) return; try { AnomalyStatus status = state.getStatus(2); Date timestamp = timeFormat.parse(timeStr); boolean isZero = Math.abs(currentValue) < 0.001; if (isZero) { if (status.startTime == null) { status.startTime = timestamp; } else if (!status.reported) { long elapsed = timestamp.getTime() - status.startTime.getTime(); if (elapsed >= config.duration * 60 * 1000) { reportAnomaly(2, 1, currentValue, timeStr, config, out); status.reported = true; } } } else { if (status.reported) { reportAnomaly(2, 0, currentValue, timeStr, config, out); status.reset(); } else if (status.startTime != null) { status.startTime = null; } } } catch (Exception e) { System.err.println("零值检测错误: " + config.encode + " - " + e.getMessage()); } } // 阈值检测 - 异常类型3(上阈值)和4(下阈值) private void checkThresholdAnomaly(ULEParamConfig config, double currentValue, String timeStr, AnomalyState state, Collector<JSONObject> out) { try { if (config.ishigh == 1) { AnomalyStatus highStatus = state.getStatus(3); processThresholdAnomaly(highStatus, currentValue, timeStr, currentValue > config.highthreshold, config, 3, out); } if (config.islow == 1) { AnomalyStatus lowStatus = state.getStatus(4); processThresholdAnomaly(lowStatus, currentValue, timeStr, currentValue < config.lowthreshold, config, 4, out); } } catch (Exception e) { System.err.println("阈值检测错误: " + config.encode + " - " + e.getMessage()); } } private void processThresholdAnomaly(AnomalyStatus status, double currentValue, String timeStr, boolean isAnomaly, ULEParamConfig config, int anomalyType, Collector<JSONObject> out) { try { Date timestamp = timeFormat.parse(timeStr); if (isAnomaly) { if (status.startTime == null) { status.startTime = timestamp; } else if (!status.reported) { long elapsed = timestamp.getTime() - status.startTime.getTime(); if (elapsed >= config.duration * 60 * 1000) { reportAnomaly(anomalyType, 1, currentValue, timeStr, config, out); status.reported = true; } } } else { if (status.reported) { reportAnomaly(anomalyType, 0, currentValue, timeStr, config, out); status.reset(); } else if (status.startTime != null) { status.startTime = null; } } } catch (Exception e) { System.err.println("阈值处理错误:极速版 " + config.encode + " - " + e.getMessage()); } } // 同步检测 - 异常类型5(优化日志输出) private void checkSyncAnomaly(ULEParamConfig config, double currentValue, String timeStr, AnomalyState state, ConfigCollection configCollection, ReadOnlyContext ctx, Collector<JSONObject> out) { if (config.issync != 1 || config.syncparaencode == null || config.syncparaencode.isEmpty()) { return; } try { // 通过encode获取关联配置 ULEParamConfig relatedConfig = configCollection.encodeToConfig.get(config.syncparaencode); if (relatedConfig == null) { if (System.currentTimeMillis() - lastSyncLogTime > 60000) { System.out.println("同步检测错误: 未找到关联配置, encode=" + config.syncparaencode); lastSyncLogTime = System.currentTimeMillis(); } return; } // 获取关联配置的tag String relatedTag = relatedConfig.tag; if (relatedTag == null || relatedTag.isEmpty()) { if (System.currentTimeMillis() - lastSyncLogTime > 60000) { System.out.println("同步检测错误: 关联配置没有tag, encode=" + config.syncparaencode); lastSyncLogTime = System.currentTimeMillis(); } return; } // 从广播状态获取关联值 ReadOnlyBroadcastState<String, Double> tagValuesState = ctx.getBroadcastState(Descriptors.tagValuesDescriptor); Double relatedValue = tagValuesState.get(relatedTag); if (relatedValue == null) { if (System.currentTimeMillis() - lastSyncLogTime > 60000) { // 优化日志:添加当前标签信息 System.out.printf("同步检测警告: 关联值未初始化 [主标签=%s(%s), 关联标签=%s(%s)]%n", config.tag, config.encode, relatedTag, config.syncparaencode); lastSyncLogTime = System.currentTimeMillis(); } return; } // 同步检测逻辑 AnomalyStatus status = state.getStatus(5); Date timestamp = timeFormat.parse(timeStr); // 业务逻辑:当前值接近1且关联值接近0时异常 boolean isAnomaly = (currentValue >= 0.99) && (Math.abs(relatedValue) < 0.01); // 日志记录 if (System.currentTimeMillis() - lastSyncLogTime > 60000) { System.out.printf("同步检测: %s (%.4f) vs %s (%.4f) -> %b%n", config.tag, currentValue, relatedTag, relatedValue, isAnomaly); lastSyncLogTime = System.currentTimeMillis(); } // 处理异常状态 if (isAnomaly) { if (status.startTime == null) { status.startTime = timestamp; } else if (!status.reported) { long elapsed = timestamp.getTime() - status.startTime.getTime(); if (elapsed >= config.duration * 60 * 1000) { reportAnomaly(5, 1, currentValue, timeStr, config, out); status.reported = true; } } } else { if (status.reported) { reportAnomaly(5, 0, currentValue, timeStr, config, out); status.reset(); } else if (status.startTime != null) { status.startTime = null; } } } catch (ParseException e) { System.err.println("同步检测时间解析错误: " + config.encode + " - " + e.getMessage()); } catch (Exception e) { System.err.println("同步检测错误: " + config.encode + " - " + e.getMessage()); } } // 报告异常(添加详细日志) private void reportAnomaly(int anomalyType, int statusFlag, double value, String time, ULEParamConfig config, Collector<JSONObject> out) { JSONObject event = new JSONObject(); event.put("tag", config.tag); event.put("paracode", config.encode); event.put("abnormaltype", anomalyType); event.put("statusflag", statusFlag); event.put("datavalue", value); event.put("triggertime", time); out.collect(event); // 添加详细日志输出 String statusDesc = statusFlag == 1 ? "异常开始" : "异常结束"; System.out.printf("报告异常: 类型=%d, 状态=%s, 标签=%s, 编码=%s, 时间=%s%n", anomalyType, statusDesc, config.tag, config.encode, time); } @Override public void processBroadcastElement(Object broadcastElement, Context ctx, Collector<JSONObject> out) throws Exception { // 处理配置更新 if (broadcastElement instanceof ConfigCollection) { ConfigCollection newConfig = (ConfigCollection) broadcastElement; BroadcastState<Void, ConfigCollection> configState = ctx.getBroadcastState(Descriptors.configStateDescriptor); // 获取旧配置 ConfigCollection oldConfig = configState.get(null); // 处理配置变更:清理不再启用的报警 if (oldConfig != null) { for (Map.Entry<String, ULEParamConfig> entry : oldConfig.encodeToConfig.entrySet()) { String encode = entry.getKey(); ULEParamConfig oldCfg = entry.getValue(); ULEParamConfig newCfg = newConfig.encodeToConfig.get(encode); if (newCfg == null || !isAlarmEnabled(newCfg, oldCfg)) { // 发送恢复事件 sendRecoveryEvents(encode, oldCfg, ctx, out); } } } // 更新广播状态 configState.put(null, newConfig); System.out.println("广播配置更新完成, 配置项: " + newConfig.encodeToConfig); } // 处理标签值更新 else if (broadcastElement instanceof Map) { @SuppressWarnings("unchecked") Map<String, Object> tagValue = (Map<String, Object>) broadcastElement; String tag = (String) tagValue.get("tag"); Double value = (Double) tagValue.get("value"); if (tag != null && value != null) { BroadcastState<String, Double> tagValuesState = ctx.getBroadcastState(Descriptors.tagValuesDescriptor); tagValuesState.put(tag, value); } } } // 检查报警是否启用 private boolean isAlarmEnabled(ULEParamConfig newCfg, ULEParamConfig oldCfg) { return (oldCfg.constantvalue == 1 && newCfg.constantvalue == 1) || (oldCfg.iszero == 1 && newCfg.iszero == 1) || (oldCfg.ishigh == 1 && newCfg.ishigh == 1) || (oldCfg.islow == 1 && newCfg.islow == 1) || (oldCfg.isonline == 1 && newCfg.isonline == 1) || (oldCfg.issync == 1 && newCfg.issync == 1); } // 发送恢复事件 private void sendRecoveryEvents(String encode, ULEParamConfig config, Context ctx, Collector<JSONObject> out) { try { AnomalyState state = stateMap.get(encode); if (state == null) return; // 遍历所有可能的报警类型 for (int type = 1; type <= 6; type++) { AnomalyStatus status = state.getStatus(type); if (status.reported) { JSONObject recoveryEvent = new JSONObject(); recoveryEvent.put("tag", config.tag); recoveryEvent.put("paracode", config.encode); recoveryEvent.put("abnormaltype", type); recoveryEvent.put("statusflag", 0); // 恢复事件 recoveryEvent.put("datavalue", 0.0); recoveryEvent.put("triggertime", timeFormat.format(new Date())); out.collect(recoveryEvent); System.out.println("发送恢复事件: 类型=" + type + ", 标签=" + config.tag); status.reset(); } } // 更新状态 stateMap.put(encode, state); } catch (Exception e) { System.err.println("发送恢复事件失败: " + e.getMessage()); } } // 辅助方法 private ConfigCollection getBroadcastConfig(ReadOnlyContext ctx) throws Exception { return ctx.getBroadcastState(Descriptors.configStateDescriptor).get(null); } private AnomalyState getOrCreateState(String encode) throws Exception { AnomalyState state = stateMap.get(encode); if (state == null) { state = new AnomalyState(); } return state; } } // 异常状态类(新增initTime字段) public static class AnomalyState implements Serializable { private static final long serialVersionUID = 1L; private final Map<Integer, AnomalyStatus> statusMap = new HashMap<>(); private Long initTime; // 初始化时间(用于从未收到数据的检测) public AnomalyStatus getStatus(int type) { return statusMap.computeIfAbsent(type, k -> new AnomalyStatus()); } public Long getInitTime() { return initTime; } public void setInitTime(Long initTime) { this.initTime = initTime; } } // 异常状态详情(保持不变) public static class AnomalyStatus implements Serializable { private static final long serialVersionUID = 1L; public Date startTime; // 异常开始时间 public Double lastValue; // 用于恒值检测 public Date lastChangeTime; // 值最后变化时间 public boolean reported; // 是否已报告 public void reset() { startTime = null; lastValue = null; lastChangeTime = null; reported = false; } } } 运行日志为:“C:\Program Files (x86)\Java\jdk1.8.0_102\bin\java.exe” -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:24763,suspend=y,server=n -javaagent:C:\Users\Administrator\AppData\Local\JetBrains\IntelliJIdea2021.2\captureAgent\debugger-agent.jar=file:/C:/Users/Administrator/AppData/Local/Temp/capture.props -Dfile.encoding=UTF-8 -classpath C:\Users\Administrator\AppData\Local\Temp\classpath1582414257.jar com.tongchuang.realtime.mds.ULEDataanomalyanalysis 已连接到目标 VM, 地址: ‘‘127.0.0.1:24763’,传输: ‘套接字’’ SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/F:/flink/flinkmaven/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.10.0/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/F:/flink/flinkmaven/repository/org/slf4j/slf4j-log4j12/1.7.25/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory] 加载配置: 30 个参数 配置加载完成,检查点时间: Wed Aug 06 08:59:30 CST 2025 广播配置更新完成, 配置项: {EP000015=ULEParamConfig(tag=DA-LT-6BT005, encode=EP000015, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000014=ULEParamConfig(tag=DA_DB195_RH_R_0281, encode=EP000014, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000013=ULEParamConfig(tag=DA-LT-6BT008, encode=EP000013, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000012=ULEParamConfig(tag=DA-LT-6BT004, encode=EP000012, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000011=ULEParamConfig(tag=DA-LT-6BT005, encode=EP000011, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000010=ULEParamConfig(tag=DA-LT-6BT001, encode=EP000010, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP100013=ULEParamConfig(tag=DA-LT-6BT008, encode=EP100013, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP100014=ULEParamConfig(tag=DA_DB195_RH_R_0281, encode=EP100014, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000019=ULEParamConfig(tag=DA-LT-5BT0005, encode=EP000019, datatype=436887248101780357, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000018=ULEParamConfig(tag=DA-LT-4BT0004, encode=EP000018, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP100010=ULEParamConfig(tag=DA-LT-6BT001, encode=EP100010, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000017=ULEParamConfig(tag=DA-LT-4BT0005, encode=EP000017, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP100011=ULEParamConfig(tag=DA-LT-6BT005, encode=EP100011, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000016=ULEParamConfig(tag=DA-LT-6BT004, encode=EP000016, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP100012=ULEParamConfig(tag=DA-LT-6BT004, encode=EP100012, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000004=ULEParamConfig(tag=DA-LT-4BT0004, encode=EP000004, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000003=ULEParamConfig(tag=DA-LT-4BT0008, encode=EP000003, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000002=ULEParamConfig(tag=DA-LT-4BT0001, encode=EP000002, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000001=ULEParamConfig(tag=DA-DB195-RH-B-0201, encode=EP000001, datatype=436887485805570949, constantvalue=1, iszero=1, isonline=1, issync=1, syncparaencode=EP000022, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000022=ULEParamConfig(tag=DA-LT-4BT0007, encode=EP000022, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000021=ULEParamConfig(tag=DA-LT-6BT008, encode=EP000021, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP100007=ULEParamConfig(tag=DA-LT-5BT0005, encode=EP100007, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000020=ULEParamConfig(tag=DA-LT-6BT005, encode=EP000020, datatype=436887248101780357, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP100008=ULEParamConfig(tag=DA-LT-5BT0005, encode=EP100008, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP100009=ULEParamConfig(tag=DA-LT-5BT0008, encode=EP100009, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000009=ULEParamConfig(tag=DA-LT-5BT0008, encode=EP000009, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000008=ULEParamConfig(tag=DA-LT-5BT0004, encode=EP000008, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000007=ULEParamConfig(tag=DA-LT-5BT0004, encode=EP000007, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000006=ULEParamConfig(tag=DA-LT-5BT0001, encode=EP000006, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000005=ULEParamConfig(tag=DA-LT-4BT0005, encode=EP000005, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3)} 分钟数据流> {“times”:“2025-08-06 08:59”,“datas”:{“DA-LT-5BT0001”:{“ontime”:3064.1802,“avg”:3067.4769,“min”:3020.7207,“max”:3103.9932},“DA-LT-6BT008”:{“ontime”:182.8847,“avg”:181.7926,“min”:180.9806,“max”:182.8847},“DA-LT-5BT0005”:{“ontime”:402.42,“avg”:403.339,“min”:402.42,“max”:404.28},“DA-LT-6BT004”:{“ontime”:1216.4056,“avg”:1216.0174,“min”:1215.5714,“max”:1216.439},“DA-LT-5BT0004”:{“ontime”:1195.0,“avg”:1196.3017,“min”:1194.8,“max”:1197.9},“DA-LT-6BT005”:{“ontime”:401.5108,“avg”:400.6736,“min”:399.7049,“max”:401.5108},“DA-LT-5BT0008”:{“ontime”:184.3,“avg”:185.3683,“min”:184.3,“max”:185.9},“DA-NY-LG1ZL-2-001”:{“ontime”:0.0,“avg”:0.0,“min”:0.0,“max”:0.0},“DA-LT-4BT0008”:{“ontime”:146.1625,“avg”:145.9867,“min”:144.8875,“max”:149.0875},“DB5701P250A00_101”:{“ontime”:1.0,“avg”:1.0,“min”:1.0,“max”:1.0},“DA-LT-4BT0004”:{“ontime”:1209.0,“avg”:1209.0,“min”:1209.0,“max”:1209.0},“DA-LT-6BT001”:{“ontime”:178349.86,“avg”:178462.2957,“min”:176977.33,“max”:179571.25},“DA-NY-LG2ZL-2-003”:{“ontime”:1.0,“avg”:1.0,“min”:1.0,“max”:1.0},“DA-LT-4BT0005”:{“ontime”:316.5625,“avg”:315.4229,“min”:313.6875,“max”:318.6875},“DA_DB195_RH_R_0281”:{“ontime”:333.94,“avg”:345.6455,“min”:307.85,“max”:393.92},“DA-DB195-RH-B-0200”:{“ontime”:1.0,“avg”:1.0,“min”:1.0,“max”:1.0},“DA-DB195-RH-B-0201”:{“ontime”:1.0,“avg”:1.0,“min”:1.0,“max”:1.0},“DA-LT-4BT0001”:{“ontime”:115738.414,“avg”:116529.9705,“min”:114829.37,“max”:117957.84}}} 同步检测警告: 关联值未初始化 [主标签=DA-DB195-RH-B-0201(EP000001), 关联标签=DA-LT-4BT0007(EP000022)] 分钟数据流> {“times”:“2025-08-06 09:00”,“datas”:{“DA-LT-5BT0001”:{“ontime”:3070.2063,“avg”:3069.2265,“min”:3027.1624,“max”:3147.2275},“DA-LT-6BT008”:{“ontime”:181.1966,“avg”:183.026,“min”:181.1966,“max”:185.5542},“DA-LT-5BT0005”:{“ontime”:404.34,“avg”:404.731,“min”:404.28,“max”:405.06},“DA-LT-6BT004”:{“ontime”:1215.5381,“avg”:1215.0252,“min”:1214.4702,“max”:1215.6382},“DA-LT-5BT0004”:{“ontime”:1197.9,“avg”:1199.1767,“min”:1197.9,“max”:1200.3},“DA-LT-6BT005”:{“ontime”:399.8423,“avg”:400.2738,“min”:399.0375,“max”:402.0015},“DA-LT-5BT0008”:{“ontime”:185.94,“avg”:186.4097,“min”:185.94,“max”:186.7},“DA-NY-LG1ZL-2-001”:{“ontime”:0.0,“avg”:0.0,“min”:0.0,“max”:0.0},“DA-LT-4BT0008”:{“ontime”:145.1375,“avg”:145.8042,“min”:144.075,“max”:148.1625},“DB5701P250A00_101”:{“ontime”:1.0,“avg”:1.0,“min”:1.0,“max”:1.0},“DA-LT-4BT0004”:{“ontime”:1209.0,“avg”:1209.0,“min”:1209.0,“max”:1209.0},“DA-LT-6BT001”:{“ontime”:178488.16,“avg”:178323.2988,“min”:177415.97,“max”:179328.48},“DA-LT-4BT0005”:{“ontime”:313.9375,“avg”:315.1292,“min”:313.8125,“max”:317.5625},“DA-NY-LG2ZL-2-003”:{“ontime”:1.0,“avg”:1.0,“min”:1.0,“max”:1.0},“DA_DB195_RH_R_0281”:{“ontime”:334.58,“avg”:337.786,“min”:311.45,“max”:367.58},“DA-DB195-RH-B-0200”:{“ontime”:1.0,“avg”:1.0,“min”:1.0,“max”:1.0},“DA-LT-4BT0001”:{“ontime”:117321.32,“avg”:116257.2892,“min”:115314.13,“max”:117696.305},“DA-DB195-RH-B-0201”:{“ontime”:1.0,“avg”:1.0,“min”:1.0,“max”:1.0}}} 同步检测警告: 关联值未初始化 [主标签=DA-DB195-RH-B-0201(EP000001), 关联标签=DA-LT-4BT0007(EP000022)] 分钟数据流> {“times”:“2025-08-06 09:01”,“datas”:{“DA-LT-5BT0001”:{“ontime”:3094.005,“avg”:3066.9,“min”:3017.5212,“max”:3141.851},“DA-LT-6BT008”:{“ontime”:185.6327,“avg”:186.4932,“min”:185.5542,“max”:187.1049},“DA-LT-5BT0005”:{“ontime”:404.4,“avg”:402.804,“min”:401.04,“max”:404.4},“DA-LT-6BT004”:{“ontime”:1214.5369,“avg”:1213.9847,“min”:1213.4358,“max”:1214.5369},“DA-LT-5BT0004”:{“ontime”:1199.9,“avg”:1200.7833,“min”:1199.9,“max”:1201.6},“DA-LT-6BT005”:{“ontime”:402.1193,“avg”:403.8882,“min”:402.1193,“max”:405.4562},“DA-LT-5BT0008”:{“ontime”:186.56,“avg”:186.504,“min”:184.82,“max”:187.7},“DA-NY-LG1ZL-2-001”:{“ontime”:0.0,“avg”:0.0,“min”:0.0,“max”:0.0},“DA-LT-4BT0008”:{“ontime”:143.8125,“avg”:144.5035,“min”:143.475,“max”:145.3625},“DB5701P250A00_101”:{“ontime”:1.0,“avg”:1.0,“min”:1.0,“max”:1.0},“DA-LT-4BT0004”:{“ontime”:1209.0,“avg”:1209.0,“min”:1209.0,“max”:1209.0},“DA-LT-6BT001”:{“ontime”:178296.28,“avg”:177633.015,“min”:176934.88,“max”:178406.75},“DA-NY-LG2ZL-2-003”:{“ontime”:1.0,“avg”:1.0,“min”:1.0,“max”:1.0},“DA-LT-4BT0005”:{“ontime”:314.3125,“avg”:314.1802,“min”:313.625,“max”:314.9375},“DA_DB195_RH_R_0281”:{“ontime”:336.73,“avg”:335.9752,“min”:293.96,“max”:361.86},“DA-DB195-RH-B-0200”:{“ontime”:1.0,“avg”:1.0,“min”:1.0,“max”:1.0},“DA-LT-4BT0001”:{“ontime”:117313.79,“avg”:116876.3563,“min”:115721.56,“max”:117964.16},“DA-DB195-RH-B-0201”:{“ontime”:1.0,“avg”:1.0,“min”:1.0,“max”:1.0}}} 同步检测警告: 关联值未初始化 [主标签=DA-DB195-RH-B-0201(EP000001), 关联标签=DA-LT-4BT0007(EP000022)] 分钟数据流> {“times”:“2025-08-06 09:02”,“datas”:{“DA-LT-5BT0001”:{“ontime”:3083.3037,“avg”:3060.3783,“min”:3005.7114,“max”:3103.624},“DA-LT-6BT008”:{“ontime”:186.2216,“avg”:186.0545,“min”:185.5346,“max”:186.3983},“DA-LT-5BT0005”:{“ontime”:401.04,“avg”:399.802,“min”:399.3,“max”:401.04},“DA-LT-6BT004”:{“ontime”:1213.4358,“avg”:1212.9452,“min”:1212.4012,“max”:1213.5359},“DA-LT-5BT0004”:{“ontime”:1201.6,“avg”:1203.3484,“min”:1201.6,“max”:1204.9},“DA-LT-6BT005”:{“ontime”:405.5151,“avg”:405.8665,“min”:405.5151,“max”:406.0451},“DA-LT-5BT0008”:{“ontime”:187.56,“avg”:185.292,“min”:183.66,“max”:187.56},“DA-NY-LG1ZL-2-001”:{“ontime”:0.0,“avg”:0.0,“min”:0.0,“max”:0.0},“DA-LT-4BT0008”:{“ontime”:144.925,“avg”:146.3315,“min”:144.9,“max”:149.075},“DB5701P250A00_101”:{“ontime”:1.0,“avg”:1.0,“min”:1.0,“max”:1.0},“DA-LT-4BT0004”:{“ontime”:1209.0,“avg”:1209.0167,“min”:1209.0,“max”:1210.0},“DA-LT-6BT001”:{“ontime”:176681.73,“avg”:177170.773,“min”:176415.9,“max”:178256.67},“DA-NY-LG2ZL-2-003”:{“ontime”:1.0,“avg”:1.0,“min”:1.0,“max”:1.0},“DA-LT-4BT0005”:{“ontime”:314.125,“avg”:313.9531,“min”:312.875,“max”:315.875},“DA_DB195_RH_R_0281”:{“ontime”:322.99,“avg”:335.8693,“min”:312.07,“max”:393.37},“DA-DB195-RH-B-0200”:{“ontime”:1.0,“avg”:1.0,“min”:1.0,“max”:1.0},“DA-LT-4BT0001”:{“ontime”:116846.76,“avg”:117260.9993,“min”:116176.56,“max”:118419.29},“DA-DB195-RH-B-0201”:{“ontime”:1.0,“avg”:1.0,“min”:1.0,“max”:1.0}}} 异常检测结果> {“abnormaltype”:3,“paracode”:“EP100010”,“datavalue”:177170.773,“tag”:“DA-LT-6BT001”,“triggertime”:“2025-08-06 09:02”,“statusflag”:1} 报告异常: 类型=3, 状态=异常开始, 标签=DA-LT-6BT001, 编码=EP100010, 时间=2025-08-06 09:02 异常检测结果> {“abnormaltype”:3,“paracode”:“EP000010”,“datavalue”:177170.773,“tag”:“DA-LT-6BT001”,“triggertime”:“2025-08-06 09:02”,“statusflag”:1} 报告异常: 类型=3, 状态=异常开始, 标签=DA-LT-6BT001, 编码=EP000010, 时间=2025-08-06 09:02 异常检测结果> {“abnormaltype”:3,“paracode”:“EP000002”,“datavalue”:117260.9993,“tag”:“DA-LT-4BT0001”,“triggertime”:“2025-08-06 09:02”,“statusflag”:1} 报告异常: 类型=3, 状态=异常开始, 标签=DA-LT-4BT0001, 编码=EP000002, 时间=2025-08-06 09:02 异常检测结果> {“abnormaltype”:4,“paracode”:“EP000001”,“datavalue”:1.0,“tag”:“DA-DB195-RH-B-0201”,“triggertime”:“2025-08-06 09:02”,“statusflag”:1} 报告异常: 类型=4, 状态=异常开始, 标签=DA-DB195-RH-B-0201, 编码=EP000001, 时间=2025-08-06 09:02 分钟数据流> {“times”:“2025-08-06 09:03”,“datas”:{“DA-LT-5BT0001”:{“ontime”:3027.0603,“avg”:3059.1179,“min”:2999.651,“max”:3113.997},“DA-LT-6BT008”:{“ontime”:186.359,“avg”:185.849,“min”:184.1802,“max”:187.0461},“DA-LT-5BT0005”:{“ontime”:399.78,“avg”:400.624,“min”:399.78,“max”:401.4},“DA-LT-6BT004”:{“ontime”:1212.4347,“avg”:1211.9953,“min”:1211.6671,“max”:1212.468},“DA-LT-5BT0004”:{“ontime”:1204.9,“avg”:1206.05,“min”:1204.9,“max”:1207.0},“DA-LT-6BT005”:{“ontime”:405.8684,“avg”:404.3949,“min”:402.8652,“max”:405.8684},“DA-LT-5BT0008”:{“ontime”:183.7,“avg”:183.3153,“min”:182.34,“max”:184.44},“DA-NY-LG1ZL-2-001”:{“ontime”:0.0,“avg”:0.0,“min”:0.0,“max”:0.0},“DA-LT-4BT0008”:{“ontime”:145.975,“avg”:146.1125,“min”:145.3125,“max”:147.1625},“DB5701P250A00_101”:{“ontime”:1.0,“avg”:1.0,“min”:1.0,“max”:1.0},“DA-LT-4BT0004”:{“ontime”:1209.0,“avg”:1209.15,“min”:1209.0,“max”:1210.0},“DA-LT-6BT001”:{“ontime”:177278.47,“avg”:178191.3243,“min”:177278.47,“max”:179240.23},“DA-LT-4BT0005”:{“ontime”:313.875,“avg”:314.3042,“min”:313.5625,“max”:315.1875},“DA-NY-LG2ZL-2-003”:{“ontime”:1.0,“avg”:1.0,“min”:1.0,“max”:1.0},“DA_DB195_RH_R_0281”:{“ontime”:380.65,“avg”:344.1003,“min”:320.36,“max”:380.65},“DA-DB195-RH-B-0200”:{“ontime”:1.0,“avg”:1.0,“min”:1.0,“max”:1.0},“DA-LT-4BT0001”:{“ontime”:116501.67,“avg”:116541.2536,“min”:115593.18,“max”:117664.38},“DA-DB195-RH-B-0201”:{“ontime”:1.0,“avg”:1.0,“min”:1.0,“max”:1.0}}} 异常检测结果> {“abnormaltype”:1,“paracode”:“EP000001”,“datavalue”:1.0,“tag”:“DA-DB195-RH-B-0201”,“triggertime”:“2025-08-06 09:03”,“statusflag”:1} 报告异常: 类型=1, 状态=异常开始, 标签=DA-DB195-RH-B-0201, 编码=EP000001, 时间=2025-08-06 09:03 同步检测警告: 关联值未初始化 [主标签=DA-DB195-RH-B-0201(EP000001), 关联标签=DA-LT-4BT0007(EP000022)] 加载配置: 30 个参数 配置加载完成,检查点时间: Wed Aug 06 09:04:31 CST 2025 广播配置更新完成, 配置项: {EP000015=ULEParamConfig(tag=DA-LT-6BT005, encode=EP000015, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000014=ULEParamConfig(tag=DA_DB195_RH_R_0281, encode=EP000014, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000013=ULEParamConfig(tag=DA-LT-6BT008, encode=EP000013, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000012=ULEParamConfig(tag=DA-LT-6BT004, encode=EP000012, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000011=ULEParamConfig(tag=DA-LT-6BT005, encode=EP000011, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000010=ULEParamConfig(tag=DA-LT-6BT001, encode=EP000010, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP100013=ULEParamConfig(tag=DA-LT-6BT008, encode=EP100013, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP100014=ULEParamConfig(tag=DA_DB195_RH_R_0281, encode=EP100014, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000019=ULEParamConfig(tag=DA-LT-5BT0005, encode=EP000019, datatype=436887248101780357, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000018=ULEParamConfig(tag=DA-LT-4BT0004, encode=EP000018, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP100010=ULEParamConfig(tag=DA-LT-6BT001, encode=EP100010, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000017=ULEParamConfig(tag=DA-LT-4BT0005, encode=EP000017, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP100011=ULEParamConfig(tag=DA-LT-6BT005, encode=EP100011, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000016=ULEParamConfig(tag=DA-LT-6BT004, encode=EP000016, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP100012=ULEParamConfig(tag=DA-LT-6BT004, encode=EP100012, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000004=ULEParamConfig(tag=DA-LT-4BT0004, encode=EP000004, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000003=ULEParamConfig(tag=DA-LT-4BT0008, encode=EP000003, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000002=ULEParamConfig(tag=DA-LT-4BT0001, encode=EP000002, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000001=ULEParamConfig(tag=DA-DB195-RH-B-0201, encode=EP000001, datatype=436887485805570949, constantvalue=1, iszero=1, isonline=1, issync=1, syncparaencode=EP000022, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000022=ULEParamConfig(tag=DA-LT-4BT0007, encode=EP000022, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000021=ULEParamConfig(tag=DA-LT-6BT008, encode=EP000021, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP100007=ULEParamConfig(tag=DA-LT-5BT0005, encode=EP100007, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000020=ULEParamConfig(tag=DA-LT-6BT005, encode=EP000020, datatype=436887248101780357, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP100008=ULEParamConfig(tag=DA-LT-5BT0005, encode=EP100008, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP100009=ULEParamConfig(tag=DA-LT-5BT0008, encode=EP100009, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000009=ULEParamConfig(tag=DA-LT-5BT0008, encode=EP000009, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000008=ULEParamConfig(tag=DA-LT-5BT0004, encode=EP000008, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000007=ULEParamConfig(tag=DA-LT-5BT0004, encode=EP000007, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000006=ULEParamConfig(tag=DA-LT-5BT0001, encode=EP000006, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3), EP000005=ULEParamConfig(tag=DA-LT-4BT0005, encode=EP000005, datatype=436887289021410181, constantvalue=1, iszero=1, isonline=1, issync=0, syncparaencode=, ishigh=1, highthreshold=10000.0, islow=1, lowthreshold=10.0, duration=3)} 分钟数据流> {“times”:“2025-08-06 09:04”,“datas”:{“DA-LT-5BT0001”:{“ontime”:3100.3306,“avg”:3065.7876,“min”:3011.8132,“max”:3125.8328},“DA-LT-6BT008”:{“ontime”:184.0428,“avg”:183.2953,“min”:181.8443,“max”:184.0821},“DA-LT-5BT0005”:{“ontime”:401.4,“avg”:402.458,“min”:401.4,“max”:403.62},“DA-LT-6BT004”:{“ontime”:1211.7339,“avg”:1211.5092,“min”:1211.3668,“max”:1211.7673},“DA-LT-5BT0004”:{“ontime”:1207.1,“avg”:1208.885,“min”:1207.1,“max”:1210.6},“DA-LT-6BT005”:{“ontime”:402.7474,“avg”:401.5958,“min”:400.9022,“max”:402.7474},“DA-LT-5BT0008”:{“ontime”:184.36,“avg”:184.4267,“min”:183.92,“max”:186.34},“DA-NY-LG1ZL-2-001”:{“ontime”:0.0,“avg”:0.0,“min”:0.0,“max”:0.0},“DA-LT-4BT0008”:{“ontime”:148.8875,“avg”:145.5819,“min”:144.6125,“max”:148.8875},“DB5701P250A00_101”:{“ontime”:1.0,“avg”:1.0,“min”:1.0,“max”:1.0},“DA-LT-4BT0004”:{“ontime”:1209.0,“avg”:1209.0,“min”:1209.0,“max”:1209.0},“DA-LT-6BT001”:{“ontime”:178735.3,“avg”:178495.8288,“min”:177315.8,“max”:179603.86},“DA-NY-LG2ZL-2-003”:{“ontime”:1.0,“avg”:1.0,“min”:1.0,“max”:1.0},“DA-LT-4BT0005”:{“ontime”:318.1875,“avg”:314.7302,“min”:313.9375,“max”:318.1875},“DA_DB195_RH_R_0281”:{“ontime”:345.1,“avg”:344.8548,“min”:305.45,“max”:374.1},“DA-DB195-RH-B-0200”:{“ontime”:1.0,“avg”:1.0,“min”:1.0,“max”:1.0},“DA-DB195-RH-B-0201”:{“ontime”:1.0,“avg”:1.0,“min”:1.0,“max”:1.0},“DA-LT-4BT0001”:{“ontime”:116909.22,“avg”:116579.9132,“min”:115389.78,“max”:117707.77}}} 同步检测警告: 关联值未初始化 [主标签=DA-DB195-RH-B-0201(EP000001), 关联标签=DA-LT-4BT0007(EP000022)]。需完善内容,1、所有异常发生时间应为实际异常出现的开始时间,不应为加duration后的时间;2、DA-LT-4BT0007离线监测未实现。
最新发布
08-07
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值