Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/修改机床参数bug
This commit is contained in:
@@ -22,7 +22,7 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
ret = json.loads(datas)
|
ret = json.loads(datas)
|
||||||
# ret = json.loads(ret['result'])
|
# ret = json.loads(ret['result'])
|
||||||
logging.info('DeviceId:%s' % ret)
|
logging.info('DeviceId:%s' % ret)
|
||||||
tool_groups = request.env['sf.tool.groups'].sudo().search([('active', '=', True)])
|
tool_groups = request.env['sf.tool.groups'].sudo().search([])
|
||||||
|
|
||||||
res = {'Succeed': True, 'Datas': []}
|
res = {'Succeed': True, 'Datas': []}
|
||||||
if tool_groups:
|
if tool_groups:
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ class Http(models.AbstractModel):
|
|||||||
def _auth_method_sf_token(cls):
|
def _auth_method_sf_token(cls):
|
||||||
# 从headers.environ中获取对方传过来的token,timestamp,加密的校验字符串
|
# 从headers.environ中获取对方传过来的token,timestamp,加密的校验字符串
|
||||||
datas = request.httprequest.headers.environ
|
datas = request.httprequest.headers.environ
|
||||||
logging.info(datas)
|
|
||||||
if 'HTTP_TOKEN' in datas:
|
if 'HTTP_TOKEN' in datas:
|
||||||
_logger.info('token:%s' % datas['HTTP_TOKEN'])
|
_logger.info('token:%s' % datas['HTTP_TOKEN'])
|
||||||
# 查询密钥
|
# 查询密钥
|
||||||
@@ -34,8 +33,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,9 +40,12 @@ 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)
|
||||||
# if check_sf_str != datas['HTTP_CHECKSTR']:
|
_logger.info('check_str:%s' % check_str)
|
||||||
# raise AuthenticationError('数据校验不通过')
|
_logger.info('sf_secret_key:%s' % factory_secret.sf_secret_key)
|
||||||
|
if check_sf_str != datas['HTTP_CHECKSTR']:
|
||||||
|
raise AuthenticationError('数据校验不通过')
|
||||||
else:
|
else:
|
||||||
raise AuthenticationError('请求参数中无token')
|
raise AuthenticationError('请求参数中无token')
|
||||||
|
|||||||
@@ -22,13 +22,13 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
ret = json.loads(datas)
|
ret = json.loads(datas)
|
||||||
logging.info('RfidCode:%s' % ret['RfidCode'])
|
logging.info('RfidCode:%s' % ret['RfidCode'])
|
||||||
if 'RfidCode' in ret:
|
if 'RfidCode' in ret:
|
||||||
workorder = request.env['mrp.workorder'].sudo().search(
|
workorder = request.env['mrp.workorder'].sudo().search([('rfid_code', '=', ret['RfidCode'])])
|
||||||
[('rfid_code', '=', ret['RfidCode']), ('routing_type', '=', '装夹预调')])
|
|
||||||
if workorder:
|
if workorder:
|
||||||
for item in workorder:
|
for item in workorder:
|
||||||
res['Datas'].append({
|
res['Datas'].append({
|
||||||
'BillId': item.production_id.name,
|
'BillId': item.production_id.name,
|
||||||
'ProductionLine': item.production_id.production_line_id.id,
|
'ProductionLine': item.production_id.production_line_id.id,
|
||||||
|
'SortId': item.sequence,
|
||||||
'CraftName': item.name,
|
'CraftName': item.name,
|
||||||
'Quantity': 1,
|
'Quantity': 1,
|
||||||
'MaterialId': item.product_id.default_code,
|
'MaterialId': item.product_id.default_code,
|
||||||
@@ -60,11 +60,13 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
datas = request.httprequest.data
|
datas = request.httprequest.data
|
||||||
ret = json.loads(datas)
|
ret = json.loads(datas)
|
||||||
if 'ProductionLine' in ret:
|
if 'ProductionLine' in ret:
|
||||||
workorder = request.env['mrp.workorder'].sudo().get_plan_workorder(ret['ProductionLine'])
|
workorder_ids = request.env['mrp.workorder'].sudo().get_plan_workorder(ret['ProductionLine'])
|
||||||
else:
|
else:
|
||||||
ProductionLine = False
|
ProductionLine = False
|
||||||
workorder = request.env['mrp.workorder'].sudo().get_plan_workorder(ProductionLine)
|
workorder_ids = request.env['mrp.workorder'].sudo().get_plan_workorder(ProductionLine)
|
||||||
logging.info('RfidCode:%s' % ret)
|
logging.info('RfidCode:%s' % ret)
|
||||||
|
logging.info('workorder_ids:%s' % workorder_ids)
|
||||||
|
workorder = request.env['mrp.workorder'].sudo().search(workorder_ids)
|
||||||
if workorder:
|
if workorder:
|
||||||
for item in workorder:
|
for item in workorder:
|
||||||
date_planned_start = ''
|
date_planned_start = ''
|
||||||
@@ -119,7 +121,8 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
'XOffset': 0 if not item.material_center_point else offset[0],
|
'XOffset': 0 if not item.material_center_point else offset[0],
|
||||||
'YOffset': 0 if not item.material_center_point else offset[1],
|
'YOffset': 0 if not item.material_center_point else offset[1],
|
||||||
'ZOffet': 0 if not item.material_center_point else offset[2],
|
'ZOffet': 0 if not item.material_center_point else offset[2],
|
||||||
'COffset': 'G54' if not item.X_deviation_angle else item.X_deviation_angle
|
'COffset': 0 if not item.X_deviation_angle else item.X_deviation_angle,
|
||||||
|
'Coordinate': 'G54'
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该rfid暂未有对应的工件预调(前置三元检测)工单'}
|
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该rfid暂未有对应的工件预调(前置三元检测)工单'}
|
||||||
@@ -293,17 +296,15 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
logging.info('NCProgDolod error:%s' % e)
|
logging.info('NCProgDolod error:%s' % e)
|
||||||
return json.JSONEncoder().encode(res)
|
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='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
|
||||||
@@ -315,6 +316,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)
|
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 = 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)
|
||||||
|
|||||||
@@ -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(
|
||||||
|
|||||||
@@ -135,6 +135,17 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
workpiece_delivery_ids = fields.One2many('sf.workpiece.delivery', 'workorder_id', '工件配送')
|
workpiece_delivery_ids = fields.One2many('sf.workpiece.delivery', 'workorder_id', '工件配送')
|
||||||
is_delivery = fields.Boolean('是否配送完成', default=False)
|
is_delivery = fields.Boolean('是否配送完成', default=False)
|
||||||
rfid_code = fields.Char('RFID')
|
rfid_code = fields.Char('RFID')
|
||||||
|
production_line_id = fields.Many2one('sf.production.line', related='production_id.production_line_id',
|
||||||
|
string='生产线', store=True)
|
||||||
|
production_line_state = fields.Selection(related='production_id.production_line_state',
|
||||||
|
string='上/下产线', store=True)
|
||||||
|
|
||||||
|
@api.onchange('rfid_code')
|
||||||
|
def compute_rfid(self):
|
||||||
|
workorder = self.env['mrp.workorder'].search([('production_id', '=', self.production_id)])
|
||||||
|
if workorder:
|
||||||
|
for item in workorder:
|
||||||
|
item.rfid_code = self.rfid_code
|
||||||
|
|
||||||
def get_plan_workorder(self, production_line):
|
def get_plan_workorder(self, production_line):
|
||||||
tomorrow = (date.today() + timedelta(days=+1)).strftime("%Y-%m-%d")
|
tomorrow = (date.today() + timedelta(days=+1)).strftime("%Y-%m-%d")
|
||||||
@@ -149,7 +160,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
params = [tomorrow, tomorrow, tomorrow, tomorrow]
|
params = [tomorrow, tomorrow, tomorrow, tomorrow]
|
||||||
if production_line:
|
if production_line:
|
||||||
sql += "AND production_line_id = %s"
|
sql += "AND production_line_id = %s"
|
||||||
params.append(production_line)
|
params.append(production_line)
|
||||||
self.env.cr.execute(sql, params)
|
self.env.cr.execute(sql, params)
|
||||||
ids = [t[0] for t in self.env.cr.fetchall()]
|
ids = [t[0] for t in self.env.cr.fetchall()]
|
||||||
return [('id', 'in', ids)]
|
return [('id', 'in', ids)]
|
||||||
@@ -875,5 +886,3 @@ class CMMprogram(models.Model):
|
|||||||
post_processing_name = fields.Char('后处理名称')
|
post_processing_name = fields.Char('后处理名称')
|
||||||
program_date = fields.Datetime('程序日期')
|
program_date = fields.Datetime('程序日期')
|
||||||
workorder_id = fields.Many2one('mrp.workorder', string="工单")
|
workorder_id = fields.Many2one('mrp.workorder', string="工单")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -69,8 +69,9 @@
|
|||||||
<field name="programming_no" readonly="1"/>
|
<field name="programming_no" readonly="1"/>
|
||||||
<field name="work_state" invisible="1"/>
|
<field name="work_state" invisible="1"/>
|
||||||
<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"
|
||||||
|
|||||||
@@ -170,14 +170,15 @@
|
|||||||
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割"))]}'/>
|
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割"))]}'/>
|
||||||
<field name="equipment_id"
|
<field name="equipment_id"
|
||||||
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割"))]}'/>
|
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割"))]}'/>
|
||||||
|
<field name="production_line_state"
|
||||||
|
attrs='{"invisible": [("routing_type","in",("获取CNC加工程序","切割"))]}'/>
|
||||||
<field name="functional_fixture_id"
|
<field name="functional_fixture_id"
|
||||||
attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
|
attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
|
||||||
<field name="functional_fixture_code" force_save="1"
|
<field name="functional_fixture_code" force_save="1"
|
||||||
attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
|
attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
|
||||||
<field name="functional_fixture_type_id" force_save="1"
|
<field name="functional_fixture_type_id" force_save="1"
|
||||||
attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
|
attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
|
||||||
<field name="rfid_code"
|
<field name="rfid_code" force_save="1"/>
|
||||||
attrs='{"invisible": [("routing_type","!=","装夹预调")]}'/>
|
|
||||||
</group>
|
</group>
|
||||||
<group attrs='{"invisible": [("routing_type","=","获取CNC加工程序")]}'>
|
<group attrs='{"invisible": [("routing_type","=","获取CNC加工程序")]}'>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -8,53 +8,53 @@ from odoo.http import request
|
|||||||
|
|
||||||
class Manufacturing_Connect(http.Controller):
|
class Manufacturing_Connect(http.Controller):
|
||||||
|
|
||||||
@http.route('/AutoDeviceApi/GetToolInfo', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
|
# @http.route('/AutoDeviceApi/GetToolInfo', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
|
||||||
cors="*")
|
# cors="*")
|
||||||
def get_equipment_tool_Info(self, **kw):
|
# def get_equipment_tool_Info(self, **kw):
|
||||||
"""
|
# """
|
||||||
机床刀库实时信息
|
# 机床刀库实时信息
|
||||||
:param kw:
|
# :param kw:
|
||||||
:return:
|
# :return:
|
||||||
"""
|
# """
|
||||||
logging.info('get_equipment_tool_Info:%s' % kw)
|
# logging.info('get_equipment_tool_Info:%s' % kw)
|
||||||
try:
|
# try:
|
||||||
datas = request.httprequest.data
|
# datas = request.httprequest.data
|
||||||
ret = json.loads(datas)
|
# ret = json.loads(datas)
|
||||||
ret = json.loads(ret.get('result'))
|
# ret = json.loads(ret.get('result'))
|
||||||
logging.info('DeviceId:%s' % ret)
|
# logging.info('DeviceId:%s' % ret)
|
||||||
equipment = request.env['maintenance.equipment'].sudo().search([('name', '=', ret['DeviceId'])])
|
# equipment = request.env['maintenance.equipment'].sudo().search([('name', '=', ret['DeviceId'])])
|
||||||
|
#
|
||||||
res = {'Succeed': True, 'Datas': []}
|
# res = {'Succeed': True, 'Datas': []}
|
||||||
if equipment:
|
# if equipment:
|
||||||
for item in equipment:
|
# for item in equipment:
|
||||||
data = []
|
# data = []
|
||||||
for equipment_tool_id in item.product_template_ids:
|
# for equipment_tool_id in item.product_template_ids:
|
||||||
functional_tool_id = self.env['sf.functional.cutting.tool.entity'].sudo().search(
|
# functional_tool_id = self.env['sf.functional.cutting.tool.entity'].sudo().search(
|
||||||
[('code', '=', equipment_tool_id.tool_code)])
|
# [('code', '=', equipment_tool_id.tool_code)])
|
||||||
|
#
|
||||||
alarm_time = None
|
# alarm_time = None
|
||||||
if functional_tool_id.functional_tool_status == '报警':
|
# if functional_tool_id.functional_tool_status == '报警':
|
||||||
alarm_time = self.env['sf.functional.tool.warning'].sudo().search(
|
# alarm_time = self.env['sf.functional.tool.warning'].sudo().search(
|
||||||
[('code', '=', equipment_tool_id.tool_code)]).alarm_time
|
# [('code', '=', equipment_tool_id.tool_code)]).alarm_time
|
||||||
equipment_tool = {
|
# equipment_tool = {
|
||||||
'RfidCode': None,
|
# 'RfidCode': None,
|
||||||
'ToolId': equipment_tool_id.code,
|
# 'ToolId': equipment_tool_id.code,
|
||||||
'ToolName': equipment_tool_id.functional_tool_name_id.name,
|
# 'ToolName': equipment_tool_id.functional_tool_name_id.name,
|
||||||
'MaxLife': equipment_tool_id.life_value_max,
|
# 'MaxLife': equipment_tool_id.life_value_max,
|
||||||
'UseLife': equipment_tool_id.used_value,
|
# 'UseLife': equipment_tool_id.used_value,
|
||||||
'AddDatetime': equipment_tool_id.tool_install_time,
|
# 'AddDatetime': equipment_tool_id.tool_install_time,
|
||||||
'State': functional_tool_id.functional_tool_status,
|
# 'State': functional_tool_id.functional_tool_status,
|
||||||
'WarnDate': alarm_time if alarm_time else False
|
# 'WarnDate': alarm_time if alarm_time else False
|
||||||
}
|
# }
|
||||||
data.append(equipment_tool)
|
# data.append(equipment_tool)
|
||||||
res['Datas'].append({
|
# res['Datas'].append({
|
||||||
'DeviceId': item.name,
|
# 'DeviceId': item.name,
|
||||||
'Data': data
|
# 'Data': data
|
||||||
})
|
# })
|
||||||
except Exception as e:
|
# except Exception as e:
|
||||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
# res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||||
logging.info('get_equipment_tool_Info error:%s' % e)
|
# logging.info('get_equipment_tool_Info error:%s' % e)
|
||||||
return json.JSONEncoder().encode(res)
|
# return json.JSONEncoder().encode(res)
|
||||||
|
|
||||||
@http.route('/AutoDeviceApi/ToolGroup', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
|
@http.route('/AutoDeviceApi/ToolGroup', type='json', auth='none', methods=['GET', 'POST'], csrf=False,
|
||||||
cors="*")
|
cors="*")
|
||||||
@@ -70,7 +70,7 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
ret = json.loads(datas)
|
ret = json.loads(datas)
|
||||||
# ret = json.loads(ret['result'])
|
# ret = json.loads(ret['result'])
|
||||||
logging.info('DeviceId:%s' % ret)
|
logging.info('DeviceId:%s' % ret)
|
||||||
functional_tools = request.env['sf.functional.cutting.tool.entity'].sudo().search([('active', '=', True)])
|
functional_tools = request.env['sf.functional.cutting.tool.entity'].sudo().search([])
|
||||||
|
|
||||||
res = {'Succeed': True, 'Datas': []}
|
res = {'Succeed': True, 'Datas': []}
|
||||||
if functional_tools:
|
if functional_tools:
|
||||||
|
|||||||
@@ -734,7 +734,7 @@ class CAMWorkOrderProgramKnifePlan(models.Model):
|
|||||||
撤回装刀申请
|
撤回装刀申请
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
self.env['sf.functional.tool.assembly'].search(
|
self.env['sf.functional.tool.assembly'].sudo().search(
|
||||||
[('assembly_order_code', '=', self.sf_functional_tool_assembly_id.assembly_order_code),
|
[('assembly_order_code', '=', self.sf_functional_tool_assembly_id.assembly_order_code),
|
||||||
('loading_task_source', '=', '0')]).unlink()
|
('loading_task_source', '=', '0')]).unlink()
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
|
import json
|
||||||
|
import requests
|
||||||
from odoo import models, api, fields
|
from odoo import models, api, fields
|
||||||
from odoo.exceptions import ValidationError
|
from odoo.exceptions import ValidationError
|
||||||
|
from odoo.addons.sf_base.commons.common import Common
|
||||||
|
|
||||||
|
|
||||||
class SfMaintenanceEquipmentTool(models.Model):
|
class SfMaintenanceEquipmentTool(models.Model):
|
||||||
@@ -29,6 +32,30 @@ class SfMaintenanceEquipmentTool(models.Model):
|
|||||||
return tools
|
return tools
|
||||||
|
|
||||||
|
|
||||||
|
class SfMaintenanceEquipment(models.Model):
|
||||||
|
_inherit = 'maintenance.equipment'
|
||||||
|
_description = '设备机床刀库'
|
||||||
|
|
||||||
|
# ==========机床当前刀库实时信息接口==========
|
||||||
|
def register_equipment_tool(self):
|
||||||
|
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||||
|
token = sf_sync_config['token']
|
||||||
|
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||||
|
headers = Common.get_headers(self, token, sf_secret_key)
|
||||||
|
strurl = "https://x24467i973.zicp.fun/AutoDeviceApi/GetToolInfos"
|
||||||
|
val = {
|
||||||
|
"DeviceId": self.name
|
||||||
|
}
|
||||||
|
kw = json.dumps(val, ensure_ascii=False)
|
||||||
|
r = requests.get(strurl, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
||||||
|
ret = r.json()
|
||||||
|
print(ret)
|
||||||
|
if r == 200:
|
||||||
|
return "机床当前刀库实时信息指令发送成功"
|
||||||
|
else:
|
||||||
|
raise ValidationError("机床当前刀库实时信息指令发送失败")
|
||||||
|
|
||||||
|
|
||||||
class StockLot(models.Model):
|
class StockLot(models.Model):
|
||||||
_inherit = 'stock.lot'
|
_inherit = 'stock.lot'
|
||||||
|
|
||||||
|
|||||||
@@ -11,12 +11,11 @@ class CNCprocessing(models.Model):
|
|||||||
|
|
||||||
# ==========MES装刀指令接口==========
|
# ==========MES装刀指令接口==========
|
||||||
def register_cnc_processing(self, cnc_processing):
|
def register_cnc_processing(self, cnc_processing):
|
||||||
create_url = '/AutoDeviceApi/ToolLoadInstruct'
|
|
||||||
sf_sync_config = self.env['res.config.settings'].get_values()
|
sf_sync_config = self.env['res.config.settings'].get_values()
|
||||||
token = sf_sync_config['token']
|
token = sf_sync_config['token']
|
||||||
sf_secret_key = sf_sync_config['sf_secret_key']
|
sf_secret_key = sf_sync_config['sf_secret_key']
|
||||||
headers = Common.get_headers(self, token, sf_secret_key)
|
headers = Common.get_headers(self, token, sf_secret_key)
|
||||||
strurl = sf_sync_config['sf_url'] + create_url
|
strurl = "https://x24467i973.zicp.fun/AutoDeviceApi/ToolLoadInstruct"
|
||||||
val = {
|
val = {
|
||||||
'DeviceId': cnc_processing.workorder_id.machine_tool_name,
|
'DeviceId': cnc_processing.workorder_id.machine_tool_name,
|
||||||
'RfidCode': None,
|
'RfidCode': None,
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
<xpath expr="//page[@name='sf_equipment_product_template']" position="replace">
|
<xpath expr="//page[@name='sf_equipment_product_template']" position="replace">
|
||||||
<page string="标准刀库" name="sf_equipment_product_template"
|
<page string="标准刀库" name="sf_equipment_product_template"
|
||||||
attrs="{'invisible': [('equipment_type', '!=', '机床')]}">
|
attrs="{'invisible': [('equipment_type', '!=', '机床')]}">
|
||||||
|
<button string="获取机床刀库信息" name="register_equipment_tool" type="object" class="btn-primary"/>
|
||||||
<field name='product_template_ids'>
|
<field name='product_template_ids'>
|
||||||
<tree editable='bottom'>
|
<tree editable='bottom'>
|
||||||
<field name="code"/>
|
<field name="code"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user