1、库位变更接口、库位信息接口优化;2、功能刀具预警模型优化;

This commit is contained in:
yuxianghui
2024-08-09 17:19:03 +08:00
parent 36fd17b6c7
commit e6ca4c27ac
6 changed files with 173 additions and 134 deletions

View File

@@ -507,13 +507,13 @@ class ShelfLocation(models.Model):
print('eeeeeee空闲', e)
# 调取获取货位信息接口
def get_sf_shelf_location_info(self):
def get_sf_shelf_location_info(self, device_id='Cabinet-AL'):
config = self.env['res.config.settings'].get_values()
headers = {'Authorization': config['center_control_Authorization']}
crea_url = config['center_control_url'] + "/AutoDeviceApi/GetLocationInfos"
params = {'DeviceId': 'Cabinet-AL'}
params = {'DeviceId': device_id}
r = requests.get(crea_url, params=params, headers=headers)
ret = r.json()

View File

@@ -13,13 +13,14 @@ class MrsShelfLocationDataSync(models.Model):
_name = 'sf.shelf.location.datasync'
_description = '同步库存信息'
def _cron_shelf_location_datasync(self):
try:
# 建立对应关系的函数
def align_data(my_data, their_data):
paired_data = list(zip(my_data, their_data))
return paired_data
def find_our_code(self, their_code):
# 建立对应关系的函数
def align_data(my_data, their_data):
paired_data = list(zip(my_data, their_data))
return paired_data
def get_total_data():
shelf_1_obj = self.env['sf.shelf'].search([('name', '=', '一号产线-一号线边刀架')], limit=1)
tool_location_objs_1 = self.env['sf.shelf.location'].search([('shelf_id', '=', shelf_1_obj.id)], order='id')
@@ -82,19 +83,21 @@ class MrsShelfLocationDataSync(models.Model):
total_data = aligned_data_1 + aligned_data_2 + aligned_data_3 + aligned_data_4 + aligned_data_5
print(total_data)
logging.info(f"total_data: {total_data}")
return total_data
for code_pair in get_total_data():
if code_pair[1] == their_code:
return code_pair[0]
return None # 如果没有找到对应的值返回None或适当的默认值
def _cron_shelf_location_datasync(self):
try:
def find_their_code(my_code, aligned_data):
for code_pair in aligned_data:
if code_pair[0] == my_code:
return code_pair[1]
return None # 如果没有找到对应的值返回None或适当的默认值
def find_our_code(their_code, aligned_data):
for code_pair in aligned_data:
if code_pair[1] == their_code:
return code_pair[0]
return None # 如果没有找到对应的值返回None或适当的默认值
# 定时更新所有设备机床刀库信息
equipment_ids = self.env['maintenance.equipment'].search(
[('equipment_type', '=', '机床'), ('function_type', '!=', False)])
@@ -105,7 +108,7 @@ class MrsShelfLocationDataSync(models.Model):
shelfinfo = self.env['sf.shelf.location'].get_sf_shelf_location_info()
print('shelfinfo:', shelfinfo)
for item in shelfinfo:
shelf_barcode = find_our_code(item['Postion'], total_data)
shelf_barcode = self.find_our_code(item['Postion'])
location_id = self.env['sf.shelf.location'].search([('barcode', '=', shelf_barcode)], limit=1)
if location_id:
# 如果是线边刀库信息,则对功能刀具移动生成记录