Forráskód Böngészése

2024/01/29 测试收费系统外网请求

wk 1 éve
szülő
commit
d967d741ff
2 módosított fájl, 28 hozzáadás és 26 törlés
  1. 12 10
      指令检查节点/check_command_XmSgj.py
  2. 16 16
      指令检查节点/node.py

+ 12 - 10
指令检查节点/check_command_XmSgj.py

@@ -526,16 +526,17 @@ class CommandChecker:
             "Sign": sign_iphone
 
         }
-        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
-        }
+        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
+            }
         if param == 'queue 1':
             command_count = 1
         else:
@@ -560,6 +561,7 @@ class CommandChecker:
                 res = self.db.query_queue_condition_in_unit(unit)
                 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')
                         self.push_http_request(self._queue_url, pickup_queue_dict, headers_dict)

+ 16 - 16
指令检查节点/node.py

@@ -118,7 +118,7 @@ class MyHttpRequestHandler(BaseHTTPRequestHandler):
             res = json.loads(st)
             print(res)
         except Exception:
-            code,msg,data = 200,"error","解析失败!"
+            code,msg,data = -200,"error","解析失败!"
             self.send_write(code,msg,data)
             return
         # 查看是否有指令类型字段
@@ -129,7 +129,7 @@ class MyHttpRequestHandler(BaseHTTPRequestHandler):
                     # 查看是否有唯一码字段
                     primary_key = res['inRecordId']
                 except Exception:
-                    code, msg, data = 2, "error", "PickCommand,解析失败,缺少关键字段inRecordId!"
+                    code, msg, data = -2, "error", "PickCommand,解析失败,缺少关键字段inRecordId!"
                     self.send_write(code, msg, data)
                     return
                 # 生成取车表单,走正常取车指令
@@ -141,7 +141,7 @@ class MyHttpRequestHandler(BaseHTTPRequestHandler):
                     code, msg, data = 0, "success", "取车指令,接收成功!"
 
                 else:
-                    code, msg, data = 1, "error", "取车失败!%s" % cmd.statu.statu_description
+                    code, msg, data = -1, "error", "取车失败!%s" % cmd.statu.statu_description
             # 查询排队
             elif res['commandType'] == 'RankCommand':
                 try:
@@ -150,7 +150,7 @@ class MyHttpRequestHandler(BaseHTTPRequestHandler):
                     car_number = res['licenesePlate']
                     primary_key = res['inRecordId']
                 except Exception:
-                    code, msg, data = 2, "error", "RankCommand,解析失败,缺少关键字段!"
+                    code, msg, data = -2, "error", "RankCommand,解析失败,缺少关键字段!"
                     self.send_write(code, msg, data)
                     return
                 # 查询排队信息
@@ -172,7 +172,7 @@ class MyHttpRequestHandler(BaseHTTPRequestHandler):
                     i = i+1
                 # 没找到对应车辆
                 if i == len(command_list):
-                    code, msg, data = 1, "error", '未查询到该车辆,车牌号:%s,单元号:%s,流水号:%s'%(car_number,garageNo,primary_key)
+                    code, msg, data = -1, "error", '未查询到该车辆,车牌号:%s,单元号:%s,流水号:%s'%(car_number,garageNo,primary_key)
             # 预约车位
             elif res['commandType'] == 'ApplyCommand':
                 try:
@@ -182,7 +182,7 @@ class MyHttpRequestHandler(BaseHTTPRequestHandler):
                     apply_table.apply_end_time = res['endTime']
 
                 except Exception:
-                    code, msg, data = 2, "error", "ApplyCommand,解析失败,缺少关键字段!"
+                    code, msg, data = -2, "error", "ApplyCommand,解析失败,缺少关键字段!"
                     self.send_write(code, msg, data)
                     return
                 #预约车位查重
@@ -190,14 +190,14 @@ class MyHttpRequestHandler(BaseHTTPRequestHandler):
                 c_empty_space_list = checker.db.query(sql)
                 space_list = checker.db.query_space_in_car_number(apply_table.car_number)
                 if len(space_list)>0:
-                    code, msg, data = 1, "error", "预约失败,车辆已在库内!"
+                    code, msg, data = -1, "error", "预约失败,车辆已在库内!"
                 elif len(c_empty_space_list) < 0:
-                    code, msg, data = 1, "error", "预约失败,无空闲车位!"
+                    code, msg, data = -1, "error", "预约失败,无空闲车位!"
                 else:
                     g_rabbitmq.publish(mq_config['mq_command_exchange_name'], "dispatch_apply_command_request_port",tf.MessageToString(apply_table, as_utf8=True))
                     code, msg, data = 0, "success", "预约成功!"
         else:
-            code, msg, data = 2, "error", "解析失败,缺少关键字段commandType!"
+            code, msg, data = -2, "error", "解析失败,缺少关键字段commandType!"
         # 发送答复
         self.send_write(code, msg, data)
     # 对接受到的post请求发送答复
@@ -235,13 +235,13 @@ if __name__ == '__main__':
     # 初始化rabbitmq
     g_rabbitmq = CM.RabbitAsyncCommunicator(mq_config['mq_ip'], mq_config['mq_port'], mq_config['mq_user'],
                                             mq_config['mq_password'])
-    g_rabbitmq.Init(cmd_callbacks, mq_config['mq_statu_exchange_keys'], "checker")
-    # 绑定队列
-    for ex, key in mq_config['mq_statu_exchange_keys']:
-        if key.find("dispatch") >= 0:
-            g_rabbitmq.bind_statu_callback(ex, key, checker.receive_dispatch_statu)
-        if key.find("measure") >= 0:
-            g_rabbitmq.bind_statu_callback(ex, key, checker.receive_measure_info)
+    # g_rabbitmq.Init(cmd_callbacks, mq_config['mq_statu_exchange_keys'], "checker")
+    # # 绑定队列
+    # for ex, key in mq_config['mq_statu_exchange_keys']:
+    #     if key.find("dispatch") >= 0:
+    #         g_rabbitmq.bind_statu_callback(ex, key, checker.receive_dispatch_statu)
+    #     if key.find("measure") >= 0:
+    #         g_rabbitmq.bind_statu_callback(ex, key, checker.receive_measure_info)
     # 收费系统云端通信
     http_community = threading.Thread(target=recv_post)
     g_rabbitmq.start()