优化制造订单的获取cnc程序
This commit is contained in:
@@ -154,7 +154,7 @@ class MrpProduction(models.Model):
|
||||
production.maintenance_count = len(production.request_ids)
|
||||
|
||||
# cnc程序获取
|
||||
def fetchCNC(self):
|
||||
def fetchCNC(self, production_names):
|
||||
cnc = self.env['mrp.production'].search([('id', '=', self.id)])
|
||||
quick_order = self.env['quick.easy.order'].search(
|
||||
[('name', '=', cnc.product_id.default_code.rsplit('-', 1)[0])])
|
||||
@@ -166,8 +166,8 @@ class MrpProduction(models.Model):
|
||||
if quick_order:
|
||||
programme_way = 'manual operation'
|
||||
try:
|
||||
res = {'model_code': '' if not cnc.product_id.model_code else cnc.product_id.model_code,
|
||||
'production_no': cnc.name,
|
||||
res = {'model_code': cnc.product_id.name,
|
||||
'production_no': production_names,
|
||||
'machine_tool_code': "",
|
||||
'material_code': self.env['sf.production.materials'].search(
|
||||
[('id', '=', cnc.product_id.materials_id.id)]).materials_no,
|
||||
@@ -185,7 +185,10 @@ class MrpProduction(models.Model):
|
||||
'model_file': '' if not cnc.product_id.model_file else base64.b64encode(
|
||||
cnc.product_id.model_file).decode('utf-8')
|
||||
}
|
||||
logging.info('res:%s' % res)
|
||||
# 打印出除了 model_file 之外的所有键值对
|
||||
for key, value in res.items():
|
||||
if key != 'model_file':
|
||||
logging.info('%s: %s' % (key, value))
|
||||
configsettings = self.env['res.config.settings'].get_values()
|
||||
config_header = Common.get_headers(self, configsettings['token'], configsettings['sf_secret_key'])
|
||||
url = '/api/intelligent_programming/create'
|
||||
@@ -263,15 +266,15 @@ class MrpProduction(models.Model):
|
||||
# 其他规则限制: 默认只分配给工作中心状态为非故障的工作中心;
|
||||
|
||||
def _create_workorder3(self):
|
||||
production_names = [production.name for production in self if production.product_id.categ_id.type == '成品']
|
||||
programming_no = None
|
||||
product_id_new = None
|
||||
production_ids = []
|
||||
product_first = None
|
||||
for production in self:
|
||||
if not production.bom_id or not production.product_id:
|
||||
continue
|
||||
workorders_values = []
|
||||
if product_id_new is None:
|
||||
product_id_new = production.product_id
|
||||
if product_first is None:
|
||||
product_first = production.product_id
|
||||
|
||||
product_qty = production.product_uom_id._compute_quantity(production.product_qty,
|
||||
production.bom_id.product_uom_id)
|
||||
@@ -296,16 +299,13 @@ class MrpProduction(models.Model):
|
||||
'state': 'pending',
|
||||
}]
|
||||
if production.product_id.categ_id.type == '成品':
|
||||
if production_ids is None:
|
||||
production_ids.append({production.name})
|
||||
if programming_no is None:
|
||||
production.fetchCNC()
|
||||
production.fetchCNC(production_names)
|
||||
programming_no = production.programming_no
|
||||
else:
|
||||
if production.product_id == product_id_new:
|
||||
if production.product_id == product_first:
|
||||
if not production.programming_no:
|
||||
production.write({'programming_no': programming_no, 'programming_state': '编程中'})
|
||||
|
||||
# 根据加工面板的面数及对应的工序模板生成工单
|
||||
i = 0
|
||||
processing_panel_len = len(production.product_id.model_processing_panel.split(','))
|
||||
|
||||
@@ -975,6 +975,23 @@ class CNCprocessing(models.Model):
|
||||
# cnc_workorder.time_ids.date_end = datetime.now()
|
||||
# cnc_workorder.button_finish()
|
||||
|
||||
def _json_cnc_processing(self, obj):
|
||||
cnc_processing_str = [0, 0, {
|
||||
'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']
|
||||
}]
|
||||
return cnc_processing_str
|
||||
|
||||
# 根据程序名和加工面匹配到ftp里对应的Nc程序名,可优化为根据cnc_processing.program_path进行匹配
|
||||
def get_cnc_processing_file(self, serverdir, cnc_processing, program_path):
|
||||
logging.info('serverdir:%s' % serverdir)
|
||||
@@ -1228,8 +1245,8 @@ class WorkPieceDelivery(models.Model):
|
||||
same_route_id = item.route_id.id
|
||||
if item.route_id.id != same_route_id:
|
||||
is_not_route += 1
|
||||
else:
|
||||
raise UserError('请选择【任务路线】再进行配送')
|
||||
# else:
|
||||
# raise UserError('请选择【任务路线】再进行配送')
|
||||
if production_type != item.type:
|
||||
raise UserError('请选择类型为%s的制造订单进行配送' % production_type)
|
||||
if down_status != item.status:
|
||||
@@ -1309,21 +1326,22 @@ class WorkPieceDelivery(models.Model):
|
||||
feeder_station_destination = None
|
||||
route_id = None
|
||||
for item in self:
|
||||
delivery_Arr.append(item.name)
|
||||
if route_id is None:
|
||||
route_id = item.route_id.id
|
||||
if feeder_station_start is None:
|
||||
feeder_station_start = item.feeder_station_start_id.name
|
||||
if feeder_station_destination is None:
|
||||
feeder_station_destination = item.feeder_station_destination_id.name
|
||||
if item.type in ['上产线', '下产线']:
|
||||
if route_id is None:
|
||||
route_id = item.route_id.id
|
||||
if feeder_station_start is None:
|
||||
feeder_station_start = item.feeder_station_start_id.name
|
||||
if feeder_station_destination is None:
|
||||
feeder_station_destination = item.feeder_station_destination_id.name
|
||||
item.route_id = route_id
|
||||
delivery_Arr.append(item.name)
|
||||
else:
|
||||
self = self.create(
|
||||
{'name': self.env['ir.sequence'].next_by_code('sf.workpiece.delivery'),
|
||||
'route_id': self.route_id.id,
|
||||
'feeder_station_start_id': self.feeder_station_start_id.id,
|
||||
'feeder_station_destination_id': self.feeder_station_destination_id.id})
|
||||
delivery_Arr.append(self.name)
|
||||
delivery_str = ','.join(map(str, delivery_Arr))
|
||||
if feeder_station_start is not None:
|
||||
positionCode_Arr.append({
|
||||
|
||||
Reference in New Issue
Block a user