Merge branch 'feature/修复工件配送时间' into develop
This commit is contained in:
@@ -429,32 +429,33 @@ class Manufacturing_Connect(http.Controller):
|
||||
logging.info('ret:%s' % ret)
|
||||
if 'DeviceId' in ret:
|
||||
logging.info('DeviceId:%s' % ret['DeviceId'])
|
||||
for i in range(1, 5):
|
||||
logging.info('F-RfidCode:%s' % i)
|
||||
if f'RfidCode{i}' in ret:
|
||||
rfid_code = ret[f'RfidCode{i}']
|
||||
logging.info('RfidCode:%s' % rfid_code)
|
||||
domain = [
|
||||
('feeder_station_destination_id.name', '=', ret['DeviceId']),
|
||||
('workorder_id.rfid_code', '=', rfid_code),
|
||||
('status', '=', '已配送'),
|
||||
('type', '=', '上产线')
|
||||
]
|
||||
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(domain, order='id asc')
|
||||
if workpiece_delivery:
|
||||
for wd in workpiece_delivery:
|
||||
logging.info('wd.production_id:%s' % wd.production_id.name)
|
||||
if wd.workorder_id.state == 'done' and wd.production_id.production_line_state == '待上产线':
|
||||
logging.info('wd.production_line_state:%s' % wd.production_id.production_line_state)
|
||||
wd.production_id.write({'production_line_state': '已上产线'})
|
||||
next_workpiece = request.env['sf.workpiece.delivery'].sudo().search(
|
||||
[('workorder_id.rfid_code', '=', rfid_code), ('type', '=', '下产线'),
|
||||
('production_id', '=', wd.production_id.id)])
|
||||
if next_workpiece:
|
||||
logging.info('next_workpiece:%s' % next_workpiece.delivery_num)
|
||||
next_workpiece.write({'status': '待下发', 'task_delivery_time': datetime.now()})
|
||||
if 'IsComplete' in ret:
|
||||
if ret['IsComplete'] is True:
|
||||
for i in range(1, 5):
|
||||
logging.info('F-RfidCode:%s' % i)
|
||||
if f'RfidCode{i}' in ret:
|
||||
rfid_code = ret[f'RfidCode{i}']
|
||||
logging.info('RfidCode:%s' % rfid_code)
|
||||
domain = [
|
||||
('feeder_station_destination_id.name', '=', ret['DeviceId']),
|
||||
('workorder_id.rfid_code', '=', rfid_code),
|
||||
('status', '=', '已配送'),
|
||||
('type', '=', '上产线')
|
||||
]
|
||||
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(domain,
|
||||
order='id asc')
|
||||
if workpiece_delivery:
|
||||
for wd in workpiece_delivery:
|
||||
logging.info('wd.production_id:%s' % wd.production_id.name)
|
||||
if wd.workorder_id.state == 'done' and wd.production_id.production_line_state == '待上产线':
|
||||
logging.info(
|
||||
'wd.production_line_state:%s' % wd.production_id.production_line_state)
|
||||
wd.production_id.write({'production_line_state': '已上产线'})
|
||||
else:
|
||||
res = {'Succeed': False, 'ErrorCode': 204,
|
||||
'Error': 'DeviceId为%s没有对应的已配送工件数据' % ret['DeviceId']}
|
||||
else:
|
||||
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该DeviceId没有对应的已配送工件数据'}
|
||||
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '未传IsComplete字段'}
|
||||
else:
|
||||
res = {'Succeed': False, 'ErrorCode': 201, 'Error': '未传DeviceId字段'}
|
||||
except Exception as e:
|
||||
@@ -480,39 +481,44 @@ class Manufacturing_Connect(http.Controller):
|
||||
if 'DeviceId' in ret:
|
||||
logging.info('DeviceId:%s' % ret['DeviceId'])
|
||||
delivery_Arr = []
|
||||
for i in range(1, 5):
|
||||
logging.info('F-RfidCode:%s' % i)
|
||||
if f'RfidCode{i}' in ret:
|
||||
rfid_code = ret[f'RfidCode{i}']
|
||||
logging.info('RfidCode:%s' % rfid_code)
|
||||
domain = [
|
||||
('feeder_station_start_id.name', '=', ret['DeviceId']),
|
||||
('workorder_id.rfid_code', '=', rfid_code),
|
||||
('status', '=', '待下发'),
|
||||
('type', '=', '下产线')
|
||||
]
|
||||
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(domain, order='id asc')
|
||||
if workpiece_delivery:
|
||||
for wd in workpiece_delivery:
|
||||
logging.info('wd.production_id:%s' % wd.production_id.name)
|
||||
if wd.workorder_id.state == 'done' and wd.production_id.production_line_state == '已上产线':
|
||||
logging.info('wd.production_line_state:%s' % wd.production_id.production_line_state)
|
||||
wd.production_id.write({'production_line_state': '已下产线'})
|
||||
delivery_Arr.append({wd.id})
|
||||
next_workpiece = request.env['sf.workpiece.delivery'].sudo().search(
|
||||
[('workorder_id.rfid_code', '=', rfid_code), ('type', '=', '运送空料架'),
|
||||
('production_id', '=', wd.production_id.id)])
|
||||
if next_workpiece:
|
||||
logging.info('next_workpiece:%s' % next_workpiece.delivery_num)
|
||||
next_workpiece.write({'status': '待下发', 'task_delivery_time': datetime.now()})
|
||||
if delivery_Arr:
|
||||
logging.info('delivery_Arr:%s' % delivery_Arr)
|
||||
delivery_workpiece = request.env['sf.workpiece.delivery'].sudo().search(
|
||||
[('id', 'in', delivery_Arr)])
|
||||
if delivery_workpiece:
|
||||
logging.info('开始向agv下发下产线任务')
|
||||
delivery_workpiece._delivery_avg()
|
||||
logging.info('agv下发下产线任务下发完成')
|
||||
if 'IsComplete' in ret:
|
||||
if ret['IsComplete'] is True:
|
||||
for i in range(1, 5):
|
||||
logging.info('F-RfidCode:%s' % i)
|
||||
if f'RfidCode{i}' in ret:
|
||||
rfid_code = ret[f'RfidCode{i}']
|
||||
logging.info('RfidCode:%s' % rfid_code)
|
||||
domain = [
|
||||
('feeder_station_start_id.name', '=', ret['DeviceId']),
|
||||
('workorder_id.rfid_code', '=', rfid_code),
|
||||
('status', '=', '待下发'),
|
||||
('type', '=', '下产线')
|
||||
]
|
||||
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(domain,
|
||||
order='id asc')
|
||||
if workpiece_delivery:
|
||||
for wd in workpiece_delivery:
|
||||
logging.info('wd.production_id:%s' % wd.production_id.name)
|
||||
if wd.workorder_id.state == 'done' and wd.production_id.production_line_state == '已上产线':
|
||||
logging.info(
|
||||
'wd.production_line_state:%s' % wd.production_id.production_line_state)
|
||||
wd.production_id.write({'production_line_state': '已下产线'})
|
||||
delivery_Arr.append(wd.id)
|
||||
else:
|
||||
res = {'Succeed': False, 'ErrorCode': 204,
|
||||
'Error': 'DeviceId为%s没有对应的已配送工件数据' % ret['DeviceId']}
|
||||
if delivery_Arr:
|
||||
logging.info('delivery_Arr:%s' % delivery_Arr)
|
||||
delivery_workpiece = request.env['sf.workpiece.delivery'].sudo().search(
|
||||
[('id', 'in', delivery_Arr)])
|
||||
if delivery_workpiece:
|
||||
logging.info('开始向agv下发下产线任务')
|
||||
is_free = delivery_workpiece._check_avgsite_state()
|
||||
if is_free is True:
|
||||
delivery_workpiece._delivery_avg()
|
||||
logging.info('agv下发下产线任务下发完成')
|
||||
else:
|
||||
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '未传IsComplete字段'}
|
||||
except Exception as e:
|
||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||
logging.info('AGVDownProduct error:%s' % e)
|
||||
|
||||
@@ -28,8 +28,7 @@ class Workpiece(http.Controller):
|
||||
req_codes = ret['reqCode'].split(',')
|
||||
for req_code in req_codes:
|
||||
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
|
||||
[('production_id.name', '=', req_code.rsplit('-', 1)[0]),
|
||||
('delivery_num', '=', req_code.strip())])
|
||||
[('delivery_num', '=', req_code.strip()), ('task_completion_time', '=', False)])
|
||||
if workpiece_delivery:
|
||||
workpiece_delivery.write({'status': '已配送', 'task_completion_time': datetime.now()})
|
||||
else:
|
||||
|
||||
@@ -8,7 +8,6 @@ class AgvSetting(models.Model):
|
||||
_name = 'sf.agv.site'
|
||||
_description = 'agv站点'
|
||||
|
||||
number = fields.Integer('序号')
|
||||
name = fields.Char('位置编号')
|
||||
owning_region = fields.Char('所属区域')
|
||||
state = fields.Selection([
|
||||
@@ -26,12 +25,13 @@ class AgvSetting(models.Model):
|
||||
center_control_r = requests.get(center_control_url, params={}, headers=headers)
|
||||
ret = center_control_r.json()
|
||||
logging.info('工件配送-请求中控站点信息:%s' % ret)
|
||||
datas = ret['Datas']
|
||||
for item in self:
|
||||
for da in datas:
|
||||
if da['DeviceId'] == item.name:
|
||||
if da['AtHome'] is True:
|
||||
item.state = '占用'
|
||||
if ret['Succeed'] is True:
|
||||
datas = ret['Datas']
|
||||
for item in self:
|
||||
for da in datas:
|
||||
if da['DeviceId'] == item.name:
|
||||
if da['AtHome'] is True:
|
||||
item.state = '占用'
|
||||
|
||||
|
||||
class AgvTaskRoute(models.Model):
|
||||
|
||||
@@ -485,10 +485,8 @@ class ResMrpWorkOrder(models.Model):
|
||||
def _json_workpiece_delivery_list(self, production):
|
||||
return [
|
||||
[0, '', {'production_id': production.id, 'type': '上产线', 'delivery_num': '%s-%s' % (production.name, 1)}],
|
||||
[0, '', {'production_id': production.id, 'type': '下产线', 'delivery_num': '%s-%s' % (production.name, 2)}],
|
||||
[0, '',
|
||||
{'production_id': production.id, 'type': '运送空料架', 'delivery_num': '%s-%s' % (production.name, 3)}],
|
||||
]
|
||||
{'production_id': production.id, 'type': '下产线', 'delivery_num': '%s-%s' % (production.name, 2)}]]
|
||||
|
||||
# 拼接工单对象属性值(表面工艺)
|
||||
def _json_workorder_surface_process_str(self, production, route, process_parameter, supplier_id):
|
||||
@@ -1097,9 +1095,12 @@ class WorkPieceDelivery(models.Model):
|
||||
[('上产线', '上产线'), ('下产线', '下产线'), ('运送空料架', '运送空料架')], string='类型')
|
||||
delivery_duration = fields.Float('配送时长', compute='_compute_delivery_duration')
|
||||
status = fields.Selection(
|
||||
[('待下发', '待下发'), ('待配送', '待配送'), ('已配送', '已配送')], string='状态', )
|
||||
[('待下发', '待下发'), ('待配送', '待配送'), ('已配送', '已配送')], string='状态', default='待下发')
|
||||
is_cnc_program_down = fields.Boolean('程序是否下发', default=False)
|
||||
|
||||
# @api.model
|
||||
# def create(self, vals):
|
||||
|
||||
@api.onchange('route_id')
|
||||
def onchange_route(self):
|
||||
if self.route_id:
|
||||
@@ -1115,7 +1116,7 @@ class WorkPieceDelivery(models.Model):
|
||||
same_production_line_id = None
|
||||
same_route_id = None
|
||||
down_status = '待下发'
|
||||
production_type = '上产线'
|
||||
production_type = None
|
||||
num = 0
|
||||
for item in self:
|
||||
num += 1
|
||||
@@ -1128,8 +1129,10 @@ class WorkPieceDelivery(models.Model):
|
||||
is_not_route += 1
|
||||
else:
|
||||
raise UserError('请选择【任务路线】再进行配送')
|
||||
# if production_type != item.type:
|
||||
# raise UserError('请选择类型为【上产线】的制造订单进行配送')
|
||||
if production_type is None:
|
||||
production_type = item.type
|
||||
if production_type != item.type:
|
||||
raise UserError('请选择类型为%s的制造订单进行配送' % production_type)
|
||||
if down_status != item.status:
|
||||
raise UserError('请选择状态为【待下发】的制造订单进行配送')
|
||||
if same_production_line_id is None:
|
||||
@@ -1146,22 +1149,42 @@ class WorkPieceDelivery(models.Model):
|
||||
raise UserError('您所选择制造订单的【目的生产线】不一致,请重新确认')
|
||||
if is_not_route >= 1:
|
||||
raise UserError('您所选择制造订单的【任务路线】不一致,请重新确认')
|
||||
if delivery_ids:
|
||||
return {
|
||||
'name': _('确认'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'sf.workpiece.delivery.wizard',
|
||||
'target': 'new',
|
||||
'context': {
|
||||
'default_delivery_ids': [(6, 0, delivery_ids)],
|
||||
}}
|
||||
is_free = self._check_avgsite_state()
|
||||
if is_free is True:
|
||||
if delivery_ids:
|
||||
return {
|
||||
'name': _('确认'),
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'sf.workpiece.delivery.wizard',
|
||||
'target': 'new',
|
||||
'context': {
|
||||
'default_delivery_ids': [(6, 0, delivery_ids)],
|
||||
}}
|
||||
else:
|
||||
raise UserError("您所选择制造订单的【任务路线】的【终点接驳站】已占用,请在该接驳站空闲时进行配送")
|
||||
|
||||
# 配送至avg小车
|
||||
def _delivery_avg(self):
|
||||
# 验证agv站点是否可用
|
||||
def _check_avgsite_state(self):
|
||||
is_free = False
|
||||
agv_site = self.env['sf.agv.site'].search([])
|
||||
if agv_site:
|
||||
agv_site.update_site_state()
|
||||
for item in self:
|
||||
if item.type in ["上产线", "下产线"]:
|
||||
logging.info('工件配送-起点状态:%s-%s' % (
|
||||
item.feeder_station_start_id.name, item.feeder_station_start_id.state))
|
||||
logging.info('工件配送-终点状态:%s-%s' % (
|
||||
item.feeder_station_destination_id.name, item.feeder_station_destination_id.state))
|
||||
if (
|
||||
item.feeder_station_start_id.state == '占用' and item.feeder_station_destination_id.state == '空闲') or (
|
||||
item.feeder_station_start_id.state == '空闲' and item.feeder_station_destination_id.state == '空闲'):
|
||||
is_free = True
|
||||
logging.info('is_free:%s' % is_free)
|
||||
return is_free
|
||||
|
||||
# 配送至avg小车
|
||||
def _delivery_avg(self):
|
||||
config = self.env['res.config.settings'].get_values()
|
||||
positionCode_Arr = []
|
||||
delivery_Arr = []
|
||||
@@ -1173,7 +1196,7 @@ class WorkPieceDelivery(models.Model):
|
||||
if feeder_station_destination is None:
|
||||
feeder_station_destination = item.feeder_station_destination_id.name
|
||||
delivery_Arr.append(item.delivery_num)
|
||||
delivery_str = ', '.join(map(str, delivery_Arr))
|
||||
delivery_str = ','.join(map(str, delivery_Arr))
|
||||
if feeder_station_start is not None:
|
||||
positionCode_Arr.append({
|
||||
'positionCode': feeder_station_start,
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
<field name="model">sf.agv.site</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree editable="bottom">
|
||||
<field name="number" required="1"/>
|
||||
<field name="name" required="1"/>
|
||||
<field name="owning_region" required="1"/>
|
||||
<field name="state" required="1"/>
|
||||
@@ -39,7 +38,6 @@
|
||||
<field name="start_site_id" required="1" options="{'no_create': True}" string="起点接驳站"/>
|
||||
<field name="end_site_id" required="1" options="{'no_create': True}" string="终点接驳站"/>
|
||||
<field name="destination_production_line_id" required="1" options="{'no_create': True}"/>
|
||||
<field name="priority" widget="priority"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -608,9 +608,9 @@
|
||||
<field name="model">sf.workpiece.delivery</field>
|
||||
<field name="arch" type="xml">
|
||||
<search string="工件配送">
|
||||
<!-- <filter string="待下发" name="status" domain="[('status', '=', '待下发')]"/>-->
|
||||
<!-- <filter string="待配送" name="status" domain="[('status', '=', '待配送')]"/>-->
|
||||
<!-- <filter string="已配送" name="status" domain="[('status', '=', '已配送')]"/>-->
|
||||
<filter string="待下发" name="on_down" domain="[('status', '=', '待下发'),('type','=',['上产线'])]"/>
|
||||
<filter string="上产线" name="down" domain="[('type', '=', '上产线')]"/>
|
||||
<filter string="下产线" name="up" domain="[('type', '=', '下产线')]"/>
|
||||
<field name="production_id"/>
|
||||
<field name="feeder_station_start_id"/>
|
||||
<field name="production_line_id"/>
|
||||
@@ -621,7 +621,6 @@
|
||||
<field name="status"/>
|
||||
<searchpanel>
|
||||
<field name="production_line_id" icon="fa-building" enable_counters="1"/>
|
||||
<field name="type" icon="fa-building" enable_counters="1"/>
|
||||
<field name="status" icon="fa-building" enable_counters="1"/>
|
||||
</searchpanel>
|
||||
</search>
|
||||
@@ -631,10 +630,10 @@
|
||||
<record id="sf_workpiece_delivery_act" model="ir.actions.act_window">
|
||||
<field name="name">工件配送</field>
|
||||
<field name="res_model">sf.workpiece.delivery</field>
|
||||
<!-- <field name="search_view_id" ref="sf_workpiece_delivery_search"/>-->
|
||||
<!-- <field name="context">{'search_default_status':'待下发'}</field>-->
|
||||
<field name="search_view_id" ref="sf_workpiece_delivery_search"/>
|
||||
<field name="context">{'search_default_on_down':1}</field>
|
||||
<field name="view_mode">tree,search</field>
|
||||
<!-- <field name="domain">[('type','in',['上产线']),('status','in',['待下发'])]</field>-->
|
||||
<field name="domain">[('type','in',['上产线','下产线'])]</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user