From 3d56e54fb22d3f3845f842ff4b581b21e2b15ce0 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Thu, 9 May 2024 18:29:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=88=B6=E9=80=A0=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E7=9A=84=E8=8E=B7=E5=8F=96cnc=E7=A8=8B=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/mrp_production.py | 26 +++++++------- sf_manufacturing/models/mrp_workorder.py | 36 ++++++++++++++----- sf_manufacturing/security/ir.model.access.csv | 2 +- sf_manufacturing/views/mrp_workorder_view.xml | 24 ++++++------- sf_mrs_connect/controllers/controllers.py | 10 ++---- 5 files changed, 56 insertions(+), 42 deletions(-) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 8e95bf70..862397a9 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -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(',')) diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 73f6b940..c525f480 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -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({ diff --git a/sf_manufacturing/security/ir.model.access.csv b/sf_manufacturing/security/ir.model.access.csv index 1798ba27..22cff848 100644 --- a/sf_manufacturing/security/ir.model.access.csv +++ b/sf_manufacturing/security/ir.model.access.csv @@ -30,7 +30,7 @@ access_mrp_workcenter_group_sf_mrp_user,mrp_workcenter,model_mrp_workcenter,sf_b access_mrp_workcenter_manager,mrp_workcenter,model_mrp_workcenter,sf_base.group_sf_mrp_manager,1,1,1,0 access_mrp_workcenter_productivity_group_sf_mrp_user,mrp_workcenter_productivity,model_mrp_workcenter_productivity,sf_base.group_sf_mrp_user,1,0,0,0 access_mrp_workcenter_productivity_manager,mrp_workcenter_productivity,model_mrp_workcenter_productivity,sf_base.group_sf_mrp_manager,1,1,1,0 -access_sf_workpiece_delivery_group_sf_order_user,sf_workpiece_delivery_group_sf_order_user,model_sf_workpiece_delivery,sf_base.group_sf_order_user,1,1,0,0 +access_sf_workpiece_delivery_group_sf_order_user,sf_workpiece_delivery_group_sf_order_user,model_sf_workpiece_delivery,sf_base.group_sf_order_user,1,1,1,0 access_sf_workpiece_delivery_group_sf_equipment_user,sf_workpiece_delivery_group_sf_equipment_user,model_sf_workpiece_delivery,sf_base.group_sf_equipment_user,1,1,0,0 access_sf_workpiece_delivery_manager,sf_workpiece_delivery,model_sf_workpiece_delivery,sf_base.group_sf_mrp_manager,1,1,0,0 diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml index 7fdf390d..8c9cb3db 100644 --- a/sf_manufacturing/views/mrp_workorder_view.xml +++ b/sf_manufacturing/views/mrp_workorder_view.xml @@ -144,8 +144,7 @@