|
|
|
|
@@ -162,13 +162,7 @@ class ToolMaterial(models.Model):
|
|
|
|
|
except Exception as e:
|
|
|
|
|
logging.info("刀具物料同步失败:%s" % e)
|
|
|
|
|
|
|
|
|
|
# @api.model_create_multi
|
|
|
|
|
# def create(self, vals_list):
|
|
|
|
|
# records = super(ToolMaterial, self).create(vals_list)
|
|
|
|
|
# for record in records:
|
|
|
|
|
# if record:
|
|
|
|
|
# record.enroll_tool_material()
|
|
|
|
|
# return records
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class FunctionalCuttingToolEntity(models.Model):
|
|
|
|
|
@@ -256,250 +250,208 @@ class FunctionalCuttingToolEntity(models.Model):
|
|
|
|
|
except Exception as e:
|
|
|
|
|
logging.info("功能刀具同步失败:%s" % e)
|
|
|
|
|
|
|
|
|
|
# @api.model_create_multi
|
|
|
|
|
# def create(self, vals_list):
|
|
|
|
|
# records = super(FunctionalCuttingToolEntity, self).create(vals_list)
|
|
|
|
|
# for record in records:
|
|
|
|
|
# if record:
|
|
|
|
|
# record.enroll_functional_tool_entity()
|
|
|
|
|
# return records
|
|
|
|
|
|
|
|
|
|
# def write(self, vals):
|
|
|
|
|
# res = super().write(vals)
|
|
|
|
|
# if vals.get('current_location'):
|
|
|
|
|
# self.enroll_functional_tool_entity()
|
|
|
|
|
# return res
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# class FunctionalToolWarning(models.Model):
|
|
|
|
|
# _inherit = 'sf.functional.tool.warning'
|
|
|
|
|
# _description = '功能刀具预警注册'
|
|
|
|
|
#
|
|
|
|
|
# crea_url = "/api/functional_tool_warning/create"
|
|
|
|
|
#
|
|
|
|
|
# # 注册同步功能刀具预警
|
|
|
|
|
# def enroll_functional_tool_warning(self):
|
|
|
|
|
# logging.info('调用功能刀具预警注册接口: enroll_functional_tool_warning()')
|
|
|
|
|
# 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)
|
|
|
|
|
# str_url = sf_sync_config['sf_url'] + self.crea_url
|
|
|
|
|
# objs_all = self.env['sf.functional.tool.warning'].search([('id', '=', self.id)])
|
|
|
|
|
# self.get_sync_functional_tool_warning(objs_all, str_url, token, headers)
|
|
|
|
|
#
|
|
|
|
|
# def sync_enroll_functional_tool_warning_all(self):
|
|
|
|
|
# logging.info('调用功能刀具预警注册接口: sync_enroll_functional_tool_warning_all()')
|
|
|
|
|
# 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)
|
|
|
|
|
# str_url = sf_sync_config['sf_url'] + self.crea_url
|
|
|
|
|
# objs_all = self.env['sf.functional.tool.warning'].search([])
|
|
|
|
|
# self.get_sync_functional_tool_warning(objs_all, str_url, token, headers)
|
|
|
|
|
#
|
|
|
|
|
# def get_sync_functional_tool_warning(self, objs_all, str_url, token, headers):
|
|
|
|
|
# tool_warning_list = []
|
|
|
|
|
# try:
|
|
|
|
|
# if objs_all:
|
|
|
|
|
# for item in objs_all:
|
|
|
|
|
# val = {
|
|
|
|
|
# 'id': item.id,
|
|
|
|
|
# 'name': item.name,
|
|
|
|
|
# 'code': item.code,
|
|
|
|
|
# 'rfid': item.rfid,
|
|
|
|
|
# 'tool_groups_name': item.tool_groups_id.name,
|
|
|
|
|
# 'production_line': item.production_line_id.name,
|
|
|
|
|
# 'machine_tool_id': item.maintenance_equipment_id.code,
|
|
|
|
|
# 'machine_tool_code': item.machine_tool_code,
|
|
|
|
|
# 'cutter_spacing_code': item.cutter_spacing_code_id.code,
|
|
|
|
|
# 'functional_tool_name': item.name,
|
|
|
|
|
# 'barcode': item.barcode_id.name,
|
|
|
|
|
# 'mrs_cutting_tool_type_code': item.mrs_cutting_tool_type_id.code,
|
|
|
|
|
# 'diameter': item.diameter,
|
|
|
|
|
# 'knife_tip_r_angle': item.knife_tip_r_angle,
|
|
|
|
|
# 'install_tool_time': item.install_tool_time.strftime('%Y-%m-%d %H:%M:%S'),
|
|
|
|
|
# 'on_board_time': item.on_board_time.strftime('%Y-%m-%d %H:%M:%S'),
|
|
|
|
|
# 'max_lifetime_value': item.max_lifetime_value,
|
|
|
|
|
# 'alarm_value': item.alarm_value,
|
|
|
|
|
# 'used_value': item.used_value,
|
|
|
|
|
# 'functional_tool_status': item.functional_tool_status,
|
|
|
|
|
# 'alarm_time': item.alarm_time.strftime('%Y-%m-%d %H:%M:%S'),
|
|
|
|
|
# 'dispose_user': item.dispose_user,
|
|
|
|
|
# 'dispose_time': item.dispose_time,
|
|
|
|
|
# 'dispose_func': item.dispose_func,
|
|
|
|
|
# }
|
|
|
|
|
# tool_warning_list.append(val)
|
|
|
|
|
# kw = json.dumps(tool_warning_list, ensure_ascii=False)
|
|
|
|
|
# r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
|
|
|
|
# ret = r.json()
|
|
|
|
|
# if ret.get('code') == 200:
|
|
|
|
|
# return "功能刀具预警注册成功"
|
|
|
|
|
# else:
|
|
|
|
|
# logging.info('没有注册功能刀具预警信息')
|
|
|
|
|
# except Exception as e:
|
|
|
|
|
# logging.info("捕获错误信息:%s" % e)
|
|
|
|
|
#
|
|
|
|
|
# @api.model_create_multi
|
|
|
|
|
# def create(self, vals_list):
|
|
|
|
|
# records = super(FunctionalToolWarning, self).create(vals_list)
|
|
|
|
|
# for record in records:
|
|
|
|
|
# if record:
|
|
|
|
|
# record.enroll_functional_tool_warning()
|
|
|
|
|
# return records
|
|
|
|
|
#
|
|
|
|
|
#
|
|
|
|
|
# class StockMoveLine(models.Model):
|
|
|
|
|
# _inherit = 'stock.move.line'
|
|
|
|
|
# _description = '功能刀具出入库记录注册'
|
|
|
|
|
#
|
|
|
|
|
# crea_url = "/api/functional_tool_move/create"
|
|
|
|
|
#
|
|
|
|
|
# # 注册同步功能刀具出入库记录
|
|
|
|
|
# def enroll_functional_tool_move(self):
|
|
|
|
|
# logging.info('调用功能刀具出入库记录注册接口: enroll_functional_tool_move()')
|
|
|
|
|
# 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)
|
|
|
|
|
# str_url = sf_sync_config['sf_url'] + self.crea_url
|
|
|
|
|
# objs_all = self.env['stock.move.line'].search([('id', '=', self.id), ('functional_tool_name_id', '!=', False)])
|
|
|
|
|
# self.get_sync_stock_move_line(objs_all, str_url, token, headers)
|
|
|
|
|
#
|
|
|
|
|
# def sync_enroll_functional_tool_move_all(self):
|
|
|
|
|
# logging.info('调用功能刀具出入库记录注册接口: sync_enroll_functional_tool_move_all()')
|
|
|
|
|
# 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)
|
|
|
|
|
# str_url = sf_sync_config['sf_url'] + self.crea_url
|
|
|
|
|
# objs_all = self.env['stock.move.line'].search([('functional_tool_name_id', '!=', False)])
|
|
|
|
|
# self.get_sync_stock_move_line(objs_all, str_url, token, headers)
|
|
|
|
|
#
|
|
|
|
|
# def get_sync_stock_move_line(self, objs_all, str_url, token, headers):
|
|
|
|
|
# tool_stock_list = []
|
|
|
|
|
# try:
|
|
|
|
|
# if objs_all:
|
|
|
|
|
# for item in objs_all:
|
|
|
|
|
# val = {
|
|
|
|
|
# 'id': item.id,
|
|
|
|
|
# 'name': item.functional_tool_name,
|
|
|
|
|
# 'code': item.code,
|
|
|
|
|
# 'rfid': item.rfid,
|
|
|
|
|
# 'tool_groups_name': item.tool_groups_id.name,
|
|
|
|
|
# 'reference': item.reference,
|
|
|
|
|
# 'barcode': item.lot_id.name,
|
|
|
|
|
# 'functional_tool_type_code': item.functional_tool_type_id.code,
|
|
|
|
|
# 'diameter': item.diameter,
|
|
|
|
|
# 'knife_tip_r_angle': item.knife_tip_r_angle,
|
|
|
|
|
# 'install_tool_time': item.install_tool_time.strftime('%Y-%m-%d %H:%M:%S'),
|
|
|
|
|
# 'location_id': item.location_id.name,
|
|
|
|
|
# 'location_dest_name': item.location_dest_id.name,
|
|
|
|
|
# 'date': item.date.strftime('%Y-%m-%d %H:%M:%S'),
|
|
|
|
|
# 'qty_done': item.qty_done,
|
|
|
|
|
# }
|
|
|
|
|
# tool_stock_list.append(val)
|
|
|
|
|
# kw = json.dumps(tool_stock_list, ensure_ascii=False)
|
|
|
|
|
# r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
|
|
|
|
# ret = r.json()
|
|
|
|
|
# if ret.get('code') == 200:
|
|
|
|
|
# return "功能刀具出入库记录注册成功"
|
|
|
|
|
# else:
|
|
|
|
|
# logging.info('没有注册功能刀具出入库记录信息')
|
|
|
|
|
# except Exception as e:
|
|
|
|
|
# logging.info("捕获错误信息:%s" % e)
|
|
|
|
|
#
|
|
|
|
|
# @api.model_create_multi
|
|
|
|
|
# def create(self, vals_list):
|
|
|
|
|
# records = super(StockMoveLine, self).create(vals_list)
|
|
|
|
|
# for record in records:
|
|
|
|
|
# if record.functional_tool_name_id:
|
|
|
|
|
# record.enroll_functional_tool_move()
|
|
|
|
|
# return records
|
|
|
|
|
#
|
|
|
|
|
#
|
|
|
|
|
# class RealTimeDistributionFunctionalTools(models.Model):
|
|
|
|
|
# _inherit = 'sf.real.time.distribution.of.functional.tools'
|
|
|
|
|
# _description = '功能刀具安全库存注册'
|
|
|
|
|
#
|
|
|
|
|
# crea_url = "/api/functional_tool_distribution/create"
|
|
|
|
|
#
|
|
|
|
|
# # 注册同步功能刀具预警
|
|
|
|
|
# def enroll_functional_tool_real_time_distribution(self):
|
|
|
|
|
# logging.info('调用功能刀具安全库存注册接口: enroll_functional_tool_real_time_distribution()')
|
|
|
|
|
# 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)
|
|
|
|
|
# str_url = sf_sync_config['sf_url'] + self.crea_url
|
|
|
|
|
# objs_all = self.env['sf.real.time.distribution.of.functional.tools'].search([('id', '=', self.id)])
|
|
|
|
|
# self.get_sync_real_time_distribution_functional_tools(objs_all, str_url, token, headers)
|
|
|
|
|
#
|
|
|
|
|
# def sync_enroll_functional_tool_real_time_distribution_all(self):
|
|
|
|
|
# logging.info('调用功能刀具安全库存注册接口: sync_enroll_functional_tool_real_time_distribution_all()')
|
|
|
|
|
# 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)
|
|
|
|
|
# str_url = sf_sync_config['sf_url'] + self.crea_url
|
|
|
|
|
# objs_all = self.env['sf.real.time.distribution.of.functional.tools'].search([])
|
|
|
|
|
# self.get_sync_real_time_distribution_functional_tools(objs_all, str_url, token, headers)
|
|
|
|
|
#
|
|
|
|
|
# def get_sync_real_time_distribution_functional_tools(self, objs_all, str_url, token, headers):
|
|
|
|
|
# tool_distribution_list = []
|
|
|
|
|
# try:
|
|
|
|
|
# if objs_all:
|
|
|
|
|
# for item in objs_all:
|
|
|
|
|
# functional_tool_codes = []
|
|
|
|
|
# for obj in item.sf_functional_tool_entity_ids:
|
|
|
|
|
# functional_tool_codes.append(obj.code)
|
|
|
|
|
# val = {
|
|
|
|
|
# 'id': item.id,
|
|
|
|
|
# 'name': item.name,
|
|
|
|
|
# 'tool_groups_name': item.tool_groups_id.name,
|
|
|
|
|
# 'cutting_tool_type_code': item.sf_cutting_tool_type_id.code,
|
|
|
|
|
# 'diameter': item.diameter,
|
|
|
|
|
# 'knife_tip_r_angle': item.knife_tip_r_angle,
|
|
|
|
|
# 'tool_stock_num': item.tool_stock_num,
|
|
|
|
|
# 'side_shelf_num': item.side_shelf_num,
|
|
|
|
|
# 'on_tool_stock_num': item.on_tool_stock_num,
|
|
|
|
|
# 'tool_stock_total': item.tool_stock_total,
|
|
|
|
|
# 'min_stock_num': item.min_stock_num,
|
|
|
|
|
# 'max_stock_num': item.max_stock_num,
|
|
|
|
|
# 'batch_replenishment_num': item.batch_replenishment_num,
|
|
|
|
|
# 'unit': item.unit,
|
|
|
|
|
# 'image': '' if not item.image else base64.b64encode(item.image).decode('utf-8'),
|
|
|
|
|
# 'functional_tool_codes': str(functional_tool_codes),
|
|
|
|
|
# 'coarse_middle_thin': item.coarse_middle_thin,
|
|
|
|
|
# 'whether_standard_knife': item.whether_standard_knife,
|
|
|
|
|
# 'suitable_machining_method_names': get_suitable_machining_method_names(item),
|
|
|
|
|
# 'blade_tip_characteristics_name': item.blade_tip_characteristics_id.name,
|
|
|
|
|
# 'handle_type_name': item.handle_type_id.name,
|
|
|
|
|
# 'cutting_direction_names': get_cutting_direction_names(item),
|
|
|
|
|
# 'suitable_coolant_names': get_suitable_coolant_names(item),
|
|
|
|
|
# 'active': item.active
|
|
|
|
|
# }
|
|
|
|
|
# tool_distribution_list.append(val)
|
|
|
|
|
# kw = json.dumps(tool_distribution_list, ensure_ascii=False)
|
|
|
|
|
# r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
|
|
|
|
# ret = r.json()
|
|
|
|
|
# if ret.get('code') == 200:
|
|
|
|
|
# return "功能刀具出入库记录注册成功"
|
|
|
|
|
# else:
|
|
|
|
|
# logging.info('没有注册功能刀具出入库记录信息')
|
|
|
|
|
# except Exception as e:
|
|
|
|
|
# logging.info("捕获错误信息:%s" % e)
|
|
|
|
|
#
|
|
|
|
|
# @api.model_create_multi
|
|
|
|
|
# def create(self, vals_list):
|
|
|
|
|
# records = super(RealTimeDistributionFunctionalTools, self).create(vals_list)
|
|
|
|
|
# for record in records:
|
|
|
|
|
# if record:
|
|
|
|
|
# record.enroll_functional_tool_real_time_distribution()
|
|
|
|
|
# return records
|
|
|
|
|
#
|
|
|
|
|
# def write(self, vals):
|
|
|
|
|
# res = super().write(vals)
|
|
|
|
|
# if vals.get('sf_functional_tool_entity_ids') or vals.get('min_stock_num') or vals.get('max_stock_num'):
|
|
|
|
|
# self.enroll_functional_tool_real_time_distribution()
|
|
|
|
|
# return res
|
|
|
|
|
|
|
|
|
|
class FunctionalToolWarning(models.Model):
|
|
|
|
|
_inherit = 'sf.functional.tool.warning'
|
|
|
|
|
_description = '功能刀具预警注册'
|
|
|
|
|
|
|
|
|
|
crea_url = "/api/functional_tool_warning/create"
|
|
|
|
|
|
|
|
|
|
# 注册同步功能刀具预警
|
|
|
|
|
def enroll_functional_tool_warning(self):
|
|
|
|
|
logging.info('调用功能刀具预警注册接口: enroll_functional_tool_warning()')
|
|
|
|
|
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)
|
|
|
|
|
str_url = sf_sync_config['sf_url'] + self.crea_url
|
|
|
|
|
objs_all = self.env['sf.functional.tool.warning'].search([('id', '=', self.id)])
|
|
|
|
|
self.get_sync_functional_tool_warning(objs_all, str_url, token, headers)
|
|
|
|
|
|
|
|
|
|
def sync_enroll_functional_tool_warning_all(self):
|
|
|
|
|
logging.info('调用功能刀具预警注册接口: sync_enroll_functional_tool_warning_all()')
|
|
|
|
|
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)
|
|
|
|
|
str_url = sf_sync_config['sf_url'] + self.crea_url
|
|
|
|
|
objs_all = self.env['sf.functional.tool.warning'].search([])
|
|
|
|
|
self.get_sync_functional_tool_warning(objs_all, str_url, token, headers)
|
|
|
|
|
|
|
|
|
|
def get_sync_functional_tool_warning(self, objs_all, str_url, token, headers):
|
|
|
|
|
tool_warning_list = []
|
|
|
|
|
try:
|
|
|
|
|
if objs_all:
|
|
|
|
|
for item in objs_all:
|
|
|
|
|
val = {
|
|
|
|
|
'id': item.id,
|
|
|
|
|
'name': item.name,
|
|
|
|
|
'code': item.code,
|
|
|
|
|
'rfid': item.rfid,
|
|
|
|
|
'tool_groups_name': item.tool_groups_id.name,
|
|
|
|
|
'production_line': item.production_line_id.name,
|
|
|
|
|
'machine_tool_id': item.maintenance_equipment_id.code,
|
|
|
|
|
'machine_tool_code': item.machine_tool_code,
|
|
|
|
|
'cutter_spacing_code': item.cutter_spacing_code_id.code,
|
|
|
|
|
'functional_tool_name': item.name,
|
|
|
|
|
'barcode': item.barcode_id.name,
|
|
|
|
|
'mrs_cutting_tool_type_code': item.mrs_cutting_tool_type_id.code,
|
|
|
|
|
'diameter': item.diameter,
|
|
|
|
|
'knife_tip_r_angle': item.knife_tip_r_angle,
|
|
|
|
|
'install_tool_time': item.install_tool_time.strftime('%Y-%m-%d %H:%M:%S'),
|
|
|
|
|
'on_board_time': item.on_board_time.strftime('%Y-%m-%d %H:%M:%S'),
|
|
|
|
|
'max_lifetime_value': item.max_lifetime_value,
|
|
|
|
|
'alarm_value': item.alarm_value,
|
|
|
|
|
'used_value': item.used_value,
|
|
|
|
|
'functional_tool_status': item.functional_tool_status,
|
|
|
|
|
'alarm_time': item.alarm_time.strftime('%Y-%m-%d %H:%M:%S'),
|
|
|
|
|
'dispose_user': item.dispose_user,
|
|
|
|
|
'dispose_time': item.dispose_time,
|
|
|
|
|
'dispose_func': item.dispose_func,
|
|
|
|
|
}
|
|
|
|
|
tool_warning_list.append(val)
|
|
|
|
|
kw = json.dumps(tool_warning_list, ensure_ascii=False)
|
|
|
|
|
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
|
|
|
|
ret = r.json()
|
|
|
|
|
if ret.get('code') == 200:
|
|
|
|
|
return "功能刀具预警注册成功"
|
|
|
|
|
else:
|
|
|
|
|
logging.info('没有注册功能刀具预警信息')
|
|
|
|
|
except Exception as e:
|
|
|
|
|
logging.info("捕获错误信息:%s" % e)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class StockMoveLine(models.Model):
|
|
|
|
|
_inherit = 'stock.move.line'
|
|
|
|
|
_description = '功能刀具出入库记录注册'
|
|
|
|
|
|
|
|
|
|
crea_url = "/api/functional_tool_move/create"
|
|
|
|
|
|
|
|
|
|
# 注册同步功能刀具出入库记录
|
|
|
|
|
def enroll_functional_tool_move(self):
|
|
|
|
|
logging.info('调用功能刀具出入库记录注册接口: enroll_functional_tool_move()')
|
|
|
|
|
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)
|
|
|
|
|
str_url = sf_sync_config['sf_url'] + self.crea_url
|
|
|
|
|
objs_all = self.env['stock.move.line'].search([('id', '=', self.id), ('functional_tool_name_id', '!=', False)])
|
|
|
|
|
self.get_sync_stock_move_line(objs_all, str_url, token, headers)
|
|
|
|
|
|
|
|
|
|
def sync_enroll_functional_tool_move_all(self):
|
|
|
|
|
logging.info('调用功能刀具出入库记录注册接口: sync_enroll_functional_tool_move_all()')
|
|
|
|
|
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)
|
|
|
|
|
str_url = sf_sync_config['sf_url'] + self.crea_url
|
|
|
|
|
objs_all = self.env['stock.move.line'].search([('functional_tool_name_id', '!=', False)])
|
|
|
|
|
self.get_sync_stock_move_line(objs_all, str_url, token, headers)
|
|
|
|
|
|
|
|
|
|
def get_sync_stock_move_line(self, objs_all, str_url, token, headers):
|
|
|
|
|
tool_stock_list = []
|
|
|
|
|
try:
|
|
|
|
|
if objs_all:
|
|
|
|
|
for item in objs_all:
|
|
|
|
|
val = {
|
|
|
|
|
'id': item.id,
|
|
|
|
|
'name': item.functional_tool_name,
|
|
|
|
|
'code': item.code,
|
|
|
|
|
'rfid': item.rfid,
|
|
|
|
|
'tool_groups_name': item.tool_groups_id.name,
|
|
|
|
|
'reference': item.reference,
|
|
|
|
|
'barcode': item.lot_id.name,
|
|
|
|
|
'functional_tool_type_code': item.functional_tool_type_id.code,
|
|
|
|
|
'diameter': item.diameter,
|
|
|
|
|
'knife_tip_r_angle': item.knife_tip_r_angle,
|
|
|
|
|
'install_tool_time': item.install_tool_time.strftime('%Y-%m-%d %H:%M:%S'),
|
|
|
|
|
'location_id': item.location_id.name,
|
|
|
|
|
'location_dest_name': item.location_dest_id.name,
|
|
|
|
|
'date': item.date.strftime('%Y-%m-%d %H:%M:%S'),
|
|
|
|
|
'qty_done': item.qty_done,
|
|
|
|
|
}
|
|
|
|
|
tool_stock_list.append(val)
|
|
|
|
|
kw = json.dumps(tool_stock_list, ensure_ascii=False)
|
|
|
|
|
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
|
|
|
|
ret = r.json()
|
|
|
|
|
if ret.get('code') == 200:
|
|
|
|
|
return "功能刀具出入库记录注册成功"
|
|
|
|
|
else:
|
|
|
|
|
logging.info('没有注册功能刀具出入库记录信息')
|
|
|
|
|
except Exception as e:
|
|
|
|
|
logging.info("捕获错误信息:%s" % e)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RealTimeDistributionFunctionalTools(models.Model):
|
|
|
|
|
_inherit = 'sf.real.time.distribution.of.functional.tools'
|
|
|
|
|
_description = '功能刀具安全库存注册'
|
|
|
|
|
|
|
|
|
|
crea_url = "/api/functional_tool_distribution/create"
|
|
|
|
|
|
|
|
|
|
# 注册同步功能刀具预警
|
|
|
|
|
def enroll_functional_tool_real_time_distribution(self):
|
|
|
|
|
logging.info('调用功能刀具安全库存注册接口: enroll_functional_tool_real_time_distribution()')
|
|
|
|
|
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)
|
|
|
|
|
str_url = sf_sync_config['sf_url'] + self.crea_url
|
|
|
|
|
objs_all = self.env['sf.real.time.distribution.of.functional.tools'].search([('id', '=', self.id)])
|
|
|
|
|
self.get_sync_real_time_distribution_functional_tools(objs_all, str_url, token, headers)
|
|
|
|
|
|
|
|
|
|
def sync_enroll_functional_tool_real_time_distribution_all(self):
|
|
|
|
|
logging.info('调用功能刀具安全库存注册接口: sync_enroll_functional_tool_real_time_distribution_all()')
|
|
|
|
|
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)
|
|
|
|
|
str_url = sf_sync_config['sf_url'] + self.crea_url
|
|
|
|
|
objs_all = self.env['sf.real.time.distribution.of.functional.tools'].search([])
|
|
|
|
|
self.get_sync_real_time_distribution_functional_tools(objs_all, str_url, token, headers)
|
|
|
|
|
|
|
|
|
|
def get_sync_real_time_distribution_functional_tools(self, objs_all, str_url, token, headers):
|
|
|
|
|
tool_distribution_list = []
|
|
|
|
|
try:
|
|
|
|
|
if objs_all:
|
|
|
|
|
for item in objs_all:
|
|
|
|
|
functional_tool_codes = []
|
|
|
|
|
for obj in item.sf_functional_tool_entity_ids:
|
|
|
|
|
functional_tool_codes.append(obj.code)
|
|
|
|
|
val = {
|
|
|
|
|
'id': item.id,
|
|
|
|
|
'name': item.name,
|
|
|
|
|
'tool_groups_name': item.tool_groups_id.name,
|
|
|
|
|
'cutting_tool_type_code': item.sf_cutting_tool_type_id.code,
|
|
|
|
|
'diameter': item.diameter,
|
|
|
|
|
'knife_tip_r_angle': item.knife_tip_r_angle,
|
|
|
|
|
'tool_stock_num': item.tool_stock_num,
|
|
|
|
|
'side_shelf_num': item.side_shelf_num,
|
|
|
|
|
'on_tool_stock_num': item.on_tool_stock_num,
|
|
|
|
|
'tool_stock_total': item.tool_stock_total,
|
|
|
|
|
'min_stock_num': item.min_stock_num,
|
|
|
|
|
'max_stock_num': item.max_stock_num,
|
|
|
|
|
'batch_replenishment_num': item.batch_replenishment_num,
|
|
|
|
|
'unit': item.unit,
|
|
|
|
|
'image': '' if not item.image else base64.b64encode(item.image).decode('utf-8'),
|
|
|
|
|
'functional_tool_codes': str(functional_tool_codes),
|
|
|
|
|
'coarse_middle_thin': item.coarse_middle_thin,
|
|
|
|
|
'whether_standard_knife': item.whether_standard_knife,
|
|
|
|
|
'suitable_machining_method_names': get_suitable_machining_method_names(item),
|
|
|
|
|
'blade_tip_characteristics_name': item.blade_tip_characteristics_id.name,
|
|
|
|
|
'handle_type_name': item.handle_type_id.name,
|
|
|
|
|
'cutting_direction_names': get_cutting_direction_names(item),
|
|
|
|
|
'suitable_coolant_names': get_suitable_coolant_names(item),
|
|
|
|
|
'active': item.active
|
|
|
|
|
}
|
|
|
|
|
tool_distribution_list.append(val)
|
|
|
|
|
kw = json.dumps(tool_distribution_list, ensure_ascii=False)
|
|
|
|
|
r = requests.post(str_url, json={}, data={'kw': kw, 'token': token}, headers=headers)
|
|
|
|
|
ret = r.json()
|
|
|
|
|
if ret.get('code') == 200:
|
|
|
|
|
return "功能刀具出入库记录注册成功"
|
|
|
|
|
else:
|
|
|
|
|
logging.info('没有注册功能刀具出入库记录信息')
|
|
|
|
|
except Exception as e:
|
|
|
|
|
logging.info("捕获错误信息:%s" % e)
|
|
|
|
|
|