Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into develop
This commit is contained in:
@@ -21,6 +21,7 @@ class Http(models.AbstractModel):
|
||||
def _auth_method_sf_token(cls):
|
||||
# 从headers.environ中获取对方传过来的token,timestamp,加密的校验字符串
|
||||
datas = request.httprequest.headers.environ
|
||||
_logger.info('datas:%s' % datas)
|
||||
if 'HTTP_TOKEN' in datas:
|
||||
_logger.info('token:%s' % datas['HTTP_TOKEN'])
|
||||
# 查询密钥
|
||||
|
||||
@@ -203,6 +203,7 @@ class Manufacturing_Connect(http.Controller):
|
||||
res = {'Succeed': True, 'Datas': ['工单已结束']}
|
||||
datas = request.httprequest.data
|
||||
ret = json.loads(datas)
|
||||
logging.info('button_Work_End:%s' % ret)
|
||||
request.env['center_control.interface.log'].sudo().create(
|
||||
{'content': ret, 'name': 'AutoDeviceApi/FeedBackEnd'})
|
||||
production_id = ret['BillId']
|
||||
|
||||
@@ -1215,11 +1215,13 @@ class CNCprocessing(models.Model):
|
||||
|
||||
# 将FTP的多面的程序单文件下载到临时目录
|
||||
def download_file_tmp(self, production_no, processing_panel):
|
||||
remotepath = os.path.join('/NC', production_no, 'return', processing_panel)
|
||||
remotepath = os.path.join('/home/ftp/ftp_root/NC', production_no, 'return', processing_panel)
|
||||
serverdir = os.path.join('/tmp', production_no, 'return', processing_panel)
|
||||
ftp_resconfig = self.env['res.config.settings'].get_values()
|
||||
ftp = FtpController(str(ftp_resconfig['ftp_host']), int(ftp_resconfig['ftp_port']), ftp_resconfig['ftp_user'],
|
||||
ftp_resconfig['ftp_password'])
|
||||
if not ftp.file_exists_1(remotepath):
|
||||
logging.info('目录不存在:%s' % remotepath)
|
||||
download_state = ftp.download_program_file(remotepath, serverdir)
|
||||
logging.info('download_state:%s' % download_state)
|
||||
return download_state
|
||||
|
||||
@@ -68,7 +68,6 @@
|
||||
progress,pending_cam,pending_processing,pending_era_cam,completed,done
|
||||
</attribute>
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//sheet//group//group[2]//label" position="before">
|
||||
<!-- <field name="process_state"/> -->
|
||||
<field name="state"/>
|
||||
@@ -79,8 +78,8 @@
|
||||
<field name="programming_no" readonly="1"/>
|
||||
<field name="work_state" invisible="1"/>
|
||||
<field name="schedule_state" invisible='1'/>
|
||||
<field name="manual_quotation" readonly="1"/>
|
||||
<field name="programming_state" readonly="1"/>
|
||||
<field name="manual_quotation" readonly="1"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='user_id']" position="before">
|
||||
<field name="plan_start_processing_time" readonly="1"/>
|
||||
@@ -255,7 +254,9 @@
|
||||
</xpath>
|
||||
|
||||
<xpath expr="//sheet//notebook//page[@name='operations']" position="attributes">
|
||||
<attribute name="attrs">{'invisible': [('schedule_state', '=', '未排')]}</attribute>
|
||||
<attribute name="attrs">{'invisible': ['|',('schedule_state', '=', '未排'),('workorder_ids', '=',
|
||||
[])]}
|
||||
</attribute>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
@@ -31,17 +31,18 @@ class Sf_Mrs_Connect(http.Controller):
|
||||
# 拉取所有加工面的程序文件
|
||||
for r in ret['processing_panel'].split(','):
|
||||
program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r)
|
||||
files_r = os.listdir(program_path_tmp_r)
|
||||
if files_r:
|
||||
for file_name in files_r:
|
||||
file_path = os.path.join(program_path_tmp_r, file_name)
|
||||
os.remove(file_path)
|
||||
if os.path.exists(program_path_tmp_r):
|
||||
files_r = os.listdir(program_path_tmp_r)
|
||||
if files_r:
|
||||
for file_name in files_r:
|
||||
file_path = os.path.join(program_path_tmp_r, file_name)
|
||||
os.remove(file_path)
|
||||
download_state = request.env['sf.cnc.processing'].with_user(
|
||||
request.env.ref("base.user_admin")).download_file_tmp(
|
||||
ret['folder_name'], r)
|
||||
if download_state == 0:
|
||||
res['status'] = -2
|
||||
res['message'] = '制造订单号为%s的CNC程序文件从FTP拉取失败' % (cnc_production.name)
|
||||
res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no'])
|
||||
return json.JSONEncoder().encode(res)
|
||||
for production in productions:
|
||||
if not production.workorder_ids:
|
||||
|
||||
@@ -21,6 +21,27 @@ class FtpController():
|
||||
except Exception:
|
||||
logging.info("ftp连接失败")
|
||||
|
||||
def file_exists_1(self, path):
|
||||
# 检查文件是否存在于FTP服务器上
|
||||
try:
|
||||
logging.info("path:%s" % path)
|
||||
logging.info("dirname:%s" % os.path.dirname(path))
|
||||
directories = os.path.normpath(path).split(os.path.sep)
|
||||
# 切换到上级目录
|
||||
current_dir = '/'
|
||||
for directory in directories:
|
||||
if directory:
|
||||
# 检查目录是否存在
|
||||
if directory in ['NC']:
|
||||
self.ftp.cwd(directory)
|
||||
if directory not in ['home', 'ftp', 'ftp_root', 'NC']:
|
||||
# 切换到新的目录
|
||||
self.ftp.cwd(current_dir)
|
||||
return os.path.basename(path)
|
||||
except Exception as e:
|
||||
logging.error(f"Error checking file: {e}")
|
||||
return False
|
||||
|
||||
def file_exists(self, path):
|
||||
# 检查文件是否存在于FTP服务器上
|
||||
try:
|
||||
@@ -32,8 +53,23 @@ class FtpController():
|
||||
logging.error(f"Error checking file: {e}")
|
||||
return False
|
||||
|
||||
|
||||
|
||||
# 下载目录下的pdf文件(程序单)
|
||||
def download_program_file(self, target_dir, serverdir):
|
||||
if not os.path.exists(serverdir):
|
||||
os.makedirs(serverdir)
|
||||
try:
|
||||
logging.info('FTP目录:%s' % target_dir)
|
||||
logging.info("进入FTP目录 ")
|
||||
# self.ftp.cwd(target_dir) # 切换工作路径
|
||||
# logging.info('FTP目录:%s' % target_dir)
|
||||
remotenames = self.ftp.nlst()
|
||||
logging.info('FTP目录文件:%s' % remotenames)
|
||||
for file in remotenames:
|
||||
server = os.path.join(serverdir, file)
|
||||
if file.find(".pdf") != -1:
|
||||
self.download_file(server, file)
|
||||
except:
|
||||
return False
|
||||
|
||||
# # 检测字符串的编码
|
||||
# def detect_encoding(self, s):
|
||||
|
||||
Reference in New Issue
Block a user