add position to ReserveResultPojo
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import os
|
||||
|
||||
BAUDRATE = 115200
|
||||
|
||||
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
@@ -19,13 +19,15 @@ from pojo.serial_modem import SerialModem
|
||||
from logs.AppLogging import init_logger
|
||||
from utils.message_receiver import MessageReceiver
|
||||
|
||||
BAUDRATE = 115200
|
||||
OTP_TIMEOUT = 90
|
||||
is_finished = False
|
||||
commandor = Commandor()
|
||||
contacts = []
|
||||
current_gsm_modem = None
|
||||
card_pool = CardPool(CARD_POOL_PORT)
|
||||
# used to save the current slot position
|
||||
current_card_pool_slot = 1
|
||||
current_sim_position = 1
|
||||
|
||||
|
||||
def get_devices_ports() -> list:
|
||||
@@ -60,10 +62,6 @@ def get_phone_number(ser):
|
||||
send_command(cmd, ser)
|
||||
|
||||
|
||||
def execut_USSD_cmd(cmd, ser):
|
||||
send_command(cmd, ser)
|
||||
|
||||
|
||||
def create_modem_for_port(port: str) -> Union[SerialModem, None]:
|
||||
logger.info('Initializing modem... for ' + port)
|
||||
# Uncomment the following line to see what the modem is doing:
|
||||
@@ -145,7 +143,9 @@ def on_message_received(ch, method, properties, body):
|
||||
logger.info(" [x] Received {} {}".format(body, datetime.datetime.now()))
|
||||
# parse the received message
|
||||
result = ReserveResultPojo.from_json(body)
|
||||
print(result)
|
||||
result.sim_position = current_sim_position
|
||||
result.slot_position = current_card_pool_slot
|
||||
logger.info(result)
|
||||
firebase_store_manager.save(result)
|
||||
oracle_log_sender.send_appoint_result(result)
|
||||
# set the flag to True
|
||||
@@ -162,12 +162,14 @@ def start_listen():
|
||||
def read_all_the_phone_number():
|
||||
params.oracle_log_sender.send_log(msg="SIM卡自检开始", subject=LOG_SUBJECT_EVENT, type=LOG_SUBJECT_EVENT)
|
||||
slot_number = 1
|
||||
global current_card_pool_slot
|
||||
slot_sum = 30
|
||||
# card_pool.switch_to_slot(29)
|
||||
firebase_store_manager.clear_all_sim_info()
|
||||
for i in range(slot_number, slot_sum + 1):
|
||||
card_pool.reset()
|
||||
print("will switch to " + str(i))
|
||||
logger.info("will switch to " + str(i))
|
||||
current_card_pool_slot = i
|
||||
card_pool.switch_to_slot(i)
|
||||
modem_pool = ModemPool(get_devices_ports())
|
||||
modem_pool.reset_all_modems()
|
||||
@@ -179,7 +181,7 @@ def start_book():
|
||||
slot_sum = 30
|
||||
for i in range(slot_number, slot_sum + 1):
|
||||
card_pool.reset()
|
||||
print("will switch to " + str(i))
|
||||
logger.info("will switch to " + str(i))
|
||||
card_pool.switch_to_slot(i)
|
||||
modem_pool = ModemPool(get_devices_ports())
|
||||
modem_pool.reset_all_modems()
|
||||
@@ -189,7 +191,10 @@ def start_book():
|
||||
excel_reader = ExcelHelper()
|
||||
global contacts
|
||||
contacts = excel_reader.read_contacts()
|
||||
global current_sim_position
|
||||
current_sim_position = 1
|
||||
for modem in modem_list:
|
||||
current_sim_position = current_sim_position + 1
|
||||
try:
|
||||
# get contact for current modem
|
||||
modem.get_ccid()
|
||||
|
||||
@@ -57,7 +57,8 @@ class Mailer:
|
||||
|
||||
if __name__ == '__main__':
|
||||
result = ReserveResultPojo(email="panleicim@gmail.com", phone="0649614591", url="url", firstName="Lei",
|
||||
lastName="PAN", message="msg", type=PublishType.SUCCESS)
|
||||
lastName="PAN", message="msg", type=PublishType.SUCCESS, passport="Ed1543183",
|
||||
slot_position=1, sim_position=1)
|
||||
|
||||
mytemplate = Template(filename=definitions.ROOT_DIR + "/templates/appointment_results.html")
|
||||
print(mytemplate.render(result_list=[result]))
|
||||
|
||||
@@ -20,6 +20,9 @@ class ReserveResultPojo:
|
||||
email: None
|
||||
id = None
|
||||
accepted = None
|
||||
passport: str
|
||||
slot_position: int
|
||||
sim_position: int
|
||||
|
||||
@staticmethod
|
||||
def from_firestore_dict(source):
|
||||
@@ -37,6 +40,15 @@ class ReserveResultPojo:
|
||||
if 'accepted' in source:
|
||||
accepted = source['accepted']
|
||||
result.accepted = accepted
|
||||
if 'sim_position' in source:
|
||||
sim_position = source['sim_position']
|
||||
result.sim_position = sim_position
|
||||
if 'slot_position' in source:
|
||||
slot_position = source['slot_position']
|
||||
result.slot_position = slot_position
|
||||
if 'passport' in source:
|
||||
passport = source['passport']
|
||||
result.passport = passport
|
||||
result.id = id
|
||||
return result
|
||||
|
||||
@@ -49,7 +61,10 @@ class ReserveResultPojo:
|
||||
u'firstName': self.firstName,
|
||||
u'lastName': self.lastName,
|
||||
u'email': self.email,
|
||||
u'url': self.url
|
||||
u'passport': self.passport,
|
||||
u'url': self.url,
|
||||
u'sim_position': self.sim_position,
|
||||
u'slot_position': self.slot_position
|
||||
}
|
||||
|
||||
return dest
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<ul>
|
||||
% for result in result_list:
|
||||
<li>姓名:${result.lastName} ${result.firstName}, 电话: ${result.phone}, <br/>邮件: ${result.email},
|
||||
<li>姓名:${result.lastName} ${result.firstName}, 电话: ${result.phone},
|
||||
<br/>邮件: ${result.email},
|
||||
<br/>护照: ${result.passport}
|
||||
<br/>SIM卡位置: 卡池第${result.slot_position}行,第${result.sim_position}列
|
||||
</li>
|
||||
% endfor
|
||||
</ul>
|
||||
Reference in New Issue
Block a user