Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/刀具物料与夹具物料的反注册
This commit is contained in:
@@ -451,11 +451,13 @@ class MachineControlSystem(models.Model):
|
||||
brand.id = item['id'],
|
||||
brand.name = item['name'],
|
||||
brand.code = item['code'],
|
||||
brand.remark = item['remark'],
|
||||
brand.brand_id = self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])]).id,
|
||||
brand.active = item['active']
|
||||
else:
|
||||
self.env['sf.machine.control_system'].create({
|
||||
"id": item['id'],
|
||||
"remark": item['remark'],
|
||||
"name": item['name'],
|
||||
"code": item['code'],
|
||||
|
||||
@@ -489,6 +491,7 @@ class MachineControlSystem(models.Model):
|
||||
"id": item['id'],
|
||||
"name": item['name'],
|
||||
"code": item['code'],
|
||||
"remark": item['remark'],
|
||||
'brand_id': self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])]).id,
|
||||
|
||||
"active": item['active'],
|
||||
@@ -525,7 +528,6 @@ class MachineBrand(models.Model):
|
||||
brand.name = item['name'],
|
||||
brand.code = item['code'],
|
||||
brand.image_brand = '' if not item['image_brand'] else base64.b64encode(item.image_brand),
|
||||
brand.manufacturer_model_number = item['manufacturer_model_number'],
|
||||
brand.active = item['active']
|
||||
else:
|
||||
self.env['sf.machine.brand'].create({
|
||||
@@ -533,7 +535,6 @@ class MachineBrand(models.Model):
|
||||
"name": item['name'],
|
||||
"code": item['code'],
|
||||
"image_brand": '' if not item['image_brand'] else base64.b64encode(item.image_brand),
|
||||
"manufacturer_model_number": item['manufacturer_model_number'],
|
||||
"active": item['active'],
|
||||
|
||||
})
|
||||
@@ -561,7 +562,6 @@ class MachineBrand(models.Model):
|
||||
"id": item['id'],
|
||||
"name": item['name'],
|
||||
"code": item['code'],
|
||||
"manufacturer_model_number": item['manufacturer_model_number'],
|
||||
"image_brand": '' if not item['image_brand'] else base64.b64encode(item.image_brand),
|
||||
"tag_ids": self.env['sf.machine.brand.tags'].search(
|
||||
[("name", 'in', item['tag_ids'])]).ids
|
||||
@@ -570,122 +570,6 @@ class MachineBrand(models.Model):
|
||||
raise ValidationError("认证未通过")
|
||||
|
||||
|
||||
class MachineTool(models.Model):
|
||||
_inherit = 'sf.machine_tool'
|
||||
_description = '机床'
|
||||
url = '/api/machine_tool/list'
|
||||
crea_url = '/api/machine_tool/create'
|
||||
|
||||
# 定时同步机床
|
||||
def sync_machine_tool(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['machine_tool_all_yesterday_list']:
|
||||
brand = self.env['sf.machine_tool'].search(
|
||||
[("code", '=', item['code'])])
|
||||
if brand:
|
||||
brand.id = item['id'],
|
||||
brand.name = item['name'],
|
||||
brand.code = item['code'],
|
||||
brand.precision = item['precision'],
|
||||
|
||||
brand.knife_type = item['knife_type'],
|
||||
brand.registration_date = item['registration_date'],
|
||||
brand.number_of_knife_library = item['number_of_knife_library'],
|
||||
brand.rotate_speed = item['rotate_speed'],
|
||||
brand.number_of_axles = item['number_of_axles'],
|
||||
# brand.control_system_id = item['control_system_id'],
|
||||
brand.type_id = item['type_id'],
|
||||
brand.brand_id = item['brand_id'],
|
||||
brand.x_axis = item['x_axis'],
|
||||
brand.y_axis = item['y_axis'],
|
||||
brand.z_axis = item['z_axis'],
|
||||
brand.b_axis = item['b_axis'],
|
||||
brand.c_axis = item['c_axis'],
|
||||
brand.state = item['state'],
|
||||
brand.active = item['active']
|
||||
|
||||
else:
|
||||
self.env['sf.machine_tool'].create({
|
||||
"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'],
|
||||
"number_of_knife_library": item['number_of_knife_library'],
|
||||
"rotate_speed": item['rotate_speed'],
|
||||
"number_of_axles": item['number_of_axles'],
|
||||
# "control_system_id": item['control_system_id'],
|
||||
"type_id": item['type_id'],
|
||||
"brand_id": item['brand_id'],
|
||||
"x_axis": item['x_axis'],
|
||||
"y_axis": item['y_axis'],
|
||||
"z_axis": item['z_axis'],
|
||||
"b_axis": item['b_axis'],
|
||||
"c_axis": item['c_axis'],
|
||||
"state": item['state'],
|
||||
"active": item['active'],
|
||||
# "tag_ids": item['tag_ids']
|
||||
|
||||
})
|
||||
else:
|
||||
raise ValidationError("认证未通过")
|
||||
|
||||
# 同步所有机床
|
||||
def sync_all_machine_tool(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['machine_tool_all_list']:
|
||||
brand = self.env['sf.machine_tool'].search(
|
||||
[("code", '=', item['code'])])
|
||||
if not brand:
|
||||
self.env['sf.machine_tool'].create({
|
||||
|
||||
"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'],
|
||||
"number_of_knife_library": item['number_of_knife_library'],
|
||||
"rotate_speed": item['rotate_speed'],
|
||||
"number_of_axles": item['number_of_axles'],
|
||||
# "control_system_id": item['control_system_id'],
|
||||
"type_id": item['type_id'],
|
||||
'brand_id': self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])]).id,
|
||||
"x_axis": item['x_axis'],
|
||||
"y_axis": item['y_axis'],
|
||||
"z_axis": item['z_axis'],
|
||||
"b_axis": item['b_axis'],
|
||||
"c_axis": item['c_axis'],
|
||||
"state": item['state'],
|
||||
"active": item['active'],
|
||||
# "tag_ids": item['tag_ids']
|
||||
|
||||
})
|
||||
else:
|
||||
raise ValidationError("认证未通过")
|
||||
|
||||
|
||||
class MachineToolType(models.Model):
|
||||
_inherit = 'sf.machine_tool.type'
|
||||
_description = '机床型号'
|
||||
@@ -727,8 +611,6 @@ class MachineToolType(models.Model):
|
||||
brand.active = item['active'],
|
||||
brand.remark = item['remark'],
|
||||
brand.brand_id = self.env['sf.machine.brand'].search([('code', '=', item['brand_id'])]).id,
|
||||
brand.machine_tool_id = self.env['sf.machine_tool'].search(
|
||||
[('code', '=', item['machine_tool_id'])]).id
|
||||
|
||||
else:
|
||||
# print(item['machine_tool_picture'].encode('utf-8'))
|
||||
@@ -740,8 +622,6 @@ class MachineToolType(models.Model):
|
||||
|
||||
"number_of_knife_library": item['number_of_knife_library'],
|
||||
"rotate_speed": item['rotate_speed'],
|
||||
'machine_tool_id': self.env['sf.machine_tool'].search(
|
||||
[('code', '=', item['machine_tool_id'])]).id,
|
||||
"number_of_axles": item['number_of_axles'],
|
||||
"x_axis": item['x_axis'],
|
||||
"y_axis": item['y_axis'],
|
||||
@@ -810,8 +690,6 @@ class MachineToolType(models.Model):
|
||||
|
||||
"number_of_knife_library": item['number_of_knife_library'],
|
||||
"rotate_speed": item['rotate_speed'],
|
||||
'machine_tool_id': self.env['sf.machine_tool'].search(
|
||||
[('code', '=', item['machine_tool_id'])]).id,
|
||||
"number_of_axles": item['number_of_axles'],
|
||||
"x_axis": item['x_axis'],
|
||||
"y_axis": item['y_axis'],
|
||||
@@ -856,11 +734,8 @@ class MachineToolType(models.Model):
|
||||
"id": item['id'],
|
||||
"name": item['name'],
|
||||
"code": item['code'],
|
||||
|
||||
"number_of_knife_library": item['number_of_knife_library'],
|
||||
"rotate_speed": item['rotate_speed'],
|
||||
'machine_tool_id': self.env['sf.machine_tool'].search(
|
||||
[('code', '=', item['machine_tool_id'])]).id,
|
||||
"number_of_axles": item['number_of_axles'],
|
||||
"x_axis": item['x_axis'],
|
||||
"y_axis": item['y_axis'],
|
||||
@@ -1053,19 +928,22 @@ class MachineToolCategory(models.Model):
|
||||
result = json.loads(r['result'])
|
||||
if result['status'] == 1:
|
||||
for item in result['machine_tool_category_yesterday_list']:
|
||||
brand = self.env['sf.machine_tool.category'].search(
|
||||
machine_tool_category = self.env['sf.machine_tool.category'].search(
|
||||
[("code", '=', item['code'])])
|
||||
if brand:
|
||||
brand.name = item['name'],
|
||||
brand.code = item['code'],
|
||||
brand.category = item['category'],
|
||||
brand.remark = item['remark']
|
||||
|
||||
if machine_tool_category:
|
||||
machine_tool_category.name = item['name'],
|
||||
machine_tool_category.code = item['code'],
|
||||
machine_tool_category.category = item['category'],
|
||||
machine_tool_category.remark = item['remark']
|
||||
machine_tool_category.active = item['active']
|
||||
else:
|
||||
brand.name = item['name'],
|
||||
brand.code = item['code'],
|
||||
brand.category = item['category'],
|
||||
brand.remark = item['remark']
|
||||
self.env['sf.machine_tool.category'].create({
|
||||
"name": item['name'],
|
||||
"code": item['code'],
|
||||
"category": item['category'],
|
||||
"remark": item['remark'],
|
||||
"active": item['active'],
|
||||
})
|
||||
else:
|
||||
raise ValidationError("认证未通过")
|
||||
|
||||
@@ -1126,12 +1004,14 @@ class sfSyncCutting_tool_Material(models.Model):
|
||||
"name": item['name'],
|
||||
"code": item['code'],
|
||||
"remark": item['remark'],
|
||||
"active": item['active'],
|
||||
})
|
||||
else:
|
||||
brand.write({
|
||||
"name": item['name'],
|
||||
"code": item['code'],
|
||||
"remark": item['remark'],
|
||||
"active": item['active'],
|
||||
})
|
||||
else:
|
||||
raise ValidationError("认证未通过")
|
||||
@@ -1159,12 +1039,14 @@ class sfSyncCutting_tool_Material(models.Model):
|
||||
"name": item['name'],
|
||||
"code": item['code'],
|
||||
"remark": item['remark'],
|
||||
"active": item['active'],
|
||||
})
|
||||
else:
|
||||
brand.write({
|
||||
"name": item['name'],
|
||||
"code": item['code'],
|
||||
"remark": item['remark'],
|
||||
"active": item['active'],
|
||||
})
|
||||
|
||||
|
||||
@@ -1384,6 +1266,7 @@ class SyncFunctionalCuttingToolModel(models.Model):
|
||||
"name": item['name'],
|
||||
"code": item['code'],
|
||||
"remark": item['remark'],
|
||||
|
||||
})
|
||||
else:
|
||||
brand.write({
|
||||
@@ -1613,7 +1496,6 @@ class SyncFixtureModel(models.Model):
|
||||
"multi_mounting_type_id": self.env['sf.multi_mounting.type'].search(
|
||||
[('code', '=', item['multi_mounting_type_code'])]).id,
|
||||
"brand_id": self.env['sf.machine.brand'].search([('code', '=', item['brand_code'])]).id,
|
||||
"manufacturer_model_number": item['manufacturer_model_number'],
|
||||
"clamping_way": item['clamping_way'],
|
||||
"port_type": item['port_type'],
|
||||
"model_file": '' if not item['model_file'] else base64.b64decode(item['model_file']),
|
||||
@@ -1634,6 +1516,7 @@ class SyncFixtureModel(models.Model):
|
||||
[('code', '=', item['apply_machine_tool_type_code'])]).id,
|
||||
"through_hole_size": item['through_hole_size'],
|
||||
"screw_size": item['screw_size'],
|
||||
"active": item['active'],
|
||||
})
|
||||
else:
|
||||
fixture_model.write({
|
||||
@@ -1643,7 +1526,6 @@ class SyncFixtureModel(models.Model):
|
||||
"multi_mounting_type_id": self.env['sf.multi_mounting.type'].search(
|
||||
[('code', '=', item['multi_mounting_type_code'])]).id,
|
||||
"brand_id": self.env['sf.machine.brand'].search([('code', '=', item['brand_code'])]).id,
|
||||
"manufacturer_model_number": item['manufacturer_model_number'],
|
||||
"clamping_way": item['clamping_way'],
|
||||
"port_type": item['port_type'],
|
||||
"model_file": '' if not item['model_file'] else base64.b64decode(item['model_file']),
|
||||
@@ -1664,6 +1546,7 @@ class SyncFixtureModel(models.Model):
|
||||
[('code', '=', item['apply_machine_tool_type_code'])]).id,
|
||||
"through_hole_size": item['through_hole_size'],
|
||||
"screw_size": item['screw_size'],
|
||||
"active": item['active'],
|
||||
})
|
||||
else:
|
||||
raise ValidationError("认证未通过")
|
||||
@@ -1695,7 +1578,6 @@ class SyncFixtureModel(models.Model):
|
||||
"multi_mounting_type_id": self.env['sf.multi_mounting.type'].search(
|
||||
[('code', '=', item['multi_mounting_type_code'])]).id,
|
||||
"brand_id": self.env['sf.machine.brand'].search([('code', '=', item['brand_code'])]).id,
|
||||
"manufacturer_model_number": item['manufacturer_model_number'],
|
||||
"clamping_way": item['clamping_way'],
|
||||
"port_type": item['port_type'],
|
||||
"model_file": '' if not item['model_file'] else base64.b64decode(item['model_file']),
|
||||
@@ -1716,6 +1598,7 @@ class SyncFixtureModel(models.Model):
|
||||
[('code', '=', item['apply_machine_tool_type_code'])]).id,
|
||||
"through_hole_size": item['through_hole_size'],
|
||||
"screw_size": item['screw_size'],
|
||||
"active": item['active'],
|
||||
})
|
||||
else:
|
||||
fixture_model.write({
|
||||
@@ -1725,7 +1608,6 @@ class SyncFixtureModel(models.Model):
|
||||
"multi_mounting_type_id": self.env['sf.multi_mounting.type'].search(
|
||||
[('code', '=', item['multi_mounting_type_code'])]).id,
|
||||
"brand_id": self.env['sf.machine.brand'].search([('code', '=', item['brand_code'])]).id,
|
||||
"manufacturer_model_number": item['manufacturer_model_number'],
|
||||
"clamping_way": item['clamping_way'],
|
||||
"port_type": item['port_type'],
|
||||
"model_file": '' if not item['model_file'] else base64.b64decode(item['model_file']),
|
||||
@@ -1746,6 +1628,7 @@ class SyncFixtureModel(models.Model):
|
||||
[('code', '=', item['apply_machine_tool_type_code'])]).id,
|
||||
"through_hole_size": item['through_hole_size'],
|
||||
"screw_size": item['screw_size'],
|
||||
"active": item['active'],
|
||||
})
|
||||
else:
|
||||
raise ValidationError("认证未通过")
|
||||
@@ -2060,14 +1943,14 @@ class SfToolModel(models.Model):
|
||||
mrs_cutting_tool_model_blade_cutter_bar_ids_list = []
|
||||
if item.get('mrs_cutting_tool_model_blade_cutter_bar_ids'):
|
||||
for mrs_cutting_tool_model_blade_cutter_bar_id in item[
|
||||
'mrs_cutting_tool_model_blade_cutter_bar_ids']:
|
||||
'mrs_cutting_tool_model_blade_cutter_bar_ids']:
|
||||
mrs_cutting_tool_model_blade_cutter_bar_ids_list.append(
|
||||
self.env['sf.cutting.tool.model'].search(
|
||||
[("code", '=', mrs_cutting_tool_model_blade_cutter_bar_id)]).id)
|
||||
mrs_cutting_tool_model_blade_cutter_pad_ids_list = []
|
||||
if item.get('mrs_cutting_tool_model_blade_cutter_pad_ids'):
|
||||
for mrs_cutting_tool_model_blade_cutter_pad_id in item[
|
||||
'mrs_cutting_tool_model_blade_cutter_pad_ids']:
|
||||
'mrs_cutting_tool_model_blade_cutter_pad_ids']:
|
||||
mrs_cutting_tool_model_blade_cutter_pad_ids_list.append(
|
||||
self.env['sf.cutting.tool.model'].search(
|
||||
[("code", '=', mrs_cutting_tool_model_blade_cutter_pad_id)]).id)
|
||||
@@ -2084,14 +1967,14 @@ class SfToolModel(models.Model):
|
||||
mrs_cutting_tool_model_handle_chuck_model_ids_list = []
|
||||
if item.get('mrs_cutting_tool_model_handle_chuck_model_ids'):
|
||||
for mrs_cutting_tool_model_handle_chuck_model_id in item[
|
||||
'mrs_cutting_tool_model_handle_chuck_model_ids']:
|
||||
'mrs_cutting_tool_model_handle_chuck_model_ids']:
|
||||
mrs_cutting_tool_model_handle_chuck_model_ids_list.append(
|
||||
self.env['sf.cutting.tool.model'].search(
|
||||
[("code", '=', mrs_cutting_tool_model_handle_chuck_model_id)]).id)
|
||||
mrs_cutting_tool_model_chuck_handle_model_ids_list = []
|
||||
if item.get('mrs_cutting_tool_model_chuck_handle_model_ids'):
|
||||
for mrs_cutting_tool_model_chuck_handle_model_id in item[
|
||||
'mrs_cutting_tool_model_chuck_handle_model_ids']:
|
||||
'mrs_cutting_tool_model_chuck_handle_model_ids']:
|
||||
mrs_cutting_tool_model_chuck_handle_model_ids_list.append(
|
||||
self.env['sf.cutting.tool.model'].search(
|
||||
[("code", '=', mrs_cutting_tool_model_chuck_handle_model_id)]).id)
|
||||
@@ -2344,14 +2227,14 @@ class SfToolModel(models.Model):
|
||||
mrs_cutting_tool_model_blade_cutter_bar_ids_list = []
|
||||
if item.get('mrs_cutting_tool_model_blade_cutter_bar_ids'):
|
||||
for mrs_cutting_tool_model_blade_cutter_bar_id in item[
|
||||
'mrs_cutting_tool_model_blade_cutter_bar_ids']:
|
||||
'mrs_cutting_tool_model_blade_cutter_bar_ids']:
|
||||
mrs_cutting_tool_model_blade_cutter_bar_ids_list.append(
|
||||
self.env['sf.cutting.tool.model'].search(
|
||||
[("code", '=', mrs_cutting_tool_model_blade_cutter_bar_id)]).id)
|
||||
mrs_cutting_tool_model_blade_cutter_pad_ids_list = []
|
||||
if item.get('mrs_cutting_tool_model_blade_cutter_pad_ids'):
|
||||
for mrs_cutting_tool_model_blade_cutter_pad_id in item[
|
||||
'mrs_cutting_tool_model_blade_cutter_pad_ids']:
|
||||
'mrs_cutting_tool_model_blade_cutter_pad_ids']:
|
||||
mrs_cutting_tool_model_blade_cutter_pad_ids_list.append(
|
||||
self.env['sf.cutting.tool.model'].search(
|
||||
[("code", '=', mrs_cutting_tool_model_blade_cutter_pad_id)]).id)
|
||||
@@ -2368,14 +2251,14 @@ class SfToolModel(models.Model):
|
||||
mrs_cutting_tool_model_handle_chuck_model_ids_list = []
|
||||
if item.get('mrs_cutting_tool_model_handle_chuck_model_ids'):
|
||||
for mrs_cutting_tool_model_handle_chuck_model_id in item[
|
||||
'mrs_cutting_tool_model_handle_chuck_model_ids']:
|
||||
'mrs_cutting_tool_model_handle_chuck_model_ids']:
|
||||
mrs_cutting_tool_model_handle_chuck_model_ids_list.append(
|
||||
self.env['sf.cutting.tool.model'].search(
|
||||
[("code", '=', mrs_cutting_tool_model_handle_chuck_model_id)]).id)
|
||||
mrs_cutting_tool_model_chuck_handle_model_ids_list = []
|
||||
if item.get('mrs_cutting_tool_model_chuck_handle_model_ids'):
|
||||
for mrs_cutting_tool_model_chuck_handle_model_id in item[
|
||||
'mrs_cutting_tool_model_chuck_handle_model_ids']:
|
||||
'mrs_cutting_tool_model_chuck_handle_model_ids']:
|
||||
mrs_cutting_tool_model_chuck_handle_model_ids_list.append(
|
||||
self.env['sf.cutting.tool.model'].search(
|
||||
[("code", '=', mrs_cutting_tool_model_chuck_handle_model_id)]).id)
|
||||
|
||||
Reference in New Issue
Block a user