From 1dc55c277010c5259cba3a5402c6c7ff10d95469 Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Mon, 2 Sep 2024 09:04:42 +0800 Subject: [PATCH 01/13] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=B8=8D=E8=89=AF?= =?UTF-8?q?=E5=B7=A5=E5=8D=95=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_machine_connect/controllers/controllers.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/sf_machine_connect/controllers/controllers.py b/sf_machine_connect/controllers/controllers.py index 35f4a257..5168173e 100644 --- a/sf_machine_connect/controllers/controllers.py +++ b/sf_machine_connect/controllers/controllers.py @@ -312,9 +312,22 @@ class Sf_Dashboard_Connect(http.Controller): # 工单计划量 plan_data_plan_counts = plan_obj.search_count( [('production_line_id.name', '=', line), ('state', 'not in', ['finished'])]) - # 工单不良累计 - plan_data_fault_counts = plan_obj.search_count( - [('production_line_id.name', '=', line), ('production_id.state', 'in', ['scrap', 'cancel'])]) + # # 工单不良累计 + # plan_data_fault_counts = plan_obj.search_count( + # [('production_line_id.name', '=', line), ('production_id.detection_result_ids.state', 'in', ['返工', '报废'])]) + + # 查找符合条件的生产计划记录 + plan_data = plan_obj.search([ + ('production_line_id.name', '=', line), + ]) + + # 过滤出那些检测结果状态为 '返工' 或 '报废' 的记录 + faulty_plans = plan_data.filtered(lambda p: any( + result.test_results in ['返工', '报废'] for result in p.production_id.detection_result_ids + )) + + # 计算符合条件的记录数量 + plan_data_fault_counts = len(faulty_plans) # 工单返工数量 From eec79d7d3e6ccc70c5deaeee149f246c56f0e2f9 Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Thu, 5 Sep 2024 10:30:04 +0800 Subject: [PATCH 02/13] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E4=B8=BAurl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_machine_connect/controllers/controllers.py | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/sf_machine_connect/controllers/controllers.py b/sf_machine_connect/controllers/controllers.py index 5168173e..6e661f46 100644 --- a/sf_machine_connect/controllers/controllers.py +++ b/sf_machine_connect/controllers/controllers.py @@ -15,7 +15,7 @@ db_config = { "user": "postgres", "password": "postgres", "port": "5432", - "host": "172.16.10.98" + "host": "172.16.10.113" } @@ -162,7 +162,8 @@ class Sf_Dashboard_Connect(http.Controller): 'first_online_duration': first_online_duration, # 停机时间:关机时间 - 运行时间 # 停机时长:关机时间 - 初次上线时间 - 'img': f'data:image/png;base64,{machine_data.machine_tool_picture.decode("utf-8")}', + # 'img': f'data:image/png;base64,{machine_data.machine_tool_picture.decode("utf-8")}', + 'img': f'https://xt.sf.jikimo.com/equipment/get_image/{machine_data.id}', 'equipment_type': machine_data.category_id.name, }) @@ -843,3 +844,21 @@ class Sf_Dashboard_Connect(http.Controller): # 返回数据 res['data'] = oee_data return json.dumps(res) + + @http.route(['/equipment/get_image/'], type='http', auth="public", website=True) + def get_image(self, record_id, **kwargs): + # 获取模型中的记录 + record = request.env['maintenance.equipment'].sudo().browse(record_id) + + # 获取图片字段的数据 + image_data_base64 = record.machine_tool_picture + + if image_data_base64: + # 将Base64解码为二进制数据 + image_data_binary = base64.b64decode(image_data_base64) + + # 返回图片数据,并设置正确的Content-Type + return request.make_response(image_data_binary, headers=[('Content-Type', 'image/png')]) + else: + # 如果没有图片数据,返回404 + return request.not_found() From 0ae7424f043136bbaf9a6449d81933e70d24fb93 Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Tue, 10 Sep 2024 16:12:24 +0800 Subject: [PATCH 03/13] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E5=A2=9E=E5=8A=A0=E8=B0=83=E7=94=A8=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_machine_connect/models/res_config_setting.py | 4 ++++ .../views/res_config_settings_views.xml | 15 +++++++++++++++ sf_manufacturing/models/mrp_workorder.py | 14 ++++++++++++-- sf_manufacturing/views/mrp_workorder_view.xml | 5 +++++ 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/sf_machine_connect/models/res_config_setting.py b/sf_machine_connect/models/res_config_setting.py index c0bdf597..60862ccf 100644 --- a/sf_machine_connect/models/res_config_setting.py +++ b/sf_machine_connect/models/res_config_setting.py @@ -16,6 +16,7 @@ class ResBFMConfigSettings(models.TransientModel): # ("https://bfm.jikimo.com", "正式环境(https://bfm.jikimo.com)")], string='bfm环境', store=True) bfm_url_new = fields.Char('业务平台环境路径', placeholder='请输入当前对应的业务平台环境路径') + get_check_file_path = fields.Char('获取检查文件路径', default='') @api.model def get_values(self): @@ -26,9 +27,11 @@ class ResBFMConfigSettings(models.TransientModel): values = super(ResBFMConfigSettings, self).get_values() config = self.env['ir.config_parameter'].sudo() bfm_url_new = config.get_param('bfm_url_new', default='') + get_check_file_path = config.get_param('get_check_file_path', default='') values.update( bfm_url_new=bfm_url_new, + get_check_file_path=get_check_file_path ) return values @@ -36,3 +39,4 @@ class ResBFMConfigSettings(models.TransientModel): super(ResBFMConfigSettings, self).set_values() ir_config = self.env['ir.config_parameter'].sudo() ir_config.set_param("bfm_url_new", self.bfm_url_new or "") + ir_config.set_param("get_check_file_path", self.get_check_file_path or "") diff --git a/sf_machine_connect/views/res_config_settings_views.xml b/sf_machine_connect/views/res_config_settings_views.xml index 4ad5b0e7..fa3ba59c 100644 --- a/sf_machine_connect/views/res_config_settings_views.xml +++ b/sf_machine_connect/views/res_config_settings_views.xml @@ -18,6 +18,21 @@ + + + + +
+

