41 lines
1.4 KiB
Python
41 lines
1.4 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/MachineToolGroup', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
|
|
cors="*")
|
|
def get_maintenance_tool_groups_Info(self, **kw):
|
|
"""
|
|
机床刀具组接口
|
|
:param kw:
|
|
:return:
|
|
"""
|
|
logging.info('get_maintenance_tool_groups_Info:%s' % kw)
|
|
try:
|
|
datas = request.httprequest.data
|
|
ret = json.loads(datas)
|
|
# ret = json.loads(ret['result'])
|
|
logging.info('DeviceId:%s' % ret)
|
|
tool_groups = request.env['sf.tool.groups'].sudo().search([])
|
|
|
|
res = {'Succeed': True, 'Datas': []}
|
|
if tool_groups:
|
|
for item in tool_groups:
|
|
device_id = ''
|
|
for equipment_id in item.equipment_ids:
|
|
device_id = '%s,%s' % (device_id, equipment_id.name)
|
|
res['Datas'].append({
|
|
'GroupName': item.name,
|
|
'DeviceId': device_id
|
|
})
|
|
except Exception as e:
|
|
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
|
logging.info('get_maintenance_tool_groups_Info error:%s' % e)
|
|
return json.JSONEncoder().encode(res)
|