Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/刀具产品调取Cloud刀具标准库(10.11)

# Conflicts:
#	sf_mrs_connect/models/sync_common.py
This commit is contained in:
jinling.yang
2023-10-11 17:41:19 +08:00
11 changed files with 406 additions and 140 deletions

View File

@@ -207,10 +207,19 @@ class sfMaterialModel(models.Model):
"hardness": item['hardness'],
"rough_machining": item['rough_machining'],
"finish_machining": item['finish_machining'],
"materials_id": materials.id,
"materials_id": self.env['sf.production.materials'].search(
[("materials_no", '=', item['materials_id.materials_no'])]).id,
"standards_id": self.env['sf.international.standards'].search(
[("name", '=', item['standards_id'])]).id,
"need_h": item['need_h'],
"alloy_code": item['alloy_code'],
"mf_materia_post": item['mf_materia_post'],
"density": item['density'],
"materials_code": item['materials_code'],
"apply": self.env['material.apply'].search(
[("name", 'in', item['apply'])]).ids
# "tag_ids": item['tag_ids']
})
else:
materials_model.name = item['name']
@@ -306,7 +315,17 @@ class sfProductionProcess(models.Model):
if result['status'] == 1:
for item in result['production_process_yesterday_list']:
if item:
production_process = self.search([("process_encode", '=', item['code'])])
brand = self.env['sf.production.process'].search(
[("code", '=', item['code'])])
if brand:
brand.name = item['name'],
brand.category_id = self.env['sf.production.process.category'].search(
[("code", '=', item['category_code'])]).id,
brand.code = item['code'],
brand.remark = item['remark'],
brand.active = item['active'],
brand.remark = item['remark']
production_process = self.search([("code", '=', item['code'])])
category = self.env['sf.production.process.category'].search(
[("code", '=', item['category_code'])])
if production_process:
@@ -317,8 +336,9 @@ class sfProductionProcess(models.Model):
else:
self.create({
"name": item['name'],
"category_id": category.id,
"process_encode": item['code'],
"category_id": self.env['sf.production.process.category'].search(
[("code", '=', item['category_code'])]).id,
"code": item['code'],
"remark": item['remark'],
"active": item['active'],
})
@@ -338,14 +358,14 @@ class sfProductionProcess(models.Model):
if result['status'] == 1:
for item in result['production_process_all_list']:
if item:
production_process = self.search([("process_encode", '=', item['code'])])
production_process = self.search([("code", '=', item['code'])])
category = self.env['sf.production.process.category'].search(
[("code", '=', item['category_code'])])
if not production_process:
self.create({
"name": item['name'],
"category_id": category.id,
"process_encode": item['code'],
"code": item['code'],
"remark": item['remark'],
"active": item['active'],
})
@@ -358,6 +378,7 @@ class sfProductionProcess(models.Model):
raise ValidationError("表面工艺认证未通过")
class sfProcessingTechnology(models.Model):
_inherit = 'sf.processing.technology'
_description = '加工工艺'
@@ -376,7 +397,7 @@ class sfProcessingTechnology(models.Model):
if result['status'] == 1:
for item in result['processing_technology_yesterday_list']:
if item:
processing_technology = self.search([("process_encode", '=', item['process_encode'])])
processing_technology = self.search([("code", '=', item['code'])])
if processing_technology:
processing_technology.name = item['name']
processing_technology.remark = item['remark']
@@ -384,7 +405,7 @@ class sfProcessingTechnology(models.Model):
else:
self.create({
"name": item['name'],
"process_encode": item['process_encode'],
"code": item['code'],
"remark": item['remark'],
"active": item['active'],
})
@@ -404,11 +425,11 @@ class sfProcessingTechnology(models.Model):
if result['status'] == 1:
for item in result['processing_technology_all_list']:
if item:
processing_technology = self.search([("process_encode", '=', item['process_encode'])])
processing_technology = self.search([("code", '=', item['code'])])
if not processing_technology:
self.create({
"name": item['name'],
"process_encode": item['process_encode'],
"code": item['code'],
"remark": item['remark'],
"active": item['active'],
})
@@ -884,7 +905,7 @@ class sfProductionProcessParameter(models.Model):
_description = '表面工艺可选参数'
url = '/api/production_process_parameter/list'
# 定时同步每日表面工艺
# 定时同步每日表面工艺可选参数
def sync_production_process_parameter_yesterday(self):
sf_sync_config = self.env['res.config.settings'].get_values()
token = sf_sync_config['token']
@@ -899,7 +920,7 @@ class sfProductionProcessParameter(models.Model):
if item:
production_process_parameter = self.search([("code", '=', item['code'])])
process = self.env['sf.production.process'].search(
[('process_encode', '=', item['process_id_code'])])
[('code', '=', item['process_id_code'])])
if production_process_parameter:
production_process_parameter.name = item['name']
production_process_parameter.active = item['active']
@@ -918,7 +939,7 @@ class sfProductionProcessParameter(models.Model):
else:
raise ValidationError("表面工艺可选参数认证未通过") # 定时同步表面工艺
# 同步所有表面工艺
# 同步所有表面工艺可选参数
def sync_all_production_process_parameter(self):
sf_sync_config = self.env['res.config.settings'].get_values()
token = sf_sync_config['token']
@@ -934,7 +955,7 @@ class sfProductionProcessParameter(models.Model):
production_process_parameter = self.search(
[("code", '=', item['code'])])
process = self.env['sf.production.process'].search(
[('process_encode', '=', item['process_id_code'])])
[('code', '=', item['process_id_code'])], limit=1)
if not production_process_parameter:
self.create({
"name": item['name'],
@@ -1684,5 +1705,115 @@ class SfMaintenanceEquipmentImage(models.Model):
"image": '' if not item['image'] else base64.b64decode(item['image']),
"active": item['active'],
})
else:
raise ValidationError("认证未通过")
class MaterialApply(models.Model):
_inherit = 'material.apply'
_description = '材料应用'
url = '/api/material_apply/list'
# 定时同步材料应用
def sync_material_apply(self):
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)
strUrl = sf_sync_config['sf_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['material_apply_yesterday_list']:
brand = self.env['material.apply'].search(
[("name", '=', item['name'])])
if brand:
brand.name = item['name'],
brand.active = item['active']
else:
self.env['material.apply'].create({
"name": item['name'],
"active": item['active'],
})
else:
raise ValidationError("认证未通过")
# 同步所有材料应用
def sync_all_material_apply(self):
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)
strUrl = sf_sync_config['sf_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['material_apply_all_list']:
brand = self.env['material.apply'].search(
[("name", '=', item['name'])])
if not brand:
self.env['material.apply'].create({
"name": item['name'],
"active": item['active'],
})
else:
raise ValidationError("认证未通过")
class ModelInternationalStandards(models.Model):
_inherit = 'sf.international.standards'
_description = '制造标准'
url = '/api/mrs_international_standards/list'
# 定时同步制造标准
def sync_mrs_international_standards(self):
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)
strUrl = sf_sync_config['sf_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['mrs_international_standards_yesterday_list']:
brand = self.env['sf.international.standards'].search(
[("name", '=', item['name'])])
if brand:
brand.name = item['name'],
brand.active = item['active']
else:
self.env['sf.international.standards'].create({
"name": item['name'],
"active": item['active'],
})
else:
raise ValidationError("认证未通过")
# 同步所有制造标准
def sync_all_mrs_international_standards(self):
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)
strUrl = sf_sync_config['sf_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['mrs_international_standards_all_list']:
brand = self.env['sf.international.standards'].search(
[("name", '=', item['name'])])
if not brand:
self.env['sf.international.standards'].create({
"name": item['name'],
"active": item['active'],
})
else:
raise ValidationError("能力特征库认证未通过")