新增agv相关接口
This commit is contained in:
@@ -34,8 +34,6 @@ class Http(models.AbstractModel):
|
|||||||
# if abs(int(datas['HTTP_TIMESTAMP']) - timestamp_str) > deltime.seconds:
|
# if abs(int(datas['HTTP_TIMESTAMP']) - timestamp_str) > deltime.seconds:
|
||||||
# raise AuthenticationError('请求已过期')
|
# raise AuthenticationError('请求已过期')
|
||||||
post_time = int(datas['HTTP_TIMESTAMP'])
|
post_time = int(datas['HTTP_TIMESTAMP'])
|
||||||
_logger.info('HTTP_TIMESTAMP:%s' % post_time)
|
|
||||||
_logger.info('HTTP_CHECKSTR:%s' % datas['HTTP_CHECKSTR'])
|
|
||||||
datetime_post = datetime.fromtimestamp(post_time)
|
datetime_post = datetime.fromtimestamp(post_time)
|
||||||
datetime_now = datetime.now().replace(microsecond=0)
|
datetime_now = datetime.now().replace(microsecond=0)
|
||||||
datetime_del = datetime_now + timedelta(seconds=5)
|
datetime_del = datetime_now + timedelta(seconds=5)
|
||||||
@@ -43,8 +41,11 @@ class Http(models.AbstractModel):
|
|||||||
raise AuthenticationError('请求已过期')
|
raise AuthenticationError('请求已过期')
|
||||||
check_str = '%s%s%s' % (datas['HTTP_TOKEN'], post_time, factory_secret.sf_secret_key)
|
check_str = '%s%s%s' % (datas['HTTP_TOKEN'], post_time, factory_secret.sf_secret_key)
|
||||||
check_sf_str = hashlib.sha1(check_str.encode('utf-8')).hexdigest()
|
check_sf_str = hashlib.sha1(check_str.encode('utf-8')).hexdigest()
|
||||||
_logger.info('check_str:%s' % check_sf_str)
|
_logger.info('HTTP_TIMESTAMP:%s' % post_time)
|
||||||
|
_logger.info('HTTP_CHECKSTR:%s' % datas['HTTP_CHECKSTR'])
|
||||||
_logger.info('check_sf_str:%s' % check_sf_str)
|
_logger.info('check_sf_str:%s' % check_sf_str)
|
||||||
|
_logger.info('check_str:%s' % check_str)
|
||||||
|
_logger.info('sf_secret_key:%s' % factory_secret.sf_secret_key)
|
||||||
# if check_sf_str != datas['HTTP_CHECKSTR']:
|
# if check_sf_str != datas['HTTP_CHECKSTR']:
|
||||||
# raise AuthenticationError('数据校验不通过')
|
# raise AuthenticationError('数据校验不通过')
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -310,13 +310,13 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
|
|
||||||
@http.route('/AutoDeviceApi/LocationChange', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
|
@http.route('/AutoDeviceApi/LocationChange', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
|
||||||
cors="*")
|
cors="*")
|
||||||
def NCProgDolod(self, **kw):
|
def LocationChange(self, **kw):
|
||||||
"""
|
"""
|
||||||
库位变更
|
库位变更
|
||||||
:param kw:
|
:param kw:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
logging.info('NCProgDolod:%s' % kw)
|
logging.info('LocationChange:%s' % kw)
|
||||||
try:
|
try:
|
||||||
res = {'Succeed': True, 'Datas': []}
|
res = {'Succeed': True, 'Datas': []}
|
||||||
datas = request.httprequest.data
|
datas = request.httprequest.data
|
||||||
@@ -328,5 +328,62 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
res = {'Succeed': False, 'ErrorCode': 201, 'Error': '未传RfidCode字段'}
|
res = {'Succeed': False, 'ErrorCode': 201, 'Error': '未传RfidCode字段'}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': 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': []}
|
||||||
|
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)
|
return json.JSONEncoder().encode(res)
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ class MrpProduction(models.Model):
|
|||||||
glb_file = fields.Binary("glb模型文件")
|
glb_file = fields.Binary("glb模型文件")
|
||||||
production_line_id = fields.Many2one('sf.production.line', string='生产线')
|
production_line_id = fields.Many2one('sf.production.line', string='生产线')
|
||||||
plan_start_processing_time = fields.Datetime('计划开始加工时间')
|
plan_start_processing_time = fields.Datetime('计划开始加工时间')
|
||||||
|
production_line_state = fields.Selection([('待上产线', '待上产线'), ('已上产线', '已上产线'), ('已下产线', '已下产线')],
|
||||||
|
string='上/下产线', default='待上产线')
|
||||||
|
|
||||||
|
|
||||||
@api.depends(
|
@api.depends(
|
||||||
|
|||||||
@@ -71,6 +71,7 @@
|
|||||||
<field name="programming_state" readonly="1"/>
|
<field name="programming_state" readonly="1"/>
|
||||||
<field name="production_line_id" readonly="1"/>
|
<field name="production_line_id" readonly="1"/>
|
||||||
<field name="plan_start_processing_time" readonly="1"/>
|
<field name="plan_start_processing_time" readonly="1"/>
|
||||||
|
<field name="production_line_state" readonly="1"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//header//button[@name='action_cancel']" position="replace">
|
<xpath expr="//header//button[@name='action_cancel']" position="replace">
|
||||||
<button name="action_cancel" type="object" string="取消" data-hotkey="z"
|
<button name="action_cancel" type="object" string="取消" data-hotkey="z"
|
||||||
|
|||||||
Reference in New Issue
Block a user