feat: regel 'Hent først når kilden er over X %' for salgsflows (v1.62.68)
This commit is contained in:
@@ -68,7 +68,7 @@ end
|
||||
|
||||
local RUN_FIELDS = {
|
||||
"id", "name", "kind", "sourceBuildingIds", "targetBuildingIds", "storeBuildingIds", "products",
|
||||
"ingredientMode", "ingredients", "sellAtPercent", "storeAbovePercent", "sellAbovePercent", "collectRound", "loops",
|
||||
"ingredientMode", "ingredients", "sellAtPercent", "storeAbovePercent", "sellAbovePercent", "minSourcePercent", "collectRound", "loops",
|
||||
"returnBelowPercent", "waitPoolGroup", "vehicleIds", "wagons", "chain",
|
||||
}
|
||||
|
||||
@@ -83,6 +83,7 @@ local function draftFrom(run, isNew)
|
||||
draft.sellAtPercent = draft.sellAtPercent or ADRuns.DEFAULT_SELL_AT_PERCENT
|
||||
draft.storeAbovePercent = draft.storeAbovePercent or ADRuns.DEFAULT_STORE_ABOVE_PERCENT
|
||||
draft.sellAbovePercent = draft.sellAbovePercent or ADRuns.DEFAULT_SELL_ABOVE_PERCENT
|
||||
draft.minSourcePercent = draft.minSourcePercent or ADRuns.DEFAULT_MIN_SOURCE_PERCENT
|
||||
draft.returnBelowPercent = draft.returnBelowPercent or ADRuns.DEFAULT_RETURN_BELOW_PERCENT
|
||||
draft.loops = draft.loops or 0
|
||||
draft.waitPoolGroup = draft.waitPoolGroup or ""
|
||||
@@ -169,7 +170,7 @@ end
|
||||
-- ---- valg ----
|
||||
|
||||
local SET_VALUES = {
|
||||
kind = true, ingredientMode = true, sellAtPercent = true, storeAbovePercent = true, sellAbovePercent = true, loops = true,
|
||||
kind = true, ingredientMode = true, sellAtPercent = true, storeAbovePercent = true, sellAbovePercent = true, minSourcePercent = true, loops = true,
|
||||
returnBelowPercent = true, waitPoolGroup = true,
|
||||
}
|
||||
local BOOL_VALUES = {showAllBuildings = true, storeAuto = true, collectRound = true}
|
||||
@@ -246,6 +247,12 @@ local function sellAboveOptions()
|
||||
return options
|
||||
end
|
||||
|
||||
local function minSourceOptions()
|
||||
local options = {{label = L("spu_minSource_off"), value = 0}}
|
||||
for _, option in ipairs(percentOptions(10, 90, 10)) do table.insert(options, option) end
|
||||
return options
|
||||
end
|
||||
|
||||
local function chosenSet(list)
|
||||
local set = {}
|
||||
for _, value in ipairs(list or {}) do set[value] = true end
|
||||
@@ -347,6 +354,7 @@ local function rowsRules(guide)
|
||||
end
|
||||
if stores then table.insert(rows, choice("storeAbovePercent", L("spu_storeAbove"), percentOptions(ADRuns.MIN_STORE_ABOVE_PERCENT, ADRuns.MAX_STORE_ABOVE_PERCENT, 5), draft.storeAbovePercent)) end
|
||||
if sells then table.insert(rows, choice("sellAbovePercent", L("spu_sellAbove"), sellAboveOptions(), draft.sellAbovePercent)) end
|
||||
if sells then table.insert(rows, choice("minSourcePercent", L("spu_minSource"), minSourceOptions(), draft.minSourcePercent or 0)) end
|
||||
table.insert(rows, toggle("collectRound", L("spu_collectRound"), draft.collectRound))
|
||||
return rows
|
||||
end
|
||||
@@ -504,6 +512,7 @@ local SUMMARY = {
|
||||
if sells then table.insert(parts, draft.sellAtPercent == 0 and L("spu_guide_flow_sumSellAlways") or L("spu_guide_flow_sumSellAt", {draft.sellAtPercent})) end
|
||||
if stores then table.insert(parts, L("spu_guide_flow_sumStoreAbove", {draft.storeAbovePercent})) end
|
||||
if sells and (draft.sellAbovePercent or 0) > 0 then table.insert(parts, L("spu_guide_flow_sumSellAbove", {draft.sellAbovePercent})) end
|
||||
if sells and (draft.minSourcePercent or 0) > 0 then table.insert(parts, L("spu_guide_flow_sumMinSource", {draft.minSourcePercent})) end
|
||||
if draft.collectRound then table.insert(parts, L("spu_guide_flow_sumRound")) end
|
||||
return parts
|
||||
end
|
||||
@@ -552,6 +561,7 @@ function ADFlowGuide.result(guide)
|
||||
products = ADGuide.deepCopy(draft.products), ingredientMode = draft.ingredientMode,
|
||||
ingredients = ADGuide.deepCopy(draft.ingredients), sellAtPercent = draft.sellAtPercent,
|
||||
storeAbovePercent = draft.storeAbovePercent, sellAbovePercent = draft.sellAbovePercent or 0,
|
||||
minSourcePercent = draft.minSourcePercent or 0,
|
||||
collectRound = draft.collectRound, loops = draft.loops,
|
||||
returnBelowPercent = draft.returnBelowPercent, waitPoolGroup = draft.waitPoolGroup or "",
|
||||
}
|
||||
|
||||
@@ -365,6 +365,7 @@ function ADOutbound.buildPlanInput(adEnv, run, vehicle)
|
||||
sellAtPercent = run.sellAtPercent,
|
||||
storeAbovePercent = run.storeAbovePercent,
|
||||
sellAbovePercent = run.sellAbovePercent,
|
||||
minSourcePercent = run.minSourcePercent,
|
||||
collectRound = run.collectRound == true,
|
||||
products = products,
|
||||
}
|
||||
|
||||
@@ -71,6 +71,8 @@ function ADOutboundPlanner.evaluate(product, input)
|
||||
priceOk = input.sellAtPercent == 0 or (percent ~= nil and percent >= (input.sellAtPercent or 90)),
|
||||
-- "sælg altid over X %": kilden er så fuld, at der sælges uanset pris
|
||||
overflow = (input.sellAbovePercent or 0) > 0 and storagePercent >= input.sellAbovePercent,
|
||||
-- "hent først ved X %": salg venter til kilden er så fuld, eller et fuldt læs ligger klar (0 = fra)
|
||||
minSourceOk = (input.minSourcePercent or 0) <= 0 or fullLoad or storagePercent >= input.minSourcePercent,
|
||||
}
|
||||
end
|
||||
|
||||
@@ -101,6 +103,10 @@ local function reasonFor(product, e, input)
|
||||
local names = table.concat(product.reservedFor or {}, ", ")
|
||||
return string.format("%s: %s reserveret til %s", product.name, formatLiters(e.reserve), names ~= "" and names or "gårdens eget forbrug")
|
||||
end
|
||||
if wantsSell(product.policy) and (e.priceOk or e.overflow) and product.quote ~= nil and not e.minSourceOk then
|
||||
return string.format("%s: lager %d %% (henter fra %d %% eller fuldt læs)", product.name,
|
||||
math.floor(e.storagePercent + 0.5), input.minSourcePercent)
|
||||
end
|
||||
local canStore = wantsStore(product.policy) and product.store ~= nil
|
||||
if wantsSell(product.policy) and product.quote == nil and not canStore then
|
||||
return product.name .. ": intet nåeligt salgssted"
|
||||
@@ -126,7 +132,7 @@ local function collectCandidates(input)
|
||||
local e = ADOutboundPlanner.evaluate(product, input)
|
||||
local added = false
|
||||
if e.available >= ADOutboundPlanner.MIN_AVAILABLE_LITERS then
|
||||
if wantsSell(product.policy) and (e.priceOk or e.overflow) and product.quote ~= nil and canSellWithoutReserve(e, input) then
|
||||
if wantsSell(product.policy) and (e.priceOk or e.overflow) and e.minSourceOk and product.quote ~= nil and canSellWithoutReserve(e, input) then
|
||||
table.insert(sell, {product = product, e = e, kind = "sell", targetWayPointId = product.quote.wayPointId, targetName = product.quote.stationName, percent = e.percent})
|
||||
added = true
|
||||
elseif wantsStore(product.policy) and (e.fullLoad or e.storageHigh or (input.feedMode and e.available >= ADOutboundPlanner.FEED_MIN_LITERS)) and product.store ~= nil then
|
||||
|
||||
@@ -20,6 +20,8 @@ ADRuns.DEFAULT_STORE_ABOVE_PERCENT, ADRuns.MIN_STORE_ABOVE_PERCENT, ADRuns.MAX_S
|
||||
-- "Sælg altid over X %": kildens lager over grænsen sælges uanset pris (0 = fra). Så hober f.eks. gylle
|
||||
-- ved BGA'en sig ikke op, når prisen er lav.
|
||||
ADRuns.DEFAULT_SELL_ABOVE_PERCENT, ADRuns.MIN_SELL_ABOVE_PERCENT, ADRuns.MAX_SELL_ABOVE_PERCENT = 0, 0, 100
|
||||
-- "hent først ved X % i kilden" (0 = fra): salg venter til kilden er så fuld eller et fuldt læs ligger klar
|
||||
ADRuns.DEFAULT_MIN_SOURCE_PERCENT, ADRuns.MIN_MIN_SOURCE_PERCENT, ADRuns.MAX_MIN_SOURCE_PERCENT = 0, 0, 95
|
||||
|
||||
local function copyList(list)
|
||||
local copy = {}
|
||||
@@ -86,6 +88,7 @@ local function copyRun(run)
|
||||
sellAtPercent = run.sellAtPercent,
|
||||
storeAbovePercent = run.storeAbovePercent,
|
||||
sellAbovePercent = run.sellAbovePercent,
|
||||
minSourcePercent = run.minSourcePercent,
|
||||
collectRound = run.collectRound,
|
||||
targetWayPointId = run.targetWayPointId,
|
||||
targetWayPointIds = copyList(run.targetWayPointIds),
|
||||
@@ -138,6 +141,7 @@ function ADRuns.createRun(store, name, kind)
|
||||
sellAtPercent = ADRuns.DEFAULT_SELL_AT_PERCENT,
|
||||
storeAbovePercent = ADRuns.DEFAULT_STORE_ABOVE_PERCENT,
|
||||
sellAbovePercent = ADRuns.DEFAULT_SELL_ABOVE_PERCENT,
|
||||
minSourcePercent = ADRuns.DEFAULT_MIN_SOURCE_PERCENT,
|
||||
collectRound = false,
|
||||
targetWayPointId = nil,
|
||||
targetWayPointIds = {},
|
||||
@@ -207,6 +211,7 @@ function ADRuns.updateRun(store, runId, changes)
|
||||
if changes.sellAtPercent ~= nil then run.sellAtPercent = tonumber(changes.sellAtPercent) == 0 and 0 or clampRange(changes.sellAtPercent, ADRuns.DEFAULT_SELL_AT_PERCENT, ADRuns.MIN_SELL_AT_PERCENT, ADRuns.MAX_SELL_AT_PERCENT) end
|
||||
if changes.storeAbovePercent ~= nil then run.storeAbovePercent = clampRange(changes.storeAbovePercent, ADRuns.DEFAULT_STORE_ABOVE_PERCENT, ADRuns.MIN_STORE_ABOVE_PERCENT, ADRuns.MAX_STORE_ABOVE_PERCENT) end
|
||||
if changes.sellAbovePercent ~= nil then run.sellAbovePercent = clampRange(changes.sellAbovePercent, ADRuns.DEFAULT_SELL_ABOVE_PERCENT, ADRuns.MIN_SELL_ABOVE_PERCENT, ADRuns.MAX_SELL_ABOVE_PERCENT) end
|
||||
if changes.minSourcePercent ~= nil then run.minSourcePercent = clampRange(changes.minSourcePercent, ADRuns.DEFAULT_MIN_SOURCE_PERCENT, ADRuns.MIN_MIN_SOURCE_PERCENT, ADRuns.MAX_MIN_SOURCE_PERCENT) end
|
||||
if changes.collectRound ~= nil then run.collectRound = changes.collectRound == true end
|
||||
if changes.chain ~= nil then run.chain = tostring(changes.chain) end
|
||||
return new
|
||||
@@ -442,6 +447,7 @@ function ADRuns.toRecords(store)
|
||||
sellAt = run.sellAtPercent,
|
||||
storeAbove = run.storeAbovePercent,
|
||||
sellAbove = run.sellAbovePercent or 0,
|
||||
minSource = run.minSourcePercent or 0,
|
||||
collectRound = run.collectRound and 1 or 0,
|
||||
stopped = run.stopped and 1 or 0,
|
||||
sleeping = run.sleeping and 1 or 0,
|
||||
@@ -490,6 +496,7 @@ function ADRuns.fromRecords(records)
|
||||
sellAtPercent = tonumber(record.sellAt) == 0 and 0 or clampRange(record.sellAt, ADRuns.DEFAULT_SELL_AT_PERCENT, ADRuns.MIN_SELL_AT_PERCENT, ADRuns.MAX_SELL_AT_PERCENT),
|
||||
storeAbovePercent = clampRange(record.storeAbove, ADRuns.DEFAULT_STORE_ABOVE_PERCENT, ADRuns.MIN_STORE_ABOVE_PERCENT, ADRuns.MAX_STORE_ABOVE_PERCENT),
|
||||
sellAbovePercent = clampRange(record.sellAbove, ADRuns.DEFAULT_SELL_ABOVE_PERCENT, ADRuns.MIN_SELL_ABOVE_PERCENT, ADRuns.MAX_SELL_ABOVE_PERCENT),
|
||||
minSourcePercent = clampRange(record.minSource, ADRuns.DEFAULT_MIN_SOURCE_PERCENT, ADRuns.MIN_MIN_SOURCE_PERCENT, ADRuns.MAX_MIN_SOURCE_PERCENT),
|
||||
collectRound = tonumber(record.collectRound) == 1,
|
||||
targetWayPointId = targets[1],
|
||||
targetWayPointIds = targets,
|
||||
|
||||
@@ -47,6 +47,7 @@ function ADRunsStorage.writeRecords(xmlFile, records)
|
||||
xmlFile:setInt(key .. "#sellAt", record.sellAt or ADRuns.DEFAULT_SELL_AT_PERCENT)
|
||||
xmlFile:setInt(key .. "#storeAbove", record.storeAbove or ADRuns.DEFAULT_STORE_ABOVE_PERCENT)
|
||||
xmlFile:setInt(key .. "#sellAbove", record.sellAbove or 0)
|
||||
xmlFile:setInt(key .. "#minSource", record.minSource or 0)
|
||||
xmlFile:setInt(key .. "#collectRound", record.collectRound or 0)
|
||||
-- maskinpulje: flowet stoppet + husket vogn pr. traktor
|
||||
xmlFile:setInt(key .. "#stopped", record.stopped or 0)
|
||||
@@ -81,6 +82,7 @@ function ADRunsStorage.readRecords(xmlFile)
|
||||
sellAt = xmlFile:getInt(key .. "#sellAt"),
|
||||
storeAbove = xmlFile:getInt(key .. "#storeAbove"),
|
||||
sellAbove = xmlFile:getInt(key .. "#sellAbove"),
|
||||
minSource = xmlFile:getInt(key .. "#minSource"),
|
||||
collectRound = xmlFile:getInt(key .. "#collectRound"),
|
||||
stopped = xmlFile:getInt(key .. "#stopped"),
|
||||
sleeping = xmlFile:getInt(key .. "#sleeping"),
|
||||
|
||||
@@ -317,6 +317,8 @@
|
||||
<text name="spu_storeAbove" text="Kør til lager over"/>
|
||||
<text name="spu_sellAbove" text="Sælg altid når kilden er over"/>
|
||||
<text name="spu_sellAbove_off" text="Fra"/>
|
||||
<text name="spu_minSource" text="Hent først når kilden er over"/>
|
||||
<text name="spu_minSource_off" text="Fra (hent alt)"/>
|
||||
<text name="spu_storeAbove_tooltip" text="Varer med Lager-politik køres til silo når kildens lager er over denne fyldning (eller der er et fuldt læs)."/>
|
||||
<text name="spu_collectRound" text="Saml op på én tur"/>
|
||||
<text name="spu_collectRound_tooltip" text="Tipvogn: samme vare fra flere kilder til vognen er fuld. Autoload-vogn: flere pallevarer med samme mål på én tur."/>
|
||||
@@ -526,6 +528,7 @@
|
||||
<text name="spu_guide_flow_sumSellAt" text="sælg fra %d %%"/>
|
||||
<text name="spu_guide_flow_sumStoreAbove" text="lager over %d %%"/>
|
||||
<text name="spu_guide_flow_sumSellAbove" text="sælg altid over %d %%"/>
|
||||
<text name="spu_guide_flow_sumMinSource" text="henter først ved %d %% (eller fuldt læs)"/>
|
||||
<text name="spu_guide_flow_sumRound" text="samlerunde"/>
|
||||
<text name="spu_guide_flow_sumLoops" text="%d ture"/>
|
||||
<text name="spu_guide_flow_sumLoopsInf" text="uendelige ture"/>
|
||||
|
||||
@@ -317,6 +317,8 @@
|
||||
<text name="spu_storeAbove" text="Drive to storage above"/>
|
||||
<text name="spu_sellAbove" text="Always sell when source is above"/>
|
||||
<text name="spu_sellAbove_off" text="Off"/>
|
||||
<text name="spu_minSource" text="Only fetch when source is above"/>
|
||||
<text name="spu_minSource_off" text="Off (fetch any amount)"/>
|
||||
<text name="spu_storeAbove_tooltip" text="Goods with the Store policy are driven to a silo when the source storage is above this fill level (or a full load is available)."/>
|
||||
<text name="spu_collectRound" text="Collect in one trip"/>
|
||||
<text name="spu_collectRound_tooltip" text="Tipper: same good from several sources until full. Autoload trailer: several pallet goods with the same destination in one trip."/>
|
||||
@@ -526,6 +528,7 @@
|
||||
<text name="spu_guide_flow_sumSellAt" text="sell from %d %%"/>
|
||||
<text name="spu_guide_flow_sumStoreAbove" text="store above %d %%"/>
|
||||
<text name="spu_guide_flow_sumSellAbove" text="always sell above %d %%"/>
|
||||
<text name="spu_guide_flow_sumMinSource" text="fetches from %d %% (or a full load)"/>
|
||||
<text name="spu_guide_flow_sumRound" text="collection round"/>
|
||||
<text name="spu_guide_flow_sumLoops" text="%d trips"/>
|
||||
<text name="spu_guide_flow_sumLoopsInf" text="endless trips"/>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<modDesc descVersion="107">
|
||||
<author>masterdraco</author>
|
||||
<version>1.62.67.0</version>
|
||||
<version>1.62.68.0</version>
|
||||
<title>
|
||||
<en>AD Smart Pickup</en>
|
||||
</title>
|
||||
|
||||
Reference in New Issue
Block a user