Merge branch 'feature/中控接口14-19优化' into feature/刀具组接口优化
This commit is contained in:
@@ -22,7 +22,7 @@ class Manufacturing_Connect(http.Controller):
|
||||
ret = json.loads(datas)
|
||||
# ret = json.loads(ret['result'])
|
||||
logging.info('DeviceId:%s' % ret)
|
||||
tool_groups = request.env['sf.tool.groups'].sudo().search([])
|
||||
tool_groups = request.env['sf.tool.groups'].sudo().search([('active', '=', True)])
|
||||
|
||||
res = {'Succeed': True, 'Datas': []}
|
||||
if tool_groups:
|
||||
|
||||
@@ -255,30 +255,31 @@ class ToolGroups(models.Model):
|
||||
remark = fields.Char('备注', size=50)
|
||||
|
||||
# ==========机床刀具组接口==========
|
||||
def _register_tool_groups(self, obj):
|
||||
create_url = '/AutoDeviceApi/MachineToolGroup'
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
token = sf_sync_config['token']
|
||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
headers = Common.get_headers(obj, token, sf_secret_key)
|
||||
strurl = sf_sync_config['sf_url'] + create_url
|
||||
device_id = ''
|
||||
name = None
|
||||
if obj:
|
||||
for equipment_id in obj.equipment_ids:
|
||||
device_id = '%s,%s' % (device_id, equipment_id.name)
|
||||
name = obj.name
|
||||
val = {
|
||||
'DeviceId': device_id,
|
||||
'GroupName': name,
|
||||
}
|
||||
kw = json.dumps(val, ensure_ascii=False)
|
||||
r = requests.post(strurl, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||
ret = r.json()
|
||||
if r == 200:
|
||||
return "机床刀具组发送成功"
|
||||
else:
|
||||
raise ValidationError("机床刀具组发送失败")
|
||||
# def _register_tool_groups(self, obj):
|
||||
# # create_url = '/AutoDeviceApi/MachineToolGroup'
|
||||
# sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
# token = sf_sync_config['token']
|
||||
# sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
# headers = Common.get_headers(obj, token, sf_secret_key)
|
||||
# strurl = "https://x24467i973.zicp.fun/AutoDeviceApi/MachineToolGroup"
|
||||
# device_id = ''
|
||||
# name = None
|
||||
# if obj:
|
||||
# for equipment_id in obj.equipment_ids:
|
||||
# device_id = '%s,%s' % (device_id, equipment_id.name)
|
||||
# name = obj.name
|
||||
# val = {
|
||||
# 'DeviceId': device_id,
|
||||
# 'GroupName': name,
|
||||
# }
|
||||
# kw = json.dumps(val, ensure_ascii=False)
|
||||
# r = requests.post(strurl, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||
# print(r)
|
||||
# ret = r.json()
|
||||
# if r == 200:
|
||||
# return "机床刀具组发送成功"
|
||||
# else:
|
||||
# raise ValidationError("机床刀具组发送失败")
|
||||
|
||||
# def write(self, vals):
|
||||
# obj = super().write(vals)
|
||||
|
||||
@@ -70,14 +70,14 @@ class Manufacturing_Connect(http.Controller):
|
||||
ret = json.loads(datas)
|
||||
# ret = json.loads(ret['result'])
|
||||
logging.info('DeviceId:%s' % ret)
|
||||
functional_tools = request.env['sf.functional.cutting.tool.entity'].sudo().search([])
|
||||
functional_tools = request.env['sf.functional.cutting.tool.entity'].sudo().search([('active', '=', True)])
|
||||
|
||||
res = {'Succeed': True, 'Datas': []}
|
||||
if functional_tools:
|
||||
for item in functional_tools:
|
||||
res['Datas'].append({
|
||||
'GroupName': item.tool_groups_id.name,
|
||||
'ToolId': item.code,
|
||||
'ToolId': item.barcode_id.name,
|
||||
'ToolName': item.name
|
||||
})
|
||||
except Exception as e:
|
||||
|
||||
@@ -179,25 +179,25 @@ class FunctionalCuttingToolEntity(models.Model):
|
||||
return result
|
||||
|
||||
# ==========刀具组接口==========
|
||||
def _register_functional_tool_groups(self, obj):
|
||||
create_url = '/AutoDeviceApi/ToolGroup'
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
token = sf_sync_config['token']
|
||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
headers = Common.get_headers(obj, token, sf_secret_key)
|
||||
strurl = sf_sync_config['sf_url'] + create_url
|
||||
val = {
|
||||
'ToolName': obj.name,
|
||||
'GroupName': obj.tool_groups_id.name,
|
||||
'ToolId': obj.code
|
||||
}
|
||||
kw = json.dumps(val, ensure_ascii=False)
|
||||
r = requests.post(strurl, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||
ret = r.json()
|
||||
if r == 200:
|
||||
return "刀具组发送成功"
|
||||
else:
|
||||
raise ValidationError("刀具组发送失败")
|
||||
# def _register_functional_tool_groups(self, obj):
|
||||
# create_url = '/AutoDeviceApi/ToolGroup'
|
||||
# sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
# token = sf_sync_config['token']
|
||||
# sf_secret_key = sf_sync_config['sf_secret_key']
|
||||
# headers = Common.get_headers(obj, token, sf_secret_key)
|
||||
# strurl = sf_sync_config['sf_url'] + create_url
|
||||
# val = {
|
||||
# 'ToolName': obj.name,
|
||||
# 'GroupName': obj.tool_groups_id.name,
|
||||
# 'ToolId': obj.code
|
||||
# }
|
||||
# kw = json.dumps(val, ensure_ascii=False)
|
||||
# r = requests.post(strurl, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||
# ret = r.json()
|
||||
# if r == 200:
|
||||
# return "刀具组发送成功"
|
||||
# else:
|
||||
# raise ValidationError("刀具组发送失败")
|
||||
|
||||
# @api.model_create_multi
|
||||
# def create(self, vals):
|
||||
|
||||
Reference in New Issue
Block a user