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:
@@ -21,6 +21,10 @@ class ResConfigSettings(models.TransientModel):
|
||||
|
||||
def sf_all_sync(self):
|
||||
try:
|
||||
self.env['sf.international.standards'].sync_all_mrs_international_standards()
|
||||
_logger.info("同步资源库国际标准完成")
|
||||
self.env['material.apply'].sync_all_material_apply()
|
||||
_logger.info("同步资源库材料应用完成")
|
||||
self.env['sf.production.materials'].sync_all_production_materials()
|
||||
_logger.info("同步资源库材料")
|
||||
self.env['sf.materials.model'].sync_all_materials_model()
|
||||
@@ -29,8 +33,8 @@ class ResConfigSettings(models.TransientModel):
|
||||
_logger.info("同步资源库表面工艺类别")
|
||||
self.env['sf.production.process'].sync_all_production_process()
|
||||
_logger.info("同步资源库表面工艺")
|
||||
self.env['sf.processing.technology'].sync_all_processing_technology()
|
||||
_logger.info("同步资源库加工工艺")
|
||||
# self.env['sf.processing.technology'].sync_all_processing_technology()
|
||||
# _logger.info("同步资源库加工工艺")
|
||||
self.env['sf.machine.brand.tags'].sync_all_machine_brand_tags()
|
||||
_logger.info("同步资源库品牌类别")
|
||||
self.env['sf.machine.brand'].sync_all_machine_brand()
|
||||
@@ -44,7 +48,10 @@ class ResConfigSettings(models.TransientModel):
|
||||
self.env['sf.cutting.tool.material'].sync_all_cutting_tool_material()
|
||||
_logger.info("同步刀具类型")
|
||||
self.env['sf.cutting.tool.type'].sync_all_tool_type()
|
||||
_logger.info("同步功能刀具类型")
|
||||
_logger.info("同步所有刀具类型完成")
|
||||
# _logger.info("同步所有刀具型号...")
|
||||
# self.env['sf.cutting.tool.model'].sync_all_tool_model()
|
||||
_logger.info("同步所有刀具型号完成")
|
||||
self.env['sf.functional.cutting.tool.model'].sync_all_functional_cutting_tool_model()
|
||||
_logger.info("同步夹具物料")
|
||||
self.env['sf.fixture.material'].sync_all_fixture_material()
|
||||
@@ -53,9 +60,12 @@ class ResConfigSettings(models.TransientModel):
|
||||
_logger.info("同步夹具型号")
|
||||
self.env['sf.fixture.model'].sync_all_fixture_model()
|
||||
_logger.info("同步功能夹具类型")
|
||||
# self.env['sf.functional.fixture'].sync_all_functional_fixture()
|
||||
|
||||
self.env['sf.functional.fixture.type'].sync_all_functional_fixture_type()
|
||||
_logger.info("同步资源库机床型号")
|
||||
|
||||
self.env['sf.machine_tool.type'].sync_all_machine_tool_type()
|
||||
_logger.info("同步资源库机床型号完成")
|
||||
except Exception as e:
|
||||
_logger.info("捕获错误信息:%s" % e)
|
||||
raise ValidationError("数据错误导致同步失败,请联系管理员")
|
||||
|
||||
@@ -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("能力特征库认证未通过")
|
||||
|
||||
Reference in New Issue
Block a user