合并智能工厂代码
This commit is contained in:
@@ -530,9 +530,11 @@ class MachineTool(models.Model):
|
||||
'active': item.active
|
||||
}
|
||||
machine_tool_list.append(val)
|
||||
# kw = machine_tool_list
|
||||
kw = json.dumps(machine_tool_list, ensure_ascii=False)
|
||||
print(type(kw))
|
||||
r = requests.post(strurl, json=kw, data=None, headers=headers)
|
||||
|
||||
r = requests.post(strurl, json={}, data={'kw':kw}, headers=headers)
|
||||
print(r)
|
||||
else:
|
||||
raise _logger.info("没有注册机床")
|
||||
@@ -892,3 +894,58 @@ class CuttingToolType(models.Model):
|
||||
})
|
||||
else:
|
||||
raise ValidationError("认证未通过")
|
||||
|
||||
|
||||
|
||||
class MrsProcessingOrder(models.Model):
|
||||
_inherit = 'mrs.processing.order'
|
||||
_description = '工序'
|
||||
url = '/api/processing_order/list'
|
||||
|
||||
# 定时同步工序
|
||||
def sync_processing_order(self):
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
token = sf_sync_config['token']
|
||||
mrs_secret_key = sf_sync_config['mrs_secret_key']
|
||||
headers = Common.get_headers(self, token, mrs_secret_key)
|
||||
|
||||
strUrl = sf_sync_config['mrs_url'] + self.url
|
||||
r = requests.post(strUrl, json={}, data=None, headers=headers)
|
||||
r = r.json()
|
||||
result = json.loads(r['result'])
|
||||
if result['status'] == 1:
|
||||
for item in result['processing_order_yesterday_list']:
|
||||
brand = self.env['mrs.processing.order'].search(
|
||||
[("id", '=', item['id'])])
|
||||
if brand:
|
||||
brand.id = item['id']
|
||||
brand.sequence = item['sequence']
|
||||
else:
|
||||
self.env['mrs.processing.order'].create({
|
||||
"id": item['id'],
|
||||
"sequence": item['sequence'],
|
||||
|
||||
})
|
||||
else:
|
||||
raise ValidationError("认证未通过")
|
||||
|
||||
# 同步所有工序
|
||||
def sync_all_processing_order(self):
|
||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||
token = sf_sync_config['token']
|
||||
mrs_secret_key = sf_sync_config['mrs_secret_key']
|
||||
headers = Common.get_headers(self, token, mrs_secret_key)
|
||||
|
||||
strUrl = sf_sync_config['mrs_url'] + self.url
|
||||
r = requests.post(strUrl, json={}, data=None, headers=headers)
|
||||
r = r.json()
|
||||
result = json.loads(r['result'])
|
||||
if result['status'] == 1:
|
||||
for item in result['processing_order_all_list']:
|
||||
self.env['mrs.processing.order'].create({
|
||||
"id": item['id'],
|
||||
"sequence": item['sequence'],
|
||||
})
|
||||
else:
|
||||
raise ValidationError("认证未通过")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user