Accept Merge Request #843: (feature/修改机床参数bug -> develop)

Merge Request: 新增获取库区信息定时器,完善库区变更接口

Created By: @龚启豪
Reviewed By: @马广威
Approved By: @马广威 
Accepted By: @龚启豪
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/843?initial=true
This commit is contained in:
龚启豪
2024-02-23 15:34:37 +08:00
committed by Coding
8 changed files with 81 additions and 11 deletions

View File

@@ -307,7 +307,7 @@ 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,
@http.route('/AutoDeviceApi/LocationChange', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
cors="*")
def LocationChange(self, **kw):
"""
@@ -320,11 +320,34 @@ class Manufacturing_Connect(http.Controller):
res = {'Succeed': True, 'Datas': []}
datas = request.httprequest.data
ret = json.loads(datas)
if ret:
print(ret)
RfidCode = ret['RfidCode']
ChangeType = ret['ChangeType']
OldDeciveId = ret['OldDeciveId']
OldPosition = ret['OldPosition']
NewDeciveId = ret['NewDeciveId']
NewPosition = ret['NewPosition']
OldDeciveStart = ret['OldDeciveStart']
OldDeciveEnd = ret['OldDeciveEnd']
workorder = request.env['mrp.workorder'].sudo().search(
[('rfid_code', '=', RfidCode)], limit=1)
if not workorder:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未根据RfidCode找到该工单'}
return json.JSONEncoder().encode(res)
else:
res = {'Succeed': False, 'ErrorCode': 201, 'Error': '未传RfidCode字段'}
old_localtion = request.env['sf.shelf.location'].sudo().search(
[('barcode', '=', OldPosition)], limit=1)
new_localtion = request.env['sf.shelf.location'].sudo().search(
[('barcode', '=', NewPosition)], limit=1)
if not new_localtion:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '没有该目标位置'}
return json.JSONEncoder().encode(res)
if old_localtion:
old_localtion.location_status = '空闲'
old_localtion.production_id = False
new_localtion.location_status = '占用'
new_localtion.production_id = workorder.production_id.id
# return json.JSONEncoder().encode(res)
# else:
# res = {'Succeed': False, 'ErrorCode': 201, 'Error': '未传RfidCode字段'}
except Exception as e:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
logging.info('LocationChange error:%s' % e)