Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -6,7 +6,6 @@ import cn.hutool.core.util.StrUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.udw.UnifiedDataAccessor;
|
||||
import org.nl.acs.udw.UnifiedDataAccessorFactory;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.openscada.opc.lib.da.Group;
|
||||
import org.openscada.opc.lib.da.Item;
|
||||
import org.openscada.opc.lib.da.ItemState;
|
||||
@@ -16,16 +15,11 @@ import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
public class DeviceOpcProtocolRunable implements Runnable {
|
||||
OpcServerService opcServerService = SpringContextHolder.getBean(OpcServerServiceImpl.class);
|
||||
|
||||
|
||||
List<OpcItemDto> protocols;
|
||||
OpcServerManageDto OpcServer;
|
||||
int error_num;
|
||||
String message;
|
||||
|
||||
Group group;
|
||||
|
||||
public DeviceOpcProtocolRunable() {
|
||||
this.error_num = 0;
|
||||
this.message = null;
|
||||
@@ -66,8 +60,8 @@ public class DeviceOpcProtocolRunable implements Runnable {
|
||||
public void run() {
|
||||
while (true) {
|
||||
try {
|
||||
group= opcServerService.getServer(this.OpcServer.getOpc_code());
|
||||
|
||||
Server server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain());
|
||||
Group group = server.addGroup();
|
||||
List<String> itemsString = new ArrayList();
|
||||
Iterator it = this.protocols.iterator();
|
||||
|
||||
@@ -97,49 +91,33 @@ public class DeviceOpcProtocolRunable implements Runnable {
|
||||
}
|
||||
|
||||
if (is_error) {
|
||||
log.info("设备OPC数据同步配置异常," + err_message);
|
||||
log.info("设备OPC数据同步配置异常");
|
||||
}
|
||||
|
||||
if (!OpcStartTag.is_run) {
|
||||
OpcStartTag.is_run = true;
|
||||
}
|
||||
|
||||
// 线程名
|
||||
//线程名
|
||||
String tag = Thread.currentThread().getName();
|
||||
if (this.OpcServer != null) {
|
||||
tag = tag + this.OpcServer.getOpc_code();
|
||||
}
|
||||
UnifiedDataAccessor accessor_value =
|
||||
UnifiedDataAccessorFactory.getAccessor(OpcConfig.udw_opc_value_key);
|
||||
UnifiedDataAccessor accessor_value = UnifiedDataAccessorFactory.getAccessor(OpcConfig.udw_opc_value_key);
|
||||
|
||||
boolean time_out = false;
|
||||
|
||||
label97:
|
||||
while (true) {
|
||||
// System.out.println("label97");
|
||||
long begin = System.currentTimeMillis();
|
||||
Map<Item, ItemState> itemStatus =null;
|
||||
|
||||
try{
|
||||
itemStatus=group.read(true, (Item[]) itemsMap.values().toArray(new Item[0]));
|
||||
}catch (Exception e){
|
||||
try{
|
||||
itemStatus=group.read(true, (Item[]) itemsMap.values().toArray(new Item[0]));
|
||||
}catch (Exception e2){
|
||||
itemStatus=group.read(true, (Item[]) itemsMap.values().toArray(new Item[0]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//TODO 读完释放server可行否?
|
||||
|
||||
Map<Item, ItemState> itemStatus = group.read(true, (Item[]) itemsMap.values().toArray(new Item[0]));
|
||||
long end = System.currentTimeMillis();
|
||||
log.trace("{} 开始记时{}", tag, DateUtil.now());
|
||||
long duration = end - begin;
|
||||
log.trace("{} 读取耗时:{}", tag, duration);
|
||||
if (duration > 1000L) {
|
||||
if (!time_out) {
|
||||
log.warn(" {} 读取超时 : {} ", tag, duration);
|
||||
log.warn("{} 读取超时 : {}", tag, duration);
|
||||
}
|
||||
|
||||
time_out = true;
|
||||
@@ -147,16 +125,14 @@ public class DeviceOpcProtocolRunable implements Runnable {
|
||||
time_out = false;
|
||||
}
|
||||
|
||||
// A1_HK_04.A1_HK_04.A1_HK_04_3.door 列表
|
||||
Set<Item> items = itemStatus.keySet();
|
||||
Iterator var18 = items.iterator();
|
||||
|
||||
while (true) {
|
||||
Item item;
|
||||
// A1_HK_04.A1_HK_04.A1_HK_04_3.door
|
||||
// 当前值
|
||||
//当前值
|
||||
Object value;
|
||||
// 旧的值
|
||||
//旧的值
|
||||
Object his;
|
||||
do {
|
||||
if (!var18.hasNext()) {
|
||||
@@ -168,24 +144,22 @@ public class DeviceOpcProtocolRunable implements Runnable {
|
||||
this.error_num = 0;
|
||||
this.message = null;
|
||||
}
|
||||
// 所有信号读完并且没有变化的值
|
||||
continue label97;
|
||||
}
|
||||
|
||||
item = (Item) var18.next();
|
||||
ItemState itemState = itemStatus.get(item);
|
||||
ItemState itemState = (ItemState) itemStatus.get(item);
|
||||
value = OpcUtl.getValue(item, itemState);
|
||||
his = accessor_value.getValue(item.getId());
|
||||
if (!ObjectUtil.equal(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD)
|
||||
&& his != null) {
|
||||
if (!ObjectUtil.equal(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD) && his != null) {
|
||||
log.warn("opc 值不健康 item: {}, 状态: {}", item.getId(), itemState.getQuality());
|
||||
}
|
||||
} while (ObjectUtil.equal(value, his)); // 如果两次的值相等,不走下面的代码
|
||||
} while (ObjectUtil.equal(value, his));//如果两次的值相等,不走下面的代码
|
||||
|
||||
OpcItemDto itemDto = this.getItem(item.getId());
|
||||
if (itemDto.getNeed_log() != null && itemDto.getNeed_log()) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
// 设备的ITEM项
|
||||
//设备的ITEM项
|
||||
List<String> relate_items = itemDto.getRelate_items();
|
||||
Iterator var26 = relate_items.iterator();
|
||||
|
||||
@@ -195,25 +169,15 @@ public class DeviceOpcProtocolRunable implements Runnable {
|
||||
sb.append("key:" + relate + "value:" + obj + ";");
|
||||
}
|
||||
|
||||
log.info("信号{}变更从{}->{};信号快照:{}", new Object[] {item.getId(), his, value, sb});
|
||||
log.info("信号{}变更从{}->{};信号快照:{}", new Object[]{item.getId(), his, value, sb});
|
||||
|
||||
}
|
||||
// 设置值
|
||||
//设置值
|
||||
accessor_value.setValue(item.getId(), value);
|
||||
|
||||
}
|
||||
}
|
||||
} catch (Exception var30) {
|
||||
|
||||
if (group != null) {
|
||||
try {
|
||||
group.getServer().dispose();
|
||||
group.clear();
|
||||
group.remove();
|
||||
} catch (Exception var6) {
|
||||
}
|
||||
this.group = null;
|
||||
}
|
||||
|
||||
|
||||
String error_message = "设备信息同步异常";
|
||||
if (!StrUtil.equals(this.message, error_message)) {
|
||||
log.warn("", var30);
|
||||
@@ -223,6 +187,7 @@ public class DeviceOpcProtocolRunable implements Runnable {
|
||||
Thread.sleep((long) (OpcConfig.synchronized_exception_wait_second * 1000));
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
++this.error_num;
|
||||
if (this.error_num > 3 && !StrUtil.equals(this.message, error_message)) {
|
||||
@@ -232,4 +197,12 @@ public class DeviceOpcProtocolRunable implements Runnable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String formatDuring(long mss) {
|
||||
long days = mss / 86400000L;
|
||||
long hours = mss % 86400000L / 3600000L;
|
||||
long minutes = mss % 3600000L / 60000L;
|
||||
long seconds = mss % 60000L / 1000L;
|
||||
return days + " days " + hours + " hours " + minutes + " minutes " + seconds + " seconds ";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,19 @@
|
||||
<div class="head-container">
|
||||
<!--工具栏-->
|
||||
<el-form :inline="true" class="demo-form-inline" label-suffix=":" label-width="90px">
|
||||
<el-form-item label="日志标签">
|
||||
<el-cascader
|
||||
v-model="labelAndValue"
|
||||
:options="labelsOptions"
|
||||
placeholder="请选择标签"
|
||||
/>
|
||||
<el-form-item label="日志级别">
|
||||
<el-select
|
||||
v-model="logLevelValue"
|
||||
style="width: 100px; height: 35px;top: -5px;"
|
||||
placeholder="选择级别"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in labelsOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="关键字">
|
||||
<el-input
|
||||
@@ -18,6 +25,34 @@
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="链路追踪">
|
||||
<el-input
|
||||
v-model="traceId"
|
||||
size="mini"
|
||||
placeholder="请输入链路id"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="SQL日志" prop="filterSql">
|
||||
<el-switch
|
||||
v-model="filterSql"
|
||||
active-color="#409EFF"
|
||||
inactive-color="#F56C6C"
|
||||
active-value="1"
|
||||
inactive-valu="0"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="HTTP日志" prop="isRequest">
|
||||
<el-switch
|
||||
v-model="isRequest"
|
||||
active-color="#409EFF"
|
||||
inactive-color="#F56C6C"
|
||||
active-value="1"
|
||||
inactive-valu="0"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item v-show="!showOptions" label="时间范围">
|
||||
<el-date-picker
|
||||
v-model="timeRange"
|
||||
@@ -47,24 +82,6 @@
|
||||
<span class="el-icon-sort" @click="changeShow" />
|
||||
</el-tooltip>
|
||||
</el-form-item>
|
||||
<el-form-item label="SQL日志" prop="filterSql">
|
||||
<el-switch
|
||||
v-model="filterSql"
|
||||
active-color="#409EFF"
|
||||
inactive-color="#F56C6C"
|
||||
active-value="1"
|
||||
inactive-valu="0"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="HTTP日志" prop="isRequest">
|
||||
<el-switch
|
||||
v-model="isRequest"
|
||||
active-color="#409EFF"
|
||||
inactive-color="#F56C6C"
|
||||
active-value="1"
|
||||
inactive-valu="0"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="显示条数">
|
||||
<el-input-number
|
||||
v-model="size"
|
||||
@@ -117,8 +134,14 @@
|
||||
<div style="width: 100%">
|
||||
<div v-for="(log, index) in logs" :key="index">
|
||||
<div>
|
||||
|
||||
<span style="margin: 5px;">{{log.system}}---{{log.message}}</span>
|
||||
<span >{{log.system}}</span>
|
||||
<span style="color: #13ce66">{{log.thread}}</span>
|
||||
<span style="color: #00afff">{{log.logLevel}}</span>
|
||||
<span>{{log.requestIp}}</span>
|
||||
<span style="color: #b4bccc">{{log.requestTime}}</span>
|
||||
<span style="color: chocolate">{{log.traceId}}</span>
|
||||
<span style="color: #7a6df0">{{log.requestMethod}}</span>
|
||||
<span style="margin: 5px;">-----{{log.message}}</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -136,6 +159,7 @@ let queryParam = {
|
||||
logLevel: null,
|
||||
startTime: null,
|
||||
endTime: null,
|
||||
traceId: null,
|
||||
message: null,
|
||||
filterSql: true,
|
||||
isRequest: true,
|
||||
@@ -146,10 +170,11 @@ export default {
|
||||
name: 'ES',
|
||||
data() {
|
||||
return {
|
||||
labelAndValue: [], // 搜索的值
|
||||
labelsOptions: [], // 所有标签和对应所有值数据
|
||||
logLevelValue: '',
|
||||
timeRange: [],
|
||||
message: '',
|
||||
traceId: '',
|
||||
size: 20,
|
||||
logData: [],
|
||||
filterSql: '1',
|
||||
@@ -222,20 +247,27 @@ export default {
|
||||
methods: {
|
||||
initLabelsValues() {
|
||||
logOperation.labelsValues().then(res => {
|
||||
|
||||
this.labelsOptions = res
|
||||
})
|
||||
},
|
||||
queryData() {
|
||||
// 清空查询数据
|
||||
this.clearParam()
|
||||
queryParam.logLabel = this.labelAndValue[0]
|
||||
queryParam.logLevel = this.logLevelValue
|
||||
const time = new Date()
|
||||
if (this.timeZoneValue !== '') {
|
||||
queryParam.endTime = ((time.getTime() - this.timeZoneValue) * 1000000).toString()
|
||||
queryParam.startTime = new Date(((time.getTime() - this.timeZoneValue)))
|
||||
}
|
||||
debugger
|
||||
if (this.timeRange !== '' && this.timeRange.length > 0) {
|
||||
queryParam.startTime = this.timeRange[0]
|
||||
queryParam.endTime = this.timeRange[1]
|
||||
}
|
||||
queryParam.message = this.message.replace(/^\s*|\s*$/g, '')
|
||||
queryParam.filterSql = this.filterSql === '1'
|
||||
queryParam.isRequest = this.filterSql === '1'
|
||||
queryParam.traceId = this.traceId
|
||||
queryParam.size = this.size
|
||||
queryParam.page = this.page
|
||||
|
||||
@@ -247,14 +279,17 @@ export default {
|
||||
this.logs.push(res.records[j])
|
||||
}
|
||||
})
|
||||
},
|
||||
changetype() {
|
||||
|
||||
},
|
||||
clearParam() {
|
||||
queryParam = {
|
||||
logLabel: null,
|
||||
logLabelValue: null,
|
||||
logLevel: null,
|
||||
startTime: null,
|
||||
endTime: null,
|
||||
message: null,
|
||||
traceId: null,
|
||||
isRequest: true,
|
||||
filterSql: true,
|
||||
size: 20
|
||||
|
||||
Reference in New Issue
Block a user