获取数据按钮增加调用服务功能
This commit is contained in:
@@ -16,6 +16,7 @@ class ResBFMConfigSettings(models.TransientModel):
|
|||||||
# ("https://bfm.jikimo.com", "正式环境(https://bfm.jikimo.com)")], string='bfm环境', store=True)
|
# ("https://bfm.jikimo.com", "正式环境(https://bfm.jikimo.com)")], string='bfm环境', store=True)
|
||||||
|
|
||||||
bfm_url_new = fields.Char('业务平台环境路径', placeholder='请输入当前对应的业务平台环境路径')
|
bfm_url_new = fields.Char('业务平台环境路径', placeholder='请输入当前对应的业务平台环境路径')
|
||||||
|
get_check_file_path = fields.Char('获取检查文件路径', default='')
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
def get_values(self):
|
def get_values(self):
|
||||||
@@ -26,9 +27,11 @@ class ResBFMConfigSettings(models.TransientModel):
|
|||||||
values = super(ResBFMConfigSettings, self).get_values()
|
values = super(ResBFMConfigSettings, self).get_values()
|
||||||
config = self.env['ir.config_parameter'].sudo()
|
config = self.env['ir.config_parameter'].sudo()
|
||||||
bfm_url_new = config.get_param('bfm_url_new', default='')
|
bfm_url_new = config.get_param('bfm_url_new', default='')
|
||||||
|
get_check_file_path = config.get_param('get_check_file_path', default='')
|
||||||
|
|
||||||
values.update(
|
values.update(
|
||||||
bfm_url_new=bfm_url_new,
|
bfm_url_new=bfm_url_new,
|
||||||
|
get_check_file_path=get_check_file_path
|
||||||
)
|
)
|
||||||
return values
|
return values
|
||||||
|
|
||||||
@@ -36,3 +39,4 @@ class ResBFMConfigSettings(models.TransientModel):
|
|||||||
super(ResBFMConfigSettings, self).set_values()
|
super(ResBFMConfigSettings, self).set_values()
|
||||||
ir_config = self.env['ir.config_parameter'].sudo()
|
ir_config = self.env['ir.config_parameter'].sudo()
|
||||||
ir_config.set_param("bfm_url_new", self.bfm_url_new or "")
|
ir_config.set_param("bfm_url_new", self.bfm_url_new or "")
|
||||||
|
ir_config.set_param("get_check_file_path", self.get_check_file_path or "")
|
||||||
|
|||||||
@@ -18,6 +18,21 @@
|
|||||||
<field name="bfm_url_new" string="业务平台访问地址"/>
|
<field name="bfm_url_new" string="业务平台访问地址"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- </div> -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h2>获取检测报告服务配置</h2>
|
||||||
|
<div class="row mt16 o_settings_container" id="jd_api">
|
||||||
|
<div class="col-12 col-lg-6 o_setting_box">
|
||||||
|
<div class="o_setting_left_pane"/>
|
||||||
|
<div class="o_setting_right_pane">
|
||||||
|
<div class="text-muted">
|
||||||
|
<label for="get_check_file_path" />
|
||||||
|
<field name="get_check_file_path" string="检测报告服务地址"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<!-- </div> -->
|
<!-- </div> -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -414,12 +414,10 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
|
|
||||||
# 获取三次元检测点数据
|
# 获取三次元检测点数据
|
||||||
def get_three_check_datas(self):
|
def get_three_check_datas(self):
|
||||||
factory_nick_name = 'XT'
|
|
||||||
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 = FtpController(str(ftp_resconfig['ftp_host']), int(ftp_resconfig['ftp_port']),
|
||||||
ftp_resconfig['ftp_user'],
|
ftp_resconfig['ftp_user'],
|
||||||
ftp_resconfig['ftp_password'])
|
ftp_resconfig['ftp_password'])
|
||||||
# ftp.connect()
|
|
||||||
|
|
||||||
local_dir_path = '/ftp/before'
|
local_dir_path = '/ftp/before'
|
||||||
os.makedirs(local_dir_path, exist_ok=True)
|
os.makedirs(local_dir_path, exist_ok=True)
|
||||||
@@ -428,6 +426,17 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
logging.info('local_file_path:%s' % local_file_path)
|
logging.info('local_file_path:%s' % local_file_path)
|
||||||
remote_path = '/home/ftp/ftp_root/ThreeTest/XT/Before/' + local_filename
|
remote_path = '/home/ftp/ftp_root/ThreeTest/XT/Before/' + local_filename
|
||||||
logging.info('remote_path:%s' % remote_path)
|
logging.info('remote_path:%s' % remote_path)
|
||||||
|
# if not ftp.file_exists(remote_path):
|
||||||
|
paload_data = {
|
||||||
|
"filename": local_filename
|
||||||
|
}
|
||||||
|
if not ftp_resconfig['get_check_file_path']:
|
||||||
|
raise UserError('请先配置获取检测报告地址')
|
||||||
|
url = ftp_resconfig['get_check_file_path'] + '/get/check/report'
|
||||||
|
response = requests.post(url, json=paload_data)
|
||||||
|
logging.info('response:%s' % response.json())
|
||||||
|
if response.json().get('detail'):
|
||||||
|
raise UserError(response.json().get('detail'))
|
||||||
|
|
||||||
if not ftp.file_exists(remote_path):
|
if not ftp.file_exists(remote_path):
|
||||||
raise UserError(f"文件不存在: {remote_path}")
|
raise UserError(f"文件不存在: {remote_path}")
|
||||||
@@ -540,6 +549,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
raise UserError('PT10点未测或数据错误')
|
raise UserError('PT10点未测或数据错误')
|
||||||
|
|
||||||
self.data_state = True
|
self.data_state = True
|
||||||
|
self.getcenter()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
@@ -513,6 +513,11 @@
|
|||||||
|
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|
||||||
|
<xpath expr="//form//header" position="inside">
|
||||||
|
<button type="object" class="oe_highlight" name="get_three_check_datas" string="获取数据"
|
||||||
|
attrs='{"invisible": [("state","!=","progress")]}'/>
|
||||||
|
</xpath>
|
||||||
|
|
||||||
|
|
||||||
<xpath expr="//page[1]" position="before">
|
<xpath expr="//page[1]" position="before">
|
||||||
<field name="results" invisible="1"/>
|
<field name="results" invisible="1"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user