Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/修改机床参数bug

This commit is contained in:
qihao.gong@jikimo.com
2024-02-23 09:56:16 +08:00
12 changed files with 171 additions and 74 deletions

View File

@@ -22,13 +22,13 @@ class Manufacturing_Connect(http.Controller):
ret = json.loads(datas)
logging.info('RfidCode:%s' % ret['RfidCode'])
if 'RfidCode' in ret:
workorder = request.env['mrp.workorder'].sudo().search(
[('rfid_code', '=', ret['RfidCode']), ('routing_type', '=', '装夹预调')])
workorder = request.env['mrp.workorder'].sudo().search([('rfid_code', '=', ret['RfidCode'])])
if workorder:
for item in workorder:
res['Datas'].append({
'BillId': item.production_id.name,
'ProductionLine': item.production_id.production_line_id.id,
'SortId': item.sequence,
'CraftName': item.name,
'Quantity': 1,
'MaterialId': item.product_id.default_code,
@@ -60,11 +60,13 @@ class Manufacturing_Connect(http.Controller):
datas = request.httprequest.data
ret = json.loads(datas)
if 'ProductionLine' in ret:
workorder = request.env['mrp.workorder'].sudo().get_plan_workorder(ret['ProductionLine'])
workorder_ids = request.env['mrp.workorder'].sudo().get_plan_workorder(ret['ProductionLine'])
else:
ProductionLine = False
workorder = request.env['mrp.workorder'].sudo().get_plan_workorder(ProductionLine)
workorder_ids = request.env['mrp.workorder'].sudo().get_plan_workorder(ProductionLine)
logging.info('RfidCode:%s' % ret)
logging.info('workorder_ids:%s' % workorder_ids)
workorder = request.env['mrp.workorder'].sudo().search(workorder_ids)
if workorder:
for item in workorder:
date_planned_start = ''
@@ -119,7 +121,8 @@ class Manufacturing_Connect(http.Controller):
'XOffset': 0 if not item.material_center_point else offset[0],
'YOffset': 0 if not item.material_center_point else offset[1],
'ZOffet': 0 if not item.material_center_point else offset[2],
'COffset': 'G54' if not item.X_deviation_angle else item.X_deviation_angle
'COffset': 0 if not item.X_deviation_angle else item.X_deviation_angle,
'Coordinate': 'G54'
})
else:
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该rfid暂未有对应的工件预调(前置三元检测)工单'}
@@ -293,17 +296,15 @@ class Manufacturing_Connect(http.Controller):
logging.info('NCProgDolod error:%s' % e)
return json.JSONEncoder().encode(res)
@http.route('/AutoDeviceApi/LocationChange', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
cors="*")
def NCProgDolod(self, **kw):
def LocationChange(self, **kw):
"""
库位变更
:param kw:
:return:
"""
logging.info('NCProgDolod:%s' % kw)
logging.info('LocationChange:%s' % kw)
try:
res = {'Succeed': True, 'Datas': []}
datas = request.httprequest.data
@@ -315,6 +316,62 @@ class Manufacturing_Connect(http.Controller):
res = {'Succeed': False, 'ErrorCode': 201, 'Error': '未传RfidCode字段'}
except Exception as e:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
logging.info('NCProgDolod error:%s' % e)
logging.info('LocationChange error:%s' % e)
return json.JSONEncoder().encode(res)
@http.route('/AutoDeviceApi/AGVToProduct', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
cors="*")
def AGVToProduct(self, **kw):
"""
AGV运送上产线完成
:param kw:
:return:
"""
logging.info('AGVToProduct:%s' % kw)
try:
res = {'Succeed': True}
datas = request.httprequest.data
ret = json.loads(datas)
if 'DeviceId' in ret:
logging.info('DeviceId:%s' % ret['DeviceId'])
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
[('feeder_station_destination', '=', ret['DeviceId'])])
if workpiece_delivery:
workpiece_delivery.production_id.write({'production_line_state': '已上产线'})
else:
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该DeviceId没有对应的工件配送数据'}
else:
res = {'Succeed': False, 'ErrorCode': 201, 'Error': '未传DeviceId字段'}
except Exception as e:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
logging.info('AGVToProduct error:%s' % e)
return json.JSONEncoder().encode(res)
@http.route('/AutoDeviceApi/AGVDownProduct', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
cors="*")
def AGVDownProduct(self, **kw):
"""
MES调度AGV搬运零件AGV托盘到产线接驳站。
生产线接受到零件AGV托盘到位信号后把生产合格或特采的零件机器人搬运零件到AGV接驳站中触发AGV运送下产线接口。
:param kw:
:return:
"""
logging.info('AGVDownProduct:%s' % kw)
try:
res = {'Succeed': True}
datas = request.httprequest.data
ret = json.loads(datas)
if 'DeviceId' in ret:
logging.info('DeviceId:%s' % ret['DeviceId'])
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
[('feeder_station_destination', '=', ret['DeviceId'])])
if workpiece_delivery:
workpiece_delivery.production_id.write({'production_line_state': '已下产线'})
else:
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该DeviceId没有对应的工件配送数据'}
else:
res = {'Succeed': False, 'ErrorCode': 201, 'Error': '未传DeviceId字段'}
except Exception as e:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
logging.info('AGVDownProduct error:%s' % e)
return json.JSONEncoder().encode(res)