69 lines
2.8 KiB
Python
69 lines
2.8 KiB
Python
# -*- coding: utf-8 -*-
|
|
import logging
|
|
import json
|
|
import base64
|
|
from odoo import http
|
|
from odoo.http import request
|
|
|
|
|
|
class Manufacturing_Connect(http.Controller):
|
|
|
|
@http.route('/AutoDeviceApi/ToolGroup', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
|
|
cors="*")
|
|
def get_functional_tool_groups_Info(self, **kw):
|
|
"""
|
|
刀具组接口
|
|
:param kw:
|
|
:return:
|
|
"""
|
|
logging.info('get_functional_tool_groups_Info:%s' % kw)
|
|
try:
|
|
datas = request.httprequest.data
|
|
ret = json.loads(datas)
|
|
# ret = json.loads(ret['result'])
|
|
logging.info('DeviceId:%s' % ret)
|
|
functional_tools = request.env['sf.tool.inventory'].sudo().search([])
|
|
|
|
res = {'Succeed': True, 'Datas': []}
|
|
if functional_tools:
|
|
for item in functional_tools:
|
|
res['Datas'].append({
|
|
'GroupName': item.tool_groups_id.name,
|
|
'ToolId': item.functional_cutting_tool_model_id.name,
|
|
'ToolName': item.name
|
|
})
|
|
except Exception as e:
|
|
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
|
logging.info('get_functional_tool_groups_Info error:%s' % e)
|
|
return json.JSONEncoder().encode(res)
|
|
|
|
@http.route('/AutoDeviceApi/PutToolParameter', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
|
|
cors="*")
|
|
def put_tool_preset_parameter_port(self, **kw):
|
|
"""
|
|
刀具预调仪接口
|
|
:param kw:
|
|
:return:
|
|
"""
|
|
logging.info('put_tool_preset_parameter_port:%s' % kw)
|
|
res = {'Succeed': True, 'Datas': []}
|
|
try:
|
|
datas = request.httprequest.data
|
|
ret = json.loads(datas)
|
|
tool_assembly = request.env['sf.functional.tool.assembly'].sudo().search([('start_preset_bool', '=', True)])
|
|
tool_assembly_order = request.env['sf.functional.tool.assembly.order'].sudo().search([])
|
|
if not tool_assembly:
|
|
return json.JSONEncoder().encode(
|
|
{'Succeed': False, 'ErrorCode': 201, 'Error': '没有找到正在组装的组装单!'})
|
|
tool_assembly.write({
|
|
'after_assembly_tool_loading_length': ret['loading_length'],
|
|
'after_assembly_functional_tool_length': ret['functional_tool_length'],
|
|
'after_assembly_max_lifetime_value': ret['max_lifetime_value'],
|
|
'after_assembly_alarm_value': 100,
|
|
'after_assembly_effective_length': 100
|
|
})
|
|
except Exception as e:
|
|
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '缺少%s字段信息' % e}
|
|
logging.info('put_tool_preset_parameter_port error:%s' % e)
|
|
return json.JSONEncoder().encode(res)
|