1、优化中控接口14-16
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import json
|
||||
import requests
|
||||
import logging
|
||||
from odoo import fields, models, api
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.addons.sf_base.commons.common import Common
|
||||
@@ -10,21 +11,22 @@ class CNCprocessing(models.Model):
|
||||
_description = 'CNC加工用刀检测'
|
||||
|
||||
# ==========MES装刀指令接口==========
|
||||
def register_cnc_processing(self, cnc_processing):
|
||||
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(self, token, sf_secret_key)
|
||||
def register_cnc_processing(self, knife_plan):
|
||||
# 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(self, token, sf_secret_key)
|
||||
headers = {'Authorization': 'Ba F2CF5DCC-1A00-4234-9E95-65603F70CC8A'}
|
||||
strurl = "https://x24467i973.zicp.fun/AutoDeviceApi/ToolLoadInstruct"
|
||||
val = {
|
||||
'DeviceId': cnc_processing.workorder_id.machine_tool_name,
|
||||
'RfidCode': None,
|
||||
'ToolId': cnc_processing.cutting_tool_no
|
||||
'DeviceId': knife_plan.machine_table_name,
|
||||
'RfidCode': knife_plan.sf_functional_tool_assembly_id.rfid,
|
||||
'ToolId': int(knife_plan.cutter_spacing_code_id.code[1:])
|
||||
}
|
||||
kw = json.dumps(val, ensure_ascii=False)
|
||||
r = requests.post(strurl, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||
r = requests.post(strurl, json=val, headers=headers)
|
||||
ret = r.json()
|
||||
if r == 200:
|
||||
logging.info('register_cnc_processing:%s' % ret)
|
||||
if ret['Succeed']:
|
||||
return "MES装刀指令发送成功"
|
||||
else:
|
||||
raise ValidationError("MES装刀指令发送失败")
|
||||
|
||||
Reference in New Issue
Block a user