diff --git a/jikimo_frontend/static/src/js/custom_form_status_indicator.js b/jikimo_frontend/static/src/js/custom_form_status_indicator.js index de50eddc..35f0f3e2 100644 --- a/jikimo_frontend/static/src/js/custom_form_status_indicator.js +++ b/jikimo_frontend/static/src/js/custom_form_status_indicator.js @@ -131,6 +131,22 @@ patch(ListRenderer.prototype, 'jikimo_frontend.ListRenderer', { dom.addClass('addRequired') } }) + try { + const dom = this.tableRef.el + if(dom ) { + const tfoot = $(dom).children('tfoot') + const tbooy = $(dom).children('tbody') + if(tfoot.length) { + const tfoot_tr = tfoot.children().eq(0) + const tbody_tr = tbooy.children().eq(0) + if(tfoot_tr.children().length < tbody_tr.children().length) { + tfoot_tr.prepend('') + } + } + } + } catch (e) { + console.log(e) + } } }) diff --git a/jikimo_frontend/static/src/scss/custom_style.scss b/jikimo_frontend/static/src/scss/custom_style.scss index 3c106665..d3a44da4 100644 --- a/jikimo_frontend/static/src/scss/custom_style.scss +++ b/jikimo_frontend/static/src/scss/custom_style.scss @@ -488,4 +488,7 @@ div:has(.o_required_modifier) > label::before { left: 0; top: 50%; transform: translateY(-50%); +} +.o_list_renderer .o_list_table tfoot .o_list_number { + text-align: left; } \ No newline at end of file diff --git a/sf_base/security/ir.model.access.csv b/sf_base/security/ir.model.access.csv index c0f53f98..3795e69b 100644 --- a/sf_base/security/ir.model.access.csv +++ b/sf_base/security/ir.model.access.csv @@ -9,16 +9,25 @@ access_sf_machine_brand_tags,sf_machine_brand_tags,model_sf_machine_brand_tags,b access_sf_machine_brand_tags_admin,sf_machine_brand_tags_admin,model_sf_machine_brand_tags,base.group_system,1,1,1,0 access_sf_machine_control_system,sf_machine_control_system,model_sf_machine_control_system,base.group_user,1,1,1,0 access_sf_machine_control_system_admin,sf_machine_control_system_admin,model_sf_machine_control_system,base.group_system,1,1,1,0 +access_sf_production_process_group_sale_director,sf_production_process_group_sale_director,model_sf_production_process,sf_base.group_sale_director,1,0,0,0 +access_sf_production_process_group_sale_salemanager,sf_production_process_group_sale_salemanager,model_sf_production_process,sf_base.group_sale_salemanager,1,0,0,0 access_sf_production_process,sf_production_process,model_sf_production_process,base.group_user,1,1,1,0 access_sf_production_process_admin,sf_production_process_admin,model_sf_production_process,base.group_system,1,1,1,0 access_sf_production_materials,sf_production_materials,model_sf_production_materials,base.group_user,1,1,1,0 +access_sf_production_materials_group_sale_director,sf_production_materials_group_sale_director,model_sf_production_materials,sf_base.group_sale_director,1,0,0,0 +access_sf_production_materials_group_sale_salemanager,sf_production_materials_group_sale_salemanager,model_sf_production_materials,sf_base.group_sale_salemanager,1,0,0,0 + access_sf_production_materials_admin,sf_production_materials_admin,model_sf_production_materials,base.group_system,1,1,1,0 access_sf_materials_model,sf_materials_model,model_sf_materials_model,base.group_user,1,1,1,0 access_sf_materials_model_admin,sf_materials_model_admin,model_sf_materials_model,base.group_system,1,1,1,0 access_sf_supplier_sort,sf_supplier_sort,model_sf_supplier_sort,base.group_user,1,1,1,0 access_sf_supplier_sort_admin,sf_supplier_sort_admin,model_sf_supplier_sort,base.group_system,1,1,1,0 access_sf_production_process_parameter,sf_production_process_parameter,model_sf_production_process_parameter,base.group_user,1,1,1,0 +access_sf_production_process_parameter_group_sale_director,sf_production_process_parameter_group_sale_director,model_sf_production_process_parameter,sf_base.group_sale_director,1,0,0,0 +access_sf_production_process_parameter_group_sale_salemanager,sf_production_process_parameter_group_sale_salemanager,model_sf_production_process_parameter,sf_base.group_sale_salemanager,1,0,0,0 + + access_sf_production_process_parameter_group_plan_director,sf_production_process_parameter_group_plan_director,model_sf_production_process_parameter,sf_base.group_plan_director,1,0,0,0 access_sf_production_process_parameter_group_purchase_director,sf_production_process_parameter_group_purchase_director,model_sf_production_process_parameter,sf_base.group_purchase_director,1,0,0,0 access_sf_production_process_parameter_group_sale_director,sf_production_process_parameter_group_sale_director,model_sf_production_process_parameter,sf_base.group_sale_director,1,0,0,0 @@ -101,6 +110,10 @@ access_sf_production_materials_group_plan_director,sf_production_materials_group access_sf_production_materials_group_purchase_director,sf_production_materials_group_purchase_director,model_sf_production_materials,sf_base.group_purchase_director,1,1,0,0 access_sf_production_materials_group_sale_director,sf_production_materials_group_sale_director,model_sf_production_materials,sf_base.group_sale_director,1,1,0,0 access_sf_materials_model,sf_materials_model,model_sf_materials_model,sf_base.group_sf_mrp_user,1,0,0,0 +access_sf_materials_model_group_sale_salemanager,sf_materials_model_group_sale_salemanager,model_sf_materials_model,sf_base.group_sale_salemanager,1,0,0,0 +access_sf_materials_model_group_sale_director,sf_materials_model_group_sale_director,model_sf_materials_model,sf_base.group_sale_director,1,0,0,0 + + access_sf_materials_model_group_plan_director,sf_materials_model_group_plan_director,model_sf_materials_model,sf_base.group_plan_director,1,0,0,0 access_sf_materials_model_group_purchase_director,sf_materials_model_group_purchase_director,model_sf_materials_model,sf_base.group_purchase_director,1,0,0,0 access_sf_materials_model_group_sale_director,sf_materials_model_group_sale_director,model_sf_materials_model,sf_base.group_sale_director,1,0,0,0 diff --git a/sf_dlm_management/views/product_template_management_view.xml b/sf_dlm_management/views/product_template_management_view.xml index 453de6a3..94fc6b45 100644 --- a/sf_dlm_management/views/product_template_management_view.xml +++ b/sf_dlm_management/views/product_template_management_view.xml @@ -10,6 +10,7 @@ + diff --git a/sf_manufacturing/__manifest__.py b/sf_manufacturing/__manifest__.py index 6a122097..1c49c88b 100644 --- a/sf_manufacturing/__manifest__.py +++ b/sf_manufacturing/__manifest__.py @@ -24,6 +24,7 @@ 'views/mrp_workcenter_views.xml', 'views/mrp_workorder_view.xml', 'views/model_type_view.xml', + 'views/agv_setting_views.xml', 'views/sf_maintenance_equipment.xml', ], diff --git a/sf_manufacturing/controllers/controllers.py b/sf_manufacturing/controllers/controllers.py index 333c57f4..64b51b50 100644 --- a/sf_manufacturing/controllers/controllers.py +++ b/sf_manufacturing/controllers/controllers.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import logging import json +from datetime import datetime from odoo import http from odoo.http import request @@ -114,7 +115,7 @@ class Manufacturing_Connect(http.Controller): logging.info('RfidCode:%s' % ret['RfidCode']) if 'RfidCode' in ret: workorder = request.env['mrp.workorder'].sudo().search( - [('routing_type', '=', '装夹预调'), ('rfid_code', '=', ret['RfidCode'])]) + [('routing_type', '=', '装夹预调'), ('rfid_code', '=', ret['RfidCode'])], limit=1, order='id asc') if workorder: for item in workorder: if item.material_center_point: @@ -122,8 +123,8 @@ class Manufacturing_Connect(http.Controller): res['Datas'].append({ 'XOffset': 0 if not item.material_center_point else offset[0], 'YOffset': 0 if not item.material_center_point else offset[1], - 'ZOffet': 0 if not item.material_center_point else offset[2], - 'COffset': 0 if not item.X_deviation_angle else item.X_deviation_angle, + 'ZOffset': 0 if not item.material_center_point else offset[2], + 'COffset': 0, 'Coordinate': 'G54' }) else: @@ -432,14 +433,15 @@ class Manufacturing_Connect(http.Controller): if 'DeviceId' in ret: logging.info('DeviceId:%s' % ret['DeviceId']) workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search( - [('feeder_station_destination', '=', ret['DeviceId'])]) + [('feeder_station_start_id.name', '=', ret['DeviceId']), + ('status', '=', '待配送')], limit=1, order='id asc') if workpiece_delivery: for wd in workpiece_delivery: - logging.info('wd.workorder_id:%s' % wd.workorder_id.name) + logging.info('wd.production_id:%s' % wd.production_id.name) if wd.workorder_id.state == 'done' and wd.production_id.production_line_state == '待上产线': - logging.info('wd.production_id:%s' % wd.production_id.name) logging.info('wd.production_line_state:%s' % wd.production_id.production_line_state) wd.production_id.write({'production_line_state': '已上产线'}) + wd.write({'production_line_state': '已上产线'}) else: res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该DeviceId没有对应的工件配送数据'} else: @@ -466,14 +468,28 @@ class Manufacturing_Connect(http.Controller): if 'DeviceId' in ret: logging.info('DeviceId:%s' % ret['DeviceId']) workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search( - [('feeder_station_destination', '=', ret['DeviceId'])]) + [('feeder_station_destination_id.name', '=', ret['DeviceId']), + ('status', '=', '待配送')], limit=1, order='id asc') if workpiece_delivery: for wd in workpiece_delivery: - logging.info('wd.workorder_id:%s' % wd.workorder_id.name) + logging.info('wd.production_id:%s' % wd.production_id.name) if wd.workorder_id.state == 'done' and wd.production_id.production_line_state == '已上产线': - logging.info('wd.production_id:%s' % wd.production_id.name) logging.info('wd.production_line_state:%s' % wd.production_id.production_line_state) + workpiece_delivery_off = request.env['sf.workpiece.delivery'].sudo().create({ + 'production_id': wd.production_id.id, + 'feeder_station_start_id': workpiece_delivery.feeder_station_start_id.id, + 'feeder_station_destination_id': '', + 'workorder_id': workpiece_delivery.workorder_id.id, + 'workpiece_code': workpiece_delivery.workpiece_code, + 'production_line_id': workpiece_delivery.production_line_id.id, + 'task_delivery_time': datetime.now(), + 'production_line_state': '已下产线' + }) wd.production_id.write({'production_line_state': '已下产线'}) + logging.info('开始向agv下发下产线任务') + workpiece_delivery_off._delivery_avg() + logging.info('agv下发下产线任务已配送') + else: res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该DeviceId没有对应的工件配送数据'} else: @@ -482,3 +498,35 @@ class Manufacturing_Connect(http.Controller): res = {'Succeed': False, 'ErrorCode': 202, 'Error': e} logging.info('AGVDownProduct error:%s' % e) return json.JSONEncoder().encode(res) + + @http.route('/AutoDeviceApi/EquipmentBaseCoordinate', type='json', auth='none', methods=['GET', 'POST'], csrf=False, + cors="*") + def PutEquipmentBaseCoordinate(self, **kw): + """ + 获取机床基坐标 + :param kw: + :return: + """ + logging.info('PutEquipmentBaseCoordinate:%s' % kw) + try: + res = {'Succeed': True} + datas = request.httprequest.data + ret = json.loads(datas) + if 'DeviceId' in ret: + equipment = request.env['maintenance.equipment'].sudo().search('name', '=', ret['DeviceId']) + if equipment: + equipment.sudo().write({ + 'base_coordinate_fixture_model_id': ret['base_coordinate_fixture_model_id'], + 'base_coordinate_g_coordinate': ret['base_coordinate_g_coordinate'], + 'base_coordinate_x': ret['base_coordinate_x'], + 'base_coordinate_y': ret['base_coordinate_y'], + 'base_coordinate_z': ret['base_coordinate_z'], + }) + else: + res = {'Succeed': False, 'ErrorCode': 203, 'Error': 'DeviceId为%s的设备不存在!' % ret['DeviceId']} + else: + res = {'Succeed': False, 'ErrorCode': 201, 'Error': '未传DeviceId字段'} + except Exception as e: + res = {'Succeed': False, 'ErrorCode': 202, 'Error': e} + logging.info('AGVDownProduct error:%s' % e) + return json.JSONEncoder().encode(res) diff --git a/sf_manufacturing/controllers/workpiece.py b/sf_manufacturing/controllers/workpiece.py index e2f60421..fcdcf606 100644 --- a/sf_manufacturing/controllers/workpiece.py +++ b/sf_manufacturing/controllers/workpiece.py @@ -25,7 +25,7 @@ class Workpiece(http.Controller): if 'method' in ret: if ret['method'] == 'end': workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search( - [('production_id.name', '=', ret['reqCode'])]) + [('production_id.name', '=', ret['reqCode']), ('agv_task_code'), '=', ret['taskCode']]) if workpiece_delivery: workpiece_delivery.write({'status': '已配送', 'task_completion_time': ret['reqTime']}) else: diff --git a/sf_manufacturing/models/__init__.py b/sf_manufacturing/models/__init__.py index 3ca83b27..3de23ef3 100644 --- a/sf_manufacturing/models/__init__.py +++ b/sf_manufacturing/models/__init__.py @@ -8,3 +8,4 @@ from . import mrp_routing_workcenter from . import stock from . import res_user from . import production_line_base +from . import agv_setting diff --git a/sf_manufacturing/models/agv_setting.py b/sf_manufacturing/models/agv_setting.py new file mode 100644 index 00000000..22c486d1 --- /dev/null +++ b/sf_manufacturing/models/agv_setting.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +from odoo import fields, models + + +class AgvSetting(models.Model): + _name = 'sf.agv.site' + _description = 'agv站点' + + number = fields.Integer('序号') + name = fields.Char('位置编号') + owning_region = fields.Char('所属区域') + state = fields.Selection([ + ('占用', '占用'), + ('空闲', '空闲')], string='状态') + divide_the_work = fields.Char('主要分工') + + +class AgvTaskRoute(models.Model): + _name = 'sf.agv.task.route' + _description = 'agv任务路线' + + name = fields.Char('名称') + type = fields.Selection([ + ('F01', '搬运'), ], string='类型', default="F01") + start_site_id = fields.Many2one('sf.agv.site', '起点接驳站位置编号') + end_site_id = fields.Many2one('sf.agv.site', '终点接驳站位置编号') + destination_production_line_id = fields.Many2one('sf.production.line', '目的生产线') + priority = fields.Selection([ + ('0', '正常'), + ('1', '低'), + ('2', '中'), + ('3', '高'), + ('4', '紧急'), + ], string='优先级', default='0') + active = fields.Boolean('有效', default=True) diff --git a/sf_manufacturing/models/mrp_production.py b/sf_manufacturing/models/mrp_production.py index 3c6cc6da..fccc4301 100644 --- a/sf_manufacturing/models/mrp_production.py +++ b/sf_manufacturing/models/mrp_production.py @@ -74,6 +74,8 @@ class MrpProduction(models.Model): # 上传零件图纸 part_drawing = fields.Binary('零件图纸') + manual_quotation = fields.Boolean('人工编程', default=False, readonly=True) + @api.depends( 'move_raw_ids.state', 'move_raw_ids.quantity_done', 'move_finished_ids.state', 'workorder_ids.state', 'product_qty', 'qty_producing', 'schedule_state') @@ -152,6 +154,15 @@ class MrpProduction(models.Model): # cnc程序获取 def fetchCNC(self): 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])]) + programme_way = False + if cnc.manual_quotation is True: + programme_way = 'manual operation' + else: + programme_way = 'auto' + 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, @@ -166,8 +177,9 @@ class MrpProduction(models.Model): 'embryo_height': cnc.product_id.bom_ids.bom_line_ids.product_id.height, 'embryo_width': cnc.product_id.bom_ids.bom_line_ids.product_id.width, 'order_no': cnc.origin, - 'model_order_no': cnc.product_id.default_code.rsplit(' -', 1)[0], + 'model_order_no': cnc.product_id.default_code, 'user': cnc.env.user.name, + 'programme_way': programme_way, 'model_file': '' if not cnc.product_id.model_file else base64.b64encode( cnc.product_id.model_file).decode('utf-8') } diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 110de50d..63c66577 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -46,6 +46,8 @@ class ResMrpWorkOrder(models.Model): ], string="工序类型") results = fields.Char('结果') + manual_quotation = fields.Boolean('人工编程', default=False, readonly=True) + @api.onchange('users_ids') def get_user_permissions(self): uid = self.env.uid @@ -414,21 +416,24 @@ class ResMrpWorkOrder(models.Model): def button_workpiece_delivery(self): if self.routing_type == '装夹预调': for item in self.workpiece_delivery_ids: - if not item.feeder_station_start: - raise UserError('【工件配送】明细中请输入起点接驳站') + if not item.route_id: + raise UserError('【工件配送】明细中请选择【任务路线】') # if not item.workpiece_code: # raise UserError('请对【同运工件】进行扫描') else: - if item.status == '待下发': - return { - 'name': _('确认'), - 'type': 'ir.actions.act_window', - 'view_mode': 'form', - 'res_model': 'sf.workpiece.delivery.wizard', - 'target': 'new', - 'context': { - 'default_workorder_id': self.id, - }} + if self.cnc_program_down_state == '已下发': + if item.status == '待下发': + return { + 'name': _('确认'), + 'type': 'ir.actions.act_window', + 'view_mode': 'form', + 'res_model': 'sf.workpiece.delivery.wizard', + 'target': 'new', + 'context': { + 'default_workorder_id': self.id, + }} + else: + raise UserError(_("该制造订单还未下发CNC程序单,无法进行工件配送")) # 拼接工单对象属性值 def json_workorder_str(self, k, production, route): @@ -666,47 +671,6 @@ class ResMrpWorkOrder(models.Model): else: self.results = '合格' - # cnc程序获取 - def fetchCNC(self): - try: - cnc = self.env['mrp.workorder'].search( - [('routing_type', '=', 'CNC加工'), ('production_id', '=', self.production_id.id)], limit=1) - res = {'model_code': '' if not cnc.product_id.model_code else cnc.product_id.model_code, - 'production_no': self.production_id.name, - 'machine_tool_code': cnc.workcenter_id.equipment_id.code, - 'material_code': cnc.env['sf.production.materials'].search( - [('id', '=', cnc.product_id.materials_id.id)]).materials_no, - 'material_type_code': cnc.env['sf.materials.model'].search( - [('id', '=', cnc.product_id.materials_type_id.id)]).materials_no, - 'machining_processing_panel': cnc.product_id.model_processing_panel, - 'machining_precision': cnc.product_id.model_machining_precision, - 'embryo_long': cnc.product_id.bom_ids.bom_line_ids.product_id.length, - 'embryo_height': cnc.product_id.bom_ids.bom_line_ids.product_id.height, - 'embryo_width': cnc.product_id.bom_ids.bom_line_ids.product_id.width, - 'order_no': cnc.production_id.origin, - 'model_order_no': cnc.product_id.default_code.rsplit(' -', 1)[0], - 'user': self.env.user.name, - '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) - 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' - config_url = configsettings['sf_url'] + url - # res_str = json.dumps(res) - ret = requests.post(config_url, json={}, data=res, headers=config_header) - ret = ret.json() - logging.info('fetchCNC-ret:%s' % ret) - if ret['status'] == 1: - self.write( - {'programming_no': ret['programming_no'], 'programming_state': '编程中', 'work_state': '编程中'}) - else: - raise UserError(ret['message']) - except Exception as e: - logging.info('fetchCNC error:%s' % e) - raise UserError("cnc程序获取编程单失败,请联系管理员") - def json_workorder_str1(self, k, production, route): workorders_values_str = [0, '', { 'product_uom_id': production.product_uom_id.id, @@ -839,7 +803,7 @@ class ResMrpWorkOrder(models.Model): production_no_ftp = reportpath.split('/') production_no = workorder.production_id.name.replace('/', '_') # ftp地址 - remotepath = os.path.join('/', production_no_ftp[1], 'detection') + remotepath = os.path.join('/NC', production_no_ftp[1], 'detection') logging.info('ftp地址:%s' % remotepath) if reportpath.find(production_no) != -1: # 服务器内临时地址 @@ -918,7 +882,7 @@ class CNCprocessing(models.Model): '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', '') + 'program_path': program_path.replace('/tmp', '/home/ftp/ftp_root/NC') }) cnc_processing.get_cnc_processing_file(program_path_tmp, cnc_processing, program_path) # cnc_workorder.state = 'done' @@ -957,7 +921,7 @@ class CNCprocessing(models.Model): # 将FTP的nc文件下载到临时目录 def download_file_tmp(self, production_no, processing_panel): - remotepath = os.path.join('/', production_no, 'return', processing_panel) + remotepath = os.path.join('/NC', production_no, 'return', processing_panel) serverdir = os.path.join('/tmp', production_no, 'return', processing_panel) 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'], @@ -1010,9 +974,9 @@ class SfWorkOrderBarcodes(models.Model): workorder = self.env['mrp.workorder'].browse(self.ids) # workorder = self.env['mrp.workorder'].search( # [('routing_type', '=', '装夹预调'), ('production_id', '=', self.production_id.id)]) - # workorder_old = self.env['mrp.workorder'].search([('rfid_code', '=', barcode)]) - # if workorder_old: - # raise UserError('该托盘已绑定工件,请先解除绑定!!!') + workorder_old = self.env['mrp.workorder'].search([('rfid_code', '=', barcode)]) + if workorder_old: + raise UserError('该托盘已绑定工件,请先解除绑定!!!') if workorder: if workorder.routing_type == '装夹预调': if workorder.state in ['done']: @@ -1073,7 +1037,7 @@ class SfWorkOrderBarcodes(models.Model): for item in workorder_rfid: if item.state == "progress": item.write({'rfid_code': barcode}) - # raise UserError('该托盘信息不存在!!!') + raise UserError('该托盘信息不存在!!!') # stock_move_line = self.env['stock.move.line'].search([('lot_name', '=', barcode)]) # if stock_move_line.product_id.categ_type == '夹具': # workorder.write({ @@ -1136,48 +1100,71 @@ class WorkPieceDelivery(models.Model): store=True) plan_start_processing_time = fields.Datetime('计划开始加工时间', readonly=True) workpiece_code = fields.Char('同运工件编码') - feeder_station_start = fields.Char('起点接驳站') - feeder_station_destination = fields.Char('目的接驳站') + route_id = fields.Many2one('sf.agv.task.route', '任务路线') + feeder_station_start_id = fields.Many2one('sf.agv.site', '起点接驳站') + feeder_station_destination_id = fields.Many2one('sf.agv.site', '目的接驳站') task_delivery_time = fields.Datetime('任务下发时间') task_completion_time = fields.Datetime('任务完成时间') delivery_duration = fields.Float('配送时长', compute='_compute_delivery_duration') status = fields.Selection( [('待下发', '待下发'), ('待配送', '待配送'), ('已配送', '已配送')], string='状态', default='待下发') + production_line_state = fields.Selection( + [('待上产线', '待上产线'), ('已上产线', '已上产线'), ('已下产线', '已下产线')], + string='上/下产线', default='待上产线') + cnc_program_down_state = fields.Selection([('待下发', '待下发'), ('已下发', '已下发')], + string='CNC程序下发状态', default='待下发') + agv_task_code = fields.Char('agv任务单号') + + @api.onchange('route_id') + def onchage_route(self): + if self.route_id: + self.feeder_station_start_id = self.route_id.start_site_id + self.feeder_station_destination_id = self.route_id.end_site_id # 工件配送 def button_delivery(self): - if self.status == '待下发': - return { - 'name': _('确认'), - 'type': 'ir.actions.act_window', - 'view_mode': 'form', - 'res_model': 'sf.workpiece.delivery.wizard', - 'target': 'new', - 'context': { - 'default_delivery_id': self.id, - }} + if self.cnc_program_down_state == '待下发': + if self.route_id: + if self.status == '待下发': + return { + 'name': _('确认'), + 'type': 'ir.actions.act_window', + 'view_mode': 'form', + 'res_model': 'sf.workpiece.delivery.wizard', + 'target': 'new', + 'context': { + 'default_delivery_id': self.id, + }} + else: + raise UserError('状态为【待下发】的工件记录可进行配送') + else: + raise UserError('请选择任务路线再进行配送') else: - raise UserError('状态为【待下发】的工件记录可进行配送') + raise UserError(_("该制造订单还未下发CNC程序单,无法进行工件配送")) # 配送至avg小车 def _delivery_avg(self): config = self.env['res.config.settings'].get_values() - agv_site = self.env['res.agv.site'].search([]) positionCode_Arr = [] - if agv_site: - for item in agv_site: - positionCode_Arr.append({ - 'positionCode': item.content, - 'code': item.type - }) + if self.feeder_station_start_id: + positionCode_Arr.append({ + 'positionCode': self.feeder_station_start_id.name, + 'code': '00' + }) + if self.feeder_station_destination_id: + positionCode_Arr.append({ + 'positionCode': self.feeder_station_destination_id.name, + 'code': '00' + }) res = {'reqCode': self.production_id.name, 'reqTime': '', 'clientCode': '', 'tokenCode': '', - 'taskTyp': config['task_type_no'], 'ctnrTyp': '', 'ctnrCode': '', 'wbCode': config['wbcode'], + 'taskTyp': 'F01', 'ctnrTyp': '', 'ctnrCode': '', 'wbCode': config['wbcode'], 'positionCodePath': positionCode_Arr, 'podCode': '', 'podDir': '', 'materialLot': '', 'priority': '', 'taskCode': '', 'agvCode': '', 'materialLot': '', 'data': ''} try: + config['agv_rcs_url'] = 'http://172.16.10.114:8182/rcms/services/rest/hikRpcService/genAgvSchedulingTask' logging.info('AGV请求路径:%s' % config['agv_rcs_url']) logging.info('AGV-json:%s' % res) headers = {'Content-Type': 'application/json'} @@ -1186,14 +1173,15 @@ class WorkPieceDelivery(models.Model): logging.info('config-ret:%s' % ret) if ret['code'] == 0: if self.production_id.name == ret['reqCode']: - self.write({'task_delivery_time': fields.Datetime.now(), 'status': '待配送'}) + self.write( + {'task_delivery_time': fields.Datetime.now(), 'status': '待配送', 'agv_task_code': ret['data']}) else: raise UserError(ret['message']) except Exception as e: logging.info('config-e:%s' % e) raise UserError("工件配送请求agv失败") - @api.depends('production_id.production_line_id') + @api.onchange('production_id.production_line_id') def _compute_production_line_id(self): if self.production_id.production_line_id: self.production_line_id = self.production_id.production_line_id.id diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index f3cba150..d766629c 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -1,14 +1,14 @@ # -*- coding: utf-8 -*- import logging +import requests import base64 import hashlib import os from odoo import models, fields, api, _ from odoo.exceptions import ValidationError from odoo.modules import get_resource_path -from OCC.Extend.DataExchange import read_step_file -from OCC.Extend.DataExchange import write_stl_file - +# from OCC.Extend.DataExchange import read_step_file +# from OCC.Extend.DataExchange import write_stl_file class ResProductMo(models.Model): @@ -522,6 +522,9 @@ class ResProductMo(models.Model): string='注册状态', default='未注册') industry_code = fields.Char('行业编码', readonly=True) + # bfm下单 + manual_quotation = fields.Boolean('人工编程', default=False, readonly=True) + @api.constrains('tool_length') def _check_tool_length_size(self): if self.tool_length > 1000000: @@ -616,6 +619,7 @@ class ResProductMo(models.Model): 'process_parameters_code') else self.get_process_parameters_id(item['process_parameters_code']), 'model_remark': item['remark'], 'default_code': '%s-%s' % (order_number, i), + 'manual_quotation': item['manual_quotation'] or False, 'active': True, } copy_product_id.sudo().write(vals) @@ -889,6 +893,33 @@ class SfMaintenanceEquipmentAndProductTemplate(models.Model): vals.append(res) return vals[0] + base_coordinate_fixture_model_id = fields.Many2one('sf.fixture.model', '基坐标卡盘型号', + domain=[('fixture_material_id', '=', '零点卡盘')]) + base_coordinate_g_coordinate = fields.Char('G坐标') + base_coordinate_x = fields.Float('x轴', digits=(12, 3)) + base_coordinate_y = fields.Float('y轴', digits=(12, 3)) + base_coordinate_z = fields.Float('z轴', digits=(12, 3)) + + # ==========获取机床基坐标接口========== + def get_equipment_base_coordinate(self): + headers = {'Authorization': 'Ba F2CF5DCC-1A00-4234-9E95-65603F70CC8A'} + crea_url = "https://x24467i973.zicp.fun/AutoDeviceApi/EquipmentBaseCoordinate" + params = {"DeviceId": self.name} + r = requests.get(crea_url, params=params, headers=headers) + ret = r.json() + logging.info('register_equipment_tool:%s' % ret) + self.write({ + 'base_coordinate_fixture_model_id': ret['base_coordinate_fixture_model_id'], + 'base_coordinate_g_coordinate': ret['base_coordinate_g_coordinate'], + 'base_coordinate_x': ret['base_coordinate_x'], + 'base_coordinate_y': ret['base_coordinate_y'], + 'base_coordinate_z': ret['base_coordinate_z'], + }) + if ret['Succeed']: + return "机床基坐标获取成功" + else: + raise ValidationError("机床基坐标获取失败") + class SfMaintenanceEquipmentTool(models.Model): _name = 'maintenance.equipment.tool' diff --git a/sf_manufacturing/security/img.png b/sf_manufacturing/security/img.png new file mode 100644 index 00000000..130affd5 Binary files /dev/null and b/sf_manufacturing/security/img.png differ diff --git a/sf_manufacturing/security/ir.model.access.csv b/sf_manufacturing/security/ir.model.access.csv index 8272af30..e8c2449c 100644 --- a/sf_manufacturing/security/ir.model.access.csv +++ b/sf_manufacturing/security/ir.model.access.csv @@ -129,4 +129,7 @@ access_sf_cmm_program_group_plan_dispatch,sf_cmm_program_group_plan_dispatch,mod access_mrp_workcenter_productivity,mrp.workcenter.productivity,mrp.model_mrp_workcenter_productivity,sf_base.group_plan_dispatch,1,0,0,0 access_maintenance_equipment_tool_group_plan_dispatch,maintenance.equipment.tool,sf_manufacturing.model_maintenance_equipment_tool,sf_base.group_plan_dispatch,1,0,0,0 -access_sf_workpiece_delivery_group_plan_dispatch,sf.workpiece.delivery,sf_manufacturing.model_sf_workpiece_delivery,sf_base.group_plan_dispatch,1,0,0,0 \ No newline at end of file +access_sf_workpiece_delivery_group_plan_dispatch,sf.workpiece.delivery,sf_manufacturing.model_sf_workpiece_delivery,sf_base.group_plan_dispatch,1,0,0,0 + +access_sf_agv_site_group_sf_order_user,sf_agv_site_group_sf_order_user,model_sf_agv_site,sf_base.group_sf_order_user,1,1,1,0 +access_sf_agv_task_route_group_sf_order_user,sf_agv_task_route_group_sf_order_user,model_sf_agv_task_route,sf_base.group_sf_order_user,1,1,1,0 \ No newline at end of file diff --git a/sf_manufacturing/views/agv_setting_views.xml b/sf_manufacturing/views/agv_setting_views.xml new file mode 100644 index 00000000..dea85e6a --- /dev/null +++ b/sf_manufacturing/views/agv_setting_views.xml @@ -0,0 +1,59 @@ + + + + + + agv站点 + sf.agv.site + + + + + + + + + + + + + AGV站点 + sf.agv.site + tree + + + + + + + AGV任务路线 + sf.agv.task.route + + + + + + + + + + + + + + AGV任务路线 + sf.agv.task.route + tree + + + + + \ No newline at end of file diff --git a/sf_manufacturing/views/mrp_workorder_view.xml b/sf_manufacturing/views/mrp_workorder_view.xml index 78db99af..6212f5f9 100644 --- a/sf_manufacturing/views/mrp_workorder_view.xml +++ b/sf_manufacturing/views/mrp_workorder_view.xml @@ -211,12 +211,12 @@ - -
-
-
+ + + + + + @@ -430,8 +430,10 @@ - - + + + + @@ -573,7 +575,7 @@ 工件配送 sf.workpiece.delivery - +
@@ -583,11 +585,13 @@ decoration-danger="status == '待配送'"/> - - - - - + + + + + + +
@@ -600,16 +604,19 @@ - + - + + + +
diff --git a/sf_manufacturing/views/sf_maintenance_equipment.xml b/sf_manufacturing/views/sf_maintenance_equipment.xml index b398f994..5ddf59b0 100644 --- a/sf_manufacturing/views/sf_maintenance_equipment.xml +++ b/sf_manufacturing/views/sf_maintenance_equipment.xml @@ -1,23 +1,38 @@ - 设备增加刀具库位table + sf_manufacturing_equipment.form maintenance.equipment - + - - - - - - - - - - + +