解决冲突
This commit is contained in:
@@ -6,7 +6,7 @@ from odoo.addons.sf_base.decorators.api_log import api_log
|
|||||||
|
|
||||||
class MainController(http.Controller):
|
class MainController(http.Controller):
|
||||||
|
|
||||||
@http.route('/api/manual_download_program', type='json', methods=['POST'], auth='wechat_token', cors='*')
|
@http.route('/api/manual_download_program', type='json', methods=['POST'], auth='public', cors='*')
|
||||||
@api_log('人工线下加工编程文件传输', requester='报工系统')
|
@api_log('人工线下加工编程文件传输', requester='报工系统')
|
||||||
def manual_download_program(self):
|
def manual_download_program(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -1300,9 +1300,6 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
machine_list = ast.literal_eval(kw['machine_list'])
|
machine_list = ast.literal_eval(kw['machine_list'])
|
||||||
time_threshold = datetime.now().replace(hour=0, minute=0, second=0, microsecond=0)
|
time_threshold = datetime.now().replace(hour=0, minute=0, second=0, microsecond=0)
|
||||||
|
|
||||||
alarm_last_24_time = 0.0
|
|
||||||
alarm_all_time = 0.0
|
|
||||||
|
|
||||||
def fetch_result_as_dict(cursor):
|
def fetch_result_as_dict(cursor):
|
||||||
"""辅助函数:将查询结果转为字典"""
|
"""辅助函数:将查询结果转为字典"""
|
||||||
columns = [desc[0] for desc in cursor.description]
|
columns = [desc[0] for desc in cursor.description]
|
||||||
@@ -1311,6 +1308,9 @@ class Sf_Dashboard_Connect(http.Controller):
|
|||||||
# 获取当前时间的时间戳
|
# 获取当前时间的时间戳
|
||||||
current_timestamp = datetime.now().timestamp()
|
current_timestamp = datetime.now().timestamp()
|
||||||
for item in machine_list:
|
for item in machine_list:
|
||||||
|
alarm_last_24_time = 0.0
|
||||||
|
alarm_all_time = 0.0
|
||||||
|
|
||||||
euipment_obj = request.env['maintenance.equipment'].sudo().search([('code', '=', item)])
|
euipment_obj = request.env['maintenance.equipment'].sudo().search([('code', '=', item)])
|
||||||
# 机床上线时间段
|
# 机床上线时间段
|
||||||
first_online_duration = current_timestamp - euipment_obj.first_online_time.timestamp()
|
first_online_duration = current_timestamp - euipment_obj.first_online_time.timestamp()
|
||||||
|
|||||||
@@ -9,8 +9,12 @@ _logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class FTP_P(FTP):
|
class FTP_P(FTP):
|
||||||
"""
|
"""
|
||||||
重写FTP类,重写dirs方法
|
重写FTP类,重写dirs方法,增加编码处理
|
||||||
"""
|
"""
|
||||||
|
def __init__(self, host='', user='', passwd='', acct='', timeout=None, encoding='gbk'):
|
||||||
|
"""初始化时指定编码方式"""
|
||||||
|
super().__init__(host, user, passwd, acct, timeout)
|
||||||
|
self.encoding = encoding
|
||||||
|
|
||||||
def dirs(self, *args):
|
def dirs(self, *args):
|
||||||
"""List a directory in long form.
|
"""List a directory in long form.
|
||||||
@@ -32,7 +36,50 @@ class FTP_P(FTP):
|
|||||||
tempdic['name'] = [file for file in r_files if file != "." and file != ".."]
|
tempdic['name'] = [file for file in r_files if file != "." and file != ".."]
|
||||||
# 去除. ..
|
# 去除. ..
|
||||||
return tempdic
|
return tempdic
|
||||||
# return [file for file in r_files if file != "." and file != ".."]
|
|
||||||
|
def nlst(self, *args):
|
||||||
|
"""Get a list of files in a directory."""
|
||||||
|
files = []
|
||||||
|
def append(line):
|
||||||
|
try:
|
||||||
|
if isinstance(line, bytes):
|
||||||
|
files.append(line.decode(self.encoding))
|
||||||
|
else:
|
||||||
|
files.append(line)
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
files.append(line.decode('utf-8', errors='replace'))
|
||||||
|
cmd = 'NLST'
|
||||||
|
if args:
|
||||||
|
cmd = cmd + ' ' + args[0]
|
||||||
|
self.retrlines(cmd, append)
|
||||||
|
return files
|
||||||
|
|
||||||
|
def cwd(self, dirname):
|
||||||
|
"""Change to a directory."""
|
||||||
|
try:
|
||||||
|
if isinstance(dirname, bytes):
|
||||||
|
dirname = dirname.decode(self.encoding)
|
||||||
|
return super().cwd(dirname)
|
||||||
|
except UnicodeEncodeError:
|
||||||
|
return super().cwd(dirname.encode(self.encoding).decode('utf-8'))
|
||||||
|
|
||||||
|
def storbinary(self, cmd, fp, blocksize=8192, callback=None, rest=None):
|
||||||
|
"""Store a file in binary mode."""
|
||||||
|
try:
|
||||||
|
if isinstance(cmd, bytes):
|
||||||
|
cmd = cmd.decode(self.encoding)
|
||||||
|
return super().storbinary(cmd, fp, blocksize, callback, rest)
|
||||||
|
except UnicodeEncodeError:
|
||||||
|
return super().storbinary(cmd.encode(self.encoding).decode('utf-8'), fp, blocksize, callback, rest)
|
||||||
|
|
||||||
|
def retrbinary(self, cmd, callback, blocksize=8192, rest=None):
|
||||||
|
"""Retrieve a file in binary mode."""
|
||||||
|
try:
|
||||||
|
if isinstance(cmd, bytes):
|
||||||
|
cmd = cmd.decode(self.encoding)
|
||||||
|
return super().retrbinary(cmd, callback, blocksize, rest)
|
||||||
|
except UnicodeEncodeError:
|
||||||
|
return super().retrbinary(cmd.encode(self.encoding).decode('utf-8'), callback, blocksize, rest)
|
||||||
|
|
||||||
|
|
||||||
# FTP接口类
|
# FTP接口类
|
||||||
|
|||||||
Reference in New Issue
Block a user