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

This commit is contained in:
mgw
2024-04-26 15:54:20 +08:00
20 changed files with 283 additions and 162 deletions

View File

@@ -426,18 +426,33 @@ class Manufacturing_Connect(http.Controller):
res = {'Succeed': True}
datas = request.httprequest.data
ret = json.loads(datas)
logging.info('ret:%s' % ret)
if 'DeviceId' in ret:
logging.info('DeviceId:%s' % ret['DeviceId'])
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
[('feeder_station_destination_id.name', '=', ret['DeviceId']),
('status', '=', '已配送'), ('type', '=', '上产线')], 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': '上产线'})
wd.write({'production_line_state': '上产线'})
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()})
else:
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该DeviceId没有对应的已配送工件数据'}
else:
@@ -461,31 +476,50 @@ class Manufacturing_Connect(http.Controller):
res = {'Succeed': True}
datas = request.httprequest.data
ret = json.loads(datas)
logging.info('ret:%s' % ret)
if 'DeviceId' in ret:
logging.info('DeviceId:%s' % ret['DeviceId'])
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
[('feeder_station_destination_id.name', '=', ret['DeviceId']),
('status', '=', '已配送'), ('type', '=', '下产线')], 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': '已下产线'})
logging.info('开始向agv下发下产线任务')
wd._delivery_avg()
logging.info('agv下发下产线任务已配送')
else:
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该DeviceId没有对应的工件配送数据'}
else:
res = {'Succeed': False, 'ErrorCode': 201, 'Error': '未传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下发下产线任务下发完成')
except Exception as e:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
logging.info('AGVDownProduct error:%s' % e)
return json.JSONEncoder().encode(res)
@http.route('/AutoDeviceApi/EquipmentBaseCoordinate', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
@http.route('/AutoDeviceApi/EquipmentBaseCoordinate', type='json', auth='sf_token', methods=['GET', 'POST'],
csrf=False,
cors="*")
def PutEquipmentBaseCoordinate(self, **kw):
"""

View File

@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
import logging
import json
from datetime import datetime
from odoo import http
from odoo.http import request
@@ -24,14 +25,16 @@ class Workpiece(http.Controller):
if 'reqCode' in ret:
if 'method' in ret:
if ret['method'] == 'end':
logging.info('backfeed-ret:%s' % ret['reqCode'].rsplit('-', 1)[0])
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
[('production_id.name', '=', ret['reqCode'].rsplit('-', 1)[0]), ('delivery_num', '=',
ret['reqCode'])])
if workpiece_delivery:
workpiece_delivery.write({'status': '已配送', 'task_completion_time': ret['reqTime']})
else:
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该reqCode暂未查到对应的工件配送记录'}
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())])
if workpiece_delivery:
workpiece_delivery.write({'status': '已配送', 'task_completion_time': datetime.now()})
else:
res = {'Succeed': False, 'ErrorCode': 203,
'Error': '该reqCode暂未查到对应的工件配送记录'}
else:
res = {'Succeed': False, 'ErrorCode': 204, 'Error': '未传method字段'}
else: