From 2b2da79e33e52bc8e09d44c42aaea08cf9c6b6b4 Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Mon, 24 Mar 2025 17:18:19 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=AD=9B=E9=80=89?= =?UTF-8?q?=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 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sf_machine_connect/controllers/controllers.py b/sf_machine_connect/controllers/controllers.py index 944eb5a0..7d2d76bd 100644 --- a/sf_machine_connect/controllers/controllers.py +++ b/sf_machine_connect/controllers/controllers.py @@ -1130,7 +1130,7 @@ class Sf_Dashboard_Connect(http.Controller): SELECT * FROM device_data WHERE device_name = %s AND time::date = CURRENT_DATE - AND device_state in ('离线') + AND device_state in ('待机', '警告', '运行中') ORDER BY time ASC LIMIT 1; """, (item,)) @@ -1143,7 +1143,7 @@ class Sf_Dashboard_Connect(http.Controller): SELECT * FROM device_data WHERE device_name = %s AND time::date = CURRENT_DATE - AND device_state in ('离线') + AND device_state in ('待机', '警告', '运行中') ORDER BY time DESC LIMIT 1; """, (item,)) @@ -1161,11 +1161,11 @@ class Sf_Dashboard_Connect(http.Controller): # 获取当月第一条记录(排除device_state等于‘离线’的记录) with conn.cursor() as cur: cur.execute(""" - SELECT * FROM device_datas + SELECT * FROM device_data WHERE device_name = %s AND time >= DATE_TRUNC('MONTH', CURRENT_DATE) AND time < DATE_TRUNC('MONTH', CURRENT_DATE) + INTERVAL '1 MONTH' - AND device_state in ('离线') + AND device_state in ('待机', '警告', '运行中') ORDER BY time ASC LIMIT 1; """, (item,)) @@ -1179,7 +1179,7 @@ class Sf_Dashboard_Connect(http.Controller): WHERE device_name = %s AND time >= DATE_TRUNC('MONTH', CURRENT_DATE) AND time < DATE_TRUNC('MONTH', CURRENT_DATE) + INTERVAL '1 MONTH' - AND device_state in ('离线') + AND device_state in ('待机', '警告', '运行中') ORDER BY time DESC LIMIT 1; """, (item,)) @@ -1200,7 +1200,7 @@ class Sf_Dashboard_Connect(http.Controller): cur.execute(""" SELECT * FROM device_data WHERE device_name = %s - AND device_state in ('离线') + AND device_state in ('待机', '警告', '运行中') ORDER BY time ASC LIMIT 1; """, (item,)) @@ -1212,7 +1212,7 @@ class Sf_Dashboard_Connect(http.Controller): cur.execute(""" SELECT * FROM device_data WHERE device_name = %s - AND device_state in ('离线') + AND device_state in ('待机', '警告', '运行中') ORDER BY time DESC LIMIT 1; """, (item,)) @@ -1290,7 +1290,7 @@ class Sf_Dashboard_Connect(http.Controller): cur.execute(""" SELECT * FROM device_data WHERE device_name = %s - AND device_state in ('离线') AND process_time IS NOT NULL + AND device_state in ('待机', '警告', '运行中') AND process_time IS NOT NULL ORDER BY time DESC LIMIT 1; """, (item,)) @@ -1299,7 +1299,7 @@ class Sf_Dashboard_Connect(http.Controller): cur.execute(""" SELECT * FROM device_data WHERE device_name = %s - AND device_state in ('离线') AND time >= %s AND process_time IS NOT NULL + AND device_state in ('待机', '警告', '运行中') AND time >= %s AND process_time IS NOT NULL ORDER BY time ASC LIMIT 1; """, (item, time_threshold)) From f8e8615dc8814cf55e8e84b6cc2475170cdbf148 Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Mon, 24 Mar 2025 17:25:23 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E9=80=82=E9=85=8D=E7=B4=A2=E5=BC=95?= 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, 4 insertions(+), 2 deletions(-) diff --git a/sf_machine_connect/controllers/controllers.py b/sf_machine_connect/controllers/controllers.py index 7d2d76bd..43af4a9b 100644 --- a/sf_machine_connect/controllers/controllers.py +++ b/sf_machine_connect/controllers/controllers.py @@ -1129,7 +1129,8 @@ class Sf_Dashboard_Connect(http.Controller): cur.execute(""" SELECT * FROM device_data WHERE device_name = %s - AND time::date = CURRENT_DATE + AND time >= CURRENT_DATE -- 今日 00:00:00 + AND time < CURRENT_DATE + 1 -- 明日 00:00:00 AND device_state in ('待机', '警告', '运行中') ORDER BY time ASC LIMIT 1; @@ -1142,7 +1143,8 @@ class Sf_Dashboard_Connect(http.Controller): cur.execute(""" SELECT * FROM device_data WHERE device_name = %s - AND time::date = CURRENT_DATE + AND time >= CURRENT_DATE -- 今日 00:00:00 + AND time < CURRENT_DATE + 1 -- 明日 00:00:00 AND device_state in ('待机', '警告', '运行中') ORDER BY time DESC LIMIT 1; From fd9018a4c89feb6ee83b3789733099238a4fbaa6 Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Tue, 25 Mar 2025 09:56:40 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E9=80=BB=E8=BE=91=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 | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sf_machine_connect/controllers/controllers.py b/sf_machine_connect/controllers/controllers.py index 43af4a9b..0c91846b 100644 --- a/sf_machine_connect/controllers/controllers.py +++ b/sf_machine_connect/controllers/controllers.py @@ -566,7 +566,8 @@ class Sf_Dashboard_Connect(http.Controller): :return: """ res = {'status': 1, 'message': '成功', 'data': {}} - plan_obj = request.env['sf.production.plan'].sudo() + # plan_obj = request.env['sf.production.plan'].sudo() + plan_obj = request.env['mrp.production'].sudo() line_list = ast.literal_eval(kw['line_list']) begin_time_str = kw['begin_time'].strip('"') end_time_str = kw['end_time'].strip('"') @@ -604,7 +605,7 @@ class Sf_Dashboard_Connect(http.Controller): return date_list for line in line_list: - date_field_name = 'actual_end_time' # 替换为你模型中的实际字段名 + date_field_name = 'date_finished' # 替换为你模型中的实际字段名 order_counts = [] if time_unit == 'hour': @@ -618,7 +619,7 @@ class Sf_Dashboard_Connect(http.Controller): orders = plan_obj.search([ ('production_line_id.name', '=', line), - ('state', 'in', ['finished']), + ('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')) # 包括结束时间 ]) @@ -637,18 +638,18 @@ class Sf_Dashboard_Connect(http.Controller): for date in date_list: next_day = date + timedelta(days=1) - orders = plan_obj.search([('production_line_id.name', '=', line), ('state', 'in', ['finished']), + orders = plan_obj.search([('production_line_id.name', '=', line), ('state', 'in', ['done']), (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( - [('production_line_id.name', '=', line), ('production_id.state', 'in', ['rework']), + [('production_line_id.name', '=', line), ('state', 'in', ['rework']), (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( - [('production_line_id.name', '=', line), ('production_id.state', 'in', ['scrap', 'cancel']), + [('production_line_id.name', '=', line), ('state', 'in', ['scrap', 'cancel']), (date_field_name, '>=', date.strftime('%Y-%m-%d 00:00:00')), (date_field_name, '<', next_day.strftime('%Y-%m-%d 00:00:00')) ]) From b39281d057b363c9d0bd934fe30b328bc165ee96 Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Tue, 25 Mar 2025 10:32:12 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=8A=A5=E5=91=8A?= =?UTF-8?q?=E7=BC=96=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- quality_control/models/quality.py | 12 ++++++++---- sf_quality/data/insepection_report_template.xml | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/quality_control/models/quality.py b/quality_control/models/quality.py index df4a11b2..95c11451 100644 --- a/quality_control/models/quality.py +++ b/quality_control/models/quality.py @@ -180,8 +180,14 @@ class QualityCheck(models.Model): # 出厂检验报告编号 report_number_id = fields.Many2one('documents.document', string='出厂检验报告编号', readonly=True) + report_number_name = fields.Char('出厂检验报告编号名称', compute='_compute_report_number_name') - old_report_name = fields.Char('旧出厂检验报告编号', default='') + @api.depends('serial_number', 'part_number') + def _compute_report_number_name(self): + for record in self: + str_serial_number = '0' + str(record.serial_number) if record.serial_number < 10 else str(record.serial_number) + str_part_number = record.part_number if record.part_number else '' + record.report_number_name = f'FQC{str_part_number}{str_serial_number}' # 出厂检验报告、关联文档的数据 report_content = fields.Binary(string='出厂检验报告', related='report_number_id.datas') @@ -303,11 +309,9 @@ class QualityCheck(models.Model): if self.serial_number > 99: raise UserError(_('流水号不能大于99')) - str_serial_number = '0' + str(self.serial_number) if self.serial_number < 10 else str(self.serial_number) - str_part_number = self.part_number if self.part_number else '' # 3. 创建文档记录 doc_vals = { - 'name': f'FQC{str_part_number}{str_serial_number}', + 'name': self.report_number_name, 'raw': pdf_content, # 'attachment_id': attachment.id, 'mimetype': 'application/pdf', diff --git a/sf_quality/data/insepection_report_template.xml b/sf_quality/data/insepection_report_template.xml index cd7998a3..f605b3e4 100644 --- a/sf_quality/data/insepection_report_template.xml +++ b/sf_quality/data/insepection_report_template.xml @@ -18,7 +18,7 @@
- 报告编号:ceshi + 报告编号:ceshi
扫描二维码查看PDF报告