合并cnc加工和后置检测工单,新增工单开始结束接口

This commit is contained in:
qihao.gong@jikimo.com
2024-01-17 17:26:24 +08:00
parent 0ea69f41e2
commit 2b7243f69c
6 changed files with 93 additions and 24 deletions

View File

@@ -40,3 +40,72 @@ class Manufacturing_Connect(http.Controller):
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
logging.info('get_Work_Info error:%s' % e)
return json.JSONEncoder().encode(res)
@http.route('/AutoDeviceApi/FeedBackStart', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
cors="*")
def button_Work_START(self, **kw):
"""
工单任务开始
:param kw:
:return:
"""
logging.info('get_Work_Info:%s' % kw)
try:
res = {'Succeed': True, 'Datas': []}
datas = request.httprequest.data
ret = json.loads(datas)
if not ret['BillId']:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传制造订单号'}
return json.JSONEncoder().encode(res)
if not ret['CraftId']:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传工序名称'}
return json.JSONEncoder().encode(res)
if not ret['DeviceId']:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传设备号'}
return json.JSONEncoder().encode(res)
production_id = ret['BillId']
routing_type = ret['CraftId']
workorder = request.env['mrp.workorder'].sudo().search(
[('production_id', '=', production_id), ('routing_type', '=', routing_type)], limit=1)
workorder.button_start()
except Exception as e:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
logging.info('get_Work_Info error:%s' % e)
return json.JSONEncoder().encode(res)
@http.route('/AutoDeviceApi/FeedBackEnd', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
cors="*")
def button_Work_End(self, **kw):
"""
工单任务结束
:param kw:
:return:
"""
logging.info('get_Work_Info:%s' % kw)
try:
res = {'Succeed': True, 'Datas': []}
datas = request.httprequest.data
ret = json.loads(datas)
if not ret['BillId']:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传制造订单号'}
return json.JSONEncoder().encode(res)
if not ret['CraftId']:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传工序名称'}
return json.JSONEncoder().encode(res)
if not ret['DeviceId']:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未传设备号'}
return json.JSONEncoder().encode(res)
production_id = ret['BillId']
routing_type = ret['CraftId']
workorder = request.env['mrp.workorder'].sudo().search(
[('production_id', '=', production_id), ('routing_type', '=', routing_type)], limit=1)
workorder.button_finish()
except Exception as e:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
logging.info('get_Work_Info error:%s' % e)
return json.JSONEncoder().encode(res)