优化同步刀具标准库接口(包含全部合并每日)

This commit is contained in:
jinling.yang
2023-10-19 17:23:53 +08:00
parent 14edbd85f4
commit d83255cc67
11 changed files with 796 additions and 1075 deletions

View File

@@ -22,48 +22,49 @@ class ResConfigSettings(models.TransientModel):
def sf_all_sync(self):
try:
self.env['sf.production.materials'].sync_all_production_materials()
_logger.info("同步资源库材料")
_logger.info("同步资源库材料完成")
self.env['sf.materials.model'].sync_all_materials_model()
_logger.info("同步资源库材料型号")
_logger.info("同步资源库材料型号完成")
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.process.category'].sync_all_production_process_category()
_logger.info("同步资源库表面工艺类别")
_logger.info("同步资源库表面工艺类别完成")
self.env['sf.production.process'].sync_all_production_process()
_logger.info("同步资源库表面工艺")
_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("同步资源库品牌类别")
_logger.info("同步资源库品牌类别完成")
self.env['sf.machine.brand'].sync_all_machine_brand()
_logger.info("同步资源库品牌")
_logger.info("同步资源库品牌完成")
self.env['sf.machine.control_system'].sync_all_machine_control_system()
_logger.info("同步资源库控制系统")
_logger.info("同步资源库控制系统完成")
self.env['sf.machine_tool.category'].sync_all_machine_tool_category()
_logger.info("同步资源库机床类型")
_logger.info("同步资源库机床类型完成")
self.env['sf.production.process.parameter'].sync_all_production_process_parameter()
_logger.info("同步刀具物料")
_logger.info("同步刀具物料完成")
self.env['sf.cutting.tool.material'].sync_all_cutting_tool_material()
_logger.info("同步刀具类型")
_logger.info("同步刀具类型完成")
self.env['sf.cutting.tool.type'].sync_all_tool_type()
_logger.info("同步所有刀具型号完成")
self.env['sf.functional.cutting.tool.model'].sync_all_functional_cutting_tool_model()
_logger.info("同步夹具物料")
_logger.info("同步夹具物料完成")
self.env['sf.fixture.material'].sync_all_fixture_material()
_logger.info("同步联装类型")
_logger.info("同步联装类型完成")
self.env['sf.multi_mounting.type'].sync_all_multi_mounting_type()
_logger.info("同步夹具型号")
_logger.info("同步夹具型号完成")
self.env['sf.fixture.model'].sync_all_fixture_model()
_logger.info("同步功能夹具类型")
_logger.info("同步功能夹具类型完成")
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("同步资源库机床型号完成")
self.env['maintenance.equipment.image'].sync_all_maintenance_equipment_image()
_logger.info("同步能力特征库完成")
self.env['sf.cutting_tool.standard.library'].sync_all_cutting_tool_standard_library()
_logger.info("同步刀具标准库完成")
self.env['maintenance.equipment.image'].sync_all_maintenance_equipment_image()
_logger.info("同步能力特征库")
except Exception as e:
_logger.info("捕获错误信息:%s" % e)
raise ValidationError("数据错误导致同步失败,请联系管理员")

View File

@@ -56,12 +56,12 @@ class MrStaticResourceDataSync(models.Model):
logging.info("刀具物料已每日同步成功")
self.env['sf.cutting.tool.type'].sync_tool_type_yesterday()
logging.info("刀具类型已每日同步成功")
self.env['sf.cutting_tool.standard.library'].sync_cutting_tool_standard_library_yesterday()
logging.info("刀具标准库已每日同步成功")
self.env['sf.functional.cutting.tool.model'].sync_functional_cutting_tool_model_yesterday()
logging.info("功能刀具类型已每日同步成功")
self.env['maintenance.equipment.image'].sync_maintenance_equipment_image_yesterday()
logging.info("能力特征库已每日同步成功")
self.env['sf.cutting_tool.standard.library'].sync_cutting_tool_standard_library_yesterday()
logging.info("刀具标准库已每日同步成功")
except Exception as e:
logging.info("捕获错误信息:%s" % e)
raise ValidationError("数据错误导致同步失败,请联系管理员")
@@ -75,11 +75,9 @@ class sfProductionMaterials(models.Model):
# 定时同步每日材料
def sync_production_materials_yesterday(self):
# 配置中获取token
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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -103,11 +101,9 @@ class sfProductionMaterials(models.Model):
# 同步所有材料
def sync_all_production_materials(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -137,11 +133,9 @@ class sfMaterialModel(models.Model):
# 定时同步每日材料型号
def sync_materials_model_yesterday(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -185,11 +179,9 @@ class sfMaterialModel(models.Model):
# 同步所有材料型号
def sync_all_materials_model(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -247,11 +239,9 @@ class sfProductionProcessCategory(models.Model):
# 定时同步每日表面工艺类别
def sync_production_process_category_yesterday(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -274,11 +264,9 @@ class sfProductionProcessCategory(models.Model):
# 同步所有表面工艺类别
def sync_all_production_process_category(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -306,11 +294,9 @@ class sfProductionProcess(models.Model):
# 定时同步每日表面工艺
def sync_production_process_yesterday(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -349,11 +335,9 @@ class sfProductionProcess(models.Model):
# 同步所有表面工艺
def sync_all_production_process(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -387,11 +371,9 @@ class sfProcessingTechnology(models.Model):
# 定时同步加工工艺
def sync_processing_technology_yesterday(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -415,11 +397,9 @@ class sfProcessingTechnology(models.Model):
# 同步所有加工工艺
def sync_all_processing_technology(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -449,11 +429,9 @@ class MachineBrandTags(models.Model):
# 定时同步品牌类别
def sync_machine_brand_tags_yesterday(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -473,12 +451,9 @@ class MachineBrandTags(models.Model):
# 同步所有品牌类别
def sync_all_machine_brand_tags(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -504,11 +479,9 @@ class MachineControlSystem(models.Model):
# 定时同步控制系统
def sync_machine_control_system_yesterday(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -535,11 +508,9 @@ class MachineControlSystem(models.Model):
# 同步所有控制系统
def sync_all_machine_control_system(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -572,11 +543,9 @@ class MachineBrand(models.Model):
# 定时同步品牌
def sync_machine_brand_yesterday(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -603,11 +572,9 @@ class MachineBrand(models.Model):
# 同步所有品牌
def sync_all_machine_brand(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -640,11 +607,9 @@ class MachineToolType(models.Model):
# 定时同步机床型号
def sync_machine_tool_type_yesterday(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -745,11 +710,9 @@ class MachineToolType(models.Model):
# 同步所有机床型号
def sync_all_machine_tool_type(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -858,11 +821,9 @@ class sfProcessingOrder(models.Model):
# 定时同步工序
def sync_processing_order_yesterday(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -880,11 +841,9 @@ class sfProcessingOrder(models.Model):
# 同步所有工序
def sync_all_processing_order(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -908,11 +867,9 @@ class sfProductionProcessParameter(models.Model):
# 定时同步每日表面工艺可选参数
def sync_production_process_parameter_yesterday(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -942,11 +899,9 @@ class sfProductionProcessParameter(models.Model):
# 同步所有表面工艺可选参数
def sync_all_production_process_parameter(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -983,11 +938,9 @@ class MachineToolCategory(models.Model):
# 定时同步机床类型
def sync_machine_tool_category_yesterday(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -1012,11 +965,9 @@ class MachineToolCategory(models.Model):
# 同步所有机床类型
def sync_all_machine_tool_category(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -1049,11 +1000,9 @@ class sfSyncCutting_tool_Material(models.Model):
# 定时同步每日刀具物料
def sync_cutting_tool_material_yesterday(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -1081,11 +1030,9 @@ class sfSyncCutting_tool_Material(models.Model):
# 同步所有刀具物料
def sync_all_cutting_tool_material(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -1120,11 +1067,9 @@ class SyncFunctionalCuttingToolModel(models.Model):
# 定时同步每日功能刀具类型列表
def sync_functional_cutting_tool_model_yesterday(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -1152,12 +1097,9 @@ class SyncFunctionalCuttingToolModel(models.Model):
# 同步所有功能刀具类型列表
def sync_all_functional_cutting_tool_model(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -1192,11 +1134,9 @@ class SyncFixtureMaterial(models.Model):
# 定时同步夹具物料列表
def sync_fixture_material_yesterday(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -1226,12 +1166,9 @@ class SyncFixtureMaterial(models.Model):
# 定时同步所有夹具物料列表
def sync_all_fixture_material(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -1268,11 +1205,9 @@ class SyncMulti_Mounting_Type(models.Model):
# 定时同步联装类型列表
def sync_multi_mounting_type_yesterday(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -1299,11 +1234,9 @@ class SyncMulti_Mounting_Type(models.Model):
# 定时同步所有联装类型列表
def sync_all_multi_mounting_type(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -1338,11 +1271,9 @@ class SyncFixtureModel(models.Model):
# 定时同步夹具型号列表
def sync_fixture_model_yesterday(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -1417,11 +1348,9 @@ class SyncFixtureModel(models.Model):
# 定时同步所有夹具型号列表
def sync_all_fixture_model(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -1504,11 +1433,9 @@ class SyncFunctionalFixtureType(models.Model):
# 定时同步功能夹具类型列表
def sync_functional_fixture_type_yesterday(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -1536,11 +1463,9 @@ class SyncFunctionalFixtureType(models.Model):
# 定时同步所有功能夹具类型列表
def sync_all_functional_fixture_type(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -1575,11 +1500,9 @@ class SfToolType(models.Model):
# 定时同步每日刀具类型
def sync_tool_type_yesterday(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -1609,11 +1532,9 @@ class SfToolType(models.Model):
# 同步所有刀具类型列表
def sync_all_tool_type(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -1651,11 +1572,9 @@ class SfMaintenanceEquipmentImage(models.Model):
# 定时同步每日能力特征库
def sync_maintenance_equipment_image_yesterday(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -1681,11 +1600,9 @@ class SfMaintenanceEquipmentImage(models.Model):
# 同步所有能力特征库
def sync_all_maintenance_equipment_image(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -1717,12 +1634,9 @@ class MaterialApply(models.Model):
# 定时同步材料应用
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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -1742,12 +1656,9 @@ class MaterialApply(models.Model):
# 同步所有材料应用
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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -1773,12 +1684,9 @@ class ModelInternationalStandards(models.Model):
# 定时同步制造标准
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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -1791,6 +1699,7 @@ class ModelInternationalStandards(models.Model):
else:
self.create({
"name": item['name'],
"code": item['code'],
"active": item['active'],
})
else:
@@ -1798,12 +1707,9 @@ class ModelInternationalStandards(models.Model):
# 同步所有制造标准
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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -1813,6 +1719,7 @@ class ModelInternationalStandards(models.Model):
if not international_standards:
self.create({
"name": item['name'],
"code": item['code'],
"active": item['active'],
})
else:
@@ -1829,40 +1736,170 @@ class Cutting_tool_standard_library(models.Model):
# 定时同步刀具标准库
def sync_cutting_tool_standard_library_yesterday(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = 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['cutting_tool_standard_library_yesterday_list']:
cutting_tool_standard_library = self.search(
[("code", '=', item['code'])])
if cutting_tool_standard_library:
cutting_tool_standard_library.write(
{"name": item['name'],
"active": item['active']}
)
else:
[("code", '=', item['code'].replace("JKM", result['factory_short_name']))])
cutting_tool_type = self.env['sf.cutting.tool.type'].search(
[("code", '=', item['cutting_tool_type_code'])])
cutting_tool_material = self.env['sf.cutting.tool.material'].search(
[("code", '=', item['cutting_tool_material_code'])])
materials_model = self.env['sf.materials.model'].search(
[("materials_no", '=', item['material_model_code'])])
brand = self.env['sf.machine.brand'].search([("code", '=', item['brand_code'])])
integral_tool_basic_param_list = []
for integral_tool_item in item['integral_tool_basic_parameter']:
integral_tool_basic_param_list.append(
self.env['sf.tool.materials.basic.parameters']._json_integral_tool_basic_param(
integral_tool_item))
blade_basic_param_list = []
for blade_item in item['blade_basic_parameter']:
blade_basic_param_list.append(
self.env['sf.tool.materials.basic.parameters']._json_blade_basic_param(blade_item))
cutter_arbor_basic_param_list = []
for cutter_arbor_item in item['cutter_arbor_basic_parameter']:
cutter_arbor_basic_param_list.append(
self.env['sf.tool.materials.basic.parameters']._json_cutter_arbor_basic_param(
cutter_arbor_item))
cutter_head_basic_param_list = []
for cutter_head_item in item['cutter_head_basic_parameter']:
cutter_head_basic_param_list.append(
self.env['sf.tool.materials.basic.parameters']._json_cutter_head_basic_param(cutter_head_item))
knife_handle_basic_param_list = []
for knife_handle_item in item['knife_handle_basic_parameter']:
knife_handle_basic_param_list.append(
self.env['sf.tool.materials.basic.parameters']._json_knife_handle_basic_param(
knife_handle_item))
chuck_basic_param_list = []
for chuck_item in item['chuck_basic_parameter']:
chuck_basic_param_list.append(
self.env['sf.tool.materials.basic.parameters']._json_chuck_basic_param(chuck_item))
cutting_speed_list = []
for cutting_speed_item in item['cutting_speed']:
cutting_speed_list.append(
self.env['sf.cutting.speed']._json_cutting_speed(cutting_speed_item))
feed_per_tooth_list = []
for feed_per_tooth_item in item['feed_per_tooth']:
feed_per_tooth_list.append(
self.env['sf.feed.per.tooth']._json_feed_per_tooth(feed_per_tooth_item))
feed_per_tooth_2_list = []
for feed_per_tooth_2_item in item['feed_per_tooth_2']:
feed_per_tooth_2_list.append(
self.env['sf.feed.per.tooth']._json_feed_per_tooth(feed_per_tooth_2_item))
feed_per_tooth_3_list = []
for feed_per_tooth_3_item in item['feed_per_tooth_3']:
feed_per_tooth_3_list.append(
self.env['sf.feed.per.tooth']._json_feed_per_tooth(feed_per_tooth_3_item))
feed_per_tooth_4_list = []
for feed_per_tooth_4_item in item['feed_per_tooth_4']:
feed_per_tooth_4_list.append(
self.env['sf.feed.per.tooth']._json_feed_per_tooth(feed_per_tooth_4_item))
if not cutting_tool_standard_library:
self.create({
"code": item['code'].replace("JKM", result['factory_short_name']),
"name": item['name'],
"cutting_tool_material_id": cutting_tool_material.id,
"cutting_tool_type_id": cutting_tool_type.id,
"brand_id": brand.id,
"material_model_id": materials_model.id,
"tool_hardness": item['tool_hardness'],
"coating_material": item['coating_material'],
"blade_type": item['blade_type'],
"integral_coarse_medium_fine": item['integral_coarse_medium_fine'],
"integral_run_out_accuracy_max": item['integral_run_out_accuracy_max'],
"integral_run_out_accuracy_min": item['integral_run_out_accuracy_min'],
"cutter_bar_ids": [(6, 0, [])] if not item.get('cutter_bar_codes') else self.env[
'sf.cutting.tool.type']._get_ids(item['cutter_bar_codes']),
"cutter_pad_ids": [(6, 0, [])] if not item.get('cutter_pad_codes') else self.env[
'sf.cutting.tool.type']._get_ids(item['cutter_pad_codes']),
"fit_blade_shape_ids": [(6, 0, [])] if not item.get('fit_blade_shape') else self.env[
'maintenance.equipment.image']._get_ids(item['fit_blade_shape']),
"suitable_machining_method_ids": [(6, 0, [])] if not item.get(
'suitable_machining_methods') else self.env['maintenance.equipment.image']._get_ids(
item['suitable_machining_methods']),
"blade_tip_characteristics_ids": [(6, 0, [])] if not item.get('blade_tip_characteristics') else
self.env['maintenance.equipment.image']._get_ids(item['blade_tip_characteristics']),
"handle_type_ids": [(6, 0, [])] if not item.get('handle_type') else self.env[
'maintenance.equipment.image']._get_ids(item['handle_type']),
"cutting_direction_ids": [(6, 0, [])] if not item.get('cutting_direction') else self.env[
'maintenance.equipment.image']._get_ids(item['cutting_direction']),
"suitable_coolant_ids": [(6, 0, [])] if not item.get('suitable_coolant') else self.env[
'maintenance.equipment.image']._get_ids(item['suitable_coolant']),
"compaction_way_ids": [(6, 0, [])] if not item.get('compaction_way') else self.env[
'maintenance.equipment.image']._get_ids(item['compaction_way']),
"integral_tool_basic_parameters_ids": integral_tool_basic_param_list,
"blade_basic_parameters_ids": blade_basic_param_list,
"cutter_bar_basic_parameters_ids": cutter_arbor_basic_param_list,
"cutter_head_basic_parameters_ids": cutter_head_basic_param_list,
"knife_handle_basic_parameters_ids": knife_handle_basic_param_list,
"chuck_basic_parameters_ids": chuck_basic_param_list,
"cutting_speed_ids": cutting_speed_list,
"feed_per_tooth_ids": feed_per_tooth_list,
"feed_per_tooth_ids_2": feed_per_tooth_2_list,
"feed_per_tooth_ids_3": feed_per_tooth_3_list,
"feed_per_tooth_ids_4": feed_per_tooth_4_list,
"is_cloud": True,
"active": item['active'],
})
else:
cutting_tool_standard_library.write(
{"name": item['name'],
"cutting_tool_material_id": cutting_tool_material.id,
"cutting_tool_type_id": cutting_tool_type.id,
"brand_id": brand.id,
"material_model_id": materials_model.id,
"tool_hardness": item['tool_hardness'],
"coating_material": item['coating_material'],
"blade_type": item['blade_type'],
"integral_coarse_medium_fine": item['integral_coarse_medium_fine'],
"integral_run_out_accuracy_max": item['integral_run_out_accuracy_max'],
"integral_run_out_accuracy_min": item['integral_run_out_accuracy_min'],
"cutter_bar_ids": [(6, 0, [])] if not item.get('cutter_bar_codes') else self.env[
'sf.cutting.tool.type']._get_ids(item['cutter_bar_codes']),
"cutter_pad_ids": [(6, 0, [])] if not item.get('cutter_pad_codes') else self.env[
'sf.cutting.tool.type']._get_ids(item['cutter_pad_codes']),
"fit_blade_shape_ids": [(6, 0, [])] if not item.get('fit_blade_shape') else self.env[
'maintenance.equipment.image']._get_ids(item['fit_blade_shape']),
"suitable_machining_method_ids": [(6, 0, [])] if not item.get(
'suitable_machining_methods') else self.env['maintenance.equipment.image']._get_ids(
item['suitable_machining_methods']),
"blade_tip_characteristics_ids": [(6, 0, [])] if not item.get('blade_tip_characteristics') else
self.env['maintenance.equipment.image']._get_ids(item['blade_tip_characteristics']),
"handle_type_ids": [(6, 0, [])] if not item.get('handle_type') else self.env[
'maintenance.equipment.image']._get_ids(item['handle_type']),
"cutting_direction_ids": [(6, 0, [])] if not item.get('cutting_direction') else self.env[
'maintenance.equipment.image']._get_ids(item['cutting_direction']),
"suitable_coolant_ids": [(6, 0, [])] if not item.get('suitable_coolant') else self.env[
'maintenance.equipment.image']._get_ids(item['suitable_coolant']),
"compaction_way_ids": [(6, 0, [])] if not item.get('compaction_way') else self.env[
'maintenance.equipment.image']._get_ids(item['compaction_way']),
"integral_tool_basic_parameters_ids": integral_tool_basic_param_list,
"blade_basic_parameters_ids": blade_basic_param_list,
"cutter_bar_basic_parameters_ids": cutter_arbor_basic_param_list,
"cutter_head_basic_parameters_ids": cutter_head_basic_param_list,
"knife_handle_basic_parameters_ids": knife_handle_basic_param_list,
"chuck_basic_parameters_ids": chuck_basic_param_list,
"cutting_speed_ids": cutting_speed_list,
"feed_per_tooth_ids": feed_per_tooth_list,
"feed_per_tooth_ids_2": feed_per_tooth_2_list,
"feed_per_tooth_ids_3": feed_per_tooth_3_list,
"feed_per_tooth_ids_4": feed_per_tooth_4_list,
"active": item['active'],
})
else:
raise ValidationError("刀具标准库认证未通过")
# 同步所有刀具标准库
def sync_all_cutting_tool_standard_library(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
config = self.env['res.config.settings'].get_values()
headers = Common.get_headers(self, config['token'], config['sf_secret_key'])
strUrl = config['sf_url'] + self.url
r = requests.post(strUrl, json={}, data=None, headers=headers)
r = r.json()
result = json.loads(r['result'])
@@ -1877,18 +1914,53 @@ class Cutting_tool_standard_library(models.Model):
materials_model = self.env['sf.materials.model'].search(
[("materials_no", '=', item['material_model_code'])])
brand = self.env['sf.machine.brand'].search([("code", '=', item['brand_code'])])
basic_param_list = []
for basic_param_item in item['basic_parameter']:
basic_param_list.append(
self.env['sf.tool.materials.basic.parameters']._json_basic_param(basic_param_item))
integral_tool_basic_param_list = []
for integral_tool_item in item['integral_tool_basic_parameter']:
integral_tool_basic_param_list.append(
self.env['sf.tool.materials.basic.parameters']._json_integral_tool_basic_param(
integral_tool_item))
blade_basic_param_list = []
for blade_item in item['blade_basic_parameter']:
blade_basic_param_list.append(
self.env['sf.tool.materials.basic.parameters']._json_blade_basic_param(blade_item))
cutter_arbor_basic_param_list = []
for cutter_arbor_item in item['cutter_arbor_basic_parameter']:
cutter_arbor_basic_param_list.append(
self.env['sf.tool.materials.basic.parameters']._json_cutter_arbor_basic_param(
cutter_arbor_item))
cutter_head_basic_param_list = []
for cutter_head_item in item['cutter_head_basic_parameter']:
cutter_head_basic_param_list.append(
self.env['sf.tool.materials.basic.parameters']._json_cutter_head_basic_param(cutter_head_item))
knife_handle_basic_param_list = []
for knife_handle_item in item['knife_handle_basic_parameter']:
knife_handle_basic_param_list.append(
self.env['sf.tool.materials.basic.parameters']._json_knife_handle_basic_param(
knife_handle_item))
chuck_basic_param_list = []
for chuck_item in item['chuck_basic_parameter']:
chuck_basic_param_list.append(
self.env['sf.tool.materials.basic.parameters']._json_chuck_basic_param(chuck_item))
cutting_speed_list = []
for cutting_speed_item in item['cutting_speed']:
cutting_speed_list.append(
self.env['sf.cutting.speed']._json_cutting_speed(cutting_speed_item))
feed_per_tooth_list = []
for feed_per_tooth_item in item['basic_parameter']:
for feed_per_tooth_item in item['feed_per_tooth']:
feed_per_tooth_list.append(
self.env['sf.feed.per.tooth']._json_feed_per_tooth(feed_per_tooth_item))
feed_per_tooth_2_list = []
for feed_per_tooth_2_item in item['feed_per_tooth_2']:
feed_per_tooth_2_list.append(
self.env['sf.feed.per.tooth']._json_feed_per_tooth_2(feed_per_tooth_2_item))
feed_per_tooth_3_list = []
for feed_per_tooth_3_item in item['feed_per_tooth_3']:
feed_per_tooth_3_list.append(
self.env['sf.feed.per.tooth']._json_feed_per_tooth_3(feed_per_tooth_3_item))
feed_per_tooth_4_list = []
for feed_per_tooth_4_item in item['feed_per_tooth_4']:
feed_per_tooth_4_list.append(
self.env['sf.feed.per.tooth']._json_feed_per_tooth_4(feed_per_tooth_4_item))
if not cutting_tool_standard_library:
self.create({
"code": item['code'].replace("JKM", result['factory_short_name']),
@@ -1900,14 +1972,40 @@ class Cutting_tool_standard_library(models.Model):
"tool_hardness": item['tool_hardness'],
"coating_material": item['coating_material'],
"blade_type": item['blade_type'],
"blade_diameter": item['blade_diameter'],
"working_hardness": item['working_hardness'],
"integral_coarse_medium_fine": item['integral_coarse_medium_fine'],
"integral_run_out_accuracy_max": item['integral_run_out_accuracy_max'],
"integral_run_out_accuracy_min": item['integral_run_out_accuracy_min'],
"basic_parameters_ids": basic_param_list,
"cutter_bar_ids": [(6, 0, [])] if not item.get('cutter_bar_codes') else self.env[
'sf.cutting.tool.type']._get_ids(item['cutter_bar_codes']),
"cutter_pad_ids": [(6, 0, [])] if not item.get('cutter_pad_codes') else self.env[
'sf.cutting.tool.type']._get_ids(item['cutter_pad_codes']),
"fit_blade_shape_ids": [(6, 0, [])] if not item.get('fit_blade_shape') else self.env[
'maintenance.equipment.image']._get_ids(item['fit_blade_shape']),
"suitable_machining_method_ids": [(6, 0, [])] if not item.get(
'suitable_machining_method') else self.env['maintenance.equipment.image']._get_ids(
item['suitable_machining_method']),
"blade_tip_characteristics_ids": [(6, 0, [])] if not item.get('blade_tip_characteristics') else
self.env['maintenance.equipment.image']._get_ids(item['blade_tip_characteristics']),
"handle_type_ids": [(6, 0, [])] if not item.get('handle_type') else self.env[
'maintenance.equipment.image']._get_ids(item['handle_type']),
"cutting_direction_ids": [(6, 0, [])] if not item.get('cutting_direction') else self.env[
'maintenance.equipment.image']._get_ids(item['cutting_direction']),
"suitable_coolant_ids": [(6, 0, [])] if not item.get('suitable_coolant') else self.env[
'maintenance.equipment.image']._get_ids(item['suitable_coolant']),
"compaction_way_ids": [(6, 0, [])] if not item.get('compaction_way') else self.env[
'maintenance.equipment.image']._get_ids(item['compaction_way']),
"integral_tool_basic_parameters_ids": integral_tool_basic_param_list,
"blade_basic_parameters_ids": blade_basic_param_list,
"cutter_bar_basic_parameters_ids": cutter_arbor_basic_param_list,
"cutter_head_basic_parameters_ids": cutter_head_basic_param_list,
"knife_handle_basic_parameters_ids": knife_handle_basic_param_list,
"chuck_basic_parameters_ids": chuck_basic_param_list,
"cutting_speed_ids": cutting_speed_list,
"feed_per_tooth_ids": feed_per_tooth_list,
"feed_per_tooth_ids_2": feed_per_tooth_2_list,
"feed_per_tooth_ids_3": feed_per_tooth_3_list,
"feed_per_tooth_ids_4": feed_per_tooth_4_list,
"is_cloud": True,
"active": item['active'],
})
else:
@@ -1920,15 +2018,40 @@ class Cutting_tool_standard_library(models.Model):
"tool_hardness": item['tool_hardness'],
"coating_material": item['coating_material'],
"blade_type": item['blade_type'],
"blade_diameter": item['blade_diameter'],
"working_hardness": item['working_hardness'],
"integral_coarse_medium_fine": item['integral_coarse_medium_fine'],
"integral_run_out_accuracy_max": item['integral_run_out_accuracy_max'],
"integral_run_out_accuracy_min": item['integral_run_out_accuracy_min'],
"basic_parameters_ids": basic_param_list,
"cutter_bar_ids": [(6, 0, [])] if not item.get('cutter_bar_codes') else self.env[
'sf.cutting.tool.type']._get_ids(item['cutter_bar_codes']),
"cutter_pad_ids": [(6, 0, [])] if not item.get('cutter_pad_codes') else self.env[
'sf.cutting.tool.type']._get_ids(item['cutter_pad_codes']),
"fit_blade_shape_ids": [(6, 0, [])] if not item.get('fit_blade_shape') else self.env[
'maintenance.equipment.image']._get_ids(item['fit_blade_shape']),
"suitable_machining_method_ids": [(6, 0, [])] if not item.get(
'suitable_machining_methods') else self.env['maintenance.equipment.image']._get_ids(
item['suitable_machining_methods']),
"blade_tip_characteristics_ids": [(6, 0, [])] if not item.get('blade_tip_characteristics') else
self.env['maintenance.equipment.image']._get_ids(item['blade_tip_characteristics']),
"handle_type_ids": [(6, 0, [])] if not item.get('handle_type') else self.env[
'maintenance.equipment.image']._get_ids(item['handle_type']),
"cutting_direction_ids": [(6, 0, [])] if not item.get('cutting_direction') else self.env[
'maintenance.equipment.image']._get_ids(item['cutting_direction']),
"suitable_coolant_ids": [(6, 0, [])] if not item.get('suitable_coolant') else self.env[
'maintenance.equipment.image']._get_ids(item['suitable_coolant']),
"compaction_way_ids": [(6, 0, [])] if not item.get('compaction_way') else self.env[
'maintenance.equipment.image']._get_ids(item['compaction_way']),
"integral_tool_basic_parameters_ids": integral_tool_basic_param_list,
"blade_basic_parameters_ids": blade_basic_param_list,
"cutter_bar_basic_parameters_ids": cutter_arbor_basic_param_list,
"cutter_head_basic_parameters_ids": cutter_head_basic_param_list,
"knife_handle_basic_parameters_ids": knife_handle_basic_param_list,
"chuck_basic_parameters_ids": chuck_basic_param_list,
"cutting_speed_ids": cutting_speed_list,
"feed_per_tooth_ids": feed_per_tooth_list,
"active": item['active'], }
)
"feed_per_tooth_ids_2": feed_per_tooth_2_list,
"feed_per_tooth_ids_3": feed_per_tooth_3_list,
"feed_per_tooth_ids_4": feed_per_tooth_4_list,
"active": item['active'],
})
else:
raise ValidationError("刀具标准库认证未通过")