1、接口优化
This commit is contained in:
@@ -470,9 +470,8 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
[0, '', {'production_id': production.id, 'type': '运送空料架'}],
|
[0, '', {'production_id': production.id, 'type': '运送空料架'}],
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# 拼接工单对象属性值(表面工艺)
|
||||||
# 拼接工单对象属性值(表面工艺)
|
def _json_workorder_surface_process_str(self, production, route, process_parameter, supplier_id):
|
||||||
def _json_workorder_surface_process_str(self, production, route, process_parameter, supplier_id):
|
|
||||||
workorders_values_str = [0, '', {
|
workorders_values_str = [0, '', {
|
||||||
'product_uom_id': production.product_uom_id.id,
|
'product_uom_id': production.product_uom_id.id,
|
||||||
'qty_producing': 0,
|
'qty_producing': 0,
|
||||||
@@ -496,9 +495,8 @@ def _json_workorder_surface_process_str(self, production, route, process_paramet
|
|||||||
}]
|
}]
|
||||||
return workorders_values_str
|
return workorders_values_str
|
||||||
|
|
||||||
|
# 维修模块按钮
|
||||||
# 维修模块按钮
|
def button_maintenance_req(self):
|
||||||
def button_maintenance_req(self):
|
|
||||||
self.ensure_one()
|
self.ensure_one()
|
||||||
return {
|
return {
|
||||||
'name': _('New Maintenance Request'),
|
'name': _('New Maintenance Request'),
|
||||||
@@ -516,36 +514,35 @@ def button_maintenance_req(self):
|
|||||||
'domain': [('workorder_id', '=', self.id)]
|
'domain': [('workorder_id', '=', self.id)]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# tray_id = fields.Many2one('sf.tray', string="托盘信息", tracking=True)
|
||||||
|
|
||||||
# tray_id = fields.Many2one('sf.tray', string="托盘信息", tracking=True)
|
# 扫码绑定托盘方法
|
||||||
|
|
||||||
# 扫码绑定托盘方法
|
# def gettray(self):
|
||||||
|
# if self.tray_code != False:
|
||||||
|
# values = self.env['sf.tray'].search([("code", "=", self.tray_code)])
|
||||||
|
# if values:
|
||||||
|
# if values.state == "占用":
|
||||||
|
# raise UserError('该托盘已占用')
|
||||||
|
# if values.state == "报损":
|
||||||
|
# raise UserError('该托盘已损坏')
|
||||||
|
# else:
|
||||||
|
# values.update({
|
||||||
|
# 'workorder_id': self,
|
||||||
|
# 'production_id': self.production_id,
|
||||||
|
# 'state': '占用',
|
||||||
|
# })
|
||||||
|
# self.work_state = "已绑定"
|
||||||
|
# orders = self.env['mrp.workorder'].search([('production_id', '=', self.production_id.id)])
|
||||||
|
# for a in orders:
|
||||||
|
# a.tray_id = values
|
||||||
|
# else:
|
||||||
|
# raise UserError('该托盘编码已失效')
|
||||||
|
# else:
|
||||||
|
# raise UserError('托盘码不能为空')
|
||||||
|
|
||||||
# def gettray(self):
|
# 验证坯料序列号是否正确
|
||||||
# if self.tray_code != False:
|
def pro_code_is_ok(self, barcode):
|
||||||
# values = self.env['sf.tray'].search([("code", "=", self.tray_code)])
|
|
||||||
# if values:
|
|
||||||
# if values.state == "占用":
|
|
||||||
# raise UserError('该托盘已占用')
|
|
||||||
# if values.state == "报损":
|
|
||||||
# raise UserError('该托盘已损坏')
|
|
||||||
# else:
|
|
||||||
# values.update({
|
|
||||||
# 'workorder_id': self,
|
|
||||||
# 'production_id': self.production_id,
|
|
||||||
# 'state': '占用',
|
|
||||||
# })
|
|
||||||
# self.work_state = "已绑定"
|
|
||||||
# orders = self.env['mrp.workorder'].search([('production_id', '=', self.production_id.id)])
|
|
||||||
# for a in orders:
|
|
||||||
# a.tray_id = values
|
|
||||||
# else:
|
|
||||||
# raise UserError('该托盘编码已失效')
|
|
||||||
# else:
|
|
||||||
# raise UserError('托盘码不能为空')
|
|
||||||
|
|
||||||
# 验证坯料序列号是否正确
|
|
||||||
def pro_code_is_ok(self, barcode):
|
|
||||||
if barcode is not False:
|
if barcode is not False:
|
||||||
if barcode != self.pro_code:
|
if barcode != self.pro_code:
|
||||||
raise UserError('坯料序列号错误')
|
raise UserError('坯料序列号错误')
|
||||||
@@ -553,73 +550,71 @@ def pro_code_is_ok(self, barcode):
|
|||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
pro_code = fields.Char(string='坯料序列号')
|
||||||
|
|
||||||
pro_code = fields.Char(string='坯料序列号')
|
pro_code_ok = fields.Boolean(default=False)
|
||||||
|
|
||||||
pro_code_ok = fields.Boolean(default=False)
|
# 托盘扫码绑定
|
||||||
|
# def gettray_auto(self, barcode):
|
||||||
|
# if barcode != False:
|
||||||
|
# values = self.env['sf.tray'].search([("code", "=", barcode)])
|
||||||
|
#
|
||||||
|
# if values:
|
||||||
|
# if values.state == "占用":
|
||||||
|
# raise UserError('该托盘已占用')
|
||||||
|
# if values.state == "报损":
|
||||||
|
# raise UserError('该托盘已损坏')
|
||||||
|
# else:
|
||||||
|
# values.update({
|
||||||
|
# 'workorder_id': self,
|
||||||
|
# 'production_id': self.production_id,
|
||||||
|
# 'state': '占用',
|
||||||
|
# })
|
||||||
|
# self.work_state = "已绑定"
|
||||||
|
# orders = self.env['mrp.workorder'].search([('production_id', '=', self.production_id.id)])
|
||||||
|
# for a in orders:
|
||||||
|
# a.tray_id = values
|
||||||
|
#
|
||||||
|
# return values
|
||||||
|
#
|
||||||
|
# # return {
|
||||||
|
# # 'name': _('New Maintenance Request'),
|
||||||
|
# # 'view_mode': 'form',
|
||||||
|
# # 'res_model': 'maintenance.request',
|
||||||
|
# # 'type': 'ir.actions.act_window',
|
||||||
|
# # 'context': {
|
||||||
|
# # 'default_company_id': self.company_id.id,
|
||||||
|
# # 'default_production_id': self.id,
|
||||||
|
# # },
|
||||||
|
# # 'domain': [('production_id', '=', self.id)],
|
||||||
|
# # }
|
||||||
|
# else:
|
||||||
|
# raise UserError('该托盘编码已失效')
|
||||||
|
# else:
|
||||||
|
# raise UserError('托盘码不能为空')
|
||||||
|
|
||||||
|
# 解除托盘绑定
|
||||||
|
# def unbindtray(self):
|
||||||
|
# tray = self.env['sf.tray'].search([("production_id", "=", self.production_id.id)])
|
||||||
|
# if tray:
|
||||||
|
# tray.unclamp()
|
||||||
|
# self.tray_id = False
|
||||||
|
|
||||||
# 托盘扫码绑定
|
# return {
|
||||||
# def gettray_auto(self, barcode):
|
# 'name': _('New Maintenance Request'),
|
||||||
# if barcode != False:
|
# 'view_mode': 'form',
|
||||||
# values = self.env['sf.tray'].search([("code", "=", barcode)])
|
# 'res_model': 'maintenance.request',
|
||||||
#
|
# 'res_id':self.id,
|
||||||
# if values:
|
# 'type': 'ir.actions.act_window',
|
||||||
# if values.state == "占用":
|
# 'context': {
|
||||||
# raise UserError('该托盘已占用')
|
# 'default_company_id': self.company_id.id,
|
||||||
# if values.state == "报损":
|
# 'default_production_id': self.id,
|
||||||
# raise UserError('该托盘已损坏')
|
# },
|
||||||
# else:
|
# 'domain': [('production_id', '=', self.id)],
|
||||||
# values.update({
|
# 'target':'new'
|
||||||
# 'workorder_id': self,
|
# }
|
||||||
# 'production_id': self.production_id,
|
|
||||||
# 'state': '占用',
|
|
||||||
# })
|
|
||||||
# self.work_state = "已绑定"
|
|
||||||
# orders = self.env['mrp.workorder'].search([('production_id', '=', self.production_id.id)])
|
|
||||||
# for a in orders:
|
|
||||||
# a.tray_id = values
|
|
||||||
#
|
|
||||||
# return values
|
|
||||||
#
|
|
||||||
# # return {
|
|
||||||
# # 'name': _('New Maintenance Request'),
|
|
||||||
# # 'view_mode': 'form',
|
|
||||||
# # 'res_model': 'maintenance.request',
|
|
||||||
# # 'type': 'ir.actions.act_window',
|
|
||||||
# # 'context': {
|
|
||||||
# # 'default_company_id': self.company_id.id,
|
|
||||||
# # 'default_production_id': self.id,
|
|
||||||
# # },
|
|
||||||
# # 'domain': [('production_id', '=', self.id)],
|
|
||||||
# # }
|
|
||||||
# else:
|
|
||||||
# raise UserError('该托盘编码已失效')
|
|
||||||
# else:
|
|
||||||
# raise UserError('托盘码不能为空')
|
|
||||||
|
|
||||||
# 解除托盘绑定
|
def recreateManufacturingOrWorkerOrder(self):
|
||||||
# def unbindtray(self):
|
|
||||||
# tray = self.env['sf.tray'].search([("production_id", "=", self.production_id.id)])
|
|
||||||
# if tray:
|
|
||||||
# tray.unclamp()
|
|
||||||
# self.tray_id = False
|
|
||||||
|
|
||||||
# return {
|
|
||||||
# 'name': _('New Maintenance Request'),
|
|
||||||
# 'view_mode': 'form',
|
|
||||||
# 'res_model': 'maintenance.request',
|
|
||||||
# 'res_id':self.id,
|
|
||||||
# 'type': 'ir.actions.act_window',
|
|
||||||
# 'context': {
|
|
||||||
# 'default_company_id': self.company_id.id,
|
|
||||||
# 'default_production_id': self.id,
|
|
||||||
# },
|
|
||||||
# 'domain': [('production_id', '=', self.id)],
|
|
||||||
# 'target':'new'
|
|
||||||
# }
|
|
||||||
|
|
||||||
def recreateManufacturingOrWorkerOrder(self):
|
|
||||||
"""
|
"""
|
||||||
重新生成制造订单或者重新生成工单
|
重新生成制造订单或者重新生成工单
|
||||||
"""
|
"""
|
||||||
@@ -663,8 +658,7 @@ def recreateManufacturingOrWorkerOrder(self):
|
|||||||
else:
|
else:
|
||||||
self.results = '合格'
|
self.results = '合格'
|
||||||
|
|
||||||
|
def json_workorder_str1(self, k, production, route):
|
||||||
def json_workorder_str1(self, k, production, route):
|
|
||||||
workorders_values_str = [0, '', {
|
workorders_values_str = [0, '', {
|
||||||
'product_uom_id': production.product_uom_id.id,
|
'product_uom_id': production.product_uom_id.id,
|
||||||
'qty_producing': 0,
|
'qty_producing': 0,
|
||||||
@@ -684,9 +678,8 @@ def json_workorder_str1(self, k, production, route):
|
|||||||
}]
|
}]
|
||||||
return workorders_values_str
|
return workorders_values_str
|
||||||
|
|
||||||
|
# 重写工单开始按钮方法
|
||||||
# 重写工单开始按钮方法
|
def button_start(self):
|
||||||
def button_start(self):
|
|
||||||
if self.routing_type == '装夹预调' and self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name:
|
if self.routing_type == '装夹预调' and self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name:
|
||||||
self.pro_code = self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name
|
self.pro_code = self.production_id.move_raw_ids[0].move_line_ids[0].lot_id.name
|
||||||
# 外协出库单,从“正在等待”变为“就绪”状态
|
# 外协出库单,从“正在等待”变为“就绪”状态
|
||||||
@@ -748,8 +741,7 @@ def button_start(self):
|
|||||||
else:
|
else:
|
||||||
raise UserError(_('请先完成上一步工单'))
|
raise UserError(_('请先完成上一步工单'))
|
||||||
|
|
||||||
|
def button_finish(self):
|
||||||
def button_finish(self):
|
|
||||||
if self.routing_type == '装夹预调':
|
if self.routing_type == '装夹预调':
|
||||||
if not self.material_center_point and self.X_deviation_angle > 0:
|
if not self.material_center_point and self.X_deviation_angle > 0:
|
||||||
raise UserError("请对前置三元检测定位参数进行计算定位")
|
raise UserError("请对前置三元检测定位参数进行计算定位")
|
||||||
@@ -791,9 +783,8 @@ def button_finish(self):
|
|||||||
self.production_id.button_mark_done1()
|
self.production_id.button_mark_done1()
|
||||||
# self.production_id.state = 'done'
|
# self.production_id.state = 'done'
|
||||||
|
|
||||||
|
# 将FTP的检测报告文件下载到临时目录
|
||||||
# 将FTP的检测报告文件下载到临时目录
|
def download_reportfile_tmp(self, workorder, reportpath):
|
||||||
def download_reportfile_tmp(self, workorder, reportpath):
|
|
||||||
logging.info('reportpath:%s' % reportpath)
|
logging.info('reportpath:%s' % reportpath)
|
||||||
production_no_ftp = reportpath.split('/')
|
production_no_ftp = reportpath.split('/')
|
||||||
production_no = workorder.production_id.name.replace('/', '_')
|
production_no = workorder.production_id.name.replace('/', '_')
|
||||||
@@ -813,9 +804,8 @@ def download_reportfile_tmp(self, workorder, reportpath):
|
|||||||
download_state = 2
|
download_state = 2
|
||||||
return download_state
|
return download_state
|
||||||
|
|
||||||
|
# 根据中控系统提供的检测文件地址去ftp里对应的制造订单里获取
|
||||||
# 根据中控系统提供的检测文件地址去ftp里对应的制造订单里获取
|
def get_detection_file(self, workorder, reportPath):
|
||||||
def get_detection_file(self, workorder, reportPath):
|
|
||||||
if reportPath.startswith('/'):
|
if reportPath.startswith('/'):
|
||||||
reportPath = reportPath[1:]
|
reportPath = reportPath[1:]
|
||||||
serverdir = os.path.join('/tmp', reportPath)
|
serverdir = os.path.join('/tmp', reportPath)
|
||||||
|
|||||||
@@ -12,13 +12,10 @@ class QualityCheck(models.Model):
|
|||||||
|
|
||||||
# ==========零件特采接口==========
|
# ==========零件特采接口==========
|
||||||
def _register_quality_check(self):
|
def _register_quality_check(self):
|
||||||
# create_url = '/AutoDeviceApi/PartSpecProc'
|
config = self.env['res.config.settings'].get_values()
|
||||||
# sf_sync_config = self.env['res.config.settings'].get_values()
|
# token = sf_sync_config['token'Ba F2CF5DCC-1A00-4234-9E95-65603F70CC8A]
|
||||||
# token = sf_sync_config['token']
|
headers = {'Authorization': config['center_control_Authorization']}
|
||||||
# sf_secret_key = sf_sync_config['sf_secret_key']
|
crea_url = config['center_control_url'] + "/AutoDeviceApi/GetToolInfos"
|
||||||
# headers = Common.get_headers(self, token, sf_secret_key)
|
|
||||||
headers = {'Authorization': 'Ba F2CF5DCC-1A00-4234-9E95-65603F70CC8A'}
|
|
||||||
crea_url = "https://x24467i973.zicp.fun/AutoDeviceApi/PartSpecProc"
|
|
||||||
origin = self.picking_id.origin
|
origin = self.picking_id.origin
|
||||||
production_id = self.env['mrp.production'].sudo().search([('name', '=', origin)])
|
production_id = self.env['mrp.production'].sudo().search([('name', '=', origin)])
|
||||||
rfid = '' if not production_id.workorder_ids else production_id.workorder_ids[-1].rfid_code or ''
|
rfid = '' if not production_id.workorder_ids else production_id.workorder_ids[-1].rfid_code or ''
|
||||||
|
|||||||
@@ -12,18 +12,16 @@ class CNCprocessing(models.Model):
|
|||||||
|
|
||||||
# ==========MES装刀指令接口==========
|
# ==========MES装刀指令接口==========
|
||||||
def register_cnc_processing(self, knife_plan):
|
def register_cnc_processing(self, knife_plan):
|
||||||
# sf_sync_config = self.env['res.config.settings'].get_values()
|
config = self.env['res.config.settings'].get_values()
|
||||||
# token = sf_sync_config['token']
|
# token = sf_sync_config['token'Ba F2CF5DCC-1A00-4234-9E95-65603F70CC8A]
|
||||||
# sf_secret_key = sf_sync_config['sf_secret_key']
|
headers = {'Authorization': config['center_control_Authorization']}
|
||||||
# headers = Common.get_headers(self, token, sf_secret_key)
|
crea_url = config['center_control_url'] + "/AutoDeviceApi/GetToolInfos"
|
||||||
headers = {'Authorization': 'Ba F2CF5DCC-1A00-4234-9E95-65603F70CC8A'}
|
|
||||||
strurl = "https://x24467i973.zicp.fun/AutoDeviceApi/ToolLoadInstruct"
|
|
||||||
val = {
|
val = {
|
||||||
'DeviceId': knife_plan.machine_table_name,
|
'DeviceId': knife_plan.machine_table_name,
|
||||||
'RfidCode': knife_plan.sf_functional_tool_assembly_id.rfid,
|
'RfidCode': knife_plan.sf_functional_tool_assembly_id.rfid,
|
||||||
'ToolId': int(knife_plan.cutter_spacing_code_id.code[1:])
|
'ToolId': int(knife_plan.cutter_spacing_code_id.code[1:])
|
||||||
}
|
}
|
||||||
r = requests.post(strurl, json=val, headers=headers)
|
r = requests.post(crea_url, json=val, headers=headers)
|
||||||
ret = r.json()
|
ret = r.json()
|
||||||
logging.info('register_cnc_processing:%s' % ret)
|
logging.info('register_cnc_processing:%s' % ret)
|
||||||
if ret['Succeed']:
|
if ret['Succeed']:
|
||||||
|
|||||||
Reference in New Issue
Block a user