|
@@ -10,7 +10,6 @@ from concurrent.futures import ThreadPoolExecutor
|
|
|
|
|
|
import requests
|
|
|
|
|
|
-
|
|
|
sys.path.append("..")
|
|
|
import pymysql
|
|
|
import logging
|
|
@@ -64,10 +63,10 @@ class CommandChecker:
|
|
|
# self._out_url_phone = 'https://sztc.smartcityxm.com/api/operateOutScene/sgjOutSceneRecord' #测试环境
|
|
|
# 余位
|
|
|
# self._park_surplus_url = 'https://sztc.xmsztc.cn/api/basicPark/sgjParkSurplus'
|
|
|
- self._park_surplus_url = 'https://sztc.smartcityxm.com/api/basicPark/sgjParkSurplus' #测试环境
|
|
|
+ self._park_surplus_url = 'https://sztc.smartcityxm.com/api/basicPark/sgjParkSurplus' # 测试环境
|
|
|
# 公众号
|
|
|
# self._queue_url = 'https://sztc.xmsztc.cn/api/operateOutScene/sgjSendPickUpMsg'
|
|
|
- self._queue_url = 'https://sztc.smartcityxm.com/api/operateOutScene/sgjSendPickUpMsg' # 测试环境
|
|
|
+ self._queue_url = 'https://sztc.smartcityxm.com/api/operateOutScene/sgjSendPickUpMsg' # 测试环境
|
|
|
# 手机端appid
|
|
|
self._app_id_phone = '20230412151327035'
|
|
|
# 手机端app秘钥
|
|
@@ -95,6 +94,7 @@ class CommandChecker:
|
|
|
self._plate_color = {'蓝色': '1', '黑色': '2', '黄色': '3', '白色': '4', '绿色': '5', '其他': '6'}
|
|
|
|
|
|
self.push_pickqueue_thread.start()
|
|
|
+
|
|
|
def get_in_url(self):
|
|
|
return self._in_url
|
|
|
|
|
@@ -115,8 +115,8 @@ class CommandChecker:
|
|
|
print("请求地址:" + url)
|
|
|
if url != self._in_url:
|
|
|
print("请求内容:" + str(request))
|
|
|
- resp = requests.post(url, json=request, headers=headers,timeout=2).json()
|
|
|
- print("请求答复:"+str(resp)+'\n')
|
|
|
+ resp = requests.post(url, json=request, headers=headers, timeout=2).json()
|
|
|
+ print("请求答复:" + str(resp) + '\n')
|
|
|
|
|
|
if (('Tag' in resp.keys()) and resp['Tag'] == 1) or \
|
|
|
(('code' in resp.keys()) and resp['code'] == 0):
|
|
@@ -329,11 +329,14 @@ class CommandChecker:
|
|
|
whitelist_res = self.db.query_whitelist_in_car_number(park_table.car_number)
|
|
|
if len(whitelist_res) <= 0:
|
|
|
# 向收费系统推送入场信息
|
|
|
- print("----------------------------推送入场-----------------------------" + str(datetime.datetime.now()))
|
|
|
+ print(
|
|
|
+ "----------------------------推送入场-----------------------------" + str(datetime.datetime.now()))
|
|
|
in_dict = self.get_cloud_request_data(park_table, 'in')
|
|
|
- headers_dict,park_surplus_dict,pickup_queue_dict,phone_out_dict = self.get_phone_request_data(park_table.car_number,park_table.primary_key,park_table.unit_id, 'in')
|
|
|
+ headers_dict, park_surplus_dict, pickup_queue_dict, phone_out_dict = self.get_phone_request_data(
|
|
|
+ park_table.car_number, park_table.primary_key, park_table.unit_id, 'in')
|
|
|
statu, response = self.push_http_request(self._in_url, in_dict)
|
|
|
- print("----------------------------推送余位-----------------------------" + str(datetime.datetime.now()))
|
|
|
+ print(
|
|
|
+ "----------------------------推送余位-----------------------------" + str(datetime.datetime.now()))
|
|
|
self.push_http_request(self._park_surplus_url, park_surplus_dict, headers_dict)
|
|
|
|
|
|
if statu != message.eNormal:
|
|
@@ -347,7 +350,8 @@ class CommandChecker:
|
|
|
park_table.statu.execute_statu = message.eError
|
|
|
park_table.statu.statu_description = "收费系统答复错误!请联系管理员!"
|
|
|
else:
|
|
|
- print("----------------------------白名单车辆-----------------------------" + str(datetime.datetime.now()))
|
|
|
+ print("----------------------------白名单车辆-----------------------------" + str(
|
|
|
+ datetime.datetime.now()))
|
|
|
return park_table
|
|
|
|
|
|
# 检查取车指令
|
|
@@ -368,14 +372,16 @@ class CommandChecker:
|
|
|
print("****************************查询车位表****************************" + str(datetime.datetime.now()))
|
|
|
space_res = self.db.query_space_in_primary_key(pick_table.primary_key)
|
|
|
space_count = len(space_res)
|
|
|
- print("****************************查询停车指令表****************************" + str(datetime.datetime.now()))
|
|
|
+ print(
|
|
|
+ "****************************查询停车指令表****************************" + str(datetime.datetime.now()))
|
|
|
command_res_park = self.db.query_park_command_in_primary_key(pick_table.primary_key)
|
|
|
command_count_park = len(command_res_park)
|
|
|
if space_count <= 0 and command_count_park <= 0:
|
|
|
pick_table.statu.execute_statu = message.eWarning
|
|
|
pick_table.statu.statu_description = "车辆信息不存在!"
|
|
|
return pick_table
|
|
|
- print("****************************查询取车指令表****************************" + str(datetime.datetime.now()))
|
|
|
+ print(
|
|
|
+ "****************************查询取车指令表****************************" + str(datetime.datetime.now()))
|
|
|
command_res = self.db.query_pick_command_in_primary_key(pick_table.primary_key)
|
|
|
command_count = len(command_res)
|
|
|
if command_count > 0:
|
|
@@ -409,13 +415,16 @@ class CommandChecker:
|
|
|
if pick_table.statu.table_process_mod == message.PROCESS_ONLY_TO_DISPATCH or pick_table.statu.table_process_mod == message.PROCESS_ONLY_TO_PAY:
|
|
|
# if pick_table.unit_id != 31 and pick_table.unit_id != 32:
|
|
|
# 直接向收费系统发送出场
|
|
|
- print("****************************收费系统推送出场****************************" + str(datetime.datetime.now()))
|
|
|
+ print("****************************收费系统推送出场****************************" + str(
|
|
|
+ datetime.datetime.now()))
|
|
|
out_dict = self.get_cloud_request_data(pick_table, 'out')
|
|
|
- headers_dict,park_surplus_dict,pickup_queue_dict,phone_out_dict = self.get_phone_request_data(pick_table.car_number,pick_table.primary_key,pick_table.unit_id, 'out')
|
|
|
+ headers_dict, park_surplus_dict, pickup_queue_dict, phone_out_dict = self.get_phone_request_data(
|
|
|
+ pick_table.car_number, pick_table.primary_key, pick_table.unit_id, 'out')
|
|
|
self.push_http_request(self._out_url, out_dict)
|
|
|
print("\n")
|
|
|
- print("****************************手机端推送出场****************************" + str(datetime.datetime.now()))
|
|
|
- self.push_http_request(self._out_url_phone, phone_out_dict,headers_dict)
|
|
|
+ print("****************************手机端推送出场****************************" + str(
|
|
|
+ datetime.datetime.now()))
|
|
|
+ self.push_http_request(self._out_url_phone, phone_out_dict, headers_dict)
|
|
|
print("\n")
|
|
|
print("****************************推送余位****************************" + str(datetime.datetime.now()))
|
|
|
self.push_http_request(self._park_surplus_url, park_surplus_dict, headers_dict)
|
|
@@ -425,11 +434,13 @@ class CommandChecker:
|
|
|
print("\n")
|
|
|
print('强制取车')
|
|
|
else:
|
|
|
- print("****************************查询白名单****************************" + str(datetime.datetime.now()))
|
|
|
+ print(
|
|
|
+ "****************************查询白名单****************************" + str(datetime.datetime.now()))
|
|
|
whitelist_res = self.db.query_whitelist_in_car_number(pick_table.car_number)
|
|
|
if len(whitelist_res) <= 0:
|
|
|
# 向收费系统查询缴费情况
|
|
|
- print("****************************查询缴费情况****************************" + str(datetime.datetime.now()))
|
|
|
+ print("****************************查询缴费情况****************************" + str(
|
|
|
+ datetime.datetime.now()))
|
|
|
request = self.get_cloud_request_data(pick_table, 'query')
|
|
|
statu, response = self.push_http_request(self._query_url, request)
|
|
|
if statu == message.eNormal:
|
|
@@ -443,13 +454,16 @@ class CommandChecker:
|
|
|
pick_table.car_number, pick_table.primary_key, pick_table.unit_id, 'out')
|
|
|
self.push_http_request(self._out_url, out_dict)
|
|
|
print("\n")
|
|
|
- print("****************************手机端推送出场****************************" + str(datetime.datetime.now()))
|
|
|
+ print("****************************手机端推送出场****************************" + str(
|
|
|
+ datetime.datetime.now()))
|
|
|
self.push_http_request(self._out_url_phone, phone_out_dict, headers_dict)
|
|
|
print("\n")
|
|
|
- print("****************************推送余位****************************" + str(datetime.datetime.now()))
|
|
|
+ print("****************************推送余位****************************" + str(
|
|
|
+ datetime.datetime.now()))
|
|
|
self.push_http_request(self._park_surplus_url, park_surplus_dict, headers_dict)
|
|
|
print("\n")
|
|
|
- print("****************************推送排队****************************" + str(datetime.datetime.now()))
|
|
|
+ print("****************************推送排队****************************" + str(
|
|
|
+ datetime.datetime.now()))
|
|
|
self.push_http_request(self._queue_url, pickup_queue_dict, headers_dict)
|
|
|
print("\n")
|
|
|
if statu != message.eNormal:
|
|
@@ -477,7 +491,7 @@ class CommandChecker:
|
|
|
return pick_table
|
|
|
|
|
|
def get_cloud_request_data(self, table, param):
|
|
|
- print(param+":")
|
|
|
+ print(param + ":")
|
|
|
# 创建请求
|
|
|
msgId = str(uuid.uuid1()) + '@' + table.car_number
|
|
|
AppId = self._app_id
|
|
@@ -511,8 +525,9 @@ class CommandChecker:
|
|
|
table.car_number_info.plate_clip_image)
|
|
|
request = http_client.HttpRequest(msgId, AppId, time, sign, data)
|
|
|
return request.__dict__
|
|
|
- def get_phone_request_data(self, car_number,primary_key,unit_id, param):
|
|
|
- print(param+":")
|
|
|
+
|
|
|
+ def get_phone_request_data(self, car_number, primary_key, unit_id, param):
|
|
|
+ print(param + ":")
|
|
|
# 创建请求
|
|
|
appid_iphone = self._app_id_phone
|
|
|
time_iphone = str(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
|
|
@@ -526,22 +541,25 @@ class CommandChecker:
|
|
|
"Sign": sign_iphone
|
|
|
|
|
|
}
|
|
|
- if param != 'queue 1':
|
|
|
- print("****************************查询余位****************************" + str(datetime.datetime.now()))
|
|
|
- total = self.db.query_total_empty_space()[0]['count(*)']
|
|
|
- large = self.db.query_large_empty_space()[0]['count(*)']
|
|
|
- small = self.db.query_small_empty_space()[0]['count(*)']
|
|
|
- park_surplus_dict = {
|
|
|
- "parkId": self._parking_id,
|
|
|
- "totalParkSurplus": total,
|
|
|
- "largeParkSurplus": large,
|
|
|
- "smallParkSurplus": small
|
|
|
- }
|
|
|
+ total = large = small = 0
|
|
|
if param == 'queue 1':
|
|
|
command_count = 1
|
|
|
else:
|
|
|
+ print("****************************查询余位*******************************" + str(datetime.datetime.now()))
|
|
|
+ total = self.db.query_total_empty_space()[0]['count(*)']
|
|
|
+ large = self.db.query_large_empty_space()[0]['count(*)']
|
|
|
+ small = self.db.query_small_empty_space()[0]['count(*)']
|
|
|
+
|
|
|
print("****************************查询排队信息****************************" + str(datetime.datetime.now()))
|
|
|
command_count = self.db.query_command_queue_count_in_unit(unit_id)[0]['count(*)']
|
|
|
+
|
|
|
+ park_surplus_dict = {
|
|
|
+ "parkId": self._parking_id,
|
|
|
+ "totalParkSurplus": total,
|
|
|
+ "largeParkSurplus": large,
|
|
|
+ "smallParkSurplus": small
|
|
|
+ }
|
|
|
+
|
|
|
pickup_queue_dict = {
|
|
|
"licenesePlate": car_number,
|
|
|
"inRecordId": primary_key,
|
|
@@ -549,12 +567,14 @@ class CommandChecker:
|
|
|
"waitNum": command_count,
|
|
|
"remainingTime": command_count * 2
|
|
|
}
|
|
|
+
|
|
|
phone_out_dict = {
|
|
|
"parkId": self._parking_id,
|
|
|
"licenesePlate": car_number,
|
|
|
"inRecordId": primary_key
|
|
|
}
|
|
|
- return headers_dict,park_surplus_dict,pickup_queue_dict,phone_out_dict
|
|
|
+ return headers_dict, park_surplus_dict, pickup_queue_dict, phone_out_dict
|
|
|
+
|
|
|
def push_pickqueue(self):
|
|
|
while True:
|
|
|
for unit in self.chnnId_in.keys():
|
|
@@ -562,11 +582,14 @@ class CommandChecker:
|
|
|
for dict in res:
|
|
|
if dict['upload_statu'] is None and dict['row_number() over(order by queue_time)'] == 2:
|
|
|
print("\n")
|
|
|
- print("===============================排队为1 推送排队详情=========================" + str(datetime.datetime.now()))
|
|
|
- headers_dict, park_surplus_dict, pickup_queue_dict, phone_out_dict = self.get_phone_request_data(dict['car_number'], dict['primary_key'], dict['unit'], 'queue 1')
|
|
|
+ print("===============================排队为1 推送排队详情=========================" + str(
|
|
|
+ datetime.datetime.now()))
|
|
|
+ headers_dict, park_surplus_dict, pickup_queue_dict, phone_out_dict = self.get_phone_request_data(
|
|
|
+ dict['car_number'], dict['primary_key'], dict['unit'], 'queue 1')
|
|
|
self.push_http_request(self._queue_url, pickup_queue_dict, headers_dict)
|
|
|
self.db.update_command_queue_upload_statu_in_car_number(dict['car_number'])
|
|
|
time.sleep(1)
|
|
|
+
|
|
|
def get_unit_str(self, unit):
|
|
|
if unit == 11:
|
|
|
return 'A1'
|
|
@@ -597,6 +620,7 @@ class CommandChecker:
|
|
|
elif unit == 3:
|
|
|
return 'C'
|
|
|
return ''
|
|
|
+
|
|
|
def get_unit_int(self, unit):
|
|
|
if unit == 'A1':
|
|
|
return 11
|