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 35f0f3e2..306142d4 100644 --- a/jikimo_frontend/static/src/js/custom_form_status_indicator.js +++ b/jikimo_frontend/static/src/js/custom_form_status_indicator.js @@ -5,6 +5,7 @@ import {patch} from '@web/core/utils/patch'; import {_t} from "@web/core/l10n/translation"; import {FormStatusIndicator} from "@web/views/form/form_status_indicator/form_status_indicator"; import {ListRenderer} from "@web/views/list/list_renderer"; +import {StatusBarField} from "@web/views/fields/statusbar/statusbar_field"; import {Field} from "@web/views/fields/field"; @@ -150,6 +151,37 @@ patch(ListRenderer.prototype, 'jikimo_frontend.ListRenderer', { } }) + +// 根据进度条设置水印 +const statusbar_params = { + '已完工': 'bg-primary', + '完成': 'bg-primary', + '采购订单': 'bg-primary', + '作废': 'bg-danger', + '封存(报废)': 'bg-danger', +} +patch(StatusBarField.prototype, 'jikimo_frontend.StatusBarField', { + setup() { + owl.onMounted(this.ribbons); + return this._super(...arguments); + }, + ribbons() { + try { + const dom = $('.o_form_sheet.position-relative') + const status = statusbar_params[this.currentName] + if(status && dom.length) { + dom.prepend(`
+
+ ${this.currentName} +
+
`) + } + } catch (e) { + console.log(e) + } + } +}) + $(function () { document.addEventListener('click', function () { const dom = $('.o_form_status_indicator_buttons ') diff --git a/jikimo_frontend/static/src/scss/custom_style.scss b/jikimo_frontend/static/src/scss/custom_style.scss index d3a44da4..9893b71b 100644 --- a/jikimo_frontend/static/src/scss/custom_style.scss +++ b/jikimo_frontend/static/src/scss/custom_style.scss @@ -490,5 +490,5 @@ div:has(.o_required_modifier) > label::before { transform: translateY(-50%); } .o_list_renderer .o_list_table tfoot .o_list_number { - text-align: left; + text-align: left !important; } \ No newline at end of file diff --git a/sf_base/controllers/controllers.py b/sf_base/controllers/controllers.py index ca600580..71ed8f94 100644 --- a/sf_base/controllers/controllers.py +++ b/sf_base/controllers/controllers.py @@ -8,7 +8,7 @@ from odoo.http import request class Manufacturing_Connect(http.Controller): - @http.route('/AutoDeviceApi/MachineToolGroup', type='json', auth='none', methods=['GET', 'POST'], csrf=False, + @http.route('/AutoDeviceApi/MachineToolGroup', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False, cors="*") def get_maintenance_tool_groups_Info(self, **kw): """ diff --git a/sf_manufacturing/controllers/controllers.py b/sf_manufacturing/controllers/controllers.py index b7d3af13..c3531f76 100644 --- a/sf_manufacturing/controllers/controllers.py +++ b/sf_manufacturing/controllers/controllers.py @@ -473,7 +473,7 @@ class Manufacturing_Connect(http.Controller): logging.info('DeviceId:%s' % ret['DeviceId']) workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search( [('feeder_station_start_id.name', '=', ret['DeviceId']), - ('status', '=', '待配送')], limit=1, order='id asc') + ('status', '=', '已配送'), ('type', '=', '上产线')], order='id asc') if workpiece_delivery: for wd in workpiece_delivery: logging.info('wd.production_id:%s' % wd.production_id.name) @@ -482,7 +482,7 @@ class Manufacturing_Connect(http.Controller): wd.production_id.write({'production_line_state': '已上产线'}) wd.write({'production_line_state': '已上产线'}) else: - res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该DeviceId没有对应的工件配送数据'} + res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该DeviceId没有对应的已配送工件数据'} else: res = {'Succeed': False, 'ErrorCode': 201, 'Error': '未传DeviceId字段'} except Exception as e: @@ -507,26 +507,16 @@ 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_id.name', '=', ret['DeviceId']), - ('status', '=', '待配送')], limit=1, order='id asc') + [('feeder_station_start_id.name', '=', ret['DeviceId']), + ('status', '=', '已配送'), ('type', '=', '下产线')], order='id asc') if workpiece_delivery: for wd in workpiece_delivery: 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_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() + wd._delivery_avg() logging.info('agv下发下产线任务已配送') else: diff --git a/sf_manufacturing/controllers/workpiece.py b/sf_manufacturing/controllers/workpiece.py index fcdcf606..b204cbc7 100644 --- a/sf_manufacturing/controllers/workpiece.py +++ b/sf_manufacturing/controllers/workpiece.py @@ -24,10 +24,17 @@ class Workpiece(http.Controller): if 'reqCode' in ret: if 'method' in ret: if ret['method'] == 'end': + logging.info('backfeed-ret:%s' % ret['reqCode'].rsplit('-', 1)[0]) workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search( - [('production_id.name', '=', ret['reqCode']), ('agv_task_code'), '=', ret['taskCode']]) + [('production_id.name', '=', ret['reqCode'].rsplit('-', 1)[0]), ('agv_task_code'), '=', + ret['taskCode']]) if workpiece_delivery: workpiece_delivery.write({'status': '已配送', 'task_completion_time': ret['reqTime']}) + if workpiece_delivery.type == '下产线': + workpiece_delivery_clear = request.env['sf.workpiece.delivery'].sudo().search( + [('production_id.name', '=', ret['reqCode']), ('type', '=', '运送空料架')]) + if workpiece_delivery_clear: + workpiece_delivery_clear._delivery_avg() else: res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该reqCode暂未查到对应的工件配送记录'} else: diff --git a/sf_manufacturing/models/agv_setting.py b/sf_manufacturing/models/agv_setting.py index 22c486d1..70075285 100644 --- a/sf_manufacturing/models/agv_setting.py +++ b/sf_manufacturing/models/agv_setting.py @@ -1,4 +1,6 @@ # -*- coding: utf-8 -*- +import requests +import logging from odoo import fields, models @@ -13,6 +15,23 @@ class AgvSetting(models.Model): ('占用', '占用'), ('空闲', '空闲')], string='状态') divide_the_work = fields.Char('主要分工') + active = fields.Boolean('有效', default=True) + + def update_site_state(self): + # 调取中控的接驳站接口并修改对应站点的状态 + config = self.env['res.config.settings'].get_values() + # token = sf_sync_config['token'Ba F2CF5DCC-1A00-4234-9E95-65603F70CC8A] + headers = {'Authorization': config['center_control_Authorization']} + center_control_url = config['center_control_url'] + "/AutoDeviceApi/GetAgvStationState" + center_control_r = requests.get(center_control_url, params={}, headers=headers) + ret = center_control_r.json() + logging.info('工件配送-请求中控站点信息:%s' % ret) + datas = ret['Datas'] + for item in self: + for da in datas: + if da['DeviceId'] == item.name: + if da['AtHome'] is True: + item.state = '占用' class AgvTaskRoute(models.Model): diff --git a/sf_manufacturing/models/mrp_workorder.py b/sf_manufacturing/models/mrp_workorder.py index 2ce9a2f6..6f0d8872 100644 --- a/sf_manufacturing/models/mrp_workorder.py +++ b/sf_manufacturing/models/mrp_workorder.py @@ -478,12 +478,19 @@ class ResMrpWorkOrder(models.Model): 'date_planned_finished': False, 'duration_expected': duration_expected, 'duration': 0, - 'workpiece_delivery_ids': False if not route.routing_type == '装夹预调' else self.env[ - 'sf.workpiece.delivery'].create( - {'production_id': production.id}) + 'workpiece_delivery_ids': False if not route.routing_type == '装夹预调' else self._json_workpiece_delivery_list( + production) }] return workorders_values_str + def _json_workpiece_delivery_list(self, production): + return [ + [0, '', {'production_id': production.id, 'type': '上产线', 'delivery_num': '%s-%s' % (production.name, 1)}], + [0, '', {'production_id': production.id, 'type': '下产线', 'delivery_num': '%s-%s' % (production.name, 2)}], + [0, '', + {'production_id': production.id, 'type': '运送空料架', 'delivery_num': '%s-%s' % (production.name, 3)}], + ] + # 拼接工单对象属性值(表面工艺) def _json_workorder_surface_process_str(self, production, route, process_parameter, supplier_id): workorders_values_str = [0, '', { @@ -977,7 +984,7 @@ class SfWorkOrderBarcodes(models.Model): # [('routing_type', '=', '装夹预调'), ('production_id', '=', self.production_id.id)]) workorder_old = self.env['mrp.workorder'].search([('rfid_code', '=', barcode)]) if workorder_old: - raise UserError('该托盘已绑定工件,请先解除绑定!!!') + raise UserError('该托盘已绑定【%s】制造订单,请先解除绑定!!!' % workorder_old.production_id.name) if workorder: if workorder.routing_type == '装夹预调': if workorder.state in ['done']: @@ -1094,6 +1101,7 @@ class WorkPieceDelivery(models.Model): _name = "sf.workpiece.delivery" _description = '工件配送' + delivery_num = fields.Char('工件配送编码') workorder_id = fields.Many2one('mrp.workorder', string='工单', readonly=True) production_id = fields.Many2one('mrp.production', string='制造订单', readonly=True) production_line_id = fields.Many2one('sf.production.line', compute='_compute_production_line_id', @@ -1106,6 +1114,8 @@ class WorkPieceDelivery(models.Model): feeder_station_destination_id = fields.Many2one('sf.agv.site', '目的接驳站') task_delivery_time = fields.Datetime('任务下发时间') task_completion_time = fields.Datetime('任务完成时间') + type = fields.Selection( + [('上产线', '上产线'), ('下产线', '下产线'), ('运送空料架', '运送空料架')], string='类型') delivery_duration = fields.Float('配送时长', compute='_compute_delivery_duration') status = fields.Selection( [('待下发', '待下发'), ('待配送', '待配送'), ('已配送', '已配送')], string='状态', @@ -1146,6 +1156,9 @@ class WorkPieceDelivery(models.Model): # 配送至avg小车 def _delivery_avg(self): + agv_site = self.env['sf.agv.site'].search([]) + # if agv_site: + # agv_site.update_site_state() config = self.env['res.config.settings'].get_values() positionCode_Arr = [] if self.feeder_station_start_id: @@ -1158,14 +1171,14 @@ class WorkPieceDelivery(models.Model): 'positionCode': self.feeder_station_destination_id.name, 'code': '00' }) - res = {'reqCode': self.production_id.name, 'reqTime': '', 'clientCode': '', 'tokenCode': '', + res = {'reqCode': self.delivery_num, 'reqTime': '', 'clientCode': '', 'tokenCode': '', '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' + # 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'} diff --git a/sf_manufacturing/models/product_template.py b/sf_manufacturing/models/product_template.py index d766629c..16ea429a 100644 --- a/sf_manufacturing/models/product_template.py +++ b/sf_manufacturing/models/product_template.py @@ -7,8 +7,8 @@ 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): diff --git a/sf_manufacturing/wizard/workpiece_delivery_views.xml b/sf_manufacturing/wizard/workpiece_delivery_views.xml index 34625878..83cfb89f 100644 --- a/sf_manufacturing/wizard/workpiece_delivery_views.xml +++ b/sf_manufacturing/wizard/workpiece_delivery_views.xml @@ -5,18 +5,11 @@ sf.workpiece.delivery.wizard
- - - -
- - 确认上述信息正确无误. -
+
是否确定配送?
-
diff --git a/sf_manufacturing/wizard/workpiece_delivery_wizard.py b/sf_manufacturing/wizard/workpiece_delivery_wizard.py index 1de3e84c..ab7f4556 100644 --- a/sf_manufacturing/wizard/workpiece_delivery_wizard.py +++ b/sf_manufacturing/wizard/workpiece_delivery_wizard.py @@ -11,8 +11,6 @@ class WorkpieceDeliveryWizard(models.TransientModel): delivery_id = fields.Many2one('sf.workpiece.delivery', string='配送') workorder_id = fields.Many2one('mrp.workorder', string='工单') - route_id = fields.Many2one('sf.agv.task.route', '任务路线') - is_ok = fields.Boolean('确认上述信息正确无误.') def confirm(self): if self.workorder_id: diff --git a/sf_mrs_connect/controllers/controllers.py b/sf_mrs_connect/controllers/controllers.py index 6efc4b82..44a65200 100644 --- a/sf_mrs_connect/controllers/controllers.py +++ b/sf_mrs_connect/controllers/controllers.py @@ -29,8 +29,8 @@ class Sf_Mrs_Connect(http.Controller): request.env.ref("base.user_admin")).search([('name', '=', ret['production_order_no'])]) logging.info('制造订单号:%s' % cnc_production.name) if cnc_production: - if ret['glb_file']: - cnc_production.glb_file = base64.b64encode(ret['glb_file']) + # if ret['glb_file']: + # cnc_production.glb_file = base64.b64encode(ret['glb_file']) # 拉取所有加工面的程序文件 # i = 1 diff --git a/sf_mrs_connect/models/res_config_setting.py b/sf_mrs_connect/models/res_config_setting.py index ef2d93d8..035b10a0 100644 --- a/sf_mrs_connect/models/res_config_setting.py +++ b/sf_mrs_connect/models/res_config_setting.py @@ -17,6 +17,7 @@ class ResConfigSettings(models.TransientModel): default='http://172.16.10.114:8182/rcms/services/rest/hikRpcService/genAgvSchedulingTask') center_control_url = fields.Char(string='中控访问地址', default='http://172.16.21.50:8001') + center_control_Authorization = fields.Char(string='中控访问认证') wbcode = fields.Char('地码') agv_code = fields.Char(string='agv编号') task_type_no = fields.Char('任务单类型编号') @@ -102,6 +103,7 @@ class ResConfigSettings(models.TransientModel): wbcode = config.get_param('wbcode', default='') agv_code = config.get_param('agv_code', default='') center_control_url = config.get_param('center_control_url', default='') + center_control_Authorization = config.get_param('center_control_Authorization', default='') ftp_host = config.get_param('ftp_host', default='') ftp_port = config.get_param('ftp_port', default='') ftp_user = config.get_param('ftp_user', default='') @@ -115,6 +117,7 @@ class ResConfigSettings(models.TransientModel): wbcode=wbcode, agv_code=agv_code, center_control_url=center_control_url, + center_control_Authorization=center_control_Authorization, ftp_host=ftp_host, ftp_port=ftp_port, ftp_user=ftp_user, @@ -132,6 +135,7 @@ class ResConfigSettings(models.TransientModel): ir_config.set_param("wbcode", self.wbcode or "") ir_config.set_param("agv_code", self.agv_code or "") ir_config.set_param("center_control_url", self.center_control_url or "") + ir_config.set_param("center_control_Authorization", self.center_control_Authorization or "") ir_config.set_param("ftp_host", self.ftp_host or "") ir_config.set_param("ftp_port", self.ftp_port or "") ir_config.set_param("ftp_user", self.ftp_user or "") diff --git a/sf_mrs_connect/views/res_config_settings_views.xml b/sf_mrs_connect/views/res_config_settings_views.xml index 0d1ccc3e..2be92365 100644 --- a/sf_mrs_connect/views/res_config_settings_views.xml +++ b/sf_mrs_connect/views/res_config_settings_views.xml @@ -106,6 +106,10 @@