feat: 新增检查包装记录是否存在的功能,优化主窗口操作逻辑及字段名称
This commit is contained in:
parent
5d2f0099ac
commit
69c8626888
@ -120,7 +120,7 @@
|
||||
}
|
||||
},
|
||||
"electricity": {
|
||||
"auto_start": true,
|
||||
"auto_start": false,
|
||||
"interval_minutes": 30
|
||||
}
|
||||
}
|
||||
@ -642,6 +642,34 @@ class InspectionDAO:
|
||||
logging.error(f"获取产品状态失败: {str(e)}")
|
||||
return 'init' # 出错时返回默认状态
|
||||
|
||||
def check_package_record_exists(self, order_id, gc_note, tray_id):
|
||||
"""检查指定工程号和托盘号的包装记录是否已存在
|
||||
|
||||
Args:
|
||||
order_id: 订单号
|
||||
gc_note: 工程号
|
||||
tray_id: 托盘号
|
||||
|
||||
Returns:
|
||||
bool: 记录是否存在
|
||||
"""
|
||||
try:
|
||||
sql = """
|
||||
SELECT COUNT(*) FROM wsbz_inspection_pack_data
|
||||
WHERE order_id = ? AND gc_note = ? AND tray_id = ? AND is_deleted = FALSE
|
||||
"""
|
||||
params = (order_id, gc_note, tray_id)
|
||||
|
||||
with SQLUtils('sqlite', database='db/jtDB.db') as db:
|
||||
db.cursor.execute(sql, params)
|
||||
result = db.cursor.fetchone()
|
||||
|
||||
return result[0] > 0 if result else False
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"检查包装记录是否存在失败: {str(e)}")
|
||||
return False
|
||||
|
||||
def update_product_status(self, order_id, gc_note, tray_id, new_status):
|
||||
"""更新产品的状态
|
||||
|
||||
|
||||
BIN
db/jtDB.db
BIN
db/jtDB.db
Binary file not shown.
@ -12,7 +12,7 @@ class MainWindowUI(QMainWindow):
|
||||
"库房": "lib",
|
||||
"机台": "jt",
|
||||
"客户": "customerexp",
|
||||
"订单数量": "maxsl",
|
||||
"订单数量": "sl",
|
||||
"规格": "size",
|
||||
"材质": "cz",
|
||||
"种类": "type_name",
|
||||
|
||||
@ -839,31 +839,12 @@ class MainWindow(MainWindowUI):
|
||||
client = modbus.get_client()
|
||||
try:
|
||||
# 判断当前操作类型(通过检查当前下料信息是否存在)
|
||||
if self._current_unload_info and self._current_unload_num > 0:
|
||||
# 下料模式 - 停止下料操作
|
||||
success3 = modbus.write_register_until_success(client, 3, 0)
|
||||
|
||||
if success3:
|
||||
logging.info(f"停止下料操作:当前层数 {self._current_unload_num}/{self._total_unload_num}")
|
||||
QMessageBox.information(self, "操作提示", "已停止下料操作")
|
||||
# 恢复开始按钮和下料按钮原始样式
|
||||
self.restore_start_button_style()
|
||||
self.restore_output_button_style()
|
||||
else:
|
||||
QMessageBox.warning(self, "错误", "停止下料操作失败")
|
||||
success3 = modbus.write_register_until_success(client, 3, 0)
|
||||
success2 = modbus.write_register_until_success(client, 2, 0)
|
||||
if success3 and success2:
|
||||
logging.info("停止操作成功")
|
||||
else:
|
||||
# 上料模式 - 停止上料操作
|
||||
success2 = modbus.write_register_until_success(client, 2, 0)
|
||||
|
||||
if success2:
|
||||
self._is_loading_active = False # 标记上料任务已停止
|
||||
logging.info("停止上料操作")
|
||||
QMessageBox.information(self, "操作提示", "已停止上料操作")
|
||||
# 恢复开始按钮和上料按钮原始样式
|
||||
self.restore_start_button_style()
|
||||
self.restore_input_button_style()
|
||||
else:
|
||||
QMessageBox.warning(self, "错误", "停止上料操作失败")
|
||||
logging.error("停止操作失败")
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"停止操作失败: {str(e)}")
|
||||
@ -1680,6 +1661,11 @@ class MainWindow(MainWindowUI):
|
||||
from dao.inspection_dao import InspectionDAO
|
||||
inspection_dao = InspectionDAO()
|
||||
|
||||
# 首先检查该工程号的包装记录是否已存在
|
||||
if inspection_dao.check_package_record_exists(order_id, gc_note, tray_id):
|
||||
logging.warning(f"工程号 {gc_note} 托盘号 {tray_id} 的包装记录已存在,跳过添加")
|
||||
return
|
||||
|
||||
# 获取该工程号的所有检验数据
|
||||
inspection_data = inspection_dao.get_inspection_data_by_order(order_id, gc_note, tray_id)
|
||||
|
||||
@ -1709,7 +1695,6 @@ class MainWindow(MainWindowUI):
|
||||
logging.warning(f"工程号 {order_id} 托盘号 {tray_id} 的贴标字段为空,不添加到包装记录")
|
||||
return
|
||||
|
||||
|
||||
# 获取当前时间作为完成时间
|
||||
finish_time = datetime.now()
|
||||
|
||||
@ -2787,11 +2772,13 @@ class MainWindow(MainWindowUI):
|
||||
logging.info(f"工程号 {gc_note} 的贴标已完成,状态更新为labeled")
|
||||
|
||||
# 获取当前行的轴号,用于保存到包装记录
|
||||
current_axios_num = self.get_current_row_axios_num(data_row)
|
||||
# 使用写入单元格的轴号,而不是重新计算轴号
|
||||
axios_num_to_use = axios_num
|
||||
logging.info(f"使用写入单元格的轴号: {axios_num_to_use}")
|
||||
|
||||
# 调用加载到包装记录的方法,传入正确的轴号
|
||||
self.load_finished_record_to_package_record(self._current_order_code, gc_note, tray_id, current_axios_num)
|
||||
logging.info(f"贴标完成,已将工程号 {gc_note} 的记录加载到包装记录,轴号: {current_axios_num}")
|
||||
self.load_finished_record_to_package_record(self._current_order_code, gc_note, tray_id, axios_num_to_use)
|
||||
logging.info(f"贴标完成,已将工程号 {gc_note} 的记录加载到包装记录,轴号: {axios_num_to_use}")
|
||||
|
||||
# 删除当前处理的行
|
||||
self.process_table.removeRow(data_row)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user