智能工厂定时同步基础数据完成
This commit is contained in:
@@ -16,12 +16,17 @@ import logging
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
MRS = 'https://mrs.cs.jikimo.com'
|
||||
# MRS = 'http://192.168.50.11:8069'
|
||||
# MRS = 'http://192.168.50.100:6069'
|
||||
# 服务器
|
||||
TOKEN = '0b231a4c-3f01-11ed-a1cb-0242ac110003'
|
||||
# 本地
|
||||
# TOKEN = '4130d97c-37be-11ed-84a7-f8b54df29535'
|
||||
|
||||
TOKEN = '9524cba0-3e39-11ed-84ab-0242ac110003'
|
||||
# TOKEN = '999e2cff-3e44-11ed-92e2-f8b54d90e788'
|
||||
mrs_secret_key = 'HcSd4zh5AofCm73W'
|
||||
|
||||
# 服务器
|
||||
mrs_secret_key = 'WNHeIopD4XJy6TLK'
|
||||
# 本地
|
||||
# mrs_secret_key = 'BCDkXbaISz4Vg08y'
|
||||
|
||||
|
||||
# TIMESTAMP = str(int(time.time()))
|
||||
@@ -52,10 +57,10 @@ class MrsProductionMaterials(models.Model):
|
||||
r = r.json()
|
||||
result = json.loads(r['result'])
|
||||
if result['status'] == 1:
|
||||
for item in result['production_materials_list']:
|
||||
for item in result['production_materials_all_list']:
|
||||
if item:
|
||||
brand = self.env['mrs.production.materials'].search(
|
||||
[("id", '=', item['id'])])
|
||||
[("materials_no", '=', item['materials_no'])])
|
||||
if brand:
|
||||
print(item['name'])
|
||||
else:
|
||||
@@ -91,10 +96,10 @@ class MrsMaterialModel(models.Model):
|
||||
r = r.json()
|
||||
result = json.loads(r['result'])
|
||||
if result['status'] == 1:
|
||||
for item in result['materials_model_list']:
|
||||
for item in result['materials_model_all_list']:
|
||||
if item:
|
||||
brand = self.env['mrs.materials.model'].search(
|
||||
[("id", '=', item['id'])])
|
||||
[("materials_num", '=', item['materials_num'])])
|
||||
if brand:
|
||||
print(item['name'])
|
||||
else:
|
||||
@@ -134,17 +139,17 @@ class MrsProductionProcess(models.Model):
|
||||
r = r.json()
|
||||
result = json.loads(r['result'])
|
||||
if result['status'] == 1:
|
||||
for item in result['production_process_list']:
|
||||
for item in result['production_process_all_list']:
|
||||
if item:
|
||||
brand = self.env['mrs.production.process'].search(
|
||||
[("id", '=', item['id'])])
|
||||
[("process_encode", '=', item['process_encode'])])
|
||||
if brand:
|
||||
print(item['name'])
|
||||
else:
|
||||
self.env['mrs.production.process'].create({
|
||||
"id": item['id'],
|
||||
"name": item['name'],
|
||||
"process_enstatus": item['process_enstatus'],
|
||||
"process_encode": item['process_encode'],
|
||||
"remark": item['remark'],
|
||||
"active": item['active'],
|
||||
# "tag_ids": item['tag_ids']
|
||||
@@ -172,17 +177,17 @@ class MrsProcessingTechnology(models.Model):
|
||||
r = r.json()
|
||||
result = json.loads(r['result'])
|
||||
if result['status'] == 1:
|
||||
for item in result[' processing_technology_list_all']:
|
||||
for item in result['processing_technology_all_list']:
|
||||
if item:
|
||||
brand = self.env['mrs.processing.technology'].search(
|
||||
[("id", '=', item['id'])])
|
||||
[("process_encode", '=', item['process_encode'])])
|
||||
if brand:
|
||||
print(item['name'])
|
||||
else:
|
||||
self.env['mrs.processing.technology'].create({
|
||||
"id": item['id'],
|
||||
"name": item['name'],
|
||||
"process_enstatus": item['process_enstatus'],
|
||||
"process_encode": item['process_encode'],
|
||||
"remark": item['remark'],
|
||||
"active": item['active'],
|
||||
# "tag_ids": item['tag_ids']
|
||||
@@ -244,18 +249,19 @@ class MachineControlSystem(models.Model):
|
||||
r = r.json()
|
||||
result = json.loads(r['result'])
|
||||
if result['status'] == 1:
|
||||
for item in result['machine_control_system_list_all']:
|
||||
for item in result['machine_control_system_all_list']:
|
||||
if item:
|
||||
brand = self.env['mrs.machine_tool.type.control_system'].search(
|
||||
[("id", '=', item['id'])])
|
||||
[("code", '=', item['code'])])
|
||||
if brand:
|
||||
print(item['name'])
|
||||
else:
|
||||
self.env['mrs.machine_tool.type.control_system'].create({
|
||||
"id": item['id'],
|
||||
"name": item['name'],
|
||||
"status": item['status'],
|
||||
"brand_id": item['brand_id'],
|
||||
"code": item['code'],
|
||||
|
||||
# "brand_id": item['brand_id'],
|
||||
"active": item['active'],
|
||||
# "tag_ids": item['tag_ids']
|
||||
|
||||
@@ -278,6 +284,7 @@ class MachineBrand(models.Model):
|
||||
'TIMESTAMP': timestamp,
|
||||
'check_str': check_mrs_str}
|
||||
strUrl = MRS + self.url
|
||||
print("打印headers密钥"+check_mrs_str )
|
||||
r = requests.post(strUrl, json={}, data=None, headers=headers)
|
||||
r = r.json()
|
||||
result = json.loads(r['result'])
|
||||
@@ -319,7 +326,7 @@ class MachineTool(models.Model):
|
||||
r = r.json()
|
||||
result = json.loads(r['result'])
|
||||
if result['status'] == 1:
|
||||
for item in result['machine_tool_list']:
|
||||
for item in result['machine_tool_all_list']:
|
||||
brand = self.env['mrs.machine_tool'].search(
|
||||
[("code", '=', item['code'])])
|
||||
if brand:
|
||||
@@ -329,6 +336,7 @@ class MachineTool(models.Model):
|
||||
"id": item['id'],
|
||||
"name": item['name'],
|
||||
"precision": item['precision'],
|
||||
"code": item['code'],
|
||||
"status": item['status'],
|
||||
"knife_type": item['knife_type'],
|
||||
"registration_date": item['registration_date'],
|
||||
@@ -370,9 +378,9 @@ class MachineToolType(models.Model):
|
||||
r = r.json()
|
||||
result = json.loads(r['result'])
|
||||
if result['status'] == 1:
|
||||
for item in result['machine_tool_type_list']:
|
||||
for item in result['machine_tool_type_all_list']:
|
||||
brand = self.env['mrs.machine_tool.type'].search(
|
||||
[("id", '=', item['id'])])
|
||||
[("code", '=', item['code'])])
|
||||
if brand:
|
||||
print(item['name'])
|
||||
else:
|
||||
@@ -418,16 +426,16 @@ class CuttingTool(models.Model):
|
||||
r = r.json()
|
||||
result = json.loads(r['result'])
|
||||
if result['status'] == 1:
|
||||
for item in result['cutting_tool_category_list_all']:
|
||||
for item in result['cutting_tool_category_all_list']:
|
||||
brand = self.env['mrs.cutting_tool.category'].search(
|
||||
[("id", '=', item['id'])])
|
||||
[("code", '=', item['code'])])
|
||||
if brand:
|
||||
print(item['name'])
|
||||
else:
|
||||
self.env['mrs.cutting_tool.category'].create({
|
||||
"id": item['id'],
|
||||
"name": item['name'],
|
||||
"status": item['status'],
|
||||
"code": item['code'],
|
||||
"remark": item['remark'],
|
||||
"active": item['active'],
|
||||
# "tag_ids": item['tag_ids']
|
||||
@@ -455,17 +463,17 @@ class CuttingToolType(models.Model):
|
||||
r = r.json()
|
||||
result = json.loads(r['result'])
|
||||
if result['status'] == 1:
|
||||
for item in result['cutting_tool_type_list_all']:
|
||||
for item in result['cutting_tool_type_all_list']:
|
||||
brand = self.env['mrs.cutting_tool.type'].search(
|
||||
[("id", '=', item['id'])])
|
||||
[("code", '=', item['code'])])
|
||||
if brand:
|
||||
print(item['name'])
|
||||
else:
|
||||
self.env['mrs.cutting_tool.type'].create({
|
||||
"id": item['id'],
|
||||
"name": item['name'],
|
||||
"status": item['status'],
|
||||
"remark": item['remark'],
|
||||
"code": item['code'],
|
||||
"active": item['active'],
|
||||
"diameter": item['diameter'],
|
||||
"cone_angle_pitch": item['cone_angle_pitch'],
|
||||
@@ -474,8 +482,8 @@ class CuttingToolType(models.Model):
|
||||
"taper_shank_length": item['taper_shank_length'],
|
||||
"tool_length": item['tool_length'],
|
||||
"blade_number": item['blade_number'],
|
||||
"brand_id": item['brand_id'],
|
||||
"category_id": item['category_id']
|
||||
# "brand_id": item['brand_id'],
|
||||
# "category_id": item['category_id']
|
||||
})
|
||||
else:
|
||||
raise ValidationError("访问失败")
|
||||
|
||||
Reference in New Issue
Block a user