Merge branch 'develop' of https://e.coding.net/jikimo-hn/jikimo_sfs/jikimo_sf into feature/制造订单列表页及详情页优化需求

This commit is contained in:
mgw
2024-06-26 14:11:45 +08:00
6 changed files with 59 additions and 18 deletions

View File

@@ -21,6 +21,7 @@ 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
_logger.info('datas:%s' % 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'])
# 查询密钥 # 查询密钥

View File

@@ -203,6 +203,7 @@ class Manufacturing_Connect(http.Controller):
res = {'Succeed': True, 'Datas': ['工单已结束']} res = {'Succeed': True, 'Datas': ['工单已结束']}
datas = request.httprequest.data datas = request.httprequest.data
ret = json.loads(datas) ret = json.loads(datas)
logging.info('button_Work_End:%s' % ret)
request.env['center_control.interface.log'].sudo().create( request.env['center_control.interface.log'].sudo().create(
{'content': ret, 'name': 'AutoDeviceApi/FeedBackEnd'}) {'content': ret, 'name': 'AutoDeviceApi/FeedBackEnd'})
production_id = ret['BillId'] production_id = ret['BillId']

View File

@@ -1215,11 +1215,13 @@ class CNCprocessing(models.Model):
# 将FTP的多面的程序单文件下载到临时目录 # 将FTP的多面的程序单文件下载到临时目录
def download_file_tmp(self, production_no, processing_panel): 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) serverdir = os.path.join('/tmp', production_no, 'return', processing_panel)
ftp_resconfig = self.env['res.config.settings'].get_values() 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 = FtpController(str(ftp_resconfig['ftp_host']), int(ftp_resconfig['ftp_port']), ftp_resconfig['ftp_user'],
ftp_resconfig['ftp_password']) ftp_resconfig['ftp_password'])
if not ftp.file_exists_1(remotepath):
logging.info('目录不存在:%s' % remotepath)
download_state = ftp.download_program_file(remotepath, serverdir) download_state = ftp.download_program_file(remotepath, serverdir)
logging.info('download_state:%s' % download_state) logging.info('download_state:%s' % download_state)
return download_state return download_state

View File

@@ -68,7 +68,6 @@
draft,confirmed,progress,completed,done draft,confirmed,progress,completed,done
</attribute> </attribute>
</xpath> </xpath>
<xpath expr="//sheet//group//group[2]//label" position="before"> <xpath expr="//sheet//group//group[2]//label" position="before">
<!-- <field name="process_state"/> --> <!-- <field name="process_state"/> -->
<field name="state"/> <field name="state"/>
@@ -79,8 +78,8 @@
<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="schedule_state" invisible='1'/> <field name="schedule_state" invisible='1'/>
<field name="manual_quotation" readonly="1"/>
<field name="programming_state" readonly="1"/> <field name="programming_state" readonly="1"/>
<field name="manual_quotation" readonly="1"/>
</xpath> </xpath>
<xpath expr="//field[@name='user_id']" position="before"> <xpath expr="//field[@name='user_id']" position="before">
<field name="plan_start_processing_time" readonly="1"/> <field name="plan_start_processing_time" readonly="1"/>
@@ -255,7 +254,9 @@
</xpath> </xpath>
<xpath expr="//sheet//notebook//page[@name='operations']" position="attributes"> <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> </xpath>
</field> </field>
</record> </record>

View File

@@ -31,18 +31,19 @@ class Sf_Mrs_Connect(http.Controller):
# 拉取所有加工面的程序文件 # 拉取所有加工面的程序文件
for r in ret['processing_panel'].split(','): for r in ret['processing_panel'].split(','):
program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r) program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r)
files_r = os.listdir(program_path_tmp_r) if os.path.exists(program_path_tmp_r):
if files_r: files_r = os.listdir(program_path_tmp_r)
for file_name in files_r: if files_r:
file_path = os.path.join(program_path_tmp_r, file_name) for file_name in files_r:
os.remove(file_path) file_path = os.path.join(program_path_tmp_r, file_name)
download_state = request.env['sf.cnc.processing'].with_user( os.remove(file_path)
request.env.ref("base.user_admin")).download_file_tmp( download_state = request.env['sf.cnc.processing'].with_user(
ret['folder_name'], r) request.env.ref("base.user_admin")).download_file_tmp(
if download_state == 0: ret['folder_name'], r)
res['status'] = -2 if download_state == 0:
res['message'] = '制造订单号为%s的CNC程序文件从FTP拉取失败' % (cnc_production.name) res['status'] = -2
return json.JSONEncoder().encode(res) res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no'])
return json.JSONEncoder().encode(res)
for production in productions: for production in productions:
if not production.workorder_ids: if not production.workorder_ids:
production.product_id.model_processing_panel = ret['processing_panel'] production.product_id.model_processing_panel = ret['processing_panel']

View File

@@ -21,6 +21,27 @@ class FtpController():
except Exception: except Exception:
logging.info("ftp连接失败") 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']) or (directory not in ['home', 'ftp', 'ftp_root', 'NC']):
self.ftp.cwd(directory)
if directory not in ['home', 'ftp', 'ftp_root', 'NC']:
# 切换到新的目录
self.ftp.cwd(directory)
return os.path.basename(path)
except Exception as e:
logging.error(f"Error checking file: {e}")
return False
def file_exists(self, path): def file_exists(self, path):
# 检查文件是否存在于FTP服务器上 # 检查文件是否存在于FTP服务器上
try: try:
@@ -32,8 +53,22 @@ class FtpController():
logging.error(f"Error checking file: {e}") logging.error(f"Error checking file: {e}")
return False 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目录 ")
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)
return True
except:
return False
# # 检测字符串的编码 # # 检测字符串的编码
# def detect_encoding(self, s): # def detect_encoding(self, s):