Merge branch 'master' of https://gitlab.com/jankstudio/resq
Conflicts: utils/mqtt_sender/mqtt_sender.py
This commit is contained in:
commit
0cc667dbec
2 changed files with 47 additions and 33 deletions
|
|
@ -38,6 +38,7 @@ use App\Entity\RiderRating;
|
|||
use App\Entity\JOEvent;
|
||||
|
||||
use DateTime;
|
||||
use Exception;
|
||||
|
||||
|
||||
class APIController extends Controller
|
||||
|
|
@ -311,6 +312,8 @@ class APIController extends Controller
|
|||
$data = [
|
||||
'first_name' => '',
|
||||
'last_name' => '',
|
||||
'priv_third_party' => (bool) false,
|
||||
'priv_promo' => (bool) false,
|
||||
];
|
||||
$res->setData($data);
|
||||
|
||||
|
|
@ -1036,11 +1039,11 @@ class APIController extends Controller
|
|||
|
||||
// make invoice json data
|
||||
$data = [
|
||||
'total_price' => $invoice->getTotalPrice(),
|
||||
'vat_ex_price' => $invoice->getVATExclusivePrice(),
|
||||
'vat' => $invoice->getVAT(),
|
||||
'discount' => $invoice->getDiscount(),
|
||||
'trade_in' => $invoice->getTradeIn(),
|
||||
'total_price' => (float) $invoice->getTotalPrice(),
|
||||
'vat_ex_price' => (float) $invoice->getVATExclusivePrice(),
|
||||
'vat' => (float) $invoice->getVAT(),
|
||||
'discount' => (float) $invoice->getDiscount(),
|
||||
'trade_in' => (float) $invoice->getTradeIn(),
|
||||
];
|
||||
$items = $invoice->getItems();
|
||||
$items_data = [];
|
||||
|
|
@ -1048,8 +1051,8 @@ class APIController extends Controller
|
|||
{
|
||||
$my_data = [
|
||||
'title' => $item->getTitle(),
|
||||
'qty' => $item->getQuantity() + 0,
|
||||
'price' => $item->getPrice() + 0.0,
|
||||
'qty' => (int) $item->getQuantity() + 0,
|
||||
'price' => (float) $item->getPrice() + 0.0,
|
||||
];
|
||||
|
||||
$item_batt = $item->getBattery();
|
||||
|
|
@ -1100,6 +1103,8 @@ class APIController extends Controller
|
|||
// $res->setData(['here' => count($ongoing_jos)]);
|
||||
// return $res->getReturnResponse();
|
||||
if (count($ongoing_jos) <= 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
// check if the latest fulfilled jo they have needs rider rating
|
||||
$query = $em->createQuery('select jo from App\Entity\JobOrder jo where jo.customer = :cust and jo.status = :status order by jo.date_fulfill desc');
|
||||
|
|
@ -1109,6 +1114,15 @@ class APIController extends Controller
|
|||
])
|
||||
->setMaxResults(1)
|
||||
->getSingleResult();
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
// no pending
|
||||
$res->setData([
|
||||
'status' => APIRiderStatus::NO_PENDING_JO
|
||||
]);
|
||||
return $res->getReturnResponse();
|
||||
}
|
||||
|
||||
// we got a recently fulfilled job order
|
||||
if ($fulfill_jo)
|
||||
|
|
@ -1399,11 +1413,11 @@ class APIController extends Controller
|
|||
|
||||
// make invoice json data
|
||||
$data = [
|
||||
'total_price' => $invoice->getTotalPrice(),
|
||||
'vat_ex_price' => $invoice->getVATExclusivePrice(),
|
||||
'vat' => $invoice->getVAT(),
|
||||
'discount' => $invoice->getDiscount(),
|
||||
'trade_in' => $invoice->getTradeIn(),
|
||||
'total_price' => (float) $invoice->getTotalPrice(),
|
||||
'vat_ex_price' => (float) $invoice->getVATExclusivePrice(),
|
||||
'vat' => (float) $invoice->getVAT(),
|
||||
'discount' => (float) $invoice->getDiscount(),
|
||||
'trade_in' => (float) $invoice->getTradeIn(),
|
||||
];
|
||||
$items = $invoice->getItems();
|
||||
$items_data = [];
|
||||
|
|
@ -1411,8 +1425,8 @@ class APIController extends Controller
|
|||
{
|
||||
$my_data = [
|
||||
'title' => $item->getTitle(),
|
||||
'qty' => $item->getQuantity() + 0,
|
||||
'price' => $item->getPrice() + 0.0,
|
||||
'qty' => (int) $item->getQuantity() + 0,
|
||||
'price' => (float) $item->getPrice() + 0.0,
|
||||
];
|
||||
|
||||
$item_batt = $item->getBattery();
|
||||
|
|
|
|||
|
|
@ -7,17 +7,18 @@ import time
|
|||
import signal
|
||||
import sys
|
||||
import os
|
||||
import logging
|
||||
|
||||
|
||||
|
||||
def sigint_handler(signal, frame):
|
||||
print 'Interrupted'
|
||||
logging.warning('Interrupted')
|
||||
sys.exit(0)
|
||||
os._exit(0)
|
||||
|
||||
|
||||
def on_connect(client, userdata, flags, rc):
|
||||
print("Connected with result code "+str(rc))
|
||||
logging.info("Connected with result code "+str(rc))
|
||||
client.subscribe("$SYS/#")
|
||||
|
||||
|
||||
|
|
@ -34,13 +35,13 @@ def getRedis(i, client):
|
|||
data = r.brpop("events", 10)
|
||||
if data:
|
||||
info = data[1].split('|')
|
||||
print "Channel: " + info[0] + " message: " + info[1]
|
||||
logging.info("Channel: " + info[0] + " message: " + info[1])
|
||||
client.publish(info[0], info[1])
|
||||
|
||||
|
||||
|
||||
def sigint_handler(signal, frame):
|
||||
print 'Interrupted'
|
||||
logging.warning('Interrupted')
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
|
|
@ -49,8 +50,6 @@ def main():
|
|||
client.on_connect = on_connect
|
||||
client.on_publish = on_publish
|
||||
|
||||
|
||||
|
||||
client.tls_set(
|
||||
"/etc/letsencrypt/live/resqaws.jankstudio.com/fullchain.pem", cert_reqs=ssl.CERT_NONE,
|
||||
tls_version=ssl.PROTOCOL_TLSv1)
|
||||
|
|
@ -64,8 +63,9 @@ def main():
|
|||
client.loop_forever()
|
||||
|
||||
|
||||
|
||||
#pid = "/tmp/mqtt_sender.pid"
|
||||
#daemon = Daemonize(app="mqtt_sender", pid=pid, action=main)
|
||||
#daemon.start()
|
||||
main()
|
||||
logging.basicConfig(filename='/tmp/mqtt_sender.log', level=logging.INFO)
|
||||
logging.info('Started mqtt_sender')
|
||||
pid = "/tmp/mqtt_sender.pid"
|
||||
daemon = Daemonize(app="mqtt_sender", pid=pid, action=main)
|
||||
daemon.start()
|
||||
#main()
|
||||
|
|
|
|||
Loading…
Reference in a new issue