Explorar el Código

2024/01/31 出口引导节点增加时间显示

wk hace 1 año
padre
commit
07b0f3339a

+ 5 - 3
mytool/db_helper/db_operation.py

@@ -31,14 +31,16 @@ class DBOperation:
     def query_small_empty_space(self):
         sql = "select count(*) from space where statu=0 and car_number is NULL and height<1.7"
         return self._db.query_all_sql(sql)
-
+    def query_pick_wait_weight_in_unit(self,unit):
+        sql = "select * from pick_wait_weight where unit=%s"
+        return self._db.query_all_sql(sql,unit)
     def query_queue_condition_in_unit(self, unit):
-        sql = "Select * , row_number() over(order by queue_time)  from command_queue where statu <2 and unit=%s"
+        sql = "Select * , row_number() over(order by queue_time)  from command_queue where type=2 and statu <2 and unit=%s"
         return self._db.query_all_sql(sql, unit)
 
 
     def query_command_queue_count_in_unit(self, unit):
-        sql = "select count(*) from command_queue where statu <2 and unit=%s"
+        sql = "select count(*) from command_queue where type=2 and statu <2 and unit=%s"
         return self._db.query_all_sql(sql, unit)
 
     def query_parking_in_unit_tableid(self, unit, tableid):

+ 38 - 25
出口引导节点/main_window_XmSgj.py

@@ -36,6 +36,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
         self.scroll_flag_dict = {}
         self.command_dict = {}
         self.last_command_dict = {}
+        self.pick_wait_weight = {}
+        self.last_pick_wait_weight = {}
         self.btn_positions = [(i, j) for i in range(0, show_config['row']) for j in range(show_config['column'])]
         # 创建listwidget与label 配置多少个单元生成多少对
 
@@ -48,7 +50,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
 
             self.list_widget_dict[i].setStyleSheet("border:5px solid #c0181f;")
             self.list_widget_dict[i].setObjectName(('list_widget_%d' % (i + 1)))
-            self.list_widget_thread[i] = threading.Thread(target=self.Scroll,args=(i,))
+            self.list_widget_thread[i] = threading.Thread(target=self.Scroll, args=(i,))
             self.list_widget_thread[i].start()
             label = QLabel(self.get_unit(i), self)
             label.setFont(QFont("黑体", 30, QFont.Bold))  # 设置字体、样式和大小
@@ -63,15 +65,16 @@ class MainWindow(QMainWindow, Ui_MainWindow):
             self.main_gridLayout.addLayout(vboxlayout, *position)
             self.main_gridLayout.setVerticalSpacing(40)
             self.command_dict[i] = []
+            self.pick_wait_weight[i] = {}
 
-        # 界面刷新定时器
-        self.timer = QTimer()
-        self.timer.timeout.connect(self.Switch)
-        self.timer.start(200)
         # 数据库查询线程
         self.db_query = threading.Thread(target=self.db_query)
         self.db_query_isClose = False
         self.db_query.start()
+        # 界面刷新定时器
+        self.timer = QTimer()
+        self.timer.timeout.connect(self.Switch)
+        self.timer.start(200)
 
         # 断开连接的弹窗
         self.t_timer = QTimer(self)
@@ -95,18 +98,23 @@ class MainWindow(QMainWindow, Ui_MainWindow):
     def db_query(self):
         while self.db_query_isClose is False:
             for i in self.unit_list:
-                if self.task_type != 0 and i != 40:
-                    self.last_command_dict[i] = self.db.query_command_all_in_unit_type_and_sort(i, self.task_type)
-                elif self.task_type != 0 and i == 40:
-                    self.last_command_dict[i] = self.db.query_command_top_number_in_type(self.task_type,self.top_number)
-                elif self.task_type == 0 and i != 40:
-                    self.last_command_dict[i] = self.db.query_command_all_in_unit_and_sort(i)
+                self.last_pick_wait_weight[i] = self.db.query_pick_wait_weight_in_unit(i)
+                if i != 40:
+                    self.last_command_dict[i] = self.db.query_queue_condition_in_unit(i)
                 else:
