feat(M06-E): 接入智慧插座业务控制
This commit is contained in:
@@ -91,6 +91,12 @@ const service = new IotMessageService({
|
||||
async execute(sql, params) {
|
||||
calls.push({ sql, params });
|
||||
if (sql.includes('FROM qipai_devices')) {
|
||||
if (params[0] === 'SOCKET_001') {
|
||||
return [[{
|
||||
id: 52, tenantId: 7, storeId: 11, roomId: 31,
|
||||
deviceId: 'SOCKET_001', deviceType: 'SMART_SOCKET'
|
||||
}], []];
|
||||
}
|
||||
return [[{
|
||||
id: 51, tenantId: 7, storeId: 11, roomId: 31,
|
||||
deviceId: 'BOX_001', deviceType: 'CONTROL_BOX'
|
||||
@@ -150,6 +156,22 @@ assert.equal(calls.some((item) =>
|
||||
item.sql.includes('INSERT INTO qipai_device_alerts')
|
||||
&& item.params.includes('DEVICE_UNCONFIRM')
|
||||
), true);
|
||||
await service.handle('/devicesend/SOCKET_001', Buffer.from(JSON.stringify({
|
||||
DeviceID: 'SOCKET_001', event: 'workInfo', switch: 'on',
|
||||
powerW: 3601, temperature: 82, overLoad: true
|
||||
})));
|
||||
assert.equal(calls.some((item) =>
|
||||
item.sql.includes('INSERT INTO qipai_device_alerts')
|
||||
&& item.params.includes('SOCKET_OVERLOAD')
|
||||
), true);
|
||||
assert.equal(calls.some((item) =>
|
||||
item.sql.includes('INSERT INTO qipai_device_alerts')
|
||||
&& item.params.includes('SOCKET_POWER_LIMIT')
|
||||
), true);
|
||||
assert.equal(calls.some((item) =>
|
||||
item.sql.includes('INSERT INTO qipai_device_alerts')
|
||||
&& item.params.includes('SOCKET_TEMPERATURE_LIMIT')
|
||||
), true);
|
||||
|
||||
await assert.rejects(
|
||||
() => service.createCommand({
|
||||
|
||||
Reference in New Issue
Block a user