From c9ee0af25a55d92f86032dcfafdd0fe701836c40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Wed, 23 Apr 2025 08:52:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jikimo_work_reporting_api/controllers/main.py | 9 ++++++++- sf_machine_connect/models/ftp_operate.py | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/jikimo_work_reporting_api/controllers/main.py b/jikimo_work_reporting_api/controllers/main.py index 110a0973..ddcda00d 100644 --- a/jikimo_work_reporting_api/controllers/main.py +++ b/jikimo_work_reporting_api/controllers/main.py @@ -17,19 +17,26 @@ class MainController(http.Controller): return {'code': 400, 'message': '参数错误'} maintenance_equipment = request.env['maintenance.equipment'].sudo().search([('name', '=', maintenance_equipment_name)], limit=1) if not maintenance_equipment: - return {'code': 400, 'message': '机床不存在'} + return {'code': 400, 'message': '机台不存在,请扫描正确的机台二维码'} + product = request.env['product.template'].sudo().search([('model_id', '=', model_id)], limit=1) + if not product: + return {'code': 400, 'message': '请扫描正确的图纸'} # 获取刀具组 tool_groups_id = request.env['sf.tool.groups'].sudo().search([('equipment_ids', 'in', maintenance_equipment.id)], limit=1) if not tool_groups_id: return {'code': 400, 'message': '刀具组不存在'} ftp_resconfig = request.env['res.config.settings'].sudo().get_values() + if not ftp_resconfig['ftp_host'] or not ftp_resconfig['ftp_port'] or not ftp_resconfig['ftp_user'] or not ftp_resconfig['ftp_password']: + return {'code': 400, 'message': '编程文件FTP配置错误'} source_ftp_info = { 'host': ftp_resconfig['ftp_host'], 'port': int(ftp_resconfig['ftp_port']), 'username': ftp_resconfig['ftp_user'], 'password': ftp_resconfig['ftp_password'] } + if not maintenance_equipment.ftp_host or not maintenance_equipment.ftp_port or not maintenance_equipment.ftp_username or not maintenance_equipment.ftp_password: + return {'code': 400, 'message': '机台FTP配置错误'} target_ftp_info = { 'host': maintenance_equipment.ftp_host, 'port': int(maintenance_equipment.ftp_port), diff --git a/sf_machine_connect/models/ftp_operate.py b/sf_machine_connect/models/ftp_operate.py index 1bb02fa4..8bd5cf52 100644 --- a/sf_machine_connect/models/ftp_operate.py +++ b/sf_machine_connect/models/ftp_operate.py @@ -160,6 +160,8 @@ def transfer_nc_files( source_ftp_info['username'], source_ftp_info['password'] ) + if not source_ftp.ftp: + raise Exception("编程文件FTP连接失败") source_ftp.ftp.set_pasv(1) # 连接目标FTP @@ -169,6 +171,8 @@ def transfer_nc_files( target_ftp_info['username'], target_ftp_info['password'] ) + if not source_ftp.ftp: + raise Exception("机床FTP连接失败") source_ftp.ftp.set_pasv(1) # 递归遍历源目录