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