1、优化刀具组接口

This commit is contained in:
yuxianghui
2024-02-22 14:23:19 +08:00
parent 5f760cf94b
commit ed8cbb1f81
4 changed files with 47 additions and 46 deletions

View File

@@ -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)