feat: 新增线径公差范围判断
This commit is contained in:
parent
5138c0e115
commit
38c29de69f
@ -624,7 +624,19 @@ class InspectionDAO:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"获取工字轮重量失败: {str(e)}")
|
logging.error(f"获取工字轮重量失败: {str(e)}")
|
||||||
return 0
|
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):
|
def get_order_create_time(self, order_id):
|
||||||
"""获取工程号的最早创建时间
|
"""获取工程号的最早创建时间
|
||||||
|
|
||||||
|
|||||||
BIN
db/jtDB.db
BIN
db/jtDB.db
Binary file not shown.
@ -2,7 +2,7 @@ from pymodbus.client import ModbusTcpClient
|
|||||||
import time
|
import time
|
||||||
client = ModbusTcpClient('localhost', port=5020)
|
client = ModbusTcpClient('localhost', port=5020)
|
||||||
client.connect()
|
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=13, values=[0])
|
||||||
|
|
||||||
client.write_registers(address=21, values=[0])
|
client.write_registers(address=21, values=[0])
|
||||||
|
|||||||
@ -657,21 +657,15 @@ class MainWindow(MainWindowUI):
|
|||||||
logging.info("工程号输入框按下回车事件")
|
logging.info("工程号输入框按下回车事件")
|
||||||
# 获取当前输入的工程号
|
# 获取当前输入的工程号
|
||||||
gc_note = self.order_edit.text().strip()
|
gc_note = self.order_edit.text().strip()
|
||||||
tray_id = self.tray_edit.currentText()
|
|
||||||
if gc_note:
|
if gc_note:
|
||||||
logging.info(f"输入的工程号: {gc_note}")
|
logging.info(f"输入的工程号: {gc_note}")
|
||||||
#判断是否是接口,如果不是接口直接添加如果是则走接口
|
#判断是否是接口,如果不是接口直接添加如果是则走接口
|
||||||
# 如果开启接口模式,则需要调用接口同步到业务库
|
# 如果开启接口模式,则需要调用接口同步到业务库
|
||||||
self.add_new_inspection_row(gc_note, self._current_order_code)
|
self.add_new_inspection_row(gc_note, self._current_order_code)
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
logging.warning("工程号为空")
|
logging.warning("工程号为空")
|
||||||
QMessageBox.warning(self, "输入提示", "请输入有效的工程号")
|
QMessageBox.warning(self, "输入提示", "请输入有效的工程号")
|
||||||
|
|
||||||
# 处理完后可以清除焦点,让输入框失去焦点
|
|
||||||
self.central_widget.setFocus()
|
|
||||||
|
|
||||||
def add_new_inspection_row(self, gc_note, order_code):
|
def add_new_inspection_row(self, gc_note, order_code):
|
||||||
"""在微丝产线表格中添加一条新记录,添加到表格末尾
|
"""在微丝产线表格中添加一条新记录,添加到表格末尾
|
||||||
|
|
||||||
@ -2369,7 +2363,30 @@ class MainWindow(MainWindowUI):
|
|||||||
break
|
break
|
||||||
|
|
||||||
if xj_config:
|
if xj_config:
|
||||||
# 找到对应的检验项,将数据写入对应的单元格
|
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)
|
self.set_inspection_value('xj', xj_config, xj_value)
|
||||||
else:
|
else:
|
||||||
logging.warning("未找到线径对应的检验项配置")
|
logging.warning("未找到线径对应的检验项配置")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user