feat: 更新订单查询和主窗口逻辑,调整字段名称为srch_spack,优化净重计算及警告提示逻辑

This commit is contained in:
zhu-mengmeng 2025-07-21 15:51:47 +08:00
parent 0d216d3067
commit cbdc25545e
5 changed files with 20 additions and 19 deletions

View File

@ -341,7 +341,7 @@ class GcApi:
# API 配置中的键名 # API 配置中的键名
api_key = "get_order_info_by_xpack" api_key = "get_order_info_by_xpack"
order_dict = { order_dict = {
"xpack": xpack, "srch_spack": xpack,
"data_corp": corp_id "data_corp": corp_id
} }
data = { data = {

Binary file not shown.

View File

@ -130,7 +130,7 @@ class LoadingDialog(LoadingDialogUI):
main_window = self.parent main_window = self.parent
if main_window and isinstance(main_window, MainWindow): if main_window and isinstance(main_window, MainWindow):
# 使用note字段作为订单号已经被修改为mo的值 # 使用note字段作为订单号已经被修改为mo的值
order_code = order_data.get("note", "") order_code = order_data.get("mo", "")
logging.info(f"发送订单号到主窗口: {order_code}") logging.info(f"发送订单号到主窗口: {order_code}")
self.order_code_signal.emit(order_code) self.order_code_signal.emit(order_code)
@ -238,7 +238,7 @@ class LoadingDialog(LoadingDialogUI):
"""通过托盘号查询订单信息并回显到页面完全仿照on_order_query""" """通过托盘号查询订单信息并回显到页面完全仿照on_order_query"""
try: try:
query_params = { query_params = {
"xpack": tray_id, "srch_spack": tray_id,
"corp_id": self.corp_id "corp_id": self.corp_id
} }
dialog = OrderQueryDialog(self) dialog = OrderQueryDialog(self)

View File

@ -2245,7 +2245,19 @@ class MainWindow(MainWindowUI):
if not gc_note: if not gc_note:
logging.warning("工程号为空") logging.warning("工程号为空")
return return
# 保存净重到数据库(毛重-工字轮重量,单位都是千克)
from dao.inspection_dao import InspectionDAO
inspection_dao = InspectionDAO()
gzl_zl_raw = inspection_dao.get_gzl_zl(self._current_order_code)
gzl_zl = 0.0
try:
if gzl_zl_raw:
gzl_zl = float(gzl_zl_raw)
except (ValueError, TypeError):
logging.warning(f"无法将工字轮重量 '{gzl_zl_raw}' 转换为浮点数,将使用默认值 0.0")
net_weight_kg = round(weight_kg - gzl_zl,3)
# 检查轴重要求范围 # 检查轴重要求范围
if "轴重要求" in self.info_values and self.info_values["轴重要求"] is not None: if "轴重要求" in self.info_values and self.info_values["轴重要求"] is not None:
try: try:
@ -2258,7 +2270,7 @@ class MainWindow(MainWindowUI):
max_weight = float(parts[1].strip()) max_weight = float(parts[1].strip())
# 检查称重值是否在范围内 # 检查称重值是否在范围内
if weight_kg < min_weight or weight_kg > max_weight: if net_weight_kg < min_weight or net_weight_kg > max_weight:
# 写入寄存器D10 给值 2 表示重量超出范围 # 写入寄存器D10 给值 2 表示重量超出范围
modbus = ModbusUtils() modbus = ModbusUtils()
client = modbus.get_client() client = modbus.get_client()
@ -2268,7 +2280,7 @@ class MainWindow(MainWindowUI):
self.warning_msg = QMessageBox(self) self.warning_msg = QMessageBox(self)
self.warning_msg.setIcon(QMessageBox.Warning) self.warning_msg.setIcon(QMessageBox.Warning)
self.warning_msg.setWindowTitle('重量超出范围') self.warning_msg.setWindowTitle('重量超出范围')
self.warning_msg.setText(f"称重值 {weight_kg:.3f}kg 不在轴重要求范围内 ({min_weight:.1f} - {max_weight:.1f}kg)") self.warning_msg.setText(f"称重值 {net_weight_kg:.3f}kg 不在轴重要求范围内 ({min_weight:.1f} - {max_weight:.1f}kg)")
self.warning_msg.setStandardButtons(QMessageBox.NoButton) self.warning_msg.setStandardButtons(QMessageBox.NoButton)
self.warning_msg.setModal(False) # 确保非模态 self.warning_msg.setModal(False) # 确保非模态
self.warning_msg.setWindowFlags(self.warning_msg.windowFlags() | Qt.WindowStaysOnTopHint) # 置顶显示 self.warning_msg.setWindowFlags(self.warning_msg.windowFlags() | Qt.WindowStaysOnTopHint) # 置顶显示
@ -2326,18 +2338,7 @@ class MainWindow(MainWindowUI):
tray_id = self.tray_edit.currentText() tray_id = self.tray_edit.currentText()
self.save_inspection_data(self._current_order_code, gc_note, tray_id, 12, 12, str(weight_kg), "pass") self.save_inspection_data(self._current_order_code, gc_note, tray_id, 12, 12, str(weight_kg), "pass")
# 保存净重到数据库(毛重-工字轮重量,单位都是千克)
from dao.inspection_dao import InspectionDAO
inspection_dao = InspectionDAO()
gzl_zl_raw = inspection_dao.get_gzl_zl(self._current_order_code)
gzl_zl = 0.0
try:
if gzl_zl_raw:
gzl_zl = float(gzl_zl_raw)
except (ValueError, TypeError):
logging.warning(f"无法将工字轮重量 '{gzl_zl_raw}' 转换为浮点数,将使用默认值 0.0")
net_weight_kg = round(weight_kg - gzl_zl,3)
self.save_inspection_data(self._current_order_code, gc_note, tray_id, 13, 13, str(net_weight_kg), "pass") self.save_inspection_data(self._current_order_code, gc_note, tray_id, 13, 13, str(net_weight_kg), "pass")
# 设置净重单元格(显示千克) # 设置净重单元格(显示千克)

View File

@ -325,7 +325,7 @@ class OrderQueryDialog(OrderQueryDialogUI):
"""通过托盘号查订单数据,返回列表""" """通过托盘号查订单数据,返回列表"""
try: try:
gc_api = GcApi() gc_api = GcApi()
response = gc_api.get_order_info_by_xpack(params.get("xpack"), params.get("corp_id")) response = gc_api.get_order_info_by_xpack(params.get("srch_spack"), params.get("corp_id"))
if response and response.get("status", False): if response and response.get("status", False):
orders_data = response.get("data", []) orders_data = response.get("data", [])
results = [] results = []