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 App\Entity\JOEvent;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
|
||||||
class APIController extends Controller
|
class APIController extends Controller
|
||||||
|
|
@ -311,6 +312,8 @@ class APIController extends Controller
|
||||||
$data = [
|
$data = [
|
||||||
'first_name' => '',
|
'first_name' => '',
|
||||||
'last_name' => '',
|
'last_name' => '',
|
||||||
|
'priv_third_party' => (bool) false,
|
||||||
|
'priv_promo' => (bool) false,
|
||||||
];
|
];
|
||||||
$res->setData($data);
|
$res->setData($data);
|
||||||
|
|
||||||
|
|
@ -1036,11 +1039,11 @@ class APIController extends Controller
|
||||||
|
|
||||||
// make invoice json data
|
// make invoice json data
|
||||||
$data = [
|
$data = [
|
||||||
'total_price' => $invoice->getTotalPrice(),
|
'total_price' => (float) $invoice->getTotalPrice(),
|
||||||
'vat_ex_price' => $invoice->getVATExclusivePrice(),
|
'vat_ex_price' => (float) $invoice->getVATExclusivePrice(),
|
||||||
'vat' => $invoice->getVAT(),
|
'vat' => (float) $invoice->getVAT(),
|
||||||
'discount' => $invoice->getDiscount(),
|
'discount' => (float) $invoice->getDiscount(),
|
||||||
'trade_in' => $invoice->getTradeIn(),
|
'trade_in' => (float) $invoice->getTradeIn(),
|
||||||
];
|
];
|
||||||
$items = $invoice->getItems();
|
$items = $invoice->getItems();
|
||||||
$items_data = [];
|
$items_data = [];
|
||||||
|
|
@ -1048,8 +1051,8 @@ class APIController extends Controller
|
||||||
{
|
{
|
||||||
$my_data = [
|
$my_data = [
|
||||||
'title' => $item->getTitle(),
|
'title' => $item->getTitle(),
|
||||||
'qty' => $item->getQuantity() + 0,
|
'qty' => (int) $item->getQuantity() + 0,
|
||||||
'price' => $item->getPrice() + 0.0,
|
'price' => (float) $item->getPrice() + 0.0,
|
||||||
];
|
];
|
||||||
|
|
||||||
$item_batt = $item->getBattery();
|
$item_batt = $item->getBattery();
|
||||||
|
|
@ -1101,14 +1104,25 @@ class APIController extends Controller
|
||||||
// return $res->getReturnResponse();
|
// return $res->getReturnResponse();
|
||||||
if (count($ongoing_jos) <= 0)
|
if (count($ongoing_jos) <= 0)
|
||||||
{
|
{
|
||||||
// check if the latest fulfilled jo they have needs rider rating
|
try
|
||||||
$query = $em->createQuery('select jo from App\Entity\JobOrder jo where jo.customer = :cust and jo.status = :status order by jo.date_fulfill desc');
|
{
|
||||||
$fulfill_jo = $query->setParameters([
|
// check if the latest fulfilled jo they have needs rider rating
|
||||||
'cust' => $cust,
|
$query = $em->createQuery('select jo from App\Entity\JobOrder jo where jo.customer = :cust and jo.status = :status order by jo.date_fulfill desc');
|
||||||
'status' => JOStatus::FULFILLED,
|
$fulfill_jo = $query->setParameters([
|
||||||
])
|
'cust' => $cust,
|
||||||
->setMaxResults(1)
|
'status' => JOStatus::FULFILLED,
|
||||||
->getSingleResult();
|
])
|
||||||
|
->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
|
// we got a recently fulfilled job order
|
||||||
if ($fulfill_jo)
|
if ($fulfill_jo)
|
||||||
|
|
@ -1399,11 +1413,11 @@ class APIController extends Controller
|
||||||
|
|
||||||
// make invoice json data
|
// make invoice json data
|
||||||
$data = [
|
$data = [
|
||||||
'total_price' => $invoice->getTotalPrice(),
|
'total_price' => (float) $invoice->getTotalPrice(),
|
||||||
'vat_ex_price' => $invoice->getVATExclusivePrice(),
|
'vat_ex_price' => (float) $invoice->getVATExclusivePrice(),
|
||||||
'vat' => $invoice->getVAT(),
|
'vat' => (float) $invoice->getVAT(),
|
||||||
'discount' => $invoice->getDiscount(),
|
'discount' => (float) $invoice->getDiscount(),
|
||||||
'trade_in' => $invoice->getTradeIn(),
|
'trade_in' => (float) $invoice->getTradeIn(),
|
||||||
];
|
];
|
||||||
$items = $invoice->getItems();
|
$items = $invoice->getItems();
|
||||||
$items_data = [];
|
$items_data = [];
|
||||||
|
|
@ -1411,8 +1425,8 @@ class APIController extends Controller
|
||||||
{
|
{
|
||||||
$my_data = [
|
$my_data = [
|
||||||
'title' => $item->getTitle(),
|
'title' => $item->getTitle(),
|
||||||
'qty' => $item->getQuantity() + 0,
|
'qty' => (int) $item->getQuantity() + 0,
|
||||||
'price' => $item->getPrice() + 0.0,
|
'price' => (float) $item->getPrice() + 0.0,
|
||||||
];
|
];
|
||||||
|
|
||||||
$item_batt = $item->getBattery();
|
$item_batt = $item->getBattery();
|
||||||
|
|
|
||||||
|
|
@ -7,17 +7,18 @@ import time
|
||||||
import signal
|
import signal
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def sigint_handler(signal, frame):
|
def sigint_handler(signal, frame):
|
||||||
print 'Interrupted'
|
logging.warning('Interrupted')
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
os._exit(0)
|
os._exit(0)
|
||||||
|
|
||||||
|
|
||||||
def on_connect(client, userdata, flags, rc):
|
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/#")
|
client.subscribe("$SYS/#")
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -34,13 +35,13 @@ def getRedis(i, client):
|
||||||
data = r.brpop("events", 10)
|
data = r.brpop("events", 10)
|
||||||
if data:
|
if data:
|
||||||
info = data[1].split('|')
|
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])
|
client.publish(info[0], info[1])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def sigint_handler(signal, frame):
|
def sigint_handler(signal, frame):
|
||||||
print 'Interrupted'
|
logging.warning('Interrupted')
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -49,8 +50,6 @@ def main():
|
||||||
client.on_connect = on_connect
|
client.on_connect = on_connect
|
||||||
client.on_publish = on_publish
|
client.on_publish = on_publish
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
client.tls_set(
|
client.tls_set(
|
||||||
"/etc/letsencrypt/live/resqaws.jankstudio.com/fullchain.pem", cert_reqs=ssl.CERT_NONE,
|
"/etc/letsencrypt/live/resqaws.jankstudio.com/fullchain.pem", cert_reqs=ssl.CERT_NONE,
|
||||||
tls_version=ssl.PROTOCOL_TLSv1)
|
tls_version=ssl.PROTOCOL_TLSv1)
|
||||||
|
|
@ -64,8 +63,9 @@ def main():
|
||||||
client.loop_forever()
|
client.loop_forever()
|
||||||
|
|
||||||
|
|
||||||
|
logging.basicConfig(filename='/tmp/mqtt_sender.log', level=logging.INFO)
|
||||||
#pid = "/tmp/mqtt_sender.pid"
|
logging.info('Started mqtt_sender')
|
||||||
#daemon = Daemonize(app="mqtt_sender", pid=pid, action=main)
|
pid = "/tmp/mqtt_sender.pid"
|
||||||
#daemon.start()
|
daemon = Daemonize(app="mqtt_sender", pid=pid, action=main)
|
||||||
main()
|
daemon.start()
|
||||||
|
#main()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue