1、优化货位变更接口、优化同步库存信息接口;2、隐藏已取消状态的销售订单的【确认接单】和【取消】按钮;3、处理功能刀具从线边刀库到刀具房没有生成移动历史问题;

This commit is contained in:
yuxianghui
2024-08-15 16:45:39 +08:00
parent bf34de58fc
commit 366e816268
5 changed files with 104 additions and 85 deletions

View File

@@ -386,7 +386,7 @@ class Manufacturing_Connect(http.Controller):
ret = json.loads(datas) ret = json.loads(datas)
request.env['center_control.interface.log'].sudo().create( request.env['center_control.interface.log'].sudo().create(
{'content': ret, 'name': 'AutoDeviceApi/LocationChange'}) {'content': ret, 'name': 'AutoDeviceApi/LocationChange'})
logging.info('LocationChange_ret===========:%s' % ret) logging.info('库位变更LocationChange_ret:%s' % ret)
RfidCode = ret['RfidCode'] RfidCode = ret['RfidCode']
ChangeType = ret['ChangeType'] ChangeType = ret['ChangeType']
OldDeciveId = ret['OldDeciveId'] OldDeciveId = ret['OldDeciveId']
@@ -429,25 +429,36 @@ class Manufacturing_Connect(http.Controller):
# 对功能刀具库位变更信息进行更改 # 对功能刀具库位变更信息进行更改
def write_tool(DeciveId): def write_tool(DeciveId):
if 'Tool' in DeciveId: if 'Tool' in DeciveId:
shelfinfo = self.env['sf.shelf.location'].get_sf_shelf_location_info(DeciveId) shelfinfo = list(filter(lambda x: x.get('DeviceId') == DeciveId,
request.env['sf.shelf.location'].sudo().get_sf_shelf_location_info(
DeciveId)))
total_data = request.env['sf.shelf.location.datasync'].sudo().get_total_data()
for item in shelfinfo: for item in shelfinfo:
shelf_barcode = self.env['sf.shelf.location.datasync'].find_our_code(item['Postion']) shelf_barcode = request.env['sf.shelf.location.datasync'].sudo().find_our_code(
location_id = self.env['sf.shelf.location'].search([('barcode', '=', shelf_barcode)], total_data, item['Postion'])
location_id = request.env['sf.shelf.location'].sudo().search(
[('barcode', '=', shelf_barcode)],
limit=1) limit=1)
if location_id: if location_id:
# 如果是线边刀库信息,则对功能刀具移动生成记录 # 如果是线边刀库信息,则对功能刀具移动生成记录
if 'Tool' in item['Postion']: if 'Tool' in item['Postion']:
tool = self.env['sf.functional.cutting.tool.entity'].sudo().search( tool = request.env['sf.functional.cutting.tool.entity'].sudo().search(
[('rfid', '=', item['RfidCode']), ('functional_tool_status', '!=', '已拆除')]) [('rfid', '=', item['RfidCode']), ('functional_tool_status', '!=', '已拆除')])
tool.tool_in_out_stock_location(location_id) tool.sudo().tool_in_out_stock_location(location_id)
if tool: if tool:
location_id.product_sn_id = tool.barcode_id.id location_id.product_sn_id = tool.barcode_id.id
# 修改功能刀具状态
# tool_install_time = {'Nomal': '正常', 'Warning': '报警'}
# tool.write({
# 'functional_tool_status': tool_install_time.get(item['State'])
# })
else: else:
location_id.product_sn_id = False location_id.product_sn_id = False
logging.info('货架已获取信息:%s' % item)
else: else:
equipment_id = self.env['maintenance.equipment'].search([('name', '=', DeciveId)]) equipment_id = request.env['maintenance.equipment'].sudo().search([('name', '=', DeciveId)])
if equipment_id: if equipment_id:
equipment_id.register_equipment_tool() equipment_id.sudo().register_equipment_tool()
else: else:
res_1 = {'Succeed': False, 'ErrorCode': 202, 'Error': f'设备【{DeciveId}】不存在'} res_1 = {'Succeed': False, 'ErrorCode': 202, 'Error': f'设备【{DeciveId}】不存在'}
return json.JSONEncoder().encode(res_1) return json.JSONEncoder().encode(res_1)

View File

@@ -42,12 +42,12 @@
<xpath expr="//form/header/button[@name='action_confirm'][2]" position="replace"> <xpath expr="//form/header/button[@name='action_confirm'][2]" position="replace">
<button name="action_confirm" data-hotkey="v" <button name="action_confirm" data-hotkey="v"
string="确认接单" type="object" context="{'validate_analytic': True}" string="确认接单" type="object" context="{'validate_analytic': True}"
attrs="{'invisible': ['|','&amp;',('check_status', '!=', 'approved'),('state', 'in', ['draft','cancel']),'&amp;','&amp;',('check_status', '=', 'approved'),('state', 'in', ['sale','cancel']),('delivery_status', '!=', False)]}"/> attrs="{'invisible': ['|','&amp;','|',('check_status', '!=', 'approved'),('state', 'in', ['draft','cancel']),'&amp;','&amp;',('check_status', '=', 'approved'),('state', 'in', ['sale','cancel']),('delivery_status', '!=', False),('state', 'in', ['cancel'])]}"/>
</xpath> </xpath>
<xpath expr="//form/header/button[@name='action_cancel']" position="attributes"> <xpath expr="//form/header/button[@name='action_cancel']" position="attributes">
<attribute name="attrs">{'invisible': ['|','&amp;',('check_status', '!=', 'approved'),('state', <attribute name="attrs">{'invisible': ['|','&amp;','|', ('check_status', '!=', 'approved'),('state',
'in', ['draft','cancel']),'&amp;','&amp;',('check_status', '=', 'approved'),('state', 'in', 'in', ['draft','cancel']),'&amp;','&amp;',('check_status', '=', 'approved'),('state', 'in',
['sale','cancel']),('delivery_status', '!=', False)]} ['sale','cancel']),('delivery_status', '!=', False), ('state', 'in', ['cancel'])]}
</attribute> </attribute>
</xpath> </xpath>
<xpath expr="//form/header/button[@name='action_draft']" position="attributes"> <xpath expr="//form/header/button[@name='action_draft']" position="attributes">

