using System.Text.Json;
using Admin.NET.Plugin.AiDOP.DataPlatform.Executors;
using Admin.NET.Plugin.AiDOP.Entity.DataPlatform;
using Microsoft.Extensions.Logging;
using SqlSugar;
namespace Admin.NET.Plugin.AiDOP.DataPlatform.Wms;
///
/// WP7 §2:WMS 六张基础数据表只读查询 + Outbox UPSERT 回写编排。
/// 不直写 165;执行侧实时量列禁止入队。
///
[ApiDescriptionSettings(Order = 326, Description = "WMS基础数据维护")]
[Route("api/aidop/wms-base")]
[AllowAnonymous]
[NonUnify]
public class WmsBaseDataService : IDynamicApiController, ITransient
{
public const string TargetSource = "DOPDEMORQ_SQLSERVER";
private static readonly HashSet AllowedTables = new(StringComparer.OrdinalIgnoreCase)
{
"DepartmentMaster", "EmployeeMaster", "LocationMaster",
"LocationShelfMaster", "EmpWorkDutyMaster", "LinePrinter"
};
private static readonly HashSet ShelfForbiddenWriteCols = new(StringComparer.OrdinalIgnoreCase)
{
"QtyOnHand", "UsedVolumeCapacity", "UsedWeightCapacity", "ContainerStatus"
};
private static readonly Dictionary BusinessKeys = new(StringComparer.OrdinalIgnoreCase)
{
["DepartmentMaster"] = ["Domain", "Department"],
["EmployeeMaster"] = ["Domain", "Employee"],
["LocationMaster"] = ["Domain", "Location"],
["LocationShelfMaster"] = ["Domain", "Location", "InvShelf"],
["EmpWorkDutyMaster"] = ["Domain", "RecID"],
["LinePrinter"] = ["Domain", "Line", "BarType"]
};
private readonly MdpSourceScopeFactory _scopeFactory;
private readonly MdpOutboxEnqueueService _enqueue;
private readonly ILogger _logger;
public WmsBaseDataService(
MdpSourceScopeFactory scopeFactory,
MdpOutboxEnqueueService enqueue,
ILogger logger)
{
_scopeFactory = scopeFactory;
_enqueue = enqueue;
_logger = logger;
}
[DisplayName("基础数据分页查询")]
[HttpGet("page")]
public async Task