优化工单相关接口

This commit is contained in:
jinling.yang
2024-02-22 14:26:56 +08:00
parent 65b5f7f30a
commit 0d755a50ae
2 changed files with 19 additions and 15 deletions

View File

@@ -34,6 +34,8 @@ class Http(models.AbstractModel):
# if abs(int(datas['HTTP_TIMESTAMP']) - timestamp_str) > deltime.seconds:
# raise AuthenticationError('请求已过期')
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_now = datetime.now().replace(microsecond=0)
datetime_del = datetime_now + timedelta(seconds=5)
@@ -42,7 +44,8 @@ class Http(models.AbstractModel):
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()
_logger.info('check_str:%s' % check_sf_str)
if check_sf_str != datas['HTTP_CHECKSTR']:
raise AuthenticationError('数据校验不通过')
_logger.info('check_sf_str:%s' % check_sf_str)
# if check_sf_str != datas['HTTP_CHECKSTR']:
# raise AuthenticationError('数据校验不通过')
else:
raise AuthenticationError('请求参数中无token')

View File

@@ -28,7 +28,7 @@ class Manufacturing_Connect(http.Controller):
for item in workorder:
res['Datas'].append({
'BillId': item.production_id.name,
'ProductionLine': item.production_line,
'ProductionLine': item.production_id.production_line_id.id,
'CraftName': item.name,
'Quantity': 1,
'MaterialId': item.product_id.default_code,
@@ -65,7 +65,6 @@ class Manufacturing_Connect(http.Controller):
ProductionLine = False
workorder = request.env['mrp.workorder'].sudo().get_plan_workorder(ProductionLine)
logging.info('RfidCode:%s' % ret)
workorder = request.env['mrp.workorder'].sudo().search([('name', '=', ret['ProductionLine'])])
if workorder:
for item in workorder:
date_planned_start = ''
@@ -108,18 +107,19 @@ class Manufacturing_Connect(http.Controller):
res = {'Succeed': True, 'Datas': []}
datas = request.httprequest.data
ret = json.loads(datas)
logging.info('RfidCode:%s' % ret)
logging.info('RfidCode:%s' % ret['RfidCode'])
if 'RfidCode' in ret:
workorder = request.env['mrp.workorder'].sudo().search(
[('routing_type', '=', '前置三元定位检测'), ('rfid_code', '=', ret['RfidCode'])])
if workorder:
for item in workorder:
offset = item.material_center_point.strip('()').split(',')
if item.material_center_point:
offset = item.material_center_point.strip('()').split(',')
res['Datas'].append({
'XOffset': item.production_id.name,
'YOffset': item.RfidCode,
'ZOffet': item.name,
'COffset': item.X_deviation_angle
'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[3],
'COffset': 'G54' if not item.X_deviation_angle else item.X_deviation_angle
})
else:
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该rfid暂未有对应的工件预调(前置三元检测)工单'}
@@ -194,15 +194,15 @@ class Manufacturing_Connect(http.Controller):
logging.info('button_Work_End error:%s' % e)
return json.JSONEncoder().encode(res)
@http.route('/AutoDeviceApi/QcCheck', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
@http.route('/AutoDeviceApi/PartQualityInspect', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
cors="*")
def Workorder_QcCheck(self, **kw):
def PartQualityInspect(self, **kw):
"""
零件质检
:param kw:
:return:
"""
logging.info('Workorder_QcCheck:%s' % kw)
logging.info('PartQualityInspect:%s' % kw)
try:
res = {'Succeed': True, 'Datas': []}
datas = request.httprequest.data
@@ -228,10 +228,10 @@ class Manufacturing_Connect(http.Controller):
[('production_id', '=', production_id), ('routing_type', '=', routing_type)], limit=1)
except Exception as e:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
logging.info('Workorder_QcCheck error:%s' % e)
logging.info('PartQualityInspect error:%s' % e)
return json.JSONEncoder().encode(res)
@http.route('/AutoDeviceApi/NCProgDolod', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
@http.route('/AutoDeviceApi/NCProgDolod', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
cors="*")
def NCProgDolod(self, **kw):
"""
@@ -245,6 +245,7 @@ class Manufacturing_Connect(http.Controller):
datas = request.httprequest.data
ret = json.loads(datas)
if 'RfidCode' in ret:
logging.info('RfidCode:%s' % ret['RfidCode'])
workorder = request.env['mrp.workorder'].sudo().search(
[('rfid_code', '=', ret['RfidCode']), ('routing_type', '=', 'CNC加工')])
if workorder: