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