diff --git a/db/jtDB.db b/db/jtDB.db index 3afa978..1f03662 100644 Binary files a/db/jtDB.db and b/db/jtDB.db differ diff --git a/from pymodbus.py b/from pymodbus.py index c5b7631..2376fcb 100644 --- a/from pymodbus.py +++ b/from pymodbus.py @@ -2,11 +2,11 @@ from pymodbus.client import ModbusTcpClient import time client = ModbusTcpClient('localhost', port=5020) client.connect() -client.write_registers(address=11, values=[212]) +client.write_registers(address=11, values=[2122]) # client.write_registers(address=3, values=[0]) -time.sleep(2) -client.write_registers(address=0, values=[0]) -client.write_registers(address=4, values=[0]) +# time.sleep(2) +# client.write_registers(address=0, values=[0]) +# client.write_registers(address=4, values=[0]) # client.write_registers(address=30, values=[25]) # client.write_registers(address=5, values=[16]) @@ -15,6 +15,6 @@ client.write_registers(address=4, values=[0]) client.write_registers(address=13, values=[1]) -result = client.read_holding_registers(address=0, count=1) +result = client.read_holding_registers(address=11, count=1) print(result.registers[0],"123===") client.close() \ No newline at end of file diff --git a/widgets/main_window.py b/widgets/main_window.py index 76c58bd..582f181 100644 --- a/widgets/main_window.py +++ b/widgets/main_window.py @@ -3354,19 +3354,32 @@ class MainWindow(MainWindowUI): """) self.delete_row_button.clicked.connect(self.handle_delete_row) - # 创建打印按钮 + # 打印托盘号按钮 + self.print_tray_button = QPushButton("打印托盘号") + self.print_tray_button.setFont(self.normal_font) + self.print_tray_button.setStyleSheet(""" + QPushButton { + padding: 5px 8px; + background-color: #e3f2fd; + border: 1px solid #2196f3; + } + QPushButton:hover { + background-color: #c8e6c9; + } + """) + self.print_tray_button.clicked.connect(lambda: self.handle_tray_complete(ismt=False)) + + # 打印选中行按钮 self.print_row_button = QPushButton("打印选中行") self.print_row_button.setFont(self.normal_font) self.print_row_button.setStyleSheet(""" QPushButton { - padding: 5px 10px; - background-color: #e3f2fd; - border: 1px solid #2196f3; - border-radius: 4px; - font-weight: bold; + padding: 5px 8px; + background-color: #e0e0e0; + border: 1px solid #cccccc; } QPushButton:hover { - background-color: #bbdefb; + background-color: #f5f5f5; } """) self.print_row_button.clicked.connect(self.handle_print_row) @@ -3376,6 +3389,7 @@ class MainWindow(MainWindowUI): title_layout.addStretch() title_layout.addWidget(self.print_row_button) title_layout.addWidget(self.delete_row_button) + title_layout.addWidget(self.print_tray_button) # 设置容器样式 title_container.setFixedHeight(40) @@ -3453,26 +3467,29 @@ class MainWindow(MainWindowUI): - def handle_tray_complete(self): - """处理托盘完成按钮点击事件""" + def handle_tray_complete(self, ismt=True): + """托盘完成或打印托盘号事件 + Args: + ismt: 是否满托,True为满托,False为未满托 + """ try: # 获取托盘号 tray_id = self.tray_edit.currentText() if not tray_id: QMessageBox.warning(self, "提示", "请先选择托盘号") return - - # 确认对话框 - reply = QMessageBox.question( - self, - "确认完成", - f"确认将托盘 {tray_id} 标记为已满托?", - QMessageBox.Yes | QMessageBox.No, - QMessageBox.No - ) - - if reply != QMessageBox.Yes: - return + if ismt: + # 确认对话框 + reply = QMessageBox.question( + self, + "确认完成", + f"确认将托盘 {tray_id} 标记为已满托?", + QMessageBox.Yes | QMessageBox.No, + QMessageBox.No + ) + + if reply != QMessageBox.Yes: + return # 调用接口 from apis.gc_api import GcApi @@ -3480,7 +3497,7 @@ class MainWindow(MainWindowUI): # 准备参数 params = { - 'ismt': True, + 'ismt': ismt, 'corp_id': self.corp_id, 'tray_id': tray_id, 'ip': '192.168.1.246' @@ -3491,8 +3508,12 @@ class MainWindow(MainWindowUI): # 处理响应 if response.get('status', False): - QMessageBox.information(self, "成功", "托盘已标记为完成") - logging.info(f"托盘 {tray_id} 已标记为完成") + if ismt: + QMessageBox.information(self, "成功", "托盘已标记为完成") + logging.info(f"托盘 {tray_id} 已标记为完成") + else: + QMessageBox.information(self, "成功", "托盘号已打印") + logging.info(f"托盘号 {tray_id} 已打印") else: error_msg = response.get('message', '未知错误') QMessageBox.warning(self, "失败", f"标记托盘完成失败: {error_msg}")