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

# Conflicts:
#	sf_manufacturing/models/mrp_production.py
#	sf_manufacturing/views/mrp_workorder_view.xml
This commit is contained in:
mgw
2024-04-23 10:56:57 +08:00
39 changed files with 713 additions and 260 deletions

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
@@ -114,7 +115,7 @@ class Manufacturing_Connect(http.Controller):
logging.info('RfidCode:%s' % ret['RfidCode'])
if 'RfidCode' in ret:
workorder = request.env['mrp.workorder'].sudo().search(
[('routing_type', '=', '装夹预调'), ('rfid_code', '=', ret['RfidCode'])])
[('routing_type', '=', '装夹预调'), ('rfid_code', '=', ret['RfidCode'])], limit=1, order='id asc')
if workorder:
for item in workorder:
if item.material_center_point:
@@ -122,8 +123,8 @@ class Manufacturing_Connect(http.Controller):
res['Datas'].append({
'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': 0 if not item.X_deviation_angle else item.X_deviation_angle,
'ZOffset': 0 if not item.material_center_point else offset[2],
'COffset': 0,
'Coordinate': 'G54'
})
else:
@@ -432,14 +433,15 @@ class Manufacturing_Connect(http.Controller):
if 'DeviceId' in ret:
logging.info('DeviceId:%s' % ret['DeviceId'])
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
[('feeder_station_destination', '=', ret['DeviceId'])])
[('feeder_station_start_id.name', '=', ret['DeviceId']),
('status', '=', '待配送')], limit=1, order='id asc')
if workpiece_delivery:
for wd in workpiece_delivery:
logging.info('wd.workorder_id:%s' % wd.workorder_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 == '待上产线':
logging.info('wd.production_id:%s' % wd.production_id.name)
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': '已上产线'})
else:
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该DeviceId没有对应的工件配送数据'}
else:
@@ -466,14 +468,28 @@ class Manufacturing_Connect(http.Controller):
if 'DeviceId' in ret:
logging.info('DeviceId:%s' % ret['DeviceId'])
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
[('feeder_station_destination', '=', ret['DeviceId'])])
[('feeder_station_destination_id.name', '=', ret['DeviceId']),
('status', '=', '待配送')], limit=1, order='id asc')
if workpiece_delivery:
for wd in workpiece_delivery:
logging.info('wd.workorder_id:%s' % wd.workorder_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 == '已上产线':
logging.info('wd.production_id:%s' % wd.production_id.name)
logging.info('wd.production_line_state:%s' % wd.production_id.production_line_state)
workpiece_delivery_off = request.env['sf.workpiece.delivery'].sudo().create({
'production_id': wd.production_id.id,
'feeder_station_start_id': workpiece_delivery.feeder_station_start_id.id,
'feeder_station_destination_id': '',
'workorder_id': workpiece_delivery.workorder_id.id,
'workpiece_code': workpiece_delivery.workpiece_code,
'production_line_id': workpiece_delivery.production_line_id.id,
'task_delivery_time': datetime.now(),
'production_line_state': '已下产线'
})
wd.production_id.write({'production_line_state': '已下产线'})
logging.info('开始向agv下发下产线任务')
workpiece_delivery_off._delivery_avg()
logging.info('agv下发下产线任务已配送')
else:
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该DeviceId没有对应的工件配送数据'}
else:
@@ -482,3 +498,35 @@ class Manufacturing_Connect(http.Controller):
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='none', methods=['GET', 'POST'], csrf=False,
cors="*")
def PutEquipmentBaseCoordinate(self, **kw):
"""
获取机床基坐标
:param kw:
:return:
"""
logging.info('PutEquipmentBaseCoordinate:%s' % kw)
try:
res = {'Succeed': True}
datas = request.httprequest.data
ret = json.loads(datas)
if 'DeviceId' in ret:
equipment = request.env['maintenance.equipment'].sudo().search('name', '=', ret['DeviceId'])
if equipment:
equipment.sudo().write({
'base_coordinate_fixture_model_id': ret['base_coordinate_fixture_model_id'],
'base_coordinate_g_coordinate': ret['base_coordinate_g_coordinate'],
'base_coordinate_x': ret['base_coordinate_x'],
'base_coordinate_y': ret['base_coordinate_y'],
'base_coordinate_z': ret['base_coordinate_z'],
})
else:
res = {'Succeed': False, 'ErrorCode': 203, 'Error': 'DeviceId为%s的设备不存在!' % ret['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)