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

View File

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

View File

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