获取检测报告服务配置

+
+
+
+
+
+
+
diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index a5e20ff7..2e77bcdd 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -414,12 +414,10 @@ class ResMrpWorkOrder(models.Model): # 获取三次元检测点数据 def get_three_check_datas(self): - factory_nick_name = 'XT' ftp_resconfig = self.env['res.config.settings'].get_values() ftp = FtpController(str(ftp_resconfig['ftp_host']), int(ftp_resconfig['ftp_port']), ftp_resconfig['ftp_user'], ftp_resconfig['ftp_password']) - # ftp.connect() local_dir_path = '/ftp/before' os.makedirs(local_dir_path, exist_ok=True) @@ -428,6 +426,17 @@ class ResMrpWorkOrder(models.Model): logging.info('local_file_path:%s' % local_file_path) remote_path = '/home/ftp/ftp_root/ThreeTest/XT/Before/' + local_filename logging.info('remote_path:%s' % remote_path) + # if not ftp.file_exists(remote_path): + paload_data = { + "filename": local_filename + } + if not ftp_resconfig['get_check_file_path']: + raise UserError('请先配置获取检测报告地址') + url = ftp_resconfig['get_check_file_path'] + '/get/check/report' + response = requests.post(url, json=paload_data) + logging.info('response:%s' % response.json()) + if response.json().get('detail'): + raise UserError(response.json().get('detail')) if not ftp.file_exists(remote_path): raise UserError(f"文件不存在: {remote_path}") @@ -540,6 +549,7 @@ class ResMrpWorkOrder(models.Model): raise UserError('PT10点未测或数据错误') self.data_state = True + self.getcenter() return True diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml index 7cada1be..bb451f51 100644 --- a/sf_manufacturing/views/mrp_workorder_view.xml +++ b/sf_manufacturing/views/mrp_workorder_view.xml @@ -513,6 +513,11 @@ + +