feat: 更新订单查询和主窗口逻辑,调整字段名称为srch_spack,优化净重计算及警告提示逻辑
This commit is contained in:
parent
0d216d3067
commit
cbdc25545e
@ -341,7 +341,7 @@ class GcApi:
|
||||
# API 配置中的键名
|
||||
api_key = "get_order_info_by_xpack"
|
||||
order_dict = {
|
||||
"xpack": xpack,
|
||||
"srch_spack": xpack,
|
||||
"data_corp": corp_id
|
||||
}
|
||||
data = {
|
||||
|
||||
BIN
db/jtDB.db
BIN
db/jtDB.db
Binary file not shown.
@ -130,7 +130,7 @@ class LoadingDialog(LoadingDialogUI):
|
||||
main_window = self.parent
|
||||
if main_window and isinstance(main_window, MainWindow):
|
||||
# 使用note字段作为订单号(已经被修改为mo的值)
|
||||
order_code = order_data.get("note", "")
|
||||
order_code = order_data.get("mo", "")
|
||||
logging.info(f"发送订单号到主窗口: {order_code}")
|
||||
self.order_code_signal.emit(order_code)
|
||||
|
||||
@ -238,7 +238,7 @@ class LoadingDialog(LoadingDialogUI):
|
||||
"""通过托盘号查询订单信息,并回显到页面(完全仿照on_order_query)"""
|
||||
try:
|
||||
query_params = {
|
||||
"xpack": tray_id,
|
||||
"srch_spack": tray_id,
|
||||
"corp_id": self.corp_id
|
||||
}
|
||||
dialog = OrderQueryDialog(self)
|
||||
|
||||
@ -2245,7 +2245,19 @@ class MainWindow(MainWindowUI):
|
||||
if not gc_note:
|
||||
logging.warning("工程号为空")
|
||||
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:
|
||||
try:
|
||||
@ -2258,7 +2270,7 @@ class MainWindow(MainWindowUI):
|
||||
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 表示重量超出范围
|
||||
modbus = ModbusUtils()
|
||||
client = modbus.get_client()
|
||||
@ -2268,7 +2280,7 @@ class MainWindow(MainWindowUI):
|
||||
self.warning_msg = QMessageBox(self)
|
||||
self.warning_msg.setIcon(QMessageBox.Warning)
|
||||
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.setModal(False) # 确保非模态
|
||||
self.warning_msg.setWindowFlags(self.warning_msg.windowFlags() | Qt.WindowStaysOnTopHint) # 置顶显示
|
||||
@ -2326,18 +2338,7 @@ class MainWindow(MainWindowUI):
|
||||
tray_id = self.tray_edit.currentText()
|
||||
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")
|
||||
|
||||
# 设置净重单元格(显示千克)
|
||||
|
||||
@ -325,7 +325,7 @@ class OrderQueryDialog(OrderQueryDialogUI):
|
||||
"""通过托盘号查订单数据,返回列表"""
|
||||
try:
|
||||
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):
|
||||
orders_data = response.get("data", [])
|
||||
results = []
|
||||
|
||||
Loading…
Reference in New Issue
Block a user