feat:修复数据展示问题
This commit is contained in:
parent
668700353f
commit
67374c5513
@ -8,7 +8,7 @@
|
|||||||
"enable_camera": false
|
"enable_camera": false
|
||||||
},
|
},
|
||||||
"base_url": "http://localhost:8085",
|
"base_url": "http://localhost:8085",
|
||||||
"mode": "standalone"
|
"mode": "api"
|
||||||
},
|
},
|
||||||
"apis": {
|
"apis": {
|
||||||
"get_tray_info": "/apjt/xcsc/tpda/getByTp_note/",
|
"get_tray_info": "/apjt/xcsc/tpda/getByTp_note/",
|
||||||
|
|||||||
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=[3922])
|
client.write_registers(address=11, values=[8922])
|
||||||
# client.write_registers(address=3, values=[0])
|
# client.write_registers(address=3, values=[0])
|
||||||
# time.sleep(2)
|
# time.sleep(2)
|
||||||
# client.write_registers(address=0, values=[0])
|
# client.write_registers(address=0, values=[0])
|
||||||
@ -12,8 +12,8 @@ client.write_registers(address=11, values=[3922])
|
|||||||
# client.write_registers(address=5, values=[16])
|
# client.write_registers(address=5, values=[16])
|
||||||
# 贴标完成
|
# 贴标完成
|
||||||
# client.write_registers(address=24, values=[1])
|
# client.write_registers(address=24, values=[1])
|
||||||
client.write_registers(address=2, values=[0])
|
# client.write_registers(address=2, values=[0])
|
||||||
client.write_registers(address=3, values=[0])
|
# client.write_registers(address=3, values=[0])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -25,7 +25,7 @@ class MainWindowUI(QMainWindow):
|
|||||||
"强度范围": "qx",
|
"强度范围": "qx",
|
||||||
"强度": "qd",
|
"强度": "qd",
|
||||||
"延伸要求": "ysl",
|
"延伸要求": "ysl",
|
||||||
"线材类型": "jz",
|
"线材类型": "xclx",
|
||||||
"包装方式": "bzfs",
|
"包装方式": "bzfs",
|
||||||
"轴重要求": "zzyq",
|
"轴重要求": "zzyq",
|
||||||
"线径公差": "xj",
|
"线径公差": "xj",
|
||||||
|
|||||||
@ -896,6 +896,11 @@ class MainWindow(MainWindowUI):
|
|||||||
# 先获取当前 info_table 已有的数据
|
# 先获取当前 info_table 已有的数据
|
||||||
order_info = {}
|
order_info = {}
|
||||||
for field_name, label in self.info_values.items():
|
for field_name, label in self.info_values.items():
|
||||||
|
# 过滤掉线径公差字段,因为线径数据是通过线径仪获取的,不需要从前端托盘入库地方获取
|
||||||
|
if field_name == "线径公差":
|
||||||
|
logging.debug(f"跳过线径公差字段,该字段由线径仪获取")
|
||||||
|
continue
|
||||||
|
|
||||||
order_info_key = self.FIELD_MAPPING.get(field_name)
|
order_info_key = self.FIELD_MAPPING.get(field_name)
|
||||||
if order_info_key and label is not None:
|
if order_info_key and label is not None:
|
||||||
try:
|
try:
|
||||||
@ -2225,7 +2230,27 @@ class MainWindow(MainWindowUI):
|
|||||||
info.update(order_info)
|
info.update(order_info)
|
||||||
|
|
||||||
# 2. 从前端获取用户修改的数据,作为补充和更新
|
# 2. 从前端获取用户修改的数据,作为补充和更新
|
||||||
|
logging.info(f"开始从前端获取数据,info_values中的字段: {list(self.info_values.keys())}")
|
||||||
|
|
||||||
|
# 专门检查线材类型字段
|
||||||
|
if "线材类型" in self.info_values:
|
||||||
|
wire_type_widget = self.info_values["线材类型"]
|
||||||
|
if isinstance(wire_type_widget, QComboBox):
|
||||||
|
wire_type_value = wire_type_widget.currentText()
|
||||||
|
logging.info(f"线材类型字段当前值: '{wire_type_value}'")
|
||||||
|
logging.info(f"线材类型下拉框选项: {[wire_type_widget.itemText(i) for i in range(wire_type_widget.count())]}")
|
||||||
|
else:
|
||||||
|
logging.warning(f"线材类型字段不是QComboBox,而是: {type(wire_type_widget)}")
|
||||||
|
else:
|
||||||
|
logging.warning("线材类型字段不在info_values中")
|
||||||
|
|
||||||
for field_name, field_key in self.FIELD_MAPPING.items():
|
for field_name, field_key in self.FIELD_MAPPING.items():
|
||||||
|
# 过滤掉线径公差字段,因为线径数据是通过线径仪获取的,不需要从前端托盘入库地方获取
|
||||||
|
if field_name == "线径公差":
|
||||||
|
logging.debug(f"跳过线径公差字段,该字段由线径仪获取")
|
||||||
|
continue
|
||||||
|
|
||||||
|
logging.debug(f"处理字段: {field_name} -> {field_key}")
|
||||||
if field_name in self.info_values and self.info_values[field_name] is not None:
|
if field_name in self.info_values and self.info_values[field_name] is not None:
|
||||||
try:
|
try:
|
||||||
# 根据控件类型获取最新值
|
# 根据控件类型获取最新值
|
||||||
@ -2247,16 +2272,23 @@ class MainWindow(MainWindowUI):
|
|||||||
else:
|
else:
|
||||||
current_value = ""
|
current_value = ""
|
||||||
|
|
||||||
|
# 对于线材类型字段,即使值为"请选择"也要包含在接口调用中
|
||||||
|
if field_name == "线材类型":
|
||||||
|
info[field_key] = current_value
|
||||||
# 如果前端有值,则更新info字典(覆盖数据库中的值)
|
# 如果前端有值,则更新info字典(覆盖数据库中的值)
|
||||||
if current_value:
|
elif current_value:
|
||||||
info[field_key] = current_value
|
info[field_key] = current_value
|
||||||
logging.debug(f"从前端更新字段 '{field_name}': '{current_value}'")
|
logging.debug(f"从前端更新字段 '{field_name}': '{current_value}'")
|
||||||
# 如果前端没有值但数据库有值,保持数据库的值
|
# 如果前端没有值但数据库有值,保持数据库的值
|
||||||
elif field_key in info:
|
elif field_key in info:
|
||||||
logging.debug(f"保持数据库字段 '{field_name}': '{info[field_key]}'")
|
logging.debug(f"保持数据库字段 '{field_name}': '{info[field_key]}'")
|
||||||
|
else:
|
||||||
|
logging.debug(f"字段 '{field_name}' 前端值为空且数据库中也无值")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.warning(f"获取前端字段 '{field_name}' 失败: {str(e)}")
|
logging.warning(f"获取前端字段 '{field_name}' 失败: {str(e)}")
|
||||||
continue
|
continue
|
||||||
|
else:
|
||||||
|
logging.debug(f"字段 '{field_name}' 不在info_values中或为None")
|
||||||
|
|
||||||
# 3. 添加其他必要的信息
|
# 3. 添加其他必要的信息
|
||||||
info['xpack'] = self.tray_edit.currentText()
|
info['xpack'] = self.tray_edit.currentText()
|
||||||
@ -2296,6 +2328,11 @@ class MainWindow(MainWindowUI):
|
|||||||
# 如果获取失败,使用本地回环地址
|
# 如果获取失败,使用本地回环地址
|
||||||
info['nw_ip'] = '127.0.0.1'
|
info['nw_ip'] = '127.0.0.1'
|
||||||
# info['nw_ip'] = '192.168.1.246'
|
# info['nw_ip'] = '192.168.1.246'
|
||||||
|
# 调试:检查线材类型字段
|
||||||
|
wire_type_value = info.get('xclx', 'NOT_FOUND')
|
||||||
|
logging.info(f"准备调用接口,线材类型字段值: {wire_type_value}")
|
||||||
|
logging.info(f"完整的info字典: {info}")
|
||||||
|
|
||||||
# 调用接口添加到包装记录
|
# 调用接口添加到包装记录
|
||||||
response = gc_api.add_order_info(info)
|
response = gc_api.add_order_info(info)
|
||||||
if response.get("status",False):
|
if response.get("status",False):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user