feat: 修改Modbus写入值,更新SQL查询以处理空值,添加安全字符串转换函数

This commit is contained in:
zhu-mengmeng 2025-07-20 23:01:27 +08:00
parent 3246e8981f
commit bc2ca6919e
4 changed files with 6 additions and 3 deletions

View File

@ -827,7 +827,7 @@ class InspectionDAO:
try: try:
sql = """ sql = """
SELECT DISTINCT data_corp, user_id, user_name, gzl_zl, mzl, ddmo, xpack, qd, spack_type, mxzs, jt, ddnote, code, type, lable, lib, gzl, maxsl, cz, size, cd, luno, SELECT DISTINCT data_corp, user_id, user_name, gzl_zl, mzl, ddmo, xpack, qd, spack_type, mxzs, jt, ddnote, code, type, lable, lib, gzl, maxsl, cz, size, cd, luno,
qfqd, pono, xj, ysl, dycz, zx_code, edit_id, remarks, zx_name, bccd, tccd, zzyq, customer, customerexp, bz_bqd as bqd, bz_tqd as tqd, type_name, remarks_hb coalesce(qfqd,'') as qfqd, pono, xj, ysl, dycz, zx_code, edit_id, remarks, zx_name, bccd, tccd, zzyq, customer, customerexp, bz_bqd as bqd, bz_tqd as tqd, type_name, remarks_hb
FROM wsbz_order_info WHERE ddmo = ? FROM wsbz_order_info WHERE ddmo = ?
""" """
params = (order_id,) params = (order_id,)

Binary file not shown.

View File

@ -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=[14322]) client.write_registers(address=11, values=[5962])
# 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])

View File

@ -4739,3 +4739,6 @@ class MainWindow(MainWindowUI):
logging.error(f"处理炉号选择失败: {str(e)}") logging.error(f"处理炉号选择失败: {str(e)}")
from PySide6.QtWidgets import QMessageBox from PySide6.QtWidgets import QMessageBox
QMessageBox.critical(self, "错误", f"处理炉号选择失败: {str(e)}") QMessageBox.critical(self, "错误", f"处理炉号选择失败: {str(e)}")
def safe_str(val):
return "" if val is None else str(val)