feat: paller — 'fuldt læs' for autoload-bil = mindst 4 paller klar (ved spawner eller i objektlager) (v1.12.14.0)

This commit is contained in:
2026-09-23 15:30:51 +02:00
parent 2714d11ab8
commit b6c729ac59
7 changed files with 46 additions and 13 deletions
+14 -4
View File
@@ -20,6 +20,8 @@ ADOutboundPlanner = {}
ADOutboundPlanner.MIN_AVAILABLE_LITERS = 1
-- Opsamlingsrunde (bulk): næste kilde besøges kun hvis mindst så stor en andel af vognen er fri.
ADOutboundPlanner.ROUND_MIN_FREE_FRACTION = 0.1
-- Paller: en autoload-bil opgiver ingen liter-kapacitet, så "fuldt læs" = mindst så mange paller klar.
ADOutboundPlanner.PALLET_FULL_LOAD_COUNT = 4
local function wantsSell(policy)
return policy == "sell" or policy == "sellElseStore"
@@ -31,25 +33,33 @@ end
-- Samlet tilgængeligt over kilderne og den højeste fyldningsgrad (%) blandt dem.
local function sumSources(product)
local total, percent = 0, 0
local total, percent, pallets = 0, 0, 0
for _, source in ipairs(product.sources or {}) do
total = total + (source.available or 0)
pallets = pallets + (source.palletCount or 0)
if source.capacity ~= nil and source.capacity > 0 then
percent = math.max(percent, 100 * (source.level or 0) / source.capacity)
end
end
return total, percent
return total, percent, pallets
end
function ADOutboundPlanner.evaluate(product, input)
local available, storagePercent = sumSources(product)
local available, storagePercent, palletCount = sumSources(product)
local percent = product.quote ~= nil and product.quote.percent or nil
local reserve = math.max(0, product.reserve or 0)
local fullLoad
if input.capacity ~= nil and input.capacity > 0 then
fullLoad = available >= input.capacity
else
fullLoad = product.isPallet == true and palletCount >= ADOutboundPlanner.PALLET_FULL_LOAD_COUNT
end
return {
available = available,
reserve = reserve,
sellable = math.max(0, available - reserve),
fullLoad = input.capacity ~= nil and input.capacity > 0 and available >= input.capacity,
palletCount = palletCount,
fullLoad = fullLoad,
storagePercent = storagePercent,
storageHigh = storagePercent >= (input.storeAbovePercent or 80),
percent = percent,