update order for oqs

This commit is contained in:
Yan
2017-06-16 18:55:14 +06:30
parent 741a7d0d64
commit 0a496f2274
3 changed files with 17 additions and 13 deletions

View File

@@ -1,7 +1,7 @@
class OrderQueueProcessorJob < ApplicationJob
queue_as :default
def perform(order_id)
def perform(order_id, table_id)
# Do something later
#Order ID
order = Order.find(order_id)
@@ -10,7 +10,7 @@ class OrderQueueProcessorJob < ApplicationJob
#Execute orders and send to order stations
if order
oqs = OrderQueueStation.new
oqs.process_order(order)
oqs.process_order(order, table_id)
end
end

View File

@@ -199,7 +199,7 @@ class Order < ApplicationRecord
#Process order items and send to order queue
def process_order_queue
#Send to background job for processing
OrderQueueProcessorJob.perform_later(self.id)
OrderQueueProcessorJob.perform_later(self.id, self.table_id)
end

View File

@@ -8,26 +8,30 @@ class OrderQueueStation < ApplicationRecord
scope :active, -> {where(is_active: true)}
def process_order (order)
def process_order (order, table_id)
oqs_stations = OrderQueueStation.active
dining=DiningFacility.find_by_name(table_id)
oqpbz = OrderQueueProcessByZone.find_by_zone_id(dining.zone_id)
order_items = order.order_items
#Assign OQS id to order Items
oqs_stations.each do |oqs|
#Get List of items -
pq_items = JSON.parse(oqs.processing_items)
pq_items = JSON.parse(oqs.processing_items)
#Loop through the processing items
pq_items.each do |pq_item|
#Processing through the looping items
order_items.each do |order_item|
if (pq_item == order_item.item_code)
#Same Order_items can appear in two location.
AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
if oqs.id == oqpbz.order_queue_station_id
#Loop through the processing items
pq_items.each do |pq_item|
#Processing through the looping items
order_items.each do |order_item|
if (pq_item == order_item.item_code)
#Same Order_items can appear in two location.
AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
end
end
end
end
end
#Print OQS where printing is require