Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/制造代码优化
This commit is contained in:
@@ -736,7 +736,7 @@ class CNCprocessing(models.Model):
|
||||
# cnc_workorder.time_ids.date_end = datetime.now()
|
||||
# cnc_workorder.button_finish()
|
||||
|
||||
# 根据程序名和加工面匹配到ftp里对应的Nc程序名
|
||||
# 根据程序名和加工面匹配到ftp里对应的Nc程序名,可优化为根据cnc_processing.program_path进行匹配
|
||||
def get_cnc_processing_file(self, serverdir, cnc_processing, program_path):
|
||||
logging.info('serverdir:%s' % serverdir)
|
||||
for root, dirs, files in os.walk(serverdir):
|
||||
@@ -778,7 +778,7 @@ class CNCprocessing(models.Model):
|
||||
# 将nc文件存到attach的datas里
|
||||
def write_file(self, nc_file_path, cnc):
|
||||
nc_file_name = nc_file_path.split('/')
|
||||
logging.info('nc_file_name:%s' % nc_file_name[-1])
|
||||
logging.info('file_name:%s' % nc_file_name[-1])
|
||||
if os.path.exists(nc_file_path):
|
||||
with open(nc_file_path, 'rb') as file:
|
||||
data_bytes = file.read()
|
||||
@@ -910,7 +910,8 @@ class WorkPieceDelivery(models.Model):
|
||||
# 配送至avg小车
|
||||
def _delivery_avg(self):
|
||||
res = {'reqCode': urllib.parse.quote(self.production_id.name), 'reqTime': '', 'clientCode': '', 'tokenCode': '',
|
||||
'taskTyp': 'F01', 'ctnrTyp': '', 'ctnrCode': '', 'wbCode': '006848AB006774', 'positionCodePath': [], 'podCode': '',
|
||||
'taskTyp': 'F01', 'ctnrTyp': '', 'ctnrCode': '', 'wbCode': '006848AB006774', 'positionCodePath': [],
|
||||
'podCode': '',
|
||||
'podDir': '', 'materialLot': '', 'priority': '', 'taskCode': '', 'agvCode': '', 'materialLot': '',
|
||||
'data': ''}
|
||||
config = self.env['res.config.settings'].get_values()
|
||||
@@ -951,7 +952,77 @@ class CMMprogram(models.Model):
|
||||
_name = 'sf.cmm.program'
|
||||
_description = "CMM程序"
|
||||
|
||||
program_path = fields.Char('程序文件路径')
|
||||
post_processing_name = fields.Char('后处理名称')
|
||||
program_date = fields.Datetime('程序日期')
|
||||
cmm_id = fields.Many2one('ir.attachment')
|
||||
sequence_number = fields.Integer('序号')
|
||||
program_name = fields.Char('程序名')
|
||||
cutting_tool_name = fields.Char('刀具名称')
|
||||
cutting_tool_no = fields.Char('刀号')
|
||||
processing_type = fields.Char('加工类型')
|
||||
margin_x_y = fields.Char('余量_X/Y')
|
||||
margin_z = fields.Char('余量_Z')
|
||||
depth_of_processing_z = fields.Char('加工深度(Z)')
|
||||
cutting_tool_extension_length = fields.Char('刀具伸出长度')
|
||||
cutting_tool_handle_type = fields.Char('刀柄型号')
|
||||
estimated_processing_time = fields.Char('预计加工时间')
|
||||
remark = fields.Text('备注')
|
||||
workorder_id = fields.Many2one('mrp.workorder', string="工单")
|
||||
production_id = fields.Many2one('mrp.production', string="制造订单")
|
||||
program_path = fields.Char('程序文件路径')
|
||||
|
||||
def cmm_program_create(self, ret, program_path, program_path_tmp):
|
||||
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加工')])
|
||||
if obj['program_name'] in program_path:
|
||||
logging.info('obj:%s' % obj['program_name'])
|
||||
cmm_program = self.sudo().create({
|
||||
'workorder_id': workorder.id,
|
||||
'sequence_number': obj['sequence_number'],
|
||||
'program_name': obj['program_name'],
|
||||
'cutting_tool_name': obj['cutting_tool_name'],
|
||||
'cutting_tool_no': obj['cutting_tool_no'],
|
||||
'processing_type': obj['processing_type'],
|
||||
'margin_x_y': obj['margin_x_y'],
|
||||
'margin_z': obj['margin_z'],
|
||||
'depth_of_processing_z': obj['depth_of_processing_z'],
|
||||
'cutting_tool_extension_length': obj['cutting_tool_extension_length'],
|
||||
'cutting_tool_handle_type': obj['cutting_tool_handle_type'],
|
||||
'estimated_processing_time': obj['estimated_processing_time'],
|
||||
'remark': obj['remark'],
|
||||
'program_path': program_path.replace('/tmp', '')
|
||||
})
|
||||
cmm_program.get_cmm_program_file(program_path_tmp, cmm_program, program_path)
|
||||
|
||||
# 根据程序名和加工面匹配到ftp里对应的cmm程序名
|
||||
def get_cmm_program_file(self, serverdir, cmm_program, program_path):
|
||||
logging.info('cmm-serverdir:%s' % serverdir)
|
||||
for root, dirs, files in os.walk(serverdir):
|
||||
for f in files:
|
||||
if f in program_path:
|
||||
cmm_program_file_path = os.path.join(serverdir, root, f)
|
||||
self.write_file_cmm(cmm_program_file_path, cmm_program)
|
||||
|
||||
# 创建附件(nc文件)
|
||||
def attachment_create(self, name, data):
|
||||
attachment = self.env['ir.attachment'].create({
|
||||
'datas': base64.b64encode(data),
|
||||
'type': 'binary',
|
||||
'public': True,
|
||||
'description': '程序文件',
|
||||
'name': name
|
||||
})
|
||||
return attachment
|
||||
|
||||
# 将cmm文件存到attach的datas里
|
||||
def write_file_cmm(self, cmm_file_path, cnc):
|
||||
cmm_file_name = cmm_file_path.split('/')
|
||||
logging.info('cmm_file_name:%s' % cmm_file_name[-1])
|
||||
if os.path.exists(cmm_file_path):
|
||||
with open(cmm_file_path, 'rb') as file:
|
||||
data_bytes = file.read()
|
||||
attachment = self.attachment_create(cnc.program_name + cmm_file_name[-1], data_bytes)
|
||||
cnc.write({'cmm_id': attachment.id})
|
||||
file.close()
|
||||
else:
|
||||
return False
|
||||
|
||||
@@ -366,10 +366,10 @@ class StockPicking(models.Model):
|
||||
# 设置外协出入单的名称
|
||||
def _get_name_Res(self, rescode):
|
||||
last_picking = self.sudo().search([('name', 'like', rescode)], order='create_date DESC', limit=1)
|
||||
logging.info('编号:' + last_picking.name)
|
||||
if not last_picking:
|
||||
num = "%04d" % 1
|
||||
else:
|
||||
logging.info('编号:' + last_picking.name)
|
||||
m = int(last_picking.name[-3:]) + 1
|
||||
num = "%04d" % m
|
||||
return '%s%s' % (rescode, num)
|
||||
@@ -419,7 +419,7 @@ class StockPicking(models.Model):
|
||||
location_id = self.env.ref(
|
||||
'sf_manufacturing.stock_location_locations_virtual_outcontract').id,
|
||||
location_dest_id = self.env['stock.location'].search(
|
||||
[('barcode', '=', 'WH-PREPRODUCTION')]).id,
|
||||
[('barcode', 'ilike', 'WH-PREPRODUCTION')]).id,
|
||||
outcontract_picking_type_in = self.env.ref(
|
||||
'sf_manufacturing.outcontract_picking_in').id,
|
||||
outcontract_picking_type_out = self.env.ref(
|
||||
|
||||
Reference in New Issue
Block a user