InventoryInboundAdminService.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using Microsoft.AspNetCore.Mvc;
  2. using Microsoft.Extensions.Logging;
  3. namespace Admin.NET.Plugin.AiDOP.MaterialWarehouse;
  4. /// <summary>库存冷链手工补偿入口(管理员)。不接受前端 tenantId/domain/entityCode。</summary>
  5. [ApiDescriptionSettings(Order = 310, Description = "S5库存冷链入站")]
  6. [Route("api/S5InventoryInbound")]
  7. [NonUnify]
  8. public sealed class InventoryInboundAdminService : IDynamicApiController, ITransient
  9. {
  10. private readonly InventoryMdpSyncService _sync;
  11. private readonly InventoryReconService _recon;
  12. private readonly ILogger _logger;
  13. public InventoryInboundAdminService(
  14. InventoryMdpSyncService sync,
  15. InventoryReconService recon,
  16. ILoggerFactory loggerFactory)
  17. {
  18. _sync = sync;
  19. _recon = recon;
  20. _logger = loggerFactory.CreateLogger(nameof(InventoryInboundAdminService));
  21. }
  22. [DisplayName("库存冷链首刷")]
  23. [HttpPost("bootstrap")]
  24. [ApiDescriptionSettings(Name = "S5InventoryBootstrap")]
  25. public async Task<InventorySyncResult> Bootstrap(CancellationToken ct)
  26. {
  27. _logger.LogInformation("[S5InventoryInbound] bootstrap requested");
  28. return await _sync.RunBootstrapAsync(ct);
  29. }
  30. [DisplayName("库存冷链跑一轮")]
  31. [HttpPost("run-once")]
  32. [ApiDescriptionSettings(Name = "S5InventoryRunOnce")]
  33. public async Task<InventorySyncResult> RunOnce(CancellationToken ct)
  34. {
  35. _logger.LogInformation("[S5InventoryInbound] run-once requested");
  36. return await _sync.RunIncrementalAsync(ct);
  37. }
  38. [DisplayName("库存冷链全量校准")]
  39. [HttpPost("reconcile")]
  40. [ApiDescriptionSettings(Name = "S5InventoryReconcile")]
  41. public async Task<InventorySyncResult> Reconcile(CancellationToken ct)
  42. {
  43. _logger.LogInformation("[S5InventoryInbound] reconcile requested");
  44. return await _sync.RunReconcileFullAsync(ct);
  45. }
  46. [DisplayName("库存流水 stg→std 补转换")]
  47. [HttpPost("transform-std")]
  48. [ApiDescriptionSettings(Name = "S5InventoryTransformStd")]
  49. public async Task<InventorySyncResult> TransformStd(CancellationToken ct)
  50. {
  51. _logger.LogInformation("[S5InventoryInbound] transform-std requested");
  52. return await _sync.TransformTransStdFromStgAsync(ct);
  53. }
  54. [DisplayName("库存日终对账(手工)")]
  55. [HttpPost("daily-recon")]
  56. [ApiDescriptionSettings(Name = "S5InventoryDailyRecon")]
  57. public async Task<object> DailyRecon(CancellationToken ct)
  58. {
  59. _logger.LogInformation("[S5InventoryInbound] daily-recon requested");
  60. var diffs = await _recon.RunDailyReconAsync(ct);
  61. return new { diffs, message = diffs == 0 ? "clean" : "diffs written" };
  62. }
  63. }