1、设备机床新增机床基坐标page页及其基本信息字段,新增主动获取和被动获取基坐标数据中控接口(接口待对接);
This commit is contained in:
@@ -480,3 +480,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)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import logging
|
||||
import requests
|
||||
import base64
|
||||
import hashlib
|
||||
import os
|
||||
@@ -892,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'
|
||||
|
||||
@@ -1,23 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
|
||||
设备增加刀具库位table
|
||||
<!-- 设备增加刀具库位table-->
|
||||
<record id="sf_manufacturing_hr_equipment_view_form" model="ir.ui.view">
|
||||
<field name="name">sf_manufacturing_equipment.form</field>
|
||||
<field name="model">maintenance.equipment</field>
|
||||
<field name="inherit_id" ref="sf_maintenance.sf_hr_equipment_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//page[@name='sf_equipment']" position="after">
|
||||
<page string="标准刀库" name="sf_equipment_product_template"
|
||||
attrs="{'invisible': [('equipment_type', '!=', '机床')]}">
|
||||
<field name = 'product_template_ids' >
|
||||
<tree editable='bottom'>
|
||||
<field name="code"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
<page string="机床基坐标" name="sf_equipment_base_coordinate"
|
||||
attrs="{'invisible': [('equipment_type', '!=', '机床')]}">
|
||||
<button name="get_equipment_base_coordinate" string="获取基坐标数据" type="object"
|
||||
class="oe_highlight"/>
|
||||
<separator invisible="0"/>
|
||||
<group>
|
||||
<group>
|
||||
<field name="base_coordinate_fixture_model_id" options="{'no_create': True}"/>
|
||||
<field name="base_coordinate_g_coordinate"/>
|
||||
<field name="base_coordinate_x"/>
|
||||
<field name="base_coordinate_y"/>
|
||||
<field name="base_coordinate_z"/>
|
||||
</group>
|
||||
</group>
|
||||
</page>
|
||||
<page string="标准刀库" name="sf_equipment_product_template"
|
||||
attrs="{'invisible': [('equipment_type', '!=', '机床')]}">
|
||||
<field name='product_template_ids'>
|
||||
<tree editable='bottom'>
|
||||
<field name="code"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user