完善保险端前后端和养殖端小程序
This commit is contained in:
97
backend/check-other-databases.js
Normal file
97
backend/check-other-databases.js
Normal file
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* 检查其他数据库
|
||||
* @file check-other-databases.js
|
||||
* @description 检查其他数据库中是否有项圈22012000107的数据
|
||||
*/
|
||||
|
||||
const mysql = require('mysql2/promise');
|
||||
|
||||
async function checkOtherDatabases() {
|
||||
console.log('🔍 检查其他数据库中项圈22012000107的数据...\n');
|
||||
|
||||
const databases = ['nxxmdata', 'nxdata', 'datav', 'aipet_new'];
|
||||
|
||||
for (const dbName of databases) {
|
||||
try {
|
||||
console.log(`\n=== 检查数据库: ${dbName} ===`);
|
||||
|
||||
// 创建连接
|
||||
const connection = await mysql.createConnection({
|
||||
host: '192.168.0.240',
|
||||
port: 3306,
|
||||
user: 'root',
|
||||
password: '', // 根据实际情况填写密码
|
||||
database: dbName
|
||||
});
|
||||
|
||||
// 查询项圈22012000107的数据
|
||||
const [results] = await connection.execute(`
|
||||
SELECT
|
||||
id, sn, deviceId, battery, temperature, state,
|
||||
uptime, longitude, latitude, gps_state, rsrp
|
||||
FROM iot_xq_client
|
||||
WHERE sn = '22012000107'
|
||||
ORDER BY uptime DESC
|
||||
LIMIT 5
|
||||
`);
|
||||
|
||||
console.log(`找到 ${results.length} 条记录`);
|
||||
|
||||
results.forEach((row, index) => {
|
||||
console.log(`\n记录${index + 1}:`);
|
||||
console.log('ID:', row.id);
|
||||
console.log('SN:', row.sn);
|
||||
console.log('设备ID:', row.deviceId);
|
||||
console.log('电量:', row.battery);
|
||||
console.log('温度:', row.temperature);
|
||||
console.log('状态:', row.state);
|
||||
console.log('经度:', row.longitude);
|
||||
console.log('纬度:', row.latitude);
|
||||
console.log('GPS状态:', row.gps_state);
|
||||
console.log('RSRP:', row.rsrp);
|
||||
console.log('更新时间:', row.uptime);
|
||||
});
|
||||
|
||||
await connection.end();
|
||||
|
||||
} catch (error) {
|
||||
console.log(`❌ 数据库 ${dbName} 检查失败:`, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
// 检查当前数据库的最新数据
|
||||
console.log('\n=== 检查当前数据库的最新数据 ===');
|
||||
try {
|
||||
const connection = await mysql.createConnection({
|
||||
host: '192.168.0.240',
|
||||
port: 3306,
|
||||
user: 'root',
|
||||
password: '',
|
||||
database: 'nxxmdata'
|
||||
});
|
||||
|
||||
// 查询所有项圈的最新数据
|
||||
const [allResults] = await connection.execute(`
|
||||
SELECT
|
||||
id, sn, deviceId, battery, temperature, state, uptime
|
||||
FROM iot_xq_client
|
||||
ORDER BY uptime DESC
|
||||
LIMIT 20
|
||||
`);
|
||||
|
||||
console.log('所有项圈的最新数据:');
|
||||
allResults.forEach((row, index) => {
|
||||
console.log(`${index + 1}. SN: ${row.sn}, 电量: ${row.battery}, 温度: ${row.temperature}, 状态: ${row.state}, 更新时间: ${row.uptime}`);
|
||||
});
|
||||
|
||||
await connection.end();
|
||||
|
||||
} catch (error) {
|
||||
console.log('❌ 查询当前数据库失败:', error.message);
|
||||
}
|
||||
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
// 运行检查
|
||||
checkOtherDatabases().catch(console.error);
|
||||
Reference in New Issue
Block a user