初始化
This commit is contained in:
@@ -0,0 +1,221 @@
|
||||
<?php
|
||||
$activeMenu = 'asdDeviceDebug';
|
||||
include APP_PATH . 'app/views/layouts/admin_header.php';
|
||||
?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="box box-primary">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title"><i class="fa fa-plug"></i> 昂盛达设备调试</h3>
|
||||
<div class="box-tools">
|
||||
<span class="badge bg-blue">共 <?php echo count($devices ?? []); ?> 台设备</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<form method="post" action="<?php echo BASE_URL; ?>/Admin/asdDeviceDebug" class="form-inline">
|
||||
<input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($csrfToken); ?>">
|
||||
<div class="form-group" style="margin-right:8px;">
|
||||
<label class="sr-only">查找设备</label>
|
||||
<input type="text" name="keyword" class="form-control" style="width:260px;"
|
||||
placeholder="按名称 / IP / 编号查找" value="<?php echo htmlspecialchars($keyword ?? ''); ?>">
|
||||
</div>
|
||||
<button type="submit" name="action" value="search" class="btn btn-default">
|
||||
<i class="fa fa-search"></i> 查找设备
|
||||
</button>
|
||||
<span class="text-muted" style="margin-left:10px;">共 <?php echo count($devices ?? []); ?> 台</span>
|
||||
</form>
|
||||
<hr>
|
||||
<form method="post" action="<?php echo BASE_URL; ?>/Admin/asdDeviceDebug">
|
||||
<input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($csrfToken); ?>">
|
||||
<div class="form-group">
|
||||
<label>选择设备</label>
|
||||
<select name="device_id" class="form-control" style="max-width:480px;">
|
||||
<option value="0">— 请选择设备 —</option>
|
||||
<?php foreach ($devices ?? [] as $dev): ?>
|
||||
<option value="<?php echo intval($dev['id']); ?>" <?php echo (isset($selDeviceId) && $selDeviceId == $dev['id']) ? 'selected' : ''; ?>>
|
||||
<?php echo htmlspecialchars($dev['device_name'] ?? '设备' . $dev['id']); ?>
|
||||
(<?php echo htmlspecialchars($dev['device_ip'] ?? '无IP'); ?>:<?php echo intval($dev['device_port'] ?? 502); ?>)
|
||||
- <?php echo ($dev['status'] == 1) ? '启用' : '禁用'; ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="btn-group" style="margin-left:8px;">
|
||||
<button type="submit" name="action" value="testLink" class="btn btn-info">
|
||||
<i class="fa fa-wifi"></i> 测试链接状态
|
||||
</button>
|
||||
<button type="submit" name="action" value="readData" class="btn btn-success">
|
||||
<i class="fa fa-download"></i> 数据读取
|
||||
</button>
|
||||
<button type="submit" name="action" value="writeData" class="btn btn-warning">
|
||||
<i class="fa fa-upload"></i> 数据写入(探针)
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<hr>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="well" style="margin-bottom:0;">
|
||||
<h4><i class="fa fa-plug"></i> 手动连接(IP:端口)</h4>
|
||||
<form method="post" action="<?php echo BASE_URL; ?>/Admin/asdDeviceDebug" class="form-inline">
|
||||
<input type="hidden" name="csrf_token" value="<?php echo htmlspecialchars($csrfToken); ?>">
|
||||
<div class="form-group" style="margin-right:6px;">
|
||||
<input type="text" name="manual_ip" class="form-control" style="width:160px;"
|
||||
placeholder="设备 IP,如 192.168.1.10" value="<?php echo htmlspecialchars($_POST['manual_ip'] ?? ''); ?>">
|
||||
</div>
|
||||
<div class="form-group" style="margin-right:6px;">
|
||||
<input type="number" name="manual_port" class="form-control" style="width:90px;"
|
||||
placeholder="端口" value="<?php echo htmlspecialchars($_POST['manual_port'] ?? '502'); ?>">
|
||||
</div>
|
||||
<button type="submit" name="action" value="manualConnect" class="btn btn-primary">
|
||||
<i class="fa fa-wifi"></i> 测试连接
|
||||
</button>
|
||||
</form>
|
||||
<p class="text-muted" style="margin-top:8px;margin-bottom:0;">不依赖数据库记录,直接对任意 IP:端口做 TCP 连通测试。</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($result)): ?>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="box box-default">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">
|
||||
<i class="fa fa-terminal"></i>
|
||||
<?php
|
||||
$titles = [
|
||||
'testLink' => '链接状态测试结果',
|
||||
'readData' => '数据读取结果',
|
||||
'writeData' => '数据写入(探针)结果',
|
||||
'manualConnect' => '手动连接测试结果',
|
||||
];
|
||||
echo htmlspecialchars($titles[$result['action']] ?? '测试结果');
|
||||
?>
|
||||
</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
|
||||
<?php if (!empty($result['error'])): ?>
|
||||
<div class="alert alert-danger">
|
||||
<i class="fa fa-times-circle"></i> <?php echo htmlspecialchars($result['error']); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($result['action'] === 'testLink'): ?>
|
||||
<table class="table table-bordered" style="max-width:600px;">
|
||||
<tr><th style="width:160px;">设备</th><td><?php echo htmlspecialchars(($result['device']['device_code'] ?? '') . ' / ' . ($result['device']['device_name'] ?? '')); ?></td></tr>
|
||||
<tr><th>目标地址</th><td><?php echo htmlspecialchars($result['ip']); ?> : <?php echo intval($result['port']); ?></td></tr>
|
||||
<tr><th>连接结果</th>
|
||||
<td>
|
||||
<?php if ($result['reachable']): ?>
|
||||
<span class="label label-success"><i class="fa fa-check"></i> 可达</span>
|
||||
<?php else: ?>
|
||||
<span class="label label-danger"><i class="fa fa-times"></i> 不可达</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr><th>延迟</th><td><?php echo $result['latency']; ?> ms</td></tr>
|
||||
<?php if ($result['error']): ?>
|
||||
<tr><th>错误信息</th><td class="text-danger"><?php echo htmlspecialchars($result['error']); ?></td></tr>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($result['action'] === 'readData'): ?>
|
||||
<p>
|
||||
设备编号:<code><?php echo htmlspecialchars($result['device_code']); ?></code>
|
||||
| 测试记录总数:<b><?php echo intval($result['counts']['rec_cnt'] ?? 0); ?></b>
|
||||
| 测试数据总数:<b><?php echo intval($result['counts']['data_cnt'] ?? 0); ?></b>
|
||||
| 设备总数:<b><?php echo intval($result['counts']['dev_cnt'] ?? 0); ?></b>
|
||||
</p>
|
||||
<p class="text-muted">最近 10 条该设备的测试记录(device_code 匹配):</p>
|
||||
<?php if (empty($result['rows'])): ?>
|
||||
<div class="alert alert-info">该设备暂无测试记录。</div>
|
||||
<?php else: ?>
|
||||
<table class="table table-bordered table-hover">
|
||||
<thead>
|
||||
<tr><th>ID</th><th>二维码/条码</th><th>产品型号</th><th>测试结果</th><th>测试时间</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($result['rows'] as $r): ?>
|
||||
<tr>
|
||||
<td><?php echo intval($r['id']); ?></td>
|
||||
<td><?php echo htmlspecialchars($r['qr_code'] ?? ''); ?></td>
|
||||
<td><?php echo htmlspecialchars($r['product_model'] ?? ''); ?></td>
|
||||
<td><?php echo htmlspecialchars($r['test_result'] ?? ''); ?></td>
|
||||
<td><?php echo htmlspecialchars($r['test_date'] ?? ''); ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($result['action'] === 'manualConnect'): ?>
|
||||
<table class="table table-bordered" style="max-width:600px;">
|
||||
<tr><th style="width:160px;">目标</th><td><?php echo htmlspecialchars($result['device']['device_name'] ?? ''); ?></td></tr>
|
||||
<tr><th>地址</th><td><?php echo htmlspecialchars($result['ip']); ?> : <?php echo intval($result['port']); ?></td></tr>
|
||||
<tr><th>连接结果</th>
|
||||
<td>
|
||||
<?php if ($result['reachable']): ?>
|
||||
<span class="label label-success"><i class="fa fa-check"></i> 可达</span>
|
||||
<?php else: ?>
|
||||
<span class="label label-danger"><i class="fa fa-times"></i> 不可达</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr><th>延迟</th><td><?php echo $result['latency']; ?> ms</td></tr>
|
||||
<?php if ($result['error']): ?>
|
||||
<tr><th>错误信息</th><td class="text-danger"><?php echo htmlspecialchars($result['error']); ?></td></tr>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($result['action'] === 'writeData'): ?>
|
||||
<?php if (empty($result['error'])): ?>
|
||||
<div class="alert alert-success">
|
||||
<i class="fa fa-check-circle"></i> 数据读写链路正常(探针已写入并回读、清理)
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<table class="table table-bordered" style="max-width:700px;">
|
||||
<tr><th style="width:180px;">设备编号</th><td><?php echo htmlspecialchars($result['device_code']); ?></td></tr>
|
||||
<tr><th>探针二维码</th><td><code><?php echo htmlspecialchars($result['probe_code']); ?></code></td></tr>
|
||||
<tr><th>写入 ID</th><td><?php echo intval($result['written_id']); ?></td></tr>
|
||||
<tr><th>回读一致</th>
|
||||
<td>
|
||||
<?php if ($result['read_back_match']): ?>
|
||||
<span class="label label-success">一致</span>
|
||||
<?php else: ?>
|
||||
<span class="label label-danger">不一致</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr><th>探针记录已清理</th>
|
||||
<td>
|
||||
<?php if ($result['deleted']): ?>
|
||||
<span class="label label-success">已删除</span>
|
||||
<?php else: ?>
|
||||
<span class="label label-warning">未删除(请检查)</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if ($result['error']): ?>
|
||||
<tr><th>错误信息</th><td class="text-danger"><?php echo htmlspecialchars($result['error']); ?></td></tr>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php include APP_PATH . 'app/views/layouts/admin_footer.php'; ?>
|
||||
Reference in New Issue
Block a user