diff --git a/gateway/NuGet.Config b/gateway/NuGet.Config
new file mode 100644
index 0000000..765346e
--- /dev/null
+++ b/gateway/NuGet.Config
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/gateway/src/IntegrationGateway.Adapters.Kms/KmsAdapter.cs b/gateway/src/IntegrationGateway.Adapters.Kms/KmsAdapter.cs
index 5a02c7a..671114d 100644
--- a/gateway/src/IntegrationGateway.Adapters.Kms/KmsAdapter.cs
+++ b/gateway/src/IntegrationGateway.Adapters.Kms/KmsAdapter.cs
@@ -17,7 +17,7 @@ namespace IntegrationGateway.Adapters.Kms;
///
/// 按设计文档 §6 KmsAdapter 完整实现。
///
-public class KmsAdapter : IHasFlatDevices, IHasAlarms
+public class KmsAdapter : IHasFlatDevices, IHasAlarms, IAcceptsControl, IHasBusinessLogs, IAcceptsDataSync
{
private readonly HttpClient _http;
private readonly KmsAuthHelper _auth;
@@ -237,4 +237,101 @@ public class KmsAdapter : IHasFlatDevices, IHasAlarms
resp.EnsureSuccessStatusCode();
return await resp.Content.ReadAsStringAsync();
}
+
+ // ═══════════════════════════════════════════
+ // IAcceptsControl — 设备控制(远程开门)
+ // ═══════════════════════════════════════════
+
+ /// 向设备下发控制指令(如远程开门)
+ public async Task SendControlAsync(string sourceDeviceId, string command, Dictionary parameters)
+ {
+ await _limiter.WaitAsync();
+ try
+ {
+ if (command == "open" || command == "authorize")
+ {
+ var req = new KmsRemotePermissionRequest
+ {
+ StaffIds = parameters.TryGetValue("staffIds", out var s) && s is List sl ? sl : null,
+ OpenerIds = parameters.TryGetValue("lockholeSort", out var lh) ? new List { (int)(long)lh! } : null,
+ Type = command == "authorize" ? 2 : 1
+ };
+ await RemoteAuthorizeAsync(req);
+ }
+ return new ControlResult { Success = true };
+ }
+ catch (Exception ex)
+ {
+ return new ControlResult { Success = false, Message = ex.Message };
+ }
+ }
+
+ // ═══════════════════════════════════════════
+ // IHasBusinessLogs — 业务记录查询
+ // ═══════════════════════════════════════════
+
+ /// 按类型查询业务记录
+ public async Task> GetBusinessLogsAsync(
+ string logType, DateTime? from, DateTime? to, int page, int size, Dictionary? filters = null)
+ {
+ if (logType == "borrow" || logType == "handover")
+ {
+ var records = await GetBorrowRecordsAsync(from, to);
+ return new PagedResult
+ {
+ Items = records.Items.Select(r => new BusinessLogEntry
+ {
+ LogId = r.Uuid ?? "", LogType = logType,
+ DeviceSourceId = $"lockhole_{r.LockerName}_{r.LockholeSort}",
+ StaffName = r.StaffName, Description = r.OpenerName,
+ CreatedAt = DateTime.TryParse(r.BorrowTime, out var bt) ? bt : null
+ }).ToList(),
+ Total = records.Total
+ };
+ }
+ if (logType == "permission")
+ {
+ var perms = await GetPermissionListAsync(from, to);
+ return new PagedResult
+ {
+ Items = perms.Items.Select(p => new BusinessLogEntry
+ {
+ LogId = p.Uuid ?? "", LogType = "permission",
+ StaffName = p.LendStaffName, Description = p.OpenerCnName,
+ CreatedAt = DateTime.TryParse(p.ApplyTime, out var at) ? at : null
+ }).ToList(),
+ Total = perms.Total
+ };
+ }
+ return new PagedResult { Items = new(), Total = 0 };
+ }
+
+ // ═══════════════════════════════════════════
+ // IAcceptsDataSync — 数据同步写入
+ // ═══════════════════════════════════════════
+
+ /// 向 KMS 批量同步数据
+ public async Task SyncDataAsync(string dataType, List