Merge remote-tracking branch 'origin/master'

This commit is contained in:
zhangzhiqiang
2023-07-27 11:22:30 +08:00
2 changed files with 10 additions and 6 deletions

View File

@@ -25,6 +25,7 @@ public class DeviceStageMonitorServiceImpl implements DeviceStageMonitorService
@Override
public JSONArray getData(JSONArray jsonArray) throws Exception {
long begin = System.currentTimeMillis();
JSONArray arr = new JSONArray();
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject obj = new JSONObject();
@@ -49,7 +50,9 @@ public class DeviceStageMonitorServiceImpl implements DeviceStageMonitorService
obj.put("id", js.getString("id")); // 设备不存在就只保留id方便前端查看
arr.add(obj);
}
long end = System.currentTimeMillis();
long duration = end - begin;
System.out.println("监控数据返回耗时:"+duration);
return arr;
}
}

View File

@@ -1,6 +1,7 @@
package org.nl.acs.opc;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.udw.UnifiedDataAccessor;
@@ -10,7 +11,6 @@ import org.nl.modules.lucene.service.LuceneExecuteLogService;
import org.nl.modules.lucene.service.dto.LuceneLogDto;
import org.nl.modules.wql.util.SpringContextHolder;
import org.openscada.opc.lib.da.*;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.*;
@@ -195,8 +195,9 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
if (true) {
this.logItemChanged(itemId, accessor_value, value, itemDto);
}
accessor_value.setValue(itemId, value);
if(!ObjectUtil.isEmpty(value)){
accessor_value.setValue(itemId, value);
}
}
}
@@ -412,15 +413,15 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
Object obj = accessor_value.getValue(relate);
sb.append("key:" + relate + "value:" + obj + ";");
}
// log.warn("设备:{}信号{}变更从{}->{};信号快照:{}", new Object[]{itemDto.getDevice_code(), itemId, his, value, sb});
if (!itemDto.getItem_code().endsWith("heartbeat")) {
lucene.deviceExecuteLog(new LuceneLogDto(itemDto.getOpc_server_code(), itemDto.getOpc_plc_code(), itemDto.getDevice_code(), itemDto.getItem_code().substring(itemDto.getItem_code().lastIndexOf(".")+1), String.valueOf(his), String.valueOf(value)));
}
} else {
// log.warn("设备:{}信号{}变更从{}->{};信号快照:{}", new Object[]{itemDto.getDevice_code(), itemId, his, value});
if (!itemDto.getItem_code().endsWith("heartbeat")) {
lucene.deviceExecuteLog(new LuceneLogDto(itemDto.getOpc_server_code(), itemDto.getOpc_plc_code(), itemDto.getDevice_code(), itemDto.getItem_code().substring(itemDto.getItem_code().lastIndexOf(".")+1), String.valueOf(his), String.valueOf(value)));
}
}
}