Documentation
¶
Index ¶
- func BaseBatchPresenter(b *pb.BaseBatchInfo) apiresource.Batch
- func BatchFlowNodePresenter(n *pb.BatchFlowNodeInfo) apiresource.BatchFlowNode
- func BatchListPresenter(ctx context.Context, resp *pb.ListBatchesByScanningStationResponse) *apiresource.List[apiresource.Batch]
- func BatchPresenter(b *pb.BatchInfo) apiresource.Batch
- func BatchQuantityPresenter(q *pb.BatchQuantityInfo) *apiresource.Quantity
- func OpenBatchSummaryPresenter(s *pb.OpenBatchSummaryInfo) apiresource.OpenBatchSummary
- func ScanningConsumptionPresenter(c *pb.ScanningConsumptionInfo) apiresource.ScanningConsumption
- func ScanningProductionStepInfoPresenter(s *pb.ScanningProductionStepInfoProto) apiresource.ScanningProductionStepInfo
- type AnalyzeOpenBatchesEndpoint
- type AnalyzeOpenBatchesRequest
- type BatchSvc
- type BatchSvcConfig
- type BulkDeleteBatchesEndpoint
- type CloseBatchEndpoint
- type CloseBatchRequest
- type DeleteBatchEndpoint
- type DeleteBatchRequest
- type DeleteManyBatchesRequest
- type GetBatchFlowEndpoint
- type GetBatchFlowRequest
- type GetPossibleNextStepsEndpoint
- type GetPossibleNextStepsRequest
- type GetRemainingQuantityToSplitEndpoint
- type GetRemainingQuantityToSplitRequest
- type GetScanningStationConsumptionEndpoint
- type GetScanningStationConsumptionRequest
- type InitializeBatchEndpoint
- type InitializeBatchRequest
- type ListBatchesByScanningStationEndpoint
- type ListBatchesByScanningStationRequest
- type MergeBatchesEndpoint
- type MergeBatchesRequest
- type MoveBatchesEndpoint
- type MoveBatchesRequest
- type SplitBatchEndpoint
- type SplitBatchRequest
- type SplitQuantityInput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BaseBatchPresenter ¶
func BaseBatchPresenter(b *pb.BaseBatchInfo) apiresource.Batch
BaseBatchPresenter converts a proto BaseBatchInfo to an apiresource.Batch. BaseBatchInfo is used for mutation responses and does not include machines.
func BatchFlowNodePresenter ¶
func BatchFlowNodePresenter(n *pb.BatchFlowNodeInfo) apiresource.BatchFlowNode
BatchFlowNodePresenter converts a proto BatchFlowNodeInfo to an apiresource.BatchFlowNode.
func BatchListPresenter ¶
func BatchListPresenter(ctx context.Context, resp *pb.ListBatchesByScanningStationResponse) *apiresource.List[apiresource.Batch]
BatchListPresenter converts a proto ListBatchesByScanningStationResponse to a paginated list.
func BatchPresenter ¶
func BatchPresenter(b *pb.BatchInfo) apiresource.Batch
BatchPresenter converts a proto BatchInfo to an apiresource.Batch.
func BatchQuantityPresenter ¶
func BatchQuantityPresenter(q *pb.BatchQuantityInfo) *apiresource.Quantity
BatchQuantityPresenter converts a proto BatchQuantityInfo to an apiresource.Quantity.
func OpenBatchSummaryPresenter ¶
func OpenBatchSummaryPresenter(s *pb.OpenBatchSummaryInfo) apiresource.OpenBatchSummary
OpenBatchSummaryPresenter converts a proto OpenBatchSummaryInfo to an apiresource.OpenBatchSummary.
func ScanningConsumptionPresenter ¶
func ScanningConsumptionPresenter(c *pb.ScanningConsumptionInfo) apiresource.ScanningConsumption
ScanningConsumptionPresenter converts a proto ScanningConsumptionInfo to an apiresource.ScanningConsumption.
func ScanningProductionStepInfoPresenter ¶
func ScanningProductionStepInfoPresenter(s *pb.ScanningProductionStepInfoProto) apiresource.ScanningProductionStepInfo
ScanningProductionStepInfoPresenter converts a proto ScanningProductionStepInfoProto to an apiresource.ScanningProductionStepInfo.
Types ¶
type AnalyzeOpenBatchesEndpoint ¶
type AnalyzeOpenBatchesEndpoint struct{}
Returns the work in progress currently sitting on the production floor, grouped by department, item, and scanning station.
Only batches that have been scanned at a scanning station and are not yet closed are counted, and each batch contributes its quantity less whatever has already moved downstream, so the totals show what is still left to work on. Each result covers one item at one scanning station.
func (*AnalyzeOpenBatchesEndpoint) Materialize ¶
func (e *AnalyzeOpenBatchesEndpoint) Materialize() *apiendpoint.APIEndpoint[*AnalyzeOpenBatchesRequest, *apiresource.List[apiresource.OpenBatchSummary]]
type AnalyzeOpenBatchesRequest ¶
type AnalyzeOpenBatchesRequest struct {
// Restrict the summaries to batches of these items; omit to include all items.
ItemIDs []string `json:"item_ids"`
// Restrict the summaries to batches whose item belongs to these product lines; omit to include all product lines.
ProductLineIDs []string `json:"product_line_ids"`
}
Request to analyze open batches.
func (*AnalyzeOpenBatchesRequest) SchemaExample ¶
func (*AnalyzeOpenBatchesRequest) SchemaExample() any
type BatchSvc ¶
type BatchSvc interface {
GetBatchFlow(ctx context.Context, req *GetBatchFlowRequest) (*apiresource.List[apiresource.BatchFlowNode], *apierror.APIError)
ListBatchesByScanningStation(ctx context.Context, req *ListBatchesByScanningStationRequest) (*apiresource.List[apiresource.Batch], *apierror.APIError)
GetPossibleNextSteps(ctx context.Context, req *GetPossibleNextStepsRequest) (*apiresource.List[apiresource.ScanningProductionStepInfo], *apierror.APIError)
AnalyzeOpenBatches(ctx context.Context, req *AnalyzeOpenBatchesRequest) (*apiresource.List[apiresource.OpenBatchSummary], *apierror.APIError)
InitializeBatch(ctx context.Context, req *InitializeBatchRequest) (*apiresource.Batch, *apierror.APIError)
MoveBatches(ctx context.Context, req *MoveBatchesRequest) (*apiresource.Batch, *apierror.APIError)
MergeBatches(ctx context.Context, req *MergeBatchesRequest) (*apiresource.Batch, *apierror.APIError)
SplitBatch(ctx context.Context, req *SplitBatchRequest) (*apiresource.Batch, *apierror.APIError)
GetRemainingQuantityToSplit(ctx context.Context, req *GetRemainingQuantityToSplitRequest) (*apiresource.Quantity, *apierror.APIError)
GetScanningStationConsumption(ctx context.Context, req *GetScanningStationConsumptionRequest) (*apiresource.List[apiresource.ScanningConsumption], *apierror.APIError)
CloseBatch(ctx context.Context, req *CloseBatchRequest) (*apiresource.Batch, *apierror.APIError)
DeleteBatch(ctx context.Context, req *DeleteBatchRequest) (*apiresource.Batch, *apierror.APIError)
DeleteManyBatches(ctx context.Context, req *DeleteManyBatchesRequest) (*apiresource.EmptyResource, *apierror.APIError)
}
func NewBatchSvc ¶
func NewBatchSvc(config *BatchSvcConfig) BatchSvc
type BatchSvcConfig ¶
type BatchSvcConfig struct {
// CoreClient (required) is the core-service gRPC client.
CoreClient pb.CoreServiceClient
}
type BulkDeleteBatchesEndpoint ¶
type BulkDeleteBatchesEndpoint struct{}
Deletes multiple batches in one request.
Batch IDs that cannot be found are skipped; the request fails only if none of the batches exist. Deleting a batch also removes its links to the batches feeding into and out of it, breaking the production flow at that point, and detaches it from any machines. After deletion, any production run whose batches are now all scanned or deleted is closed automatically.
func (*BulkDeleteBatchesEndpoint) Materialize ¶
func (e *BulkDeleteBatchesEndpoint) Materialize() *apiendpoint.APIEndpoint[*DeleteManyBatchesRequest, *apiresource.EmptyResource]
type CloseBatchEndpoint ¶
type CloseBatchEndpoint struct{}
Closes a batch so it can no longer be scanned or advanced through production.
Use this to finish a batch whose remaining quantity will not be produced, for example when the floor stops short of the planned output. Batches also close on their own when they reach the last production step, when they are moved or merged into a downstream batch, and when everything split off them accounts for their whole quantity. A closed batch cannot be reopened.
func (*CloseBatchEndpoint) Materialize ¶
func (e *CloseBatchEndpoint) Materialize() *apiendpoint.APIEndpoint[*CloseBatchRequest, *apiresource.Batch]
type CloseBatchRequest ¶
type CloseBatchRequest struct {
// Batch ID.
BatchID string `json:"batch_id" validate:"required"`
}
Request to close a batch.
func (*CloseBatchRequest) SchemaExample ¶
func (*CloseBatchRequest) SchemaExample() any
type DeleteBatchEndpoint ¶
type DeleteBatchEndpoint struct{}
Deletes a batch by ID and returns the deleted batch.
Deleting a batch also removes its links to the batches feeding into and out of it, breaking the production flow at that point, and detaches it from any machines. After deletion, the batch's production run is closed automatically once all of its batches are scanned or deleted. Deleting the same batch twice reports that it has already been deleted.
func (*DeleteBatchEndpoint) Materialize ¶
func (e *DeleteBatchEndpoint) Materialize() *apiendpoint.APIEndpoint[*DeleteBatchRequest, *apiresource.Batch]
type DeleteBatchRequest ¶
type DeleteBatchRequest struct {
// Batch ID.
BatchID string `path:"id" validate:"required"`
}
Request to delete a batch.
type DeleteManyBatchesRequest ¶
type DeleteManyBatchesRequest struct {
// Batch IDs to delete.
BatchIDs []string `json:"batch_ids" validate:"required"`
}
Request to delete multiple batches.
func (*DeleteManyBatchesRequest) SchemaExample ¶
func (*DeleteManyBatchesRequest) SchemaExample() any
type GetBatchFlowEndpoint ¶
type GetBatchFlowEndpoint struct{}
Returns the full production flow graph containing a batch.
The flow is every batch connected to the given batch through input/output relationships, in both directions, including the batch itself. Nodes come back in no particular order; rebuild the graph from each node's input and output edges rather than from their position in the list.
func (*GetBatchFlowEndpoint) Materialize ¶
func (e *GetBatchFlowEndpoint) Materialize() *apiendpoint.APIEndpoint[*GetBatchFlowRequest, *apiresource.List[apiresource.BatchFlowNode]]
type GetBatchFlowRequest ¶
type GetBatchFlowRequest struct {
// Batch ID.
BatchID string `path:"id" validate:"required"`
}
Request to retrieve the production flow graph for a batch.
type GetPossibleNextStepsEndpoint ¶
type GetPossibleNextStepsEndpoint struct{}
Returns the production steps a batch can be advanced to from a given scanning station.
Use this to drive the step picker on a scanning terminal after an operator scans a batch. Traversal starts at the batch: an open batch that has already been scanned offers the steps that come after its current step, while a closed batch is followed downstream to the batches it produced and the search continues from there. Only steps assigned to the given scanning station are returned, so a batch with nothing left to do at that station comes back with an empty list.
func (*GetPossibleNextStepsEndpoint) Materialize ¶
func (e *GetPossibleNextStepsEndpoint) Materialize() *apiendpoint.APIEndpoint[*GetPossibleNextStepsRequest, *apiresource.List[apiresource.ScanningProductionStepInfo]]
type GetPossibleNextStepsRequest ¶
type GetPossibleNextStepsRequest struct {
// Batch ID.
BatchID string `path:"id" validate:"required"`
// Scanning station ID to evaluate next steps from.
ScanningStationID string `json:"scanning_station_id" validate:"required"`
}
Request to retrieve possible next production steps for a batch.
func (*GetPossibleNextStepsRequest) SchemaExample ¶
func (*GetPossibleNextStepsRequest) SchemaExample() any
type GetRemainingQuantityToSplitEndpoint ¶
type GetRemainingQuantityToSplitEndpoint struct{}
Returns the remaining quantity available to split from the specified batches at a given production step.
Use this to cap how much an operator can record on the next split. The remaining quantity is the step's expected output for the source batches minus the quantities already split off into output batches, expressed in the step's produced unit. When a single batch ID is supplied, output already recorded as seconds and waste also counts against the remainder; when several are supplied, only first-quality output does.
func (*GetRemainingQuantityToSplitEndpoint) Materialize ¶
func (e *GetRemainingQuantityToSplitEndpoint) Materialize() *apiendpoint.APIEndpoint[*GetRemainingQuantityToSplitRequest, *apiresource.Quantity]
type GetRemainingQuantityToSplitRequest ¶
type GetRemainingQuantityToSplitRequest struct {
// Batch IDs to check remaining quantities for.
//
// Pass a single ID for a single-part step, or one ID per part for a multi-part step. Each ID is resolved forward through its production flow to the batch that is actually available at the step, so an operator can scan an earlier batch in the chain.
BatchIDs []string `json:"batch_ids" validate:"required"`
// The production step the split would be performed at.
//
// Its configuration determines the expected output quantity and the unit the remainder is expressed in.
ProductionStepID string `json:"production_step_id" validate:"required"`
}
Request to get the remaining quantity available to split from batches.
func (*GetRemainingQuantityToSplitRequest) SchemaExample ¶
func (*GetRemainingQuantityToSplitRequest) SchemaExample() any
type GetScanningStationConsumptionEndpoint ¶
type GetScanningStationConsumptionEndpoint struct{}
Returns the material demand and current inventory for the operation a scanning station would perform on the given batches.
Use this to preview what a scan will draw from stock, and to compare that against what is on hand, before committing the operation. Demand is each of the step's configured material quantities scaled by how much output the operation produces relative to the step's standard run size, so it grows with the batch quantities (or the proposed split quantity). How the step is determined depends on the station's type: `init_batch` stations derive it from the station and the batch's item, while `move_batch`, `split_batch`, and `merge_batch` stations use `production_step_id`. Nothing is consumed by this call.
func (*GetScanningStationConsumptionEndpoint) Materialize ¶
func (e *GetScanningStationConsumptionEndpoint) Materialize() *apiendpoint.APIEndpoint[*GetScanningStationConsumptionRequest, *apiresource.List[apiresource.ScanningConsumption]]
type GetScanningStationConsumptionRequest ¶
type GetScanningStationConsumptionRequest struct {
// Scanning station ID.
ScanningStationID string `path:"id" validate:"required"`
// Batch IDs the scanning operation would be performed on.
//
// At an `init_batch` station only the first ID is used, since demand comes from that batch's own item and quantity. At the other station types each ID is resolved forward through its production flow to the batch that is actually available at the step, and the demand of all of them is added together.
BatchIDs []string `json:"batch_ids" validate:"required"`
// Production step ID to scope the consumption calculation.
//
// Required for `move_batch`, `split_batch`, and `merge_batch` stations. Ignored for `init_batch` stations, where the step is derived from the station and the batch's item.
ProductionStepID field.Optional[string] `json:"production_step_id,omitzero"`
// Proposed split quantity to factor into the consumption calculation.
//
// Required for `split_batch` stations. It is applied only when splitting a single batch at a single-part step, where material demand is scaled to this quantity instead of the batch's full expected output; splits covering several batches or several parts ignore it.
SplitQuantity field.Optional[SplitQuantityInput] `json:"split_quantity,omitzero"`
}
Request to get material consumption data for a scanning station.
func (*GetScanningStationConsumptionRequest) SchemaExample ¶
func (*GetScanningStationConsumptionRequest) SchemaExample() any
type InitializeBatchEndpoint ¶
type InitializeBatchEndpoint struct{}
Marks a production run batch as scanned at a scanning station, starting it through production.
The batch is attached to the production step that produces its item at the station, the step's material consumption is executed asynchronously, and the batch is closed automatically if the step is the last one. The batch's production run is started, and the run is closed once all of its batches are scanned or deleted.
func (*InitializeBatchEndpoint) Materialize ¶
func (e *InitializeBatchEndpoint) Materialize() *apiendpoint.APIEndpoint[*InitializeBatchRequest, *apiresource.Batch]
type InitializeBatchRequest ¶
type InitializeBatchRequest struct {
// ID of the batch to initialize.
//
// The batch must belong to a production run, still be open, and not have been scanned before.
BatchID string `json:"batch_id" validate:"required"`
// ID of the scanning station the batch is being scanned at.
//
// The station must have a production step that produces the batch's item, since that step is what the batch is attached to.
ScanningStationID string `json:"scanning_station_id" validate:"required"`
}
Request to initialize a batch at a scanning station.
func (*InitializeBatchRequest) SchemaExample ¶
func (*InitializeBatchRequest) SchemaExample() any
type ListBatchesByScanningStationEndpoint ¶
type ListBatchesByScanningStationEndpoint struct{}
Returns a paginated list of the batches scanned at a given scanning station, most recently scanned first.
Only batches that have actually been scanned at the station appear. Batches created there by a move, merge, or split are attached to the station but never marked as scanned, so they are not listed. The search term matches on item SKU.
func (*ListBatchesByScanningStationEndpoint) Materialize ¶
func (e *ListBatchesByScanningStationEndpoint) Materialize() *apiendpoint.APIEndpoint[*ListBatchesByScanningStationRequest, *apiresource.List[apiresource.Batch]]
type ListBatchesByScanningStationRequest ¶
type ListBatchesByScanningStationRequest struct {
// Scanning station ID.
ScanningStationID string `path:"id" validate:"required"`
apiresource.PaginationRequest
}
Request to list batches for a scanning station.
type MergeBatchesEndpoint ¶
type MergeBatchesEndpoint struct{}
Merges multiple batches into a single new batch at a production step.
The new batch is created at the target step and its quantity is scaled from how much input was supplied against the step's configured input-to-output ratio: for a single-part step the source quantities are summed, and for a multi-part step every part must work out to the same output quantity or the merge is rejected. The source batches are linked as inputs and closed, the step's material consumption runs asynchronously afterwards, and the new batch is closed immediately if the target step is the last one in the flow. Returns the newly created batch.
func (*MergeBatchesEndpoint) Materialize ¶
func (e *MergeBatchesEndpoint) Materialize() *apiendpoint.APIEndpoint[*MergeBatchesRequest, *apiresource.Batch]
type MergeBatchesRequest ¶
type MergeBatchesRequest struct {
// Batch IDs to merge.
//
// Duplicates are rejected. For single-part production steps all batches must be of the same item; for multi-part steps supply at least one batch per part the step consumes. Each ID is resolved forward through its production flow to the batch that is actually available at the step, so an operator can scan an earlier batch in the chain.
BatchIDs []string `json:"batch_ids" validate:"required"`
// Scanning station ID performing the merge.
ScanningStationID string `json:"scanning_station_id" validate:"required"`
// The production step the merged batch is created at.
ProductionStepID string `json:"production_step_id" validate:"required"`
}
Request to merge multiple batches into one.
func (*MergeBatchesRequest) SchemaExample ¶
func (*MergeBatchesRequest) SchemaExample() any
type MoveBatchesEndpoint ¶
type MoveBatchesEndpoint struct{}
Advances batches to a production step by creating a new batch at that step.
The new batch carries the item the target step produces, and its quantity is scaled from the source quantities against the step's configured input-to-output ratio; when several parts are supplied, each must work out to the same output quantity or the move is rejected. The source batches are linked as inputs and closed, the step's material consumption runs asynchronously afterwards, and the new batch is closed immediately if the target step is the last one in the flow. Returns the newly created batch.
func (*MoveBatchesEndpoint) Materialize ¶
func (e *MoveBatchesEndpoint) Materialize() *apiendpoint.APIEndpoint[*MoveBatchesRequest, *apiresource.Batch]
type MoveBatchesRequest ¶
type MoveBatchesRequest struct {
// Batch IDs to move.
//
// Pass a single ID to advance one batch, or multiple IDs (one per part) when the target step combines multiple parts. Each ID is resolved forward through its production flow to the batch that is actually available at the step, so an operator can scan an earlier batch in the chain.
BatchIDs []string `json:"batch_ids" validate:"required"`
// Target production step ID.
ProductionStepID string `json:"production_step_id" validate:"required"`
// Scanning station ID performing the move.
ScanningStationID string `json:"scanning_station_id" validate:"required"`
}
Request to move batches to a production step.
func (*MoveBatchesRequest) SchemaExample ¶
func (*MoveBatchesRequest) SchemaExample() any
type SplitBatchEndpoint ¶
type SplitBatchEndpoint struct{}
Splits a quantity off one or more batches into a new batch, grading the output as firsts, seconds, and waste.
Unlike a move, the operator states how much was produced rather than letting the step's ratio decide, which is how partial output and quality grading are recorded. A new batch carrying the firsts quantity is created at the production step, with any seconds and waste recorded on it, and the source batches are linked as inputs. Only the firsts quantity is added to inventory; seconds and waste still consume input materials. The step's material consumption runs asynchronously afterwards, and the new batch is closed immediately if the step is the last one in the flow. Returns the newly created batch.
func (*SplitBatchEndpoint) Materialize ¶
func (e *SplitBatchEndpoint) Materialize() *apiendpoint.APIEndpoint[*SplitBatchRequest, *apiresource.Batch]
type SplitBatchRequest ¶
type SplitBatchRequest struct {
// Batch IDs to split from.
//
// Pass a single ID for single-part production steps, or multiple IDs (one per part) for multi-part steps. Each ID is resolved forward through its production flow to the batch that is actually available at the step, so an operator can scan an earlier batch in the chain.
BatchIDs []string `json:"batch_ids" validate:"required"`
// Scanning station ID performing the split.
ScanningStationID string `json:"scanning_station_id" validate:"required"`
// The production step the new batch is created at.
ProductionStepID string `json:"production_step_id" validate:"required"`
// First-quality output quantity for the new batch.
//
// At least one of `firsts`, `seconds`, or `waste` must be non-zero.
Firsts SplitQuantityInput `json:"firsts" validate:"required"`
// Seconds-quality (B-grade) output quantity recorded on the new batch.
//
// Seconds consume input materials but are not added to inventory.
Seconds field.Optional[SplitQuantityInput] `json:"seconds,omitzero"`
// Scrap quantity recorded on the new batch.
//
// Like seconds, scrap consumes input materials but is not added to inventory.
Waste field.Optional[SplitQuantityInput] `json:"waste,omitzero"`
// Whether to close the source batches after splitting.
//
// Set this when the operator is done with the source batch even though quantity is left over. When left open, a source batch is still closed automatically once everything split off it (firsts, seconds, and waste together) accounts for its full quantity.
CloseBatch bool `json:"close_batch"`
}
Request to split a quantity off one or more batches into a new batch.
func (*SplitBatchRequest) SchemaExample ¶
func (*SplitBatchRequest) SchemaExample() any
type SplitQuantityInput ¶
type SplitQuantityInput struct {
// Client-side identifier for this quantity.
//
// Useful for correlating quantities in your own UI; it is not stored and has no effect on the result.
ID string `json:"id"`
// Quantity to split off, as a decimal measure expressed in `unit_id`.
Measure string `json:"measure" validate:"required"`
// ID of the unit the measure is expressed in.
UnitID string `json:"unit_id" validate:"required"`
}
Quantity input for a split operation.
Source Files
¶
- endpoint_analyze_open_batches.go
- endpoint_bulk_delete_batches.go
- endpoint_close_batch.go
- endpoint_delete_batch.go
- endpoint_get_batch_flow.go
- endpoint_get_consumption.go
- endpoint_get_next_steps.go
- endpoint_get_remaining_to_split.go
- endpoint_initialize_batch.go
- endpoint_list_by_scanning_station.go
- endpoint_merge_batches.go
- endpoint_move_batches.go
- endpoint_split_batch.go
- presenter.go
- service.go