1、优化货位变更接口、优化同步库存信息接口;2、隐藏已取消状态的销售订单的【确认接单】和【取消】按钮;3、处理功能刀具从线边刀库到刀具房没有生成移动历史问题;
This commit is contained in:
@@ -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'])
|
||||||
limit=1)
|
location_id = request.env['sf.shelf.location'].sudo().search(
|
||||||
|
[('barcode', '=', shelf_barcode)],
|
||||||
|
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)
|
||||||
|
|||||||
@@ -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': ['|','&',('check_status', '!=', 'approved'),('state', 'in', ['draft','cancel']),'&','&',('check_status', '=', 'approved'),('state', 'in', ['sale','cancel']),('delivery_status', '!=', False)]}"/>
|
attrs="{'invisible': ['|','&','|',('check_status', '!=', 'approved'),('state', 'in', ['draft','cancel']),'&','&',('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': ['|','&',('check_status', '!=', 'approved'),('state',
|
<attribute name="attrs">{'invisible': ['|','&','|', ('check_status', '!=', 'approved'),('state',
|
||||||
'in', ['draft','cancel']),'&','&',('check_status', '=', 'approved'),('state', 'in',
|
'in', ['draft','cancel']),'&','&',('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">
|
||||||
|
|||||||
@@ -118,27 +118,28 @@ 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', '=', '制造前')])
|
||||||
for item in self:
|
if self:
|
||||||
# 中控反馈该位置有刀
|
for item in self:
|
||||||
if item:
|
# 中控反馈该位置有刀
|
||||||
# 系统该位置有刀
|
if item:
|
||||||
if location_id.product_sn_id:
|
# 系统该位置有刀
|
||||||
# 中控反馈和系统中,该位置是同一把刀
|
if location_id.product_sn_id:
|
||||||
if item.barcode_id == location_id.product_sn_id:
|
# 中控反馈和系统中,该位置是同一把刀
|
||||||
return True
|
if item.barcode_id == location_id.product_sn_id:
|
||||||
# 中控反馈和系统中,该位置不是同一把刀
|
return True
|
||||||
else:
|
# 中控反馈和系统中,该位置不是同一把刀
|
||||||
# 原刀从线边出库
|
else:
|
||||||
item.tool_in_out_stock_location_1(location_id, tool_room_id)
|
# 原刀从线边出库
|
||||||
# 新刀入库到线边
|
item.tool_in_out_stock_location_1(location_id, tool_room_id)
|
||||||
item.create_stock_move(pre_manufacturing_id, location_id)
|
# 新刀入库到线边
|
||||||
item.current_shelf_location_id = location_id.id
|
item.create_stock_move(pre_manufacturing_id, location_id)
|
||||||
|
item.current_shelf_location_id = location_id.id
|
||||||
|
|
||||||
# 中控反馈该位置没有刀
|
# 中控反馈该位置没有刀
|
||||||
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(
|
||||||
|
|||||||
@@ -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']:
|
||||||
|
|||||||
@@ -13,79 +13,80 @@ 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')
|
||||||
|
|
||||||
location_codes_1 = [location.barcode for location in tool_location_objs_1]
|
location_codes_1 = [location.barcode for location in tool_location_objs_1]
|
||||||
print(location_codes_1)
|
print(location_codes_1)
|
||||||
# 对方的数据列表
|
# 对方的数据列表
|
||||||
their_data_1 = [f"ToolCab1-{i:02}" for i in range(1, 73)]
|
their_data_1 = [f"ToolCab1-{i:02}" for i in range(1, 73)]
|
||||||
|
|
||||||
# 执行对齐
|
# 执行对齐
|
||||||
aligned_data_1 = align_data(location_codes_1, their_data_1)
|
aligned_data_1 = align_data(location_codes_1, their_data_1)
|
||||||
|
|
||||||
# 2
|
# 2
|
||||||
shelf_2_obj = self.env['sf.shelf'].search([('name', '=', '一号产线-二号线边刀架')], limit=1)
|
shelf_2_obj = self.env['sf.shelf'].search([('name', '=', '一号产线-二号线边刀架')], limit=1)
|
||||||
tool_location_objs_2 = self.env['sf.shelf.location'].search([('shelf_id', '=', shelf_2_obj.id)], order='id')
|
tool_location_objs_2 = self.env['sf.shelf.location'].search([('shelf_id', '=', shelf_2_obj.id)], order='id')
|
||||||
|
|
||||||
location_codes_2 = [location.barcode for location in tool_location_objs_2]
|
location_codes_2 = [location.barcode for location in tool_location_objs_2]
|
||||||
print(location_codes_2)
|
print(location_codes_2)
|
||||||
# 对方的数据列表
|
# 对方的数据列表
|
||||||
their_data_2 = [f"ToolCab2-{i:02}" for i in range(1, 73)]
|
their_data_2 = [f"ToolCab2-{i:02}" for i in range(1, 73)]
|
||||||
|
|
||||||
# 执行对齐
|
# 执行对齐
|
||||||
aligned_data_2 = align_data(location_codes_2, their_data_2)
|
aligned_data_2 = align_data(location_codes_2, their_data_2)
|
||||||
|
|
||||||
# 4
|
# 4
|
||||||
shelf_4_obj = self.env['sf.shelf'].search([('name', '=', '一号产线-一号线边料架')], limit=1)
|
shelf_4_obj = self.env['sf.shelf'].search([('name', '=', '一号产线-一号线边料架')], limit=1)
|
||||||
tool_location_objs_4 = self.env['sf.shelf.location'].search([('shelf_id', '=', shelf_4_obj.id)], order='id')
|
tool_location_objs_4 = self.env['sf.shelf.location'].search([('shelf_id', '=', shelf_4_obj.id)], order='id')
|
||||||
|
|
||||||
location_codes_4 = [location.barcode for location in tool_location_objs_4]
|
location_codes_4 = [location.barcode for location in tool_location_objs_4]
|
||||||
print(location_codes_4)
|
print(location_codes_4)
|
||||||
# 对方的数据列表
|
# 对方的数据列表
|
||||||
their_data_4 = [f"PartCab4-{i:02}" for i in range(1, 17)]
|
their_data_4 = [f"PartCab4-{i:02}" for i in range(1, 17)]
|
||||||
|
|
||||||
# 执行对齐
|
# 执行对齐
|
||||||
aligned_data_4 = align_data(location_codes_4, their_data_4)
|
aligned_data_4 = align_data(location_codes_4, their_data_4)
|
||||||
|
|
||||||
# 3
|
# 3
|
||||||
shelf_3_obj = self.env['sf.shelf'].search([('name', '=', '一号产线-二号线边料架')], limit=1)
|
shelf_3_obj = self.env['sf.shelf'].search([('name', '=', '一号产线-二号线边料架')], limit=1)
|
||||||
tool_location_objs_3 = self.env['sf.shelf.location'].search([('shelf_id', '=', shelf_3_obj.id)], order='id')
|
tool_location_objs_3 = self.env['sf.shelf.location'].search([('shelf_id', '=', shelf_3_obj.id)], order='id')
|
||||||
|
|
||||||
location_codes_3 = [location.barcode for location in tool_location_objs_3]
|
location_codes_3 = [location.barcode for location in tool_location_objs_3]
|
||||||
print(location_codes_3)
|
print(location_codes_3)
|
||||||
# 对方的数据列表
|
# 对方的数据列表
|
||||||
their_data_3 = [f"PartCab3-{i:02}" for i in range(1, 13)]
|
their_data_3 = [f"PartCab3-{i:02}" for i in range(1, 13)]
|
||||||
|
|
||||||
# 执行对齐
|
# 执行对齐
|
||||||
aligned_data_3 = align_data(location_codes_3, their_data_3)
|
aligned_data_3 = align_data(location_codes_3, their_data_3)
|
||||||
|
|
||||||
# 5
|
# 5
|
||||||
shelf_5_obj = self.env['sf.shelf'].search([('name', '=', '一号产线-三号线边料架')], limit=1)
|
shelf_5_obj = self.env['sf.shelf'].search([('name', '=', '一号产线-三号线边料架')], limit=1)
|
||||||
tool_location_objs_5 = self.env['sf.shelf.location'].search([('shelf_id', '=', shelf_5_obj.id)], order='id')
|
tool_location_objs_5 = self.env['sf.shelf.location'].search([('shelf_id', '=', shelf_5_obj.id)], order='id')
|
||||||
|
|
||||||
location_codes_5 = [location.barcode for location in tool_location_objs_5]
|
location_codes_5 = [location.barcode for location in tool_location_objs_5]
|
||||||
print(location_codes_5)
|
print(location_codes_5)
|
||||||
# 对方的数据列表
|
# 对方的数据列表
|
||||||
their_data_5 = [f"PartCab5-{i:02}" for i in range(1, 13)]
|
their_data_5 = [f"PartCab5-{i:02}" for i in range(1, 13)]
|
||||||
|
|
||||||
# 执行对齐
|
# 执行对齐
|
||||||
aligned_data_5 = align_data(location_codes_5, their_data_5)
|
aligned_data_5 = align_data(location_codes_5, their_data_5)
|
||||||
|
|
||||||
total_data = aligned_data_1 + aligned_data_2 + aligned_data_3 + aligned_data_4 + aligned_data_5
|
total_data = aligned_data_1 + aligned_data_2 + aligned_data_3 + aligned_data_4 + aligned_data_5
|
||||||
print(total_data)
|
print(total_data)
|
||||||
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:
|
||||||
|
|||||||
Reference in New Issue
Block a user