-                    self.last_command_dict[i] = self.db.query_command_top_number(self.top_number)
+                    self.last_command_dict[i] = self.db.query_command_top_number_in_type(self.task_type,
+                                                                                         self.top_number)
+
+                # elif self.task_type != 0 and i == 40:
+                #     self.last_command_dict[i] = self.db.query_command_top_number_in_type(self.task_type,self.top_number)
+                # elif self.task_type == 0 and i != 40:
+                #     self.last_command_dict[i] = self.db.query_queue_condition_in_unit(i)
+                # else:
+                #     self.last_command_dict[i] = self.db.query_command_top_number(self.top_number)
 
             time.sleep(0.2)
 
-    def get_listWidget_item(self, dict):
+    def get_listWidget_item(self, dict, index):
         item = QListWidgetItem()
         item.setFont(QFont('微软雅黑', self.font_size, QFont.Bold))
         show_str = ""
@@ -128,35 +136,40 @@ class MainWindow(QMainWindow, Ui_MainWindow):
             item.setBackground(QColor(250, 240, 200))
             if (dict['statu'] == 0):  # 排队
                 item.setForeground(QColor(80, 80, 80))
-                show_str = "%s 排队中" % (dict['car_number'])
+                show_str = "%s %s排队中" % (dict['car_number'], self.get_unit(dict['unit']))
+                if index != 40:
+                    show_str = "%s 剩%d分钟" % (dict['car_number'],
+                                                int((dict['row_number() over(order by queue_time)'] - 1) * 5 *
+                                                    self.pick_wait_weight[index][0]['wait_weight']))
             elif (dict['statu'] == 1):  # 工作
                 item.setForeground(QColor('blue'))
-                show_str = "%s 取车中" % (dict['car_number'])
+                show_str = "%s %s取车中" % (dict['car_number'], self.get_unit(dict['unit']))
             elif (dict['statu'] == 2):  # 已完成
                 item.setForeground(QColor('green'))
-                show_str = "%s 出口%d" % (dict['car_number'],dict['export_id'])
+                show_str = "%s %s出口%d" % (dict['car_number'], self.get_unit(dict['unit']), dict['export_id'])
             elif (dict['statu'] == 3):  # 已完成
                 item.setForeground(QColor(80, 180, 200))
-                show_str = "%s 维护!" % (dict['car_number'])
-            show_str = show_str[:len(show_str)-3]+self.get_unit(dict['unit'])+show_str[len(show_str)-3:]
+                show_str = "%s %s维护!" % (dict['car_number'], self.get_unit(dict['unit']))
 
         item.setText(show_str)
         return item
 
     def Switch(self):
         for i in self.unit_list:
-            if (i in self.last_command_dict.keys()) is False or self.last_command_dict[i] is None:
+
+            if (i in self.last_command_dict.keys()) is False or self.last_command_dict[i] is None or \
+                    (i in self.last_pick_wait_weight.keys()) is False or self.last_pick_wait_weight[i] is None:
                 self.show_message_box()
-            elif self.command_dict[i] != self.last_command_dict[i]:
+            elif self.command_dict[i] != self.last_command_dict[i] or self.pick_wait_weight[i] != \
+                    self.last_pick_wait_weight[i]:
+                self.pick_wait_weight[i] = self.last_pick_wait_weight[i]
                 self.command_dict[i] = self.last_command_dict[i]
                 self.list_widget_dict[i].clear()
-
                 for dict in self.command_dict[i]:
-                    if dict['statu'] != 4:
-                        self.list_widget_dict[i].addItem(self.get_listWidget_item(dict))
-
+                    if dict['statu'] != 4 and dict['type'] == self.task_type:
+                        self.list_widget_dict[i].addItem(self.get_listWidget_item(dict, i))
 
-    def Scroll(self,i):
+    def Scroll(self, i):
         while True:
             for index in range(self.list_widget_dict[i].count()):
                 # if self.scroll_flag_dict[i] is True:

+ 33 - 3
出口引导节点/mytool/db_helper/db_operation.py

@@ -20,6 +20,29 @@ class DBOperation:
     def update(self, sql):
         return self._db.execute_sql(sql)
 
+    def query_total_empty_space(self):
+        sql = "select count(*) from space where statu=0 and car_number is NULL"
+        return self._db.query_all_sql(sql)
+
+    def query_large_empty_space(self):
+        sql = "select count(*) from space where statu=0 and car_number is NULL and height>=1.7"
+        return self._db.query_all_sql(sql)
+
+    def query_small_empty_space(self):
+        sql = "select count(*) from space where statu=0 and car_number is NULL and height<1.7"
+        return self._db.query_all_sql(sql)
+    def query_pick_wait_weight_in_unit(self,unit):
+        sql = "select * from pick_wait_weight where unit=%s"
+        return self._db.query_all_sql(sql,unit)
+    def query_queue_condition_in_unit(self, unit):
+        sql = "Select * , row_number() over(order by queue_time)  from command_queue where type=2 and statu <2 and unit=%s"
+        return self._db.query_all_sql(sql, unit)
+
+
+    def query_command_queue_count_in_unit(self, unit):
+        sql = "select count(*) from command_queue where type=2 and statu <2 and unit=%s"
+        return self._db.query_all_sql(sql, unit)
+
     def query_parking_in_unit_tableid(self, unit, tableid):
         sql = "select * from space WHERE unit=%s and table_id=%s"
         return self._db.query_all_sql(sql, (unit, tableid))
@@ -51,12 +74,15 @@ class DBOperation:
     def query_command_all(self):
         sql = "select * from command_queue"
         return self._db.query_all_sql(sql)
-    def query_command_top_number(self,number):
+
+    def query_command_top_number(self, number):
         sql = "select *from ( select * from command_queue order by queue_time desc limit %s ) aa order by queue_time"
         return self._db.query_all_sql(sql, number)
-    def query_command_top_number_in_type(self, type,number):
+
+    def query_command_top_number_in_type(self, type, number):
         sql = "select * from ( select * from command_queue  where type=%s and statu != 4 order by queue_time desc limit %s ) aa order by queue_time"
-        return self._db.query_all_sql(sql, (type,number))
+        return self._db.query_all_sql(sql, (type, number))
+
     def query_command_in_car_number(self, car_number):
         sql = "select * from command_queue WHERE car_number=%s"
         return self._db.query_all_sql(sql, car_number)
@@ -153,6 +179,10 @@ class DBOperation:
         sql = "update space set remark=%s where id=%s"
         return self._db.execute_sql(sql, (remark, space_id))
 
+    def update_command_queue_upload_statu_in_car_number(self, car_number):
+        sql = "update command_queue set upload_statu=1 where car_number=%s"
+        return self._db.execute_sql(sql, car_number)
+
     def clear_space_data(self, space_id):
         sql = "update space set car_number=NULL,primary_key=NULL,statu=0,space_info=NULL,measure_buffer=NULL,plate_color=NULL,plate_type=NULL,plate_confidence=NULL,recognition_time=NULL,plate_full_image=NULL,plate_clip_image=NULL,remark=NULL where id=%s"
         return self._db.execute_sql(sql, space_id)

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

@@ -552,7 +552,7 @@ class CommandChecker:
 
             print("****************************查询排队信息****************************" + str(datetime.datetime.now()))
             command_count = self.db.query_command_queue_count_in_unit(unit_id)[0]['count(*)']
-
+        weight = self.db.query_pick_wait_weight_in_unit(unit_id)[0]['wait_weight']
         park_surplus_dict = {
             "parkId": self._parking_id,
             "totalParkSurplus": total,
@@ -565,7 +565,7 @@ class CommandChecker:
             "inRecordId": primary_key,
             "garageNo": self.get_unit_str(unit_id),
             "waitNum": command_count,
-            "remainingTime": command_count * 2
+            "remainingTime": command_count * 5 * weight
         }
 
         phone_out_dict = {

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

@@ -219,9 +219,9 @@ class MyHttpRequestHandler(BaseHTTPRequestHandler):
                 sql = "Select *  from space where height>1.799 and wheel_base>2.899 and unit>30 and car_number is null and statu=0"
                 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:
+                if len(space_list)>0 and apply_table.operation_type == 0:
                     code, msg, data = -2, "error", "预约失败,车辆已在库内!"
-                elif len(c_empty_space_list) < 0:
+                elif len(c_empty_space_list) < 0 and apply_table.operation_type == 0:
                     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))

+ 33 - 3
管理节点/mytool/db_helper/db_operation.py

@@ -20,6 +20,29 @@ class DBOperation:
     def update(self, sql):
         return self._db.execute_sql(sql)
 
+    def query_total_empty_space(self):
+        sql = "select count(*) from space where statu=0 and car_number is NULL"
+        return self._db.query_all_sql(sql)
+
+    def query_large_empty_space(self):
+        sql = "select count(*) from space where statu=0 and car_number is NULL and height>=1.7"
+        return self._db.query_all_sql(sql)
+
+    def query_small_empty_space(self):
+        sql = "select count(*) from space where statu=0 and car_number is NULL and height<1.7"
+        return self._db.query_all_sql(sql)
+    def query_pick_wait_weight_in_unit(self,unit):
+        sql = "select * from pick_wait_weight where unit=%s"
+        return self._db.query_all_sql(sql,unit)
+    def query_queue_condition_in_unit(self, unit):
+        sql = "Select * , row_number() over(order by queue_time)  from command_queue where type=2 and statu <2 and unit=%s"
+        return self._db.query_all_sql(sql, unit)
+
+
+    def query_command_queue_count_in_unit(self, unit):
+        sql = "select count(*) from command_queue where type=2 and statu <2 and unit=%s"
+        return self._db.query_all_sql(sql, unit)
+
     def query_parking_in_unit_tableid(self, unit, tableid):
         sql = "select * from space WHERE unit=%s and table_id=%s"
         return self._db.query_all_sql(sql, (unit, tableid))
@@ -51,12 +74,15 @@ class DBOperation:
     def query_command_all(self):
         sql = "select * from command_queue"
         return self._db.query_all_sql(sql)
-    def query_command_top_number(self,number):
+
+    def query_command_top_number(self, number):
         sql = "select *from ( select * from command_queue order by queue_time desc limit %s ) aa order by queue_time"
         return self._db.query_all_sql(sql, number)
-    def query_command_top_number_in_type(self, type,number):
+
+    def query_command_top_number_in_type(self, type, number):
         sql = "select * from ( select * from command_queue  where type=%s and statu != 4 order by queue_time desc limit %s ) aa order by queue_time"
-        return self._db.query_all_sql(sql, (type,number))
+        return self._db.query_all_sql(sql, (type, number))
+
     def query_command_in_car_number(self, car_number):
         sql = "select * from command_queue WHERE car_number=%s"
         return self._db.query_all_sql(sql, car_number)
@@ -153,6 +179,10 @@ class DBOperation:
         sql = "update space set remark=%s where id=%s"
         return self._db.execute_sql(sql, (remark, space_id))
 
+    def update_command_queue_upload_statu_in_car_number(self, car_number):
+        sql = "update command_queue set upload_statu=1 where car_number=%s"
+        return self._db.execute_sql(sql, car_number)
+
     def clear_space_data(self, space_id):
         sql = "update space set car_number=NULL,primary_key=NULL,statu=0,space_info=NULL,measure_buffer=NULL,plate_color=NULL,plate_type=NULL,plate_confidence=NULL,recognition_time=NULL,plate_full_image=NULL,plate_clip_image=NULL,remark=NULL where id=%s"
         return self._db.execute_sql(sql, space_id)