update cups restart for order

This commit is contained in:
Aung Myo
2018-02-01 17:14:34 +06:30
parent 6bf22439e8
commit 6657c11122
3 changed files with 46 additions and 58 deletions

View File

@@ -278,19 +278,34 @@ 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, self.table_id)
# order = Order.find(order_id)
# #Execute orders and send to order stations
# if order
# oqs = OrderQueueStation.new
# oqs.process_order(order, table_id)
# end
cup_status = `#{"sudo service cups status"}`
print_status = check_cup_status(cup_status)
if print_status
OrderQueueProcessorJob.perform_later(self.id, self.table_id)
else
cup_start = `#{"sudo service cups start"}`
cup_status = `#{"sudo service cups status"}`
print_status = check_cup_status(cup_status)
# assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
# ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
if print_status
OrderQueueProcessorJob.perform_later(self.id, self.table_id)
else
msg = ' Print Error ! Please contact to service'
ActionCable.server.broadcast "call_waiter_channel",table: msg,time:'print_error'
OrderQueueProcessorJob.perform_later(self.id, self.table_id)
end
end
end
def check_cup_status(status)
if status.include? "Active: active (running)" || "Active: active (exited)" #"Cup Server is already running"
return true
end
return false
end
#send order items and send to order queue
def send_order_broadcast(booking)