Accept Merge Request #2188: (hotfix/修复刀具预警没有预警记录和通知 -> develop)
Merge Request: 功能刀具寿命到期消息通知 Created By: @胡尧 Accepted By: @胡尧 URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/2188
This commit is contained in:
@@ -107,38 +107,47 @@ class MrsShelfLocationDataSync(models.Model):
|
||||
equipment_id.register_equipment_tool()
|
||||
|
||||
shelfinfo = self.env['sf.shelf.location'].get_sf_shelf_location_info()
|
||||
total_data = self.get_total_data()
|
||||
print('shelfinfo:', shelfinfo)
|
||||
for item in shelfinfo:
|
||||
logging.info('货架已获取信息:%s' % item)
|
||||
shelf_barcode = self.find_our_code(total_data, item['Postion'])
|
||||
location_id = self.env['sf.shelf.location'].search([('barcode', '=', shelf_barcode)], limit=1)
|
||||
if location_id:
|
||||
# 如果是线边刀库信息,则对功能刀具移动生成记录
|
||||
if 'Tool' in item['Postion']:
|
||||
tool = self.env['sf.functional.cutting.tool.entity'].sudo().search(
|
||||
[('rfid', '=', item['RfidCode']), ('functional_tool_status', '!=', '已拆除')])
|
||||
tool.tool_in_out_stock_location(location_id)
|
||||
if tool:
|
||||
location_id.product_sn_id = tool.barcode_id.id
|
||||
# 修改功能刀具标准状态值和已使用寿命值、功能刀具状态
|
||||
if 'LifeStd' in item and 'LifeUse' in item:
|
||||
tool.sudo().write({
|
||||
'max_lifetime_value': item['LifeStd'],
|
||||
'used_value': item['LifeUse'],
|
||||
'functional_tool_status': item['State'],
|
||||
})
|
||||
else:
|
||||
location_id.product_sn_id = False
|
||||
if item['RfidCode']:
|
||||
logging.info('Rfid为【%s】的功能刀具在系统中不存在!' % item['RfidCode'])
|
||||
else:
|
||||
stock_lot_obj = self.env['stock.lot'].search([('rfid', '=', item['RfidCode'])], limit=1)
|
||||
if stock_lot_obj:
|
||||
location_id.product_sn_id = stock_lot_obj.id
|
||||
else:
|
||||
location_id.product_sn_id = False
|
||||
self.set_shelf_location(shelfinfo)
|
||||
|
||||
except Exception as e:
|
||||
logging.info("库区信息同步失败:%s" % e)
|
||||
raise ValidationError("数据错误导致同步失败,请联系管理员")
|
||||
|
||||
def set_shelf_location(self, shelfinfo):
|
||||
print('shelfinfo:', shelfinfo)
|
||||
total_data = self.get_total_data()
|
||||
for item in shelfinfo:
|
||||
logging.info('货架已获取信息:%s' % item)
|
||||
shelf_barcode = self.env['sf.shelf.location.datasync'].sudo().find_our_code(
|
||||
total_data, item['Postion'])
|
||||
location_id = self.env['sf.shelf.location'].sudo().search(
|
||||
[('barcode', '=', shelf_barcode)],
|
||||
limit=1)
|
||||
if location_id:
|
||||
# 如果是线边刀库信息,则对功能刀具移动生成记录
|
||||
if 'Tool' in item['Postion']:
|
||||
tool = self.env['sf.functional.cutting.tool.entity'].sudo().search(
|
||||
[('rfid', '=', item['RfidCode']), ('functional_tool_status', '!=', '已拆除')])
|
||||
tool.sudo().tool_in_out_stock_location(location_id)
|
||||
if tool:
|
||||
location_id.product_sn_id = tool.barcode_id.id
|
||||
if item.get('State') == '报警' and tool.functional_tool_status != '报警':
|
||||
# 创建报警刀具拆解单和刀具报警记录
|
||||
tool.create_tool_dismantle()
|
||||
# 修改功能刀具标准状态值和已使用寿命值、功能刀具状态
|
||||
if 'LifeStd' in item and 'LifeUse' in item:
|
||||
tool.sudo().write({
|
||||
'max_lifetime_value': item['LifeStd'],
|
||||
'used_value': item['LifeUse'],
|
||||
'functional_tool_status': item['State'],
|
||||
})
|
||||
else:
|
||||
location_id.product_sn_id = False
|
||||
if item['RfidCode']:
|
||||
logging.info('Rfid为【%s】的功能刀具在系统中不存在!' % item['RfidCode'])
|
||||
else:
|
||||
stock_lot_obj = self.env['stock.lot'].search([('rfid', '=', item['RfidCode'])], limit=1)
|
||||
if stock_lot_obj:
|
||||
location_id.product_sn_id = stock_lot_obj.id
|
||||
else:
|
||||
location_id.product_sn_id = False
|
||||
|
||||
Reference in New Issue
Block a user