From 38c29de69ffd52eefba58a60dad67550f173a579 Mon Sep 17 00:00:00 2001 From: zhu-mengmeng <15588200382@163.com> Date: Wed, 25 Jun 2025 15:24:55 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E7=BA=BF=E5=BE=84?= =?UTF-8?q?=E5=85=AC=E5=B7=AE=E8=8C=83=E5=9B=B4=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dao/inspection_dao.py | 14 +++++++++++++- db/jtDB.db | Bin 77824 -> 77824 bytes from pymodbus.py | 2 +- widgets/main_window.py | 33 +++++++++++++++++++++++++-------- 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/dao/inspection_dao.py b/dao/inspection_dao.py index 1df316d..df3ce4d 100644 --- a/dao/inspection_dao.py +++ b/dao/inspection_dao.py @@ -624,7 +624,19 @@ class InspectionDAO: except Exception as e: logging.error(f"获取工字轮重量失败: {str(e)}") return 0 - + def get_xj_range(self,order_id): + """获取线径范围""" + try: + sql = """ + SELECT bccd, tccd FROM wsbz_order_info WHERE ddmo = ? + """ + params = (order_id,) + self.db.cursor.execute(sql, params) + result = self.db.cursor.fetchone() + return result[0],result[1] if result else None,None + except Exception as e: + logging.error(f"获取线径范围失败: {str(e)}") + return None,None def get_order_create_time(self, order_id): """获取工程号的最早创建时间 diff --git a/db/jtDB.db b/db/jtDB.db index 96c85423425fa56ba8aac8fe913ab5edc7de84b1..70019cbb93e3cc1015b93660e34201bc37300c86 100644 GIT binary patch delta 509 zcmZp8z|!!5Wr8&0+KDpGjB7V0%(rLM+2p|DAjZiR&cGkfw~tSjw}$67j}`Y!t{+_C zo243TxtJT}I42+M)2O#JGB7gLH89gPGF31%wKBA@GB(z;Ffgz*Fm_;kKX;QZUl=YG z#)id}#U-h^IOUBX@(v8k!3Ko{xEPrl7#SECS~kjY2r4o#sPj)g-lw!#xjVsx2WYpc zm64gArJ1qu=KlRf2I4$x892DlGw@#I^Wxji8_eUtKbiYH&!f$P0^7Nn^IEhg7c7#W zT(??K0jSl?%ETP2Ys{@oEhjTBk!7*WYSEnhaFL`j6O&;M&4L2Xyv)@t8k2u7liytW RcN-()jmd%nSC%ju007S=ML_@n diff --git a/from pymodbus.py b/from pymodbus.py index 3cd0ae8..7a6dc49 100644 --- a/from pymodbus.py +++ b/from pymodbus.py @@ -2,7 +2,7 @@ from pymodbus.client import ModbusTcpClient import time client = ModbusTcpClient('localhost', port=5020) client.connect() -client.write_registers(address=11, values=[2243]) +client.write_registers(address=11, values=[2242]) client.write_registers(address=13, values=[0]) client.write_registers(address=21, values=[0]) diff --git a/widgets/main_window.py b/widgets/main_window.py index ecb7208..e0e2e2e 100644 --- a/widgets/main_window.py +++ b/widgets/main_window.py @@ -657,21 +657,15 @@ class MainWindow(MainWindowUI): logging.info("工程号输入框按下回车事件") # 获取当前输入的工程号 gc_note = self.order_edit.text().strip() - tray_id = self.tray_edit.currentText() if gc_note: logging.info(f"输入的工程号: {gc_note}") #判断是否是接口,如果不是接口直接添加如果是则走接口 # 如果开启接口模式,则需要调用接口同步到业务库 self.add_new_inspection_row(gc_note, self._current_order_code) - - else: logging.warning("工程号为空") QMessageBox.warning(self, "输入提示", "请输入有效的工程号") - # 处理完后可以清除焦点,让输入框失去焦点 - self.central_widget.setFocus() - def add_new_inspection_row(self, gc_note, order_code): """在微丝产线表格中添加一条新记录,添加到表格末尾 @@ -2369,8 +2363,31 @@ class MainWindow(MainWindowUI): break if xj_config: - # 找到对应的检验项,将数据写入对应的单元格 - self.set_inspection_value('xj', xj_config, xj_value) + from dao.inspection_dao import InspectionDAO + inspection_dao = InspectionDAO() + bccd, tccd = inspection_dao.get_xj_range(self._current_order_code) + + if bccd is not None and tccd is not None: + if bccd <= xj_value <= tccd: + self.set_inspection_value('xj', xj_config, xj_value) + else: + logging.warning(f"线径 {xj_value} 不在公差范围内 ({bccd} - {tccd})") + reply = QMessageBox.question( + self, + '确认保存', + f"线径 {xj_value} 不在公差范围内 ({bccd} - {tccd}),\n是否继续保存?", + QMessageBox.Yes | QMessageBox.No, + QMessageBox.No + ) + if reply == QMessageBox.Yes: + self.set_inspection_value('xj', xj_config, xj_value) + else: + logging.info(f"用户取消保存超出范围的线径值: {xj_value}") + # TODO:后续根据实际情况实现 + pass + else: + logging.info(f"未找到订单 {self._current_order_code} 的线径公差范围,直接保存值 {xj_value}") + self.set_inspection_value('xj', xj_config, xj_value) else: logging.warning("未找到线径对应的检验项配置")