1.新增每日同步切削速度和每齿走刀量及切削宽度和深度的接口
2.优化产品模版
This commit is contained in:
@@ -67,6 +67,13 @@ class ResConfigSettings(models.TransientModel):
|
||||
_logger.info("同步刀具标准库完成")
|
||||
self.env['sf.tool.materials.basic.parameters'].sync_all_cutting_tool_basic_parameters()
|
||||
_logger.info("同步刀具物料基本参数完成")
|
||||
self.env['sf.cutting.width.depth'].sync_all_cutting_width_depth()
|
||||
_logger.info("同步刀具物料切削宽度和深度完成")
|
||||
self.env['sf.cutting.speed'].sync_all_cutting_speed()
|
||||
_logger.info("同步刀具物料切削速度完成")
|
||||
self.env['sf.feed.per.tooth'].sync_all_feed_per_tooth()
|
||||
_logger.info("同步刀具物料每齿走刀量完成")
|
||||
|
||||
except Exception as e:
|
||||
_logger.info("捕获错误信息:%s" % e)
|
||||
raise ValidationError("数据错误导致同步失败,请联系管理员")
|
||||
|
||||
@@ -64,6 +64,12 @@ class MrStaticResourceDataSync(models.Model):
|
||||
logging.info("刀具标准库已每日同步成功")
|
||||
self.env['sf.tool.materials.basic.parameters'].sync_cutting_tool_basic_parameters_yesterday()
|
||||
_logger.info("同步刀具物料基本参数完成")
|
||||
self.env['sf.cutting.width.depth'].sync_cutting_width_depth_yesterday()
|
||||
_logger.info("同步刀具物料切削宽度和深度完成")
|
||||
self.env['sf.cutting.speed'].sync_cutting_speed_yesterday()
|
||||
_logger.info("同步刀具物料切削速度完成")
|
||||
self.env['sf.feed.per.tooth'].sync_feed_per_tooth_yesterday()
|
||||
_logger.info("同步刀具物料每齿走刀量完成")
|
||||
except Exception as e:
|
||||
logging.info("捕获错误信息:%s" % e)
|
||||
raise ValidationError("数据错误导致同步失败,请联系管理员")
|
||||
@@ -1907,6 +1913,242 @@ class ModelInternationalStandards(models.Model):
|
||||
raise ValidationError("制造标准认证未通过")
|
||||
|
||||
|
||||
class CuttingSpeed(models.Model):
|
||||
_inherit = 'sf.cutting.speed'
|
||||
_description = '切削速度'
|
||||
url = '/api/cutting_speed/list'
|
||||
|
||||
def sync_cutting_speed_yesterday(self):
|
||||
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_speed_yesterday_list']:
|
||||
cutting_speed = self.search([("name", '=', item['name'])])
|
||||
if not cutting_speed:
|
||||
self.create({
|
||||
'name': item['name'],
|
||||
'standard_library_id': self.env['sf.cutting_tool.standard.library'].search(
|
||||
[('code', '=', item['standard_library_code'].replace("JKM", result[
|
||||
'factory_short_name']))]).id,
|
||||
'execution_standard_id': self.env['sf.international.standards'].search(
|
||||
[('code', '=', item['execution_standard_code'])]).id,
|
||||
'material_name_id': self.env['sf.materials.model'].search(
|
||||
[('materials_no', '=', item['material_name'])]).id,
|
||||
'cutting_width_depth_id': self.env['sf.cutting.width.depth'].search(
|
||||
[('name', '=', item['cutting_width_depth'])]).id,
|
||||
'ability_feature_library': self.env['maintenance.equipment.image'].search(
|
||||
[('name', '=', item['ability_feature_library']), ('type', '=', '加工能力')]).id,
|
||||
'material_code': item['material_code'],
|
||||
'material_grade': item['material_grade'],
|
||||
'tensile_strength': item['tensile_strength'],
|
||||
'hardness': item['hardness'],
|
||||
'cutting_speed': item['cutting_speed'],
|
||||
'application': item['application'],
|
||||
'active': item['active'],
|
||||
})
|
||||
else:
|
||||
if item['active'] is False:
|
||||
item.write({'active': False})
|
||||
else:
|
||||
self.write({
|
||||
'execution_standard_id': self.env['sf.international.standards'].search(
|
||||
[('code', '=', item['execution_standard_code'])]).id,
|
||||
'material_name_id': self.env['sf.materials.model'].search(
|
||||
[('materials_no', '=', item['material_name'])]).id,
|
||||
'cutting_width_depth_id': self.env['sf.cutting.width.depth'].search(
|
||||
[('name', '=', item['cutting_width_depth'])]).id,
|
||||
'ability_feature_library': self.env['maintenance.equipment.image'].search(
|
||||
[('name', '=', item['ability_feature_library']), ('type', '=', '加工能力')]).id,
|
||||
'material_code': item['material_code'],
|
||||
'material_grade': item['material_grade'],
|
||||
'tensile_strength': item['tensile_strength'],
|
||||
'hardness': item['hardness'],
|
||||
'cutting_speed': item['cutting_speed'],
|
||||
'application': item['application'], })
|
||||
else:
|
||||
raise ValidationError("切削速度认证未通过")
|
||||
|
||||
def sync_all_cutting_speed(self):
|
||||
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_speed_all_list']:
|
||||
cutting_speed = self.search([("name", '=', item['name'])])
|
||||
if not cutting_speed:
|
||||
self.create({
|
||||
'name': item['name'],
|
||||
'standard_library_id': self.env['sf.cutting_tool.standard.library'].search(
|
||||
[('code', '=', item['standard_library_code'].replace("JKM", result[
|
||||
'factory_short_name']))]).id,
|
||||
'execution_standard_id': self.env['sf.international.standards'].search(
|
||||
[('code', '=', item['execution_standard_code'])]).id,
|
||||
'material_name_id': self.env['sf.materials.model'].search(
|
||||
[('materials_no', '=', item['material_name'])]).id,
|
||||
'cutting_width_depth_id': self.env['sf.cutting.width.depth'].search(
|
||||
[('name', '=', item['cutting_width_depth'])]).id,
|
||||
'ability_feature_library': self.env['maintenance.equipment.image'].search(
|
||||
[('name', '=', item['ability_feature_library']), ('type', '=', '加工能力')]).id,
|
||||
'material_code': item['material_code'],
|
||||
'material_grade': item['material_grade'],
|
||||
'tensile_strength': item['tensile_strength'],
|
||||
'hardness': item['hardness'],
|
||||
'cutting_speed': item['cutting_speed'],
|
||||
'application': item['application'],
|
||||
'active': item['active'],
|
||||
})
|
||||
else:
|
||||
if item['active'] is False:
|
||||
item.write({'active': False})
|
||||
else:
|
||||
self.write({
|
||||
'execution_standard_id': self.env['sf.international.standards'].search(
|
||||
[('code', '=', item['execution_standard_code'])]).id,
|
||||
'material_name_id': self.env['sf.materials.model'].search(
|
||||
[('materials_no', '=', item['material_name'])]).id,
|
||||
'cutting_width_depth_id': self.env['sf.cutting.width.depth'].search(
|
||||
[('name', '=', item['cutting_width_depth'])]).id,
|
||||
'ability_feature_library': self.env['maintenance.equipment.image'].search(
|
||||
[('name', '=', item['ability_feature_library']), ('type', '=', '加工能力')]).id,
|
||||
'material_code': item['material_code'],
|
||||
'material_grade': item['material_grade'],
|
||||
'tensile_strength': item['tensile_strength'],
|
||||
'hardness': item['hardness'],
|
||||
'cutting_speed': item['cutting_speed'],
|
||||
'application': item['application'], })
|
||||
else:
|
||||
raise ValidationError("切削速度认证未通过")
|
||||
|
||||
|
||||
class CuttingWidthDepth(models.Model):
|
||||
_inherit = 'sf.cutting.width.depth'
|
||||
_description = '切削宽度和深度'
|
||||
url = '/api/cutting_width_depth/list'
|
||||
|
||||
def sync_cutting_width_depth_yesterday(self):
|
||||
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_width_depth_yesterday_list']:
|
||||
cutting_width_depth = self.search([("name", '=', item['name'])])
|
||||
if not cutting_width_depth:
|
||||
self.create({
|
||||
'name': item['name'],
|
||||
})
|
||||
else:
|
||||
raise ValidationError("切削宽度和深度认证未通过")
|
||||
|
||||
def sync_all_cutting_width_depth(self):
|
||||
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_width_depth_all_list']:
|
||||
cutting_width_depth = self.search([("name", '=', item['name'])])
|
||||
if not cutting_width_depth:
|
||||
self.create({
|
||||
'name': item['name'],
|
||||
})
|
||||
else:
|
||||
raise ValidationError("切削宽度和深度认证未通过")
|
||||
|
||||
|
||||
class CuttingSpeed(models.Model):
|
||||
_inherit = 'sf.feed.per.tooth'
|
||||
_description = '每齿走刀量'
|
||||
url = '/api/feed_per_tooth/list'
|
||||
|
||||
def sync_feed_per_tooth_yesterday(self):
|
||||
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['feed_per_tooth_yesterday_list']:
|
||||
feed_per_tooth = self.search([("name", '=', item['name'])])
|
||||
if not feed_per_tooth:
|
||||
self.create({
|
||||
'name': item['name'],
|
||||
'standard_library_id': self.env['sf.cutting_tool.standard.library'].search(
|
||||
[('code', '=', item['standard_library_code'].replace("JKM", result[
|
||||
'factory_short_name']))]).id,
|
||||
'materials_type_id': self.env['sf.materials.model'].search(
|
||||
[('materials_no', '=', item['materials_type_code'])]).id,
|
||||
'cutting_width_depth_id': self.env['sf.cutting.width.depth'].search(
|
||||
[('name', '=', item['cutting_width_depth'])]).id,
|
||||
'blade_diameter': item['blade_diameter'],
|
||||
'feed_per_tooth': item['feed_per_tooth'],
|
||||
'active': item['active'],
|
||||
})
|
||||
else:
|
||||
if item['active'] is False:
|
||||
item.write({'active': False})
|
||||
else:
|
||||
self.write({
|
||||
'materials_type_id': self.env['sf.materials.model'].search(
|
||||
[('materials_no', '=', item['materials_type_code'])]).id,
|
||||
'cutting_width_depth_id': self.env['sf.cutting.width.depth'].search(
|
||||
[('name', '=', item['cutting_width_depth'])]).id,
|
||||
'blade_diameter': item['blade_diameter'],
|
||||
'feed_per_tooth': item['feed_per_tooth'], })
|
||||
else:
|
||||
raise ValidationError("每齿走刀量认证未通过")
|
||||
|
||||
def sync_all_feed_per_tooth(self):
|
||||
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['feed_per_tooth_all_list']:
|
||||
feed_per_tooth = self.search([("name", '=', item['name'])])
|
||||
if not feed_per_tooth:
|
||||
self.create({
|
||||
'name': item['name'],
|
||||
'standard_library_id': self.env['sf.cutting_tool.standard.library'].search(
|
||||
[('code', '=', item['standard_library_code'].replace("JKM", result[
|
||||
'factory_short_name']))]).id,
|
||||
'materials_type_id': self.env['sf.materials.model'].search(
|
||||
[('materials_no', '=', item['materials_type_code'])]).id,
|
||||
'cutting_width_depth_id': self.env['sf.cutting.width.depth'].search(
|
||||
[('name', '=', item['cutting_width_depth'])]).id,
|
||||
'blade_diameter': item['blade_diameter'],
|
||||
'feed_per_tooth': item['feed_per_tooth'],
|
||||
'active': item['active'],
|
||||
})
|
||||
else:
|
||||
if item['active'] is False:
|
||||
item.write({'active': False})
|
||||
else:
|
||||
self.write({
|
||||
'materials_type_id': self.env['sf.materials.model'].search(
|
||||
[('materials_no', '=', item['materials_type_code'])]).id,
|
||||
'cutting_width_depth_id': self.env['sf.cutting.width.depth'].search(
|
||||
[('name', '=', item['cutting_width_depth'])]).id,
|
||||
'blade_diameter': item['blade_diameter'],
|
||||
'feed_per_tooth': item['feed_per_tooth'], })
|
||||
else:
|
||||
raise ValidationError("每齿走刀量认证未通过")
|
||||
|
||||
|
||||
class Cutting_tool_standard_library(models.Model):
|
||||
_inherit = 'sf.cutting_tool.standard.library'
|
||||
_description = '刀具标准库'
|
||||
@@ -2197,6 +2439,7 @@ class CuttingToolBasicParameters(models.Model):
|
||||
'install_aperture_diameter': blade_item['diameter_mounting_hole'],
|
||||
'pitch': blade_item['pitch'],
|
||||
'chip_breaker_groove': blade_item['is_chip_breaker'],
|
||||
'chip_breaker_type_code': blade_item['chip_breaker_type_code'],
|
||||
'blade_teeth_model': '无' if not blade_item['blade_profile'] else blade_item[
|
||||
'blade_profile'],
|
||||
'blade_blade_number': blade_item['blade_number'],
|
||||
@@ -2216,7 +2459,6 @@ class CuttingToolBasicParameters(models.Model):
|
||||
'name': integral_tool_item['name'],
|
||||
'length': blade_item['length'],
|
||||
'thickness': blade_item['thickness'],
|
||||
'width': blade_item['width'],
|
||||
'cutting_blade_length': blade_item['cutting_blade_length'],
|
||||
'relief_angle': blade_item['relief_angle'],
|
||||
'blade_tip_circular_arc_radius': blade_item['radius_tip_re'],
|
||||
@@ -2224,6 +2466,7 @@ class CuttingToolBasicParameters(models.Model):
|
||||
'install_aperture_diameter': blade_item['diameter_mounting_hole'],
|
||||
'pitch': blade_item['pitch'],
|
||||
'chip_breaker_groove': blade_item['is_chip_breaker'],
|
||||
'chip_breaker_type_code': blade_item['chip_breaker_type_code'],
|
||||
'blade_teeth_model': '无' if not blade_item['blade_profile'] else blade_item[
|
||||
'blade_profile'],
|
||||
'blade_blade_number': blade_item['blade_number'],
|
||||
@@ -2546,6 +2789,7 @@ class CuttingToolBasicParameters(models.Model):
|
||||
'install_aperture_diameter': blade_item['diameter_mounting_hole'],
|
||||
'pitch': blade_item['pitch'],
|
||||
'chip_breaker_groove': blade_item['is_chip_breaker'],
|
||||
'chip_breaker_type_code': blade_item['chip_breaker_type_code'],
|
||||
'blade_teeth_model': '无' if not blade_item['blade_profile'] else blade_item[
|
||||
'blade_profile'],
|
||||
'blade_blade_number': blade_item['blade_number'],
|
||||
@@ -2575,6 +2819,7 @@ class CuttingToolBasicParameters(models.Model):
|
||||
'install_aperture_diameter': blade_item['diameter_mounting_hole'],
|
||||
'pitch': blade_item['pitch'],
|
||||
'chip_breaker_groove': blade_item['is_chip_breaker'],
|
||||
'chip_breaker_type_code': blade_item['chip_breaker_type_code'],
|
||||
'blade_teeth_model': '无' if not blade_item['blade_profile'] else blade_item[
|
||||
'blade_profile'],
|
||||
'blade_blade_number': blade_item['blade_number'],
|
||||
@@ -2587,7 +2832,6 @@ class CuttingToolBasicParameters(models.Model):
|
||||
'blade_tip_height_tolerance': blade_item['tip_height_tolerance'],
|
||||
'inscribed_circle_tolerance': blade_item['internal_circle_tolerance'],
|
||||
'thickness_tolerance': blade_item['thickness_tolerance'],
|
||||
'active': blade_item['active'],
|
||||
})
|
||||
basic_parameters_chuck_list = json.loads(
|
||||
result['cutting_tool_basic_parameters_all_list']['basic_parameters_chuck'])
|
||||
@@ -2634,7 +2878,6 @@ class CuttingToolBasicParameters(models.Model):
|
||||
'weight': chuck_item['weight'],
|
||||
'max_load_capacity': chuck_item['load_capacity_max'],
|
||||
'cooling_jacket': chuck_item['cooling_sleeve_model'],
|
||||
'active': chuck_item['active'],
|
||||
})
|
||||
basic_parameters_cutter_arbor_list = json.loads(
|
||||
result['cutting_tool_basic_parameters_all_list']['basic_parameters_cutter_arbor'])
|
||||
@@ -2705,7 +2948,6 @@ class CuttingToolBasicParameters(models.Model):
|
||||
'pressing_plate': cutter_arbor_item['fit_plate_model'],
|
||||
'screw': cutter_arbor_item['fit_screw_model'],
|
||||
'spanner': cutter_arbor_item['fit_wrench_model'],
|
||||
'active': cutter_arbor_item['active'],
|
||||
})
|
||||
basic_parameters_cutter_head_list = json.loads(
|
||||
result['cutting_tool_basic_parameters_all_list']['basic_parameters_cutter_head'])
|
||||
@@ -2762,7 +3004,6 @@ class CuttingToolBasicParameters(models.Model):
|
||||
'spanner': cutter_head_item['fit_wrench_model'],
|
||||
'is_cooling_hole': cutter_head_item['is_cooling_hole'],
|
||||
'locating_slot_code': cutter_head_item['locator_slot_code'],
|
||||
'active': cutter_head_item['active'],
|
||||
})
|
||||
basic_parameters_knife_handle_list = json.loads(
|
||||
result['cutting_tool_basic_parameters_all_list']['basic_parameters_knife_handle'])
|
||||
|
||||
Reference in New Issue
Block a user