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