1.修复及优化质检接口2.质量检查新增检测报告和检测结果2个字段
This commit is contained in:
@@ -95,8 +95,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
Y10_axis = fields.Float(default=0)
|
||||
Z10_axis = fields.Float(default=0)
|
||||
X_deviation_angle = fields.Integer(string="X轴偏差度", default=0)
|
||||
test_results = fields.Selection([("合格", "合格"), ("返工", "返工"), ("报废", "报废")], default='合格',
|
||||
string="检测结果")
|
||||
test_result = fields.Char("检测结果")
|
||||
cnc_ids = fields.One2many("sf.cnc.processing", 'workorder_id', string="CNC加工程序")
|
||||
cmm_ids = fields.One2many("sf.cmm.program", 'workorder_id', string="CMM程序")
|
||||
tray_code = fields.Char(string="托盘编码")
|
||||
@@ -432,7 +431,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
"""
|
||||
重新生成制造订单或者重新生成工单
|
||||
"""
|
||||
if self.test_results == '报废':
|
||||
if self.test_result == '报废':
|
||||
values = self.env['mrp.production'].create_production1_values(self.production_id)
|
||||
productions = self.env['mrp.production'].with_user(SUPERUSER_ID).sudo().with_company(
|
||||
self.production_id.company_id).create(
|
||||
@@ -464,7 +463,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
'mail.message_origin_link',
|
||||
values={'self': production, 'origin': origin_production},
|
||||
subtype_id=self.env.ref('mail.mt_note').id)
|
||||
if self.test_results == '返工':
|
||||
if self.test_result == '返工':
|
||||
productions = self.production_id
|
||||
# self.env['stock.move'].sudo().create(productions._get_moves_raw_values())
|
||||
# self.env['stock.move'].sudo().create(productions._get_moves_finished_values())
|
||||
@@ -631,33 +630,34 @@ class ResMrpWorkOrder(models.Model):
|
||||
|
||||
# 将FTP的检测报告文件下载到临时目录
|
||||
def download_reportfile_tmp(self, workorder, reportpath):
|
||||
logging.info('reportpath:%s' % reportpath)
|
||||
production_no = workorder.production_id.name.replace('/', '_')
|
||||
# ftp地址
|
||||
remotepath = os.path.join('/', production_no, 'detection')
|
||||
serverdir = os.path.join('/tmp', production_no, 'detection')
|
||||
ftp_resconfig = self.env['res.config.settings'].get_values()
|
||||
ftp = FtpController(str(ftp_resconfig['ftp_host']), int(ftp_resconfig['ftp_port']),
|
||||
ftp_resconfig['ftp_user'],
|
||||
ftp_resconfig['ftp_password'])
|
||||
download_state = ftp.download_reportfile_tree(remotepath, serverdir, reportpath)
|
||||
logging.info('download_state:%s' % download_state)
|
||||
logging.info('ftp地址:%s' % remotepath)
|
||||
if remotepath in reportpath:
|
||||
# 服务器内临时地址
|
||||
serverdir = os.path.join('/tmp', production_no, 'detection')
|
||||
ftp_resconfig = self.env['res.config.settings'].get_values()
|
||||
ftp = FtpController(str(ftp_resconfig['ftp_host']), int(ftp_resconfig['ftp_port']),
|
||||
ftp_resconfig['ftp_user'],
|
||||
ftp_resconfig['ftp_password'])
|
||||
download_state = ftp.download_reportfile_tree(remotepath, serverdir, reportpath)
|
||||
logging.info('download_state:%s' % download_state)
|
||||
else:
|
||||
download_state = 2
|
||||
return download_state
|
||||
|
||||
# 根据中控系统提供的检测文件地址去ftp里对应的制造订单里获取
|
||||
def get_detection_file(self, workorder, reportPath):
|
||||
logging.info('workorder:%s' % workorder.name)
|
||||
logging.info('制造订单:%s' % workorder.production_id.name)
|
||||
logging.info('reportPath:%s' % reportPath)
|
||||
serverdir = os.path.join('/tmp', reportPath).replace('//', '/')
|
||||
logging.info('serverdir:%s' % serverdir)
|
||||
logging.info('get_detection_file-serverdir:%s' % serverdir)
|
||||
for root, dirs, files in os.walk(serverdir):
|
||||
for f in files:
|
||||
logging.info('f:%s' % f)
|
||||
if os.path.splitext(f)[1] == ".pdf":
|
||||
full_path = os.path.join(serverdir, root, f)
|
||||
logging.info('检测文件路径:%s' % full_path)
|
||||
if full_path is not False:
|
||||
workorder.detection_report = base64.b64encode(
|
||||
open(full_path, 'rb').read())
|
||||
if f in reportPath:
|
||||
workorder.detection_report = base64.b64encode(
|
||||
open(serverdir, 'rb').read())
|
||||
return True
|
||||
|
||||
|
||||
class CNCprocessing(models.Model):
|
||||
@@ -686,15 +686,11 @@ class CNCprocessing(models.Model):
|
||||
|
||||
# mrs下发编程单创建CNC加工
|
||||
def cnc_processing_create(self, cnc_workorder, ret, program_path, program_path_tmp):
|
||||
logging.info('ret:%s' % ret)
|
||||
logging.info('program_path_tmp:%s' % program_path_tmp)
|
||||
logging.info('program_path:%s' % program_path)
|
||||
for obj in ret['programming_list']:
|
||||
workorder = self.env['mrp.workorder'].search([('production_id.name', '=', ret['production_order_no']),
|
||||
('processing_panel', '=', obj['processing_panel']),
|
||||
('routing_type', '=', 'CNC加工')])
|
||||
logging.info('workorder:%s' % workorder.id)
|
||||
logging.info('obj:%s' % obj)
|
||||
if obj['program_name'] in program_path:
|
||||
logging.info('obj:%s' % obj['program_name'])
|
||||
cnc_processing = self.env['sf.cnc.processing'].create({
|
||||
@@ -739,9 +735,6 @@ class CNCprocessing(models.Model):
|
||||
if f in program_path:
|
||||
# if cnc_processing.program_name == f.split('.')[0]:
|
||||
cnc_file_path = os.path.join(serverdir, root, f)
|
||||
logging.info('cnc_file_path:%s' % cnc_file_path)
|
||||
logging.info('program_path:%s' % program_path)
|
||||
logging.info('f:%s' % f)
|
||||
self.write_file(cnc_file_path, cnc_processing)
|
||||
|
||||
# 创建附件(nc文件)
|
||||
|
||||
Reference in New Issue
Block a user