feat(M08-C): 补保洁与设备运营
This commit is contained in:
@@ -12,6 +12,7 @@ const managerAccess = {
|
||||
storeIds: ['11']
|
||||
};
|
||||
const issued = [];
|
||||
const audits = [];
|
||||
const service = new DeviceControlService({
|
||||
async execute(sql) {
|
||||
if (sql.includes('FROM qipai_devices')) {
|
||||
@@ -26,6 +27,7 @@ const service = new DeviceControlService({
|
||||
deviceType: 'CONTROL_BOX', status: 'ONLINE'
|
||||
}], []];
|
||||
}
|
||||
if (sql.includes('DEVICE_COMMAND_REQUESTED')) audits.push(sql);
|
||||
return [[], []];
|
||||
}
|
||||
}, {
|
||||
@@ -37,6 +39,7 @@ const service = new DeviceControlService({
|
||||
});
|
||||
const context = {
|
||||
tenantId: '7', storeId: '11', roomId: '31', traceId: 'trace',
|
||||
actorType: 'ADMIN', actorId: '22', ip: '127.0.0.1', userAgent: 'test',
|
||||
access: managerAccess
|
||||
};
|
||||
|
||||
@@ -75,6 +78,8 @@ assert.equal(issued.at(-1).payload.action, 'localtask');
|
||||
assert.equal(issued.at(-1).payload.switch, 'on');
|
||||
await service.clearSmartSocketTask(context, 1);
|
||||
assert.equal(issued.at(-1).payload.action, 'clearTask');
|
||||
assert.equal(audits.length, 14);
|
||||
assert.match(audits[0], /DEVICE_COMMAND_REQUESTED/);
|
||||
|
||||
await assert.rejects(
|
||||
() => service.controlSubLock(context, {
|
||||
@@ -160,6 +165,25 @@ const response = await app.inject({
|
||||
});
|
||||
assert.equal(response.statusCode, 200);
|
||||
assert.equal(routed.slot1, 'on');
|
||||
const appPowerResponse = await app.inject({
|
||||
method: 'POST',
|
||||
url: '/app-api/management/device-control/power',
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
payload: { storeId: '11', roomId: '31', slotall: 'off' }
|
||||
});
|
||||
assert.equal(appPowerResponse.statusCode, 200);
|
||||
assert.equal(routed.slotall, 'off');
|
||||
const appDoorResponse = await app.inject({
|
||||
method: 'POST',
|
||||
url: '/app-api/management/device-control/door',
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
payload: { storeId: '11', roomId: '31', order: 'open', holdopen: 0, delayTime: 4 }
|
||||
});
|
||||
assert.equal(appDoorResponse.statusCode, 200);
|
||||
assert.equal(routed.order, 'open');
|
||||
assert.equal(routedContext.storeId, '11');
|
||||
assert.equal(routedContext.actorType, 'ADMIN');
|
||||
assert.equal(routedContext.actorId, '22');
|
||||
const socketResponse = await app.inject({
|
||||
method: 'POST',
|
||||
url: '/admin-api/device-control/socket/switch',
|
||||
|
||||
Reference in New Issue
Block a user