opt: 接口日志显示优化

This commit is contained in:
yanps
2024-07-09 13:40:06 +08:00
parent d652148c1f
commit 44ed477346
3 changed files with 66 additions and 26 deletions

View File

@@ -117,7 +117,7 @@ public class ItemProtocol {
} }
Boolean isonline; Boolean isonline;
Boolean isError; Boolean isError = false;
public int getOpcIntegerValue(String protocol) { public int getOpcIntegerValue(String protocol) {
Integer value = this.driver.getIntegeregerValue(protocol); Integer value = this.driver.getIntegeregerValue(protocol);

View File

@@ -769,7 +769,8 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
@Override @Override
public JSONObject getDeviceStatusName() { public JSONObject getDeviceStatusName() {
JSONObject jo = new JSONObject(); Map<String, Object> map = new LinkedHashMap<>();
String move_1 = ""; String move_1 = "";
String move_2 = ""; String move_2 = "";
String action = ""; String action = "";
@@ -840,25 +841,26 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
iserror = false; iserror = false;
} }
} }
jo.put("requireSucess", requireSucess); map.put("device_name", this.getDevice().getDevice_name());
jo.put("device_name", this.getDevice().getDevice_name()); map.put("mode", mode);
jo.put("mode", mode); map.put("action", action);
jo.put("move_1", move_1); map.put("walk_y", walk_y);
jo.put("move_2", move_2); map.put("error", ErrorUtil.getDictDetail("error_type", String.valueOf(this.getError())));
jo.put("action", action); map.put("task", this.getTask());
jo.put("walk_y", walk_y); map.put("isOnline", this.getIsonline());
jo.put("error", ErrorUtil.getDictDetail("error_type", String.valueOf(this.getError()))); map.put("isError", this.getIserror());
jo.put("task", this.getTask()); map.put("is_disable1", this.getIs_disable());
jo.put("isOnline", this.getIsonline()); map.put("is_disable", is_disable);
jo.put("isError", this.getIserror()); map.put("is_click", true);
jo.put("is_disable1", this.getIs_disable()); map.put("driver_type", "slit_two_manipulator");
jo.put("is_disable", is_disable); map.put("requireSucess", requireSucess);
jo.put("message", message); map.put("move_1", move_1);
jo.put("is_click", true); map.put("move_2", move_2);
jo.put("driver_type", "slit_two_manipulator"); map.put("message", message);
jo.put("notCreateTaskMessage", LangProcess.msg(notCreateTaskMessage)); map.put("notCreateTaskMessage", LangProcess.msg(notCreateTaskMessage));
jo.put("notCreateInstMessage", LangProcess.msg(notCreateInstMessage)); map.put("notCreateInstMessage", LangProcess.msg(notCreateInstMessage));
jo.put("feedMessage", LangProcess.msg(feedMessage)); map.put("feedMessage", LangProcess.msg(feedMessage));
JSONObject jo = new JSONObject(map);
return jo; return jo;
} }

View File

@@ -16,8 +16,20 @@
<!-- <el-table-column v-if="false" prop="id" label="id"/>--> <!-- <el-table-column v-if="false" prop="id" label="id"/>-->
<!-- <el-table-column prop="trace_id" label="链路追踪" /> --> <!-- <el-table-column prop="trace_id" label="链路追踪" /> -->
<el-table-column prop="method" label="方法" width="150px" /> <el-table-column prop="method" label="方法" width="150px" />
<el-table-column prop="requestparam" label="请求参数" class="text-wrapper" /> <el-table-column prop="requestparam" label="请求参数" class="text-wrapper">
<el-table-column prop="responseparam" label="返回参数" class="text-wrapper" /> <template slot-scope="scope">
<div @click="handleClick(scope.row.requestparam)">
{{ truncateOrFullText(scope.row.requestparam) }}
</div>
</template>
</el-table-column>
<el-table-column prop="responseparam" label="返回参数" class="text-wrapper">
<template slot-scope="scope">
<div>
<pre class="json-pre">{{ scope.row.responseparam }}</pre>
</div>
</template>
</el-table-column>
<el-table-column prop="logTime" label="记录时间" width="190px" /> <el-table-column prop="logTime" label="记录时间" width="190px" />
<el-table-column prop="content" label="内容详情" class="text-wrapper" /> <el-table-column prop="content" label="内容详情" class="text-wrapper" />
@@ -54,7 +66,7 @@ export default {
page: 0 page: 0
}, },
query: { query: {
createTime: [new Date(new Date().setTime(new Date().getTime() - 3600 * 1000)), new Date(new Date().setTime(new Date().getTime() + 3600 * 1000))], createTime: [new Date(new Date().setTime(new Date().getTime() - 3600 * 1000)), new Date(new Date().setTime(new Date().getTime() + 3600 * 1000))]
} }
}) })
}, },
@@ -66,13 +78,27 @@ export default {
edit: ['admin', 'param:edit'], edit: ['admin', 'param:edit'],
del: ['admin', 'param:del'] del: ['admin', 'param:del']
}, },
rules: {} rules: {}
} }
}, },
created() { created() {
}, },
methods: { methods: {
truncateOrFullText(text) {
if (text.length > 1000) {
return text.slice(0, 1000) + '...'
}
return text
},
handleClick(content) {
if (content.length > 1000) {
this.$alert(content, '完整内容', {
confirmButtonText: '关闭',
dangerouslyUseHTMLString: true,
customClass: 'full-content-alert'
})
}
},
// 钩子在获取表格数据之前执行false 则代表不获取数据 // 钩子在获取表格数据之前执行false 则代表不获取数据
[CRUD.HOOK.beforeRefresh]() { [CRUD.HOOK.beforeRefresh]() {
return true return true
@@ -103,6 +129,18 @@ export default {
<style scoped> <style scoped>
.text-wrapper { .text-wrapper {
word-break: break-all; word-break: break-all;
word-wrap: break-word word-wrap: break-word;
cursor: pointer;
overflow: hidden;
text-overflow: ellipsis;
}
.full-content-alert {
max-width: none; /* 如果需要自定义 tooltip 的宽度可以在这里设置 */
}
.json-pre {
font-family: Arial, Helvetica, sans-serif;
max-height: 200px; /* 根据需要设置最大高度 */
overflow: auto; /* 添加滚动条 */
white-space: pre-wrap; /* 保留空格和换行 */
} }
</style> </style>