View File

@@ -118,6 +118,7 @@ class FunctionalCuttingToolEntity(models.Model):
def tool_in_out_stock_location(self, location_id): def tool_in_out_stock_location(self, location_id):
tool_room_id = self.env['stock.location'].search([('name', '=', '刀具房')]) tool_room_id = self.env['stock.location'].search([('name', '=', '刀具房')])
pre_manufacturing_id = self.env['stock.location'].search([('name', '=', '制造前')]) pre_manufacturing_id = self.env['stock.location'].search([('name', '=', '制造前')])
if self:
for item in self: for item in self:
# 中控反馈该位置有刀 # 中控反馈该位置有刀
if item: if item:
@@ -138,7 +139,7 @@ class FunctionalCuttingToolEntity(models.Model):
else: else:
# 系统该位置有刀 # 系统该位置有刀
if location_id.product_sn_id: if location_id.product_sn_id:
item.tool_in_out_stock_location_1(location_id, tool_room_id) self.tool_in_out_stock_location_1(location_id, tool_room_id)
def tool_in_out_stock_location_1(self, location_id, tool_room_id): def tool_in_out_stock_location_1(self, location_id, tool_room_id):
tool = self.env['sf.functional.cutting.tool.entity'].search( tool = self.env['sf.functional.cutting.tool.entity'].search(

View File

@@ -53,7 +53,7 @@ class SfMaintenanceEquipment(models.Model):
params = {"DeviceId": self.name} params = {"DeviceId": self.name}
r = requests.get(crea_url, params=params, headers=headers) r = requests.get(crea_url, params=params, headers=headers)
ret = r.json() ret = r.json()
logging.info('register_equipment_tool:%s' % ret) logging.info('机床刀库register_equipment_tool():%s' % ret)
datas = ret['Datas'] datas = ret['Datas']
self.write_maintenance_equipment_tool(datas) self.write_maintenance_equipment_tool(datas)
if ret['Succeed']: if ret['Succeed']:

View File

@@ -13,14 +13,14 @@ class MrsShelfLocationDataSync(models.Model):
_name = 'sf.shelf.location.datasync' _name = 'sf.shelf.location.datasync'
_description = '同步库存信息' _description = '同步库存信息'
def find_our_code(self, their_code): def get_total_data(self):
# 建立对应关系的函数 # 建立对应关系的函数
def align_data(my_data, their_data): def align_data(my_data, their_data):
paired_data = list(zip(my_data, their_data)) paired_data = list(zip(my_data, their_data))
return paired_data return paired_data
def get_total_data(): logging.info('============================get_total_data()======================')
shelf_1_obj = self.env['sf.shelf'].search([('name', '=', '一号产线-一号线边刀架')], limit=1) 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') tool_location_objs_1 = self.env['sf.shelf.location'].search([('shelf_id', '=', shelf_1_obj.id)], order='id')
@@ -85,7 +85,8 @@ class MrsShelfLocationDataSync(models.Model):
logging.info(f"total_data: {total_data}") logging.info(f"total_data: {total_data}")
return total_data return total_data
for code_pair in get_total_data(): def find_our_code(self, total_data, their_code):
for code_pair in total_data:
if code_pair[1] == their_code: if code_pair[1] == their_code:
return code_pair[0] return code_pair[0]
return None # 如果没有找到对应的值返回None或适当的默认值 return None # 如果没有找到对应的值返回None或适当的默认值
@@ -106,9 +107,10 @@ class MrsShelfLocationDataSync(models.Model):
equipment_id.register_equipment_tool() equipment_id.register_equipment_tool()
shelfinfo = self.env['sf.shelf.location'].get_sf_shelf_location_info() shelfinfo = self.env['sf.shelf.location'].get_sf_shelf_location_info()
total_data = self.get_total_data()
print('shelfinfo:', shelfinfo) print('shelfinfo:', shelfinfo)
for item in shelfinfo: for item in shelfinfo:
shelf_barcode = self.find_our_code(item['Postion']) shelf_barcode = self.find_our_code(total_data, item['Postion'])
location_id = self.env['sf.shelf.location'].search([('barcode', '=', shelf_barcode)], limit=1) location_id = self.env['sf.shelf.location'].search([('barcode', '=', shelf_barcode)], limit=1)
if location_id: if location_id:
# 如果是线边刀库信息,则对功能刀具移动生成记录 # 如果是线边刀库信息,则对功能刀具移动生成记录
@@ -118,6 +120,11 @@ class MrsShelfLocationDataSync(models.Model):
tool.tool_in_out_stock_location(location_id) tool.tool_in_out_stock_location(location_id)
if tool: if tool:
location_id.product_sn_id = tool.barcode_id.id location_id.product_sn_id = tool.barcode_id.id
# 修改功能刀具状态
# tool_install_time = {'Nomal': '正常', 'Warning': '报警'}
# tool.write({
# 'functional_tool_status': tool_install_time.get(item['State'])
# })
else: else:
location_id.product_sn_id = False location_id.product_sn_id = False
else: else: