feat: 新增数量和机台
This commit is contained in:
parent
b05dc327af
commit
ef77566b1d
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=[2222])
|
client.write_registers(address=11, values=[2922])
|
||||||
# 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])
|
||||||
@ -15,6 +15,7 @@ client.write_registers(address=11, values=[2222])
|
|||||||
client.write_registers(address=13, values=[1])
|
client.write_registers(address=13, values=[1])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
result = client.read_holding_registers(address=13, count=1)
|
result = client.read_holding_registers(address=13, count=1)
|
||||||
print(result.registers[0],"123===")
|
print(result.registers[0],"123===")
|
||||||
client.close()
|
client.close()
|
||||||
@ -10,7 +10,9 @@ class MainWindowUI(QMainWindow):
|
|||||||
# 定义字段映射为类属性,方便外部引用
|
# 定义字段映射为类属性,方便外部引用
|
||||||
FIELD_MAPPING = {
|
FIELD_MAPPING = {
|
||||||
"库房": "lib",
|
"库房": "lib",
|
||||||
|
"机台": "jt",
|
||||||
"客户": "customerexp",
|
"客户": "customerexp",
|
||||||
|
"订单数量": "maxsl",
|
||||||
"规格": "size",
|
"规格": "size",
|
||||||
"材质": "cz",
|
"材质": "cz",
|
||||||
"种类": "type_name",
|
"种类": "type_name",
|
||||||
@ -289,9 +291,9 @@ class MainWindowUI(QMainWindow):
|
|||||||
|
|
||||||
# 创建信息表格 - 使用QTableWidget实现
|
# 创建信息表格 - 使用QTableWidget实现
|
||||||
self.info_table = QTableWidget()
|
self.info_table = QTableWidget()
|
||||||
# 计算需要的行数:19个字段,每行2个字段,最后两行是备注(跨列)
|
# 计算需要的行数:21个字段,每行2个字段,最后两行是备注(跨列)
|
||||||
# 前18个字段需要9行,备注占用2行,总共11行
|
# 前20个字段需要10行,备注占用2行,总共12行
|
||||||
self.info_table.setRowCount(11) # 9行常规字段 + 2行备注
|
self.info_table.setRowCount(12) # 10行常规字段 + 2行备注
|
||||||
self.info_table.setColumnCount(4) # 4列:标签1, 值1, 标签2, 值2
|
self.info_table.setColumnCount(4) # 4列:标签1, 值1, 标签2, 值2
|
||||||
self.info_table.setShowGrid(True) # 显示网格线
|
self.info_table.setShowGrid(True) # 显示网格线
|
||||||
self.info_table.horizontalHeader().setVisible(False) # 隐藏水平表头
|
self.info_table.horizontalHeader().setVisible(False) # 隐藏水平表头
|
||||||
@ -372,6 +374,24 @@ class MainWindowUI(QMainWindow):
|
|||||||
value.addItem("不合格库(线材)")
|
value.addItem("不合格库(线材)")
|
||||||
value.addItem("废丝库")
|
value.addItem("废丝库")
|
||||||
value.setCurrentIndex(0) # 默认选择第一个
|
value.setCurrentIndex(0) # 默认选择第一个
|
||||||
|
elif field_name == "机台":
|
||||||
|
# 机台字段使用QLineEdit,与其他字段保持一致
|
||||||
|
value = QLineEdit("")
|
||||||
|
value.setFont(self.normal_font)
|
||||||
|
value.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
|
||||||
|
value.setStyleSheet("background-color: white; padding: 5px; border: 1px solid #cccccc;")
|
||||||
|
value.setFrame(False)
|
||||||
|
value.setContentsMargins(0, 0, 0, 0)
|
||||||
|
value.setFixedHeight(35)
|
||||||
|
elif field_name == "订单数量":
|
||||||
|
# 订单数量字段使用QLineEdit,与其他字段保持一致
|
||||||
|
value = QLineEdit("")
|
||||||
|
value.setFont(self.normal_font)
|
||||||
|
value.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
|
||||||
|
value.setStyleSheet("background-color: white; padding: 5px; border: 1px solid #cccccc;")
|
||||||
|
value.setFrame(False)
|
||||||
|
value.setContentsMargins(0, 0, 0, 0)
|
||||||
|
value.setFixedHeight(35)
|
||||||
elif field_name == "线材类型":
|
elif field_name == "线材类型":
|
||||||
# 线材类型字段使用QComboBox,与库房组件配置相同
|
# 线材类型字段使用QComboBox,与库房组件配置相同
|
||||||
value = QComboBox()
|
value = QComboBox()
|
||||||
@ -461,7 +481,7 @@ class MainWindowUI(QMainWindow):
|
|||||||
|
|
||||||
# 设置行高
|
# 设置行高
|
||||||
for i in range(self.info_table.rowCount()):
|
for i in range(self.info_table.rowCount()):
|
||||||
if i == 9: # 备注行(第10行,索引为9)
|
if i == 10: # 备注行(第11行,索引为10)
|
||||||
self.info_table.setRowHeight(i, 35) # 备注行第一行高度
|
self.info_table.setRowHeight(i, 35) # 备注行第一行高度
|
||||||
self.info_table.setRowHeight(i + 1, 35) # 备注行第二行高度
|
self.info_table.setRowHeight(i + 1, 35) # 备注行第二行高度
|
||||||
break
|
break
|
||||||
|
|||||||
@ -2197,6 +2197,41 @@ class MainWindow(MainWindowUI):
|
|||||||
info['lib'] = warehouse_combo.currentText()
|
info['lib'] = warehouse_combo.currentText()
|
||||||
else:
|
else:
|
||||||
info['lib'] = "成品库" # 默认值
|
info['lib'] = "成品库" # 默认值
|
||||||
|
|
||||||
|
# 添加炉号信息
|
||||||
|
luno_container = self.info_values.get("炉号")
|
||||||
|
if luno_container:
|
||||||
|
# 炉号字段是容器,需要找到其中的QLineEdit
|
||||||
|
for child in luno_container.children():
|
||||||
|
if hasattr(child, 'text') and hasattr(child, 'setText'):
|
||||||
|
luno_value = child.text().strip()
|
||||||
|
if luno_value:
|
||||||
|
info['luno'] = luno_value
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
info['luno'] = "" # 默认值
|
||||||
|
|
||||||
|
# 添加线材类型信息
|
||||||
|
wire_type_combo = self.info_values.get("线材类型")
|
||||||
|
if wire_type_combo:
|
||||||
|
wire_type_value = wire_type_combo.currentText().strip()
|
||||||
|
if wire_type_value and wire_type_value != "请选择":
|
||||||
|
info['xclx'] = wire_type_value
|
||||||
|
else:
|
||||||
|
info['xclx'] = "" # 默认值
|
||||||
|
else:
|
||||||
|
info['xclx'] = "" # 默认值
|
||||||
|
|
||||||
|
# 添加机台信息
|
||||||
|
machine_edit = self.info_values.get("机台")
|
||||||
|
if machine_edit:
|
||||||
|
machine_value = machine_edit.text().strip()
|
||||||
|
if machine_value:
|
||||||
|
info['jt'] = machine_value
|
||||||
|
else:
|
||||||
|
info['jt'] = "" # 默认值
|
||||||
|
else:
|
||||||
|
info['jt'] = "" # 默认值
|
||||||
# 获取本机IP地址
|
# 获取本机IP地址
|
||||||
# import socket
|
# import socket
|
||||||
# try:
|
# try:
|
||||||
@ -3780,8 +3815,12 @@ class MainWindow(MainWindowUI):
|
|||||||
if hasattr(child, 'text') and hasattr(child, 'setText'):
|
if hasattr(child, 'text') and hasattr(child, 'setText'):
|
||||||
current_value = child.text()
|
current_value = child.text()
|
||||||
break
|
break
|
||||||
else:
|
elif hasattr(self.info_values[field_name], 'text'):
|
||||||
|
# 其他有text方法的控件
|
||||||
current_value = self.info_values[field_name].text()
|
current_value = self.info_values[field_name].text()
|
||||||
|
else:
|
||||||
|
# 对于没有text方法的控件,使用空字符串
|
||||||
|
current_value = ""
|
||||||
except RuntimeError as e:
|
except RuntimeError as e:
|
||||||
# 如果对象已被删除,记录错误并跳过
|
# 如果对象已被删除,记录错误并跳过
|
||||||
logging.warning(f"控件对象已被删除,字段: {field_name}, 错误: {str(e)}")
|
logging.warning(f"控件对象已被删除,字段: {field_name}, 错误: {str(e)}")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user