修复中控对接接口

This commit is contained in:
jinling.yang
2024-07-25 10:27:07 +08:00
parent 30c823189c
commit c9d4f0667a
3 changed files with 32 additions and 27 deletions

View File

@@ -868,23 +868,18 @@ class MrpProduction(models.Model):
raise UserError('编程单号为%s的CNC程序文件从FTP拉取失败' % (self.programming_no))
productions = self.env['mrp.production'].search(
[('programming_no', '=', self.programming_no), ('state', 'not in', ('cancel', 'done'))])
logging.info('get_new_program productions:%s' % productions)
if productions:
for production in productions:
panel_workorder = production.workorder_ids.filtered(lambda
pw: pw.processing_panel == processing_panel and pw.routing_type == 'CNC加工' and pw.state not in (
'rework', 'done'))
logging.info('get_new_program panel_workorder:%s' % panel_workorder)
if panel_workorder:
logging.info('get_new_program 1')
if panel_workorder.cmm_ids:
panel_workorder.cmm_ids.sudo().unlink()
if panel_workorder.cnc_ids:
panel_workorder.cnc_ids.sudo().unlink()
logging.info('get_new_program 2')
self.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan(
production)
logging.info('get_new_program 3')
# program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test',
# processing_panel)
logging.info('program_path_tmp_panel:%s' % program_path_tmp_panel)
@@ -895,21 +890,19 @@ class MrpProduction(models.Model):
if file_extension.lower() == '.pdf':
panel_file_path = os.path.join(program_path_tmp_panel, file)
logging.info('panel_file_path:%s' % panel_file_path)
logging.info('get_new_program 4')
panel_workorder.write(
{'cnc_ids': panel_workorder.cnc_ids.sudo()._json_cnc_processing(processing_panel,
result),
'cmm_ids': panel_workorder.cmm_ids.sudo()._json_cmm_program(processing_panel, result),
'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())})
logging.info('get_new_program 5')
pre_workorder = production.workorder_ids.filtered(lambda
ap: ap.routing_type == '装夹预调' and ap.processing_panel == processing_panel and ap.state not in (
'rework', 'done'))
logging.info('get_new_program 6')
if pre_workorder:
pre_workorder.write(
{'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})
logging.info('get_new_program 7')
logging.info('更新程序完成:%s' % production.name)
else:
raise UserError(result['message'])
except Exception as e:

View File

@@ -255,7 +255,7 @@ class ResMrpWorkOrder(models.Model):
sql = """
SELECT *
FROM mrp_workorder
WHERE
WHERE state!='rework'
to_char(date_planned_start::timestamp + '8 hour','YYYY-MM-DD HH:mm:SS')>= %s
AND to_char(date_planned_finished::timestamp + '8 hour','YYYY-MM-DD HH:mm:SS')<= %s
"""
@@ -753,10 +753,15 @@ class ResMrpWorkOrder(models.Model):
('processing_panel', '=', workorder.processing_panel),
('routing_type', '=', 'CNC加工'), ('state', 'in', ['done', 'rework']),
('test_results', '=', '返工')])
cnc_workorder_pending = self.env['mrp.workorder'].search(
[('production_id', '=', workorder.production_id.id),
('processing_panel', '=', workorder.processing_panel),
('routing_type', '=', 'CNC加工'), ('state', 'in', ['pending'])])
if workorder.state not in ['cancel', 'progress', 'rework']:
if workorder.production_id.state == 'rework':
logging.info('len(re_work):%s' % len(re_work))
logging.info('len(cnc_workorder):%s' % len(cnc_workorder))
logging.info('len(cnc_workorder_pending):%s' % len(cnc_workorder_pending))
logging.info('工序:%s' % workorder.routing_type)
logging.info('状态:%s' % workorder.state)
logging.info('is_rework:%s' % workorder.is_rework)
@@ -771,7 +776,7 @@ class ResMrpWorkOrder(models.Model):
# 新工单
if workorder.is_rework is False:
if workorder.production_id.programming_state == '已编程' and workorder.production_id.is_rework is False:
if re_work:
if re_work or cnc_workorder:
workorder.state = 'ready'
else:
if workorder.production_id.is_rework is True:
@@ -790,13 +795,15 @@ class ResMrpWorkOrder(models.Model):
workorder.state = 'waiting'
elif workorder.routing_type == '解除装夹' and workorder.state not in ['done', 'rework', 'cancel']:
if cnc_workorder:
workorder.state = 'waiting'
if not cnc_workorder_pending:
workorder.state = 'waiting'
# else:
# if workorder.production_id.is_rework is True:
# workorder.state = 'waiting'
elif workorder.production_id.state == 'progress':
logging.info('len(re_work):%s' % len(re_work))
logging.info('len(cnc_workorder):%s' % len(cnc_workorder))
logging.info('len(cnc_workorder_pending):%s' % len(cnc_workorder_pending))
logging.info('工序:%s' % workorder.routing_type)
logging.info('状态:%s' % workorder.state)
logging.info('is_rework:%s' % workorder.is_rework)
@@ -808,7 +815,7 @@ class ResMrpWorkOrder(models.Model):
workorder.is_rework is False and workorder.state not in [
'done', 'rework',
'cancel']:
if re_work and workorder.production_id.is_rework is False:
if (re_work or cnc_workorder) and workorder.production_id.is_rework is False:
workorder.state = 'ready'
if workorder.routing_type == '表面工艺' and workorder.state not in ['done', 'progress']:
unclamp_workorder = self.env['mrp.workorder'].search(
@@ -817,9 +824,11 @@ class ResMrpWorkOrder(models.Model):
('state', 'in', ['done'])])
if unclamp_workorder:
workorder.state = 'ready'
# else:
# if workorder.state not in ['cancel', 'rework']:
# workorder.state = 'rework'
logging.info('工序:%s' % workorder.sequence)
logging.info('工单最终状态:%s' % workorder.state)
# else:
# if workorder.state not in ['cancel', 'rework']:
# workorder.state = 'rework'
# elif workorder.routing_type == 'CNC加工' and workorder.state not in ['done', 'cancel', 'progress',
# 'rework']:
# per_work = self.env['mrp.workorder'].search(