Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/制造代码优化

This commit is contained in:
mgw
2024-04-24 08:58:54 +08:00
30 changed files with 753 additions and 173 deletions

View File

@@ -478,12 +478,19 @@ class ResMrpWorkOrder(models.Model):
'date_planned_finished': False,
'duration_expected': duration_expected,
'duration': 0,
'workpiece_delivery_ids': False if not route.routing_type == '装夹预调' else self.env[
'sf.workpiece.delivery'].create(
{'production_id': production.id})
'workpiece_delivery_ids': False if not route.routing_type == '装夹预调' else self._json_workpiece_delivery_list(
production)
}]
return workorders_values_str
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)}],
]
# 拼接工单对象属性值(表面工艺)
def _json_workorder_surface_process_str(self, production, route, process_parameter, supplier_id):
workorders_values_str = [0, '', {
@@ -977,7 +984,7 @@ class SfWorkOrderBarcodes(models.Model):
# [('routing_type', '=', '装夹预调'), ('production_id', '=', self.production_id.id)])
workorder_old = self.env['mrp.workorder'].search([('rfid_code', '=', barcode)])
if workorder_old:
raise UserError('该托盘已绑定工件,请先解除绑定!!!')
raise UserError('该托盘已绑定%s】制造订单,请先解除绑定!!!' % workorder_old.production_id.name)
if workorder:
if workorder.routing_type == '装夹预调':
if workorder.state in ['done']:
@@ -1094,6 +1101,7 @@ class WorkPieceDelivery(models.Model):
_name = "sf.workpiece.delivery"
_description = '工件配送'
delivery_num = fields.Char('工件配送编码')
workorder_id = fields.Many2one('mrp.workorder', string='工单', readonly=True)
production_id = fields.Many2one('mrp.production', string='制造订单', readonly=True)
production_line_id = fields.Many2one('sf.production.line', compute='_compute_production_line_id',
@@ -1106,6 +1114,8 @@ class WorkPieceDelivery(models.Model):
feeder_station_destination_id = fields.Many2one('sf.agv.site', '目的接驳站')
task_delivery_time = fields.Datetime('任务下发时间')
task_completion_time = fields.Datetime('任务完成时间')
type = fields.Selection(
[('上产线', '上产线'), ('下产线', '下产线'), ('运送空料架', '运送空料架')], string='类型')
delivery_duration = fields.Float('配送时长', compute='_compute_delivery_duration')
status = fields.Selection(
[('待下发', '待下发'), ('待配送', '待配送'), ('已配送', '已配送')], string='状态',
@@ -1146,6 +1156,9 @@ class WorkPieceDelivery(models.Model):
# 配送至avg小车
def _delivery_avg(self):
agv_site = self.env['sf.agv.site'].search([])
# if agv_site:
# agv_site.update_site_state()
config = self.env['res.config.settings'].get_values()
positionCode_Arr = []
if self.feeder_station_start_id:
@@ -1158,14 +1171,14 @@ class WorkPieceDelivery(models.Model):
'positionCode': self.feeder_station_destination_id.name,
'code': '00'
})
res = {'reqCode': self.production_id.name, 'reqTime': '', 'clientCode': '', 'tokenCode': '',
res = {'reqCode': self.delivery_num, 'reqTime': '', 'clientCode': '', 'tokenCode': '',
'taskTyp': 'F01', 'ctnrTyp': '', 'ctnrCode': '', 'wbCode': config['wbcode'],
'positionCodePath': positionCode_Arr,
'podCode': '',
'podDir': '', 'materialLot': '', 'priority': '', 'taskCode': '', 'agvCode': '', 'materialLot': '',
'data': ''}
try:
config['agv_rcs_url'] = 'http://172.16.10.114:8182/rcms/services/rest/hikRpcService/genAgvSchedulingTask'
# config['agv_rcs_url'] = 'http://172.16.10.114:8182/rcms/services/rest/hikRpcService/genAgvSchedulingTask'
logging.info('AGV请求路径:%s' % config['agv_rcs_url'])
logging.info('AGV-json:%s' % res)
headers = {'Content-Type': 'application/json'}