坯料的采购订单零件图号,零件名称显示
This commit is contained in:
@@ -3,6 +3,8 @@ import logging
|
||||
import os
|
||||
import json
|
||||
import base64
|
||||
import traceback
|
||||
|
||||
from odoo import http, fields, models
|
||||
from odoo.http import request
|
||||
from odoo.addons.sf_base.controllers.controllers import MultiInheritController
|
||||
@@ -42,26 +44,26 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
|
||||
|
||||
# 拉取所有加工面的程序文件
|
||||
for r in ret['processing_panel'].split(','):
|
||||
program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r)
|
||||
program_path_tmp_r = os.path.join('/tmp', ret['folder_name'] or '', 'return', r)
|
||||
if os.path.exists(program_path_tmp_r):
|
||||
files_r = os.listdir(program_path_tmp_r)
|
||||
if files_r:
|
||||
for file_name in files_r:
|
||||
file_path = os.path.join(program_path_tmp_r, file_name)
|
||||
os.remove(file_path)
|
||||
download_state = request.env['sf.cnc.processing'].with_user(
|
||||
request.env.ref("base.user_admin")).download_file_tmp(
|
||||
ret['folder_name'], r)
|
||||
if download_state is False:
|
||||
res['status'] = -2
|
||||
res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no'])
|
||||
return json.JSONEncoder().encode(res)
|
||||
# download_state = request.env['sf.cnc.processing'].with_user(
|
||||
# request.env.ref("base.user_admin")).download_file_tmp(
|
||||
# ret['folder_name'], r)
|
||||
# if download_state is False:
|
||||
# res['status'] = -2
|
||||
# res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no'])
|
||||
# return json.JSONEncoder().encode(res)
|
||||
for production in productions:
|
||||
production.write({'programming_state': '已编程', 'work_state': '已编程', 'is_rework': False})
|
||||
for panel in ret['processing_panel'].split(','):
|
||||
# 查询状态为进行中且工序类型为CNC加工的工单
|
||||
cnc_workorder_has = production.workorder_ids.filtered(
|
||||
lambda ach: ach.routing_type in ['CNC加工', '人工线下加工'] and ach.state not in ['progress', 'done',
|
||||
lambda ach: ach.routing_type == 'CNC加工' and ach.state not in ['progress', 'done',
|
||||
'rework',
|
||||
'cancel'] and ach.processing_panel == panel)
|
||||
if cnc_workorder_has:
|
||||
@@ -76,36 +78,34 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
|
||||
for panel in ret['processing_panel'].split(','):
|
||||
# 查询状态为进行中且工序类型为CNC加工的工单
|
||||
cnc_workorder = productions.workorder_ids.filtered(
|
||||
lambda ac: ac.routing_type in ['CNC加工', '人工线下加工'] and ac.state not in ['progress', 'done', 'rework'
|
||||
lambda ac: ac.routing_type == 'CNC加工' and ac.state not in ['progress', 'done', 'rework'
|
||||
'cancel'] and ac.processing_panel == panel)
|
||||
if cnc_workorder:
|
||||
# program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test',
|
||||
# panel)
|
||||
program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', panel)
|
||||
files_panel = os.listdir(program_path_tmp_panel)
|
||||
if files_panel:
|
||||
for file in files_panel:
|
||||
file_extension = os.path.splitext(file)[1]
|
||||
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)
|
||||
cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())})
|
||||
pre_workorder = productions.workorder_ids.filtered(
|
||||
lambda ap: ap.routing_type in ['装夹预调', '人工线下加工'] and ap.state not in ['done', 'rework'
|
||||
'cancel'] and ap.processing_panel == panel)
|
||||
if pre_workorder:
|
||||
pre_workorder.write(
|
||||
{'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})
|
||||
# if cnc_workorder:
|
||||
# # program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test',
|
||||
# # panel)
|
||||
# program_path_tmp_panel = os.path.join('/tmp', "ret['folder_name']", 'return', panel)
|
||||
# files_panel = os.listdir(program_path_tmp_panel)
|
||||
# if files_panel:
|
||||
# for file in files_panel:
|
||||
# file_extension = os.path.splitext(file)[1]
|
||||
# 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)
|
||||
# cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())})
|
||||
# pre_workorder = productions.workorder_ids.filtered(
|
||||
# lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done', 'rework'
|
||||
# 'cancel'] and ap.processing_panel == panel)
|
||||
# if pre_workorder:
|
||||
# pre_workorder.write(
|
||||
# {'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})
|
||||
productions.write({'programming_state': '已编程', 'work_state': '已编程'})
|
||||
productions.filtered(lambda p: p.production_type == '人工线下加工').write({'manual_quotation': True})
|
||||
logging.info('已更新制造订单编程状态:%s' % productions.ids)
|
||||
|
||||
# 对制造订单所有面的cnc工单的程序用刀进行校验
|
||||
try:
|
||||
logging.info(f'已更新制造订单:{productions}')
|
||||
re_tool_chekout = False
|
||||
productions_temp = productions.filtered(lambda p: p.production_type == '自动化产线加工')
|
||||
re_tool_chekout = productions_temp.production_cnc_tool_checkout()
|
||||
re_tool_chekout = productions.production_cnc_tool_checkout()
|
||||
if re_tool_chekout:
|
||||
return json.JSONEncoder().encode({'status': -3, 'message': '对cnc工单的程序用刀进行校验失败'})
|
||||
except Exception as e:
|
||||
@@ -202,17 +202,6 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
|
||||
'send_time': ret['send_time'],
|
||||
})
|
||||
logging.info('已创建无效功能刀具的编程记录:%s' % production.name)
|
||||
elif ret['reprogramming_reason']:
|
||||
production.programming_record_ids.create({
|
||||
'number': len(production.programming_record_ids) + 1,
|
||||
'production_id': production.id,
|
||||
'reason': ret['reprogramming_reason'],
|
||||
'programming_method': ret['programme_way'],
|
||||
'current_programming_count': ret['reprogramming_num'],
|
||||
'target_production_id': productions_reprogram,
|
||||
'apply_time': ret['trigger_time'],
|
||||
'send_time': ret['send_time'],
|
||||
})
|
||||
else:
|
||||
logging.info('无对应状态,不需更新编程记录')
|
||||
|
||||
@@ -266,5 +255,7 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
|
||||
except Exception as e:
|
||||
res = {'status': -1, 'message': '系统解析失败'}
|
||||
request.cr.rollback()
|
||||
logging.info('get_cnc_processing_create error:%s' % e)
|
||||
traceback_error = traceback.format_exc()
|
||||
logging.info('get_cnc_processing_create error:%s' % traceback_error)
|
||||
# logging.info('get_cnc_processing_create error:%s' % e)
|
||||
return json.JSONEncoder().encode(res)
|
||||
|
||||
@@ -2305,6 +2305,8 @@ class Cutting_tool_standard_library(models.Model):
|
||||
result = json.loads(r['result'])
|
||||
if result['status'] == 1:
|
||||
for item in result['cutting_tool_standard_library_all_list']:
|
||||
if item['code'] == 'JKM-T-DJWL-ZTDJ-20250225001':
|
||||
print('qwfhuiuiohfqwuio')
|
||||
cutting_tool_standard_library = self.search(
|
||||
[("code", '=', item['code']),
|
||||
("active", 'in', [True, False])])
|
||||
|
||||
Reference in New Issue
Block a user