From cf8c14e7380eaec81b7800c58242ec8e5ffaa46b Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Wed, 9 Apr 2025 15:22:41 +0800 Subject: [PATCH 01/22] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- quality_control/views/quality_views.xml | 2 +- sf_machine_connect/controllers/controllers.py | 25 +++++++++++++------ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/quality_control/views/quality_views.xml b/quality_control/views/quality_views.xml index 38de9e4e..528003e3 100644 --- a/quality_control/views/quality_views.xml +++ b/quality_control/views/quality_views.xml @@ -267,7 +267,7 @@ - + diff --git a/sf_machine_connect/controllers/controllers.py b/sf_machine_connect/controllers/controllers.py index 4385937c..0017e2ae 100644 --- a/sf_machine_connect/controllers/controllers.py +++ b/sf_machine_connect/controllers/controllers.py @@ -567,7 +567,7 @@ class Sf_Dashboard_Connect(http.Controller): """ res = {'status': 1, 'message': '成功', 'data': {}} # plan_obj = request.env['sf.production.plan'].sudo() - plan_obj = request.env['mrp.workorder'].sudo().search([('routing_type', '=', 'CNC加工')]) + # plan_obj = request.env['mrp.workorder'].sudo().search([('routing_type', '=', 'CNC加工')]) line_list = ast.literal_eval(kw['line_list']) begin_time_str = kw['begin_time'].strip('"') end_time_str = kw['end_time'].strip('"') @@ -617,11 +617,19 @@ class Sf_Dashboard_Connect(http.Controller): for time_interval in time_intervals: start_time, end_time = time_interval - orders = plan_obj.search([ - ('production_id.production_line_id.name', '=', line), + # orders = plan_obj.search([ + # ('production_line_id.name', '=', line), + # ('state', 'in', ['done']), + # (date_field_name, '>=', start_time.strftime('%Y-%m-%d %H:%M:%S')), + # (date_field_name, '<=', end_time.strftime('%Y-%m-%d %H:%M:%S')) # 包括结束时间 + # ]) + + orders = request.env['mrp.workorder'].sudo().search([ + ('routing_type', '=', 'CNC加工'), # 将第一个条件合并进来 + ('production_line_id.name', '=', line), ('state', 'in', ['done']), (date_field_name, '>=', start_time.strftime('%Y-%m-%d %H:%M:%S')), - (date_field_name, '<=', end_time.strftime('%Y-%m-%d %H:%M:%S')) # 包括结束时间 + (date_field_name, '<=', end_time.strftime('%Y-%m-%d %H:%M:%S')) ]) # 使用小时和分钟作为键,确保每个小时的数据有独立的键 @@ -638,18 +646,21 @@ class Sf_Dashboard_Connect(http.Controller): for date in date_list: next_day = date + timedelta(days=1) - orders = plan_obj.search([('production_id.production_line_id.name', '=', line), ('state', 'in', ['done']), + orders = request.env['mrp.workorder'].sudo().search([('production_id.production_line_id.name', '=', line), ('state', 'in', ['done']), + ('routing_type', '=', 'CNC加工'), (date_field_name, '>=', date.strftime('%Y-%m-%d 00:00:00')), (date_field_name, '<', next_day.strftime('%Y-%m-%d 00:00:00')) ]) - rework_orders = plan_obj.search( + rework_orders = request.env['mrp.workorder'].sudo().search( [('production_id.production_line_id.name', '=', line), ('state', 'in', ['rework']), + ('routing_type', '=', 'CNC加工'), (date_field_name, '>=', date.strftime('%Y-%m-%d 00:00:00')), (date_field_name, '<', next_day.strftime('%Y-%m-%d 00:00:00')) ]) - not_passed_orders = plan_obj.search( + not_passed_orders = request.env['mrp.workorder'].sudo().search( [('production_id.production_line_id.name', '=', line), ('state', 'in', ['scrap', 'cancel']), + ('routing_type', '=', 'CNC加工'), (date_field_name, '>=', date.strftime('%Y-%m-%d 00:00:00')), (date_field_name, '<', next_day.strftime('%Y-%m-%d 00:00:00')) ]) From ddb0c304b9957630f3aa486ae85dc71bc864fffd Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Wed, 9 Apr 2025 15:57:13 +0800 Subject: [PATCH 02/22] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_machine_connect/controllers/controllers.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sf_machine_connect/controllers/controllers.py b/sf_machine_connect/controllers/controllers.py index 0017e2ae..9fb69303 100644 --- a/sf_machine_connect/controllers/controllers.py +++ b/sf_machine_connect/controllers/controllers.py @@ -414,7 +414,7 @@ class Sf_Dashboard_Connect(http.Controller): # 工单计划量切换为CNC工单 plan_data_total_counts = work_order_obj.search_count( - [('production_id.production_line_id.name', '=', line), + [('production_line_id.name', '=', line), ('id', '!=', 8061), ('state', 'in', ['ready', 'progress', 'done']), ('routing_type', '=', 'CNC加工')]) # # 工单完成量 @@ -423,13 +423,13 @@ class Sf_Dashboard_Connect(http.Controller): # 工单完成量切换为CNC工单 plan_data_finish_counts = work_order_obj.search_count( - [('production_id.production_line_id.name', '=', line), + [('production_line_id.name', '=', line), ('state', 'in', ['done']), ('routing_type', '=', 'CNC加工')]) # 超期完成量 # 搜索所有已经完成的工单 plan_data_overtime = work_order_obj.search([ - ('production_id.production_line_id.name', '=', line), + ('production_line_id.name', '=', line), ('state', 'in', ['done']), ('routing_type', '=', 'CNC加工') ]) From 6c926bf08103a85af45fafab6d7203a4040ac7e6 Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Wed, 9 Apr 2025 16:39:21 +0800 Subject: [PATCH 03/22] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=B4=A8=E6=A3=80?= =?UTF-8?q?=E5=8F=96=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_machine_connect/controllers/controllers.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sf_machine_connect/controllers/controllers.py b/sf_machine_connect/controllers/controllers.py index 9fb69303..ad958485 100644 --- a/sf_machine_connect/controllers/controllers.py +++ b/sf_machine_connect/controllers/controllers.py @@ -448,9 +448,14 @@ class Sf_Dashboard_Connect(http.Controller): ]) # 过滤出那些检测结果状态为 '返工' 或 '报废' 的记录 - faulty_plans = plan_data.filtered(lambda p: any( - result.test_results in ['返工', '报废'] for result in p.production_id.detection_result_ids - )) + # faulty_plans = plan_data.filtered(lambda p: any( + # result.test_results in ['返工', '报废'] for result in p.production_id.detection_result_ids + # )) + + faulty_plans = request.env['quality.check'].sudo().search([ + ('operation_id.name', '=', 'CNC加工'), + ('quality_state', 'in', ['fail']) + ]) # 查找制造订单取消与归档的数量 cancel_order_count = production_obj.search_count( From bdf4696c089fa49db3f30a9538bfb67e363defa7 Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Wed, 9 Apr 2025 16:56:53 +0800 Subject: [PATCH 04/22] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=BE=85=E5=AE=8C?= =?UTF-8?q?=E6=88=90=E5=B7=A5=E5=8D=95=E6=98=8E=E7=BB=86?= 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, 12 insertions(+), 7 deletions(-) diff --git a/sf_machine_connect/controllers/controllers.py b/sf_machine_connect/controllers/controllers.py index ad958485..dcfa3ea2 100644 --- a/sf_machine_connect/controllers/controllers.py +++ b/sf_machine_connect/controllers/controllers.py @@ -767,11 +767,14 @@ class Sf_Dashboard_Connect(http.Controller): for line in line_list: # 未完成订单 - not_done_orders = plan_obj.search( - [('production_line_id.name', '=', line), ('state', 'not in', ['finished']), - ('production_id.state', 'not in', ['cancel', 'done']), ('active', '=', True) + # not_done_orders = plan_obj.search( + # [('production_line_id.name', '=', line), ('state', 'not in', ['finished']), + # ('production_id.state', 'not in', ['cancel', 'done']), ('active', '=', True) + # ]) + not_done_orders = request.env['mrp.workorder'].sudo().search( + [('production_line_id.name', '=', line), ('state', 'in', ['ready', 'progress']), + ('routing_type', '=', 'CNC加工') ]) - # print(not_done_orders) # 完成订单 # 获取当前时间,并计算24小时前的时间 @@ -823,16 +826,18 @@ class Sf_Dashboard_Connect(http.Controller): 'draft': '待排程', 'done': '已排程', 'processing': '生产中', - 'finished': '已完成' + 'finished': '已完成', + 'ready': '待加工', + 'progress': '生产中', } line_dict = { 'sequence': id_to_sequence[order.id], - 'workorder_name': order.name, + 'workorder_name': order.production_id.name, 'blank_name': blank_name, 'material': material, 'dimensions': dimensions, - 'order_qty': order.product_qty, + 'order_qty': 1, 'state': state_dict[order.state], } From 87786dbd8000cd3e14edb7e1f7f145aad3707a25 Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Fri, 11 Apr 2025 14:16:18 +0800 Subject: [PATCH 05/22] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=95=85=E9=9A=9C?= =?UTF-8?q?=E6=97=B6=E9=95=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_machine_connect/controllers/controllers.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sf_machine_connect/controllers/controllers.py b/sf_machine_connect/controllers/controllers.py index dcfa3ea2..19d0f17e 100644 --- a/sf_machine_connect/controllers/controllers.py +++ b/sf_machine_connect/controllers/controllers.py @@ -926,7 +926,10 @@ class Sf_Dashboard_Connect(http.Controller): for row in result2: alarm_count.append(row[1]) if row[0]: - total_alarm_time += abs(float(row[0])) + if float(row[0]) >= 28800: + continue + # total_alarm_time += abs(float(row[0])) + total_alarm_time += float(row[0]) else: total_alarm_time += 0.0 if len(list(set(alarm_count))) == 1: @@ -1353,7 +1356,7 @@ class Sf_Dashboard_Connect(http.Controller): for result in results: alarm_last_24_nums.append(result[1]) if result[0]: - if float(result[0]) >= 1000: + if float(result[0]) >= 28800: continue alarm_last_24_time += float(result[0]) else: @@ -1371,7 +1374,7 @@ class Sf_Dashboard_Connect(http.Controller): for result in results: alarm_all_nums.append(result[1]) if result[0]: - if float(result[0]) >= 1000: + if float(result[0]) >= 28800: continue alarm_all_time += float(result[0]) else: From 026697f363bbd5892b4eb830f3627bba1bf3a052 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Fri, 11 Apr 2025 16:12:58 +0800 Subject: [PATCH 06/22] =?UTF-8?q?=E4=BF=AE=E6=94=B9sf=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E4=B8=8D=E5=9C=A8=E9=83=A8=E7=BD=B2=E6=97=B6?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/jikimo_workorder_exception.py | 4 ++-- sf_mrs_connect/data/ir_cron_data.xml | 23 ++++++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/jikimo_workorder_exception_notify/models/jikimo_workorder_exception.py b/jikimo_workorder_exception_notify/models/jikimo_workorder_exception.py index 0ab0d6ae..f4a49c1f 100644 --- a/jikimo_workorder_exception_notify/models/jikimo_workorder_exception.py +++ b/jikimo_workorder_exception_notify/models/jikimo_workorder_exception.py @@ -52,10 +52,10 @@ class JikimoWorkorderException(models.Model): def _get_message(self, message_queue_ids): contents, _ = super(JikimoWorkorderException, self)._get_message(message_queue_ids) - url = self.env['ir.config_parameter'].get_param('web.base.url') + base_url = self.env['ir.config_parameter'].get_param('web.base.url') action_id = self.env.ref('mrp.mrp_production_action').id for index, content in enumerate(contents): exception_id = self.env['jikimo.workorder.exception'].browse(message_queue_ids[index].res_id) - url = url + '/web#id=%s&view_type=form&action=%s' % (exception_id.workorder_id.production_id.id, action_id) + url = base_url + '/web#id=%s&view_type=form&action=%s' % (exception_id.workorder_id.production_id.id, action_id) contents[index] = content.replace('{{url}}', url) return contents, message_queue_ids diff --git a/sf_mrs_connect/data/ir_cron_data.xml b/sf_mrs_connect/data/ir_cron_data.xml index 7cc18c8e..a2d43891 100644 --- a/sf_mrs_connect/data/ir_cron_data.xml +++ b/sf_mrs_connect/data/ir_cron_data.xml @@ -1,16 +1,16 @@ - - - 制造-配置:每日定时同步cloud的静态资源库 - - code - model.sf_all_sync() - 1 - days - -1 - - + + + 制造-配置:每日定时同步cloud的静态资源库 + + code + model.sf_all_sync() + 1 + days + -1 + + @@ -220,4 +220,5 @@ + \ No newline at end of file From a8961086389c4b433bac551d9896cf6d4811bca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Fri, 11 Apr 2025 16:49:18 +0800 Subject: [PATCH 07/22] =?UTF-8?q?=E4=BA=A7=E5=93=81=E4=B8=BB=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E3=80=90=E6=9D=A1=E7=A0=81=E3=80=91=E5=AD=98=E5=82=A8?= =?UTF-8?q?=E6=A8=A1=E5=9E=8BID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/__manifest__.py | 1 + sf_manufacturing/views/product_template_views.xml | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 sf_manufacturing/views/product_template_views.xml diff --git a/sf_manufacturing/__manifest__.py b/sf_manufacturing/__manifest__.py index ba0c6751..a19f5542 100644 --- a/sf_manufacturing/__manifest__.py +++ b/sf_manufacturing/__manifest__.py @@ -44,6 +44,7 @@ 'views/sale_order_views.xml', 'views/mrp_workorder_batch_replan.xml', 'views/purchase_order_view.xml', + 'views/product_template_views.xml', ], 'assets': { diff --git a/sf_manufacturing/views/product_template_views.xml b/sf_manufacturing/views/product_template_views.xml new file mode 100644 index 00000000..a99a332a --- /dev/null +++ b/sf_manufacturing/views/product_template_views.xml @@ -0,0 +1,15 @@ + + + + + product.template.product.form.inherit.sf_manufacture + product.template + + + + + + + + + \ No newline at end of file From 91d79008e107ea88b68821951be1a76a12c8400b Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Mon, 14 Apr 2025 11:21:24 +0800 Subject: [PATCH 08/22] =?UTF-8?q?=E6=95=85=E9=9A=9C=E6=97=B6=E9=95=BF?= =?UTF-8?q?=E6=8F=90=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_machine_connect/controllers/controllers.py | 58 ++++++++++++++++--- .../data/insepection_report_template.xml | 4 ++ 2 files changed, 54 insertions(+), 8 deletions(-) diff --git a/sf_machine_connect/controllers/controllers.py b/sf_machine_connect/controllers/controllers.py index 19d0f17e..d5c8c7cb 100644 --- a/sf_machine_connect/controllers/controllers.py +++ b/sf_machine_connect/controllers/controllers.py @@ -18,6 +18,11 @@ db_config = { "host": "172.16.10.131" } +# 基础数据 +TotalAlarmTime = 0 +TodayAlarmTime = 0 +MonthAlarmTime = 0 + def convert_to_seconds(time_str): # 修改正则表达式,使 H、M、S 部分可选 @@ -455,7 +460,7 @@ class Sf_Dashboard_Connect(http.Controller): faulty_plans = request.env['quality.check'].sudo().search([ ('operation_id.name', '=', 'CNC加工'), ('quality_state', 'in', ['fail']) - ]) + ]) # 查找制造订单取消与归档的数量 cancel_order_count = production_obj.search_count( @@ -651,11 +656,12 @@ class Sf_Dashboard_Connect(http.Controller): for date in date_list: next_day = date + timedelta(days=1) - orders = request.env['mrp.workorder'].sudo().search([('production_id.production_line_id.name', '=', line), ('state', 'in', ['done']), - ('routing_type', '=', 'CNC加工'), - (date_field_name, '>=', date.strftime('%Y-%m-%d 00:00:00')), - (date_field_name, '<', next_day.strftime('%Y-%m-%d 00:00:00')) - ]) + orders = request.env['mrp.workorder'].sudo().search( + [('production_id.production_line_id.name', '=', line), ('state', 'in', ['done']), + ('routing_type', '=', 'CNC加工'), + (date_field_name, '>=', date.strftime('%Y-%m-%d 00:00:00')), + (date_field_name, '<', next_day.strftime('%Y-%m-%d 00:00:00')) + ]) rework_orders = request.env['mrp.workorder'].sudo().search( [('production_id.production_line_id.name', '=', line), ('state', 'in', ['rework']), @@ -892,6 +898,8 @@ class Sf_Dashboard_Connect(http.Controller): # 获取请求的机床数据 machine_list = ast.literal_eval(kw['machine_list']) total_alarm_time = 0 + today_alarm_time = 0 + month_alarm_time = 0 alarm_count_num = 0 for item in machine_list: sql = ''' @@ -904,6 +912,11 @@ class Sf_Dashboard_Connect(http.Controller): ) subquery; ''' + # 计算时间范围 + now = datetime.now() + today_start = now.replace(hour=0, minute=0, second=0, microsecond=0) + month_start = now.replace(day=1, hour=0, minute=0, second=0, microsecond=0) + sql2 = ''' SELECT DISTINCT ON (alarm_start_time) alarm_time, alarm_start_time FROM device_data @@ -918,8 +931,16 @@ class Sf_Dashboard_Connect(http.Controller): cur.execute(sql2, (item,)) result2 = cur.fetchall() - # print('result2========', result2) - # + today_data = [] + month_data = [] + + for record in result2: + alarm_start = datetime.strptime(record[1], "%Y-%m-%d %H:%M:%S") + if alarm_start >= today_start: + today_data.append(record) + if alarm_start >= month_start: + month_data.append(record) + for row in result: res['data'][item] = {'idle_count': row[0]} alarm_count = [] @@ -939,7 +960,28 @@ class Sf_Dashboard_Connect(http.Controller): alarm_count_num = 1 else: alarm_count_num = len(list(set(alarm_count))) + + for today in today_data: + if today[0]: + if float(today[0]) >= 28800: + continue + today_alarm_time += float(today[0]) + else: + today_alarm_time += 0.0 + for month in month_data: + if month[0]: + if float(month[0]) >= 28800: + continue + month_alarm_time += float(month[0]) + else: + month_alarm_time += 0.0 + + TotalAlarmTime = total_alarm_time / 3600 + TodayAlarmTime = today_alarm_time / 3600 + MonthAlarmTime = month_alarm_time / 3600 + logging.info('=====AlarmTime===== %s, %s, %s' % (TotalAlarmTime, TodayAlarmTime, MonthAlarmTime)) res['data'][item]['total_alarm_time'] = total_alarm_time / 3600 + logging.info('=======================') res['data'][item]['alarm_count_num'] = alarm_count_num # 返回统计结果 diff --git a/sf_quality/data/insepection_report_template.xml b/sf_quality/data/insepection_report_template.xml index d989137c..14a42065 100644 --- a/sf_quality/data/insepection_report_template.xml +++ b/sf_quality/data/insepection_report_template.xml @@ -78,6 +78,10 @@

公司邮箱:

+ +
+ 1 页/共 1 +