feat(M08-C): 补保洁与设备运营

This commit is contained in:
Codex
2026-08-10 10:52:06 +08:00
parent a95e8bf8c8
commit 65932a8000
17 changed files with 815 additions and 104 deletions
@@ -37,6 +37,8 @@ import { ThirdPartyClient } from '../dist/third-party/third-party-client.js';
import { ThirdPartyService } from '../dist/third-party/third-party-service.js';
import { DeviceRepository } from '../dist/devices/device-repository.js';
import { IotMessageService } from '../dist/devices/iot-message-service.js';
import { DeviceCommandService } from '../dist/devices/device-command-service.js';
import { DeviceControlService } from '../dist/devices/device-control-service.js';
import { MemberProfileService } from '../dist/wallets/member-profile-service.js';
import {
executeMigrationPlan,
@@ -1724,6 +1726,44 @@ async function assertDeviceTopology(pool, context) {
signalStrength: 22, firmwareVersion: '1.0.1',
snapshot: { slot1: true, door: 'closed' }
});
const published = [];
const control = new DeviceControlService(
pool,
new DeviceCommandService(new IotMessageService(pool), {
async publishDeviceCommand(deviceId, payload) {
published.push({ deviceId, payload: JSON.parse(payload) });
}
})
);
const doorResult = await control.controlDoor({
tenantId: context.tenantId,
storeId,
roomId,
traceId: 'm08c-manager-door',
actorType: 'ADMIN',
actorId: adminId,
ip: '127.0.0.1',
userAgent: 'M08-C manager miniapp',
access
}, { order: 'open', holdopen: 0, delayTime: 4 });
assert.equal(doorResult.status, 'PUBLISHED');
assert.equal(published[0].deviceId, 'M06B_BOX_001');
assert.equal(published[0].payload.action, 'Crldoor');
const [commandAuditRows] = await pool.query(
`SELECT actor_type AS actorType, actor_id AS actorId, action,
JSON_UNQUOTE(JSON_EXTRACT(metadata, '$.commandType')) AS commandType,
JSON_UNQUOTE(JSON_EXTRACT(metadata, '$.roomId')) AS roomId
FROM qipai_audit_logs
WHERE tenant_id = ? AND trace_id = 'm08c-manager-door'`,
[context.tenantId]
);
assert.deepEqual(commandAuditRows, [{
actorType: 'ADMIN',
actorId: Number(adminId),
action: 'DEVICE_COMMAND_REQUESTED',
commandType: 'Crldoor',
roomId
}]);
await repository.addMaintenance(actor, {
assetId: controlBox.assetId, storeId, roomId,
recordType: 'INSPECTION', status: 'OPEN', description: 'M06-B inspection'
@@ -2051,6 +2091,8 @@ try {
'Sub-1G parent-child topology',
'device status snapshots and maintenance state'
,
'manager device command actor audit attribution'
,
'13-digit IoT command state transition',
'QoS 1 duplicate event receive count',
'ACK correlation without duplicate side effects',